From 78eb9e553c48f9334ea6f199251b802f117d308a Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 28 Sep 1998 02:03:28 +0000 Subject: [PATCH] `include' handling from Marcus Daniels: * automake.in: New pattern: INCLUDE_PATTERN. (read_am_file): Make AM_FILE a local filehandle. For INCLUDE_PATTERN, store included paths on @include_stack and call read_am_file with argument. (handle_configure): When printing the dependencies for Makefile.in, print the items on include_stack (if any) as dependencies, too. * automake.texi: Make a command index `cm' that goes into the concept index. Put if, endif, else, and include in the command index. (Include): Show usage of include directive. --- ChangeLog | 14 ++++++++++++++ Makefile.in | 4 ++-- THANKS | 1 + automake.in | 28 ++++++++++++++++++++++++++-- automake.texi | 35 +++++++++++++++++++++++++++++++++-- m4/Makefile.in | 2 +- tests/Makefile.in | 2 +- 7 files changed, 78 insertions(+), 8 deletions(-) diff --git a/ChangeLog b/ChangeLog index a560ae14..56566f01 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,17 @@ +1998-05-26 Marcus G. Daniels + + * automake.in: New pattern: INCLUDE_PATTERN. + (read_am_file): Make AM_FILE a local filehandle. + For INCLUDE_PATTERN, store included paths on @include_stack and call + read_am_file with argument. + (handle_configure): When printing the dependencies for + Makefile.in, print the items on include_stack (if any) as + dependencies, too. + + * automake.texi: Make a command index `cm' that goes into the + concept index. Put if, endif, else, and include in the command index. + (Include): Show usage of include directive. + Mon Sep 28 00:03:45 1998 Tom Tromey `.' in SUBDIRS changes order of builds: diff --git a/Makefile.in b/Makefile.in index 522871cd..09b6b713 100644 --- a/Makefile.in +++ b/Makefile.in @@ -66,7 +66,7 @@ VERSION = @VERSION@ AUTOMAKE_OPTIONS = gnits MAINT_CHARSET = latin1 -SUBDIRS = . tests m4 +SUBDIRS = . m4 tests bin_SCRIPTS = automake aclocal info_TEXINFOS = automake.texi @@ -113,7 +113,7 @@ GZIP = --best all: all-redirect .SUFFIXES: .SUFFIXES: .dvi .info .ps .texi .texinfo .txi -$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --gnits Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) diff --git a/THANKS b/THANKS index e532f519..5562ec4c 100644 --- a/THANKS +++ b/THANKS @@ -47,6 +47,7 @@ Kevin Dalley kevin@aimnet.com Kevin Street street@iname.com L. Peter Deutsch ghost@aladdin.com Maciej W. Rozycki macro@ds2.pg.gda.pl +Marcus G. Daniels mgd@ute.santafe.edu Marius Vollmer mvo@zagadka.ping.de Mark Eichin eichin@cygnus.com Mark Galassi rosalia@nis.lanl.gov diff --git a/automake.in b/automake.in index 3054f15b..32d8689a 100755 --- a/automake.in +++ b/automake.in @@ -47,6 +47,8 @@ $GNITS_VERSION_PATTERN = "[0-9]+\\.[0-9]+([a-z]|\\.[0-9]+)?"; $IF_PATTERN = "^if[ \t]+\([A-Za-z][A-Za-z0-9_]*\)[ \t]*\(#.*\)?\$"; $ELSE_PATTERN = "^else[ \t]*\(#.*\)?\$"; $ENDIF_PATTERN = "^endif[ \t]*\(#.*\)?\$"; +# This will pass through anything not of the prescribed form. +$INCLUDE_PATTERN = "^include[ \t]+((\\\$\\\(top_srcdir\\\)/[^ \t\n]+)|(\\\$\\\(srcdir\\\)/[^ \t\n]+)|([^/][^\\\ \t]+))[ \t]*(#.*)?\$"; # Some regular expressions. One reason to put them here is that it # makes indentation work better in Emacs. @@ -3058,7 +3060,9 @@ sub handle_configure . ': ' . ($seen_maint_mode ? '@MAINT@ ' : '') . $amfile . ' ' - . '$(top_srcdir)/configure.in $(ACLOCAL_M4)' . "\n" + . '$(top_srcdir)/configure.in $(ACLOCAL_M4)' + . ' ' . join (' ', @include_stack) + . "\n" . "\tcd \$(top_srcdir) && \$(AUTOMAKE) " . ($cygnus_mode ? '--cygnus' : ('--' . $strictness_name)) . ($cmdline_use_dependencies ? '' : ' --include-deps') @@ -5127,6 +5131,7 @@ sub define_program_variable sub read_am_file { local ($amfile) = @_; + local (*AM_FILE); open (AM_FILE, $amfile) || die "automake: couldn't open \`$amfile': $!\n"; print "automake: reading $amfile\n" if $verbose; @@ -5361,8 +5366,24 @@ sub read_am_file &am_line_error ($., "bad macro name \`$last_var_name'") if ! $is_ok_macro; } + elsif (/$INCLUDE_PATTERN/o) + { + local ($path) = $1; + + if ($path =~ s/^\$\(top_srcdir\)\///) + { + push (@include_stack, "\$\(top_srcdir\)/$path"); + } + else + { + $path =~ s/\$\(srcdir\)\///; + push (@include_stack, "\$\(srcdir\)/$path"); + $path = $relative_dir . "/" . $path; + } + &read_am_file ($path); + } else - { + { # This isn't an error; it is probably a continued rule. # In fact, this is what we assume. $was_rule = 1; @@ -5565,6 +5586,9 @@ sub initialize_per_input # This is the conditional stack. @conditional_stack = (); + # This holds the set of included files. + @include_stack = (); + # This holds the "relative directory" of the current Makefile.in. # Eg for src/Makefile.in, this is "src". $relative_dir = ''; diff --git a/automake.texi b/automake.texi index 85b6ad9a..a17ee272 100644 --- a/automake.texi +++ b/automake.texi @@ -82,12 +82,15 @@ approved by the Free Software Foundation. @defcodeindex op @c Define an index of targets. @defcodeindex tr +@c Define an index of commands. +@defcodeindex cm @c Put everything in one index (arbitrarily chosen to be the concept index). @syncodeindex cv cp @syncodeindex op cp @syncodeindex tr cp @syncodeindex vr cp +@syncodeindex cm cp @ifinfo @node Top, Introduction, (dir), (dir) @@ -116,6 +119,7 @@ documents version @value{VERSION}. * Options:: Changing Automake's behavior * Miscellaneous:: Miscellaneous rules * Conditionals:: Conditionals +* Include:: Including extra files in an Automake template. * Gnits:: The effect of @code{--gnu} and @code{--gnits} * Cygnus:: The effect of @code{--cygnus} * Extending:: Extending Automake @@ -2382,7 +2386,7 @@ will be suppressed. Unrecognized options are diagnosed by @code{automake}. -@node Miscellaneous, Conditionals, Options, Top +@node Miscellaneous, Include, Options, Top @chapter Miscellaneous Rules There are a few rules and variables that didn't fit anywhere else. @@ -2449,7 +2453,30 @@ source files, you would also need to add these suffixes to the list: SUFFIXES = .java .class @end example -@node Conditionals, Gnits, Miscellaneous, Top +@node Include, Conditionals, Miscellaneous, Top +@chapter Include + +@cmindex include +To include another file (perhaps for common rules), +the following syntax is supported: + +include ($(srcdir)|$(top_srcdir))/filename + +Using files in the current directory: +@example +include $(srcdir)/Makefile.extra +@end example + +@example +include Makefile.generated +@end example + +Using a file in the top level directory: +@example +include $(top_srcdir)/filename +@end example + +@node Conditionals, Gnits, Include, Top @chapter Conditionals Automake supports a simple type of conditionals. @@ -2485,6 +2512,10 @@ AM_CONDITIONAL(DEBUG, test x$debug = xtrue) Here is an example of how to use that conditional in @file{Makefile.am}: +@cmindex if +@cmindex endif +@cmindex else + @example if DEBUG DBG = debug diff --git a/m4/Makefile.in b/m4/Makefile.in index dd3ed094..a5678502 100644 --- a/m4/Makefile.in +++ b/m4/Makefile.in @@ -84,7 +84,7 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) GZIP = --best all: all-redirect .SUFFIXES: -$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --gnits m4/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) diff --git a/tests/Makefile.in b/tests/Makefile.in index 47eb07f2..1136f4cf 100644 --- a/tests/Makefile.in +++ b/tests/Makefile.in @@ -109,7 +109,7 @@ DISTFILES = $(DIST_COMMON) $(SOURCES) $(HEADERS) $(TEXINFOS) $(EXTRA_DIST) GZIP = --best all: all-redirect .SUFFIXES: -$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) +$(srcdir)/Makefile.in: Makefile.am $(top_srcdir)/configure.in $(ACLOCAL_M4) cd $(top_srcdir) && $(AUTOMAKE) --gnits tests/Makefile Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status $(BUILT_SOURCES) -- 2.43.5