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@
/automake
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'
40 # Only set `LANG' and `LC_ALL' to "C" if already set.
41 # These must not be set unconditionally because not all systems understand
42 # e.g. LANG=C (notably SCO).
43 if test "${LC_ALL+set}" = set; then LC_ALL
=C
; export LC_ALL
; fi
44 if test "${LANG+set}" = set; then LANG
=C
; export LANG
; fi
49 while test $# -gt 0; do
52 usage
="Usage: automake [--help] [--version] [Makefile]..."
54 echo "Usage: automake [OPTION]... [Makefile]..."
56 --help print this help, then exit
57 --version print version number, then exit
58 --use-deps include code to auto-generate dependencies
59 --include-deps include generated dependencies in Makefile"
61 echo "Files which are automatically distributed, if found:"
63 while test $# -gt 0; do
66 # Ignore errors here, in case we have an odd number.
73 echo "Automake version $version"
85 -- ) # Stop option processing.
90 # FIXME consider "-" meaning stdin as input?
91 echo "automake: unrecognized option -- \`$1'" 1>&2
102 if test "$am_usedeps" = yes && test "$am_incdeps" = yes; then
103 echo "automake: can't specify both --use-deps and --include-deps" 1>&2
107 test -n "$mfiles" ||
{
109 mfiles
=`echo */Makefile.am`
110 if test "$mfiles" = '*/Makefile.am'; then
113 mfiles
=`echo "$mfiles" | sed 's/\.am//g'`
116 if test -f Makefile.am
; then
117 mfiles
="Makefile $mfiles"
120 if test -n "$mfiles"; then
121 echo "automake: using $mfiles" 1>&2
123 echo "automake: no \"Makefile.am\" found or specified" 1>&2
131 # Some handy sed scripts.
132 am_rmnl
=$am_dir/nl-remove.
sed
133 am_ass
=$am_dir/hack-make.
sed
135 for am_makefile
in $mfiles; do
137 if test ! -f ${am_makefile}.am
; then
138 echo "automake: ${am_makefile}.am: No such honkin' file" 1>&2
143 echo creating
${am_makefile}.
in
145 exec 4> ${am_makefile}.vars
146 exec 5> ${am_makefile}.rules
148 echo "# Makefile.in generated automatically by automake $version from Makefile.am." >&4
149 cat $am_dir/header-vars.am
>&4
150 cat $am_dir/header.am
>&5
152 DEFS
= INCLUDES
= CPPFLAGS
= CFLAGS
=
153 SOURCES
= CONFIG_HEADER
= SUBDIRS
= PROGRAMS
= LIBPROGRAMS
= SCRIPTS
= LIBSCRIPTS
=
154 LIBRARIES
= TEXINFOS
= MANS
= AM_PROGRAMS
=
157 eval `sed -n -f $am_rmnl ${am_makefile}.am | sed -n -f $am_ass`
160 # If a variable is set at configure time, we still need to know the
161 # values it can assume (statically). This is done using the AM_
162 # forms in the Makefile.am. Handle it now.
164 test -n "$AM_PROGRAMS" && {
165 PROGRAMS
=$AM_PROGRAMS
167 test -n "$AM_LIBPROGRAMS" && {
168 LIBPROGRAMS
=$AM_LIBPROGRAMS
170 test -n "$AM_SCRIPTS" && {
173 test -n "$AM_LIBSCRIPTS" && {
174 LIBSCRIPTS
=$AM_LIBSCRIPTS
176 test -n "$AM_LIBRARIES" && {
177 LIBRARIES
=$AM_LIBRARIES
180 if grep @kr@
${am_makefile}.am
>/dev
/null
; then
186 if test -n "$PROGRAMS$LIBPROGRAMS$LIBRARIES"; then
187 cat $am_dir/compile-vars.am
>&4
188 cat $am_dir/compile.am
>&5
190 # Check for automatic de-ANSIfication.
191 if grep @kr@
${am_makefile}.am
>/dev
/null
; then
192 cat $am_dir/compile-kr.am
>&5
193 am_suffixes
=".krc .krh .kro $am_suffixes"
196 for am_file
in $PROGRAMS $LIBPROGRAMS $LIBRARIES; do
197 if eval "test \"\$var_${am_file}_SOURCES\" = explicit"; then
198 if eval "test \"\$var_${am_file}_OBJECTS\" = explicit"; then
201 sed -n -f $am_rmnl ${am_makefile}.am |
202 sed -n "/^[ ]*${am_file}_SOURCES[ ]*=/{
208 s/\\.\${kr}c/.${kr}o/g
209 s/\\.\$(kr)c/.${kr}o/g
210 s/\\.[cCmylfs]/.${kr}o/g
214 SOURCES
="$SOURCES \${${am_file}_SOURCES}"
216 echo "${am_file}_SOURCES = ${am_file}.c" >&4
217 echo "${am_file}_OBJECTS = ${am_file}.${kr}o" >&4
218 SOURCES
="$SOURCES ${am_file}.c"
220 if test -n "$CONFIG_HEADER"; then
221 echo "\$(${am_file}_OBJECTS): $CONFIG_HEADER" >&5
227 # Boilerplate for scripts or programs.
229 if test -n "$PROGRAMS"; then
230 cat $am_dir/programs.am
>&5
232 if test -n "$SCRIPTS"; then
233 cat $am_dir/scripts.am
>&5
235 if test -n "$LIBPROGRAMS$LIBSCRIPTS"; then
236 cat $am_dir/libprograms.am
>&5
238 if test -n "$LIBSCRIPTS"; then
239 cat $am_dir/libscripts.am
>&5
242 if test -n "$PROGRAMS$LIBPROGRAMS$SCRIPTS$LIBSCRIPTS"; then
243 if test -n "$PROGRAMS$LIBPROGRAMS"; then
244 for am_prog
in $PROGRAMS $LIBPROGRAMS; do
245 # If `prog_LDADD' is explicitly defined, use it. Otherwise,
247 eval "test \"\$var_${am_prog}_LDADD\" = explicit" ||
{
248 # Not set, so set it.
249 echo "${am_prog}_LDADD = \${LDADD}" >&5
252 # Insert rule for this target, unless it is explicitly given
254 eval "test \"\$target_$am_prog\" != explicit" &&
255 sed "s/@PROGRAM@/$am_prog/g" $am_dir/program.am
>&5
260 if test -n "$LIBRARIES"; then
261 echo "LIBFILES = " `echo "$LIBRARIES"|sed 's/\([a-zA-Z0-9_][a-zA-Z0-9_]*\)/lib\1.a/g'` >&4
262 cat $am_dir/libraries-vars.am
>&4
263 cat $am_dir/libraries.am
>&5
264 for am_lib
in $LIBRARIES; do
265 sed "s/@LIBRARY@/$am_lib/g" $am_dir/library.am
>&5
269 if test -n "$TEXINFOS"; then
270 cat $am_dir/texinfos-vars.am
>&4
271 cat $am_dir/texinfos.am
>&5
272 am_suffixes
=".texi .info .dvi $am_suffixes"
273 echo "$TEXINFOS" |
sed 's/^/INFOS = /; s/\.texi/.info*/g' >&4
274 echo "$TEXINFOS" |
sed 's/^/INFO_DEPS = /; s/\.texi/.info/g' >&4
275 echo "$TEXINFOS" |
sed 's/^/DVIS = /; s/\.texi/.dvi/g' >&4
278 if test -n "$MANS"; then
279 cat $am_dir/mans-vars.am
>&4
280 cat $am_dir/mans.am
>&5
284 "") if grep @kr@
${am_makefile}.am
>/dev
/null
; then
285 cat $am_dir/clean-kr.am
>&5
286 else cat $am_dir/clean.am
>&5
288 cat $am_dir/footer.am
>&5 ;;
289 *) cat $am_dir/subdirs.am
>&5 ;;
292 case "$am_makefile" in
294 cat $am_dir/remake-subd.am
>&5
297 test -f aclocal.
m4 && echo "ACLOCAL = aclocal.m4" >&4
298 cat $am_dir/remake.am
>&5
302 case "$CONFIG_HEADER" in
304 */*) ;; # It's in some other directory, so don't remake it in this one.
306 test -f acconfig.h
&& echo "ACCONFIG = acconfig.h" >&4
307 test -f config.h.top
&& echo "CONFIG_TOP = config.h.top" >&4
308 test -f config.h.bot
&& echo "CONFIG_BOT = config.h.bot" >&4
309 cat $am_dir/remake-hdr.am
>&5 ;;
312 echo "SOURCES = $SOURCES" >&4
318 case "$am_makefile" in
320 if test -n "${SOURCES}${HEADERS}${ETAGS_ARGS}"; then
321 cat $am_dir/tags-subd.am
>&5
325 if test -n "${SUBDIRS}"; then
326 cat $am_dir/tags.am
>&5
328 if test -n "${SOURCES}${HEADERS}${ETAGS_ARGS}"; then
329 cat $am_dir/tags-subd.am
>&5
336 # Handle "dist" targets.
338 am_reldir
=`echo "$am_makefile" | sed 's,//*[^/][^/]*$,,g'`
339 if test "$am_reldir" = "$am_makefile"; then
343 # Look for certain common files and make sure they are included.
345 for cfile
in $common; do
346 if test -f $am_reldir/$cfile; then
347 dlist
="$dlist $cfile"
350 echo "DIST_COMMON = $dlist" >&4
351 # Include "dist" boilerplate.
352 case "$am_makefile" in
354 cat $am_dir/dist-subd-vars.am
>&4
355 echo "subdir = $am_reldir" >&5
356 cat $am_dir/dist-subd.am
>&5
359 cat $am_dir/dist-vars.am
>&4
360 if test -n "$SUBDIRS"; then
361 cat $am_dir/dist-subd-top.am
>&5
363 cat $am_dir/dist.am
>&5
369 # Put .SUFFIXES way down at the bottom.
371 if test -n "$am_suffixes"; then
372 echo ".SUFFIXES:" >&5
373 echo ".SUFFIXES: $am_suffixes" >&5
379 # Handle auto-generating dependencies.
381 if test "$am_usedeps" = yes; then
382 if test -n "$SOURCES"; then
383 # Include code to auto-generate dependencies.
384 cat $am_dir/depend.am
>&5
387 if test "$am_incdeps" = yes; then
388 # Include any already generated dependencies.
389 if test -d .deps
&& test -f .deps
/empty.P
; then
399 test -z "$TEXINFOS" ||
test -f $am_reldir/texinfo.tex ||
{
400 echo "automake: ${am_makefile}.am defines TEXINFOS, but" 1>&2
401 echo "automake: ${am_reldir}/texinfo.tex does not exist" 1>&2
405 sed '/^[^#=]*:/,$d' ${am_makefile}.am
>&4
406 sed -n '/^[^#=]*:/,$p' ${am_makefile}.am
>&5
407 cat ${am_makefile}.vars ${am_makefile}.rules > ${am_makefile}.
in
408 rm -f ${am_makefile}.vars
${am_makefile}.rules