* 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.
+1998-05-26 Marcus G. Daniels <mgd@ute.santafe.edu>
+
+ * 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 <tromey@cygnus.com>
`.' in SUBDIRS changes order of builds:
AUTOMAKE_OPTIONS = gnits
MAINT_CHARSET = latin1
-SUBDIRS = . tests m4
+SUBDIRS = . m4 tests
bin_SCRIPTS = automake aclocal
info_TEXINFOS = automake.texi
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)
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
$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.
. ': '
. ($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')
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;
&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;
# 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 = '';
@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)
* 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
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.
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.
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
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)
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)