* configure.ac: Add --enable-site-macro-dir option.
* bin/Makefile.am: Expand @SITE_MACRO_DIR@.
* bin/autom4te.in: Add --prepend-include, --include-envvar, and
--site-macro-subdir options.
* bin/autoconf.in: Add --prepend-include option.
* bin/autoheader.in: Add --prepend-include option.
* bin/autoreconf.in: Add --prepend-include option.
* bin/autoscan.in: Add --prepend-include option.
* bin/autoupdate.in: Add --prepend-include option.
* doc/autoconf.texi: Document use of $AC_MACRO_PATH and site
macro directory, remove note that include path directories are
used in reverse order, and document --prepend-include option.
* lib/autom4te.in: Use --prepend-include instead of --include.
* tests/wrapsh.in: Use --prepend-include instead of --include.
+2002-07-17 Mark D. Roth <roth@feep.net>
+
+ * configure.ac: Add --enable-site-macro-dir option.
+ * bin/Makefile.am: Expand @SITE_MACRO_DIR@.
+ * bin/autom4te.in: Add --prepend-include, --include-envvar, and
+ --site-macro-subdir options.
+ * bin/autoconf.in: Add --prepend-include option.
+ * bin/autoheader.in: Add --prepend-include option.
+ * bin/autoreconf.in: Add --prepend-include option.
+ * bin/autoscan.in: Add --prepend-include option.
+ * bin/autoupdate.in: Add --prepend-include option.
+ * doc/autoconf.texi: Document use of $AC_MACRO_PATH and site
+ macro directory, remove note that include path directories are
+ used in reverse order, and document --prepend-include option.
+ * lib/autom4te.in: Use --prepend-include instead of --include.
+ * tests/wrapsh.in: Use --prepend-include instead of --include.
+
2002-07-17 Akim Demaille <akim@epita.fr>
* lib/autoconf/general.m4 (_AC_INIT_PACKAGE): `_' is allowed in
-e 's,@M4\@,$(M4),g' \
-e 's,@AWK\@,$(AWK),g' \
-e 's,@VERSION\@,$(VERSION),g' \
- -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g'
+ -e 's,@PACKAGE_NAME\@,$(PACKAGE_NAME),g' \
+ -e 's,@SITE_MACRO_DIR\@,$(SITE_MACRO_DIR),g'
# autoconf is written in M4sh.
AUTOM4SH = $(top_builddir)/tests/autom4te --language M4sh
-V, --version print version number, then exit
-v, --verbose verbosely report processing
-d, --debug don't remove temporary files
- -I, --include=DIR look for input files in DIR (cumulative)
+ -B, --prepend-include=DIR prepend directory DIR to search path
+ -I, --include=DIR append directory DIR to search path
-f, --force consider all files obsolete
-o, --output=FILE save output in FILE (stdout is the default)
-W, --warnings=CATEGORY report the warnings falling in CATEGORY [syntax]
--debug | -d | \
--force | -f | \
--include=* | -I?* | \
+ --prepend-include=* | -B?* | \
--warnings=* | -W?* )
AUTOM4TE="$AUTOM4TE $1"; shift ;;
# Options with separated arg passed as is to autom4te.
--include | -I | \
+ --prepend-include | -B | \
--warnings | -W )
test $# = 1 && eval "$exit_missing_arg"
AUTOM4TE="$AUTOM4TE $option $2"
my $autom4te = $ENV{'AUTOM4TE'} || '@bindir@/@autom4te-name@';
local $config_h;
my $config_h_in;
+my @prepend_include;
my @include;
my @warning;
\`error\' warnings are error
Library directories:
- -I, --include=DIR look for files in DIR (cumulative)
+ -B, --prepend-include=DIR prepend directory DIR to search path
+ -I, --include=DIR append directory DIR to search path
Report bugs to <bug-autoconf\@gnu.org>.
END
my $srcdir;
getopt ('I|include|A|autoconf-dir|m|macrodir|l|localdir=s' => \@include,
+ 'B|prepend-include=s' => \@prepend_include,
'W|warning=s' => \@warning);
if (! @ARGV)
parse_args;
# Preach.
-my $config_h_top = find_file ("config.h.top?", @include);
-my $config_h_bot = find_file ("config.h.bot?", @include);
-my $acconfig_h = find_file ("acconfig.h?", @include);
+my $config_h_top = find_file ("config.h.top?",
+ reverse(@prepend_include), @include);
+my $config_h_bot = find_file ("config.h.bot?",
+ reverse(@prepend_include), @include);
+my $acconfig_h = find_file ("acconfig.h?",
+ reverse(@prepend_include), @include);
if ($config_h_top || $config_h_bot || $acconfig_h)
{
my $msg = << "END";
# Set up autoconf.
my $autoconf = "$autom4te --language=autoconf ";
$autoconf .= join (' ', map { "--include=$_" } @include);
+$autoconf .= join (' ', map { "--prepend-include=$_" } @prepend_include);
$autoconf .= ' --debug' if $debug;
$autoconf .= ' --force' if $force;
$autoconf .= ' --verbose' if $verbose;
The environment variable \`WARNINGS\' is honored.
Library directories:
- -I, --include=DIR look for FILES in DIR (cumulative)
+ -B, --prepend-include=DIR prepend directory DIR to search path
+ -I, --include=DIR append directory DIR to search path
Tracing:
-t, --trace=MACRO report the MACRO invocations
# Process the arguments for real this time.
my @trace;
+ my @prepend_include;
+ my $include_envvar;
+ my @site_macro_subdirs;
getopt
(
# Operation modes:
"M|melt" => \$melt,
# Library directories:
+ "B|prepend-include=s" => \@prepend_include,
"I|include=s" => \@include,
+ "include-envvar=s" => \$include_envvar,
+ "site-macro-subdir=s" => \@site_macro_subdirs,
# Tracing:
# Using a hash for traces is seducing. Unfortunately, upon `-t FOO',
$melt = 1
if $freeze;
+ # Add directories from the appropriate env var to the include path.
+ @include = (@include, split(/:/, $ENV{$include_envvar}))
+ if defined($include_envvar) && exists($ENV{$include_envvar});
+
+ # Also add the site macro directory, if applicable.
+ map { @include = (@include, "@SITE_MACRO_DIR@/$_"); } @site_macro_subdirs
+ if ('@SITE_MACRO_DIR@' ne 'no') && @site_macro_subdirs;
+
# Normalize the includes: the first occurrence is enough, several is
# a pain since it introduces a useless difference in the path which
# invalidates the cache. And strip `.' which is implicit and always
# first.
- @include = grep { !/^\.$/ } uniq (@include);
+ @include = grep { !/^\.$/ } uniq (reverse(@prepend_include), @include);
# Convert @trace to %trace, and work around the M4 builtins tracing
# problem.
#
# Neutralize its stdin, so that GNU M4 1.5 doesn't neutralize SIGINT.
#
- # Be extremely cautious to reverse the includes when talking to M4:
- # it doesn't speak the same --include as we do.
- #
# We don't output directly to the cache files, to avoid problems
# when we are interrupted (that leaves corrupted files).
my $command = ("$m4"
- . join (' --include=', '', reverse @include)
+ . join (' --include=', '', @include)
. " --define=m4_warnings=$m4_warnings"
. ' --debug=aflq'
. " --error-output=$tcache" . $req->id . "t"
# output but comments and empty lines.
my $command = ("$m4"
. ' --fatal-warning'
- . join (' --include=', '', reverse @include)
+ . join (' --include=', '', @include)
. ' --define=divert'
. " @ARGV"
. ' </dev/null');
# or an improper paren etc.
$command = ("$m4"
. ' --fatal-warning'
- . join (' --include=', '', reverse @include)
+ . join (' --include=', '', @include)
. " --freeze-state=$output"
. " @ARGV"
. ' </dev/null');
-s, --symlink instead of copying, install symbolic links
Library directories:
- -I, --include=DIR look for FILES in DIR (cumulative)
+ -B, --prepend-include=DIR prepend directory DIR to search path
+ -I, --include=DIR append directory DIR to search path
The environment variables AUTOCONF, AUTOHEADER, AUTOMAKE, ACLOCAL,
AUTOPOINT, LIBTOOLIZE are honored.
# --install -- as --add-missing in other tools.
my $install = 0;
+my @prepend_include;
my @include;
my $status = 0;
# symlink -- when --install, use symlinks instead.
my $srcdir;
getopt ('I|include|A|autoconf-dir|m|macrodir|l|localdir=s' => \@include,
+ 'B|prepend-include=s' => \@prepend_include,
'i|install' => \$install,
's|symlink' => \$symlink);
# Dispatch autoreconf's option to the tools.
# --include;
$autoconf .= join (' --include=', '', @include);
+ $autoconf .= join (' --prepend-include=', '', @prepend_include);
$autoheader .= join (' --include=', '', @include);
+ $autoheader .= join (' --prepend-include=', '', @prepend_include);
# --install and --symlink;
if ($install)
# Autoconf and lib files.
my $autom4te = $ENV{'AUTOM4TE'} || '@bindir@/@autom4te-name@';
my $autoconf = "$autom4te --language=autoconf";
+my @prepend_include;
my @include = ('@datadir@');
# $help
-V, --version print version number, then exit
-v, --verbose verbosely report processing
-d, --debug don't remove temporary files
- -I, --include=DIR look for input files in DIR (cumulative)
+ -B, --prepend-include=DIR prepend directory DIR to search path
+ -I, --include=DIR append directory DIR to search path
Report bugs to <bug-autoconf\@gnu.org>.\n";
# Process any command line arguments.
sub parse_args ()
{
- getopt ("I|include|A|autoconf-dir|m|macrodir=s" => \@include);
+ getopt ('I|include|A|autoconf-dir|m|macrodir=s' => \@include,
+ 'B|prepend-include=s' => @prepend_include);
die "$me: too many arguments
Try `$me --help' for more information.\n"
my $tables_are_consistent = 1;
foreach my $kind (@kinds)
{
- my $file = find_file ("autoscan/$kind", @include);
+ my $file = find_file ("autoscan/$kind",
+ reverse(@prepend_include), @include);
my $table = new Autom4te::XFile $file;
while ($_ = $table->getline)
{
$autoconf .= " --debug" if $debug;
$autoconf .= " --verbose" if $verbose;
$autoconf .= join (' --include=', '', @include);
+$autoconf .= join (' --prepend-include=', '', @prepend_include);
my $configure_ac = find_configure_ac;
init_tables;
my $autom4te = $ENV{'AUTOM4TE'} || '@bindir@/@autom4te-name@';
my $autoconf = "$autom4te --language=autoconf";
# We need to find m4sugar.
+my @prepend_include;
my @include = ('@datadir@');
my $force = 0;
# m4.
-V, --version print version number, then exit
-v, --verbose verbosely report processing
-d, --debug don't remove temporary files
- -I, --include=DIR look for input files in DIR (cumulative)
+ -B, --prepend-include=DIR prepend directory DIR to search path
+ -I, --include=DIR append directory DIR to search path
-f, --force consider all files obsolete
Report bugs to <bug-autoconf\@gnu.org>.
my $srcdir;
getopt ('I|include|A|autoconf-dir|m|macrodir|l|localdir=s' => \@include,
+ 'B|prepend-include=s' => \@prepend_include,
'f|force' => \$force);
if (! @ARGV)
$autoconf .= " --force" if $force;
$autoconf .= " --verbose" if $verbose;
$autoconf .= join (' --include=', '', @include);
+$autoconf .= join (' --prepend-include=', '', @prepend_include);
mktmpdir ('au');
handle_m4_macros;
or die "$me: cannot close $tmp/input.m4: $!\n";
# Now ask m4 to perform the update.
- # M4 and I don't agree on the associativity of `--include': reverse!
- xsystem ("$m4"
- . join (' --include=', '', reverse (@include, $tmp))
+ xsystem ("$m4 --include=$tmp"
+ . join (' --include=', '', reverse (@prepend_include))
+ . join (' --include=', '', @include)
. " $tmp/input.m4 >$tmp/updated");
update_file ("$tmp/updated",
"$file" eq "$tmp/stdin" ? '-' : "$file");
AM_INIT_AUTOMAKE
+AC_ARG_ENABLE([site-macro-dir],
+ AC_HELP_STRING([--enable-site-macro-dir=DIR],
+ [use site macro directory DIR @<:@DATADIR/autoconf/site_macros@:>@]),
+ ,
+ [enable_site_macro_dir='${datadir}/autoconf/site_macros'])
+AC_SUBST([SITE_MACRO_DIR], "${enable_site_macro_dir}")
+
# Initialize the test suite and build position independent wrappers.
AC_CONFIG_TESTDIR([tests])
AC_CONFIG_FILES([tests/Makefile tests/atlocal])
@item --include=@var{dir}
@itemx -I @var{dir}
-Also look for input files in @var{dir}. Multiple invocations
-accumulate. Directories are browsed from last to first.
+Append @var{dir} to the include path. Multiple invocations accumulate.
+
+@item --prepend-include=@var{dir}
+@item -B @var{dir}
+Prepend @var{dir} to the include path. Multiple invocations accumulate.
@end table
@node ifnames Invocation
@item --include=@var{dir}
@itemx -I @var{dir}
-Also look for input files in @var{dir}. Multiple invocations
-accumulate. Directories are browsed from last to first.
+Append @var{dir} to the include path. Multiple invocations accumulate.
+
+@item --prepend-include=@var{dir}
+@item -B @var{dir}
+Prepend @var{dir} to the include path. Multiple invocations accumulate.
+
+After searching any directories specified using @option{--prepend-include}
+or @option{--include}, @command{autoconf} will also search the directories
+specified in the @code{AC_MACRO_PATH} environment variable, if set.
+And finally, @command{autoconf} will also search the system-wide site
+macro directory, which is set to
+@samp{$@{datadir@}/autoconf/site_macros/autoconf} by default.
@item --output=@var{file}
@itemx -o @var{file}
@item --include=@var{dir}
@itemx -I @var{dir}
-Also look for input files in @var{dir}. Multiple invocations
-accumulate. Directories are browsed from last to first.
+Append @var{dir} to the include path. Multiple invocations accumulate.
+
+@item --prepend-include=@var{dir}
+@item -B @var{dir}
+Prepend @var{dir} to the include path. Multiple invocations accumulate.
@end table
@item --include=@var{dir}
@itemx -I @var{dir}
-Also look for input files in @var{dir}. Multiple invocations accumulate.
-Directories are browsed from last to first.
+Append @var{dir} to include path. Multiple invocations accumulate.
+
+@item --prepend-include=@var{dir}
+@item -B @var{dir}
+Prepend @var{dir} to include path. Multiple invocations accumulate.
@item --warnings=@var{category}
@itemx -W @var{category}
@item --include=@var{dir}
@itemx -I @var{dir}
Also look for input files in @var{dir}. Multiple invocations
-accumulate. Contrary to M4 but in agreement with common sense,
-directories are browsed from last to first.
+accumulate.
@item --output=@var{file}
@itemx -o @var{file}
@item Autoconf
create Autoconf executable configure scripts.
@end table
+
+@item --prepend-include=@var{dir}
+@item -B @var{dir}
+Prepend directory @var{dir} to the search path. This is used to include
+the language-specific files before any third-party macros.
+
+@item --include-envvar=@var{envvar}
+Add directories specified in the environment variable @var{envvar} to
+the search path.
+
+@item --site-macro-subdir=@var{subdir}
+If the site macro directory is set, add the subdirectory @var{subdir}
+of the site macro directory to the search path.
@end table
@cindex @file{autom4te.cfg}
As an example, if Autoconf is installed in its default location,
-@file{/usr/local}, running @samp{autom4te -l m4sugar foo.m4} is strictly
-equivalent to running @samp{autom4te --include /usr/local/share/autoconf
-m4sugar/m4sugar.m4f --warning syntax foo.m4}. Recursive expansion
-applies: running @samp{autom4te -l m4sh foo.m4}, is the same as
-@samp{autom4te --language M4sugar m4sugar/m4sh.m4f foo.m4}, i.e.,
-@samp{autom4te --include /usr/local/share/autoconf m4sugar/m4sugar.m4f
-m4sugar/m4sh.m4f --mode 777 foo.m4}. The definition of the languages is
-stored in @file{autom4te.cfg}.
+@file{/usr/local}, running @samp{autom4te -l m4sugar foo.m4} is
+strictly equivalent to running @samp{autom4te --prepend-include
+/usr/local/share/autoconf m4sugar/m4sugar.m4f --warning syntax foo.m4}.
+Recursive expansion applies: running @samp{autom4te -l m4sh foo.m4},
+is the same as @samp{autom4te --language M4sugar m4sugar/m4sh.m4f
+foo.m4}, i.e., @samp{autom4te --prepend-include /usr/local/share/autoconf
+m4sugar/m4sugar.m4f m4sugar/m4sh.m4f --mode 777 foo.m4}. The definition
+of the languages is stored in @file{autom4te.cfg}.
@node Programming in M4sugar
## ---------- ##
begin-language: "Autoconf"
-args: --include @datadir@
+args: --prepend-include @datadir@
+args: --site-macro-subdir autoconf
+args: --include-envvar AC_MACRO_PATH
args: autoconf/autoconf.m4f
args: acsite.m4?
args: aclocal.m4?
## -------- ##
begin-language: "Autotest"
-args: --include @datadir@
+args: --prepend-include @datadir@
+args: --site-macro-subdir autotest
+args: --include-envvar AT_MACRO_PATH
args: autotest/autotest.m4f
args: package.m4?
args: --mode 777
## ---- ##
begin-language: "M4sh"
-args: --include @datadir@
+args: --prepend-include @datadir@
+args: --site-macro-subdir m4sh
+args: --include-envvar M4SH_MACRO_PATH
args: m4sugar/m4sh.m4f
args: --mode 777
args: --language M4sugar
## ------- ##
begin-language: "M4sugar"
-args: --include @datadir@
+args: --prepend-include @datadir@
+args: --site-macro-subdir m4sugar
+args: --include-envvar M4SUGAR_MACRO_PATH
args: m4sugar/m4sugar.m4f
args: --warning syntax
end-language: "M4sugar"
# @configure_input@
# Running `$0' as if it were installed.
-exec @abs_top_builddir@/bin/$as_me --include @abs_top_builddir@/lib ${1+"$@"}
+exec @abs_top_builddir@/bin/$as_me --prepend-include @abs_top_builddir@/lib ${1+"$@"}