On Wed May 22 21:40 2002 -0500, Mark D. Roth wrote:
> On Wed May 22 15:50 2002 -0700, Paul Eggert wrote:
> > My own reaction is positive, but I would suggest that you write up the
> > proposal, as a proposed patch to the manual.  (Often the documentation
> > is the hardest to write, so perhaps it'll be easier for you if you
> > implement it and then document it.  :-)
> 
> No problem.  I'll mail the documentation patch to the list when I have
> it done.

I've attached the first draft of a patch to add the functionality I've
proposed.  It fixes the order in which the `-I' directories are
searched, and it includes updates to the documentation.

I'm particularly interested in feedback from Paul and Akim, but I'd
also like to know what everyone else thinks.  Thanks!

-- 
Mark D. Roth <[EMAIL PROTECTED]>
http://www.feep.net/~roth/
cvs server: Diffing .
Index: configure.ac
===================================================================
RCS file: /cvsroot/autoconf/autoconf/configure.ac,v
retrieving revision 1.38
diff -u -r1.38 configure.ac
--- configure.ac        22 Apr 2002 14:33:05 -0000      1.38
+++ configure.ac        25 May 2002 04:07:13 -0000
@@ -31,6 +31,14 @@
 
 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'])
+SITE_MACRO_DIR="${enable_site_macro_dir}";
+AC_SUBST([SITE_MACRO_DIR])
+
 # Initialize the test suite and build position independent wrappers.
 AC_CONFIG_TESTDIR([tests])
 AC_CONFIG_FILES([tests/Makefile tests/atlocal])
cvs server: Diffing bin
Index: bin/Makefile.am
===================================================================
RCS file: /cvsroot/autoconf/autoconf/bin/Makefile.am,v
retrieving revision 1.5
diff -u -r1.5 Makefile.am
--- bin/Makefile.am     10 Apr 2002 15:58:19 -0000      1.5
+++ bin/Makefile.am     25 May 2002 04:07:13 -0000
@@ -45,7 +45,8 @@
        -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
Index: bin/autoconf.in
===================================================================
RCS file: /cvsroot/autoconf/autoconf/bin/autoconf.in,v
retrieving revision 1.147
diff -u -r1.147 autoconf.in
--- bin/autoconf.in     22 Apr 2002 09:13:43 -0000      1.147
+++ bin/autoconf.in     25 May 2002 04:07:13 -0000
@@ -252,6 +252,16 @@
   esac
 done
 
+# Add $AC_MACRO_PATH
+if test -n "${AC_MACRO_PATH}"; then
+  AUTOM4TE="$AUTOM4TE -I `echo ${AC_MACRO_PATH}|sed 's/:/ -I /'`";
+fi
+
+# Add site macro dir
+if test "@SITE_MACRO_DIR@" != "no"; then
+  AUTOM4TE="$AUTOM4TE -I@SITE_MACRO_DIR@";
+fi
+
 # Find the input file.
 case $# in
   0)
Index: bin/autom4te.in
===================================================================
RCS file: /cvsroot/autoconf/autoconf/bin/autom4te.in,v
retrieving revision 1.61
diff -u -r1.61 autom4te.in
--- bin/autom4te.in     20 Apr 2002 06:09:01 -0000      1.61
+++ bin/autom4te.in     25 May 2002 04:07:13 -0000
@@ -267,6 +267,7 @@
 my @warning;
 
 # M4 include path.
+my @std_include;
 my @include;
 
 # 0 for EXIT_SUCCESS.
@@ -389,7 +390,8 @@
 The environment variable \`WARNINGS\' is honored.
 
 Library directories:
-  -I, --include=DIR  look for FILES in DIR (cumulative)
+  -s, --std-include=DIR  use standard include direcotry DIR
+  -I, --include=DIR      look for FILES in DIR (cumulative)
 
 Tracing:
   -t, --trace=MACRO      report the MACRO invocations
@@ -493,6 +495,7 @@
      "M|melt"       => \$melt,
 
      # Library directories:
+     "s|std-include=s" => \@std_include,
      "I|include=s" => \@include,
 
      # Tracing:
@@ -525,7 +528,10 @@
   # 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 = (@std_include, grep { !/^\.$/ } uniq (@include));
+  #print "$me: include path:\n";
+  #foreach (@include) { print "\t$_\n"; }
+  #print "\n";
 
   # Convert @trace to %trace, and work around the M4 builtins tracing
   # problem.
@@ -599,13 +605,10 @@
   #
   # 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"
@@ -1047,7 +1050,7 @@
   # output but comments and empty lines.
   my $command = ("$m4"
                 . ' --fatal-warning'
-                . join (' --include=', '', reverse @include)
+                . join (' --include=', '', @include)
                 . ' --define=divert'
                 . " @ARGV"
                 . ' </dev/null');
@@ -1070,7 +1073,7 @@
   # or an improper paren etc.
   $command = ("$m4"
              . ' --fatal-warning'
-             . join (' --include=', '', reverse @include)
+             . join (' --include=', '', @include)
              . " --freeze-state=$output"
              . " @ARGV"
              . ' </dev/null');
cvs server: Diffing config
cvs server: Diffing doc
Index: doc/autoconf.texi
===================================================================
RCS file: /cvsroot/autoconf/autoconf/doc/autoconf.texi,v
retrieving revision 1.627
diff -u -r1.627 autoconf.texi
--- doc/autoconf.texi   23 May 2002 17:53:10 -0000      1.627
+++ doc/autoconf.texi   25 May 2002 04:07:15 -0000
@@ -1083,7 +1083,7 @@
 @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.
+accumulate.
 @end table
 
 @node ifnames Invocation
@@ -1168,7 +1168,13 @@
 @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.
+accumulate.
+
+After searching any directories specified using @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} by default.
 
 @item --output=@var{file}
 @itemx -o @var{file}
@@ -1441,7 +1447,7 @@
 @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.
+accumulate.
 @end table
 
 
@@ -2527,7 +2533,6 @@
 @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.
 
 @item --warnings=@var{category}
 @itemx -W @var{category}
@@ -6980,8 +6985,7 @@
 @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}
@@ -7241,6 +7245,12 @@
 @item Autoconf
 create Autoconf executable configure scripts.
 @end table
+
+@item --std-include=@var{dir}
+@itemx -s @var{dir}
+Use standard include directory @var{dir}.  This directory is prepended
+to the include path so that the language-specific files are always
+included first.
 @end table
 
 @cindex @file{autom4te.cfg}
cvs server: Diffing lib
Index: lib/autom4te.in
===================================================================
RCS file: /cvsroot/autoconf/autoconf/lib/autom4te.in,v
retrieving revision 1.11
diff -u -r1.11 autom4te.in
--- lib/autom4te.in     3 Apr 2002 13:35:59 -0000       1.11
+++ lib/autom4te.in     25 May 2002 04:07:15 -0000
@@ -126,7 +126,7 @@
 ## ---------- ##
 
 begin-language: "Autoconf"
-args: --include @datadir@
+args: --std-include @datadir@
 args: autoconf/autoconf.m4f
 args: acsite.m4?
 args: aclocal.m4?
@@ -144,7 +144,7 @@
 ## -------- ##
 
 begin-language: "Autotest"
-args: --include @datadir@
+args: --std-include @datadir@
 args: autotest/autotest.m4f
 args: package.m4?
 args: --mode 777
@@ -157,7 +157,7 @@
 ## ---- ##
 
 begin-language: "M4sh"
-args: --include @datadir@
+args: --std-include @datadir@
 args: m4sugar/m4sh.m4f
 args: --mode 777
 args: --language M4sugar
@@ -169,7 +169,7 @@
 ## ------- ##
 
 begin-language: "M4sugar"
-args: --include @datadir@
+args: --std-include @datadir@
 args: m4sugar/m4sugar.m4f
 args: --warning syntax
 end-language: "M4sugar"
cvs server: Diffing lib/Autom4te
cvs server: Diffing lib/autoconf
cvs server: Diffing lib/autoscan
cvs server: Diffing lib/autotest
cvs server: Diffing lib/emacs
cvs server: Diffing lib/m4sugar
cvs server: Diffing man
cvs server: Diffing tests

Reply via email to