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 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
39 common
='THANKS TODO README NEWS COPYING COPYING.LIB INSTALL NLS ChangeLog configure configure.in config.guess config.sub mkinstalldirs install-sh texinfo.tex'
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
49 while test $# -gt 0; do
54 echo "Files which are automatically distributed, if found:"
56 while test $# -gt 0; do
65 echo "Automake version $version"
69 -- ) # Stop option processing.
75 # FIXME consider "-" meaning stdin as input?
76 echo "automake: unrecognized option -- \`$1'" 1>&2
88 test -n "$mfiles" ||
{
90 mfiles
=`echo */Makefile.am`
91 if test "$mfiles" = '*/Makefile.am'; then
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
114 cat > $am_rmnl <<\EOF
130 # Turn Makefile target and variable assignments into shell variable
132 # * For targets, define the variable `target_NAME' to "explicit".
133 # * For variables whose names are uppercase, perform the actual assignment.
134 # We only do this for all-upper variables to avoid conflict with variables
136 # * For other variables, define `var_NAME' to "explicit". Such variables
137 # can only be used as flags; any use of their values must be done
138 # later, in the generated Makefile.
143 /^
*\
([a-zA-Z_.
][a-zA-Z0-9_.
]*\
):.
*/{
144 s
//target_\
1=explicit
/
148 s
/^
*\
([A-Z
][A-Z0-9_
]*\
)[ ]*=[ ]*\
(.
*\
)/\
1='\2'/p
149 s
/^
*\
([A-Za-z
][A-Za-z0-9_
]*\
)[ ]*=[ ]*\
(.
*\
)/var_\
1=explicit
/p
152 for am_makefile
in $mfiles; do
154 if test ! -f ${am_makefile}.am
; then
155 echo "automake: ${am_makefile}.am: No such honkin' file" 1>&2
160 echo creating
${am_makefile}.
in
162 exec 4> ${am_makefile}.vars
163 exec 5> ${am_makefile}.rules
165 echo "# Makefile.in generated automatically by automake $version from Makefile.am." >&4
166 cat $am_dir/header-vars.am
>&4
167 cat $am_dir/header.am
>&5
169 DEFS
= INCLUDES
= CPPFLAGS
= CFLAGS
=
170 SOURCES
= CONFIG_HEADER
= SUBDIRS
= PROGRAMS
= LIBPROGRAMS
= SCRIPTS
= LIBSCRIPTS
=
171 LIBRARIES
= TEXINFOS
= MANS
= AM_PROGRAMS
=
173 eval `sed -n -f $am_rmnl ${am_makefile}.am | sed -n -f $am_ass`
176 # If a variable is set at configure time, we still need to know the
177 # values it can assume (statically). This is done using the AM_
178 # forms in the Makefile.am. Handle it now.
180 test -n "$AM_PROGRAMS" && {
181 PROGRAMS
=$AM_PROGRAMS
183 test -n "$AM_LIBPROGRAMS" && {
184 LIBPROGRAMS
=$AM_LIBPROGRAMS
186 test -n "$AM_SCRIPTS" && {
189 test -n "$AM_LIBSCRIPTS" && {
190 LIBSCRIPTS
=$AM_LIBSCRIPTS
192 test -n "$AM_LIBRARIES" && {
193 LIBRARIES
=$AM_LIBRARIES
196 if grep @kr@
${am_makefile}.am
>/dev
/null
; then
202 if test -n "$PROGRAMS$LIBPROGRAMS$LIBRARIES"; then
203 cat $am_dir/compile-vars.am
>&4
204 cat $am_dir/compile.am
>&5
205 grep @kr@
${am_makefile}.am
>/dev
/null
&& cat $am_dir/compile-kr.am
>&5
206 for am_file
in $PROGRAMS $LIBPROGRAMS $LIBRARIES; do
207 if grep "^[ ]*${am_file}_SOURCES[ ]*=" ${am_makefile}.am
>/dev
/null
; then
208 if grep "^[ ]*${am_file}_OBJECTS[ ]*=" ${am_makefile}.am
>/dev
/null
; then
211 sed -n -f $am_rmnl ${am_makefile}.am |
212 sed -n "/^[ ]*${am_file}_SOURCES[ ]*=/{
218 s/\\.\${kr}c/.${kr}o/g
219 s/\\.\$(kr)c/.${kr}o/g
220 s/\\.[cCmylfs]/.${kr}o/g
224 SOURCES
="$SOURCES \${${am_file}_SOURCES}"
226 echo "${am_file}_SOURCES = ${am_file}.c
227 ${am_file}_OBJECTS = ${am_file}.${kr}o" >&4
228 SOURCES
="$SOURCES ${am_file}.c"
230 if test -n "$CONFIG_HEADER"; then
231 echo "\$(${am_file}_OBJECTS): $CONFIG_HEADER" >&5
236 if test -n "$PROGRAMS$LIBPROGRAMS$SCRIPTS$LIBSCRIPTS"; then
237 if test -n "$PROGRAMS$SCRIPTS"; then
238 cat $am_dir/programs.am
>&5
240 if test -n "$LIBPROGRAMS$LIBSCRIPTS"; then
241 cat $am_dir/libprograms.am
>&5
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 echo "$TEXINFOS" |
sed 's/^/INFOS = /; s/\.texi/.info*/g' >&4
273 echo "$TEXINFOS" |
sed 's/^/INFO_DEPS = /; s/\.texi/.info/g' >&4
274 echo "$TEXINFOS" |
sed 's/^/DVIS = /; s/\.texi/.dvi/g' >&4
277 if test -n "$MANS"; then
278 cat $am_dir/mans-vars.am
>&4
279 cat $am_dir/mans.am
>&5
283 "") if grep @kr@
${am_makefile}.am
>/dev
/null
; then
284 cat $am_dir/clean-kr.am
>&5
285 else cat $am_dir/clean.am
>&5
287 cat $am_dir/footer.am
>&5 ;;
288 *) cat $am_dir/subdirs.am
>&5 ;;
291 case "$am_makefile" in
293 cat $am_dir/remake-subd.am
>&5
296 test -f aclocal.
m4 && echo "ACLOCAL = aclocal.m4" >&4
297 cat $am_dir/remake.am
>&5
301 case "$CONFIG_HEADER" in
303 */*) ;; # It's in some other directory, so don't remake it in this one.
305 test -f acconfig.h
&& echo "ACCONFIG = acconfig.h" >&4
306 test -f config.h.top
&& echo "CONFIG_TOP = config.h.top" >&4
307 test -f config.h.bot
&& echo "CONFIG_BOT = config.h.bot" >&4
308 cat $am_dir/remake-hdr.am
>&5 ;;
311 echo "SOURCES = $SOURCES" >&4
317 case "$am_makefile" in
319 if test -n "${SOURCES}${HEADERS}${ETAGS_ARGS}"; then
320 cat $am_dir/tags-subd.am
>&5
324 if test -n "${SUBDIRS}"; then
325 cat $am_dir/tags.am
>&5
327 if test -n "${SOURCES}${HEADERS}${ETAGS_ARGS}"; then
328 cat $am_dir/tags-subd.am
>&5
335 # Handle "dist" targets.
337 am_reldir
=`echo "$am_makefile" | sed 's,//*[^/][^/]*$,,g'`
338 if test "$am_reldir" = "$am_makefile"; then
342 # Look for certain common files and make sure they are included.
344 for cfile
in $common; do
345 if test -f $am_reldir/$cfile; then
346 dlist
="$dlist $cfile"
349 echo "DIST_COMMON = $dlist" >&4
350 # Include "dist" boilerplate.
351 case "$am_makefile" in
353 cat $am_dir/dist-subd-vars.am
>&4
354 echo "subdir = $am_reldir" >&5
355 cat $am_dir/dist-subd.am
>&5
358 cat $am_dir/dist-vars.am
>&4
359 if test -n "$SUBDIRS"; then
360 cat $am_dir/dist-subd-top.am
>&5
362 cat $am_dir/dist.am
>&5
371 test -z "$TEXINFOS" ||
test -f $am_reldir/texinfo.tex
) ||
{
372 echo "automake: ${am_makefile}.am defines TEXINFOS, but" 1>&2
373 echo "automake: ${am_reldir}/texinfo.tex does not exist" 1>&2
377 sed '/^[^#=]*:/,$d' ${am_makefile}.am
>&4
378 sed -n '/^[^#=]*:/,$p' ${am_makefile}.am
>&5
379 cat ${am_makefile}.vars ${am_makefile}.rules > ${am_makefile}.
in
380 rm -f ${am_makefile}.vars
${am_makefile}.rules
385 rm -f $am_rmnl $am_ass