Look for .texi file in $am_reldir
[automake.git] / automake.in
blob800b41f1bbe2dc8fba0e1454c1bc9e2455239ced
1 #! /bin/sh
2 # @configure_input@
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)
10 # any later version.
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.
27 version=@VERSION@
29 # We need prefix because datadir might depend on it.
30 prefix=@prefix@
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
36 # lines up nicely.
37 common='THANKS TODO README NEWS COPYING COPYING.LIB INSTALL ABOUT-NLS ChangeLog configure configure.in config.guess config.sub mkinstalldirs install-sh texinfo.tex'
39 # $echo will eventually be used to handle NLS matters.
40 echo=echo
42 mfiles=
43 am_usedeps=yes
44 am_incdeps=no
45 while test $# -gt 0; do
46 case "$1" in
47 --help | --h* )
48 $echo "Usage: automake [OPTION]... [Makefile]..."
49 $echo "\
50 --amdir=DIR directory storing config files
51 --help print this help, then exit
52 --version print version number, then exit
53 --include-deps include generated dependencies in Makefile"
54 echo
55 $echo "Files which are automatically distributed, if found:"
56 set $common
57 while test $# -gt 0; do
58 echo " $1 $2"
59 shift
60 # Ignore errors here, in case we have an odd number.
61 shift 2>/dev/null
62 done
63 exit 0
66 --version | --v* )
67 $echo "Automake version $version"
68 exit 0
71 --amdir=* | --a*=* )
72 am_dir="`echo \"${1}\" | sed -e 's/^[^=]*=//'`"
75 --amdir | --a* )
76 if test $# -eq 1; then
77 $echo "automake: no argument given for option \`$1'" 1>&2
78 exit 1
80 shift
81 am_dir="${1}"
84 --include-deps | --i*)
85 am_incdeps=yes
86 am_usedeps=no
89 -- ) # Stop option processing.
90 shift
91 while test $# -gt 0; do
92 mfiles="$mfiles $1"
93 shift
94 done
95 break
98 -*)
99 # FIXME consider "-" meaning stdin as input?
100 $echo "automake: unrecognized option -- \`$1'" 1>&2
101 exit 1
105 mfiles="$mfiles $1"
107 esac
108 shift
109 done
111 test -n "$mfiles" || {
112 # Look around.
113 mfiles=`echo */Makefile.am`
114 if test "$mfiles" = '*/Makefile.am'; then
115 mfiles=
116 else
117 mfiles=`echo "$mfiles" | sed 's/\.am//g'`
120 if test -f Makefile.am; then
121 mfiles="Makefile $mfiles"
124 if test -n "$mfiles"; then
125 $echo "automake: using $mfiles" 1>&2
126 else
127 $echo "automake: no \"Makefile.am\" found or specified" 1>&2
128 exit 1
133 am_status=0
135 # Some handy sed scripts.
136 am_rmnl=$am_dir/nl-remove.sed
137 am_ass=$am_dir/hack-make.sed
139 for am_makefile in $mfiles; do
140 if test ! -f ${am_makefile}.am; then
141 $echo "automake: ${am_makefile}.am: No such honkin' file" 1>&2
142 am_status=1
143 continue
147 am_localstatus=0
149 $echo "creating ${am_makefile}.in"
151 # Find our directory relative to top.
152 am_reldir=`echo "$am_makefile" | sed 's,//*[^/][^/]*$,,g'`
153 if test "$am_reldir" = "$am_makefile"; then
154 # Bogus.
155 am_reldir=.
158 exec 4> ${am_makefile}.vars
159 exec 5> ${am_makefile}.rules
161 echo "# Makefile.in generated automatically by automake $version from Makefile.am." >&4
162 cat $am_dir/header-vars.am >&4
163 cat $am_dir/header.am >&5
165 DEFS= INCLUDES= CPPFLAGS= CFLAGS=
166 SOURCES= CONFIG_HEADER= SUBDIRS= PROGRAMS= LIBPROGRAMS= SCRIPTS= LIBSCRIPTS=
167 LIBRARIES= TEXINFOS= MANS= AM_PROGRAMS=
168 am_suffixes=
169 am_recursive_install=no
170 am_dist_common=
171 # The following are targets that formerly were implemented as
172 # double-colon rules. Nowadays we have to construct such lists
173 # explicitly.
174 installexec= uninstall= id= tags= info= dvi= check=
175 installdata= all='${ALL}' install=
177 eval `sed -n -f $am_rmnl ${am_makefile}.am | sed -n -f $am_ass`
180 # If a variable is set at configure time, we still need to know the
181 # values it can assume (statically). This is done using the AM_
182 # forms in the Makefile.am. Handle it now.
184 test -n "$AM_PROGRAMS" && {
185 PROGRAMS=$AM_PROGRAMS
187 test -n "$AM_LIBPROGRAMS" && {
188 LIBPROGRAMS=$AM_LIBPROGRAMS
190 test -n "$AM_SCRIPTS" && {
191 SCRIPTS=$AM_SCRIPTS
193 test -n "$AM_LIBSCRIPTS" && {
194 LIBSCRIPTS=$AM_LIBSCRIPTS
196 test -n "$AM_LIBRARIES" && {
197 LIBRARIES=$AM_LIBRARIES
200 if grep @kr@ ${am_makefile}.am >/dev/null; then
201 kr='${kr}'
202 else
206 if test -n "$PROGRAMS$LIBPROGRAMS$LIBRARIES"; then
207 cat $am_dir/compile-vars.am >&4
208 cat $am_dir/compile.am >&5
210 am_suffixes=".c .o $am_suffixes"
212 # Check for automatic de-ANSIfication.
213 if grep @kr@ ${am_makefile}.am >/dev/null; then
214 cat $am_dir/compile-kr.am >&5
215 am_suffixes=".krc .krh .kro $am_suffixes"
218 for am_file in $PROGRAMS $LIBPROGRAMS $LIBRARIES; do
219 if eval "test \"\$var_${am_file}_SOURCES\" = explicit"; then
220 if eval "test \"\$var_${am_file}_OBJECTS\" = explicit"; then
222 else
223 sed -n -f $am_rmnl ${am_makefile}.am |
224 sed -n "/^[ ]*${am_file}_SOURCES[ ]*=/{
225 s/SOURCES/OBJECTS/
226 s/@[^@]*@//g
227 s/\$([^)]*)//g
228 s/\${[^}]*}//g
229 s/\\.cc/.${kr}o/g
230 s/\\.\${kr}c/.${kr}o/g
231 s/\\.\$(kr)c/.${kr}o/g
232 s/\\.[cCmylfs]/.${kr}o/g
234 }" >&4
236 SOURCES="$SOURCES \${${am_file}_SOURCES}"
237 OBJECTS="$OBJECTS \${${am_file}_OBJECTS}"
238 else
239 echo "${am_file}_SOURCES = ${am_file}.c" >&4
240 echo "${am_file}_OBJECTS = ${am_file}.${kr}o" >&4
241 SOURCES="$SOURCES ${am_file}.c"
242 OBJECTS="$OBJECTS ${am_file}.${kr}o"
244 if test -n "$CONFIG_HEADER"; then
245 echo "\$(${am_file}_OBJECTS): $CONFIG_HEADER" >&5
247 done
252 # Boilerplate for scripts or programs.
254 if test -n "$PROGRAMS"; then
255 cat $am_dir/programs.am >&5
256 installexec="install-programs $installexec"
257 uninstall="uninstall-programs $uninstall"
259 if test -n "$SCRIPTS"; then
260 cat $am_dir/scripts.am >&5
261 installexec="install-scripts $installexec"
262 uninstall="uninstall-scripts $uninstall"
264 if test -n "$LIBPROGRAMS$LIBSCRIPTS"; then
265 cat $am_dir/libprograms.am >&5
266 installexec="install-libprograms $installexec"
267 uninstall="uninstall-libprograms $uninstall"
269 if test -n "$LIBSCRIPTS"; then
270 cat $am_dir/libscripts.am >&5
271 installexec="install-libscripts $installexec"
272 uninstall="uninstall-libscripts $uninstall"
275 if test -n "$PROGRAMS$LIBPROGRAMS$SCRIPTS$LIBSCRIPTS"; then
276 if test -n "$PROGRAMS$LIBPROGRAMS"; then
277 for am_prog in $PROGRAMS $LIBPROGRAMS; do
278 # If `prog_LDADD' is explicitly defined, use it. Otherwise,
279 # use LDADD.
280 eval "test \"\$var_${am_prog}_LDADD\" = explicit" || {
281 # Not set, so set it.
282 echo "${am_prog}_LDADD = \${LDADD}" >&5
285 # Insert rule for this target, unless it is explicitly given
286 # in Makefile.am.
287 eval "test \"\$target_$am_prog\" != explicit" &&
288 sed "s/@PROGRAM@/$am_prog/g" $am_dir/program.am >&5
289 done
293 if test -n "$LIBRARIES"; then
294 echo "LIBFILES = " `echo "$LIBRARIES"|sed 's/\([a-zA-Z0-9_][a-zA-Z0-9_]*\)/lib\1.a/g'` >&4
295 cat $am_dir/libraries-vars.am >&4
296 cat $am_dir/libraries.am >&5
298 installexec="install-libraries $installexec"
299 uninstall="uninstall-libraries $uninstall"
301 for am_lib in $LIBRARIES; do
302 sed "s/@LIBRARY@/$am_lib/g" $am_dir/library.am >&5
303 done
306 if test -n "$TEXINFOS"; then
307 # Give an error if more than one texinfo is defined -- we
308 # can't handle that. But how to count? Sigh. We do the naive,
309 # broken thing.
310 set $TEXINFOS
311 if test $# -gt 1; then
312 $echo "automake: $am_makefile specified more than one file in \`TEXINFOS'"
313 am_localstatus=1
314 else
315 am_infobase=`echo "$TEXINFOS" | sed 's/\.texi//'`
317 am_deps="$TEXINFOS"
318 # Only do version.texi if requested. FIXME error if .texi
319 # file does not exist?
320 if grep $am_reldir/version.texi $TEXINFOS > /dev/null 2>&1; then
321 am_deps="version.texi $am_deps"
322 am_dist_common="version.texi $am_dist_common"
324 if eval "test \"\$var_${am_infobase}_TEXINFOS\" = explicit"; then
325 # User supplied eg automake_TEXINFOS. So use those as
326 # dependencies.
327 am_deps="\$(${am_infobase}_TEXINFOS) $am_deps"
328 am_dist_common"\$(${am_infobase}_TEXINFOS) $am_dist_common"
329 sed "s/@TEXI@/$TEXINFOS/g" $am_dir/texi-version.am >&5
332 if test -n "$am_deps"; then
333 echo "${am_infobase}.info: $am_deps" >&5
334 echo >&5
337 cat $am_dir/texinfos-vars.am >&4
338 cat $am_dir/texinfos.am >&5
339 am_suffixes=".texi .info .dvi $am_suffixes"
340 installdata="install-info $installdata"
341 uninstall="uninstall-info $uninstall"
342 info="\$(INFO_DEPS) $info"
343 dvi="\$(DVIS) $dvi"
345 echo "$TEXINFOS" | sed 's/^/INFOS = /; s/\.texi/.info*/g' >&4
346 echo "$TEXINFOS" | sed 's/^/INFO_DEPS = /; s/\.texi/.info/g' >&4
347 echo "$TEXINFOS" | sed 's/^/DVIS = /; s/\.texi/.dvi/g' >&4
351 if test -n "$MANS"; then
352 cat $am_dir/mans-vars.am >&4
353 cat $am_dir/mans.am >&5
355 installdata="install-man $installdata"
356 uninstall="uninstall-man $uninstall"
361 # Handle DATA and PACKAGEDATA.
363 if test -n "$DATA"; then
364 cat $am_dir/data.am >&5
365 installdata="install-ddata $installdata"
366 uninstall="uninstall-ddata $uninstall"
368 if test -n "$PACKAGEDATA"; then
369 cat $am_dir/packagedata.am >&5
370 installdata="install-pdata $installdata"
371 uninstall="uninstall-pdata $uninstall"
374 case "$SUBDIRS" in
376 if grep @kr@ ${am_makefile}.am >/dev/null; then
377 cat $am_dir/clean-kr.am >&5
378 else
379 cat $am_dir/clean.am >&5
383 cat $am_dir/subdirs.am >&5
385 all="all-recursive $all"
386 check="check-recursive $check"
387 info="info-recursive $info"
388 dvi="dvi-recursive $dvi"
389 am_recursive_install=yes
391 esac
393 case "$am_makefile" in
394 */*)
395 cat $am_dir/remake-subd.am >&5
398 test -f aclocal.m4 && echo "ACLOCAL = aclocal.m4" >&4
399 cat $am_dir/remake.am >&5
401 esac
403 case "$CONFIG_HEADER" in
404 "") ;;
405 */*) ;; # It's in some other directory, so don't remake it in this one.
407 test -f acconfig.h && echo "ACCONFIG = acconfig.h" >&4
408 test -f config.h.top && echo "CONFIG_TOP = config.h.top" >&4
409 test -f config.h.bot && echo "CONFIG_BOT = config.h.bot" >&4
410 am_dist_common="stamp-h.in $am_dist_common"
411 cat $am_dir/remake-hdr.am >&5 ;;
412 esac
415 # Handle TAGS.
417 case "$am_makefile" in
418 */*)
419 if test -n "${SOURCES}${HEADERS}${ETAGS_ARGS}"; then
420 cat $am_dir/tags-subd.am >&5
424 if test -n "${SUBDIRS}"; then
425 cat $am_dir/tags.am >&5
426 else
427 if test -n "${SOURCES}${HEADERS}${ETAGS_ARGS}"; then
428 cat $am_dir/tags-subd.am >&5
432 esac
435 # Handle "dist" targets.
438 # Look for certain common files and make sure they are included.
439 for cfile in $common; do
440 if test -f $am_reldir/$cfile; then
441 am_dist_common="$am_dist_common $cfile"
443 done
444 echo "DIST_COMMON = $am_dist_common" >&4
446 # Include "dist" boilerplate.
447 case "$am_makefile" in
448 */*)
449 cat $am_dir/dist-subd-vars.am >&4
450 echo "subdir = $am_reldir" >&5
451 cat $am_dir/dist-subd.am >&5
454 cat $am_dir/dist-vars.am >&4
455 if test -n "$SUBDIRS"; then
456 cat $am_dir/dist-subd-top.am >&5
457 else
458 cat $am_dir/dist.am >&5
461 esac
465 # Handle auto-generating dependencies.
467 if test "$am_usedeps" = yes && test -n "$SOURCES"; then
468 # Include code to auto-generate dependencies.
469 cat $am_dir/depend.am >&5
471 if test "$am_incdeps" = yes; then
472 # Include any already generated dependencies.
473 if test -d $am_reldir/.deps && test -f $am_reldir/.deps/empty.P; then
474 cat $am_reldir/.deps/*.P >&5
479 # Some final checks.
481 test -z "$TEXINFOS" || test -f $am_reldir/texinfo.tex || {
482 $echo "automake: ${am_makefile}.am defines TEXINFOS, but" 1>&2
483 $echo "automake: ${am_reldir}/texinfo.tex does not exist" 1>&2
486 case "$am_makefile" in
487 */*)
488 # In a subdirectory.
492 # In top-level, or only, directory.
493 test -f $am_reldir/install-sh || {
494 $echo "automake: $am_reldir/install-sh does not exist" 1>&2
496 test -f $am_reldir/mkinstalldirs || {
497 $echo "automake: $am_reldir/mkinstalldirs does not exist" 1>&2
500 esac
502 # Copy from Makefile.am to output.
503 sed '/^[^#=]*:/,$d' ${am_makefile}.am >&4
504 sed -n '/^[^#=]*:/,$p' ${am_makefile}.am >&5
505 echo >&5
507 echo "SOURCES = $SOURCES" >&4
508 echo "OBJECTS = $OBJECTS" >&4
509 echo >&4
512 # Put .SUFFIXES way down at the bottom.
514 if test -n "$am_suffixes"; then
515 echo ".SUFFIXES:" >&5
516 echo ".SUFFIXES: $am_suffixes" >&5
517 echo >&5
520 # Ditto .NOEXPORT.
521 cat $am_dir/footer.am >&5
523 # Output variable definitions.
524 exec 6> ${am_makefile}.in
526 cat ${am_makefile}.vars >&6
529 # Merge any targets that need to be merged.
531 for am_target in all info dvi check; do
532 # If user specified the local form of the target, then include it.
533 if eval "test \"\$target_${am_target}_local\" = explicit"; then
534 eval "${am_target}=\"${am_target}-local \$${am_target}\""
537 # Always print these targets; GNU makefile standards require it.
538 eval "am_val=\"\$${am_target}\""
539 echo "${am_target}: ${am_val}" >&6
540 echo >&6
541 done
543 # Handle the various install targets specially. We do this so that
544 # (eg) "make install-exec" will run "install-exec-recursive" if
545 # required, but "make install" won't run it twice. Step one is to
546 # see if the user specified local versions of any of the targets we
547 # handle.
548 if test -n "$target_install_exec_local"; then
549 installexec="install-exec-local $installexec"
551 if test -n "$target_uninstall_local"; then
552 uninstall="uninstall-local $uninstall"
554 if test -n "$target_install_data_local"; then
555 installdata="install-data-local $installdata"
557 # FIXME do install-local here? Maybe make it an error and tell the
558 # user to use install-data or install-exec?
560 # Step two: if we are doing recursive makes, write out the
561 # appropriate rules.
562 if test $am_recursive_install = yes; then
563 install="install-recursive $install"
564 if test -n "$installexec"; then
565 echo "install-exec-am: $installexec" >&6
566 echo >&6
567 installexec="install-exec-recursive install-exec-am"
568 install="install-exec-am $install"
570 if test -n "$installdata"; then
571 echo "install-data-am: $installdata" >&6
572 echo >&6
573 installdata="install-data-recursive install-data-am"
574 install="install-data-am $install"
576 if test -n "$uninstall"; then
577 echo "uninstall-am: $uninstall" >&6
578 echo >&6
579 uninstall="uninstall-recursive uninstall-am"
583 # Step three: print definitions users can use.
584 if test -n "$installexec"; then
585 echo "install-exec: $installexec" >&6
586 echo >&6
587 if test $am_recursive_install = no; then
588 install="install-exec $install"
591 if test -n "$installdata"; then
592 echo "install-data: $installdata" >&6
593 echo >&6
594 if test $am_recursive_install = no; then
595 install="install-data $install"
599 echo "install: $install" >&6
600 echo >&6
601 echo "uninstall: $uninstall" >&6
602 echo >&6
604 cat ${am_makefile}.rules >&6
605 rm -f ${am_makefile}.vars ${am_makefile}.rules
607 exit $am_localstatus
608 ) || {
609 am_status=1
611 done
613 exit $am_status