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 target_distname=default
79 DEFS= INCLUDES= CPPFLAGS= CFLAGS=
80 SOURCES= CONFIG_HEADER= SUBDIRS= PROGRAMS= LIBRARIES= TEXINFOS= MANS=
82 eval `sed -n -f $am_rmnl ${am_makefile}.am | sed -n -f $am_ass`
84 if test -n "$PROGRAMS" || test -n "$LIBRARIES"; then
85 cat $AM_DIR/compile-vars.am >&4
86 cat $AM_DIR/compile.am >&5
87 for am_file in $PROGRAMS $LIBRARIES; do
88 if grep "^[ ]*${am_file}_SOURCES[ ]*=" ${am_makefile}.am >/dev/null; then
89 sed -n -f $am_rmnl ${am_makefile}.am |
90 sed -n "/^[ ]*${am_file}_SOURCES[ ]*=/{
101 SOURCES="$SOURCES \${${am_file}_SOURCES}"
103 echo "${am_file}_SOURCES = ${am_file}.c
104 ${am_file}_OBJECTS = ${am_file}.o" >&4
105 SOURCES="$SOURCES ${am_file}.c"
107 if test -n "$CONFIG_HEADER"; then
108 echo "\$(${am_file}_OBJECTS): $CONFIG_HEADER" >&4
113 if test -n "$PROGRAMS"; then
114 cat $AM_DIR/programs-vars.am >&4
115 cat $AM_DIR/programs.am >&5
116 for am_prog in $PROGRAMS; do
117 sed "s/@PROGRAM@/$am_prog/g" $AM_DIR/program.am >&5
121 if test -n "$LIBRARIES"; then
122 echo "LIBFILES = " `echo "$LIBRARIES"|sed 's/\([a-zA-Z0-9_][a-zA-Z0-9_]*\)/lib\1.a/g'` >&4
123 cat $AM_DIR/libraries-vars.am >&4
124 cat $AM_DIR/libraries.am >&5
125 for am_lib in $LIBRARIES; do
126 sed "s/@LIBRARY@/$am_lib/g" $AM_DIR/library.am >&5
130 if test -n "$TEXINFOS"; then
131 cat $AM_DIR/texinfos-vars.am >&4
132 cat $AM_DIR/texinfos.am >&5
133 echo "$TEXINFOS" | sed 's/^/INFOS = /; s/\.texi/.info/g' >&4
134 echo "$TEXINFOS" | sed 's/^/DVIS = /; s/\.texi/.dvi/g' >&4
137 if test -n "$MANS"; then
138 cat $AM_DIR/mans-vars.am >&4
139 cat $AM_DIR/mans.am >&5
143 "") cat $AM_DIR/clean.am >&5 ;;
144 *) cat $AM_DIR/subdirs.am >&5 ;;
147 case "$am_makefile" in
148 */*) cat $AM_DIR/remake-subd.am >&5 ;;
149 *) test -f aclocal.m4 && echo "ACLOCAL = aclocal.m4" >&4
150 cat $AM_DIR/remake.am >&5 ;;
153 case "$CONFIG_HEADER" in
155 */*) ;; # It's in some other directory, so don't remake it in this one.
157 test -f acconfig.h && echo "ACCONFIG = acconfig.h" >&4
158 test -f config.h.top && echo "CONFIG_TOP = config.h.top" >&4
159 test -f config.h.bot && echo "CONFIG_BOT = config.h.bot" >&4
160 cat $AM_DIR/remake-hdr.am >&5 ;;
163 echo "SOURCES = $SOURCES" >&4
165 case "$am_makefile" in
167 cat $AM_DIR/dist-subd-vars.am >&4
168 cat $AM_DIR/dist-subd.am >&5 ;;
169 *) test "$target_distname" != explicit && cat $AM_DIR/distname.am >&5
170 cat $AM_DIR/dist-vars.am >&4
171 cat $AM_DIR/dist.am >&5 ;;
174 cat $AM_DIR/footer.am >&5
176 # if test -n "$SOURCES"; then
177 # echo "# Dependencies generated automatically by mkdep:" >&5
178 # mkdep -a -f ${am_makefile}.in $DEFS $INCLUDES $CPPFLAGS $CFLAGS $SOURCES
181 sed '/^ *\([a-zA-Z_.][a-zA-Z0-9_.]*\):.*/,$d' ${am_makefile}.am >> ${am_makefile}.vars
182 sed -n '/^ *\([a-zA-Z_.][a-zA-Z0-9_.]*\):.*/,$p' ${am_makefile}.am >> ${am_makefile}.rules
183 cat ${am_makefile}.vars ${am_makefile}.rules > ${am_makefile}.in
184 rm -f ${am_makefile}.vars ${am_makefile}.rules