Always include footer.am in output
[automake.git] / automake.in
blob6c51a5eb7efdfda59bedfdee01df459774bee2b6
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@/@PACKAGE@
33 # These are commonly found files that we look for and automatically
34 # include in DIST_FILES. NOTE if you add something here, make sure
35 # you add it in the right place -- that is, so that the "--help" still
36 # lines up nicely.
37 common='THANKS TODO README NEWS COPYING COPYING.LIB INSTALL ABOUT-NLS ChangeLog configure configure.in config.guess config.sub mkinstalldirs install-sh texinfo.tex acconfig.h config.h.top config.h.bot'
39 # $echo will eventually be used to handle NLS matters.
40 echo=echo
42 mfiles=
43 am_usedeps=yes
44 am_incdeps=no
45 while test $# -gt 0; do
46 case "$1" in
47 --help | --h* )
48 $echo "Usage: automake [OPTION]... [Makefile]..."
49 $echo "\
50 --amdir=DIR directory storing config files
51 --help print this help, then exit
52 --version print version number, then exit
53 --include-deps include generated dependencies in Makefile"
54 echo
55 $echo "Files which are automatically distributed, if found:"
56 set $common
57 while test $# -gt 0; do
58 echo " $1 $2"
59 shift
60 # Ignore errors here, in case we have an odd number.
61 shift 2>/dev/null
62 done
63 exit 0
66 --version | --v* )
67 $echo "Automake version $version"
68 exit 0
71 --amdir=* | --a*=* )
72 am_dir="`echo \"${1}\" | sed -e 's/^[^=]*=//'`"
75 --amdir | --a* )
76 if test $# -eq 1; then
77 $echo "automake: no argument given for option \`$1'" 1>&2
78 exit 1
80 shift
81 am_dir="${1}"
84 --include-deps | --i*)
85 am_incdeps=yes
86 am_usedeps=no
89 -- ) # Stop option processing.
90 shift
91 while test $# -gt 0; do
92 mfiles="$mfiles $1"
93 shift
94 done
95 break
98 -*)
99 # FIXME consider "-" meaning stdin as input?
100 $echo "automake: unrecognized option -- \`$1'" 1>&2
101 exit 1
105 mfiles="$mfiles $1"
107 esac
108 shift
109 done
111 test -n "$mfiles" || {
112 # Look around.
113 mfiles=`echo */Makefile.am`
114 if test "$mfiles" = '*/Makefile.am'; then
115 mfiles=
116 else
117 mfiles=`echo "$mfiles" | sed 's/\.am//g'`
120 if test -f Makefile.am; then
121 mfiles="Makefile $mfiles"
124 if test -n "$mfiles"; then
125 $echo "automake: using $mfiles" 1>&2
126 else
127 $echo "automake: no \"Makefile.am\" found or specified" 1>&2
128 exit 1
133 am_status=0
135 # Some handy sed scripts.
136 am_rmnl=$am_dir/nl-remove.sed
137 am_ass=$am_dir/hack-make.sed
139 for am_makefile in $mfiles; do
140 if test ! -f ${am_makefile}.am; then
141 $echo "automake: ${am_makefile}.am: No such honkin' file" 1>&2
142 am_status=1
143 continue
147 am_localstatus=0
149 $echo "creating ${am_makefile}.in"
151 # Find our directory relative to top.
152 am_reldir=`echo "$am_makefile" | sed 's,//*[^/][^/]*$,,g'`
153 if test "$am_reldir" = "$am_makefile"; then
154 # Bogus.
155 am_reldir=.
158 exec 4> ${am_makefile}.vars
159 exec 5> ${am_makefile}.rules
161 echo "# Makefile.in generated automatically by automake $version from Makefile.am." >&4
162 cat $am_dir/header-vars.am >&4
163 cat $am_dir/header.am >&5
165 DEFS= INCLUDES= CPPFLAGS= CFLAGS=
166 SOURCES= CONFIG_HEADER= SUBDIRS= PROGRAMS= LIBPROGRAMS= SCRIPTS= LIBSCRIPTS=
167 LIBRARIES= TEXINFOS= MANS= AM_PROGRAMS=
168 am_suffixes=
169 # The following are targets that formerly were implemented as
170 # double-colon rules. Nowadays we have to construct such lists
171 # explicitly.
172 installexec= uninstall= id= tags= info= dvi= check=
173 installdata= all='${ALL}' install=
174 am_recursive_install=no
176 eval `sed -n -f $am_rmnl ${am_makefile}.am | sed -n -f $am_ass`
179 # If a variable is set at configure time, we still need to know the
180 # values it can assume (statically). This is done using the AM_
181 # forms in the Makefile.am. Handle it now.
183 test -n "$AM_PROGRAMS" && {
184 PROGRAMS=$AM_PROGRAMS
186 test -n "$AM_LIBPROGRAMS" && {
187 LIBPROGRAMS=$AM_LIBPROGRAMS
189 test -n "$AM_SCRIPTS" && {
190 SCRIPTS=$AM_SCRIPTS
192 test -n "$AM_LIBSCRIPTS" && {
193 LIBSCRIPTS=$AM_LIBSCRIPTS
195 test -n "$AM_LIBRARIES" && {
196 LIBRARIES=$AM_LIBRARIES
199 if grep @kr@ ${am_makefile}.am >/dev/null; then
200 kr='${kr}'
201 else
205 if test -n "$PROGRAMS$LIBPROGRAMS$LIBRARIES"; then
206 cat $am_dir/compile-vars.am >&4
207 cat $am_dir/compile.am >&5
209 am_suffixes=".c .o $am_suffixes"
211 # Check for automatic de-ANSIfication.
212 if grep @kr@ ${am_makefile}.am >/dev/null; then
213 cat $am_dir/compile-kr.am >&5
214 am_suffixes=".krc .krh .kro $am_suffixes"
217 for am_file in $PROGRAMS $LIBPROGRAMS $LIBRARIES; do
218 if eval "test \"\$var_${am_file}_SOURCES\" = explicit"; then
219 if eval "test \"\$var_${am_file}_OBJECTS\" = explicit"; then
221 else
222 sed -n -f $am_rmnl ${am_makefile}.am |
223 sed -n "/^[ ]*${am_file}_SOURCES[ ]*=/{
224 s/SOURCES/OBJECTS/
225 s/@[^@]*@//g
226 s/\$([^)]*)//g
227 s/\${[^}]*}//g
228 s/\\.cc/.${kr}o/g
229 s/\\.\${kr}c/.${kr}o/g
230 s/\\.\$(kr)c/.${kr}o/g
231 s/\\.[cCmylfs]/.${kr}o/g
233 }" >&4
235 SOURCES="$SOURCES \${${am_file}_SOURCES}"
236 OBJECTS="$OBJECTS \${${am_file}_OBJECTS}"
237 else
238 echo "${am_file}_SOURCES = ${am_file}.c" >&4
239 echo "${am_file}_OBJECTS = ${am_file}.${kr}o" >&4
240 SOURCES="$SOURCES ${am_file}.c"
241 OBJECTS="$OBJECTS ${am_file}.${kr}o"
243 if test -n "$CONFIG_HEADER"; then
244 echo "\$(${am_file}_OBJECTS): $CONFIG_HEADER" >&5
246 done
251 # Boilerplate for scripts or programs.
253 if test -n "$PROGRAMS"; then
254 cat $am_dir/programs.am >&5
255 installexec="install-programs $installexec"
256 uninstall="uninstall-programs $uninstall"
258 if test -n "$SCRIPTS"; then
259 cat $am_dir/scripts.am >&5
260 installexec="install-scripts $installexec"
261 uninstall="uninstall-scripts $uninstall"
263 if test -n "$LIBPROGRAMS$LIBSCRIPTS"; then
264 cat $am_dir/libprograms.am >&5
265 installexec="install-libprograms $installexec"
266 uninstall="uninstall-libprograms $uninstall"
268 if test -n "$LIBSCRIPTS"; then
269 cat $am_dir/libscripts.am >&5
270 installexec="install-libscripts $installexec"
271 uninstall="uninstall-libscripts $uninstall"
274 if test -n "$PROGRAMS$LIBPROGRAMS$SCRIPTS$LIBSCRIPTS"; then
275 if test -n "$PROGRAMS$LIBPROGRAMS"; then
276 for am_prog in $PROGRAMS $LIBPROGRAMS; do
277 # If `prog_LDADD' is explicitly defined, use it. Otherwise,
278 # use LDADD.
279 eval "test \"\$var_${am_prog}_LDADD\" = explicit" || {
280 # Not set, so set it.
281 echo "${am_prog}_LDADD = \${LDADD}" >&5
284 # Insert rule for this target, unless it is explicitly given
285 # in Makefile.am.
286 eval "test \"\$target_$am_prog\" != explicit" &&
287 sed "s/@PROGRAM@/$am_prog/g" $am_dir/program.am >&5
288 done
292 if test -n "$LIBRARIES"; then
293 echo "LIBFILES = " `echo "$LIBRARIES"|sed 's/\([a-zA-Z0-9_][a-zA-Z0-9_]*\)/lib\1.a/g'` >&4
294 cat $am_dir/libraries-vars.am >&4
295 cat $am_dir/libraries.am >&5
297 installexec="install-libraries $installexec"
298 uninstall="uninstall-libraries $uninstall"
300 for am_lib in $LIBRARIES; do
301 sed "s/@LIBRARY@/$am_lib/g" $am_dir/library.am >&5
302 done
305 if test -n "$TEXINFOS"; then
306 # Give an error if more than one texinfo is defined -- we
307 # can't handle that. But how to count? Sigh. We do the naive,
308 # broken thing.
309 set $TEXINFOS
310 if test $# -gt 1; then
311 $echo "automake: $am_makefile specified more than one file in \`TEXINFOS'"
312 am_localstatus=1
313 else
314 am_infobase=`echo "$TEXINFOS" | sed 's/\.texi//'`
316 am_deps=
317 # Only do version.texi if requested.
318 if grep version.texi $TEXINFOS > /dev/null; then
319 am_deps="version.texi $am_deps"
321 if eval "test \"\$var_${am_infobase}_TEXINFOS\" = explicit"; then
322 # User supplied eg automake_TEXINFOS. So use those as
323 # dependencies.
324 am_deps="\$(${am_infobase}_TEXINFOS) $am_deps"
325 sed "s/@TEXI@/$TEXINFOS/g" $am_dir/texi-version.am >&5
328 if test -n "$am_deps"; then
329 echo "${am_infobase}.info: $am_deps" >&5
330 echo >&5
333 cat $am_dir/texinfos-vars.am >&4
334 cat $am_dir/texinfos.am >&5
335 am_suffixes=".texi .info .dvi $am_suffixes"
336 installdata="install-info $installdata"
337 uninstall="uninstall-info $uninstall"
338 info="\$(INFO_DEPS) $info"
339 dvi="\$(DVIS) $dvi"
341 echo "$TEXINFOS" | sed 's/^/INFOS = /; s/\.texi/.info*/g' >&4
342 echo "$TEXINFOS" | sed 's/^/INFO_DEPS = /; s/\.texi/.info/g' >&4
343 echo "$TEXINFOS" | sed 's/^/DVIS = /; s/\.texi/.dvi/g' >&4
347 if test -n "$MANS"; then
348 cat $am_dir/mans-vars.am >&4
349 cat $am_dir/mans.am >&5
351 installdata="install-man $installdata"
352 uninstall="uninstall-man $uninstall"
357 # Handle DATA and PACKAGEDATA.
359 if test -n "$DATA"; then
360 cat $am_dir/data.am >&5
361 installdata="install-ddata $installdata"
362 uninstall="uninstall-ddata $uninstall"
364 if test -n "$PACKAGEDATA"; then
365 cat $am_dir/packagedata.am >&5
366 installdata="install-pdata $installdata"
367 uninstall="uninstall-pdata $uninstall"
370 case "$SUBDIRS" in
372 if grep @kr@ ${am_makefile}.am >/dev/null; then
373 cat $am_dir/clean-kr.am >&5
374 else
375 cat $am_dir/clean.am >&5
379 cat $am_dir/subdirs.am >&5
381 all="all-recursive $all"
382 check="check-recursive $check"
383 info="info-recursive $info"
384 dvi="dvi-recursive $dvi"
385 am_recursive_install=yes
387 esac
388 cat $am_dir/footer.am >&5
390 case "$am_makefile" in
391 */*)
392 cat $am_dir/remake-subd.am >&5
395 test -f aclocal.m4 && echo "ACLOCAL = aclocal.m4" >&4
396 cat $am_dir/remake.am >&5
398 esac
400 case "$CONFIG_HEADER" in
401 "") ;;
402 */*) ;; # It's in some other directory, so don't remake it in this one.
404 test -f acconfig.h && echo "ACCONFIG = acconfig.h" >&4
405 test -f config.h.top && echo "CONFIG_TOP = config.h.top" >&4
406 test -f config.h.bot && echo "CONFIG_BOT = config.h.bot" >&4
407 cat $am_dir/remake-hdr.am >&5 ;;
408 esac
411 # Handle TAGS.
413 case "$am_makefile" in
414 */*)
415 if test -n "${SOURCES}${HEADERS}${ETAGS_ARGS}"; then
416 cat $am_dir/tags-subd.am >&5
420 if test -n "${SUBDIRS}"; then
421 cat $am_dir/tags.am >&5
422 else
423 if test -n "${SOURCES}${HEADERS}${ETAGS_ARGS}"; then
424 cat $am_dir/tags-subd.am >&5
428 esac
431 # Handle "dist" targets.
434 # Look for certain common files and make sure they are included.
435 dlist=
436 for cfile in $common; do
437 if test -f $am_reldir/$cfile; then
438 dlist="$dlist $cfile"
440 done
441 echo "DIST_COMMON = $dlist" >&4
442 # Include "dist" boilerplate.
443 case "$am_makefile" in
444 */*)
445 cat $am_dir/dist-subd-vars.am >&4
446 echo "subdir = $am_reldir" >&5
447 cat $am_dir/dist-subd.am >&5
450 cat $am_dir/dist-vars.am >&4
451 if test -n "$SUBDIRS"; then
452 cat $am_dir/dist-subd-top.am >&5
453 else
454 cat $am_dir/dist.am >&5
457 esac
460 # Put .SUFFIXES way down at the bottom.
462 if test -n "$am_suffixes"; then
463 echo ".SUFFIXES:" >&5
464 echo ".SUFFIXES: $am_suffixes" >&5
465 echo >&5
470 # Handle auto-generating dependencies.
472 if test "$am_usedeps" = yes && test -n "$SOURCES"; then
473 # Include code to auto-generate dependencies.
474 cat $am_dir/depend.am >&5
476 if test "$am_incdeps" = yes; then
477 # Include any already generated dependencies.
478 if test -d $am_reldir/.deps && test -f $am_reldir/.deps/empty.P; then
479 cat $am_reldir/.deps/*.P >&5
484 # Some final checks.
486 test -z "$TEXINFOS" || test -f $am_reldir/texinfo.tex || {
487 $echo "automake: ${am_makefile}.am defines TEXINFOS, but" 1>&2
488 $echo "automake: ${am_reldir}/texinfo.tex does not exist" 1>&2
491 case "$am_makefile" in
492 */*)
493 # In a subdirectory.
497 # In top-level, or only, directory.
498 test -f $am_reldir/install-sh || {
499 $echo "automake: $am_reldir/install-sh does not exist" 1>&2
501 test -f $am_reldir/mkinstalldirs || {
502 $echo "automake: $am_reldir/mkinstalldirs does not exist" 1>&2
505 esac
507 # Copy from Makefile.am to output.
508 sed '/^[^#=]*:/,$d' ${am_makefile}.am >&4
509 sed -n '/^[^#=]*:/,$p' ${am_makefile}.am >&5
511 echo "SOURCES = $SOURCES" >&4
512 echo "OBJECTS = $OBJECTS" >&4
513 echo >&4
516 # Output variable definitions.
517 exec 6> ${am_makefile}.in
519 cat ${am_makefile}.vars >&6
522 # Merge any targets that need to be merged.
524 for am_target in all info dvi check; do
525 # If user specified the local form of the target, then include it.
526 if eval "test \"\$target_${am_target}_local\" = explicit"; then
527 eval "${am_target}=\"${am_target}-local \$${am_target}\""
530 # Always print these targets; GNU makefile standards require it.
531 eval "am_val=\"\$${am_target}\""
532 echo "${am_target}: ${am_val}" >&6
533 echo >&6
534 done
536 # Handle the various install targets specially. We do this so that
537 # (eg) "make install-exec" will run "install-exec-recursive" if
538 # required, but "make install" won't run it twice. Step one is to
539 # see if the user specified local versions of any of the targets we
540 # handle.
541 if test -n "$target_install_exec_local"; then
542 installexec="install-exec-local $installexec"
544 if test -n "$target_uninstall_local"; then
545 uninstall="uninstall-local $uninstall"
547 if test -n "$target_install_data_local"; then
548 installdata="install-data-local $installdata"
550 # FIXME do install-local here? Maybe make it an error and tell the
551 # user to use install-data or install-exec?
553 # Step two: if we are doing recursive makes, write out the
554 # appropriate rules.
555 if test $am_recursive_install = yes; then
556 install="install-recursive $install"
557 if test -n "$installexec"; then
558 echo "install-exec-am: $installexec" >&6
559 echo >&6
560 installexec="install-exec-recursive install-exec-am"
561 install="install-exec-am $install"
563 if test -n "$installdata"; then
564 echo "install-data-am: $installdata" >&6
565 echo >&6
566 installdata="install-data-recursive install-data-am"
567 install="install-data-am $install"
569 if test -n "$uninstall"; then
570 echo "uninstall-am: $uninstall" >&6
571 echo >&6
572 uninstall="uninstall-recursive uninstall-am"
576 # Step three: print definitions users can use.
577 if test -n "$installexec"; then
578 echo "install-exec: $installexec" >&6
579 echo >&6
580 if test $am_recursive_install = no; then
581 install="install-exec $install"
584 if test -n "$installdata"; then
585 echo "install-data: $installdata" >&6
586 echo >&6
587 if test $am_recursive_install = no; then
588 install="install-data $install"
592 echo "install: $install" >&6
593 echo >&6
594 echo "uninstall: $uninstall" >&6
595 echo >&6
598 cat ${am_makefile}.rules >&6
599 rm -f ${am_makefile}.vars ${am_makefile}.rules
601 exit $am_localstatus
602 ) || {
603 am_status = 1
605 done
607 exit $am_status