autoconf: * acgeneral.m4 (AC_INCLUDE): New macro.

From 8e8fa48c6b79b8a14f533cf638c1b2cf7c1eda88 Mon Sep 17 00:00:00 2001
From: oliva <[EMAIL REDACTED]>
Date: Wed, 15 Sep 1999 02:39:28 +0000
Subject: [PATCH] * acgeneral.m4 (AC_INCLUDE): New macro. * autoconf.texi:
 Document it.

---
 ChangeLog               |  3 +++
 acgeneral.m4            |  6 ++++++
 autoconf.texi           | 21 +++++++++++++++++++++
 doc/autoconf.texi       | 21 +++++++++++++++++++++
 lib/autoconf/general.m4 |  6 ++++++
 5 files changed, 57 insertions(+)

diff --git a/ChangeLog b/ChangeLog
index 6d28d3ff..9857aaf6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,8 @@
 1999-09-14  Alexandre Oliva  <oliva@lsd.ic.unicamp.br>
 
+	* acgeneral.m4 (AC_INCLUDE): New macro.
+	* autoconf.texi: Document it.
+
 	* acgeneral.m4 (AC_OUTPUT_SUBDIRS): Save INSTALL in
 	ac_given_INSTALL, so that we can adjust relative pathnames for
 	sub-configures.
diff --git a/acgeneral.m4 b/acgeneral.m4
index fd2d9cdf..3d3b1a43 100644
--- a/acgeneral.m4
+++ b/acgeneral.m4
@@ -1046,6 +1046,12 @@ AC_INIT_PREPARE($1)dnl
 AC_DIVERT_POP()dnl to NORMAL
 ])
 
+dnl AC_INCLUDE
+AC_DEFUN(AC_INCLUDE,
+[ifelse($1, [], [], [dnl
+  esyscmd([for file in $1; do echo "builtin(include,$file)dnl"; done])dnl
+])])
+
 dnl AC_INIT_PREPARE(UNIQUE-FILE-IN-SOURCE-DIR)
 AC_DEFUN(AC_INIT_PREPARE,
 [trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15
diff --git a/autoconf.texi b/autoconf.texi
index 9ca57302..0fb39dfb 100644
--- a/autoconf.texi
+++ b/autoconf.texi
@@ -799,6 +799,27 @@ with @samp{--srcdir}; this is a safety check.  @xref{Invoking configure},
 for more information.
 @end defmac
 
+Small packages may store all their macros in @code{aclocal.m4}.  As the
+set of macros grows, or for maintenance reasons, a maintainer may prefer 
+to split the macros in several files.  In this case, Autoconf must be
+told which files to load, and in which order.
+
+@defmac AC_INCLUDE (@var{file(s)})
+@maindex AC_INCLUDE
+Read the macro definitions that appear in the listed files.  A list of
+space-separated filenames or shell globbing patterns is expected.  The
+files will be read in the order they're listed.
+
+Because the order of definition of macros is important (only the last
+definition of a macro is used), beware that it is @code{AC_INIT} that
+loads @file{acsite.m4} and @file{aclocal.m4}.  Note that
+@code{AC_INCLUDE}ing a file before @code{AC_INIT} or within
+@file{aclocal.m4} is different from doing so after @code{AC_INIT}: in
+the latter case, non-macro lines from included files may end up in the
+@file{configure} script, whereas in the former case, they'd be discarded
+just like any text that appear before @code{AC_INIT}.
+@end defmac
+
 Packages that do manual configuration or use the @code{install} program
 might need to tell @code{configure} where to find some other shell
 scripts by calling @code{AC_CONFIG_AUX_DIR}, though the default places
diff --git a/doc/autoconf.texi b/doc/autoconf.texi
index 9ca57302..0fb39dfb 100644
--- a/doc/autoconf.texi
+++ b/doc/autoconf.texi
@@ -799,6 +799,27 @@ with @samp{--srcdir}; this is a safety check.  @xref{Invoking configure},
 for more information.
 @end defmac
 
+Small packages may store all their macros in @code{aclocal.m4}.  As the
+set of macros grows, or for maintenance reasons, a maintainer may prefer 
+to split the macros in several files.  In this case, Autoconf must be
+told which files to load, and in which order.
+
+@defmac AC_INCLUDE (@var{file(s)})
+@maindex AC_INCLUDE
+Read the macro definitions that appear in the listed files.  A list of
+space-separated filenames or shell globbing patterns is expected.  The
+files will be read in the order they're listed.
+
+Because the order of definition of macros is important (only the last
+definition of a macro is used), beware that it is @code{AC_INIT} that
+loads @file{acsite.m4} and @file{aclocal.m4}.  Note that
+@code{AC_INCLUDE}ing a file before @code{AC_INIT} or within
+@file{aclocal.m4} is different from doing so after @code{AC_INIT}: in
+the latter case, non-macro lines from included files may end up in the
+@file{configure} script, whereas in the former case, they'd be discarded
+just like any text that appear before @code{AC_INIT}.
+@end defmac
+
 Packages that do manual configuration or use the @code{install} program
 might need to tell @code{configure} where to find some other shell
 scripts by calling @code{AC_CONFIG_AUX_DIR}, though the default places
diff --git a/lib/autoconf/general.m4 b/lib/autoconf/general.m4
index fd2d9cdf..3d3b1a43 100644
--- a/lib/autoconf/general.m4
+++ b/lib/autoconf/general.m4
@@ -1046,6 +1046,12 @@ AC_INIT_PREPARE($1)dnl
 AC_DIVERT_POP()dnl to NORMAL
 ])
 
+dnl AC_INCLUDE
+AC_DEFUN(AC_INCLUDE,
+[ifelse($1, [], [], [dnl
+  esyscmd([for file in $1; do echo "builtin(include,$file)dnl"; done])dnl
+])])
+
 dnl AC_INIT_PREPARE(UNIQUE-FILE-IN-SOURCE-DIR)
 AC_DEFUN(AC_INIT_PREPARE,
 [trap 'rm -fr conftest* confdefs* core core.* *.core $ac_clean_files; exit 1' 1 2 15