Removed unnecessary comment
[automake.git] / automake.in
blob640d7947783a0b38b44f08f14c289a176387c87d
1 #! /bin/sh
2 # @configure_input@
4 # automake - create Makefile.in from Makefile.am
5 # Copyright (C) 1994 Free Software Foundation, Inc.
7 # This program is free software; you can redistribute it and/or modify
8 # it under the terms of the GNU General Public License as published by
9 # the Free Software Foundation; either version 2, or (at your option)
10 # any later version.
12 # This program is distributed in the hope that it will be useful,
13 # but WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 # GNU General Public License for more details.
17 # You should have received a copy of the GNU General Public License
18 # along with this program; if not, write to the Free Software
19 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
21 # Sample usage: automake Makefile lib/Makefile src/Makefile man/Makefile
22 # Written by David Mackenzie <djm@gnu.ai.mit.edu>.
24 # Caveat: must use all lowercase variables in this file. User
25 # Makefile.am can cause any uppercase variable to be set.
27 version=@VERSION@
29 # We need prefix because datadir might depend on it.
30 prefix=@prefix@
31 am_dir=@datadir@/automake
33 usage="Usage: automake [--help] [--version] [Makefile]..."
35 # These are commonly found files that we look for and automatically
36 # include in DIST_FILES. NOTE if you add something here, make sure
37 # you add it in the right place -- that is, so that the "--help" still
38 # lines up nicely.
39 common='THANKS TODO README NEWS COPYING COPYING.LIB INSTALL NLS ChangeLog configure configure.in config.guess config.sub mkinstalldirs install-sh texinfo.tex'
41 # NLS nuisances.
42 # Only set `LANG' and `LC_ALL' to "C" if already set.
43 # These must not be set unconditionally because not all systems understand
44 # e.g. LANG=C (notably SCO).
45 if test "${LC_ALL+set}" = set; then LC_ALL=C; export LC_ALL; fi
46 if test "${LANG+set}" = set; then LANG=C; export LANG; fi
48 mfiles=
49 while test $# -gt 0; do
50 case "$1" in
51 --help | --h* )
52 echo $usage
53 echo
54 echo "Files which are automatically distributed, if found:"
55 set $common
56 while test $# -gt 0; do
57 echo " $1 $2"
58 shift
59 shift
60 done
61 exit 0
64 --version | --v* )
65 echo "Automake version $version"
66 exit 0
69 -- ) # Stop option processing.
70 shift
71 break
74 -*)
75 # FIXME consider "-" meaning stdin as input?
76 echo "automake: unrecognized option -- \`$1'" 1>&2
77 echo "${usage}" 1>&2
78 exit 1
81 * )
82 mfiles="$mfiles $1"
84 esac
85 shift
86 done
88 test -n "$mfiles" || {
89 # Look around.
90 mfiles=`echo */Makefile.am`
91 if test "$mfiles" = '*/Makefile.am'; then
92 mfiles=
93 else
94 mfiles=`echo "$mfiles" | sed 's/\.am//g'`
97 if test -f Makefile.am; then
98 mfiles="Makefile $mfiles"
101 if test -n "$mfiles"; then
102 echo "automake: using $mfiles" 1>&2
103 else
104 echo "${usage}" 1>&2
105 exit 1
110 am_status=0
112 # Some handy sed scripts.
113 am_rmnl=$am_dir/nl-remove.sed
114 am_ass=$am_dir/hack-make.sed
116 for am_makefile in $mfiles; do
118 if test ! -f ${am_makefile}.am; then
119 echo "automake: ${am_makefile}.am: No such honkin' file" 1>&2
120 am_status=1
121 continue
124 echo creating ${am_makefile}.in
126 exec 4> ${am_makefile}.vars
127 exec 5> ${am_makefile}.rules
129 echo "# Makefile.in generated automatically by automake $version from Makefile.am." >&4
130 cat $am_dir/header-vars.am >&4
131 cat $am_dir/header.am >&5
133 DEFS= INCLUDES= CPPFLAGS= CFLAGS=
134 SOURCES= CONFIG_HEADER= SUBDIRS= PROGRAMS= LIBPROGRAMS= SCRIPTS= LIBSCRIPTS=
135 LIBRARIES= TEXINFOS= MANS= AM_PROGRAMS=
136 am_suffixes=
138 eval `sed -n -f $am_rmnl ${am_makefile}.am | sed -n -f $am_ass`
141 # If a variable is set at configure time, we still need to know the
142 # values it can assume (statically). This is done using the AM_
143 # forms in the Makefile.am. Handle it now.
145 test -n "$AM_PROGRAMS" && {
146 PROGRAMS=$AM_PROGRAMS
148 test -n "$AM_LIBPROGRAMS" && {
149 LIBPROGRAMS=$AM_LIBPROGRAMS
151 test -n "$AM_SCRIPTS" && {
152 SCRIPTS=$AM_SCRIPTS
154 test -n "$AM_LIBSCRIPTS" && {
155 LIBSCRIPTS=$AM_LIBSCRIPTS
157 test -n "$AM_LIBRARIES" && {
158 LIBRARIES=$AM_LIBRARIES
161 if grep @kr@ ${am_makefile}.am >/dev/null; then
162 kr='${kr}'
163 else
167 if test -n "$PROGRAMS$LIBPROGRAMS$LIBRARIES"; then
168 cat $am_dir/compile-vars.am >&4
169 cat $am_dir/compile.am >&5
171 # Check for automatic de-ANSIfication.
172 if grep @kr@ ${am_makefile}.am >/dev/null; then
173 cat $am_dir/compile-kr.am >&5
174 am_suffixes=".krc .krh .kro $am_suffixes"
177 for am_file in $PROGRAMS $LIBPROGRAMS $LIBRARIES; do
178 if eval "test \"\$var_${am_file}_SOURCES\" = explicit"; then
179 if eval "test \"\$var_${am_file}_OBJECTS\" = explicit"; then
181 else
182 sed -n -f $am_rmnl ${am_makefile}.am |
183 sed -n "/^[ ]*${am_file}_SOURCES[ ]*=/{
184 s/SOURCES/OBJECTS/
185 s/@[^@]*@//g
186 s/\$([^)]*)//g
187 s/\${[^}]*}//g
188 s/\\.cc/.${kr}o/g
189 s/\\.\${kr}c/.${kr}o/g
190 s/\\.\$(kr)c/.${kr}o/g
191 s/\\.[cCmylfs]/.${kr}o/g
193 }" >&4
195 SOURCES="$SOURCES \${${am_file}_SOURCES}"
196 else
197 echo "${am_file}_SOURCES = ${am_file}.c" >&4
198 echo "${am_file}_OBJECTS = ${am_file}.${kr}o" >&4
199 SOURCES="$SOURCES ${am_file}.c"
201 if test -n "$CONFIG_HEADER"; then
202 echo "\$(${am_file}_OBJECTS): $CONFIG_HEADER" >&5
204 done
208 # Boilerplate for scripts or programs.
210 if test -n "$PROGRAMS"; then
211 cat $am_dir/programs.am >&5
213 if test -n "$SCRIPTS"; then
214 cat $am_dir/scripts.am >&5
216 if test -n "$LIBPROGRAMS$LIBSCRIPTS"; then
217 cat $am_dir/libprograms.am >&5
219 if test -n "$LIBSCRIPTS"; then
220 cat $am_dir/libscripts.am >&5
223 if test -n "$PROGRAMS$LIBPROGRAMS$SCRIPTS$LIBSCRIPTS"; then
224 if test -n "$PROGRAMS$LIBPROGRAMS"; then
225 for am_prog in $PROGRAMS $LIBPROGRAMS; do
226 # If `prog_LDADD' is explicitly defined, use it. Otherwise,
227 # use LDADD.
228 eval "test \"\$var_${am_prog}_LDADD\" = explicit" || {
229 # Not set, so set it.
230 echo "${am_prog}_LDADD = \${LDADD}" >&5
233 # Insert rule for this target, unless it is explicitly given
234 # in Makefile.am.
235 eval "test \"\$target_$am_prog\" != explicit" &&
236 sed "s/@PROGRAM@/$am_prog/g" $am_dir/program.am >&5
237 done
241 if test -n "$LIBRARIES"; then
242 echo "LIBFILES = " `echo "$LIBRARIES"|sed 's/\([a-zA-Z0-9_][a-zA-Z0-9_]*\)/lib\1.a/g'` >&4
243 cat $am_dir/libraries-vars.am >&4
244 cat $am_dir/libraries.am >&5
245 for am_lib in $LIBRARIES; do
246 sed "s/@LIBRARY@/$am_lib/g" $am_dir/library.am >&5
247 done
250 if test -n "$TEXINFOS"; then
251 cat $am_dir/texinfos-vars.am >&4
252 cat $am_dir/texinfos.am >&5
253 am_suffixes=".texi .info .dvi $am_suffixes"
254 echo "$TEXINFOS" | sed 's/^/INFOS = /; s/\.texi/.info*/g' >&4
255 echo "$TEXINFOS" | sed 's/^/INFO_DEPS = /; s/\.texi/.info/g' >&4
256 echo "$TEXINFOS" | sed 's/^/DVIS = /; s/\.texi/.dvi/g' >&4
259 if test -n "$MANS"; then
260 cat $am_dir/mans-vars.am >&4
261 cat $am_dir/mans.am >&5
264 case "$SUBDIRS" in
265 "") if grep @kr@ ${am_makefile}.am >/dev/null; then
266 cat $am_dir/clean-kr.am >&5
267 else cat $am_dir/clean.am >&5
269 cat $am_dir/footer.am >&5 ;;
270 *) cat $am_dir/subdirs.am >&5 ;;
271 esac
273 case "$am_makefile" in
274 */*)
275 cat $am_dir/remake-subd.am >&5
278 test -f aclocal.m4 && echo "ACLOCAL = aclocal.m4" >&4
279 cat $am_dir/remake.am >&5
281 esac
283 case "$CONFIG_HEADER" in
284 "") ;;
285 */*) ;; # It's in some other directory, so don't remake it in this one.
287 test -f acconfig.h && echo "ACCONFIG = acconfig.h" >&4
288 test -f config.h.top && echo "CONFIG_TOP = config.h.top" >&4
289 test -f config.h.bot && echo "CONFIG_BOT = config.h.bot" >&4
290 cat $am_dir/remake-hdr.am >&5 ;;
291 esac
293 echo "SOURCES = $SOURCES" >&4
297 # Handle TAGS.
299 case "$am_makefile" in
300 */*)
301 if test -n "${SOURCES}${HEADERS}${ETAGS_ARGS}"; then
302 cat $am_dir/tags-subd.am >&5
306 if test -n "${SUBDIRS}"; then
307 cat $am_dir/tags.am >&5
308 else
309 if test -n "${SOURCES}${HEADERS}${ETAGS_ARGS}"; then
310 cat $am_dir/tags-subd.am >&5
314 esac
317 # Handle "dist" targets.
319 am_reldir=`echo "$am_makefile" | sed 's,//*[^/][^/]*$,,g'`
320 if test "$am_reldir" = "$am_makefile"; then
321 # Bogus.
322 am_reldir=.
324 # Look for certain common files and make sure they are included.
325 dlist=
326 for cfile in $common; do
327 if test -f $am_reldir/$cfile; then
328 dlist="$dlist $cfile"
330 done
331 echo "DIST_COMMON = $dlist" >&4
332 # Include "dist" boilerplate.
333 case "$am_makefile" in
334 */*)
335 cat $am_dir/dist-subd-vars.am >&4
336 echo "subdir = $am_reldir" >&5
337 cat $am_dir/dist-subd.am >&5
340 cat $am_dir/dist-vars.am >&4
341 if test -n "$SUBDIRS"; then
342 cat $am_dir/dist-subd-top.am >&5
343 else
344 cat $am_dir/dist.am >&5
347 esac
350 # Put .SUFFIXES way down at the bottom.
352 if test -n "$am_suffixes"; then
353 echo ".SUFFIXES:" >&5
354 echo ".SUFFIXES: $am_suffixes" >&5
358 # Some final checks.
360 test -z "$TEXINFOS" || test -f $am_reldir/texinfo.tex || {
361 echo "automake: ${am_makefile}.am defines TEXINFOS, but" 1>&2
362 echo "automake: ${am_reldir}/texinfo.tex does not exist" 1>&2
366 sed '/^[^#=]*:/,$d' ${am_makefile}.am >&4
367 sed -n '/^[^#=]*:/,$p' ${am_makefile}.am >&5
368 cat ${am_makefile}.vars ${am_makefile}.rules > ${am_makefile}.in
369 rm -f ${am_makefile}.vars ${am_makefile}.rules
372 done
374 exit $am_status