From 9f0dd45aa9b691747c3391d65d7ef389ac9ec650 Mon Sep 17 00:00:00 2001 From: Tom Tromey Date: Mon, 28 Sep 1998 02:03:36 +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 a560ae1..56566f0 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 522871c..09b6b71 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 e532f51..5562ec4 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 3054f15..32d8689 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 85b6ad9..a17ee27 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 dd3ed09..a567850 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 47eb07f..1136f4c 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.7.4