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)
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.
29 # We need prefix because datadir might depend on it.
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
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.
45 while test $# -gt 0; do
48 $echo "Usage: automake [OPTION]... [Makefile]..."
50 --help print this help, then exit
51 --version print version number, then exit
52 --use-deps include code to auto-generate dependencies
53 --include-deps include generated dependencies in Makefile"
55 $echo "Files which are automatically distributed, if found:"
57 while test $# -gt 0; do
60 # Ignore errors here, in case we have an odd number.
67 $echo "Automake version $version"
79 -- ) # Stop option processing.
81 while test $# -gt 0; do
89 # FIXME consider "-" meaning stdin as input?
90 $echo "automake: unrecognized option -- \`$1'" 1>&2
101 if test "$am_usedeps" = yes && test "$am_incdeps" = yes; then
102 $echo "automake: can't specify both --use-deps and --include-deps" 1>&2
106 test -n "$mfiles" ||
{
108 mfiles
=`echo */Makefile.am`
109 if test "$mfiles" = '*/Makefile.am'; then
112 mfiles
=`echo "$mfiles" | sed 's/\.am//g'`
115 if test -f Makefile.am
; then
116 mfiles
="Makefile $mfiles"
119 if test -n "$mfiles"; then
120 $echo "automake: using $mfiles" 1>&2
122 $echo "automake: no \"Makefile.am\" found or specified" 1>&2
130 # Some handy sed scripts.
131 am_rmnl
=$am_dir/nl-remove.
sed
132 am_ass
=$am_dir/hack-make.
sed
134 for am_makefile
in $mfiles; do
136 if test ! -f ${am_makefile}.am
; then
137 $echo "automake: ${am_makefile}.am: No such honkin' file" 1>&2
142 $echo "creating ${am_makefile}.in"
144 exec 4> ${am_makefile}.vars
145 exec 5> ${am_makefile}.rules
147 echo "# Makefile.in generated automatically by automake $version from Makefile.am." >&4
148 cat $am_dir/header-vars.am
>&4
149 cat $am_dir/header.am
>&5
151 DEFS
= INCLUDES
= CPPFLAGS
= CFLAGS
=
152 SOURCES
= CONFIG_HEADER
= SUBDIRS
= PROGRAMS
= LIBPROGRAMS
= SCRIPTS
= LIBSCRIPTS
=
153 LIBRARIES
= TEXINFOS
= MANS
= AM_PROGRAMS
=
155 # The following are targets that formerly were implemented as
156 # double-colon rules. Nowadays we have to construct such lists
158 installexec
= uninstallexec
= id
= tags
= info
= dvi
= check
=
159 installdata
= uninstalldata
= all
='${ALL}'
162 eval `sed -n -f $am_rmnl ${am_makefile}.am | sed -n -f $am_ass`
165 # If a variable is set at configure time, we still need to know the
166 # values it can assume (statically). This is done using the AM_
167 # forms in the Makefile.am. Handle it now.
169 test -n "$AM_PROGRAMS" && {
170 PROGRAMS
=$AM_PROGRAMS
172 test -n "$AM_LIBPROGRAMS" && {
173 LIBPROGRAMS
=$AM_LIBPROGRAMS
175 test -n "$AM_SCRIPTS" && {
178 test -n "$AM_LIBSCRIPTS" && {
179 LIBSCRIPTS
=$AM_LIBSCRIPTS
181 test -n "$AM_LIBRARIES" && {
182 LIBRARIES
=$AM_LIBRARIES
185 if grep @kr@
${am_makefile}.am
>/dev
/null
; then
191 if test -n "$PROGRAMS$LIBPROGRAMS$LIBRARIES"; then
192 cat $am_dir/compile-vars.am
>&4
193 cat $am_dir/compile.am
>&5
195 # Check for automatic de-ANSIfication.
196 if grep @kr@
${am_makefile}.am
>/dev
/null
; then
197 cat $am_dir/compile-kr.am
>&5
198 am_suffixes
=".krc .krh .kro $am_suffixes"
201 for am_file
in $PROGRAMS $LIBPROGRAMS $LIBRARIES; do
202 if eval "test \"\$var_${am_file}_SOURCES\" = explicit"; then
203 if eval "test \"\$var_${am_file}_OBJECTS\" = explicit"; then
206 sed -n -f $am_rmnl ${am_makefile}.am |
207 sed -n "/^[ ]*${am_file}_SOURCES[ ]*=/{
213 s/\\.\${kr}c/.${kr}o/g
214 s/\\.\$(kr)c/.${kr}o/g
215 s/\\.[cCmylfs]/.${kr}o/g
219 SOURCES
="$SOURCES \${${am_file}_SOURCES}"
220 OBJECTS
="$OBJECTS \${${am_file}_OBJECTS}"
222 echo "${am_file}_SOURCES = ${am_file}.c" >&4
223 echo "${am_file}_OBJECTS = ${am_file}.${kr}o" >&4
224 SOURCES
="$SOURCES ${am_file}.c"
225 OBJECTS
="$OBJECTS ${am_file}.${kr}o"
227 if test -n "$CONFIG_HEADER"; then
228 echo "\$(${am_file}_OBJECTS): $CONFIG_HEADER" >&5
235 # Boilerplate for scripts or programs.
237 if test -n "$PROGRAMS"; then
238 cat $am_dir/programs.am
>&5
239 installexec
="install-programs $installexec"
240 uninstallexec
="uninstall-programs $uninstallexec"
242 if test -n "$SCRIPTS"; then
243 cat $am_dir/scripts.am
>&5
244 installexec
="install-scripts $installexec"
245 uninstallexec
="uninstall-scripts $uninstallexec"
247 if test -n "$LIBPROGRAMS$LIBSCRIPTS"; then
248 cat $am_dir/libprograms.am
>&5
249 installexec
="install-libprograms $installexec"
250 uninstallexec
="uninstall-libprograms $uninstallexec"
252 if test -n "$LIBSCRIPTS"; then
253 cat $am_dir/libscripts.am
>&5
254 installexec
="install-libscripts $installexec"
255 uninstallexec
="uninstall-libscripts $uninstallexec"
258 if test -n "$PROGRAMS$LIBPROGRAMS$SCRIPTS$LIBSCRIPTS"; then
259 if test -n "$PROGRAMS$LIBPROGRAMS"; then
260 for am_prog
in $PROGRAMS $LIBPROGRAMS; do
261 # If `prog_LDADD' is explicitly defined, use it. Otherwise,
263 eval "test \"\$var_${am_prog}_LDADD\" = explicit" ||
{
264 # Not set, so set it.
265 echo "${am_prog}_LDADD = \${LDADD}" >&5
268 # Insert rule for this target, unless it is explicitly given
270 eval "test \"\$target_$am_prog\" != explicit" &&
271 sed "s/@PROGRAM@/$am_prog/g" $am_dir/program.am
>&5
276 if test -n "$LIBRARIES"; then
277 echo "LIBFILES = " `echo "$LIBRARIES"|sed 's/\([a-zA-Z0-9_][a-zA-Z0-9_]*\)/lib\1.a/g'` >&4
278 cat $am_dir/libraries-vars.am
>&4
279 cat $am_dir/libraries.am
>&5
281 installexec
="install-libraries $installexec"
282 uninstallexec
="uninstall-libraries $uninstallexec"
284 for am_lib
in $LIBRARIES; do
285 sed "s/@LIBRARY@/$am_lib/g" $am_dir/library.am
>&5
289 if test -n "$TEXINFOS"; then
290 cat $am_dir/texinfos-vars.am
>&4
291 cat $am_dir/texinfos.am
>&5
292 am_suffixes
=".texi .info .dvi $am_suffixes"
293 installdata
="install-info $installdata"
294 uninstalldata
="uninstall-info $uninstalldata"
295 info
="\$(INFO_DEPS) $info"
298 echo "$TEXINFOS" |
sed 's/^/INFOS = /; s/\.texi/.info*/g' >&4
299 echo "$TEXINFOS" |
sed 's/^/INFO_DEPS = /; s/\.texi/.info/g' >&4
300 echo "$TEXINFOS" |
sed 's/^/DVIS = /; s/\.texi/.dvi/g' >&4
303 if test -n "$MANS"; then
304 cat $am_dir/mans-vars.am
>&4
305 cat $am_dir/mans.am
>&5
307 installdata
="install-man $installdata"
308 uninstalldata
="uninstall-man $uninstall"
313 # Handle DATA and PACKAGEDATA.
315 if test -n "$DATA"; then
316 cat $am_dir/data.am
>&5
317 installdata
="install-ddata $installdata"
318 uninstalldata
="uninstall-ddata $uninstalldata"
320 if test -n "$PACKAGEDATA"; then
321 cat $am_dir/packagedata.am
>&5
322 installdata
="install-pdata $installdata"
323 uninstalldata
="uninstall-pdata $uninstalldata"
328 if grep @kr@
${am_makefile}.am
>/dev
/null
; then
329 cat $am_dir/clean-kr.am
>&5
331 cat $am_dir/clean.am
>&5
333 cat $am_dir/footer.am
>&5
336 cat $am_dir/subdirs.am
>&5
338 all
="all-recursive $all"
339 installdata
="install-data-recursive $installdata"
340 installexec
="install-exec-recursive $installexec"
341 uninstalldata
="uninstall-data-recursive $uninstalldata"
342 uninstallexec
="uninstall-exec-recursive $uninstallexec"
343 check
="check-recursive $check"
344 info
="info-recursive $info"
345 dvi
="dvi-recursive $dvi"
346 install="install-recursive $install"
347 uninstall
="uninstall-recursive $uninstall"
351 case "$am_makefile" in
353 cat $am_dir/remake-subd.am
>&5
356 test -f aclocal.
m4 && echo "ACLOCAL = aclocal.m4" >&4
357 cat $am_dir/remake.am
>&5
361 case "$CONFIG_HEADER" in
363 */*) ;; # It's in some other directory, so don't remake it in this one.
365 test -f acconfig.h
&& echo "ACCONFIG = acconfig.h" >&4
366 test -f config.h.top
&& echo "CONFIG_TOP = config.h.top" >&4
367 test -f config.h.bot
&& echo "CONFIG_BOT = config.h.bot" >&4
368 cat $am_dir/remake-hdr.am
>&5 ;;
374 case "$am_makefile" in
376 if test -n "${SOURCES}${HEADERS}${ETAGS_ARGS}"; then
377 cat $am_dir/tags-subd.am
>&5
381 if test -n "${SUBDIRS}"; then
382 cat $am_dir/tags.am
>&5
384 if test -n "${SOURCES}${HEADERS}${ETAGS_ARGS}"; then
385 cat $am_dir/tags-subd.am
>&5
392 # Handle "dist" targets.
394 am_reldir
=`echo "$am_makefile" | sed 's,//*[^/][^/]*$,,g'`
395 if test "$am_reldir" = "$am_makefile"; then
399 # Look for certain common files and make sure they are included.
401 for cfile
in $common; do
402 if test -f $am_reldir/$cfile; then
403 dlist
="$dlist $cfile"
406 echo "DIST_COMMON = $dlist" >&4
407 # Include "dist" boilerplate.
408 case "$am_makefile" in
410 cat $am_dir/dist-subd-vars.am
>&4
411 echo "subdir = $am_reldir" >&5
412 cat $am_dir/dist-subd.am
>&5
415 cat $am_dir/dist-vars.am
>&4
416 if test -n "$SUBDIRS"; then
417 cat $am_dir/dist-subd-top.am
>&5
419 cat $am_dir/dist.am
>&5
425 # Put .SUFFIXES way down at the bottom.
427 if test -n "$am_suffixes"; then
428 echo ".SUFFIXES:" >&5
429 echo ".SUFFIXES: $am_suffixes" >&5
435 # Handle auto-generating dependencies.
437 if test "$am_usedeps" = yes && test -n "$SOURCES"; then
438 # Include code to auto-generate dependencies.
439 cat $am_dir/depend.am
>&5
441 if test "$am_incdeps" = yes; then
442 # Include any already generated dependencies.
443 if test -d $am_reldir/.deps
&& test -f $am_reldir/.deps
/empty.P
; then
444 cat $am_reldir/.deps
/*.P
>&5
451 test -z "$TEXINFOS" ||
test -f $am_reldir/texinfo.tex ||
{
452 $echo "automake: ${am_makefile}.am defines TEXINFOS, but" 1>&2
453 $echo "automake: ${am_reldir}/texinfo.tex does not exist" 1>&2
457 # Copy from Makefile.am to output.
458 sed '/^[^#=]*:/,$d' ${am_makefile}.am
>&4
459 sed -n '/^[^#=]*:/,$p' ${am_makefile}.am
>&5
461 echo "SOURCES = $SOURCES" >&4
462 echo "OBJECTS = $OBJECTS" >&4
465 # Output variable definitions.
466 exec 6> ${am_makefile}.
in
468 cat ${am_makefile}.vars
>&6
471 # Merge any targets that need to be merged.
473 for am_target
in all info dvi check
; do
474 # If user specified the local form of the target, then include it.
475 if eval "test \"\$target_${am_target}_local\" = explicit"; then
476 eval "${am_target}=\"${am_target}-local \$${am_target}\""
479 # Always print these targets; GNU makefile standards require it.
480 eval "am_val=\"\$${am_target}\""
481 echo "${am_target}: ${am_val}" >&6
485 # Handle the various install targets specially, because we do name
486 # hackery. This is truly gross.
487 if test -n "$target_install_exec_local"; then
488 installexec
="install-exec-local $installexec"
490 if test -n "$target_uninstall_exec_local"; then
491 uninstallexec
="uninstall-exec-local $uninstallexec"
493 if test -n "$target_install_data_local"; then
494 installdata
="install-data-local $installdata"
496 if test -n "$target_uninstall_data_local"; then
497 uninstalldata
="uninstall-data-local $uninstalldata"
500 if test -n "$installexec"; then
501 install="install-exec $install"
502 echo "install-exec: $installexec" >&6
505 if test -n "$uninstallexec"; then
506 uninstall
="uninstall-exec $uninstall"
507 echo "uninstall-exec: $uninstallexec" >&6
510 if test -n "$installdata"; then
511 install="install-data $install"
512 echo "install-data: $installdata" >&6
515 if test -n "$uninstalldata"; then
516 uninstall
="uninstall-data $uninstall"
517 echo "uninstall-data: $uninstalldata" >&6
521 echo "install: $install" >&6
523 echo "uninstall: $uninstall" >&6
527 cat ${am_makefile}.rules
>&6
528 rm -f ${am_makefile}.vars
${am_makefile}.rules