--use-deps now the default
[automake.git] / automake.in
blob505983d69e8d71598613d6daa7d475e64bbef5ea
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 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 --help print this help, then exit
51 --version print version number, then exit
52 --include-deps include generated dependencies in Makefile"
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 # Ignore errors here, in case we have an odd number.
60 shift 2>/dev/null
61 done
62 exit 0
65 --version | --v* )
66 $echo "Automake version $version"
67 exit 0
70 --include-deps)
71 am_incdeps=yes
72 am_usedeps=no
75 -- ) # Stop option processing.
76 shift
77 while test $# -gt 0; do
78 mfiles="$mfiles $1"
79 shift
80 done
81 break
84 -*)
85 # FIXME consider "-" meaning stdin as input?
86 $echo "automake: unrecognized option -- \`$1'" 1>&2
87 exit 1
90 * )
91 mfiles="$mfiles $1"
93 esac
94 shift
95 done
97 test -n "$mfiles" || {
98 # Look around.
99 mfiles=`echo */Makefile.am`
100 if test "$mfiles" = '*/Makefile.am'; then
101 mfiles=
102 else
103 mfiles=`echo "$mfiles" | sed 's/\.am//g'`
106 if test -f Makefile.am; then
107 mfiles="Makefile $mfiles"
110 if test -n "$mfiles"; then
111 $echo "automake: using $mfiles" 1>&2
112 else
113 $echo "automake: no \"Makefile.am\" found or specified" 1>&2
114 exit 1
119 am_status=0
121 # Some handy sed scripts.
122 am_rmnl=$am_dir/nl-remove.sed
123 am_ass=$am_dir/hack-make.sed
125 for am_makefile in $mfiles; do
127 if test ! -f ${am_makefile}.am; then
128 $echo "automake: ${am_makefile}.am: No such honkin' file" 1>&2
129 am_status=1
130 continue
133 $echo "creating ${am_makefile}.in"
135 exec 4> ${am_makefile}.vars
136 exec 5> ${am_makefile}.rules
138 echo "# Makefile.in generated automatically by automake $version from Makefile.am." >&4
139 cat $am_dir/header-vars.am >&4
140 cat $am_dir/header.am >&5
142 DEFS= INCLUDES= CPPFLAGS= CFLAGS=
143 SOURCES= CONFIG_HEADER= SUBDIRS= PROGRAMS= LIBPROGRAMS= SCRIPTS= LIBSCRIPTS=
144 LIBRARIES= TEXINFOS= MANS= AM_PROGRAMS=
145 am_suffixes=
146 # The following are targets that formerly were implemented as
147 # double-colon rules. Nowadays we have to construct such lists
148 # explicitly.
149 installexec= uninstallexec= id= tags= info= dvi= check=
150 installdata= uninstalldata= all='${ALL}'
151 install= uninstall=
153 eval `sed -n -f $am_rmnl ${am_makefile}.am | sed -n -f $am_ass`
156 # If a variable is set at configure time, we still need to know the
157 # values it can assume (statically). This is done using the AM_
158 # forms in the Makefile.am. Handle it now.
160 test -n "$AM_PROGRAMS" && {
161 PROGRAMS=$AM_PROGRAMS
163 test -n "$AM_LIBPROGRAMS" && {
164 LIBPROGRAMS=$AM_LIBPROGRAMS
166 test -n "$AM_SCRIPTS" && {
167 SCRIPTS=$AM_SCRIPTS
169 test -n "$AM_LIBSCRIPTS" && {
170 LIBSCRIPTS=$AM_LIBSCRIPTS
172 test -n "$AM_LIBRARIES" && {
173 LIBRARIES=$AM_LIBRARIES
176 if grep @kr@ ${am_makefile}.am >/dev/null; then
177 kr='${kr}'
178 else
182 if test -n "$PROGRAMS$LIBPROGRAMS$LIBRARIES"; then
183 cat $am_dir/compile-vars.am >&4
184 cat $am_dir/compile.am >&5
186 # Check for automatic de-ANSIfication.
187 if grep @kr@ ${am_makefile}.am >/dev/null; then
188 cat $am_dir/compile-kr.am >&5
189 am_suffixes=".krc .krh .kro $am_suffixes"
192 for am_file in $PROGRAMS $LIBPROGRAMS $LIBRARIES; do
193 if eval "test \"\$var_${am_file}_SOURCES\" = explicit"; then
194 if eval "test \"\$var_${am_file}_OBJECTS\" = explicit"; then
196 else
197 sed -n -f $am_rmnl ${am_makefile}.am |
198 sed -n "/^[ ]*${am_file}_SOURCES[ ]*=/{
199 s/SOURCES/OBJECTS/
200 s/@[^@]*@//g
201 s/\$([^)]*)//g
202 s/\${[^}]*}//g
203 s/\\.cc/.${kr}o/g
204 s/\\.\${kr}c/.${kr}o/g
205 s/\\.\$(kr)c/.${kr}o/g
206 s/\\.[cCmylfs]/.${kr}o/g
208 }" >&4
210 SOURCES="$SOURCES \${${am_file}_SOURCES}"
211 OBJECTS="$OBJECTS \${${am_file}_OBJECTS}"
212 else
213 echo "${am_file}_SOURCES = ${am_file}.c" >&4
214 echo "${am_file}_OBJECTS = ${am_file}.${kr}o" >&4
215 SOURCES="$SOURCES ${am_file}.c"
216 OBJECTS="$OBJECTS ${am_file}.${kr}o"
218 if test -n "$CONFIG_HEADER"; then
219 echo "\$(${am_file}_OBJECTS): $CONFIG_HEADER" >&5
221 done
226 # Boilerplate for scripts or programs.
228 if test -n "$PROGRAMS"; then
229 cat $am_dir/programs.am >&5
230 installexec="install-programs $installexec"
231 uninstallexec="uninstall-programs $uninstallexec"
233 if test -n "$SCRIPTS"; then
234 cat $am_dir/scripts.am >&5
235 installexec="install-scripts $installexec"
236 uninstallexec="uninstall-scripts $uninstallexec"
238 if test -n "$LIBPROGRAMS$LIBSCRIPTS"; then
239 cat $am_dir/libprograms.am >&5
240 installexec="install-libprograms $installexec"
241 uninstallexec="uninstall-libprograms $uninstallexec"
243 if test -n "$LIBSCRIPTS"; then
244 cat $am_dir/libscripts.am >&5
245 installexec="install-libscripts $installexec"
246 uninstallexec="uninstall-libscripts $uninstallexec"
249 if test -n "$PROGRAMS$LIBPROGRAMS$SCRIPTS$LIBSCRIPTS"; then
250 if test -n "$PROGRAMS$LIBPROGRAMS"; then
251 for am_prog in $PROGRAMS $LIBPROGRAMS; do
252 # If `prog_LDADD' is explicitly defined, use it. Otherwise,
253 # use LDADD.
254 eval "test \"\$var_${am_prog}_LDADD\" = explicit" || {
255 # Not set, so set it.
256 echo "${am_prog}_LDADD = \${LDADD}" >&5
259 # Insert rule for this target, unless it is explicitly given
260 # in Makefile.am.
261 eval "test \"\$target_$am_prog\" != explicit" &&
262 sed "s/@PROGRAM@/$am_prog/g" $am_dir/program.am >&5
263 done
267 if test -n "$LIBRARIES"; then
268 echo "LIBFILES = " `echo "$LIBRARIES"|sed 's/\([a-zA-Z0-9_][a-zA-Z0-9_]*\)/lib\1.a/g'` >&4
269 cat $am_dir/libraries-vars.am >&4
270 cat $am_dir/libraries.am >&5
272 installexec="install-libraries $installexec"
273 uninstallexec="uninstall-libraries $uninstallexec"
275 for am_lib in $LIBRARIES; do
276 sed "s/@LIBRARY@/$am_lib/g" $am_dir/library.am >&5
277 done
280 if test -n "$TEXINFOS"; then
281 cat $am_dir/texinfos-vars.am >&4
282 cat $am_dir/texinfos.am >&5
283 am_suffixes=".texi .info .dvi $am_suffixes"
284 installdata="install-info $installdata"
285 uninstalldata="uninstall-info $uninstalldata"
286 info="\$(INFO_DEPS) $info"
287 dvi="\$(DVIS) $dvi"
289 echo "$TEXINFOS" | sed 's/^/INFOS = /; s/\.texi/.info*/g' >&4
290 echo "$TEXINFOS" | sed 's/^/INFO_DEPS = /; s/\.texi/.info/g' >&4
291 echo "$TEXINFOS" | sed 's/^/DVIS = /; s/\.texi/.dvi/g' >&4
294 if test -n "$MANS"; then
295 cat $am_dir/mans-vars.am >&4
296 cat $am_dir/mans.am >&5
298 installdata="install-man $installdata"
299 uninstalldata="uninstall-man $uninstall"
304 # Handle DATA and PACKAGEDATA.
306 if test -n "$DATA"; then
307 cat $am_dir/data.am >&5
308 installdata="install-ddata $installdata"
309 uninstalldata="uninstall-ddata $uninstalldata"
311 if test -n "$PACKAGEDATA"; then
312 cat $am_dir/packagedata.am >&5
313 installdata="install-pdata $installdata"
314 uninstalldata="uninstall-pdata $uninstalldata"
317 case "$SUBDIRS" in
319 if grep @kr@ ${am_makefile}.am >/dev/null; then
320 cat $am_dir/clean-kr.am >&5
321 else
322 cat $am_dir/clean.am >&5
324 cat $am_dir/footer.am >&5
327 cat $am_dir/subdirs.am >&5
329 all="all-recursive $all"
330 installdata="install-data-recursive $installdata"
331 installexec="install-exec-recursive $installexec"
332 uninstalldata="uninstall-data-recursive $uninstalldata"
333 uninstallexec="uninstall-exec-recursive $uninstallexec"
334 check="check-recursive $check"
335 info="info-recursive $info"
336 dvi="dvi-recursive $dvi"
337 install="install-recursive $install"
338 uninstall="uninstall-recursive $uninstall"
340 esac
342 case "$am_makefile" in
343 */*)
344 cat $am_dir/remake-subd.am >&5
347 test -f aclocal.m4 && echo "ACLOCAL = aclocal.m4" >&4
348 cat $am_dir/remake.am >&5
350 esac
352 case "$CONFIG_HEADER" in
353 "") ;;
354 */*) ;; # It's in some other directory, so don't remake it in this one.
356 test -f acconfig.h && echo "ACCONFIG = acconfig.h" >&4
357 test -f config.h.top && echo "CONFIG_TOP = config.h.top" >&4
358 test -f config.h.bot && echo "CONFIG_BOT = config.h.bot" >&4
359 cat $am_dir/remake-hdr.am >&5 ;;
360 esac
363 # Handle TAGS.
365 case "$am_makefile" in
366 */*)
367 if test -n "${SOURCES}${HEADERS}${ETAGS_ARGS}"; then
368 cat $am_dir/tags-subd.am >&5
372 if test -n "${SUBDIRS}"; then
373 cat $am_dir/tags.am >&5
374 else
375 if test -n "${SOURCES}${HEADERS}${ETAGS_ARGS}"; then
376 cat $am_dir/tags-subd.am >&5
380 esac
383 # Handle "dist" targets.
385 am_reldir=`echo "$am_makefile" | sed 's,//*[^/][^/]*$,,g'`
386 if test "$am_reldir" = "$am_makefile"; then
387 # Bogus.
388 am_reldir=.
390 # Look for certain common files and make sure they are included.
391 dlist=
392 for cfile in $common; do
393 if test -f $am_reldir/$cfile; then
394 dlist="$dlist $cfile"
396 done
397 echo "DIST_COMMON = $dlist" >&4
398 # Include "dist" boilerplate.
399 case "$am_makefile" in
400 */*)
401 cat $am_dir/dist-subd-vars.am >&4
402 echo "subdir = $am_reldir" >&5
403 cat $am_dir/dist-subd.am >&5
406 cat $am_dir/dist-vars.am >&4
407 if test -n "$SUBDIRS"; then
408 cat $am_dir/dist-subd-top.am >&5
409 else
410 cat $am_dir/dist.am >&5
413 esac
416 # Put .SUFFIXES way down at the bottom.
418 if test -n "$am_suffixes"; then
419 echo ".SUFFIXES:" >&5
420 echo ".SUFFIXES: $am_suffixes" >&5
421 echo >&5
426 # Handle auto-generating dependencies.
428 if test "$am_usedeps" = yes && test -n "$SOURCES"; then
429 # Include code to auto-generate dependencies.
430 cat $am_dir/depend.am >&5
432 if test "$am_incdeps" = yes; then
433 # Include any already generated dependencies.
434 if test -d $am_reldir/.deps && test -f $am_reldir/.deps/empty.P; then
435 cat $am_reldir/.deps/*.P >&5
440 # Some final checks.
442 test -z "$TEXINFOS" || test -f $am_reldir/texinfo.tex || {
443 $echo "automake: ${am_makefile}.am defines TEXINFOS, but" 1>&2
444 $echo "automake: ${am_reldir}/texinfo.tex does not exist" 1>&2
448 # Copy from Makefile.am to output.
449 sed '/^[^#=]*:/,$d' ${am_makefile}.am >&4
450 sed -n '/^[^#=]*:/,$p' ${am_makefile}.am >&5
452 echo "SOURCES = $SOURCES" >&4
453 echo "OBJECTS = $OBJECTS" >&4
456 # Output variable definitions.
457 exec 6> ${am_makefile}.in
459 cat ${am_makefile}.vars >&6
462 # Merge any targets that need to be merged.
464 for am_target in all info dvi check; do
465 # If user specified the local form of the target, then include it.
466 if eval "test \"\$target_${am_target}_local\" = explicit"; then
467 eval "${am_target}=\"${am_target}-local \$${am_target}\""
470 # Always print these targets; GNU makefile standards require it.
471 eval "am_val=\"\$${am_target}\""
472 echo "${am_target}: ${am_val}" >&6
473 echo >&6
474 done
476 # Handle the various install targets specially, because we do name
477 # hackery. This is truly gross.
478 if test -n "$target_install_exec_local"; then
479 installexec="install-exec-local $installexec"
481 if test -n "$target_uninstall_exec_local"; then
482 uninstallexec="uninstall-exec-local $uninstallexec"
484 if test -n "$target_install_data_local"; then
485 installdata="install-data-local $installdata"
487 if test -n "$target_uninstall_data_local"; then
488 uninstalldata="uninstall-data-local $uninstalldata"
491 if test -n "$installexec"; then
492 install="install-exec $install"
493 echo "install-exec: $installexec" >&6
494 echo >&6
496 if test -n "$uninstallexec"; then
497 uninstall="uninstall-exec $uninstall"
498 echo "uninstall-exec: $uninstallexec" >&6
499 echo >&6
501 if test -n "$installdata"; then
502 install="install-data $install"
503 echo "install-data: $installdata" >&6
504 echo >&6
506 if test -n "$uninstalldata"; then
507 uninstall="uninstall-data $uninstall"
508 echo "uninstall-data: $uninstalldata" >&6
509 echo >&6
512 echo "install: $install" >&6
513 echo >&6
514 echo "uninstall: $uninstall" >&6
515 echo >&6
518 cat ${am_makefile}.rules >&6
519 rm -f ${am_makefile}.vars ${am_makefile}.rules
522 done
524 exit $am_status