2 # automake - create Makefile.in from Makefile.am
3 # Copyright (C) 1994 Free Software Foundation, Inc.
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License as published by
7 # the Free Software Foundation; either version 2, or (at your option)
10 # This program is distributed in the hope that it will be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write to the Free Software
17 # Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 # Sample usage: automake Makefile lib/Makefile src/Makefile man/Makefile
20 # Written by David Mackenzie <djm@gnu.ai.mit.edu>.
22 if test $# -eq 0; then
23 echo "Usage: automake Makefile..." >&2
28 AM_DIR=`echo $0|sed s%automake%%`
48 # Turn Makefile target and variable assignments
49 # into shell variable assignments.
54 /^ *\([a-zA-Z_.][a-zA-Z0-9_.]*\):.*/{
55 s//target_\1=explicit/
59 s/^ *\([A-Z][A-Z0-9_]*\)[ ]*=[ ]*\(.*\)/\1='\2'/p
64 if test ! -f ${am_makefile}.am; then
65 echo "automake: ${am_makefile}.am: No such honkin' file"
70 echo creating ${am_makefile}.in
72 exec 4> ${am_makefile}.vars
73 exec 5> ${am_makefile}.rules
75 cat $AM_DIR/header-vars.am >&4
76 cat $AM_DIR/header.am >&5
78 DEFS= INCLUDES= CPPFLAGS= CFLAGS=
79 SOURCES= CONFIG_HEADER= SUBDIRS= PROGRAMS= LIBPROGRAMS=
80 LIBRARIES= TEXINFOS= MANS=
82 eval `sed -n -f $am_rmnl ${am_makefile}.am | sed -n -f $am_ass`
84 if test -n "$PROGRAMS$LIBPROGRAMS$LIBRARIES"; then
85 cat $AM_DIR/compile-vars.am >&4
86 cat $AM_DIR/compile.am >&5
87 for am_file in $PROGRAMS $LIBPROGRAMS $LIBRARIES; do
88 if grep "^[ ]*${am_file}_SOURCES[ ]*=" ${am_makefile}.am >/dev/null; then
89 if grep "^[ ]*${am_file}_OBJECTS[ ]*=" ${am_makefile}.am >/dev/null; then
92 sed -n -f $am_rmnl ${am_makefile}.am |
93 sed -n "/^[ ]*${am_file}_SOURCES[ ]*=/{
99 s/\\.\${kr}c/.\${kr}o/g
100 s/\\.\$(kr)c/.\${kr}o/g
101 s/\\.[cCmylfs]/.\${kr}o/g
105 SOURCES="$SOURCES \${${am_file}_SOURCES}"
107 echo "${am_file}_SOURCES = ${am_file}.c
108 ${am_file}_OBJECTS = ${am_file}.\${kr}o" >&4
109 SOURCES="$SOURCES ${am_file}.c"
111 if test -n "$CONFIG_HEADER"; then
112 echo "\$(${am_file}_OBJECTS): $CONFIG_HEADER" >&4
117 if test -n "$PROGRAMS$LIBPROGRAMS"; then
118 if test -n "$PROGRAMS"; then
119 cat $AM_DIR/programs-vars.am >&4
120 cat $AM_DIR/programs.am >&5
122 if test -n "$LIBPROGRAMS"; then
123 cat $AM_DIR/libprograms-vars.am >&4
124 cat $AM_DIR/libprograms.am >&5
126 for am_prog in $PROGRAMS $LIBPROGRAMS; do
127 eval "test \"\$target_$am_prog\" != explicit" &&
128 sed "s/@PROGRAM@/$am_prog/g" $AM_DIR/program.am >&5
132 if test -n "$LIBRARIES"; then
133 echo "LIBFILES = " `echo "$LIBRARIES"|sed 's/\([a-zA-Z0-9_][a-zA-Z0-9_]*\)/lib\1.a/g'` >&4
134 cat $AM_DIR/libraries-vars.am >&4
135 cat $AM_DIR/libraries.am >&5
136 for am_lib in $LIBRARIES; do
137 sed "s/@LIBRARY@/$am_lib/g" $AM_DIR/library.am >&5
141 if test -n "$TEXINFOS"; then
142 cat $AM_DIR/texinfos-vars.am >&4
143 cat $AM_DIR/texinfos.am >&5
144 echo "$TEXINFOS" | sed 's/^/INFOS = /; s/\.texi/.info/g' >&4
145 echo "$TEXINFOS" | sed 's/^/DVIS = /; s/\.texi/.dvi/g' >&4
148 if test -n "$MANS"; then
149 cat $AM_DIR/mans-vars.am >&4
150 cat $AM_DIR/mans.am >&5
154 "") cat $AM_DIR/clean.am >&5 ;;
155 *) cat $AM_DIR/subdirs.am >&5 ;;
158 case "$am_makefile" in
160 *) test -f aclocal.m4 && echo "ACLOCAL = aclocal.m4" >&4
161 cat $AM_DIR/remake.am >&5 ;;
164 case "$CONFIG_HEADER" in
166 */*) ;; # It's in some other directory, so don't remake it in this one.
168 test -f acconfig.h && echo "ACCONFIG = acconfig.h" >&4
169 test -f config.h.top && echo "CONFIG_TOP = config.h.top" >&4
170 test -f config.h.bot && echo "CONFIG_BOT = config.h.bot" >&4
171 cat $AM_DIR/remake-hdr.am >&5 ;;
174 echo "SOURCES = $SOURCES" >&4
176 case "$am_makefile" in
178 cat $AM_DIR/dist-subd-vars.am >&4
179 cat $AM_DIR/dist-subd.am >&5 ;;
180 *) test "$target_distname" != explicit && cat $AM_DIR/distname.am >&5
181 cat $AM_DIR/dist-vars.am >&4
182 cat $AM_DIR/dist.am >&5 ;;
185 cat $AM_DIR/footer.am >&5
187 sed '/^ *\([a-zA-Z_.][a-zA-Z0-9_. ]*\):.*/,$d' ${am_makefile}.am >&4
188 sed -n '/^ *\([a-zA-Z_.][a-zA-Z0-9_. ]*\):.*/,$p' ${am_makefile}.am >&5
189 cat ${am_makefile}.vars ${am_makefile}.rules > ${am_makefile}.in
190 rm -f ${am_makefile}.vars ${am_makefile}.rules
194 rm -f $am_rmnl $am_ass