diff options
author | Craig Fields <cfields@mit.edu> | 1994-12-06 15:15:17 +0000 |
---|---|---|
committer | Craig Fields <cfields@mit.edu> | 1994-12-06 15:15:17 +0000 |
commit | a9097df5df569227547a6ac5d7f004b0a4ac93aa (patch) | |
tree | 63bdbd9d4edb5c8f91b7ad43bc2df2e24da31065 /util | |
parent | 4bcc53d2b0402a334de37250608534084543bd43 (diff) |
Initial revision
Diffstat (limited to 'util')
-rw-r--r-- | util/autoconf/NEWS | 272 | ||||
-rw-r--r-- | util/autoconf/acspecific.m4 | 1950 | ||||
-rw-r--r-- | util/autoconf/autoconf.info | 152 | ||||
-rw-r--r-- | util/autoconf/autoconf.info-1 | 1156 | ||||
-rw-r--r-- | util/autoconf/autoconf.info-2 | 1214 | ||||
-rw-r--r-- | util/autoconf/autoconf.info-3 | 1198 | ||||
-rw-r--r-- | util/autoconf/autoconf.info-4 | 1123 | ||||
-rw-r--r-- | util/autoconf/autoconf.texi | 5125 | ||||
-rw-r--r-- | util/autoconf/autoreconf.sh | 149 | ||||
-rw-r--r-- | util/autoconf/autoscan.pl | 394 | ||||
-rwxr-xr-x | util/autoconf/config.guess | 470 | ||||
-rw-r--r-- | util/autoconf/texinfo.tex | 4355 | ||||
-rw-r--r-- | util/et/ChangeLog | 69 | ||||
-rwxr-xr-x | util/reconf | 18 |
14 files changed, 17645 insertions, 0 deletions
diff --git a/util/autoconf/NEWS b/util/autoconf/NEWS new file mode 100644 index 0000000..cb22655 --- /dev/null +++ b/util/autoconf/NEWS @@ -0,0 +1,272 @@ +Major changes in release 2.1: + +* Fix C++ problems. +* More explanations in the manual. +* Fix a spurious failure in the testsuite. +* Clarify some warning messages. +* autoreconf by default only rebuilds configure and config.h.in files + that are older than any of their particular input files; there is a + --force option to use after installing a new version of Autoconf. + +Thanks to everybody who's submitted changes and additions to Autoconf! +I've incorporated many of them, and am still considering others for +future releases -- but I didn't want to postpone this release indefinitely. + +Caution: don't indiscriminantly rebuild configure scripts with +Autoconf version 2. Some configure.in files need minor adjustments to +work with it; the documentation has a chapter on upgrading. A few +configure.in files, including those for GNU Emacs and the GNU C +Library, need major changes because they relied on undocumented +internals of version 1. Future releases of those packages will have +updated configure.in files. + +It's best to use GNU m4 1.3 (or later) with Autoconf version 2. +Autoconf now makes heavy use of m4 diversions, which were implemented +inefficiently in GNU m4 releases before 1.3. + +Major changes in release 2.0: + +** New copyright terms: +* There are no restrictions on distribution or use of configure scripts. + +** Documentation: +* Autoconf manual is reorganized to make information easier to find + and has several new indexes. +* INSTALL is reorganized and clearer and is now made from Texinfo source. + +** New utilities: +* autoscan to generate a preliminary configure.in for a package by + scanning its source code for commonly used nonportable functions, + programs, and header files. +* ifnames to list the symbols used in #if and #ifdef directives in a + source tree. +* autoupdate to update a configure.in to use the version 2 macro names. +* autoreconf to recursively remake configure and configuration header + files in a source tree. + +** Changed utilities: +* autoheader can take pieces of acconfig.h to replace config.h.{top,bot}. +* autoconf and autoheader can look for package-local definition files + in an alternate directory. + +** New macros: +* AC_CACHE_VAL to share results of tests between configure runs. +* AC_DEFUN to define macros, automatically AC_PROVIDE them, and ensure + that macros invoked with AC_REQUIRE don't interrupt other macros. +* AC_CONFIG_AUX_DIR, AC_CANONICAL_SYSTEM, AC_CANONICAL_HOST, AC_LINK_FILES to + support deciding unguessable features based on the host and target types. +* AC_CONFIG_SUBDIRS to recursively configure a source tree. +* AC_ARG_PROGRAM to use the options --program-prefix, + --program-suffix, and --program-transform-name to change the names + of programs being installed. +* AC_PREFIX_DEFAULT to change the default installation prefix. +* AC_TRY_COMPILE to compile a test program without linking it. +* AC_CHECK_TYPE to check whether sys/types.h or stdlib.h defines a given type. +* AC_CHECK_LIB to check for a particular function and library. +* AC_MSG_CHECKING and AC_MSG_RESULT to print test results, on a single line, + whether or not the test succeeds. They obsolete AC_CHECKING and AC_VERBOSE. +* AC_SUBST_FILE to insert one file into another. +* AC_FUNC_MEMCMP to check whether memcmp is 8-bit clean. +* AC_FUNC_STRFTIME to find strftime even if it's in -lintl. +* AC_FUNC_GETMNTENT to find getmntent even if it's in -lsun or -lseq. +* AC_HEADER_SYS_WAIT to check whether sys/wait.h is POSIX.1 compatible. + +** Changed macros: +* Many macros renamed systematically, but old names are accepted for + backward compatibility. +* AC_OUTPUT adds the "automatically generated" comment to + non-Makefiles where it finds @configure_input@ in an input file, to + support files with various comment syntaxes. +* AC_OUTPUT does not replace "prefix" and "exec_prefix" in generated + files when they are not enclosed in @ signs. +* AC_OUTPUT allows the optional environment variable CONFIG_STATUS to + override the file name "config.status". +* AC_OUTPUT takes an optional argument for passing variables from + configure to config.status. +* AC_OUTPUT and AC_CONFIG_HEADER allow you to override the input-file names. +* AC_OUTPUT automatically substitutes the values of CFLAGS, CXXFLAGS, + CPPFLAGS, and LDFLAGS from the environment. +* AC_PROG_CC and AC_PROG_CXX now set CFLAGS and CXXFLAGS, respectively. +* AC_PROG_INSTALL looks for install-sh or install.sh in the directory + specified by AC_CONFIG_AUXDIR, or srcdir or srcdir/.. or + srcdir/../.. by default. +* AC_DEFINE, AC_DEFINE_UNQUOTED, and AC_SUBST are more robust and smaller. +* AC_DEFINE no longer prints anything, because of the new result reporting + mechanism (AC_MSG_CHECKING and AC_MSG_RESULT). +* AC_VERBOSE pays attention to --quiet/--silent, not --verbose. +* AC_ARG_ENABLE and AC_ARG_WITH support whitespace in the arguments to + --enable- and --with- options. +* AC_CHECK_FUNCS and AC_CHECK_HEADERS take optional shell commands to + execute on success or failure. +* Checking for C functions in C++ works. + +** Removed macros: +* AC_REMOTE_TAPE and AC_RSH removed; too specific to tar and cpio, and + better maintained with them. +* AC_ARG_ARRAY removed because no one was likely using it. +* AC_HAVE_POUNDBANG replaced with AC_SYS_INTERPRETER, which doesn't + take arguments, for consistency with all of the other specific checks. + +** New files: +* Comes with config.sub and config.guess, and uses them optionally. +* Uses config.cache to cache test results. An alternate cache file + can be selected with the --cache-file=FILE option. +* Uses optional shell scripts $prefix/share/config.site and + $prefix/etc/config.site to perform site or system specific initializations. +* configure saves compiler output to ./config.log for debugging. +* New files autoconf.m4 and autoheader.m4 load the other Autoconf macros. +* acsite.m4 is the new name for the system-wide aclocal.m4. +* Has a DejaGnu test suite. + +Major changes in release 1.11: + +* AC_PROG_INSTALL calls install.sh with the -c option. +* AC_SET_MAKE cleans up after itself. +* AC_OUTPUT sets prefix and exec_prefix if they weren't set already. +* AC_OUTPUT prevents shells from looking in PATH for config.status. + +Plus a few other bug fixes. + +Major changes in release 1.10: + +* autoheader uses config.h.bot if present, analogous to config.h.top. +* AC_PROG_INSTALL looks for install.sh in srcdir or srcdir/.. and + never uses cp. +* AC_PROG_CXX looks for cxx as a C++ compiler. + +Plus several bugs fixed. + +Major changes in release 1.9: + +* AC_YYTEXT_POINTER replaces AC_DECLARE_YYTEXT. +* AC_SIZEOF_TYPE generates the cpp symbol name automatically, + and autoheader generates entries for those names automatically. +* AC_FIND_X gets the result from xmkmf correctly. +* AC_FIND_X assumes no X if --without-x was given. +* AC_FIND_XTRA adds libraries to the variable X_EXTRA_LIBS. +* AC_PROG_INSTALL finds OSF/1 installbsd. + +Major changes in release 1.8: + +** New macros: +* New macros AC_LANG_C, AC_LANG_CPLUSPLUS, AC_LANG_SAVE, AC_LANG_RESTORE, + AC_PROG_CXX, AC_PROG_CXXCPP, AC_REQUIRE_CPP + for checking both C++ and C features in one configure script. +* New macros AC_CHECKING, AC_VERBOSE, AC_WARN, AC_ERROR for printing messages. +* New macros AC_FIND_XTRA, AC_MMAP, AC_SIZEOF_TYPE, AC_PREREQ, + AC_SET_MAKE, AC_ENABLE. + +** Changed macros: +* AC_FIND_X looks for X in more places. +* AC_PROG_INSTALL defaults to install.sh instead of cp, if it's in srcdir. + install.sh is distributed with Autoconf. +* AC_DECLARE_YYTEXT has been removed because it can't work, pending + a rewrite of quoting in AC_DEFINE. +* AC_OUTPUT adds its comments in C format when substituting in C files. +* AC_COMPILE_CHECK protects its ECHO-TEXT argument with double quotes. + +** New or changed command line options: +* configure accepts --enable-FEATURE[=ARG] and --disable-FEATURE options. +* configure accepts --without-PACKAGE, which sets withval=no. +* configure accepts --x-includes=DIR and --x-libraries=DIR. +* Giving --with-PACKAGE no argument sets withval=yes instead of withval=1. +* configure accepts --help, --version, --silent/--quiet, --no-create options. +* configure accepts and ignores most other Cygnus configure options, and + warns about unknown options. +* config.status accepts --help, --version options. + +** Paths and other changes: +* Relative srcdir values are not made absolute. +* The values of @prefix@ and @exec_prefix@ and @top_srcdir@ get substituted. +* Autoconf library files are installed in ${datadir}/autoconf, not ${datadir}. +* autoheader optionally copies config.h.top to the beginning of config.h.in. +* The example Makefile dependencies for configure et al. work better. +* Namespace cleanup: all shell variables used internally by Autoconf + have names beginning with `ac_'. + +More big improvements are in process for future releases, but have not +yet been (variously) finished, integrated, tested, or documented enough +to release yet. + +Major changes in release 1.7: + +* New macro AC_OBSOLETE. +* Bugs in Makefile.in fixed. +* AC_LONG_FILE_NAMES improved. + +Major changes in release 1.6: + +* New macro AC_LONG_64_BITS. +* Multiple .h files can be created. +* AC_FIND_X looks for X files directly if it doesn't find xmkmf. +* AC_ALLOCA defines C_ALLOCA if using alloca.c. +* --with-NAME can take a value, e.g., --with-targets=sun4,hp300bsd. +* Unused --no-create option to configure removed. +* autoheader doesn't change the timestamp of its output file if + the file didn't change. +* All macros that look for libraries now use AC_HAVE_LIBRARY. +* config.status checks three optional environment variables to + modify its behavior. +* The usual bug fixes. + +Major changes in release 1.5: + +* New macros AC_FIND_X, AC_OFF_T, AC_STAT_MACROS_BROKEN, AC_REVISION. +* autoconf and autoheader scripts have GNU standards conforming + --version and --help options (they print their message and exit). +* Many bug fixes. + +Major changes in release 1.4: + +* New macros AC_HAVE_POUNDBANG, AC_TIME_WITH_SYS_TIME, AC_LONG_DOUBLE, + AC_GETGROUPS_T, AC_DEFINE_UNQUOTED. +* autoconf and autoheader use the M4 environment variable to determine the + path of the m4 program to use. +* The --macrodir option to autoconf and autoheader specifies the directory + in which acspecific.m4, acgeneral.m4, etc. reside if not the default. +* autoconf and autoheader can take `-' as their file names, which means to + read stdin as input. +* Resulting configure scripts can take a --verbose option which causes them + to print the results of their tests. +* AC_DEFINE quotes its second argument in such a way that spaces, magic + shell characters, etc. will be preserved during various stages of + expansion done by the shell. If you don't want this, use + AC_DEFINE_UNQUOTED instead. +* Much textual processing done with external calls to tr and sed have been + internalized with builtin m4 `patsubst' and `translit' calls. +* AC_OUTPUT doesn't hardwire the filenames it outputs. Instead, you can + set the shell variables `gen_files' and `gen_config' to the list of + filenames to output. +* AC_DECLARE_YYTEXT does an AC_SUBST of `LEX_OUTPUT_ROOT', which may be + "lex.yy" or "lexyy", depending on the system. +* AC_PROGRAMS_CHECK takes an optional third arg. If given, it is used as + the default value. +* If AC_ALLOCA chooses alloca.c, it also defines STACK_DIRECTION. +* AC_CONST works much more reliably on more systems. +* Many bug fixes. + +Major changes in release 1.3: + +configure no longer requires awk for packages that use a config.h. +Support handling --with-PACKAGE options. +New `autoheader' script to create `config.h.in' from `configure.in'. +Ignore troublesome -lucb and -lPW when searching for alloca. +Rename --exec_prefix to --exec-prefix for GNU standards conformance. +Improve detection of STDC library. +Add AC_HAVE_LIBRARY to check for non-default libraries. +Function checking should work with future GNU libc releases. + +Major changes in release 1.2: + +The --srcdir option is now usually unnecessary. +Add a file containing sample comments describing CPP macros. +A comment in config.status tells which host it was configured on. +Substituted variable values can now contain commas. +Fix bugs in various feature checks. + +Major changes in release 1.1: + +Added AC_STRCOLL macro. +Made AC_GETLOADAVG check for more things. +AC_OUTPUT argument is now optional. +Various bug fixes. diff --git a/util/autoconf/acspecific.m4 b/util/autoconf/acspecific.m4 new file mode 100644 index 0000000..3c07bc9 --- /dev/null +++ b/util/autoconf/acspecific.m4 @@ -0,0 +1,1950 @@ +dnl Macros that test for specific features. +dnl This file is part of Autoconf. +dnl Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. +dnl +dnl This program is free software; you can redistribute it and/or modify +dnl it under the terms of the GNU General Public License as published by +dnl the Free Software Foundation; either version 2, or (at your option) +dnl any later version. +dnl +dnl This program is distributed in the hope that it will be useful, +dnl but WITHOUT ANY WARRANTY; without even the implied warranty of +dnl MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +dnl GNU General Public License for more details. +dnl +dnl You should have received a copy of the GNU General Public License +dnl along with this program; if not, write to the Free Software +dnl Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +dnl +dnl As a special exception, the Free Software Foundation gives unlimited +dnl permission to copy, distribute and modify the configure scripts that +dnl are the output of Autoconf. You need not follow the terms of the GNU +dnl General Public License when using or distributing such scripts, even +dnl though portions of the text of Autoconf appear in them. The GNU +dnl General Public License (GPL) does govern all other use of the material +dnl that constitutes the Autoconf program. +dnl +dnl Certain portions of the Autoconf source text are designed to be copied +dnl (in certain cases, depending on the input) into the output of +dnl Autoconf. We call these the "data" portions. The rest of the Autoconf +dnl source text consists of comments plus executable code that decides which +dnl of the data portions to output in any given case. We call these +dnl comments and executable code the "non-data" portions. Autoconf never +dnl copies any of the non-data portions into its output. +dnl +dnl This special exception to the GPL applies to versions of Autoconf +dnl released by the Free Software Foundation. When you make and +dnl distribute a modified version of Autoconf, you may extend this special +dnl exception to the GPL to apply to your modified version as well, *unless* +dnl your modified version has the potential to copy into its output some +dnl of the text that was the non-data portion of the version that you started +dnl with. (In other words, unless your change moves or copies text from +dnl the non-data portions to the data portions.) If your modification has +dnl such potential, you must delete any notice of this special exception +dnl to the GPL from your modified version. +dnl +dnl Written by David MacKenzie, with help from +dnl Franc,ois Pinard, Karl Berry, Richard Pixley, Ian Lance Taylor, +dnl Roland McGrath, Noah Friedman, david d zuhn, and many others. + + +dnl ### Checks for programs + + +dnl Check whether to use -n, \c, or newline-tab to separate +dnl checking messages from result messages. +dnl Idea borrowed from dist 3.0. +dnl Internal use only. +AC_DEFUN(AC_PROG_ECHO_N, +[if (echo "testing\c"; echo 1,2,3) | grep c >/dev/null; then + # Stardent Vistra SVR4 grep lacks -e, says ghazi@caip.rutgers.edu. + if (echo -n testing; echo 1,2,3) | sed s/-n/xn/ | grep xn >/dev/null; then + ac_n= ac_c=' +' ac_t=' ' + else + ac_n=-n ac_c= ac_t= + fi +else + ac_n= ac_c='\c' ac_t= +fi +]) + +AC_DEFUN(AC_PROG_CC, +[AC_BEFORE([$0], [AC_PROG_CPP])dnl +AC_CHECK_PROG(CC, gcc, gcc, cc) + +AC_MSG_CHECKING(whether we are using GNU C) +AC_CACHE_VAL(ac_cv_prog_gcc, +[dnl The semicolon is to pacify NeXT's syntax-checking cpp. +cat > conftest.c <<EOF +#ifdef __GNUC__ + yes; +#endif +EOF +if ${CC-cc} -E conftest.c 2>&AC_FD_CC | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gcc=yes +else + ac_cv_prog_gcc=no +fi])dnl +AC_MSG_RESULT($ac_cv_prog_gcc) +if test $ac_cv_prog_gcc = yes; then + GCC=yes + if test "${CFLAGS+set}" != set; then + AC_MSG_CHECKING(whether ${CC-cc} accepts -g) +AC_CACHE_VAL(ac_cv_prog_gcc_g, +[echo 'void f(){}' > conftest.c +if test -z "`${CC-cc} -g -c conftest.c 2>&1`"; then + ac_cv_prog_gcc_g=yes +else + ac_cv_prog_gcc_g=no +fi +rm -f conftest* +])dnl + AC_MSG_RESULT($ac_cv_prog_gcc_g) + if test $ac_cv_prog_gcc_g = yes; then + CFLAGS="-g -O" + else + CFLAGS="-O" + fi + fi +else + GCC= + test "${CFLAGS+set}" = set || CFLAGS="-g" +fi +]) + +AC_DEFUN(AC_PROG_CXX, +[AC_BEFORE([$0], [AC_PROG_CXXCPP])dnl +AC_CHECK_PROGS(CXX, $CCC c++ g++ gcc CC cxx, gcc) + +AC_MSG_CHECKING(whether we are using GNU C++) +AC_CACHE_VAL(ac_cv_prog_gxx, +[dnl The semicolon is to pacify NeXT's syntax-checking cpp. +cat > conftest.C <<EOF +#ifdef __GNUC__ + yes; +#endif +EOF +if ${CXX-g++} -E conftest.C 2>&AC_FD_CC | egrep yes >/dev/null 2>&1; then + ac_cv_prog_gxx=yes +else + ac_cv_prog_gxx=no +fi])dnl +AC_MSG_RESULT($ac_cv_prog_gxx) +if test $ac_cv_prog_gxx = yes; then + GXX=yes + if test "${CXXFLAGS+set}" != set; then + AC_MSG_CHECKING(whether ${CXX-g++} accepts -g) +AC_CACHE_VAL(ac_cv_prog_gxx_g, +[echo 'void f(){}' > conftest.cc +if test -z "`${CXX-g++} -g -c conftest.cc 2>&1`"; then + ac_cv_prog_gxx_g=yes +else + ac_cv_prog_gxx_g=no +fi +rm -f conftest* +])dnl + AC_MSG_RESULT($ac_cv_prog_gxx_g) + if test $ac_cv_prog_gxx_g = yes; then + CXXFLAGS="-g -O" + else + CXXFLAGS="-O" + fi + fi +else + GXX= + test "${CXXFLAGS+set}" = set || CXXFLAGS="-g" +fi +]) + +AC_DEFUN(AC_PROG_GCC_TRADITIONAL, +[AC_REQUIRE([AC_PROG_CC])dnl +AC_REQUIRE([AC_PROG_CPP])dnl +if test $ac_cv_prog_gcc = yes; then + AC_MSG_CHECKING(whether ${CC-cc} needs -traditional) +AC_CACHE_VAL(ac_cv_prog_gcc_traditional, +[ ac_pattern="Autoconf.*'x'" + AC_EGREP_CPP($ac_pattern, [#include <sgtty.h> +Autoconf TIOCGETP], + ac_cv_prog_gcc_traditional=yes, ac_cv_prog_gcc_traditional=no) + + if test $ac_cv_prog_gcc_traditional = no; then + AC_EGREP_CPP($ac_pattern, [#include <termio.h> +Autoconf TCGETA], + ac_cv_prog_gcc_traditional=yes) + fi])dnl + AC_MSG_RESULT($ac_cv_prog_gcc_traditional) + if test $ac_cv_prog_gcc_traditional = yes; then + CC="$CC -traditional" + fi +fi +]) + +AC_DEFUN(AC_PROG_CC_C_O, +[if test "x$CC" != xcc; then + AC_MSG_CHECKING(whether $CC and cc understand -c and -o together) +else + AC_MSG_CHECKING(whether cc understands -c and -o together) +fi +set dummy $CC; ac_cc=[$]2 +AC_CACHE_VAL(ac_cv_prog_cc_${ac_cc}_c_o, +[eval ac_cv_prog_cc_${ac_cc}_c_o=no +echo 'foo(){}' > conftest.c +# Make sure it works both with $CC and with simple cc. +# We do the test twice because some compilers refuse to overwrite an +# existing .o file with -o, though they will create one. +if ${CC-cc} -c conftest.c -o conftest.o 1>&AC_FD_CC 2>&AC_FD_CC && + test -f conftest.o && ${CC-cc} -c conftest.c -o conftest.o 1>&AC_FD_CC 2>&AC_FD_CC +then + if test "x$CC" != xcc; then + # Test first that cc exists at all. + if cc -c conftest.c 1>&AC_FD_CC 2>&AC_FD_CC + then + if cc -c conftest.c -o conftest2.o 1>&AC_FD_CC 2>&AC_FD_CC && + test -f conftest2.o && cc -c conftest.c -o conftest2.o 1>&AC_FD_CC 2>&AC_FD_CC + then + eval ac_cv_prog_cc_${ac_cc}_c_o=yes + fi + fi + fi +fi +rm -f conftest* +])dnl +if eval "test \"`echo '$ac_cv_prog_cc_'${ac_cc}_c_o`\" = yes"; then + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) + AC_DEFINE(NO_MINUS_C_MINUS_O) +fi +]) + +dnl Define SET_MAKE to set ${MAKE} if make doesn't. +AC_DEFUN(AC_PROG_MAKE_SET, +[AC_MSG_CHECKING(whether ${MAKE-make} sets \$MAKE) +set dummy ${MAKE-make}; ac_make=[$]2 +AC_CACHE_VAL(ac_cv_prog_make_${ac_make}_set, +[cat > conftestmake <<\EOF +all: + @echo 'ac_maketemp="${MAKE}"' +EOF +changequote(, )dnl +# GNU make sometimes prints "make[1]: Entering...", which would confuse us. +eval `${MAKE-make} -f conftestmake 2>/dev/null | grep temp=` +changequote([, ])dnl +if test -n "$ac_maketemp"; then + eval ac_cv_prog_make_${ac_make}_set=yes +else + eval ac_cv_prog_make_${ac_make}_set=no +fi +rm -f conftestmake])dnl +if eval "test \"`echo '$ac_cv_prog_make_'${ac_make}_set`\" = yes"; then + AC_MSG_RESULT(yes) + SET_MAKE= +else + AC_MSG_RESULT(no) + SET_MAKE="MAKE=${MAKE-make}" +fi +AC_SUBST([SET_MAKE])dnl +]) + +AC_DEFUN(AC_PROG_RANLIB, +[AC_CHECK_PROG(RANLIB, ranlib, ranlib, :)]) + +dnl Check for mawk first since it's said to be faster. +AC_DEFUN(AC_PROG_AWK, +[AC_CHECK_PROGS(AWK, mawk gawk nawk awk, )]) + +AC_DEFUN(AC_PROG_YACC, +[AC_CHECK_PROGS(YACC, 'bison -y' byacc, yacc)]) + +AC_DEFUN(AC_PROG_CPP, +[AC_MSG_CHECKING(how to run the C preprocessor) +# On Suns, sometimes $CPP names a directory. +if test -n "$CPP" && test -d "$CPP"; then + CPP= +fi +if test -z "$CPP"; then +AC_CACHE_VAL(ac_cv_prog_CPP, +[ # This must be in double quotes, not single quotes, because CPP may get + # substituted into the Makefile and "${CC-cc}" will confuse make. + CPP="${CC-cc} -E" + # On the NeXT, cc -E runs the code through the compiler's parser, + # not just through cpp. +dnl Use a header file that comes with gcc, so configuring glibc +dnl with a fresh cross-compiler works. + AC_TRY_CPP([#include <assert.h> +Syntax Error], , + CPP="${CC-cc} -E -traditional-cpp" + AC_TRY_CPP([#include <assert.h> +Syntax Error], , CPP=/lib/cpp)) + ac_cv_prog_CPP="$CPP"])dnl +fi +CPP="$ac_cv_prog_CPP" +AC_MSG_RESULT($CPP) +AC_SUBST(CPP)dnl +]) + +AC_DEFUN(AC_PROG_CXXCPP, +[AC_MSG_CHECKING(how to run the C++ preprocessor) +if test -z "$CXXCPP"; then +AC_CACHE_VAL(ac_cv_prog_CXXCPP, +[AC_LANG_SAVE[]dnl +AC_LANG_CPLUSPLUS[]dnl + CXXCPP="${CXX-g++} -E" + AC_TRY_CPP([#include <stdlib.h>], , CXXCPP=/lib/cpp) + ac_cv_prog_CXXCPP="$CXXCPP" +AC_LANG_RESTORE[]dnl +fi])dnl +CXXCPP="$ac_cv_prog_CXXCPP" +AC_MSG_RESULT($CXXCPP) +AC_SUBST(CXXCPP)dnl +]) + +dnl Require finding the C or C++ preprocessor, whichever is the +dnl current language. +AC_DEFUN(AC_REQUIRE_CPP, +[ifelse(AC_LANG, C, [AC_REQUIRE([AC_PROG_CPP])], [AC_REQUIRE([AC_PROG_CXXCPP])])]) + +AC_DEFUN(AC_PROG_LEX, +[AC_CHECK_PROG(LEX, flex, flex, lex) +if test -z "$LEXLIB" +then + case "$LEX" in + flex*) ac_lib=fl ;; + *) ac_lib=l ;; + esac + AC_CHECK_LIB($ac_lib, main, LEXLIB="-l$ac_lib") +fi +AC_SUBST(LEXLIB)]) + +AC_DEFUN(AC_DECL_YYTEXT, +[AC_REQUIRE_CPP()dnl +AC_REQUIRE([AC_PROG_LEX])dnl +AC_MSG_CHECKING(for yytext declaration) +AC_CACHE_VAL(ac_cv_prog_lex_yytext_pointer, +[# POSIX says lex can declare yytext either as a pointer or an array; the +# default is implementation-dependent. Figure out which it is, since +# not all implementations provide the %pointer and %array declarations. +# +# The minimal lex program is just a single line: %%. But some broken lexes +# (Solaris, I think it was) want two %% lines, so accommodate them. +ac_cv_prog_lex_yytext_pointer=no + echo '%% +%%' | $LEX +if test -f lex.yy.c; then + LEX_OUTPUT_ROOT=lex.yy +elif test -f lexyy.c; then + LEX_OUTPUT_ROOT=lexyy +else + AC_MSG_ERROR(cannot find output from $LEX, giving up) +fi +echo 'extern char *yytext; main () { exit (0); }' >>$LEX_OUTPUT_ROOT.c +ac_save_LIBS="$LIBS" +LIBS="$LIBS $LEXLIB" +AC_TRY_LINK(`cat $LEX_OUTPUT_ROOT.c`, ac_cv_prog_lex_yytext_pointer=yes) +LIBS="$ac_save_LIBS" +rm -f "${LEX_OUTPUT_ROOT}.c"])dnl +AC_MSG_RESULT($ac_cv_prog_lex_yytext_pointer) +if test $ac_cv_prog_lex_yytext_pointer = yes; then + AC_DEFINE(YYTEXT_POINTER) +fi +AC_SUBST(LEX_OUTPUT_ROOT)dnl +]) + +AC_DEFUN(AC_PROG_INSTALL, +[AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl +# Find a good install program. We prefer a C program (faster), +# so one script is as good as another. But avoid the broken or +# incompatible versions: +# SysV /etc/install, /usr/sbin/install +# SunOS /usr/etc/install +# IRIX /sbin/install +# AIX /bin/install +# AFS /usr/afsws/bin/install, which mishandles nonexistent args +# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff" +# ./install, which can be erroneously created by make from ./install.sh. +AC_MSG_CHECKING(for a BSD compatible install) +if test -z "$INSTALL"; then +AC_CACHE_VAL(ac_cv_path_install, +[ IFS="${IFS= }"; ac_save_ifs="$IFS"; IFS="${IFS}:" + for ac_dir in $PATH; do + case "$ac_dir" in + ''|.|/etc|/usr/sbin|/usr/etc|/sbin|/usr/afsws/bin|/usr/ucb) ;; + *) + # OSF1 and SCO ODT 3.0 have their own names for install. + for ac_prog in ginstall installbsd scoinst install; do + if test -f $ac_dir/$ac_prog; then + if test $ac_prog = install && + grep dspmsg $ac_dir/$ac_prog >/dev/null 2>&1; then + # AIX install. It has an incompatible calling convention. + # OSF/1 installbsd also uses dspmsg, but is usable. + : + else + ac_cv_path_install="$ac_dir/$ac_prog -c" + break 2 + fi + fi + done + ;; + esac + done + IFS="$ac_save_ifs" + # As a last resort, use the slow shell script. + test -z "$ac_cv_path_install" && ac_cv_path_install="$ac_install_sh"])dnl + INSTALL="$ac_cv_path_install" +fi +dnl We do special magic for INSTALL instead of AC_SUBST, to get +dnl relative paths right. +AC_MSG_RESULT($INSTALL) + +# Use test -z because SunOS4 sh mishandles braces in ${var-val}. +# It thinks the first close brace ends the variable substitution. +test -z "$INSTALL_PROGRAM" && INSTALL_PROGRAM='${INSTALL}' +AC_SUBST(INSTALL_PROGRAM)dnl + +test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644' +AC_SUBST(INSTALL_DATA)dnl +]) + +AC_DEFUN(AC_PROG_LN_S, +[AC_MSG_CHECKING(whether ln -s works) +AC_CACHE_VAL(ac_cv_prog_LN_S, +[rm -f conftestdata +if ln -s X conftestdata 2>/dev/null +then + rm -f conftestdata + ac_cv_prog_LN_S="ln -s" +else + ac_cv_prog_LN_S=ln +fi])dnl +LN_S="$ac_cv_prog_LN_S" +if test "$ac_cv_prog_LN_S" = "ln -s"; then + AC_MSG_RESULT(yes) +else + AC_MSG_RESULT(no) +fi +AC_SUBST(LN_S)dnl +]) + +define(AC_RSH, +[errprint(__file__:__line__: [$0] has been removed; replace it with equivalent code +)m4exit(4)]) + + +dnl ### Checks for header files + + +AC_DEFUN(AC_HEADER_STDC, +[AC_REQUIRE_CPP()dnl +AC_MSG_CHECKING(for ANSI C header files) +AC_CACHE_VAL(ac_cv_header_stdc, +[AC_TRY_CPP([#include <stdlib.h> +#include <stdarg.h> +#include <string.h> +#include <float.h>], ac_cv_header_stdc=yes, ac_cv_header_stdc=no) + +if test $ac_cv_header_stdc = yes; then + # SunOS 4.x string.h does not declare mem*, contrary to ANSI. +AC_EGREP_HEADER(memchr, string.h, , ac_cv_header_stdc=no) +fi + +if test $ac_cv_header_stdc = yes; then + # ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI. +AC_EGREP_HEADER(free, stdlib.h, , ac_cv_header_stdc=no) +fi + +if test $ac_cv_header_stdc = yes; then + # /bin/cc in Irix-4.0.5 gets non-ANSI ctype macros unless using -ansi. +AC_TRY_RUN([#include <ctype.h> +#define ISLOWER(c) ('a' <= (c) && (c) <= 'z') +#define TOUPPER(c) (ISLOWER(c) ? 'A' + ((c) - 'a') : (c)) +#define XOR(e, f) (((e) && !(f)) || (!(e) && (f))) +int main () { int i; for (i = 0; i < 256; i++) +if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2); +exit (0); } +], , ac_cv_header_stdc=no, ac_cv_header_stdc=no) +fi])dnl +AC_MSG_RESULT($ac_cv_header_stdc) +if test $ac_cv_header_stdc = yes; then + AC_DEFINE(STDC_HEADERS) +fi +]) + +AC_DEFUN(AC_UNISTD_H, +[AC_OBSOLETE([$0], [; instead use AC_CHECK_HEADERS(unistd.h)])dnl +AC_CHECK_HEADER(unistd.h, AC_DEFINE(HAVE_UNISTD_H))]) + +AC_DEFUN(AC_USG, +[AC_OBSOLETE([$0], + [; instead use AC_CHECK_HEADERS(string.h) and HAVE_STRING_H])dnl +AC_MSG_CHECKING([for BSD string and memory functions]) +AC_TRY_LINK([#include <strings.h>], [rindex(0, 0); bzero(0, 0);], + [AC_MSG_RESULT(yes); AC_DEFINE(USG)], [AC_MSG_RESULT(no)])]) + + +dnl If memchr and the like aren't declared in <string.h>, include <memory.h>. +dnl To avoid problems, don't check for gcc2 built-ins. +AC_DEFUN(AC_MEMORY_H, +[AC_OBSOLETE([$0], [; instead use AC_CHECK_HEADERS(memory.h) and HAVE_MEMORY_H])dnl +AC_MSG_CHECKING(whether string.h declares mem functions) +AC_EGREP_HEADER(memchr, string.h, ac_found=yes, ac_found=no) +AC_MSG_RESULT($ac_found) +if test $ac_found = no; then + AC_CHECK_HEADER(memory.h, [AC_DEFINE(NEED_MEMORY_H)]) +fi +]) + +AC_DEFUN(AC_HEADER_MAJOR, +[AC_MSG_CHECKING(whether sys/types.h defines makedev) +AC_CACHE_VAL(ac_cv_header_sys_types_h_makedev, +[AC_TRY_LINK([#include <sys/types.h>], [return makedev(0, 0);], + ac_cv_header_sys_types_h_makedev=yes, ac_cv_header_sys_types_h_makedev=no) +])dnl +AC_MSG_RESULT($ac_cv_header_sys_types_h_makedev) + +if test $ac_cv_header_sys_types_h_makedev = no; then +AC_CHECK_HEADER(sys/mkdev.h, [AC_DEFINE(MAJOR_IN_MKDEV)]) + + if test $ac_cv_header_sys_mkdev_h = no; then +AC_CHECK_HEADER(sys/sysmacros.h, [AC_DEFINE(MAJOR_IN_SYSMACROS)]) + fi +fi +]) + +AC_DEFUN(AC_HEADER_DIRENT, +[ac_header_dirent=no +AC_CHECK_HEADERS_DIRENT(dirent.h sys/ndir.h sys/dir.h ndir.h, + [ac_header_dirent=$ac_hdr; break]) +# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix. +if test $ac_header_dirent = dirent.h; then +AC_CHECK_LIB(dir, opendir, LIBS="$LIBS -ldir") +else +AC_CHECK_LIB(x, opendir, LIBS="$LIBS -lx") +fi +]) + +dnl Like AC_CHECK_HEADER, except also make sure that HEADER-FILE +dnl defines the type `DIR'. dirent.h on NextStep 3.2 doesn't. +dnl AC_CHECK_HEADER_DIRENT(HEADER-FILE, ACTION-IF-FOUND) +AC_DEFUN(AC_CHECK_HEADER_DIRENT, +[ac_safe=`echo "$1" | tr './\055' '___'` +AC_MSG_CHECKING([for $1 that defines DIR]) +AC_CACHE_VAL(ac_cv_header_dirent_$ac_safe, +[AC_TRY_COMPILE([#include <sys/types.h> +#include <$1>], [DIR *dirp = 0;], + eval "ac_cv_header_dirent_$ac_safe=yes", + eval "ac_cv_header_dirent_$ac_safe=no")])dnl +if eval "test \"`echo '$ac_cv_header_dirent_'$ac_safe`\" = yes"; then + AC_MSG_RESULT(yes) + $2 +else + AC_MSG_RESULT(no) +fi +]) + +dnl Like AC_CHECK_HEADERS, except succeed only for a HEADER-FILE that +dnl defines `DIR'. +dnl AC_CHECK_HEADERS_DIRENT(HEADER-FILE... [, ACTION]) +define(AC_CHECK_HEADERS_DIRENT, +[for ac_hdr in $1 +do +AC_CHECK_HEADER_DIRENT($ac_hdr, +[changequote(, )dnl + ac_tr_hdr=HAVE_`echo $ac_hdr | tr '[a-z]./\055' '[A-Z]___'` +changequote([, ])dnl + AC_DEFINE_UNQUOTED($ac_tr_hdr) $2])dnl +done]) + +AC_DEFUN(AC_DIR_HEADER, +[AC_OBSOLETE([$0], [; instead use AC_HEADER_DIRENT])dnl +ac_header_dirent=no +for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do + AC_CHECK_HEADER_DIRENT($ac_hdr, [ac_header_dirent=$ac_hdr; break]) +done + +case "$ac_header_dirent" in +dirent.h) AC_DEFINE(DIRENT) ;; +sys/ndir.h) AC_DEFINE(SYSNDIR) ;; +sys/dir.h) AC_DEFINE(SYSDIR) ;; +ndir.h) AC_DEFINE(NDIR) ;; +esac + +AC_MSG_CHECKING(whether closedir returns void) +AC_CACHE_VAL(ac_cv_func_closedir_void, +[AC_TRY_RUN([#include <sys/types.h> +#include <$ac_header_dirent> +int closedir(); main() { exit(closedir(opendir(".")) != 0); }], + ac_cv_func_closedir_void=no, ac_cv_func_closedir_void=yes)])dnl +AC_MSG_RESULT($ac_cv_func_closedir_void) +if test $ac_cv_func_closedir_void = yes; then + AC_DEFINE(VOID_CLOSEDIR) +fi +]) + +AC_DEFUN(AC_HEADER_STAT, +[AC_MSG_CHECKING(whether stat file-mode macros are broken) +AC_CACHE_VAL(ac_cv_header_stat_broken, +[AC_EGREP_CPP([You lose], [#include <sys/types.h> +#include <sys/stat.h> +#ifdef S_ISBLK +# if S_ISBLK (S_IFDIR) +You lose. +# endif +# ifdef S_IFCHR +# if S_ISBLK (S_IFCHR) +You lose. +# endif +# endif +#endif + +#ifdef S_ISLNK +# if S_ISLNK (S_IFREG) +You lose. +# endif +#endif + +#ifdef S_ISSOCK +# if S_ISSOCK (S_IFREG) +You lose. +# endif +#endif +], ac_cv_header_stat_broken=yes, ac_cv_header_stat_broken=no)])dnl +AC_MSG_RESULT($ac_cv_header_stat_broken) +if test $ac_cv_header_stat_broken = yes; then + AC_DEFINE(STAT_MACROS_BROKEN) +fi +]) + +AC_DEFUN(AC_DECL_SYS_SIGLIST, +[AC_MSG_CHECKING([for sys_siglist declaration in signal.h or unistd.h]) +AC_CACHE_VAL(ac_cv_decl_sys_siglist, +[AC_TRY_COMPILE([#include <sys/types.h> +#include <signal.h> +/* NetBSD declares sys_siglist in unistd.h. */ +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif], [char *msg = *(sys_siglist + 1);], + ac_cv_decl_sys_siglist=yes, ac_cv_decl_sys_siglist=no)])dnl +AC_MSG_RESULT($ac_cv_decl_sys_siglist) +if test $ac_cv_decl_sys_siglist = yes; then + AC_DEFINE(SYS_SIGLIST_DECLARED) +fi +]) + +AC_DEFUN(AC_HEADER_SYS_WAIT, +[AC_MSG_CHECKING([for sys/wait.h that is POSIX.1 compatible]) +AC_CACHE_VAL(ac_cv_header_sys_wait_h, +[AC_TRY_COMPILE([#include <sys/types.h> +#include <sys/wait.h> +#ifndef WEXITSTATUS +#define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) +#endif +#ifndef WIFEXITED +#define WIFEXITED(stat_val) (((stat_val) & 255) == 0) +#endif], [int s; +wait (&s); +s = WIFEXITED (s) ? WEXITSTATUS (s) : 1;], +ac_cv_header_sys_wait_h=yes, ac_cv_header_sys_wait_h=no)])dnl +AC_MSG_RESULT($ac_cv_header_sys_wait_h) +if test $ac_cv_header_sys_wait_h = yes; then + AC_DEFINE(HAVE_SYS_WAIT_H) +fi +]) + + +dnl ### Checks for typedefs + + +AC_DEFUN(AC_TYPE_GETGROUPS, +[AC_REQUIRE([AC_TYPE_UID_T])dnl +AC_MSG_CHECKING(type of array argument to getgroups) +AC_CACHE_VAL(ac_cv_type_getgroups, +[AC_TRY_RUN( +changequote(<<, >>)dnl +<< +/* Thanks to Mike Rendell for this test. */ +#include <sys/types.h> +#define NGID 256 +#undef MAX +#define MAX(x, y) ((x) > (y) ? (x) : (y)) +main() +{ + gid_t gidset[NGID]; + int i, n; + union { gid_t gval; long lval; } val; + + val.lval = -1; + for (i = 0; i < NGID; i++) + gidset[i] = val.gval; + n = getgroups (sizeof (gidset) / MAX (sizeof (int), sizeof (gid_t)) - 1, + gidset); + /* Exit non-zero if getgroups seems to require an array of ints. This + happens when gid_t is short but getgroups modifies an array of ints. */ + exit ((n > 0 && gidset[n] != val.gval) ? 1 : 0); +} +>>, +changequote([, ])dnl + ac_cv_type_getgroups=gid_t, ac_cv_type_getgroups=int, + ac_cv_type_getgroups=cross) +if test $ac_cv_type_getgroups = cross; then + dnl When we can't run the test program (we are cross compiling), presume + dnl that <unistd.h> has either an accurate prototype for getgroups or none. + dnl Old systems without prototypes probably use int. + AC_EGREP_HEADER([getgroups.*int.*gid_t], unistd.h, + ac_cv_type_getgroups=gid_t, ac_cv_type_getgroups=int) +fi])dnl +AC_MSG_RESULT($ac_cv_type_getgroups) +AC_DEFINE_UNQUOTED(GETGROUPS_T, $ac_cv_type_getgroups) +]) + +AC_DEFUN(AC_TYPE_UID_T, +[AC_MSG_CHECKING(for uid_t in sys/types.h) +AC_CACHE_VAL(ac_cv_type_uid_t, +[AC_EGREP_HEADER(uid_t, sys/types.h, + ac_cv_type_uid_t=yes, ac_cv_type_uid_t=no)])dnl +AC_MSG_RESULT($ac_cv_type_uid_t) +if test $ac_cv_type_uid_t = no; then + AC_DEFINE(uid_t, int) + AC_DEFINE(gid_t, int) +fi +]) + +AC_DEFUN(AC_TYPE_SIZE_T, +[AC_CHECK_TYPE(size_t, unsigned)]) + +AC_DEFUN(AC_TYPE_PID_T, +[AC_CHECK_TYPE(pid_t, int)]) + +AC_DEFUN(AC_TYPE_OFF_T, +[AC_CHECK_TYPE(off_t, long)]) + +AC_DEFUN(AC_TYPE_MODE_T, +[AC_CHECK_TYPE(mode_t, int)]) + +dnl Note that identifiers starting with SIG are reserved by ANSI C. +AC_DEFUN(AC_TYPE_SIGNAL, +[AC_MSG_CHECKING([return type of signal handlers]) +AC_CACHE_VAL(ac_cv_type_signal, +[AC_TRY_COMPILE([#include <sys/types.h> +#include <signal.h> +#ifdef signal +#undef signal +#endif +extern void (*signal ()) ();], +[int i;], ac_cv_type_signal=void, ac_cv_type_signal=int)])dnl +AC_MSG_RESULT($ac_cv_type_signal) +AC_DEFINE_UNQUOTED(RETSIGTYPE, $ac_cv_type_signal) +]) + + +dnl ### Checks for functions + + +AC_DEFUN(AC_FUNC_CLOSEDIR_VOID, +[AC_REQUIRE([AC_HEADER_DIRENT])dnl +AC_MSG_CHECKING(whether closedir returns void) +AC_CACHE_VAL(ac_cv_func_closedir_void, +[AC_TRY_RUN([#include <sys/types.h> +#include <$ac_header_dirent> +int closedir(); main() { exit(closedir(opendir(".")) != 0); }], + ac_cv_func_closedir_void=no, ac_cv_func_closedir_void=yes)])dnl +AC_MSG_RESULT($ac_cv_func_closedir_void) +if test $ac_cv_func_closedir_void = yes; then + AC_DEFINE(CLOSEDIR_VOID) +fi +]) + +AC_DEFUN(AC_FUNC_MMAP, +[AC_MSG_CHECKING(for working mmap) +AC_CACHE_VAL(ac_cv_func_mmap, +[AC_TRY_RUN([ +/* Thanks to Mike Haertel and Jim Avera for this test. */ +#include <sys/types.h> +#include <fcntl.h> +#include <sys/mman.h> + +#ifdef BSD +# ifndef BSD4_1 +# define HAVE_GETPAGESIZE +# endif +#endif + +#ifndef HAVE_GETPAGESIZE +# include <sys/param.h> +# ifdef EXEC_PAGESIZE +# define getpagesize() EXEC_PAGESIZE +# else +# ifdef NBPG +# define getpagesize() NBPG * CLSIZE +# ifndef CLSIZE +# define CLSIZE 1 +# endif +# else +# ifdef NBPC +# define getpagesize() NBPC +# else +# define getpagesize() PAGESIZE /* SVR4 */ +# endif +# endif +# endif +#endif + +#ifdef __osf__ +# define valloc malloc +#endif + +#ifdef __cplusplus +extern "C" { void *valloc(unsigned), *malloc(unsigned); } +#else +char *valloc(), *malloc(); +#endif + +int +main() +{ + char *buf1, *buf2, *buf3; + int i = getpagesize(), j; + int i2 = getpagesize()*2; + int fd; + + buf1 = (char *)valloc(i2); + buf2 = (char *)valloc(i); + buf3 = (char *)malloc(i2); + for (j = 0; j < i2; ++j) + *(buf1 + j) = rand(); + fd = open("conftestmmap", O_CREAT | O_RDWR, 0666); + write(fd, buf1, i2); + mmap(buf2, i, PROT_READ | PROT_WRITE, MAP_FIXED | MAP_PRIVATE, fd, 0); + for (j = 0; j < i; ++j) + if (*(buf1 + j) != *(buf2 + j)) + exit(1); + lseek(fd, (long)i, 0); + read(fd, buf2, i); /* read into mapped memory -- file should not change */ + /* (it does in i386 SVR4.0 - Jim Avera, jima@netcom.com) */ + lseek(fd, (long)0, 0); + read(fd, buf3, i2); + for (j = 0; j < i2; ++j) + if (*(buf1 + j) != *(buf3 + j)) + exit(1); + exit(0); +} +], ac_cv_func_mmap=yes, ac_cv_func_mmap=no, ac_cv_func_mmap=no)])dnl +AC_MSG_RESULT($ac_cv_func_mmap) +if test $ac_cv_func_mmap = yes; then + AC_DEFINE(HAVE_MMAP) +fi +]) + +AC_DEFUN(AC_FUNC_VPRINTF, +[AC_CHECK_FUNC(vprintf, AC_DEFINE(HAVE_VPRINTF)) +if test "$ac_cv_func_vprintf" != yes; then +AC_CHECK_FUNC(_doprnt, AC_DEFINE(HAVE_DOPRNT)) +fi +]) + +AC_DEFUN(AC_FUNC_VFORK, +[AC_REQUIRE([AC_TYPE_PID_T])dnl +AC_CHECK_HEADER(vfork.h, AC_DEFINE(HAVE_VFORK_H)) +AC_MSG_CHECKING(for working vfork) +AC_CACHE_VAL(ac_cv_func_vfork, +[AC_REQUIRE([AC_TYPE_SIGNAL]) +AC_TRY_RUN([/* Thanks to Paul Eggert for this test. */ +#include <stdio.h> +#include <sys/types.h> +#include <sys/stat.h> +#include <signal.h> +#ifdef HAVE_UNISTD_H +#include <unistd.h> +#endif +#ifdef HAVE_VFORK_H +#include <vfork.h> +#endif +/* On sparc systems, changes by the child to local and incoming + argument registers are propagated back to the parent. + The compiler is told about this with #include <vfork.h>, + but some compilers (e.g. gcc -O) don't grok <vfork.h>. + Test for this by using a static variable whose address + is put into a register that is clobbered by the vfork. */ +static +#ifdef __cplusplus +sparc_address_test (int arg) +#else +sparc_address_test (arg) int arg; +#endif +{ + static pid_t child; + if (!child) { + child = vfork (); + if (child < 0) + perror ("vfork"); + if (!child) { + arg = getpid(); + write(-1, "", 0); + _exit (arg); + } + } +} +static int signalled; +static RETSIGTYPE catch (s) int s; { signalled = 1; } +main() { + pid_t parent = getpid (); + pid_t child; + + sparc_address_test (); + + signal (SIGINT, catch); + + child = vfork (); + + if (child == 0) { + /* Here is another test for sparc vfork register problems. + This test uses lots of local variables, at least + as many local variables as main has allocated so far + including compiler temporaries. 4 locals are enough for + gcc 1.40.3 on a sparc, but we use 8 to be safe. + A buggy compiler should reuse the register of parent + for one of the local variables, since it will think that + parent can't possibly be used any more in this routine. + Assigning to the local variable will thus munge parent + in the parent process. */ + pid_t + p = getpid(), p1 = getpid(), p2 = getpid(), p3 = getpid(), + p4 = getpid(), p5 = getpid(), p6 = getpid(), p7 = getpid(); + /* Convince the compiler that p..p7 are live; otherwise, it might + use the same hardware register for all 8 local variables. */ + if (p != p1 || p != p2 || p != p3 || p != p4 + || p != p5 || p != p6 || p != p7) + _exit(1); + + /* On some systems (e.g. SunOS 5.2), if the parent is catching + a signal, the child ignores the signal before execing, + and the parent later receives that signal, the parent dumps core. + Test for this by ignoring SIGINT in the child. */ + signal (SIGINT, SIG_IGN); + + /* On some systems (e.g. IRIX 3.3), + vfork doesn't separate parent from child file descriptors. + If the child closes a descriptor before it execs or exits, + this munges the parent's descriptor as well. + Test for this by closing stdout in the child. */ + _exit(close(fileno(stdout)) != 0); + } else { + int status; + struct stat st; + + while (wait(&status) != child) + ; + exit( + /* Was there some problem with vforking? */ + child < 0 + + /* Did the child fail? (This shouldn't happen.) */ + || status + + /* Did the vfork/compiler bug occur? */ + || parent != getpid() + + /* Did the signal handling bug occur? */ + || kill(parent, SIGINT) != 0 + || signalled != 1 + + /* Did the file descriptor bug occur? */ + || fstat(fileno(stdout), &st) != 0 + ); + } +}], ac_cv_func_vfork=yes, ac_cv_func_vfork=no, ac_cv_func_vfork=no)])dnl +AC_MSG_RESULT($ac_cv_func_vfork) +if test $ac_cv_func_vfork = no; then + AC_DEFINE(vfork, fork) +fi +]) + +AC_DEFUN(AC_FUNC_WAIT3, +[AC_MSG_CHECKING(for wait3 that fills in rusage) +AC_CACHE_VAL(ac_cv_func_wait3, +[AC_TRY_RUN([#include <sys/types.h> +#include <sys/time.h> +#include <sys/resource.h> +#include <stdio.h> +/* HP-UX has wait3 but does not fill in rusage at all. */ +main() { + struct rusage r; + int i; + /* Use a field that we can force nonzero -- + voluntary context switches. + For systems like NeXT and OSF/1 that don't set it, + also use the system CPU time. */ + r.ru_nvcsw = 0; + r.ru_stime.tv_sec = 0; + r.ru_stime.tv_usec = 0; + switch (fork()) { + case 0: /* Child. */ + sleep(1); /* Give up the CPU. */ + _exit(0); + case -1: _exit(0); /* What can we do? */ + default: /* Parent. */ + wait3(&i, 0, &r); + sleep(1); /* Avoid "text file busy" from rm on fast HP-UX machines. */ + exit(r.ru_nvcsw == 0 + && r.ru_stime.tv_sec == 0 && r.ru_stime.tv_usec == 0); + } +}], ac_cv_func_wait3=yes, ac_cv_func_wait3=no, ac_cv_func_wait3=no)])dnl +AC_MSG_RESULT($ac_cv_func_wait3) +if test $ac_cv_func_wait3 = yes; then + AC_DEFINE(HAVE_WAIT3) +fi +]) + +AC_DEFUN(AC_FUNC_ALLOCA, +[AC_REQUIRE_CPP()dnl Set CPP; we run AC_EGREP_CPP conditionally. +# The Ultrix 4.2 mips builtin alloca declared by alloca.h only works +# for constant arguments. Useless! +AC_MSG_CHECKING([for working alloca.h]) +AC_CACHE_VAL(ac_cv_header_alloca_h, +[AC_TRY_LINK([#include <alloca.h>], [char *p = alloca(2 * sizeof(int));], + ac_cv_header_alloca_h=yes, ac_cv_header_alloca_h=no)])dnl +AC_MSG_RESULT($ac_cv_header_alloca_h) +if test $ac_cv_header_alloca_h = yes; then + AC_DEFINE(HAVE_ALLOCA_H) +fi + +AC_MSG_CHECKING([for alloca]) +AC_CACHE_VAL(ac_cv_func_alloca, +[AC_TRY_LINK([ +#ifdef __GNUC__ +# define alloca __builtin_alloca +#else +# if HAVE_ALLOCA_H +# include <alloca.h> +# else +# ifdef _AIX + #pragma alloca +# else +# ifndef alloca /* predefined by HP cc +Olibcalls */ +char *alloca (); +# endif +# endif +# endif +#endif +], [char *p = (char *) alloca(1);], + ac_cv_func_alloca=yes, ac_cv_func_alloca=no)])dnl +AC_MSG_RESULT($ac_cv_func_alloca) +if test $ac_cv_func_alloca = yes; then + AC_DEFINE(HAVE_ALLOCA) +fi + +if test $ac_cv_func_alloca = no; then + # The SVR3 libPW and SVR4 libucb both contain incompatible functions + # that cause trouble. Some versions do not even contain alloca or + # contain a buggy version. If you still want to use their alloca, + # use ar to extract alloca.o from them instead of compiling alloca.c. + ALLOCA=alloca.o + AC_DEFINE(C_ALLOCA) + +AC_MSG_CHECKING(whether alloca needs Cray hooks) +AC_CACHE_VAL(ac_cv_os_cray, +[AC_EGREP_CPP(webecray, +[#if defined(CRAY) && ! defined(CRAY2) +webecray +#else +wenotbecray +#endif +], ac_cv_os_cray=yes, ac_cv_os_cray=no)])dnl +AC_MSG_RESULT($ac_cv_os_cray) +if test $ac_cv_os_cray = yes; then +AC_CHECK_FUNC(_getb67, AC_DEFINE(CRAY_STACKSEG_END, _getb67), +AC_CHECK_FUNC(GETB67, AC_DEFINE(CRAY_STACKSEG_END, GETB67), +AC_CHECK_FUNC(getb67, AC_DEFINE(CRAY_STACKSEG_END, getb67)))) +fi + +AC_MSG_CHECKING(stack direction for C alloca) +AC_CACHE_VAL(ac_cv_c_stack_direction, +[AC_TRY_RUN([find_stack_direction () +{ + static char *addr = 0; + auto char dummy; + if (addr == 0) + { + addr = &dummy; + return find_stack_direction (); + } + else + return (&dummy > addr) ? 1 : -1; +} +main () +{ + exit (find_stack_direction() < 0); +}], ac_cv_c_stack_direction=1, ac_cv_c_stack_direction=-1, + ac_cv_c_stack_direction=0)])dnl +AC_MSG_RESULT($ac_cv_c_stack_direction) +AC_DEFINE_UNQUOTED(STACK_DIRECTION, $ac_cv_c_stack_direction) +fi +AC_SUBST(ALLOCA)dnl +]) + +AC_DEFUN(AC_FUNC_GETLOADAVG, +[# Some definitions of getloadavg require that the program be installed setgid. +NEED_SETGID=false +AC_SUBST(NEED_SETGID)dnl +ac_have_func=no + +# Check for the 4.4BSD definition of getloadavg. +AC_CHECK_LIB(util, getloadavg, [LIBS="$LIBS -lutil" ac_have_func=yes +# Some systems with -lutil have (and need) -lkvm as well, some do not. +AC_CHECK_LIB(kvm, kvm_open, LIBS="$LIBS -lkvm")]) + +if test $ac_have_func = no; then +# There is a commonly available library for RS/6000 AIX. +# Since it is not a standard part of AIX, it might be installed locally. +ac_save_LIBS="$LIBS" LIBS="-L/usr/local/lib $LIBS" +AC_CHECK_LIB(getloadavg, getloadavg, LIBS="$LIBS -lgetloadavg", LIBS="$ac_save_LIBS") +fi + +# Make sure it is really in the library, if we think we found it. +AC_REPLACE_FUNCS(getloadavg) + +if test $ac_cv_func_getloadavg = yes; then + AC_DEFINE(HAVE_GETLOADAVG) +else +ac_have_func=no +AC_CHECK_HEADER(sys/dg_sys_info.h, +[ac_have_func=yes AC_DEFINE(DGUX) +AC_CHECK_LIB(dgc, dg_sys_info)]) +if test $ac_have_func = no; then +# We cannot check for <dwarf.h>, because Solaris 2 does not use dwarf (it +# uses stabs), but it is still SVR4. We cannot check for <elf.h> because +# Irix 4.0.5F has the header but not the library. +AC_CHECK_LIB(elf, elf_read, + [LIBS="$LIBS -lelf" ac_have_func=yes AC_DEFINE(SVR4) + AC_CHECK_LIB(kvm, kvm_open, LIBS="$LIBS -lkvm")]) +fi +if test $ac_have_func = no; then +AC_CHECK_HEADER(inq_stats/cpustats.h, + [ac_have_func=yes AC_DEFINE(UMAX) + AC_DEFINE(UMAX4_3)]) +fi +if test $ac_have_func = no; then +AC_CHECK_HEADER(sys/cpustats.h, + [ac_have_func=yes AC_DEFINE(UMAX)]) +fi +if test $ac_have_func = no; then +AC_CHECK_HEADERS(mach/mach.h) +fi + +AC_CHECK_HEADER(nlist.h, +[AC_DEFINE(NLIST_STRUCT) +AC_MSG_CHECKING([for n_un in struct nlist]) +AC_CACHE_VAL(ac_cv_struct_nlist_n_un, +[AC_TRY_COMPILE([#include <nlist.h>], +[struct nlist n; n.n_un.n_name = 0;], +ac_cv_struct_nlist_n_un=yes, ac_cv_struct_nlist_n_un=no)])dnl +AC_MSG_RESULT($ac_cv_struct_nlist_n_un) +if test $ac_cv_struct_nlist_n_un = yes; then + AC_DEFINE(NLIST_NAME_UNION) +fi +])dnl + +dnl FIXME two bugs here: +dnl Hardwiring the path of getloadavg.c in the top-level directory, +dnl and not checking whether a getloadavg from a library needs privileges. +AC_MSG_CHECKING(whether getloadavg requires setgid) +AC_CACHE_VAL(ac_cv_func_getloadavg_setgid, +[AC_EGREP_CPP([Yowza Am I SETGID yet], +[#include "$srcdir/getloadavg.c" +#ifdef LDAV_PRIVILEGED +Yowza Am I SETGID yet +#endif], + ac_cv_func_getloadavg_setgid=yes, ac_cv_func_getloadavg_setgid=no)])dnl +AC_MSG_RESULT($ac_cv_func_getloadavg_setgid) +if test $ac_cv_func_getloadavg_setgid = yes; then + NEED_SETGID=true AC_DEFINE(GETLOADAVG_PRIVILEGED) +fi + +fi # Do not have getloadavg in system libraries. + +if test "$NEED_SETGID" = true; then + AC_MSG_CHECKING(group of /dev/kmem) +AC_CACHE_VAL(ac_cv_group_kmem, +[changequote(, )dnl + # On Solaris, /dev/kmem is a symlink. Get info on the real file. + ac_ls_output=`ls -lgL /dev/kmem 2>/dev/null` + # If we got an error (system does not support symlinks), try without -L. + test -z "$ac_ls_output" && ac_ls_output=`ls -lg /dev/kmem` + ac_cv_group_kmem=`echo $ac_ls_output \ + | sed -ne 's/[ ][ ]*/ /g; + s/^.[sSrwx-]* *[0-9]* *\([^0-9]*\) *.*/\1/; + / /s/.* //;p;'` +changequote([, ])dnl +])dnl + KMEM_GROUP=$ac_cv_group_kmem + AC_MSG_RESULT($KMEM_GROUP) +fi +AC_SUBST(KMEM_GROUP)dnl +]) + +AC_DEFUN(AC_FUNC_UTIME_NULL, +[AC_MSG_CHECKING(whether utime accepts a null argument) +AC_CACHE_VAL(ac_cv_func_utime_null, +[rm -f conftestdata; > conftestdata +# Sequent interprets utime(file, 0) to mean use start of epoch. Wrong. +AC_TRY_RUN([#include <sys/types.h> +#include <sys/stat.h> +main() { +struct stat s, t; +exit(!(stat ("conftestdata", &s) == 0 && utime("conftestdata", (long *)0) == 0 +&& stat("conftestdata", &t) == 0 && t.st_mtime >= s.st_mtime +&& t.st_mtime - s.st_mtime < 120)); +}], ac_cv_func_utime_null=yes, ac_cv_func_utime_null=no, + ac_cv_func_utime_null=no) +rm -f core])dnl +AC_MSG_RESULT($ac_cv_func_utime_null) +if test $ac_cv_func_utime_null = yes; then + AC_DEFINE(HAVE_UTIME_NULL) +fi +]) + +AC_DEFUN(AC_FUNC_STRCOLL, +[AC_MSG_CHECKING(for strcoll) +AC_CACHE_VAL(ac_cv_func_strcoll, +[AC_TRY_RUN([#include <string.h> +main () +{ + exit (strcoll ("abc", "def") >= 0 || + strcoll ("ABC", "DEF") >= 0 || + strcoll ("123", "456") >= 0); +}], ac_cv_func_strcoll=yes, ac_cv_func_strcoll=no, ac_cv_func_strcoll=no)])dnl +AC_MSG_RESULT($ac_cv_func_strcoll) +if test $ac_cv_func_strcoll = yes; then + AC_DEFINE(HAVE_STRCOLL) +fi +]) + +AC_DEFUN(AC_FUNC_SETVBUF_REVERSED, +[AC_MSG_CHECKING(whether setvbuf arguments are reversed) +AC_CACHE_VAL(ac_cv_func_setvbuf_reversed, +[AC_TRY_RUN([#include <stdio.h> +/* If setvbuf has the reversed format, exit 0. */ +main () { + /* This call has the arguments reversed. + A reversed system may check and see that the address of main + is not _IOLBF, _IONBF, or _IOFBF, and return nonzero. */ + if (setvbuf(stdout, _IOLBF, (char *) main, BUFSIZ) != 0) + exit(1); + putc('\r', stdout); + exit(0); /* Non-reversed systems segv here. */ +}], ac_cv_func_setvbuf_reversed=yes, ac_cv_func_setvbuf_reversed=no) +rm -f core])dnl +AC_MSG_RESULT($ac_cv_func_setvbuf_reversed) +if test $ac_cv_func_setvbuf_reversed = yes; then + AC_DEFINE(SETVBUF_REVERSED) +fi +]) + +AC_DEFUN(AC_FUNC_GETMNTENT, +[# getmntent is in -lsun on Irix 4, -lseq on Dynix/PTX. +AC_CHECK_LIB(sun, getmntent, LIBS="$LIBS -lsun", + [AC_CHECK_LIB(seq, getmntent, LIBS="$LIBS -lseq")]) +AC_CHECK_FUNC(getmntent, [AC_DEFINE(HAVE_GETMNTENT)])]) + +AC_DEFUN(AC_FUNC_STRFTIME, +[# strftime is in -lintl on SCO UNIX. +AC_CHECK_LIB(intl, strftime, LIBS="$LIBS -lintl") +AC_CHECK_FUNC(strftime, [AC_DEFINE(HAVE_STRFTIME)])]) + +AC_DEFUN(AC_FUNC_MEMCMP, +[AC_MSG_CHECKING(for 8-bit clean memcmp) +AC_CACHE_VAL(ac_cv_func_memcmp, +[AC_TRY_RUN([ +main() +{ + char c0 = 0x40, c1 = 0x80, c2 = 0x81; + exit(memcmp(&c0, &c2, 1) < 0 && memcmp(&c1, &c2, 1) < 0 ? 0 : 1); +} +], ac_cv_func_memcmp=yes, ac_cv_func_memcmp=no, ac_cv_func_memcmp=no)])dnl +AC_MSG_RESULT($ac_cv_func_memcmp) +test $ac_cv_func_memcmp = no && LIBOBJS="$LIBOBJS memcmp.o" +AC_SUBST(LIBOBJS)dnl +]) + + +dnl ### Checks for structure members + + +AC_DEFUN(AC_HEADER_TIME, +[AC_MSG_CHECKING([whether time.h and sys/time.h may both be included]) +AC_CACHE_VAL(ac_cv_header_time, +[AC_TRY_COMPILE([#include <sys/types.h> +#include <sys/time.h> +#include <time.h>], +[struct tm *tp;], ac_cv_header_time=yes, ac_cv_header_time=no)])dnl +AC_MSG_RESULT($ac_cv_header_time) +if test $ac_cv_header_time = yes; then + AC_DEFINE(TIME_WITH_SYS_TIME) +fi +]) + +AC_DEFUN(AC_STRUCT_TM, +[AC_MSG_CHECKING([whether struct tm is in sys/time.h or time.h]) +AC_CACHE_VAL(ac_cv_struct_tm, +[AC_TRY_COMPILE([#include <sys/types.h> +#include <time.h>], +[struct tm *tp; tp->tm_sec;], + ac_cv_struct_tm=time.h, ac_cv_struct_tm=sys/time.h)])dnl +AC_MSG_RESULT($ac_cv_struct_tm) +if test $ac_cv_struct_tm = sys/time.h; then + AC_DEFINE(TM_IN_SYS_TIME) +fi +]) + +AC_DEFUN(AC_STRUCT_TIMEZONE, +[AC_REQUIRE([AC_STRUCT_TM])dnl +AC_MSG_CHECKING([for tm_zone in struct tm]) +AC_CACHE_VAL(ac_cv_struct_tm_zone, +[AC_TRY_COMPILE([#include <sys/types.h> +#include <$ac_cv_struct_tm>], [struct tm tm; tm.tm_zone;], + ac_cv_struct_tm_zone=yes, ac_cv_struct_tm_zone=no)])dnl +AC_MSG_RESULT($ac_cv_struct_tm_zone) +if test "$ac_cv_struct_tm_zone" = yes; then + AC_DEFINE(HAVE_TM_ZONE) +else + AC_MSG_CHECKING([for tzname]) +AC_CACHE_VAL(ac_cv_var_tzname, +[AC_TRY_LINK( +changequote(<<, >>)dnl +<<#include <time.h> +#ifndef tzname /* For SGI. */ +extern char *tzname[]; /* RS6000 and others reject char **tzname. */ +#endif>>, +changequote([, ])dnl +[atoi(*tzname);], ac_cv_var_tzname=yes, ac_cv_var_tzname=no)])dnl + AC_MSG_RESULT($ac_cv_var_tzname) + if test $ac_cv_var_tzname = yes; then + AC_DEFINE(HAVE_TZNAME) + fi +fi +]) + +AC_DEFUN(AC_STRUCT_ST_BLOCKS, +[AC_MSG_CHECKING([for st_blocks in struct stat]) +AC_CACHE_VAL(ac_cv_struct_st_blocks, +[AC_TRY_COMPILE([#include <sys/types.h> +#include <sys/stat.h>], [struct stat s; s.st_blocks;], +ac_cv_struct_st_blocks=yes, ac_cv_struct_st_blocks=no)])dnl +AC_MSG_RESULT($ac_cv_struct_st_blocks) +if test $ac_cv_struct_st_blocks = yes; then + AC_DEFINE(HAVE_ST_BLOCKS) +else + LIBOBJS="$LIBOBJS fileblocks.o" +fi +AC_SUBST(LIBOBJS)dnl +]) + +AC_DEFUN(AC_STRUCT_ST_BLKSIZE, +[AC_MSG_CHECKING([for st_blksize in struct stat]) +AC_CACHE_VAL(ac_cv_struct_st_blksize, +[AC_TRY_COMPILE([#include <sys/types.h> +#include <sys/stat.h>], [struct stat s; s.st_blksize;], +ac_cv_struct_st_blksize=yes, ac_cv_struct_st_blksize=no)])dnl +AC_MSG_RESULT($ac_cv_struct_st_blksize) +if test $ac_cv_struct_st_blksize = yes; then + AC_DEFINE(HAVE_ST_BLKSIZE) +fi +]) + +AC_DEFUN(AC_STRUCT_ST_RDEV, +[AC_MSG_CHECKING([for st_rdev in struct stat]) +AC_CACHE_VAL(ac_cv_struct_st_rdev, +[AC_TRY_COMPILE([#include <sys/types.h> +#include <sys/stat.h>], [struct stat s; s.st_rdev;], +ac_cv_struct_st_rdev=yes, ac_cv_struct_st_rdev=no)])dnl +AC_MSG_RESULT($ac_cv_struct_st_rdev) +if test $ac_cv_struct_st_rdev = yes; then + AC_DEFINE(HAVE_ST_RDEV) +fi +]) + + +dnl ### Checks for compiler characteristics + + +AC_DEFUN(AC_C_CROSS, +[# If we cannot run a trivial program, we must be cross compiling. +AC_MSG_CHECKING(whether cross-compiling) +AC_CACHE_VAL(ac_cv_c_cross, +[AC_TRY_RUN([main(){return(0);}], + ac_cv_c_cross=no, ac_cv_c_cross=yes, ac_cv_cross=yes)])dnl +cross_compiling=$ac_cv_c_cross +AC_MSG_RESULT($ac_cv_c_cross) +]) + +AC_DEFUN(AC_C_CHAR_UNSIGNED, +[AC_MSG_CHECKING(whether char is unsigned) +AC_CACHE_VAL(ac_cv_c_char_unsigned, +[if test "$GCC" = yes; then + # GCC predefines this symbol on systems where it applies. +AC_EGREP_CPP(yes, +[#ifdef __CHAR_UNSIGNED__ + yes +#endif +], ac_cv_c_char_unsigned=yes, ac_cv_c_char_unsigned=no) +else +AC_TRY_RUN( +[/* volatile prevents gcc2 from optimizing the test away on sparcs. */ +#if !defined(__STDC__) || __STDC__ != 1 +#define volatile +#endif +main() { + volatile char c = 255; exit(c < 0); +}], ac_cv_c_char_unsigned=yes, ac_cv_c_char_unsigned=no) +fi])dnl +AC_MSG_RESULT($ac_cv_c_char_unsigned) +if test $ac_cv_c_char_unsigned = yes && test "$GCC" != yes; then + AC_DEFINE(__CHAR_UNSIGNED__) +fi +]) + +AC_DEFUN(AC_C_LONG_DOUBLE, +[AC_MSG_CHECKING(for long double) +AC_CACHE_VAL(ac_cv_c_long_double, +[if test "$GCC" = yes; then + ac_cv_c_long_double=yes +else +AC_TRY_RUN([int main() { +/* The Stardent Vistra knows sizeof(long double), but does not support it. */ +long double foo = 0.0; +/* On Ultrix 4.3 cc, long double is 4 and double is 8. */ +exit(sizeof(long double) < sizeof(double)); }], +ac_cv_c_long_double=yes, ac_cv_c_long_double=no) +fi])dnl +AC_MSG_RESULT($ac_cv_c_long_double) +if test $ac_cv_c_long_double = yes; then + AC_DEFINE(HAVE_LONG_DOUBLE) +fi +]) + +AC_DEFUN(AC_INT_16_BITS, +[AC_OBSOLETE([$0], [; instead use AC_CHECK_SIZEOF(int)])dnl +AC_MSG_CHECKING(whether int is 16 bits) +AC_TRY_RUN([main() { exit(sizeof(int) != 2); }], + [AC_MSG_RESULT(yes) + AC_DEFINE(INT_16_BITS)], AC_MSG_RESULT(no)) +]) + +AC_DEFUN(AC_LONG_64_BITS, +[AC_OBSOLETE([$0], [; instead use AC_CHECK_SIZEOF(long)])dnl +AC_MSG_CHECKING(whether long int is 64 bits) +AC_TRY_RUN([main() { exit(sizeof(long int) != 8); }], + [AC_MSG_RESULT(yes) + AC_DEFINE(LONG_64_BITS)], AC_MSG_RESULT(no)) +]) + +AC_DEFUN(AC_C_BIGENDIAN, +[AC_MSG_CHECKING(whether byte ordering is bigendian) +AC_CACHE_VAL(ac_cv_c_bigendian, +[AC_TRY_RUN([main () { + /* Are we little or big endian? From Harbison&Steele. */ + union + { + long l; + char c[sizeof (long)]; + } u; + u.l = 1; + exit (u.c[sizeof (long) - 1] == 1); +}], ac_cv_c_bigendian=no, ac_cv_c_bigendian=yes)])dnl +AC_MSG_RESULT($ac_cv_c_bigendian) +if test $ac_cv_c_bigendian = yes; then + AC_DEFINE(WORDS_BIGENDIAN) +fi +]) + +AC_DEFUN(AC_C_INLINE, +[AC_MSG_CHECKING([for inline]) +AC_CACHE_VAL(ac_cv_c_inline, +[if test "$GCC" = yes; then +AC_TRY_COMPILE(, [} inline foo() {], ac_cv_c_inline=yes, ac_cv_c_inline=no) +else + ac_cv_c_inline=no +fi])dnl +AC_MSG_RESULT($ac_cv_c_inline) +if test $ac_cv_c_inline = no; then + AC_DEFINE(inline, __inline) +fi +]) + +AC_DEFUN(AC_C_CONST, +[dnl This message is consistent in form with the other checking messages, +dnl and with the result message. +AC_MSG_CHECKING([for working const]) +AC_CACHE_VAL(ac_cv_c_const, +[AC_TRY_COMPILE(, +changequote(<<, >>)dnl +<< +/* Ultrix mips cc rejects this. */ +typedef int charset[2]; const charset x; +/* SunOS 4.1.1 cc rejects this. */ +char const *const *ccp; +char **p; +/* NEC SVR4.0.2 mips cc rejects this. */ +struct point {int x, y;}; +static struct point const zero; +/* AIX XL C 1.02.0.0 rejects this. + It does not let you subtract one const X* pointer from another in an arm + of an if-expression whose if-part is not a constant expression */ +const char *g = "string"; +ccp = &g + (g ? g-g : 0); +/* HPUX 7.0 cc rejects these. */ +++ccp; +p = (char**) ccp; +ccp = (char const *const *) p; +{ /* SCO 3.2v4 cc rejects this. */ + char *t; + char const *s = 0 ? (char *) 0 : (char const *) 0; + + *t++ = 0; +} +{ /* Someone thinks the Sun supposedly-ANSI compiler will reject this. */ + int x[] = {25, 17}; + const int *foo = &x[0]; + ++foo; +} +{ /* Sun SC1.0 ANSI compiler rejects this -- but not the above. */ + typedef const int *iptr; + iptr p = 0; + ++p; +} +{ /* AIX XL C 1.02.0.0 rejects this saying + "k.c", line 2.27: 1506-025 (S) Operand must be a modifiable lvalue. */ + struct s { int j; const int *ap[3]; }; + struct s *b; b->j = 5; +} +{ /* ULTRIX-32 V3.1 (Rev 9) vcc rejects this */ + const int foo = 10; +} +>>, +changequote([, ])dnl +ac_cv_c_const=yes, ac_cv_c_const=no)])dnl +AC_MSG_RESULT($ac_cv_c_const) +if test $ac_cv_c_const = no; then + AC_DEFINE(const, ) +fi +]) + +define(AC_ARG_ARRAY, +[errprint(__file__:__line__: [$0] has been removed; don't do unportable things with arguments +)m4exit(4)]) + + +dnl ### Checks for operating system services + + +AC_DEFUN(AC_SYS_INTERPRETER, +[# Pull the hash mark out of the macro call to avoid m4 problems. +ac_msg="whether #! works in shell scripts" +AC_MSG_CHECKING($ac_msg) +AC_CACHE_VAL(ac_cv_sys_interpreter, +[echo '#!/bin/cat +exit 69 +' > conftest +chmod u+x conftest +(SHELL=/bin/sh; export SHELL; ./conftest >/dev/null) +if test $? -ne 69; then + ac_cv_sys_interpreter=yes +else + ac_cv_sys_interpreter=no +fi +rm -f conftest])dnl +AC_MSG_RESULT($ac_cv_sys_interpreter) +]) + +define(AC_HAVE_POUNDBANG, +[errprint(__file__:__line__: [$0 has been replaced by AC_SYS_INTERPRETER, taking no arguments +])m4exit(4)]) + +AC_DEFUN(AC_SYS_LONG_FILE_NAMES, +[AC_MSG_CHECKING(for long file names) +AC_CACHE_VAL(ac_cv_sys_long_file_names, +[ac_cv_sys_long_file_names=yes +# Test for long file names in all the places we know might matter: +# . the current directory, where building will happen +# /tmp where it might want to write temporary files +# /var/tmp likewise +# /usr/tmp likewise +# $prefix/lib where we will be installing things +# $exec_prefix/lib likewise +# eval it to expand exec_prefix. +for ac_dir in `eval echo . /tmp /var/tmp /usr/tmp $prefix/lib $exec_prefix/lib` ; do + test -d $ac_dir || continue + test -w $ac_dir || continue # It is less confusing to not echo anything here. + (echo 1 > $ac_dir/conftest9012345) 2>/dev/null + (echo 2 > $ac_dir/conftest9012346) 2>/dev/null + val=`cat $ac_dir/conftest9012345 2>/dev/null` + if test ! -f $ac_dir/conftest9012345 || test "$val" != 1; then + ac_cv_sys_long_file_names=no + rm -f $ac_dir/conftest9012345 $ac_dir/conftest9012346 2>/dev/null + break + fi + rm -f $ac_dir/conftest9012345 $ac_dir/conftest9012346 2>/dev/null +done])dnl +AC_MSG_RESULT($ac_cv_sys_long_file_names) +if test $ac_cv_sys_long_file_names = yes; then + AC_DEFINE(HAVE_LONG_FILE_NAMES) +fi +]) + +AC_DEFUN(AC_SYS_RESTARTABLE_SYSCALLS, +[AC_MSG_CHECKING(for restartable system calls) +AC_CACHE_VAL(ac_cv_sys_restartable_syscalls, +[AC_TRY_RUN( +[/* Exit 0 (true) if wait returns something other than -1, + i.e. the pid of the child, which means that wait was restarted + after getting the signal. */ +#include <sys/types.h> +#include <signal.h> +ucatch (isig) { } +main () { + int i = fork (), status; + if (i == 0) { sleep (3); kill (getppid (), SIGINT); sleep (3); exit (0); } + signal (SIGINT, ucatch); + status = wait(&i); + if (status == -1) wait(&i); + exit (status == -1); +} +], ac_cv_sys_restartable_syscalls=yes, ac_cv_sys_restartable_syscalls=no)])dnl +AC_MSG_RESULT($ac_cv_sys_restartable_syscalls) +if test $ac_cv_sys_restartable_syscalls = yes; then + AC_DEFINE(HAVE_RESTARTABLE_SYSCALLS) +fi +]) + +AC_DEFUN(AC_PATH_X, +[AC_REQUIRE_CPP()dnl Set CPP; we run AC_PATH_X_DIRECT conditionally. +# If we find X, set shell vars x_includes and x_libraries to the +# paths, otherwise set no_x=yes. +# Uses ac_ vars as temps to allow command line to override cache and checks. +# --without-x overrides everything else, but does not touch the cache. +AC_MSG_CHECKING(for X) + +AC_ARG_WITH(x, [ --with-x use the X Window System]) +if test "x$with_x" = xno; then + no_x=yes +else + if test "x$x_includes" != xNONE && test "x$x_libraries" != xNONE; then + no_x= + else +AC_CACHE_VAL(ac_cv_path_x, +[# One or both of the vars are not set, and there is no cached value. +no_x=yes +AC_PATH_X_XMKMF +if test "$no_x" = yes; then +AC_PATH_X_DIRECT +fi +if test "$no_x" = yes; then + ac_cv_path_x="no_x=yes" +else + ac_cv_path_x="no_x= ac_x_includes=$ac_x_includes ac_x_libraries=$ac_x_libraries" +fi])dnl + fi + eval "$ac_cv_path_x" +fi # $with_x != no + +if test "$no_x" = yes; then + AC_MSG_RESULT(no) +else + test "x$x_includes" = xNONE && x_includes=$ac_x_includes + test "x$x_libraries" = xNONE && x_libraries=$ac_x_libraries + ac_cv_path_x="no_x= ac_x_includes=$x_includes ac_x_libraries=$x_libraries" + AC_MSG_RESULT([libraries $x_libraries, headers $x_includes]) +fi +]) + +dnl Internal subroutine of AC_PATH_X. +dnl Set ac_x_includes, ac_x_libraries, and no_x (initially yes). +AC_DEFUN(AC_PATH_X_XMKMF, +[rm -fr conftestdir +if mkdir conftestdir; then + cd conftestdir + # Make sure to not put "make" in the Imakefile rules, since we grep it out. + cat > Imakefile <<'EOF' +acfindx: + @echo 'ac_im_incroot="${INCROOT}"; ac_im_usrlibdir="${USRLIBDIR}"; ac_im_libdir="${LIBDIR}"' +EOF + if (xmkmf) >/dev/null 2>/dev/null && test -f Makefile; then + no_x= + # GNU make sometimes prints "make[1]: Entering...", which would confuse us. + eval `make acfindx 2>/dev/null | grep -v make` + # Open Windows xmkmf reportedly sets LIBDIR instead of USRLIBDIR. + if test ! -f $ac_im_usrlibdir/libX11.a && test -f $ac_im_libdir/libX11.a + then + ac_im_usrlibdir=$ac_im_libdir + fi + case "$ac_im_incroot" in + /usr/include) ;; + *) ac_x_includes="$ac_im_incroot" ;; + esac + case "$ac_im_usrlibdir" in + /usr/lib | /lib) ;; + *) ac_x_libraries="$ac_im_usrlibdir" ;; + esac + fi + cd .. + rm -fr conftestdir +fi +]) + +dnl Internal subroutine of AC_PATH_X. +dnl Set ac_x_includes, ac_x_libraries, and no_x (initially yes). +AC_DEFUN(AC_PATH_X_DIRECT, +[test -z "$x_direct_test_library" && x_direct_test_library=Xt +test -z "$x_direct_test_function" && x_direct_test_function=XtMalloc +test -z "$x_direct_test_include" && x_direct_test_include=X11/Intrinsic.h +AC_TRY_CPP([#include <$x_direct_test_include>], +[no_x= ac_x_includes=], +[ for ac_dir in \ + /usr/X11R6/include \ + /usr/X11R5/include \ + /usr/X11R4/include \ + \ + /usr/include/X11R6 \ + /usr/include/X11R5 \ + /usr/include/X11R4 \ + \ + /usr/local/X11R6/include \ + /usr/local/X11R5/include \ + /usr/local/X11R4/include \ + \ + /usr/local/include/X11R6 \ + /usr/local/include/X11R5 \ + /usr/local/include/X11R4 \ + \ + /usr/X11/include \ + /usr/include/X11 \ + /usr/local/X11/include \ + /usr/local/include/X11 \ + \ + /usr/X386/include \ + /usr/x386/include \ + /usr/XFree86/include/X11 \ + \ + /usr/include \ + /usr/local/include \ + /usr/unsupported/include \ + /usr/athena/include \ + /usr/local/x11r5/include \ + /usr/lpp/Xamples/include \ + \ + /usr/openwin/include \ + /usr/openwin/share/include \ + ; \ + do + if test -r "$ac_dir/$x_direct_test_include"; then + no_x= ac_x_includes=$ac_dir + break + fi + done]) + +# Check for the libraries. +# See if we find them without any special options. +# Don't add to $LIBS permanently. +ac_save_LIBS="$LIBS" +LIBS="$LIBS -l$x_direct_test_library" +AC_TRY_LINK(, [${x_direct_test_function}()], +[LIBS="$ac_save_LIBS" no_x= ac_x_libraries=], +[LIBS="$ac_save_LIBS" +# First see if replacing the include by lib works. +for ac_dir in `echo "$ac_x_includes" | sed s/include/lib/` \ + /usr/X11R6/lib \ + /usr/X11R5/lib \ + /usr/X11R4/lib \ + \ + /usr/lib/X11R6 \ + /usr/lib/X11R5 \ + /usr/lib/X11R4 \ + \ + /usr/local/X11R6/lib \ + /usr/local/X11R5/lib \ + /usr/local/X11R4/lib \ + \ + /usr/local/lib/X11R6 \ + /usr/local/lib/X11R5 \ + /usr/local/lib/X11R4 \ + \ + /usr/X11/lib \ + /usr/lib/X11 \ + /usr/local/X11/lib \ + /usr/local/lib/X11 \ + \ + /usr/X386/lib \ + /usr/x386/lib \ + /usr/XFree86/lib/X11 \ + \ + /usr/lib \ + /usr/local/lib \ + /usr/unsupported/lib \ + /usr/athena/lib \ + /usr/local/x11r5/lib \ + /usr/lpp/Xamples/lib \ + \ + /usr/openwin/lib \ + /usr/openwin/share/lib \ + ; \ +do + for ac_extension in a so sl; do + if test -r $ac_dir/lib${x_direct_test_library}.$ac_extension; then + no_x= ac_x_libraries=$ac_dir + break 2 + fi + done +done])]) + +dnl Find additional X libraries, magic flags, etc. +AC_DEFUN(AC_PATH_XTRA, +[AC_REQUIRE([AC_ISC_POSIX])dnl +AC_REQUIRE([AC_PATH_X])dnl +if test "$no_x" = yes; then + # Not all programs may use this symbol, but it does not hurt to define it. + X_CFLAGS="$X_CFLAGS -DX_DISPLAY_MISSING" +else + if test -n "$x_includes"; then + X_CFLAGS="$X_CFLAGS -I$x_includes" + fi + + # It would be nice to have a more robust check for the -R ld option than + # just checking for Solaris. + # It would also be nice to do this for all -L options, not just this one. + if test -n "$x_libraries"; then + X_LIBS="$X_LIBS -L$x_libraries" + if test "`(uname) 2>/dev/null`" = SunOS && + uname -r | grep '^5' >/dev/null; then + X_LIBS="$X_LIBS -R$x_libraries" + fi + fi + + # Check for libraries that X11R6 Xt/Xaw programs need. + + ac_save_LDFLAGS="$LDFLAGS" + LDFLAGS="$LDFLAGS -L$x_libraries" + # SM needs ICE to (dynamically) link under SunOS 4.x (so we have to + # check for ICE first), but we must link in the order -lSM -lICE or + # we get undefined symbols. So assume we have SM if we have ICE. + # These have to be linked with before -lX11, unlike the other + # libraries we check for below, so use a different variable. + # --interran@uluru.Stanford.EDU, kb@cs.umb.edu. + AC_CHECK_LIB(ICE, IceConnectionNumbers, + [X_PRE_LIBS="$X_PRE_LIBS -lSM -lICE"]) + LDFLAGS="$ac_save_LDFLAGS" + + # Check for system-dependent libraries X programs must link with. + + if test "$ISC" = yes; then + X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl_s -linet" + else + # Martyn.Johnson@cl.cam.ac.uk says this is needed for Ultrix, if the X + # libraries were built with DECnet support. And karl@cs.umb.edu says + # the Alpha needs dnet_stub (dnet does not exist). + AC_CHECK_LIB(dnet, dnet_ntoa, [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet"]) + if test $ac_cv_lib_dnet = no; then + AC_CHECK_LIB(dnet_stub, dnet_ntoa, + [X_EXTRA_LIBS="$X_EXTRA_LIBS -ldnet_stub"]) + fi + + # msh@cis.ufl.edu says -lnsl (and -lsocket) are needed for his 386/AT, + # to get the SysV transport functions. + # Not sure which flavor of 386 UNIX this is, but it seems harmless to + # check for it. + AC_CHECK_LIB(nsl, t_accept, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lnsl"]) + + # lieder@skyler.mavd.honeywell.com says without -lsocket, + # socket/setsockopt and other routines are undefined under SCO ODT 2.0. + # But -lsocket is broken on IRIX, according to simon@lia.di.epfl.ch. + if test "`(uname) 2>/dev/null`" != IRIX; then + AC_CHECK_LIB(socket, socket, [X_EXTRA_LIBS="$X_EXTRA_LIBS -lsocket"]) + fi + fi +fi +AC_SUBST(X_CFLAGS)dnl +AC_SUBST(X_PRE_LIBS)dnl +AC_SUBST(X_LIBS)dnl +AC_SUBST(X_EXTRA_LIBS)dnl +]) + + +dnl ### Checks for UNIX variants +dnl These are kludges which should be replaced by a single POSIX check. + + +AC_DEFUN(AC_AIX, +[AC_BEFORE([$0], [AC_TRY_COMPILE])dnl +AC_BEFORE([$0], [AC_TRY_LINK])dnl +AC_BEFORE([$0], [AC_TRY_RUN])dnl +AC_MSG_CHECKING(for AIX) +AC_EGREP_CPP(yes, +[#ifdef _AIX + yes +#endif +], [AC_MSG_RESULT(yes); AC_DEFINE(_ALL_SOURCE)], AC_MSG_RESULT(no)) +]) + +AC_DEFUN(AC_MINIX, +[AC_BEFORE([$0], [AC_TRY_COMPILE])dnl +AC_BEFORE([$0], [AC_TRY_LINK])dnl +AC_BEFORE([$0], [AC_TRY_RUN])dnl +AC_CHECK_HEADER(minix/config.h, MINIX=yes, MINIX=) +if test "$MINIX" = yes; then + AC_DEFINE(_POSIX_SOURCE) + AC_DEFINE(_POSIX_1_SOURCE, 2) + AC_DEFINE(_MINIX) +fi +]) + +AC_DEFUN(AC_ISC_POSIX, +[AC_BEFORE([$0], [AC_TRY_LINK])dnl +AC_BEFORE([$0], [AC_TRY_LINK])dnl +AC_BEFORE([$0], [AC_TRY_RUN])dnl +AC_MSG_CHECKING(for POSIXized ISC) +if test -d /etc/conf/kconfig.d && + grep _POSIX_VERSION [/usr/include/sys/unistd.h] >/dev/null 2>&1 +then + AC_MSG_RESULT(yes) + ISC=yes # If later tests want to check for ISC. + AC_DEFINE(_POSIX_SOURCE) + if test "$GCC" = yes; then + CC="$CC -posix" + else + CC="$CC -Xp" + fi +else + AC_MSG_RESULT(no) + ISC= +fi +]) + +AC_DEFUN(AC_XENIX_DIR, +[AC_OBSOLETE([$0], [; instead use AC_HEADER_DIRENT])dnl +AC_REQUIRE([AC_DIR_HEADER])dnl +AC_MSG_CHECKING(for Xenix) +AC_EGREP_CPP(yes, +[#if defined(M_XENIX) && !defined(M_UNIX) + yes +#endif +], [AC_MSG_RESULT(yes); XENIX=yes], [AC_MSG_RESULT(no); XENIX=]) +if test "$XENIX" = yes; then + # Make sure -ldir precedes -lx. + test $ac_header_dirent = dirent.h && LIBS="$LIBS -ldir" + LIBS="$LIBS -lx" +fi +]) + +AC_DEFUN(AC_DYNIX_SEQ, +[AC_OBSOLETE([$0], [; instead use AC_FUNC_GETMNTENT])dnl +AC_CHECK_LIB(seq, getmntent, LIBS="$LIBS -lseq") +]) + +AC_DEFUN(AC_IRIX_SUN, +[AC_OBSOLETE([$0], [; instead use AC_FUNC_GETMNTENT or AC_CHECK_LIB(sun, getpwnam)])dnl +AC_CHECK_LIB(sun, getmntent, LIBS="$LIBS -lsun") +]) + +AC_DEFUN(AC_SCO_INTL, +[AC_OBSOLETE([$0], [; instead use AC_FUNC_STRFTIME])dnl +AC_CHECK_LIB(intl, strftime, LIBS="$LIBS -lintl") +]) diff --git a/util/autoconf/autoconf.info b/util/autoconf/autoconf.info new file mode 100644 index 0000000..cec6b13 --- /dev/null +++ b/util/autoconf/autoconf.info @@ -0,0 +1,152 @@ +This is Info file autoconf.info, produced by Makeinfo-1.55 from the +input file ./autoconf.texi. + +START-INFO-DIR-ENTRY +* Autoconf: (autoconf). Create source code configuration scripts. +END-INFO-DIR-ENTRY + + This file documents the GNU Autoconf package for creating scripts to +configure source code packages using templates and an `m4' macro +package. + + Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. + + Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, provided that +the entire resulting derived work is distributed under the terms of a +permission notice identical to this one. + + Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions, except that this permission notice may be stated in a +translation approved by the Foundation. + + +Indirect: +autoconf.info-1: 1085 +autoconf.info-2: 51012 +autoconf.info-3: 100216 +autoconf.info-4: 150192 +autoconf.info-5: 198408 + +Tag Table: +(Indirect) +Node: Top1085 +Node: Introduction9210 +Node: Making configure Scripts13050 +Node: Writing configure.in16115 +Node: Invoking autoscan19815 +Node: Invoking ifnames22120 +Node: Invoking autoconf23610 +Node: Invoking autoreconf25448 +Node: Setup27768 +Node: Input28654 +Node: Output30270 +Node: Makefile Substitutions33020 +Node: Preset Output Variables34602 +Node: Build Directories37840 +Node: Automatic Remaking39566 +Node: Configuration Headers41632 +Node: Header Templates43999 +Node: Invoking autoheader45178 +Node: Subdirectories48265 +Node: Default Prefix49608 +Node: Versions51012 +Node: Existing Tests52914 +Node: Alternative Programs54379 +Node: Particular Programs55043 +Node: Generic Programs60893 +Node: Libraries62570 +Node: Library Functions64399 +Node: Particular Functions64957 +Node: Generic Functions70704 +Node: Header Files72545 +Node: Particular Headers73104 +Node: Generic Headers80075 +Node: Structures81375 +Node: Typedefs83612 +Node: Particular Typedefs84116 +Node: Generic Typedefs85316 +Node: Compiler Characteristics85759 +Node: System Services88215 +Node: UNIX Variants90536 +Node: Writing Tests92555 +Node: Examining Declarations94327 +Node: Examining Syntax96793 +Node: Examining Libraries97848 +Node: Run Time100216 +Node: Test Programs101177 +Node: Guidelines103712 +Node: Test Functions104901 +Node: Portable Shell106444 +Node: Testing Values and Files108096 +Node: Multiple Cases109751 +Node: Language Choice110949 +Node: Results112507 +Node: Defining Symbols113266 +Node: Setting Output Variables116275 +Node: Caching Results118121 +Node: Cache Variable Names120023 +Node: Cache Files121572 +Node: Printing Messages123357 +Node: Writing Macros126644 +Node: Macro Definitions127263 +Node: Macro Names128368 +Node: Quoting130819 +Node: Dependencies Between Macros132721 +Node: Prerequisite Macros133353 +Node: Suggested Ordering134808 +Node: Obsolete Macros136338 +Node: Manual Configuration137562 +Node: Specifying Names138471 +Node: Canonicalizing140343 +Node: System Type Variables141657 +Node: Using System Type142404 +Node: Site Configuration143684 +Node: External Software144457 +Node: Package Options146922 +Node: Site Details148978 +Node: Transforming Names150192 +Node: Transformation Options151371 +Node: Transformation Examples151837 +Node: Transformation Rules153405 +Node: Site Defaults154814 +Node: Invoking configure157976 +Node: Basic Installation158917 +Node: Compilers and Options161239 +Node: Build Directory161881 +Node: Installation Names162582 +Node: Optional Features163500 +Node: System Type164270 +Node: Sharing Defaults165292 +Node: Operation Controls165916 +Node: Invoking config.status166780 +Node: Questions170168 +Node: Distributing170700 +Node: Why GNU m4171826 +Node: Bootstrapping172639 +Node: Why Not Imake173255 +Node: Upgrading177836 +Node: Changed File Names179357 +Node: Changed Makefiles180093 +Node: Changed Macros181173 +Node: Invoking autoupdate182420 +Node: Changed Results184011 +Node: Changed Macro Writing186113 +Node: History187376 +Node: Genesis188083 +Node: Exodus189256 +Node: Leviticus192305 +Node: Numbers193828 +Node: Deuteronomy195744 +Node: Old Macro Names198408 +Node: Environment Variable Index201457 +Node: Output Variable Index202459 +Node: Preprocessor Symbol Index206540 +Node: Macro Index211348 + +End Tag Table diff --git a/util/autoconf/autoconf.info-1 b/util/autoconf/autoconf.info-1 new file mode 100644 index 0000000..f49358c --- /dev/null +++ b/util/autoconf/autoconf.info-1 @@ -0,0 +1,1156 @@ +This is Info file autoconf.info, produced by Makeinfo-1.55 from the +input file ./autoconf.texi. + +START-INFO-DIR-ENTRY +* Autoconf: (autoconf). Create source code configuration scripts. +END-INFO-DIR-ENTRY + + This file documents the GNU Autoconf package for creating scripts to +configure source code packages using templates and an `m4' macro +package. + + Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. + + Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, provided that +the entire resulting derived work is distributed under the terms of a +permission notice identical to this one. + + Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions, except that this permission notice may be stated in a +translation approved by the Foundation. + + +File: autoconf.info, Node: Top, Next: Introduction, Up: (dir) + + This file documents the GNU Autoconf package for creating scripts to +configure source code packages using templates and an `m4' macro +package. This is edition 2.1, for Autoconf version 2.1. + +* Menu: + +* Introduction:: Autoconf's purpose, strengths, and weaknesses. +* Making configure Scripts:: How to organize and produce Autoconf scripts. +* Setup:: Initialization and output. +* Existing Tests:: Macros that check for particular features. +* Writing Tests:: How to write new feature checks. +* Results:: What to do with results from feature checks. +* Writing Macros:: Adding new macros to Autoconf. +* Manual Configuration:: Selecting features that can't be guessed. +* Site Configuration:: Local defaults for `configure'. +* Invoking configure:: How to use the Autoconf output. +* Invoking config.status:: Recreating a configuration. +* Questions:: Questions about Autoconf, with answers. +* Upgrading:: Tips for upgrading from version 1. +* History:: History of Autoconf. +* Old Macro Names:: Backward compatibility macros. +* Environment Variable Index:: Index of environment variables used. +* Output Variable Index:: Index of variables set in output files. +* Preprocessor Symbol Index:: Index of C preprocessor symbols defined. +* Macro Index:: Index of Autoconf macros. + + -- The Detailed Node Listing -- + +Making `configure' Scripts + +* Writing configure.in:: What to put in an Autoconf input file. +* Invoking autoscan:: Semi-automatic `configure.in' writing. +* Invoking ifnames:: Listing the conditionals in source code. +* Invoking autoconf:: How to create configuration scripts. +* Invoking autoreconf:: Remaking multiple `configure' scripts. + +Initialization and Output Files + +* Input:: Where Autoconf should find files. +* Output:: Creating output files. +* Makefile Substitutions:: Using output variables in `Makefile's. +* Configuration Headers:: Creating a configuration header file. +* Subdirectories:: Configuring independent packages together. +* Default Prefix:: Changing the default installation prefix. +* Versions:: Version numbers in `configure'. + +Substitutions in Makefiles + +* Preset Output Variables:: Output variables that are always set. +* Build Directories:: Compiling in a different directory. +* Automatic Remaking:: Makefile rules for configuring. + +Configuration Header Files + +* Header Templates:: Input for the configuration headers. +* Invoking autoheader:: How to create configuration templates. + +Existing Tests + +* Alternative Programs:: Selecting between alternative programs. +* Libraries:: Library archives that might be missing. +* Library Functions:: C library functions that might be missing. +* Header Files:: Header files that might be missing. +* Structures:: Structures or members that might be missing. +* Typedefs:: `typedef's that might be missing. +* Compiler Characteristics:: C compiler or machine architecture features. +* System Services:: Operating system services. +* UNIX Variants:: Special kludges for specific UNIX variants. + +Alternative Programs + +* Particular Programs:: Special handling to find certain programs. +* Generic Programs:: How to find other programs. + +Library Functions + +* Particular Functions:: Special handling to find certain functions. +* Generic Functions:: How to find other functions. + +Header Files + +* Particular Headers:: Special handling to find certain headers. +* Generic Headers:: How to find other headers. + +Typedefs + +* Particular Typedefs:: Special handling to find certain types. +* Generic Typedefs:: How to find other types. + +Writing Tests + +* Examining Declarations:: Detecting header files and declarations. +* Examining Syntax:: Detecting language syntax features. +* Examining Libraries:: Detecting functions and global variables. +* Run Time:: Testing for run-time features. +* Portable Shell:: Shell script portability pitfalls. +* Testing Values and Files:: Checking strings and files. +* Multiple Cases:: Tests for several possible values. +* Language Choice:: Selecting which language to use for testing. + +Checking Run Time Behavior + +* Test Programs:: Running test programs. +* Guidelines:: General rules for writing test programs. +* Test Functions:: Avoiding pitfalls in test programs. + +Results of Tests + +* Defining Symbols:: Defining C preprocessor symbols. +* Setting Output Variables:: Replacing variables in output files. +* Caching Results:: Speeding up subsequent `configure' runs. +* Printing Messages:: Notifying users of progress or problems. + +Caching Results + +* Cache Variable Names:: Shell variables used in caches. +* Cache Files:: Files `configure' uses for caching. + +Writing Macros + +* Macro Definitions:: Basic format of an Autoconf macro. +* Macro Names:: What to call your new macros. +* Quoting:: Protecting macros from unwanted expansion. +* Dependencies Between Macros:: What to do when macros depend on other macros. + +Dependencies Between Macros + +* Prerequisite Macros:: Ensuring required information. +* Suggested Ordering:: Warning about possible ordering problems. +* Obsolete Macros:: Warning about old ways of doing things. + +Manual Configuration + +* Specifying Names:: Specifying the system type. +* Canonicalizing:: Getting the canonical system type. +* System Type Variables:: Variables containing the system type. +* Using System Type:: What to do with the system type. + +Site Configuration + +* External Software:: Working with other optional software. +* Package Options:: Selecting optional features. +* Site Details:: Configuring site details. +* Transforming Names:: Changing program names when installing. +* Site Defaults:: Giving `configure' local defaults. + +Transforming Program Names When Installing + +* Transformation Options:: `configure' options to transforme names. +* Transformation Examples:: Sample uses of transforming names. +* Transformation Rules:: `Makefile' uses of transforming names. + +Running `configure' Scripts + +* Basic Installation:: Instructions for typical cases. +* Compilers and Options:: Selecting compilers and optimization. +* Build Directory:: Configuring in a different directory. +* Installation Names:: Installing in different directories. +* Optional Features:: Selecting optional features. +* System Type:: Specifying the system type. +* Sharing Defaults:: Setting site-wide defaults for `configure'. +* Operation Controls:: Changing how `configure' runs. + +Questions About Autoconf + +* Distributing:: Distributing `configure' scripts. +* Why GNU m4:: Why not use the standard `m4'? +* Bootstrapping:: Autoconf and GNU `m4' require each other? +* Why Not Imake:: Why GNU uses `configure' instead of Imake. + +Upgrading From Version 1 + +* Changed File Names:: Files you might rename. +* Changed Makefiles:: New things to put in `Makefile.in'. +* Changed Macros:: Macro calls you might replace. +* Invoking autoupdate:: Replacing old macro names in `configure.in'. +* Changed Results:: Changes in how to check test results. +* Changed Macro Writing:: Better ways to write your own macros. + +History of Autoconf + +* Genesis:: Prehistory and naming of `configure'. +* Exodus:: The plagues of `m4' and Perl. +* Leviticus:: The priestly code of portability arrives. +* Numbers:: Growth and contributors. +* Deuteronomy:: Approaching the promises of easy configuration. + + +File: autoconf.info, Node: Introduction, Next: Making configure Scripts, Prev: Top, Up: Top + +Introduction +************ + + A physicist, an engineer, and a computer scientist were + discussing the nature of God. Surely a Physicist, said the + physicist, because early in the Creation, God made Light; and you + know, Maxwell's equations, the dual nature of electro-magnetic + waves, the relativist consequences... An Engineer!, said the + engineer, because before making Light, God split the Chaos into + Land and Water; it takes a hell of an engineer to handle that big + amount of mud, and orderly separation of solids from + liquids... The computer scientist shouted: And the Chaos, + where do you think it was coming from, hmm? + + ---Anonymous + + Autoconf is a tool for producing shell scripts that automatically +configure software source code packages to adapt to many kinds of +UNIX-like systems. The configuration scripts produced by Autoconf are +independent of Autoconf when they are run, so their users do not need to +have Autoconf. + + The configuration scripts produced by Autoconf require no manual user +intervention when run; they do not normally even need an argument +specifying the system type. Instead, they test for the presence of each +feature that the software package they are for might need individually. +(Before each check, they print a one-line message stating what they are +checking for, so the user doesn't get too bored while waiting for the +script to finish.) As a result, they deal well with systems that are +hybrids or customized from the more common UNIX variants. There is no +need to maintain files that list the features supported by each release +of each variant of UNIX. + + For each software package that Autoconf is used with, it creates a +configuration script from a template file that lists the system +features that the package needs or can use. After the shell code to +recognize and respond to a system feature has been written, Autoconf +allows it to be shared by many software packages that can use (or need) +that feature. If it later turns out that the shell code needs +adjustment for some reason, it needs to be changed in only one place; +all of the configuration scripts can be regenerated automatically to +take advantage of the updated code. + + The Metaconfig package is similar in purpose to Autoconf, but the +scripts it produces require manual user intervention, which is quite +inconvenient when configuring large source trees. Unlike Metaconfig +scripts, Autoconf scripts can support cross-compiling, if some care is +taken in writing them. + + There are several jobs related to making portable software packages +that Autoconf currently does not do. Among these are automatically +creating `Makefile' files with all of the standard targets, and +supplying replacements for standard library functions and header files +on systems that lack them. Work is in progress to add those features in +the future. + + Autoconf imposes some restrictions on the names of macros used with +`#ifdef' in C programs (*note Preprocessor Symbol Index::.). + + Autoconf requires GNU `m4' in order to generate the scripts. It +uses features that some UNIX versions of `m4' do not have. It also +overflows internal limits of some versions of `m4', including GNU `m4' +1.0. You must use version 1.1 or later of GNU `m4'. Using version 1.3 +or later will be much faster than 1.1 or 1.2. + + *Note Upgrading::, for information about upgrading from version 1. +*Note History::, for the story of Autoconf's development. *Note +Questions::, for answers to some common questions about Autoconf. + + Mail suggestions and bug reports for Autoconf to +`bug-gnu-utils@prep.ai.mit.edu'. Please include the Autoconf version +number, which you can get by running `autoconf --version'. + + +File: autoconf.info, Node: Making configure Scripts, Next: Setup, Prev: Introduction, Up: Top + +Making `configure' Scripts +************************** + + The configuration scripts that Autoconf produces are by convention +called `configure'. When run, `configure' creates several files, +replacing configuration parameters in them with appropriate values. +The files that `configure' creates are: + + * one or more `Makefile' files, one in each subdirectory of the + package (*note Makefile Substitutions::.); + + * optionally, a C header file, the name of which is configurable, + containing `#define' directives (*note Configuration Headers::.); + + * a shell script called `config.status' that, when run, will recreate + the files listed above (*note Invoking config.status::.); + + * a shell script called `config.cache' that saves the results of + running many of the tests (*note Cache Files::.); + + * a file called `config.log' containing any messages produced by + compilers, to help debugging if `configure' makes a mistake. + + To create a `configure' script with Autoconf, you need to write an +Autoconf input file `configure.in' and run `autoconf' on it. If you +write your own feature tests to supplement those that come with +Autoconf, you might also write files called `aclocal.m4' and +`acsite.m4'. If you use a C header file to contain `#define' +directives, you might also write `acconfig.h', and you will distribute +the Autoconf-generated file `config.h.in' with the package. + + Here is a diagram showing how the files that can be used in +configuration are produced. Programs that are executed are suffixed by +`*'. Optional files are enclosed in square brackets (`[]'). +`autoconf' and `autoheader' also read the installed Autoconf macro +files (by reading `autoconf.m4'). + +Files used in preparing a software package for distribution: + your source files --> [autoscan*] --> [configure.scan] --> configure.in + + configure.in --. .------> autoconf* -----> configure + +---+ + [aclocal.m4] --+ `---. + [acsite.m4] ---' | + +--> [autoheader*] -> [config.h.in] + [acconfig.h] ----. | + +-----' + [config.h.top] --+ + [config.h.bot] --' + + Makefile.in -------------------------------> Makefile.in + +Files used in configuring a software package: + .-------------> config.cache + configure* ------------+-------------> config.log + | + [config.h.in] -. v .-> [config.h] -. + +--> config.status* -+ +--> make* + Makefile.in ---' `-> Makefile ---' + +* Menu: + +* Writing configure.in:: What to put in an Autoconf input file. +* Invoking autoscan:: Semi-automatic `configure.in' writing. +* Invoking ifnames:: Listing the conditionals in source code. +* Invoking autoconf:: How to create configuration scripts. +* Invoking autoreconf:: Remaking multiple `configure' scripts. + + +File: autoconf.info, Node: Writing configure.in, Next: Invoking autoscan, Up: Making configure Scripts + +Writing `configure.in' +====================== + + To produce a `configure' script for a software package, create a +file called `configure.in' that contains invocations of the Autoconf +macros that test the system features your package needs or can use. +Autoconf macros already exist to check for many features; see *Note +Existing Tests::, for their descriptions. For most other features, you +can use Autoconf template macros to produce custom checks; see *Note +Writing Tests::, for information about them. For especially tricky or +specialized features, `configure.in' might need to contain some +hand-crafted shell commands. The `autoscan' program can give you a +good start in writing `configure.in' (*note Invoking autoscan::., for +more information). + + The order in which `configure.in' calls the Autoconf macros is not +important, with a few exceptions. Every `configure.in' must contain a +call to `AC_INIT' before the checks, and a call to `AC_OUTPUT' at the +end (*note Output::.). Additionally, some macros rely on other macros +having been called first, because they check previously set values of +some variables to decide what to do. These macros are noted in the +individual descriptions (*note Existing Tests::.), and they also warn +you when creating `configure' if they are called out of order. + + To encourage consistency, here is a suggested order for calling the +Autoconf macros. Generally speaking, the things near the end of this +list could depend on things earlier in it. For example, library +functions could be affected by typedefs and libraries. + + `AC_INIT(FILE)' + checks for programs + checks for libraries + checks for header files + checks for typedefs + checks for structures + checks for compiler characteristics + checks for library functions + checks for system services + `AC_OUTPUT([FILE...])' + + It is best to put each macro call on its own line in `configure.in'. +Most of the macros don't add extra newlines; they rely on the newline +after the macro call to terminate the commands. This approach makes +the generated `configure' script a little easier to read by not +inserting lots of blank lines. It is generally safe to set shell +variables on the same line as a macro call, because the shell allows +assignments without intervening newlines. + + When calling macros that take arguments, there must not be any blank +space between the macro name and the open parenthesis. Arguments can be +more than one line long if they are enclosed within the `m4' quote +characters `[' and `]'. If you have a long line such as a list of file +names, you can generally use a backslash at the end of a line to +continue it logically on the next line (this is implemented by the +shell, not by anything special that Autoconf does). + + Some macros handle two cases: what to do if the given condition is +met, and what to do if the condition is not met. In some places you +might want to do something if a condition is true but do nothing if it's +false, or vice versa. To omit the true case, pass an empty value for +the ACTION-IF-FOUND argument to the macro. To omit the false case, +omit the ACTION-IF-NOT-FOUND argument to the macro, including the comma +before it. + + You can include comments in `configure.in' files by starting them +with the `m4' builtin macro `dnl', which discards text up through the +next newline. These comments do not appear in the generated +`configure' scripts. For example, it is helpful to begin +`configure.in' files with a line like this: + + dnl Process this file with autoconf to produce a configure script. + + +File: autoconf.info, Node: Invoking autoscan, Next: Invoking ifnames, Prev: Writing configure.in, Up: Making configure Scripts + +Using `autoscan' to Create `configure.in' +========================================= + + The `autoscan' program can help you create a `configure.in' file for +a software package. `autoscan' examines source files in the directory +tree rooted at a directory given as a command line argument, or the +current directory if none is given. It searches the source files for +common portability problems and creates a file `configure.scan' which +is a preliminary `configure.in' for that package. + + You should manually examine `configure.scan' before renaming it to +`configure.in'; it will probably need some adjustments. Occasionally +`autoscan' outputs a macro in the wrong order relative to another +macro, so that `autoconf' produces a warning; you need to move such +macros manually. Also, if you want the package to use a configuration +header file, you must add a call to `AC_CONFIG_HEADER' (*note +Configuration Headers::.). You might also have to change or add some +`#if' directives to your program in order to make it work with Autoconf +(*note Invoking ifnames::., for information about a program that can +help with that job). + + `autoscan' uses several data files, which are installed along with +the distributed Autoconf macro files, to determine which macros to +output when it finds particular symbols in a package's source files. +These files all have the same format. Each line consists of a symbol, +whitespace, and the Autoconf macro to output if that symbol is +encountered. Lines starting with `#' are comments. + + `autoscan' is only installed if you already have Perl installed. +`autoscan' accepts the following options: + +`--help' + Print a summary of the command line options and exit. + +`--macrodir=DIR' + Look for the data files in directory DIR instead of the default + installation directory. You can also set the `AC_MACRODIR' + environment variable to a directory; this option overrides the + environment variable. + +`--verbose' + Print the names of the files it examines and the potentially + interesting symbols it finds in them. This output can be + voluminous. + +`--version' + Print the version number of Autoconf and exit. + + +File: autoconf.info, Node: Invoking ifnames, Next: Invoking autoconf, Prev: Invoking autoscan, Up: Making configure Scripts + +Using `ifnames' to List Conditionals +==================================== + + `ifnames' can help when writing a `configure.in' for a software +package. It prints the identifiers that the package already uses in C +preprocessor conditionals. If a package has already been set up to +have some portability, this program can help you figure out what its +`configure' needs to check for. It may help fill in some gaps in a +`configure.in' generated by `autoscan' (*note Invoking autoscan::.). + + `ifnames' scans all of the C source files named on the command line +(or the standard input, if none are given) and writes to the standard +output a sorted list of all the identifiers that appear in those files +in `#if', `#elif', `#ifdef', or `#ifndef' directives. It prints each +identifier on a line, followed by a space-separated list of the files +in which that identifier occurs. + +`ifnames' accepts the following options: + +`--help' +`-h' + Print a summary of the command line options and exit. + +`--macrodir=DIR' +`-m DIR' + Look for the Autoconf macro files in directory DIR instead of the + default installation directory. Only used to get the version + number. You can also set the `AC_MACRODIR' environment variable + to a directory; this option overrides the environment variable. + +`--version' + Print the version number of Autoconf and exit. + + +File: autoconf.info, Node: Invoking autoconf, Next: Invoking autoreconf, Prev: Invoking ifnames, Up: Making configure Scripts + +Using `autoconf' to Create `configure' +====================================== + + To create `configure' from `configure.in', run the `autoconf' +program with no arguments. `autoconf' processes `configure.in' with +the `m4' macro processor, using the Autoconf macros. If you give +`autoconf' an argument, it reads that file instead of `configure.in' +and writes the configuration script to the standard output instead of +to `configure'. If you give `autoconf' the argument `-', it reads the +standard input instead of `configure.in' and writes the configuration +script on the standard output. + + The Autoconf macros are defined in several files. Some of the files +are distributed with Autoconf; `autoconf' reads them first. Then it +looks for the optional file `acsite.m4' in the directory that contains +the distributed Autoconf macro files, and for the optional file +`aclocal.m4' in the current directory. Those files can contain your +site's or the package's own Autoconf macro definitions (*note Writing +Macros::., for more information). If a macro is defined in more than +one of the files that `autoconf' reads, the last definition it reads +overrides the earlier ones. + + `autoconf' accepts the following options: + +`--help' +`-h' + Print a summary of the command line options and exit. + +`--localdir=DIR' +`-l DIR' + Look for the package file `aclocal.m4' in directory DIR instead of + in the current directory. + +`--macrodir=DIR' +`-m DIR' + Look for the installed macro files in directory DIR. You can also + set the `AC_MACRODIR' environment variable to a directory; this + option overrides the environment variable. + +`--version' + Print the version number of Autoconf and exit. + + +File: autoconf.info, Node: Invoking autoreconf, Prev: Invoking autoconf, Up: Making configure Scripts + +Using `autoreconf' to Update `configure' Scripts +================================================ + + If you have a lot of Autoconf-generated `configure' scripts, the +`autoreconf' program can save you some work. It runs `autoconf' (and +`autoheader', where appropriate) repeatedly to remake the Autoconf +`configure' scripts and configuration header templates in the directory +tree rooted at the current directory. By default, it only remakes +those files that are older than their `configure.in' or (if present) +`aclocal.m4'. Since `autoheader' does not change the timestamp of its +output file if the file wouldn't be changing, this is not necessarily +the minimum amount of work. If you install a new version of Autoconf, +you can make `autoreconf' remake *all* of the files by giving it the +`--force' option. + + If you give `autoreconf' the `--macrodir=DIR' or `--localdir=DIR' +options, it passes them down to `autoconf' and `autoheader' (with +relative paths adjusted properly). + + *Note Automatic Remaking::, for `Makefile' rules to automatically +remake `configure' scripts when their source files change. That method +handles the timestamps of configuration header templates properly, but +does not pass `--macrodir=DIR' or `--localdir=DIR'. + +`autoreconf' accepts the following options: + +`--help' +`-h' + Print a summary of the command line options and exit. + +`--force' +`-f' + Remake even `configure' scripts and configuration headers that are + newer than their input files (`configure.in' and, if present, + `aclocal.m4'). + +`--localdir=DIR' +`-l DIR' + Look for the package files `aclocal.m4' and `acconfig.h' (but not + `FILE.top' and `FILE.bot') in directory DIR instead of in the + directory containing each `configure.in'. + +`--macrodir=DIR' +`-m DIR' + Look for the Autoconf macro files in directory DIR instead of the + default installation directory. You can also set the `AC_MACRODIR' + environment variable to a directory; this option overrides the + environment variable. + +`--verbose' + Print the name of each directory where `autoreconf' runs + `autoconf' (and `autoheader', if appropriate). + +`--version' + Print the version number of Autoconf and exit. + + +File: autoconf.info, Node: Setup, Next: Existing Tests, Prev: Making configure Scripts, Up: Top + +Initialization and Output Files +******************************* + + Autoconf-generated `configure' scripts need some information about +how to initialize, such as how to find the package's source files; and +about the output files to produce. The following sections describe +initialization and creating output files. + +* Menu: + +* Input:: Where Autoconf should find files. +* Output:: Creating output files. +* Makefile Substitutions:: Using output variables in `Makefile's. +* Configuration Headers:: Creating a configuration header file. +* Subdirectories:: Configuring independent packages together. +* Default Prefix:: Changing the default installation prefix. +* Versions:: Version numbers in `configure'. + + +File: autoconf.info, Node: Input, Next: Output, Up: Setup + +Finding `configure' Input +========================= + + Every `configure' script must call `AC_INIT' before doing anything +else. The only other required macro is `AC_OUTPUT' (*note Output::.). + + - Macro: AC_INIT (UNIQUE-FILE-IN-SOURCE-DIR) + Process any command-line arguments and find the source code + directory. UNIQUE-FILE-IN-SOURCE-DIR is some file that is in the + package's source directory; `configure' checks for this file's + existence to make sure that the directory that it is told contains + the source code in fact does (*note Invoking configure::., for + more information). + + Packages that do manual configuration or use the `install' program +might need to tell `configure' where to find some other shell scripts +by calling `AC_CONFIG_AUX_DIR', though the default places it looks are +correct for most cases. + + - Macro: AC_CONFIG_AUX_DIR(DIR) + Use the `install-sh', `config.sub', `config.guess', and Cygnus + `configure' scripts that are in directory DIR. These are + auxiliary files used in configuration. DIR can be either absolute + or relative to `SRCDIR'. The default is `SRCDIR' or `SRCDIR/..' or + `SRCDIR/../..', whichever is the first that contains `install-sh'. + The other files are not checked for, so that using + `AC_PROG_INSTALL' does not automatically require distributing the + other auxiliary files. It checks for `install.sh' also, but that + name is obsolete because some `make' programs have a rule that + creates `install' from it if there is no `Makefile'. + + +File: autoconf.info, Node: Output, Next: Makefile Substitutions, Prev: Input, Up: Setup + +Creating Output Files +===================== + + Every Autoconf-generated `configure' script must finish by calling +`AC_OUTPUT'. It is the macro that creates the `Makefile's and optional +other files resulting from configuration. The only other required +macro is `AC_INIT' (*note Input::.). + + - Macro: AC_OUTPUT ([FILE...] [,EXTRA-CMDS] [,INIT-CMDS]) + Create output files. The FILE... argument is a + whitespace-separated list of output files; it may be empty. This + macro creates each file `FILE' by copying an input file (by default + named `FILE.in'), substituting the output variable values. *Note + Makefile Substitutions::, for more information on using output + variables. *Note Setting Output Variables::, for more information + on creating them. This macro creates the directory that the file + is in if it doesn't exist (but not the parents of that directory). + Usually, `Makefile's are created this way, but other files, such + as `.gdbinit', can be specified as well. + + If `AC_CONFIG_HEADER', `AC_LINK_FILES', or `AC_CONFIG_SUBDIRS' has + been called, this macro also creates the files named as their + arguments. + + A typical call to `AC_OUTPUT' looks like this: + AC_OUTPUT(Makefile src/Makefile man/Makefile X/Imakefile) + + You can override an input file name by appending it to FILE, + separated by a colon. For example, + AC_OUTPUT(Makefile:templates/top.mk lib/Makefile:templates/lib.mk) + + If you pass EXTRA-CMDS, those commands will be inserted into + `config.status' to be run after all its other processing. If + INIT-CMDS are given, they are inserted just before EXTRA-CMDS, + with shell variable, command, and backslash substitutions + performed on them in `configure'. You can use INIT-CMDS to pass + variables from `configure' to the EXTRA-CMDS. + + If you run `make' on subdirectories, you should run it using the +`make' variable `MAKE'. Most versions of `make' set `MAKE' to the name +of the `make' program plus any options it was given. (But many do not +include in it the values of any variables set on the command line, so +those are not passed on automatically.) Some old versions of `make' do +not set this variable. The following macro allows you to use it even +with those versions. + + - Macro: AC_PROG_MAKE_SET + If `make' predefines the variable `MAKE', define output variable + `SET_MAKE' to be empty. Otherwise, define `SET_MAKE' to contain + `MAKE=make'. Calls `AC_SUBST' for `SET_MAKE'. + + To use this macro, place a line like this in each `Makefile.in' that +runs `MAKE' on other directories: + + @SET_MAKE@ + + +File: autoconf.info, Node: Makefile Substitutions, Next: Configuration Headers, Prev: Output, Up: Setup + +Substitutions in Makefiles +========================== + + Each subdirectory in a distribution that contains something to be +compiled or installed should come with a file `Makefile.in', from which +`configure' will create a `Makefile' in that directory. To create a +`Makefile', `configure' performs a simple variable substitution, +replacing occurrences of `@VARIABLE@' in `Makefile.in' with the value +that `configure' has determined for that variable. Variables that are +substituted into output files in this way are called "output +variables". They are ordinary shell variables that are set in +`configure'. To make `configure' substitute a particular variable into +the output files, the macro `AC_SUBST' must be called with that +variable name as an argument. Any occurrences of `@VARIABLE@' for +other variables are left unchanged. *Note Setting Output Variables::, +for more information on creating output variables with `AC_SUBST'. + + A software package that uses a `configure' script should be +distributed with a file `Makefile.in', but no `Makefile'; that way, the +user has to properly configure the package for the local system before +compiling it. + + *Note Makefile Conventions: (standards.info)Makefile Conventions, +for more information on what to put in `Makefile's. + +* Menu: + +* Preset Output Variables:: Output variables that are always set. +* Build Directories:: Compiling in a different directory. +* Automatic Remaking:: Makefile rules for configuring. + + +File: autoconf.info, Node: Preset Output Variables, Next: Build Directories, Up: Makefile Substitutions + +Preset Output Variables +----------------------- + + Some output variables are preset by the Autoconf macros. Some of the +Autoconf macros set additional output variables, which are mentioned in +the descriptions for those macros. *Note Output Variable Index::, for a +complete list of output variables. Here is what each of the preset ones +contains. + + - Variable: configure_input + A comment saying that the file was generated automatically by + `configure' and giving the name of the input file. `AC_OUTPUT' + adds a comment line containing this variable to the top of every + `Makefile' it creates. For other files, you should reference this + variable in a comment at the top of each input file. For example, + an input shell script should begin like this: + + #!/bin/sh + # @configure_input@ + + The presence of that line also reminds people editing the file + that it needs to be processed by `configure' in order to be used. + + - Variable: exec_prefix + The installation prefix for architecture-dependent files. + + - Variable: prefix + The installation prefix for architecture-independent files. + + - Variable: srcdir + The directory that contains the source code for that `Makefile'. + + - Variable: top_srcdir + The top-level source code directory for the package. In the + top-level directory, this is the same as `srcdir'. + + - Variable: CFLAGS + Debugging and optimization options for the C compiler. If it is + not set in the environment when `configure' runs, the default + value is set when you call `AC_PROG_CC' (or empty if you don't). + `configure' uses this variable when compiling programs to test for + C features. + + - Variable: CPPFLAGS + Header file search directory (`-IDIR') and any other miscellaneous + options for the C preprocessor and compiler. If it is not set in + the environment when `configure' runs, the default value is empty. + `configure' uses this variable when compiling or preprocessing + programs to test for C features. + + - Variable: CXXFLAGS + Debugging and optimization options for the C++ compiler. If it is + not set in the environment when `configure' runs, the default + value is set when you call `AC_PROG_CXX' (or empty if you don't). + `configure' uses this variable when compiling programs to test for + C++ features. + + - Variable: DEFS + `-D' options to pass to the C compiler. If `AC_CONFIG_HEADER' is + called, `configure' replaces `@DEFS@' with `-DHAVE_CONFIG_H' + instead (*note Configuration Headers::.). This variable is not + defined while `configure' is performing its tests, only when + creating the output files. *Note Setting Output Variables::, for + how to check the results of previous tests. + + - Variable: LDFLAGS + Stripping (`-s') and any other miscellaneous options for the + linker. If it is not set in the environment when `configure' runs, + the default value is empty. `configure' uses this variable when + linking programs to test for C features. + + - Variable: LIBS + `-l' and `-L' options to pass to the linker. + + +File: autoconf.info, Node: Build Directories, Next: Automatic Remaking, Prev: Preset Output Variables, Up: Makefile Substitutions + +Build Directories +----------------- + + You might want to compile a software package in a different directory +from the one that contains the source code. Doing this allows you to +compile the package for several architectures simultaneously from the +same copy of the source code and keep multiple sets of object files on +disk. + + To support doing this, `make' uses the `VPATH' variable to find the +files that are in the source directory. GNU `make' and most other +recent `make' programs can do this. Older `make' programs do not +support `VPATH'; when using them, the source code must be in the same +directory as the object files. + + To support `VPATH', each `Makefile.in' should contain two lines that +look like: + + srcdir = @srcdir@ + VPATH = @srcdir@ + + Do not set `VPATH' to the value of another variable, for example +`VPATH = $(srcdir)', because some versions of `make' do not do variable +substitutions on the value of `VPATH'. + + `configure' substitutes in the correct value for `srcdir' when it +produces `Makefile.in'. + + Do not use the `make' variable `$<', which expands to the pathname +of the file in the source directory (found with `VPATH'), except in +implicit rules. (An implicit rule is one such as `.c.o', which tells +how to create a `.o' file from a `.c' file.) Some versions of `make' +do not set `$<' in explicit rules; they expand it to an empty value. + + Instead, `Makefile' command lines should always refer to source +files by prefixing them with `$(srcdir)/'. For example: + + time.info: time.texinfo + $(MAKEINFO) $(srcdir)/time.texinfo + + +File: autoconf.info, Node: Automatic Remaking, Prev: Build Directories, Up: Makefile Substitutions + +Automatic Remaking +------------------ + + You can put rules like the following in the top-level `Makefile.in' +for a package to automatically update the configuration information when +you change the configuration files. This example includes all of the +optional files, such as `aclocal.m4' and those related to configuration +header files. Omit from the `Makefile.in' rules any of these files +that your package does not use. + + The `${srcdir}/' prefix is included because of limitations in the +`VPATH' mechanism. + + The `stamp-' files are necessary because the timestamps of +`config.h.in' and `config.h' will not be changed if remaking them does +not change their contents. This feature avoids unnecessary +recompilation. You should include the file `stamp-h.in' your package's +distribution, so `make' will consider `config.h.in' up to date. On +some old BSD systems, `touch' or any command that results in an empty +file does not update the timestamps, so use a command like `date' as a +workaround. + + ${srcdir}/configure: configure.in aclocal.m4 + cd ${srcdir} && autoconf + + # autoheader might not change config.h.in, so touch a stamp file. + ${srcdir}/config.h.in: stamp-h.in + ${srcdir}/stamp-h.in: configure.in aclocal.m4 acconfig.h \ + config.h.top config.h.bot + cd ${srcdir} && autoheader + date > ${srcdir}/stamp-h.in + + config.h: stamp-h + stamp-h: config.h.in config.status + ./config.status + + Makefile: Makefile.in config.status + ./config.status + + config.status: configure + ./config.status --recheck + + In addition, you should pass `date > stamp-h' in the EXTRA-CMDS +argument to `AC_OUTPUT', so `config.status' will ensure that `config.h' +is considered up to date. *Note Output::, for more information about +`AC_OUTPUT'. + + *Note Invoking config.status::, for more examples of handling +configuration-related dependencies. + + +File: autoconf.info, Node: Configuration Headers, Next: Subdirectories, Prev: Makefile Substitutions, Up: Setup + +Configuration Header Files +========================== + + When a package tests more than a few C preprocessor symbols, the +command lines to pass `-D' options to the compiler can get quite long. +This causes two problems. One is that the `make' output is hard to +visually scan for errors. More seriously, the command lines can exceed +the length limits of some operating systems. As an alternative to +passing `-D' options to the compiler, `configure' scripts can create a +C header file containing `#define' directives. The `AC_CONFIG_HEADER' +macro selects this kind of output. It should be called right after +`AC_INIT'. + + The package should `#include' the configuration header file before +any other header files, to prevent inconsistencies in declarations (for +example, if it redefines `const'). Use `#include <config.h>' instead +of `#include "config.h"', and pass the C compiler a `-I.' option (or +`-I..'; whichever directory contains `config.h'). That way, even if +the source directory is configured itself (perhaps to make a +distribution), other build directories can also be configured without +finding the `config.h' from the source directory. + + - Macro: AC_CONFIG_HEADER (HEADER-TO-CREATE ...) + Make `AC_OUTPUT' create the file(s) in the whitespace-separated + list HEADER-TO-CREATE containing C preprocessor `#define' + statements, and replace `@DEFS@' in generated files with + `-DHAVE_CONFIG_H' instead of the value of `DEFS'. The usual name + for HEADER-TO-CREATE is `config.h'. + + If HEADER-TO-CREATE already exists and its contents are identical + to what `AC_OUTPUT' would put in it, it is left alone. Doing this + allows some changes in configuration without needlessly causing + object files that depend on the header file to be recompiled. + + Usually the input file is named `HEADER-TO-CREATE.in'; however, + you can override the input file name by appending it to + HEADER-TO-CREATE, separated by a colon. For example, + AC_CONFIG_HEADER(defines.h:defines.hin) + + Doing this allows you to keep your filenames acceptable to MS-DOS. + +* Menu: + +* Header Templates:: Input for the configuration headers. +* Invoking autoheader:: How to create configuration templates. + + +File: autoconf.info, Node: Header Templates, Next: Invoking autoheader, Up: Configuration Headers + +Configuration Header Templates +------------------------------ + + Your distribution should contain a template file that looks as you +want the final header file to look, including comments, with default +values in the `#define' statements. For example, suppose your +`configure.in' makes these calls: + + AC_CONFIG_HEADER(conf.h) + AC_CHECK_HEADERS(unistd.h) + +Then you could have code like the following in `conf.h.in'. On systems +that have `unistd.h', `configure' will change the 0 to a 1. On other +systems, it will leave the line unchanged. + + /* Define as 1 if you have unistd.h. */ + #define HAVE_UNISTD_H 0 + + Alternately, if your code tests for configuration options using +`#ifdef' instead of `#if', a default value can be to `#undef' the +variable instead of to define it to a value. On systems that have +`unistd.h', `configure' will change the second line to read `#define +HAVE_UNISTD_H 1'. On other systems, it will comment that line out (in +case the system predefines that symbol). + + /* Define if you have unistd.h. */ + #undef HAVE_UNISTD_H + + +File: autoconf.info, Node: Invoking autoheader, Prev: Header Templates, Up: Configuration Headers + +Using `autoheader' to Create `config.h.in' +------------------------------------------ + + The `autoheader' program can create a template file of C `#define' +statements for `configure' to use. If `configure.in' invokes +`AC_CONFIG_HEADER(FILE)', `autoheader' creates `FILE.in'. Otherwise, +`autoheader' creates `config.h.in'. + + If you give `autoheader' an argument, it uses that file instead of +`configure.in' and writes the header file to the standard output +instead of to `config.h.in'. If you give `autoheader' an argument of +`-', it reads the standard input instead of `configure.in' and writes +the header file to the standard output. + + `autoheader' scans `configure.in' and figures out which C +preprocessor symbols it might define. It copies comments and `#define' +and `#undef' statements from a file called `acconfig.h', which comes +with and is installed with Autoconf. It also uses a file called +`acconfig.h' in the current directory, if present. If you `AC_DEFINE' +any additional symbols, you must create that file with entries for +them. For symbols defined by `AC_CHECK_HEADERS', `AC_CHECK_FUNCS', +`AC_CHECK_SIZEOF', or `AC_CHECK_LIB', `autoheader' generates comments +and `#undef' statements itself rather than copying them from a file, +since the possible symbols are effectively limitless. + + The file that `autoheader' creates contains mainly `#define' and +`#undef' statements and their accompanying comments. If `./acconfig.h' +contains the string `@TOP@', `autoheader' copies the lines before the +line containing `@TOP@' into the top of the file that it generates. +Similarly, if `./acconfig.h' contains the string `@BOTTOM@', +`autoheader' copies the lines after that line to the end of the file it +generates. Either or both of those strings may be omitted. + + An alternate way to produce the same effect is to create the files +`FILE.top' (typically `config.h.top') and/or `FILE.bot' in the current +directory. If they exist, `autoheader' copies them to the beginning +and end, respectively, of its output. Their use is discouraged because +they have file names that contain two periods, and so can not be stored +on MS-DOS; also, they are two more files to clutter up the directory. +But if you use the `--localdir=DIR' option to use an `acconfig.h' in +another directory, they give you a way to put custom boilerplate in each +individual `config.h.in'. + + `autoheader' accepts the following options: + +`--help' +`-h' + Print a summary of the command line options and exit. + +`--localdir=DIR' +`-l DIR' + Look for the package files `aclocal.m4' and `acconfig.h' (but not + `FILE.top' and `FILE.bot') in directory DIR instead of in the + current directory. + +`--macrodir=DIR' +`-m DIR' + Look for the installed macro files and `acconfig.h' in directory + DIR. You can also set the `AC_MACRODIR' environment variable to a + directory; this option overrides the environment variable. + +`--version' + Print the version number of Autoconf and exit. + + +File: autoconf.info, Node: Subdirectories, Next: Default Prefix, Prev: Configuration Headers, Up: Setup + +Configuring Other Packages in Subdirectories +============================================ + + In most situations, calling `AC_OUTPUT' is sufficient to produce +`Makefile's in subdirectories. However, `configure' scripts that +control more than one independent package can use `AC_CONFIG_SUBDIRS' +to run `configure' scripts for other packages in subdirectories. + + - Macro: AC_CONFIG_SUBDIRS (DIR ...) + Make `AC_OUTPUT' run `configure' in each subdirectory DIR in the + given whitespace-separated list. If a given DIR is not found, no + error is reported, so a `configure' script can configure whichever + parts of a large source tree are present. If a given DIR contains + `configure.in' but no `configure', the Cygnus `configure' script + found by `AC_CONFIG_AUXDIR' is used. The subdirectory `configure' + scripts are given the same command line options that were given to + this `configure' script, with minor changes if needed (e.g., to + adjust a relative path for the cache file or source directory). + This macro also sets the output variable `subdirs' to the list of + directories `DIR ...'. `Makefile' rules can use this variable to + determine which subdirectories to recurse into. + + +File: autoconf.info, Node: Default Prefix, Next: Versions, Prev: Subdirectories, Up: Setup + +Default Prefix +============== + + By default, `configure' sets the prefix for files it installs to +`/usr/local'. The user of `configure' can select a different prefix +using the `--prefix' and `--exec-prefix' options. There are two ways +to change the default: when creating `configure', and when running it. + + Some software packages might want to install in a directory besides +`/usr/local' by default. To accomplish that, use the +`AC_PREFIX_DEFAULT' macro. + + - Macro: AC_PREFIX_DEFAULT (PREFIX) + Set the default installation prefix to PREFIX instead of + `/usr/local'. + + It may be convenient for users to have `configure' guess the +installation prefix from the location of a related program that they +have already installed. If you wish to do that, you can call +`AC_PREFIX_PROGRAM'. + + - Macro: AC_PREFIX_PROGRAM (PROGRAM) + If the user did not specify an installation prefix (using the + `--prefix' option), guess a value for it by looking for PROGRAM in + `PATH', the way the shell does. If PROGRAM is found, set the + prefix to the parent of the directory containing PROGRAM; + otherwise leave the prefix specified in `Makefile.in' unchanged. + For example, if PROGRAM is `gcc' and the `PATH' contains + `/usr/local/gnu/bin/gcc', set the prefix to `/usr/local/gnu'. + diff --git a/util/autoconf/autoconf.info-2 b/util/autoconf/autoconf.info-2 new file mode 100644 index 0000000..ae8fc7b --- /dev/null +++ b/util/autoconf/autoconf.info-2 @@ -0,0 +1,1214 @@ +This is Info file autoconf.info, produced by Makeinfo-1.55 from the +input file ./autoconf.texi. + +START-INFO-DIR-ENTRY +* Autoconf: (autoconf). Create source code configuration scripts. +END-INFO-DIR-ENTRY + + This file documents the GNU Autoconf package for creating scripts to +configure source code packages using templates and an `m4' macro +package. + + Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. + + Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, provided that +the entire resulting derived work is distributed under the terms of a +permission notice identical to this one. + + Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions, except that this permission notice may be stated in a +translation approved by the Foundation. + + +File: autoconf.info, Node: Versions, Prev: Default Prefix, Up: Setup + +Version Numbers in `configure' +============================== + + The following macros manage version numbers for `configure' scripts. +Using them is optional. + + - Macro: AC_PREREQ (VERSION) + Ensure that a recent enough version of Autoconf is being used. If + the version of Autoconf being used to create `configure' is earlier + than VERSION, print an error message on the standard error output + and do not create `configure'. For example: + + AC_PREREQ(1.8) + + This macro is useful if your `configure.in' relies on non-obvious + behavior that changed between Autoconf releases. If it merely + needs recently added macros, then `AC_PREREQ' is less useful, + because the `autoconf' program already tells the user which macros + are not found. The same thing happens if `configure.in' is + processed by a version of Autoconf older than when `AC_PREREQ' was + added. + + - Macro: AC_REVISION (REVISION-INFO) + Copy revision stamp REVISION-INFO into the `configure' script, + with any dollar signs or double-quotes removed. This macro lets + you put a revision stamp from `configure.in' into `configure' + without RCS or CVS changing it when you check in `configure'. That + way, you can determine easily which revision of `configure.in' a + particular `configure' corresponds to. + + It is a good idea to call this macro before `AC_INIT' so that the + revision number is near the top of both `configure.in' and + `configure'. To support doing that, the `AC_REVISION' output + begins with `#!/bin/sh', like the normal start of a `configure' + script does. + + For example, this line in `configure.in': + + AC_REVISION($Revision$)dnl + + produces this in `configure': + + #!/bin/sh + # From configure.in Revision: 1.30 + + +File: autoconf.info, Node: Existing Tests, Next: Writing Tests, Prev: Setup, Up: Top + +Existing Tests +************** + + These macros test for particular system features that packages might +need or want to use. If you need to test for a kind of feature that +none of these macros check for, you can probably do it by calling +primitive test macros with appropriate arguments (*note Writing +Tests::.). + + These tests print messages telling the user which feature they're +checking for, and what they find. They cache their results for future +`configure' runs (*note Caching Results::.). + + Some of these macros set output variables. *Note Makefile +Substitutions::, for how to get their values. The phrase "define NAME" +is used below as a shorthand to mean "define C preprocessor symbol NAME +to the value 1". *Note Defining Symbols::, for how to get those symbol +definitions into your program. + +* Menu: + +* Alternative Programs:: Selecting between alternative programs. +* Libraries:: Library archives that might be missing. +* Library Functions:: C library functions that might be missing. +* Header Files:: Header files that might be missing. +* Structures:: Structures or members that might be missing. +* Typedefs:: `typedef's that might be missing. +* Compiler Characteristics:: C compiler or machine architecture features. +* System Services:: Operating system services. +* UNIX Variants:: Special kludges for specific UNIX variants. + + +File: autoconf.info, Node: Alternative Programs, Next: Libraries, Up: Existing Tests + +Alternative Programs +==================== + + These macros check for the presence or behavior of particular +programs. They are used to choose between several alternative programs +and to decide what to do once one has been chosen. If there is no +macro specifically defined to check for a program you need, and you +don't need to check for any special properties of it, then you can use +one of the general program check macros. + +* Menu: + +* Particular Programs:: Special handling to find certain programs. +* Generic Programs:: How to find other programs. + + +File: autoconf.info, Node: Particular Programs, Next: Generic Programs, Up: Alternative Programs + +Particular Program Checks +------------------------- + + These macros check for particular programs--whether they exist, and +in some cases whether they support certain features. + + - Macro: AC_DECL_YYTEXT + Define `YYTEXT_POINTER' if `yytext' is a `char *' instead of a + `char []'. Also set output variable `LEX_OUTPUT_ROOT' to the base + of the file name that the lexer generates; usually `lex.yy', but + sometimes something else. These results vary according to whether + `lex' or `flex' is being used. + + - Macro: AC_PROG_AWK + Check for `mawk', `gawk', `nawk', and `awk', in that order, and + set output variable `AWK' to the first one that it finds. It + tries `mawk' first because that is reported to be the fastest + implementation. + + - Macro: AC_PROG_CC + Determine a C compiler to use. If `CC' is not already set in the + environment, check for `gcc', and use `cc' if it's not found. Set + output variable `CC' to the name of the compiler found. + + If using the GNU C compiler, set shell variable `GCC' to `yes', + empty otherwise. If output variable `CFLAGS' was not already set, + set it to `-g -O' for the GNU C compiler (`-O' on systems where + GCC does not accept `-g'), or `-g' for other compilers. + + - Macro: AC_PROG_CC_C_O + If the C compiler does not accept the `-c' and `-o' options + simultaneously, define `NO_MINUS_C_MINUS_O'. + + - Macro: AC_PROG_CPP + Set output variable `CPP' to a command that runs the C + preprocessor. If `$CC -E' doesn't work, it uses `/lib/cpp'. It + is only portable to run `CPP' on files with a `.c' extension. + + If the current language is C (*note Language Choice::.), many of + the specific test macros use the value of `CPP' indirectly by + calling `AC_TRY_CPP', `AC_CHECK_HEADER', `AC_EGREP_HEADER', or + `AC_EGREP_CPP'. + + - Macro: AC_PROG_CXX + Determine a C++ compiler to use. Check if the environment variable + `CXX' or `CCC' (in that order) is set; if so, set output variable + `CXX' to its value. Otherwise search for a C++ compiler under + likely names (`c++', `g++', `gcc', `CC', and `cxx'). If none of + those checks succeed, as a last resort set `CXX' to `gcc'. + + If using the GNU C++ compiler, set shell variable `GXX' to `yes', + empty otherwise. If output variable `CXXFLAGS' was not already + set, set it to `-g -O' for the GNU C++ compiler (`-O' on systems + where G++ does not accept `-g'), or `-g' for other compilers. + + - Macro: AC_PROG_CXXCPP + Set output variable `CXXCPP' to a command that runs the C++ + preprocessor. If `$CXX -E' doesn't work, it uses `/lib/cpp'. It + is only portable to run `CXXCPP' on files with a `.c', `.C', or + `.cc' extension. + + If the current language is C++ (*note Language Choice::.), many of + the specific test macros use the value of `CXXCPP' indirectly by + calling `AC_TRY_CPP', `AC_CHECK_HEADER', `AC_EGREP_HEADER', or + `AC_EGREP_CPP'. + + - Macro: AC_PROG_GCC_TRADITIONAL + Add `-traditional' to output variable `CC' if using the GNU C + compiler and `ioctl' does not work properly without + `-traditional'. That usually happens when the fixed header files + have not been installed on an old system. Since recent versions + of the GNU C compiler fix the header files automatically when + installed, this is becoming a less prevalent problem. + + - Macro: AC_PROG_INSTALL + Set output variable `INSTALL' to the path of a BSD compatible + `install' program, if one is found in the current `PATH'. + Otherwise, set `INSTALL' to `DIR/install-sh -c', checking the + directories specified to `AC_CONFIG_AUX_DIR' (or its default + directories) to determine DIR (*note Output::.). Also set the + variable `INSTALL_PROGRAM' to `${INSTALL}' and `INSTALL_DATA' to + `${INSTALL} -m 644'. + + This macro screens out various instances of `install' known to not + work. It prefers to find a C program rather than a shell script, + for speed. Instead of `install-sh', it can also use `install.sh', + but that name is obsolete because some `make' programs have a rule + that creates `install' from it if there is no `Makefile'. + + A copy of `install-sh' which you may use comes with Autoconf. If + you use `AC_PROG_INSTALL', you must include either `install-sh' or + `install.sh' in your distribution, or `configure' will produce an + error message saying it can't find them--even if the system you're + on has a good `install' program. This check is a safety measure + to prevent you from accidentally leaving that file out, which + would prevent your package from installing on systems that don't + have a BSD-compatible `install' program. + + If you need to use your own installation program because it has + features not found in standard `install' programs, there is no + reason to use `AC_PROG_INSTALL'; just put the pathname of your + program into your `Makefile.in' files. + + - Macro: AC_PROG_LEX + If `flex' is found, set output variable `LEX' to `flex' and + `LEXLIB' to `-lfl', if that library is in a standard place. + Otherwise set `LEX' to `lex' and `LEXLIB' to `-ll'. + + - Macro: AC_PROG_LN_S + If `ln -s' works on the current filesystem (the operating system + and filesystem support symbolic links), set output variable `LN_S' + to `ln -s', otherwise set it to `ln'. + + - Macro: AC_PROG_RANLIB + Set output variable `RANLIB' to `ranlib' if `ranlib' is found, + otherwise to `:' (do nothing). + + - Macro: AC_PROG_YACC + If `bison' is found, set output variable `YACC' to `bison -y'. + Otherwise, if `byacc' is found, set `YACC' to `byacc'. Otherwise + set `YACC' to `yacc'. + + +File: autoconf.info, Node: Generic Programs, Prev: Particular Programs, Up: Alternative Programs + +Generic Program Checks +---------------------- + + These macros are used to find programs not covered by the particular +test macros. If you need to check the behavior of a program as well as +find out whether it is present, you have to write your own test for it +(*note Writing Tests::.). + + - Macro: AC_CHECK_PROG (VARIABLE, PROG-TO-CHECK-FOR, VALUE-IF-FOUND [, + VALUE-IF-NOT-FOUND]) + Check whether program PROG-TO-CHECK-FOR exists in `PATH'. If it + is found, set VARIABLE to VALUE-IF-FOUND, otherwise to + VALUE-IF-NOT-FOUND, if given. If VARIABLE was already set, do + nothing. Calls `AC_SUBST' for VARIABLE. + + - Macro: AC_CHECK_PROGS (VARIABLE, PROGS-TO-CHECK-FOR [, + VALUE-IF-NOT-FOUND]) + Check for each program in the whitespace-separated list + PROGS-TO-CHECK-FOR exists in `PATH'. If it is found, set VARIABLE + to the name of that program. Otherwise, continue checking the + next program in the list. If none of the programs in the list are + found, set VARIABLE to VALUE-IF-NOT-FOUND; if VALUE-IF-NOT-FOUND + is not specified, the value of VARIABLE is not changed. Calls + `AC_SUBST' for VARIABLE. + + - Macro: AC_PATH_PROG (VARIABLE, PROG-TO-CHECK-FOR [, + VALUE-IF-NOT-FOUND]) + Like `AC_CHECK_PROG', but set VARIABLE to the entire path of + PROG-TO-CHECK-FOR if found. + + - Macro: AC_PATH_PROGS (VARIABLE, PROGS-TO-CHECK-FOR [, + VALUE-IF-NOT-FOUND]) + Like `AC_CHECK_PROGS', but if any of PROGS-TO-CHECK-FOR are found, + set VARIABLE to the entire path of the program found. + + +File: autoconf.info, Node: Libraries, Next: Library Functions, Prev: Alternative Programs, Up: Existing Tests + +Library Files +============= + + The following macros check for the presence of certain C library +archive files. + + - Macro: AC_CHECK_LIB (LIBRARY, FUNCTION [, ACTION-IF-FOUND [, + ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]]) + Try to ensure that C function FUNCTION is available by checking + whether a test C program can be linked with the library LIBRARY to + get the function. LIBRARY is the base name of the library; e.g., + to check for `-lmp', use `mp' as the LIBRARY argument. + + ACTION-IF-FOUND is a list of shell commands to run if the link + with the library succeeds; ACTION-IF-NOT-FOUND is a list of shell + commands to run if the link fails. If ACTION-IF-FOUND and + ACTION-IF-NOT-FOUND are not specified, the default action is to + add `-lLIBRARY' to `LIBS' and define `HAVE_LIBLIBRARY' (in all + capitals). + + If linking with LIBRARY results in unresolved symbols, which would + be resolved by linking with additional libraries, give those + libraries as the OTHER-LIBRARIES argument, separated by spaces: + `-lX11 -lXt'. Otherwise this macro will fail to detect that + LIBRARY is present, because linking the test program will always + fail with unresolved symbols. + + - Macro: AC_HAVE_LIBRARY (LIBRARY, [, ACTION-IF-FOUND [, + ACTION-IF-NOT-FOUND [, OTHER-LIBRARIES]]]) + This macro is equivalent to calling `AC_CHECK_LIB' with a FUNCTION + argument of `main'. In addition, LIBRARY can be written as any of + `foo', `-lfoo', or `libfoo.a'. In all of those cases, the + compiler is passed `-lfoo'. However, LIBRARY can not be a shell + variable; it must be a literal name. This macro is considered + obsolete. + + +File: autoconf.info, Node: Library Functions, Next: Header Files, Prev: Libraries, Up: Existing Tests + +Library Functions +================= + + The following macros check for particular C library functions. If +there is no macro specifically defined to check for a function you need, +and you don't need to check for any special properties of it, then you +can use one of the general function check macros. + +* Menu: + +* Particular Functions:: Special handling to find certain functions. +* Generic Functions:: How to find other functions. + + +File: autoconf.info, Node: Particular Functions, Next: Generic Functions, Up: Library Functions + +Particular Function Checks +-------------------------- + + These macros check for particular C functions--whether they exist, +and in some cases how they respond when given certain arguments. + + - Macro: AC_FUNC_ALLOCA + Check how to get `alloca'. Tries to get a builtin version by + checking for `alloca.h' or the predefined C preprocessor macros + `__GNUC__' and `_AIX'. If this macro finds `alloca.h', it defines + `HAVE_ALLOCA_H'. + + If those attempts fail, it looks for the function in the standard C + library. If any of those methods succeed, it defines + `HAVE_ALLOCA'. Otherwise, it sets the output variable `ALLOCA' to + `alloca.o' and defines `C_ALLOCA' (so programs can periodically + call `alloca(0)' to garbage collect). This variable is separate + from `LIBOBJS' so multiple programs can share the value of + `ALLOCA' without needing to create an actual library, in case only + some of them use the code in `LIBOBJS'. + + This macro does not try to get `alloca' from the System V R3 + `libPW' or the System V R4 `libucb' because those libraries + contain some incompatible functions that cause trouble. Some + versions do not even contain `alloca' or contain a buggy version. + If you still want to use their `alloca', use `ar' to extract + `alloca.o' from them instead of compiling `alloca.c'. + + Source files that use `alloca' should start with a piece of code + like the following, to declare it properly. In some versions of + AIX, the declaration of `alloca' must precede everything else + except for comments and preprocessor directives. The `#pragma' + directive is indented so that pre-ANSI C compilers will ignore it, + rather than choke on it. + + /* AIX requires this to be the first thing in the file. */ + #ifdef __GNUC__ + # define alloca __builtin_alloca + #else + # if HAVE_ALLOCA_H + # include <alloca.h> + # else + # ifdef _AIX + #pragma alloca + # else + # ifndef alloca /* predefined by HP cc +Olibcalls */ + char *alloca (); + # endif + # endif + # endif + #endif + + - Macro: AC_FUNC_CLOSEDIR_VOID + If the `closedir' function does not return a meaningful value, + define `CLOSEDIR_VOID'. Otherwise, callers ought to check its + return value for an error indicator. + + - Macro: AC_FUNC_GETLOADAVG + Check how to get the system load averages. If the system has the + `getloadavg' function, this macro defines `HAVE_GETLOADAVG', and + adds to `LIBS' any libraries needed to get that function. + + Otherwise, it adds `getloadavg.o' to the output variable + `LIBOBJS', and possibly defines several other C preprocessor + macros and output variables: + + 1. It defines `SVR4', `DGUX', `UMAX', or `UMAX4_3' if on those + systems. + + 2. If it finds `nlist.h', it defines `NLIST_STRUCT'. + + 3. If `struct nlist' has an `n_un' member, it defines + `NLIST_NAME_UNION'. + + 4. If compiling `getloadavg.c' defines `LDAV_PRIVILEGED', + programs need to be installed specially on this system for + `getloadavg' to work, and this macro defines + `GETLOADAVG_PRIVILEGED'. + + 5. This macro sets the output variable `NEED_SETGID'. The value + is `true' if special installation is required, `false' if not. + If `NEED_SETGID' is `true', this macro sets `KMEM_GROUP' to + the name of the group that should own the installed program. + + - Macro: AC_FUNC_GETMNTENT + Check for the `getmntent' in the `sun' and `seq' libraries, for + Irix 4 and PTX, respectively. Then, if `getmntent' is available, + define `HAVE_GETMNTENT'. + + - Macro: AC_FUNC_MEMCMP + If the `memcmp' function is not available, or does not work on + 8-bit data (like the one on SunOS 4.1.3), add `memcmp.o' to output + variable `LIBOBJS'. + + - Macro: AC_FUNC_MMAP + If the `mmap' function exists and works correctly on memory mapped + files, define `HAVE_MMAP'. + + - Macro: AC_FUNC_SETVBUF_REVERSED + If `setvbuf' takes the buffering type as its second argument and + the buffer pointer as the third, instead of the other way around, + define `SETVBUF_REVERSED'. This is the case on System V before + release 3. + + - Macro: AC_FUNC_STRCOLL + If the `strcoll' function exists and works correctly, define + `HAVE_STRCOLL'. This does a bit more than + `AC_CHECK_FUNCS(strcoll)', because some systems have incorrect + definitions of `strcoll', which should not be used. + + - Macro: AC_FUNC_STRFTIME + Check for `strftime' in the `intl' library, for SCO UNIX. Then, + if `strftime' is available, define `HAVE_STRFTIME'. + + - Macro: AC_FUNC_UTIME_NULL + If `utime(FILE, NULL)' sets FILE's timestamp to the present, + define `HAVE_UTIME_NULL'. + + - Macro: AC_FUNC_VFORK + If `vfork.h' is found, define `HAVE_VFORK_H'. If a working + `vfork' is not found, define `vfork' to be `fork'. This macro + checks for several known errors in implementations of `vfork' and + considers the system to not have a working `vfork' if it detects + any of them. + + - Macro: AC_FUNC_VPRINTF + If `vprintf' is found, define `HAVE_VPRINTF'. Otherwise, if + `_doprnt' is found, define `HAVE_DOPRNT'. (If `vprintf' is + available, you may assume that `vfprintf' and `vsprintf' are also + available.) + + - Macro: AC_FUNC_WAIT3 + If `wait3' is found and fills in the contents of its third argument + (a `struct rusage *'), which HP-UX does not do, define + `HAVE_WAIT3'. + + +File: autoconf.info, Node: Generic Functions, Prev: Particular Functions, Up: Library Functions + +Generic Function Checks +----------------------- + + These macros are used to find functions not covered by the particular +test macros. If the functions might be in libraries other than the +default C library, first call `AC_CHECK_LIB' for those libraries. If +you need to check the behavior of a function as well as find out +whether it is present, you have to write your own test for it (*note +Writing Tests::.). + + - Macro: AC_CHECK_FUNC (FUNCTION, ACTION-IF-FOUND [, + ACTION-IF-NOT-FOUND]) + If C function FUNCTION is available, run shell commands + ACTION-IF-FOUND, otherwise ACTION-IF-NOT-FOUND. If you just want + to define a symbol if the function is available, consider using + `AC_CHECK_FUNCS' instead. This macro checks for functions with C + linkage even when `AC_LANG_CPLUSPLUS' has been called, since C++ is + more standardized than C is. (*note Language Choice::., for more + information about selecting the language for checks.) + + - Macro: AC_CHECK_FUNCS (FUNCTION... [, ACTION-IF-FOUND [, + ACTION-IF-NOT-FOUND]]) + For each given FUNCTION in the whitespace-separated argument list + that is available, define `HAVE_FUNCTION' (in all capitals). If + ACTION-IF-FOUND is given, it is additional shell code to execute + when one of the functions is found. You can give it a value of + `break' to break out of the loop on the first match. If + ACTION-IF-NOT-FOUND is given, it is executed when one of the + functions is not found. + + - Macro: AC_REPLACE_FUNCS (FUNCTION-NAME...) + For each given FUNCTION-NAME in the whitespace-separated argument + list that is not in the C library, add `FUNCTION-NAME.o' to the + value of the output variable `LIBOBJS'. + + +File: autoconf.info, Node: Header Files, Next: Structures, Prev: Library Functions, Up: Existing Tests + +Header Files +============ + + The following macros check for the presence of certain C header +files. If there is no macro specifically defined to check for a header +file you need, and you don't need to check for any special properties of +it, then you can use one of the general header file check macros. + +* Menu: + +* Particular Headers:: Special handling to find certain headers. +* Generic Headers:: How to find other headers. + + +File: autoconf.info, Node: Particular Headers, Next: Generic Headers, Up: Header Files + +Particular Header Checks +------------------------ + + These macros check for particular system header files--whether they +exist, and in some cases whether they declare certain symbols. + + - Macro: AC_DECL_SYS_SIGLIST + Define `SYS_SIGLIST_DECLARED' if the variable `sys_siglist' is + declared in a system header file, either `signal.h' or `unistd.h'. + + - Macro: AC_DIR_HEADER + Like calling `AC_HEADER_DIRENT' and `AC_FUNC_CLOSEDIR_VOID', but + defines a different set of C preprocessor macros to indicate which + header file is found. This macro and the names it defines are + considered obsolete. The names it defines are: + + `dirent.h' + `DIRENT' + + `sys/ndir.h' + `SYSNDIR' + + `sys/dir.h' + `SYSDIR' + + `ndir.h' + `NDIR' + + In addition, if the `closedir' function does not return a + meaningful value, define `VOID_CLOSEDIR'. + + - Macro: AC_HEADER_DIRENT + Check for the following header files, and for the first one that is + found and defines `DIR', define the listed C preprocessor macro: + + `dirent.h' + `HAVE_DIRENT_H' + + `sys/ndir.h' + `HAVE_SYS_NDIR_H' + + `sys/dir.h' + `HAVE_SYS_DIR_H' + + `ndir.h' + `HAVE_NDIR_H' + + The directory library declarations in the source code should look + something like the following: + + #if HAVE_DIRENT_H + # include <dirent.h> + # define NAMLEN(dirent) strlen((dirent)->d_name) + #else + # define dirent direct + # define NAMLEN(dirent) (dirent)->d_namlen + # if HAVE_SYS_NDIR_H + # include <sys/ndir.h> + # endif + # if HAVE_SYS_DIR_H + # include <sys/dir.h> + # endif + # if HAVE_NDIR_H + # include <ndir.h> + # endif + #endif + + Using the above declarations, the program would declare variables + to be type `struct dirent', not `struct direct', and would access + the length of a directory entry name by passing a pointer to a + `struct dirent' to the `NAMLEN' macro. + + This macro also checks for the SCO Xenix `dir' and `x' libraries. + + - Macro: AC_HEADER_MAJOR + If `sys/types.h' does not define `major', `minor', and `makedev', + but `sys/mkdev.h' does, define `MAJOR_IN_MKDEV'; otherwise, if + `sys/sysmacros.h' does, define `MAJOR_IN_SYSMACROS'. + + - Macro: AC_HEADER_STDC + Define `STDC_HEADERS' if the system has ANSI C header files. + Specifically, this macro checks for `stdlib.h', `stdarg.h', + `string.h', and `float.h'; if the system has those, it probably + has the rest of the ANSI C header files. This macro also checks + whether `string.h' declares `memchr' (and thus presumably the + other `mem' functions), whether `stdlib.h' declare `free' (and + thus presumably `malloc' and other related functions), and whether + the `ctype.h' macros work on characters with the high bit set, as + ANSI C requires. + + Use `STDC_HEADERS' instead of `__STDC__' to determine whether the + system has ANSI-compliant header files (and probably C library + functions) because many systems that have GCC do not have ANSI C + header files. + + On systems without ANSI C headers, there is so much variation that + it is probably easier to declare the functions you use than to + figure out exactly what the system header files declare. Some + systems contain a mix of functions ANSI and BSD; some are mostly + ANSI but lack `memmove'; some define the BSD functions as macros in + `string.h' or `strings.h'; some have only the BSD functions but + `string.h'; some declare the memory functions in `memory.h', some + in `string.h'; etc. It is probably sufficient to check for one + string function and one memory function; if the library has the + ANSI versions of those then it probably has most of the others. + If you put the following in `configure.in': + + AC_HEADER_STDC + AC_CHECK_FUNCS(strchr memcpy) + + then, in your code, you can put declarations like this: + + #if STDC_HEADERS + # include <string.h> + #else + # ifndef HAVE_STRCHR + # define strchr index + # define strrchr rindex + # endif + char *strchr (), *strrchr (); + # ifndef HAVE_MEMCPY + # define memcpy(d, s, n) bcopy ((s), (d), (n)) + # define memmove(d, s, n) bcopy ((s), (d), (n)) + # endif + #endif + + If you use a function like `memchr', `memset', `strtok', or + `strspn', which have no BSD equivalent, then macros won't suffice; + you must provide an implementation of each function. An easy way + to incorporate your implementations only when needed (since the + ones in system C libraries may be hand optimized) is to, taking + `memchr' for example, put it in `memchr.c' and use + `AC_REPLACE_FUNCS(memchr)'. + + - Macro: AC_HEADER_SYS_WAIT + If `sys/wait.h' exists and is compatible with POSIX.1, define + `HAVE_SYS_WAIT_H'. Incompatibility can occur if `sys/wait.h' does + not exist, or if it uses the old BSD `union wait' instead of `int' + to store a status value. If `sys/wait.h' is not POSIX.1 + compatible, then instead of including it, define the POSIX.1 + macros with their usual interpretations. Here is an example: + + #include <sys/types.h> + #if HAVE_SYS_WAIT_H + # include <sys/wait.h> + #endif + #ifndef WEXITSTATUS + # define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) + #endif + #ifndef WIFEXITED + # define WIFEXITED(stat_val) (((stat_val) & 255) == 0) + #endif + + - Macro: AC_MEMORY_H + Define `NEED_MEMORY_H' if `memcpy', `memcmp', etc. are not + declared in `string.h' and `memory.h' exists. This macro is + obsolete; instead, use `AC_CHECK_HEADERS(memory.h)'. See the + example for `AC_HEADER_STDC'. + + - Macro: AC_UNISTD_H + Define `HAVE_UNISTD_H' if the system has `unistd.h'. This macro + is obsolete; instead, use `AC_CHECK_HEADERS(unistd.h)'. + + The way to check if the system supports POSIX.1 is: + + #if HAVE_UNISTD_H + # include <sys/types.h> + # include <unistd.h> + #endif + + #ifdef _POSIX_VERSION + /* Code for POSIX.1 systems. */ + #endif + + `_POSIX_VERSION' is defined when `unistd.h' is included on POSIX.1 + systems. If there is no `unistd.h', it is definitely not a + POSIX.1 system. However, some non-POSIX.1 systems do have + `unistd.h'. + + - Macro: AC_USG + Define `USG' if the system does not have `strings.h', `rindex', + `bzero', etc. This implies that it has `string.h', `strrchr', + `memset', etc. + + The symbol `USG' is obsolete. Instead of this macro, see the + example for `AC_HEADER_STDC'. + + +File: autoconf.info, Node: Generic Headers, Prev: Particular Headers, Up: Header Files + +Generic Header Checks +--------------------- + + These macros are used to find system header files not covered by the +particular test macros. If you need to check the contents of a header +as well as find out whether it is present, you have to write your own +test for it (*note Writing Tests::.). + + - Macro: AC_CHECK_HEADER (HEADER-FILE, ACTION-IF-FOUND [, + ACTION-IF-NOT-FOUND]) + If the system header file HEADER-FILE exists, execute shell + commands ACTION-IF-FOUND, otherwise execute ACTION-IF-NOT-FOUND. + If you just want to define a symbol if the header file is + available, consider using `AC_CHECK_HEADERS' instead. + + - Macro: AC_CHECK_HEADERS (HEADER-FILE... [, ACTION-IF-FOUND [, + ACTION-IF-NOT-FOUND]]) + For each given system header file HEADER-FILE in the + whitespace-separated argument list that exists, define + `HAVE_HEADER-FILE' (in all capitals). If ACTION-IF-FOUND is + given, it is additional shell code to execute when one of the + header files is found. You can give it a value of `break' to + break out of the loop on the first match. If ACTION-IF-NOT-FOUND + is given, it is executed when one of the header files is not found. + + +File: autoconf.info, Node: Structures, Next: Typedefs, Prev: Header Files, Up: Existing Tests + +Structures +========== + + The following macros check for certain structures or structure +members. To check structures not listed here, use `AC_EGREP_CPP' +(*note Examining Declarations::.) or `AC_TRY_COMPILE' (*note Examining +Syntax::.). + + - Macro: AC_HEADER_STAT + If the macros `S_ISDIR', `S_ISREG' et al. defined in `sys/stat.h' + do not work properly (returning false positives), define + `STAT_MACROS_BROKEN'. This is the case on Tektronix UTekV, Amdahl + UTS and Motorola System V/88. + + - Macro: AC_HEADER_TIME + If a program may include both `time.h' and `sys/time.h', define + `TIME_WITH_SYS_TIME'. On some older systems, `sys/time.h' + includes `time.h', but `time.h' is not protected against multiple + inclusion, so programs should not explicitly include both files. + This macro is useful in programs that use, for example, `struct + timeval' or `struct timezone' as well as `struct tm'. It is best + used in conjunction with `HAVE_SYS_TIME_H', which can be checked + for using `AC_CHECK_HEADERS(sys/time.h)'. + + #if TIME_WITH_SYS_TIME + # include <sys/time.h> + # include <time.h> + #else + # if HAVE_SYS_TIME_H + # include <sys/time.h> + # else + # include <time.h> + # endif + #endif + + - Macro: AC_STRUCT_ST_BLKSIZE + If `struct stat' contains an `st_blksize' member, define + `HAVE_ST_BLKSIZE'. + + - Macro: AC_STRUCT_ST_BLOCKS + If `struct stat' contains an `st_blocks' member, define + `HAVE_ST_BLOCKS'. Otherwise, add `fileblocks.o' to the output + variable `LIBOBJS'. + + - Macro: AC_STRUCT_ST_RDEV + If `struct stat' contains an `st_rdev' member, define + `HAVE_ST_RDEV'. + + - Macro: AC_STRUCT_TM + If `time.h' does not define `struct tm', define `TM_IN_SYS_TIME', + which means that including `sys/time.h' had better define `struct + tm'. + + - Macro: AC_STRUCT_TIMEZONE + Figure out how to get the current timezone. If `struct tm' has a + `tm_zone' member, define `HAVE_TM_ZONE'. Otherwise, if the + external array `tzname' is found, define `HAVE_TZNAME'. + + +File: autoconf.info, Node: Typedefs, Next: Compiler Characteristics, Prev: Structures, Up: Existing Tests + +Typedefs +======== + + The following macros check for C typedefs. If there is no macro +specifically defined to check for a typedef you need, and you don't need +to check for any special properties of it, then you can use a general +typedef check macro. + +* Menu: + +* Particular Typedefs:: Special handling to find certain types. +* Generic Typedefs:: How to find other types. + + +File: autoconf.info, Node: Particular Typedefs, Next: Generic Typedefs, Up: Typedefs + +Particular Typedef Checks +------------------------- + + These macros check for particular C typedefs in `sys/types.h' and +`stdlib.h' (if it exists). + + - Macro: AC_TYPE_GETGROUPS + Define `GETGROUPS_T' to be whichever of `gid_t' or `int' is the + base type of the array argument to `getgroups'. + + - Macro: AC_TYPE_MODE_T + If `mode_t' is not defined, define `mode_t' to be `int'. + + - Macro: AC_TYPE_OFF_T + If `off_t' is not defined, define `off_t' to be `long'. + + - Macro: AC_TYPE_PID_T + If `pid_t' is not defined, define `pid_t' to be `int'. + + - Macro: AC_TYPE_SIGNAL + If `signal.h' declares `signal' as returning a pointer to a + function returning `void', define `RETSIGTYPE' to be `void'; + otherwise, define it to be `int'. + + Define signal handlers as returning type `RETSIGTYPE': + + RETSIGTYPE + hup_handler () + { + ... + } + + - Macro: AC_TYPE_SIZE_T + If `size_t' is not defined, define `size_t' to be `unsigned'. + + - Macro: AC_TYPE_UID_T + If `uid_t' is not defined, define `uid_t' to be `int' and `gid_t' + to be `int'. + + +File: autoconf.info, Node: Generic Typedefs, Prev: Particular Typedefs, Up: Typedefs + +Generic Typedef Checks +---------------------- + + This macro is used to check for typedefs not covered by the +particular test macros. + + - Macro: AC_CHECK_TYPE (TYPE, DEFAULT) + If the type TYPE is not defined in `sys/types.h' or `stdlib.h' (if + it exists), define it to be the C (or C++) builtin type DEFAULT; + e.g., `short' or `unsigned'. + + +File: autoconf.info, Node: Compiler Characteristics, Next: System Services, Prev: Typedefs, Up: Existing Tests + +Compiler Characteristics +======================== + + The following macros check for C compiler or machine architecture +features. To check for characteristics not listed here, use +`AC_TRY_COMPILE' (*note Examining Syntax::.) or `AC_TRY_RUN' (*note Run +Time::.) + + - Macro: AC_C_BIGENDIAN + If words are stored with the most significant byte first (like + Motorola and SPARC, but not Intel and VAX, CPUs), define + `WORDS_BIGENDIAN'. + + - Macro: AC_C_CONST + If the C compiler does not fully support the keyword `const', + define `const' to be empty. Some C compilers that do not define + `__STDC__' do support `const'; some compilers that define + `__STDC__' do not completely support `const'. Programs can simply + use `const' as if every C compiler supported it; for those that + don't, the `Makefile' or configuration header file will define it + as empty. + + - Macro: AC_C_INLINE + If the C compiler is a version of GCC that supports the keyword + `__inline' but not `inline' (such as some NeXT versions), define + `inline' to be `__inline'. + + - Macro: AC_C_CHAR_UNSIGNED + If the C type `char' is unsigned, define `__CHAR_UNSIGNED__', + unless the C compiler predefines it. + + - Macro: AC_C_LONG_DOUBLE + If the C compiler supports the `long double' type, define + `HAVE_LONG_DOUBLE'. Some C compilers that do not define + `__STDC__' do support the `long double' type; some compilers that + define `__STDC__' do not support `long double'. + + - Macro: AC_CHECK_SIZEOF (TYPE) + Define `SIZEOF_UCTYPE' to be the size in bytes of the C (or C++) + builtin type TYPE, e.g. `int' or `char *'. If `type' is unknown + to the compiler, it gets a size of 0. UCTYPE is TYPE, with + lowercase converted to uppercase, spaces changed to underscores, + and asterisks changed to `P'. For example, the call + AC_CHECK_SIZEOF(int *) + + defines `SIZEOF_INT_P' to be 8 on DEC Alpha AXP systems. + + - Macro: AC_INT_16_BITS + If the C type `int' is 16 bits wide, define `INT_16_BITS'. This + macro is obsolete; it is more general to use + `AC_CHECK_SIZEOF(int)' instead. + + - Macro: AC_LONG_64_BITS + If the C type `long int' is 64 bits wide, define `LONG_64_BITS'. + This macro is obsolete; it is more general to use + `AC_CHECK_SIZEOF(long)' instead. + + +File: autoconf.info, Node: System Services, Next: UNIX Variants, Prev: Compiler Characteristics, Up: Existing Tests + +System Services +=============== + + The following macros check for operating system services or +capabilities. + + - Macro: AC_SYS_INTERPRETER + Check whether the system supports starting scripts with a line of + the form `#!/bin/csh' to select the interpreter to use for the + script. After running this macro, shell code in `configure.in' + can check the variable `ac_cv_sys_interpreter'; it will be set to + `yes' if the system supports `#!', `no' if not. + + - Macro: AC_PATH_X + Try to locate the X Window System include files and libraries. If + the user gave the command line options `--x-includes=DIR' and + `--x-libraries=DIR', use those directories. If either or both + were not given, get the missing values by running `xmkmf' on a + trivial `Imakefile' and examining the `Makefile' that it produces. + If that fails (such as if `xmkmf' is not present), look for them + in several directories where they often reside. If either method + is successful, set the shell variables `x_includes' and + `x_libraries' to their locations, unless they are in directories + the compiler searches by default. + + If both methods fail, or the user gave the command line option + `--without-x', set the shell variable `no_x' to `yes'; otherwise + set it to the empty string. + + - Macro: AC_PATH_XTRA + An enhanced version of `AC_PATH_X'. Add the C compiler flags that + X needs to output variable `X_CFLAGS', and the X linker flags to + `X_LIBS'. If X is not available, add `-DX_DISPLAY_MISSING' to + `X_CFLAGS'. + + Also check for special libraries that some systems need in order to + compile X programs. Add any that the system needs to output + variable `X_EXTRA_LIBS'. And check for special X11R6 libraries + that need to be linked with before `-lX11', and add any found to + the output variable `X_PRE_LIBS'. + + - Macro: AC_SYS_LONG_FILE_NAMES + If the system supports file names longer than 14 characters, define + `HAVE_LONG_FILE_NAMES'. + + - Macro: AC_SYS_RESTARTABLE_SYSCALLS + If the system automatically restarts a system call that is + interrupted by a signal, define `HAVE_RESTARTABLE_SYSCALLS'. + + +File: autoconf.info, Node: UNIX Variants, Prev: System Services, Up: Existing Tests + +UNIX Variants +============= + + The following macros check for certain operating systems that need +special treatment for some programs, due to exceptional oddities in +their header files or libraries. These macros are warts; they will be +replaced by a more systematic approach, based on the functions they make +available or the environments they provide. + + - Macro: AC_AIX + If on AIX, define `_ALL_SOURCE'. Allows the use of some BSD + functions. Should be called before any macros that run the C + compiler. + + - Macro: AC_DYNIX_SEQ + If on Dynix/PTX (Sequent UNIX), add `-lseq' to output variable + `LIBS'. This macro is obsolete; instead, use `AC_FUNC_GETMNTENT'. + + - Macro: AC_IRIX_SUN + If on IRIX (Silicon Graphics UNIX), add `-lsun' to output variable + `LIBS'. This macro is obsolete. If you were using it to get + `getmntent', use `AC_FUNC_GETMNTENT' instead. If you used it for + the NIS versions of the password and group functions, use + `AC_CHECK_LIB(sun, getpwnam)'. + + - Macro: AC_ISC_POSIX + If on a POSIXized ISC UNIX, define `_POSIX_SOURCE' and add + `-posix' (for the GNU C compiler) or `-Xp' (for other C compilers) + to output variable `CC'. This allows the use of POSIX facilities. + Must be called after `AC_PROG_CC' and before any other macros + that run the C compiler. + + - Macro: AC_MINIX + If on Minix, define `_MINIX' and `_POSIX_SOURCE' and define + `_POSIX_1_SOURCE' to be 2. This allows the use of POSIX + facilities. Should be called before any macros that run the C + compiler. + + - Macro: AC_SCO_INTL + If on SCO UNIX, add `-lintl' to output variable `LIBS'. This + macro is obsolete; instead, use `AC_FUNC_STRFTIME'. + + - Macro: AC_XENIX_DIR + If on Xenix, add `-lx' to output variable `LIBS'. Also, if + `dirent.h' is being used, add `-ldir' to `LIBS'. This macro is + obsolete; use `AC_HEADER_DIRENT' instead. + + +File: autoconf.info, Node: Writing Tests, Next: Results, Prev: Existing Tests, Up: Top + +Writing Tests +************* + + If the existing feature tests don't do something you need, you have +to write new ones. These macros are the building blocks. They provide +ways for other macros to check whether various kinds of features are +available and report the results. + + This chapter contains some suggestions and some of the reasons why +the existing tests are written the way they are. You can also learn a +lot about how to write Autoconf tests by looking at the existing ones. +If something goes wrong in one or more of the Autoconf tests, this +information can help you understand the assumptions behind them, which +might help you figure out how to best solve the problem. + + These macros check the output of the C compiler system. They do not +cache the results of their tests for future use (*note Caching +Results::.), because they don't know enough about the information they +are checking for to generate a cache variable name. They also do not +print any messages, for the same reason. The checks for particular +kinds of C features call these macros and do cache their results and +print messages about what they're checking for. + +* Menu: + +* Examining Declarations:: Detecting header files and declarations. +* Examining Syntax:: Detecting language syntax features. +* Examining Libraries:: Detecting functions and global variables. +* Run Time:: Testing for run-time features. +* Portable Shell:: Shell script portability pitfalls. +* Testing Values and Files:: Checking strings and files. +* Multiple Cases:: Tests for several possible values. +* Language Choice:: Selecting which language to use for testing. + + +File: autoconf.info, Node: Examining Declarations, Next: Examining Syntax, Up: Writing Tests + +Examining Declarations +====================== + + The macro `AC_TRY_CPP' is used to check whether particular header +files exist. You can check for one at a time, or more than one if you +need several header files to all exist for some purpose. + + - Macro: AC_TRY_CPP (INCLUDES, ACTION-IF-TRUE [, ACTION-IF-FALSE]) + INCLUDES is C or C++ `#include' statements and declarations, on + which shell variable, backquote, and backslash substitutions are + performed. (Actually, it can be any C program, but other + statements are probably not useful.) If the preprocessor produces + no error messages while processing it, run shell commands + ACTION-IF-TRUE. Otherwise run shell commands ACTION-IF-FALSE. + + This macro uses `CPPFLAGS', but not `CFLAGS', because `-g', `-O', + etc. are not valid options to many C preprocessors. + + Here is now to find out whether a header file contains a particular +declaration, such as a typedef, a structure, a structure member, or a +function. Use `AC_EGREP_HEADER' instead of running `grep' directly on +the header file; on some systems the symbol might be defined in another +header file that the file you are checking `#include's. + + - Macro: AC_EGREP_HEADER (PATTERN, HEADER-FILE, ACTION-IF-FOUND [, + ACTION-IF-NOT-FOUND]) + If the output of running the preprocessor on the system header file + HEADER-FILE matches the `egrep' regular expression PATTERN, + execute shell commands ACTION-IF-FOUND, otherwise execute + ACTION-IF-NOT-FOUND. + + To check for C preprocessor symbols, either defined by header files +or predefined by the C preprocessor, use `AC_EGREP_CPP'. Here is an +example of the latter: + + AC_EGREP_CPP(yes, + [#ifdef _AIX + yes + #endif + ], is_aix=yes, is_aix=no) + + - Macro: AC_EGREP_CPP (PATTERN, PROGRAM, ACTION-IF-FOUND [, + ACTION-IF-NOT-FOUND]) + PROGRAM is the text of a C or C++ program, on which shell + variable, backquote, and backslash substitutions are performed. + If the output of running the preprocessor on PROGRAM matches the + `egrep' regular expression PATTERN, execute shell commands + ACTION-IF-FOUND, otherwise execute ACTION-IF-NOT-FOUND. + + This macro calls `AC_PROG_CPP' or `AC_PROG_CXXCPP' (depending on + which language is current, *note Language Choice::.), if it hasn't + been called already. + + +File: autoconf.info, Node: Examining Syntax, Next: Examining Libraries, Prev: Examining Declarations, Up: Writing Tests + +Examining Syntax +================ + + To check for a syntax feature of the C or C++ compiler, such as +whether it recognizes a certain keyword, use `AC_TRY_COMPILE' to try to +compile a small program that uses that feature. You can also use it to +check for structures and structure members that are not present on all +systems. + + - Macro: AC_TRY_COMPILE (INCLUDES, FUNCTION-BODY, ACTION-IF-FOUND [, + ACTION-IF-NOT-FOUND]) + Create a test C program to see whether a function whose body + consists of FUNCTION-BODY can be compiled; INCLUDES is any + `#include' statements needed by the code in FUNCTION-BODY. If the + file compiles successfully, run shell commands ACTION-IF-FOUND, + otherwise run ACTION-IF-NOT-FOUND. This macro uses `CFLAGS' or + `CXXFLAGS', and `CPPFLAGS', when compiling. It does not try to + link; use `AC_TRY_LINK' if you need to do that (*note Examining + Libraries::.). + + +File: autoconf.info, Node: Examining Libraries, Next: Run Time, Prev: Examining Syntax, Up: Writing Tests + +Examining Libraries +=================== + + To check for a library, a function, or a global variable, Autoconf +`configure' scripts try to compile and link a small program that uses +it. This is unlike Metaconfig, which by default uses `nm' or `ar' on +the C library to try to figure out which functions are available. +Trying to link with the function is usually a more reliable approach +because it avoids dealing with the variations in the options and output +formats of `nm' and `ar' and in the location of the standard libraries. +It also allows configuring for cross-compilation or checking a +function's runtime behavior if needed. On the other hand, it can be +slower than scanning the libraries once. + + A few systems have linkers that do not return a failure exit status +when there are unresolved functions in the link. This bug makes the +configuration scripts produced by Autoconf unusable on those systems. +However, some of them can be given options that make the exit status +correct. This is a problem that Autoconf does not currently handle +automatically. + + `AC_TRY_LINK' is used to compile test programs to test for functions +and global variables. It is also used (by `AC_CHECK_LIB') to check for +libraries, by adding the library being checked for to `LIBS' +temporarily and trying to link a small program. + + - Macro: AC_TRY_LINK (INCLUDES, FUNCTION-BODY, ACTION-IF-FOUND [, + ACTION-IF-NOT-FOUND]) + Create a test C program to see whether a function whose body + consists of FUNCTION-BODY can be compiled and linked; INCLUDES is + any `#include' statements needed by the code in FUNCTION-BODY. If + the file compiles and links successfully, run shell commands + ACTION-IF-FOUND, otherwise run ACTION-IF-NOT-FOUND. This macro + uses `CFLAGS' or `CXXFLAGS', `CPPFLAGS', `LDFLAGS', and `LIBS' + when compiling. + + - Macro: AC_COMPILE_CHECK (ECHO-TEXT, INCLUDES, FUNCTION-BODY, + ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND]) + This is an obsolete version of `AC_TRY_LINK', with the addition + that it prints `checking for ECHO-TEXT' to the standard output + first, if ECHO-TEXT is non-empty. Use `AC_MSG_CHECKING' and + `AC_MSG_RESULT' instead to print messages (*note Printing + Messages::.). + diff --git a/util/autoconf/autoconf.info-3 b/util/autoconf/autoconf.info-3 new file mode 100644 index 0000000..0cbd5db --- /dev/null +++ b/util/autoconf/autoconf.info-3 @@ -0,0 +1,1198 @@ +This is Info file autoconf.info, produced by Makeinfo-1.55 from the +input file ./autoconf.texi. + +START-INFO-DIR-ENTRY +* Autoconf: (autoconf). Create source code configuration scripts. +END-INFO-DIR-ENTRY + + This file documents the GNU Autoconf package for creating scripts to +configure source code packages using templates and an `m4' macro +package. + + Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. + + Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, provided that +the entire resulting derived work is distributed under the terms of a +permission notice identical to this one. + + Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions, except that this permission notice may be stated in a +translation approved by the Foundation. + + +File: autoconf.info, Node: Run Time, Next: Portable Shell, Prev: Examining Libraries, Up: Writing Tests + +Checking Run Time Behavior +========================== + + Sometimes you need to find out how a system performs at run time, +such as whether a given function has a certain capability or bug. If +you can, make such checks when your program runs instead of when it is +configured. You can check for things like the machine's endianness when +your program initializes itself. + + If you really need to test for a run-time behavior while configuring, +you can write a test program to determine the result, and compile and +run it using `AC_TRY_RUN'. Avoid running test programs if possible, +because using them prevents people from configuring your package for +cross-compiling. + +* Menu: + +* Test Programs:: Running test programs. +* Guidelines:: General rules for writing test programs. +* Test Functions:: Avoiding pitfalls in test programs. + + +File: autoconf.info, Node: Test Programs, Next: Guidelines, Up: Run Time + +Running Test Programs +--------------------- + + Use the following macro if you need to test run-time behavior of the +system while configuring. + + - Macro: AC_TRY_RUN (PROGRAM, ACTION-IF-TRUE [, ACTION-IF-FALSE [, + ACTION-IF-CROSS-COMPILING]]) + PROGRAM is the text of a C program, on which shell variable and + backquote substitutions are performed. If it compiles and links + successfully and returns an exit status of 0 when executed, run + shell commands ACTION-IF-TRUE. Otherwise run shell commands + ACTION-IF-FALSE; the exit status of the program is available in + the shell variable `$?'. This macro uses `CFLAGS' or `CXXFLAGS', + `CPPFLAGS', `LDFLAGS', and `LIBS' when compiling. + + If the C compiler being used does not produce executables that run + on the system where `configure' is being run, then the test + program is not run. If the optional shell commands + ACTION-IF-CROSS-COMPILING are given, they are run instead and this + macro calls `AC_C_CROSS' if it has not already been called. + Otherwise, `configure' prints an error message and exits. + + Try to provide a pessimistic default value to use when +cross-compiling makes run-time tests impossible. You do this by +passing the optional last argument to `AC_TRY_RUN'. `autoconf' prints +a warning message when creating `configure' each time it encounters a +call to `AC_TRY_RUN' with no ACTION-IF-CROSS-COMPILING argument given. +You may ignore the warning, though users will not be able to configure +your package for cross-compiling. A few of the macros distributed with +Autoconf produce this warning message. + + To configure for cross-compiling you can also choose a value for +those parameters based on the canonical system name (*note Manual +Configuration::.). Alternatively, set up a test results cache file with +the correct values for the target system (*note Caching Results::.). + + To provide a default for calls of `AC_TRY_RUN' that are embedded in +other macros, including a few of the ones that come with Autoconf, you +can call `AC_C_CROSS' before running them. Then, if the shell variable +`cross_compiling' is set to `yes', use an alternate method to get the +results instead of calling the macros. + + - Macro: AC_C_CROSS + If the C compiler being used does not produce executables that can + run on the system where `configure' is being run, set the shell + variable `cross_compiling' to `yes', otherwise `no'. + + +File: autoconf.info, Node: Guidelines, Next: Test Functions, Prev: Test Programs, Up: Run Time + +Guidelines for Test Programs +---------------------------- + + Test programs should not write anything to the standard output. They +should return 0 if the test succeeds, nonzero otherwise, so that success +can be distinguished easily from a core dump or other failure; +segmentation violations and other failures produce a nonzero exit +status. Test programs should `exit', not `return', from `main', +because on some systems (old Suns, at least) the argument to `return' +in `main' is ignored. + + Test programs can use `#if' or `#ifdef' to check the values of +preprocessor macros defined by tests that have already run. For +example, if you call `AC_HEADER_STDC', then later on in `configure.in' +you can have a test program that includes an ANSI C header file +conditionally: + + #if STDC_HEADERS + # include <stdlib.h> + #endif + + If a test program needs to use or create a data file, give it a name +that starts with `conftest', such as `conftestdata'. The `configure' +script cleans up by running `rm -rf conftest*' after running test +programs and if the script is interrupted. + + +File: autoconf.info, Node: Test Functions, Prev: Guidelines, Up: Run Time + +Test Functions +-------------- + + Function declarations in test programs should have a prototype +conditionalized for C++. In practice, though, test programs rarely need +functions that take arguments. + + #ifdef __cplusplus + foo(int i) + #else + foo(i) int i; + #endif + + Functions that test programs declare should also be conditionalized +for C++, which requires `extern "C"' prototypes. Make sure to not +include any header files containing clashing prototypes. + + #ifdef __cplusplus + extern "C" void *malloc(size_t); + #else + char *malloc(); + #endif + + If a test program calls a function with invalid parameters (just to +see whether it exists), organize the program to ensure that it never +invokes that function. You can do this by calling it in another +function that is never invoked. You can't do it by putting it after a +call to `exit', because GCC version 2 knows that `exit' never returns +and optimizes out any code that follows it in the same block. + + If you include any header files, make sure to call the functions +relevant to them with the correct number of arguments, even if they are +just 0, to avoid compilation errors due to prototypes. GCC version 2 +has internal prototypes for several functions that it automatically +inlines; for example, `memcpy'. To avoid errors when checking for +them, either pass them the correct number of arguments or redeclare them +with a different return type (such as `char'). + + +File: autoconf.info, Node: Portable Shell, Next: Testing Values and Files, Prev: Run Time, Up: Writing Tests + +Portable Shell Programming +========================== + + When writing your own checks, there are some shell script programming +techniques you should avoid in order to make your code portable. The +Bourne shell and upward-compatible shells like Bash and the Korn shell +have evolved over the years, but to prevent trouble, do not take +advantage of features that were added after UNIX version 7, circa 1977. +You should not use shell functions, aliases, negated character classes, +or other features that are not found in all Bourne-compatible shells; +restrict yourself to the lowest common denominator. Even `unset' is +not supported by all shells! + + The set of external programs you should run in a `configure' script +is fairly small. *Note Utilities in Makefiles: +(standards.info)Utilities in Makefiles, for the list. This restriction +allows users to start out with a fairly small set of programs and build +the rest, avoiding too many interdependencies between packages. + + Some of these external utilities have a portable subset of features, +as well; for example, don't rely on `ln' having a `-f' option or `cat' +having any options. `sed' scripts should not contain comments or use +branch labels longer than 8 characters. Don't use `grep -s' to +suppress output, because `grep -s' on System V does not suppress +output, only error messages. Instead, redirect the standard output and +standard error (in case the file doesn't exist) of `grep' to +`/dev/null'. Check the exit status of `grep' to determine whether it +found a match. + + +File: autoconf.info, Node: Testing Values and Files, Next: Multiple Cases, Prev: Portable Shell, Up: Writing Tests + +Testing Values and Files +======================== + + `configure' scripts need to test properties of many files and +strings. Here are some portability problems to watch out for when doing +those tests. + + The `test' program is the way to perform many file and string tests. +It is often invoked by the alternate name `[', but using that name in +Autoconf code is asking for trouble since it is an `m4' quote character. + + If you need to make multiple checks using `test', combine them with +the shell operators `&&' and `||' instead of using the `test' operators +`-a' and `-o'. On System V, the precedence of `-a' and `-o' is wrong +relative to the unary operators; consequently, POSIX does not specify +them, so using them is nonportable. If you combine `&&' and `||' in +the same statement, keep in mind that they have equal precedence. + + To enable `configure' scripts to support cross-compilation, they +shouldn't do anything that tests features of the host system instead of +the target system. But occasionally you may find it necessary to check +whether some arbitrary file exists. To do so, use `test -f' or `test +-r'. Do not use `test -x', because 4.3BSD does not have it. + + Another nonportable shell programming construction is + VAR=${VAR:-VALUE} + +The intent is to set VAR to VALUE only if it is not already set, but if +VAR has any value, even the empty string, to leave it alone. Old BSD +shells, including the Ultrix `sh', don't accept the colon, and complain +and die. A portable equivalent is + : ${VAR=VALUE} + + +File: autoconf.info, Node: Multiple Cases, Next: Language Choice, Prev: Testing Values and Files, Up: Writing Tests + +Multiple Cases +============== + + Some operations are accomplished in several possible ways, depending +on the UNIX variant. Checking for them essentially requires a "case +statement". Autoconf does not directly provide one; however, it is +easy to simulate by using a shell variable to keep track of whether a +way to perform the operation has been found yet. + + Here is an example that uses the shell variable `fstype' to keep +track of whether the remaining cases need to be checked. + + AC_MSG_CHECKING(how to get filesystem type) + fstype=no + # The order of these tests is important. + AC_TRY_CPP([#include <sys/statvfs.h> + #include <sys/fstyp.h>], AC_DEFINE(FSTYPE_STATVFS) fstype=SVR4) + if test $fstype = no; then + AC_TRY_CPP([#include <sys/statfs.h> + #include <sys/fstyp.h>], AC_DEFINE(FSTYPE_USG_STATFS) fstype=SVR3) + fi + if test $fstype = no; then + AC_TRY_CPP([#include <sys/statfs.h> + #include <sys/vmount.h>], AC_DEFINE(FSTYPE_AIX_STATFS) fstype=AIX) + fi + # (more cases omitted here) + AC_MSG_RESULT($fstype) + + +File: autoconf.info, Node: Language Choice, Prev: Multiple Cases, Up: Writing Tests + +Language Choice +=============== + + Packages that use both C and C++ need to test features of both +compilers. Autoconf-generated `configure' scripts check for C features +by default. The following macros determine which language's compiler +is used in tests that follow in `configure.in'. + + - Macro: AC_LANG_C + Do compilation tests using `CC' and `CPP' and use extension `.c' + for test programs. + + - Macro: AC_LANG_CPLUSPLUS + Do compilation tests using `CXX' and `CXXCPP' and use extension + `.C' for test programs. + + - Macro: AC_LANG_SAVE + Remember the current language (as set by `AC_LANG_C' or + `AC_LANG_CPLUSPLUS') on a stack. Does not change which language is + current. Use this macro and `AC_LANG_RESTORE' in macros that need + to temporarily switch to a particular language. + + - Macro: AC_LANG_RESTORE + Select the language that is saved on the top of the stack, as set + by `AC_LANG_SAVE', and remove it from the stack. This macro is + equivalent to either `AC_LANG_C' or `AC_LANG_CPLUSPLUS', whichever + had been run most recently when `AC_LANG_SAVE' was last called. + + Do not call this macro more times than `AC_LANG_SAVE'. + + - Macro: AC_REQUIRE_CPP + Ensure that whichever preprocessor would currently be used for + tests has been found. Calls `AC_REQUIRE' (*note Prerequisite + Macros::.) with an argument of either `AC_PROG_CPP' or + `AC_PROG_CXXCPP', depending on which language is current. + + +File: autoconf.info, Node: Results, Next: Writing Macros, Prev: Writing Tests, Up: Top + +Results of Tests +**************** + + Once `configure' has determined whether a feature exists, what can +it do to record that information? There are four sorts of things it can +do: define a C preprocessor symbol, set a variable in the output files, +save the result in a cache file for future `configure' runs, and print +a message letting the user know the result of the test. + +* Menu: + +* Defining Symbols:: Defining C preprocessor symbols. +* Setting Output Variables:: Replacing variables in output files. +* Caching Results:: Speeding up subsequent `configure' runs. +* Printing Messages:: Notifying users of progress or problems. + + +File: autoconf.info, Node: Defining Symbols, Next: Setting Output Variables, Up: Results + +Defining C Preprocessor Symbols +=============================== + + A common action to take in response to a feature test is to define a +C preprocessor symbol indicating the results of the test. That is done +by calling `AC_DEFINE' or `AC_DEFINE_UNQUOTED'. + + By default, `AC_OUTPUT' places the symbols defined by these macros +into the output variable `DEFS', which contains an option +`-DSYMBOL=VALUE' for each symbol defined. Unlike in Autoconf version +1, there is no variable `DEFS' defined while `configure' is running. +To check whether Autoconf macros have already defined a certain C +preprocessor symbol, test the value of the appropriate cache variable, +as in this example: + + AC_CHECK_FUNC(vprintf, AC_DEFINE(HAVE_VPRINTF)) + if test "$ac_cv_func_vprintf" != yes; then + AC_CHECK_FUNC(_doprnt, AC_DEFINE(HAVE_DOPRNT)) + fi + + If `AC_CONFIG_HEADER' has been called, then instead of creating +`DEFS', `AC_OUTPUT' creates a header file by substituting the correct +values into `#define' statements in a template file. *Note +Configuration Headers::, for more information about this kind of output. + + - Macro: AC_DEFINE (VARIABLE [, VALUE]) + Define C preprocessor variable VARIABLE. If VALUE is given, set + VARIABLE to that value (verbatim), otherwise set it to 1. VALUE + should not contain literal newlines, and if you are not using + `AC_CONFIG_HEADER' it should not contain any `#' characters, as + `make' tends to eat them. To use a shell variable (which you need + to do in order to define a value containing the `m4' quote + characters `[' or `]'), use `AC_DEFINE_UNQUOTED' instead. The + following example defines the C preprocessor variable `EQUATION' + to be the string constant `"$a > $b"': + + AC_DEFINE(EQUATION, "$a > $b") + + - Macro: AC_DEFINE_UNQUOTED (VARIABLE [, VALUE]) + Like `AC_DEFINE', but three shell expansions are + performed--once--on VARIABLE and VALUE: variable expansion (`$'), + command substitution (``'), and backslash escaping (`\'). Single + and double quote characters in the value have no special meaning. + Use this macro instead of `AC_DEFINE' when VARIABLE or VALUE is a + shell variable. Examples: + + AC_DEFINE_UNQUOTED(config_machfile, "${machfile}") + AC_DEFINE_UNQUOTED(GETGROUPS_T, $ac_cv_type_getgroups) + AC_DEFINE_UNQUOTED(${ac_tr_hdr}) + + Due to the syntactical bizarreness of the Bourne shell, do not use +semicolons to separate `AC_DEFINE' or `AC_DEFINE_UNQUOTED' calls from +other macro calls or shell code; that can cause syntax errors in the +resulting `configure' script. Use either spaces or newlines. That is, +do this: + + AC_CHECK_HEADER(elf.h, AC_DEFINE(SVR4) LIBS="$LIBS -lelf") + +or this: + + AC_CHECK_HEADER(elf.h, + AC_DEFINE(SVR4) + LIBS="$LIBS -lelf") + +instead of this: + + AC_CHECK_HEADER(elf.h, AC_DEFINE(SVR4); LIBS="$LIBS -lelf") + + +File: autoconf.info, Node: Setting Output Variables, Next: Caching Results, Prev: Defining Symbols, Up: Results + +Setting Output Variables +======================== + + One way to record the results of tests is to set "output variables", +which are shell variables whose values are substituted into files that +`configure' outputs. The two macros below create new output variables. +*Note Preset Output Variables::, for a list of output variables that +are always available. + + - Macro: AC_SUBST (VARIABLE) + Create an output variable from a shell variable. Make `AC_OUTPUT' + substitute the variable VARIABLE into output files (typically one + or more `Makefile's). This means that `AC_OUTPUT' will replace + instances of `@VARIABLE@' in input files with the value that the + shell variable VARIABLE has when `AC_OUTPUT' is called. The value + of VARIABLE should not contain literal newlines. + + - Macro: AC_SUBST_FILE (VARIABLE) + Another way to create an output variable from a shell variable. + Make `AC_OUTPUT' insert (without substitutions) the contents of + the file named by shell variable VARIABLE into output files. This + means that `AC_OUTPUT' will replace instances of `@VARIABLE@' in + output files (such as `Makefile.in') with the contents of the file + that the shell variable VARIABLE names when `AC_OUTPUT' is called. + Set the variable to `/dev/null' for cases that do not have a file + to insert. + + This macro is useful for inserting `Makefile' fragments containing + special dependencies or other `make' directives for particular host + or target types into `Makefile's. For example, `configure.in' + could contain: + + AC_SUBST_FILE(host_frag)dnl + host_frag=$srcdir/conf/sun4.mh + + and then a `Makefile.in' could contain: + + @host_frag@ + + +File: autoconf.info, Node: Caching Results, Next: Printing Messages, Prev: Setting Output Variables, Up: Results + +Caching Results +=============== + + To avoid checking for the same features repeatedly in various +`configure' scripts (or repeated runs of one script), `configure' saves +the results of many of its checks in a "cache file". If, when a +`configure' script runs, it finds a cache file, it reads from it the +results from previous runs and avoids rerunning those checks. As a +result, `configure' can run much faster than if it had to perform all +of the checks every time. + + - Macro: AC_CACHE_VAL (CACHE-ID, COMMANDS-TO-SET-IT) + Ensure that the results of the check identified by CACHE-ID are + available. If the results of the check were in the cache file + that was read, and `configure' was not given the `--quiet' or + `--silent' option, print a message saying that the result was + cached; otherwise, run the shell commands COMMANDS-TO-SET-IT. + Those commands should have no side effects except for setting the + variable CACHE-ID. In particular, they should not call + `AC_DEFINE'; the code that follows the call to `AC_CACHE_VAL' + should do that, based on the cached value. Also, they should not + print any messages, for example with `AC_MSG_CHECKING'; do that + before calling `AC_CACHE_VAL', so the messages are printed + regardless of whether the results of the check are retrieved from + the cache or determined by running the shell commands. If the + shell commands are run to determine the value, the value will be + saved in the cache file just before `configure' creates its output + files. *Note Cache Variable Names::, for how to choose the name + of the CACHE-ID variable. + +* Menu: + +* Cache Variable Names:: Shell variables used in caches. +* Cache Files:: Files `configure' uses for caching. + + +File: autoconf.info, Node: Cache Variable Names, Next: Cache Files, Up: Caching Results + +Cache Variable Names +-------------------- + + The names of cache variables should have the following format: + + PACKAGE-PREFIX_cv_VALUE-TYPE_SPECIFIC-VALUE[_ADDITIONAL-OPTIONS] + +for example, `ac_cv_header_stat_broken' or +`ac_cv_prog_gcc_traditional'. The parts of the variable name are: + +PACKAGE-PREFIX + An abbreviation for your package or organization; the same prefix + you begin local Autoconf macros with, except lowercase by + convention. For cache values used by the distributed Autoconf + macros, this value is `ac'. + +`_cv_' + Indicates that this shell variable is a cache value. + +VALUE-TYPE + A convention for classifying cache values, to produce a rational + naming system. The values used in Autoconf are listed in *Note + Macro Names::. + +SPECIFIC-VALUE + Which member of the class of cache values this test applies to. + For example, which function (`alloca'), program (`gcc'), or output + variable (`INSTALL'). + +ADDITIONAL-OPTIONS + Any particular behavior of the specific member that this test + applies to. For example, `broken' or `set'. This part of the + name may be omitted if it does not apply. + + Like their names, the values that may be assigned to cache variables +have a few restrictions. The values may not contain single quotes or +curly braces. Usually, their values will be boolean (`yes' or `no') or +the names of files or functions; so this is not an important +restriction. + + +File: autoconf.info, Node: Cache Files, Prev: Cache Variable Names, Up: Caching Results + +Cache Files +----------- + + A cache file is a shell script that caches the results of configure +tests run on one system so they can be shared between configure scripts +and configure runs. It is not useful on other systems. If its contents +are invalid for some reason, the user may delete or edit it. + + By default, configure uses `./config.cache' as the cache file, +creating it if it does not exist already. `configure' accepts the +`--cache-file=FILE' option to use a different cache file; that is what +`configure' does when it calls `configure' scripts in subdirectories, +so they share the cache. Giving `--cache-file=/dev/null' disables +caching, for debugging `configure'. *Note Subdirectories::, for +information on configuring subdirectories with the `AC_CONFIG_SUBDIRS' +macro. `config.status' only pays attention to the cache file if it is +given the `--recheck' option, which makes it rerun `configure'. + + It is wrong to try to distribute cache files for particular system +types. There is too much room for error in doing that, and too much +administrative overhead in maintaining them. For any features that +can't be guessed automatically, use the standard method of the canonical +system type and linking files (*note Manual Configuration::.). + + The cache file on a particular system will gradually accumulate +whenever someone runs a `configure' script; it will be initially +nonexistent. Running `configure' merges the new cache results with the +existing cache file. The site initialization script can specify a +site-wide cache file to use instead of the default, to make it work +transparently, as long as the same C compiler is used every time (*note +Site Defaults::.). + + +File: autoconf.info, Node: Printing Messages, Prev: Caching Results, Up: Results + +Printing Messages +================= + + `configure' scripts need to give users running them several kinds of +information. The following macros print messages in ways appropriate +for each kind. The arguments to all of them get enclosed in shell +double quotes, so the shell performs variable and backquote substitution +on them. + + These macros are all wrappers around the `echo' shell command. +`configure' scripts should rarely need to run `echo' directly to print +messages for the user. Using these macros makes it easy to change how +and when each kind of message is printed; such changes need only be +made to the macro definitions, and all of the callers change +automatically. + + - Macro: AC_MSG_CHECKING (FEATURE-DESCRIPTION) + Notify the user that `configure' is checking for a particular + feature. This macro prints a message that starts with `checking ' + and ends with `...' and no newline. It must be followed by a call + to `AC_MSG_RESULT' to print the result of the check and the + newline. The FEATURE-DESCRIPTION should be something like + `whether the Fortran compiler accepts C++ comments' or `for c89'. + + This macro prints nothing if `configure' is run with the `--quiet' + or `--silent' option. + + - Macro: AC_MSG_RESULT (RESULT-DESCRIPTION) + Notify the user of the results of a check. RESULT-DESCRIPTION is + almost always the value of the cache variable for the check, + typically `yes', `no', or a file name. This macro should follow a + call to `AC_MSG_CHECKING', and the RESULT-DESCRIPTION should be + the completion of the message printed by the call to + `AC_MSG_CHECKING'. + + This macro prints nothing if `configure' is run with the `--quiet' + or `--silent' option. + + - Macro: AC_MSG_ERROR (ERROR-DESCRIPTION) + Notify the user of an error that prevents `configure' from + completing. This macro prints an error message on the standard + error stream and exits `configure' with a nonzero status. + eRROR-DESCRIPTION should be something like `invalid value $HOME + for \$HOME'. + + - Macro: AC_MSG_WARN (PROBLEM-DESCRIPTION) + Notify the `configure' user of a possible problem. This macro + prints the message on the standard error stream; `configure' + continues running afterward, so macros that call `AC_MSG_WARN' + should provide a default (back-up) behavior for the situations + they warn about. PROBLEM-DESCRIPTION should be something like `ln + -s seems to make hard links'. + + The following two macros are an obsolete alternative to +`AC_MSG_CHECKING' and `AC_MSG_RESULT'. + + - Macro: AC_CHECKING (FEATURE-DESCRIPTION) + This macro is similar to `AC_MSG_CHECKING', except that it prints a + newline after the FEATURE-DESCRIPTION. It is useful mainly to + print a general description of the overall purpose of a group of + feature checks, e.g., + + AC_CHECKING(if stack overflow is detectable) + + - Macro: AC_VERBOSE (RESULT-DESCRIPTION) + This macro is similar to `AC_MSG_RESULT', except that it is meant + to follow a call to `AC_CHECKING' instead of `AC_MSG_CHECKING'; it + starts the message it prints with a tab. It is considered + obsolete. + + +File: autoconf.info, Node: Writing Macros, Next: Manual Configuration, Prev: Results, Up: Top + +Writing Macros +************** + + When you write a feature test that could be applicable to more than +one software package, the best thing to do is encapsulate it in a new +macro. Here are some instructions and guidelines for writing Autoconf +macros. + +* Menu: + +* Macro Definitions:: Basic format of an Autoconf macro. +* Macro Names:: What to call your new macros. +* Quoting:: Protecting macros from unwanted expansion. +* Dependencies Between Macros:: What to do when macros depend on other macros. + + +File: autoconf.info, Node: Macro Definitions, Next: Macro Names, Up: Writing Macros + +Macro Definitions +================= + + Autoconf macros are defined using the `AC_DEFUN' macro, which is +similar to the `m4' builtin `define' macro. In addition to defining a +macro, `AC_DEFUN' adds to it some code which is used to constrain the +order in which macros are called (*note Prerequisite Macros::.). + + An Autoconf macro definition looks like this: + + AC_DEFUN(MACRO-NAME, [MACRO-BODY]) + +The square brackets here do not indicate optional text: they should +literally be present in the macro definition to avoid macro expansion +problems (*note Quoting::.). You can refer to any arguments passed to +the macro as `$1', `$2', etc. + + To introduce comments in `m4', use the `m4' builtin `dnl'; it causes +`m4' to discard the text through the next newline. It is not needed +between macro definitions in `acsite.m4' and `aclocal.m4', because all +output is discarded until `AC_INIT' is called. + + *Note How to define new macros: (m4.info)Definitions, for more +complete information on writing `m4' macros. + + +File: autoconf.info, Node: Macro Names, Next: Quoting, Prev: Macro Definitions, Up: Writing Macros + +Macro Names +=========== + + All of the Autoconf macros have all-uppercase names starting with +`AC_' to prevent them from accidentally conflicting with other text. +All shell variables that they use for internal purposes have +mostly-lowercase names starting with `ac_'. To ensure that your macros +don't conflict with present or future Autoconf macros, you should +prefix your own macro names and any shell variables they use with some +other sequence. Possibilities include your initials, or an abbreviation +for the name of your organization or software package. + + Most of the Autoconf macros' names follow a structured naming +convention that indicates the kind of feature check by the name. The +macro names consist of several words, separated by underscores, going +from most general to most specific. The names of their cache +variables use the same convention (*note Cache Variable Names::., for +more information on them). + + The first word of the name after `AC_' usually tells the category of +feature being tested. Here are the categories used in Autoconf for +specific test macros, the kind of macro that you are more likely to +write. They are also used for cache variables, in all-lowercase. Use +them where applicable; where they're not, invent your own categories. + +`C' + C language builtin features. + +`DECL' + Declarations of C variables in header files. + +`FUNC' + Functions in libraries. + +`GROUP' + UNIX group owners of files. + +`HEADER' + Header files. + +`LIB' + C libraries. + +`PATH' + The full path names to files, including programs. + +`PROG' + The base names of programs. + +`STRUCT' + Definitions of C structures in header files. + +`SYS' + Operating system features. + +`TYPE' + C builtin or declared types. + +`VAR' + C variables in libraries. + + After the category comes the name of the particular feature being +tested. Any further words in the macro name indicate particular aspects +of the feature. For example, `AC_FUNC_UTIME_NULL' checks the behavior +of the `utime' function when called with a `NULL' pointer. + + A macro that is an internal subroutine of another macro should have a +name that starts with the name of that other macro, followed by one or +more words saying what the internal macro does. For example, +`AC_PATH_X' has internal macros `AC_PATH_X_XMKMF' and +`AC_PATH_X_DIRECT'. + + +File: autoconf.info, Node: Quoting, Next: Dependencies Between Macros, Prev: Macro Names, Up: Writing Macros + +Quoting +======= + + Macros that are called by other macros are evaluated by `m4' several +times; each evaluation might require another layer of quotes to prevent +unwanted expansions of macros or `m4' builtins, such as `define' and +`$1'. Quotes are also required around macro arguments that contain +commas, since commas separate the arguments from each other. It's a +good idea to quote any macro arguments that contain newlines or calls +to other macros, as well. + + Autoconf changes the `m4' quote characters from the default ``' and +`'' to `[' and `]', because many of the macros use ``' and `'', +mismatched. However, in a few places the macros need to use brackets +(usually in C program text or regular expressions). In those places, +they use the `m4' builtin command `changequote' to temporarily change +the quote characters to `<<' and `>>'. (Sometimes, if they don't need +to quote anything, they disable quoting entirely instead by setting the +quote characters to empty strings.) Here is an example: + + AC_TRY_LINK( + changequote(<<, >>)dnl + <<#include <time.h> + #ifndef tzname /* For SGI. */ + extern char *tzname[]; /* RS6000 and others reject char **tzname. */ + #endif>>, + changequote([, ])dnl + [atoi(*tzname);], ac_cv_var_tzname=yes, ac_cv_var_tzname=no) + + When you create a `configure' script using newly written macros, +examine it carefully to check whether you need to add more quotes in +your macros. If one or more words have disappeared in the `m4' output, +you need more quotes. When in doubt, quote. + + However, it's also possible to put on too many layers of quotes. If +this happens, the resulting `configure' script will contain unexpanded +macros. The `autoconf' program checks for this problem by doing `grep +AC_ configure'. + + +File: autoconf.info, Node: Dependencies Between Macros, Prev: Quoting, Up: Writing Macros + +Dependencies Between Macros +=========================== + + Some Autoconf macros depend on other macros having been called first +in order to work correctly. Autoconf provides a way to ensure that +certain macros are called if needed and a way to warn the user if +macros are called in an order that might cause incorrect operation. + +* Menu: + +* Prerequisite Macros:: Ensuring required information. +* Suggested Ordering:: Warning about possible ordering problems. +* Obsolete Macros:: Warning about old ways of doing things. + + +File: autoconf.info, Node: Prerequisite Macros, Next: Suggested Ordering, Up: Dependencies Between Macros + +Prerequisite Macros +------------------- + + A macro that you write might need to use values that have previously +been computed by other macros. For example, `AC_DECL_YYTEXT' examines +the output of `flex' or `lex', so it depends on `AC_PROG_LEX' having +been called first to set the shell variable `LEX'. + + Rather than forcing the user of the macros to keep track of the +dependencies between them, you can use the `AC_REQUIRE' macro to do it +automatically. `AC_REQUIRE' can ensure that a macro is only called if +it is needed, and only called once. + + - Macro: AC_REQUIRE (MACRO-NAME) + If the `m4' macro MACRO-NAME has not already been called, call it + (without any arguments). Make sure to quote MACRO-NAME with + square brackets. MACRO-NAME must have been defined using + `AC_DEFUN' or else contain a call to `AC_PROVIDE' to indicate that + it has been called. + + An alternative to using `AC_DEFUN' is to use `define' and call +`AC_PROVIDE'. Because this technique does not prevent nested messages, +it is considered obsolete. + + - Macro: AC_PROVIDE (THIS-MACRO-NAME) + Record the fact that THIS-MACRO-NAME has been called. + tHIS-MACRO-NAME should be the name of the macro that is calling + `AC_PROVIDE'. An easy way to get it is from the `m4' builtin + variable `$0', like this: + + AC_PROVIDE([$0]) + + +File: autoconf.info, Node: Suggested Ordering, Next: Obsolete Macros, Prev: Prerequisite Macros, Up: Dependencies Between Macros + +Suggested Ordering +------------------ + + Some macros should be run before another macro if both are called, +but neither *requires* that the other be called. For example, a macro +that changes the behavior of the C compiler should be called before any +macros that run the C compiler. Many of these dependencies are noted in +the documentation. + + Autoconf provides the `AC_BEFORE' macro to warn users when macros +with this kind of dependency appear out of order in a `configure.in' +file. The warning occurs when creating `configure' from +`configure.in', not when running `configure'. For example, +`AC_PROG_CPP' checks whether the C compiler can run the C preprocessor +when given the `-E' option. It should therefore be called after any +macros that change which C compiler is being used, such as +`AC_PROG_CC'. So `AC_PROG_CC' contains: + + AC_BEFORE([$0], [AC_PROG_CPP])dnl + +This warns the user if a call to `AC_PROG_CPP' has already occurred +when `AC_PROG_CC' is called. + + - Macro: AC_BEFORE (THIS-MACRO-NAME, CALLED-MACRO-NAME) + Make `m4' print a warning message on the standard error output if + CALLED-MACRO-NAME has already been called. THIS-MACRO-NAME should + be the name of the macro that is calling `AC_BEFORE'. The macro + CALLED-MACRO-NAME must have been defined using `AC_DEFUN' or else + contain a call to `AC_PROVIDE' to indicate that it has been called. + + +File: autoconf.info, Node: Obsolete Macros, Prev: Suggested Ordering, Up: Dependencies Between Macros + +Obsolete Macros +--------------- + + Configuration and portability technology has evolved over the years. +Often better ways of solving a particular problem are developed, or +ad-hoc approaches are systematized. This process has occurred in many +parts of Autoconf. One result is that some of the macros are now +considered "obsolete"; they still work, but are no longer considered +the best thing to do. Autoconf provides the `AC_OBSOLETE' macro to +warn users producing `configure' scripts when they use obsolete macros, +to encourage them to modernize. A sample call is: + + AC_OBSOLETE([$0], [; use AC_CHECK_HEADERS(unistd.h) instead])dnl + + - Macro: AC_OBSOLETE (THIS-MACRO-NAME [, SUGGESTION]) + Make `m4' print a message on the standard error output warning that + THIS-MACRO-NAME is obsolete, and giving the file and line number + where it was called. THIS-MACRO-NAME should be the name of the + macro that is calling `AC_OBSOLETE'. If SUGGESTION is given, it + is printed at the end of the warning message; for example, it can + be a suggestion for what to use instead of THIS-MACRO-NAME. + + +File: autoconf.info, Node: Manual Configuration, Next: Site Configuration, Prev: Writing Macros, Up: Top + +Manual Configuration +******************** + + A few kinds of features can't be guessed automatically by running +test programs. For example, the details of the object file format, or +special options that need to be passed to the compiler or linker. It is +possible to check for such features using ad-hoc means, such as having +`configure' check the output of the `uname' program, or looking for +libraries that are unique to particular systems. However, Autoconf +provides a uniform method for handling unguessable features. + +* Menu: + +* Specifying Names:: Specifying the system type. +* Canonicalizing:: Getting the canonical system type. +* System Type Variables:: Variables containing the system type. +* Using System Type:: What to do with the system type. + + +File: autoconf.info, Node: Specifying Names, Next: Canonicalizing, Up: Manual Configuration + +Specifying the System Type +========================== + + Like other GNU `configure' scripts, Autoconf-generated `configure' +scripts can make decisions based on a canonical name for the system +type, which has the form: + + CPU-COMPANY-SYSTEM + + `configure' can usually guess the canonical name for the type of +system it's running on. To do so it runs a script called +`config.guess', which derives the name using the `uname' command or +symbols predefined by the C preprocessor. + + Alternately, the user can specify the system type with command line +arguments to `configure'. Doing so is necessary when cross-compiling. +In the most complex case of cross-compiling, three system types are +involved. The options to specify them are: + +`--build=BUILD-TYPE' + the type of system on which the package is being configured and + compiled (rarely needed); + +`--host=HOST-TYPE' + the type of system on which the package will run; + +`--target=TARGET-TYPE' + the type of system for which any compiler tools in the package will + produce code. + +If the user gives `configure' a non-option argument, it is used as the +default for the host, target, and build system types if the user does +not specify them explicitly with options. The target and build types +default to the host type if it is given and they are not. If you are +cross-compiling, you still have to specify the names of the cross-tools +you use, in particular the C compiler, on the `configure' command line, +e.g., + + CC=m68k-coff-gcc configure --target=m68k-coff + + `configure' recognizes short aliases for many system types; for +example, `decstation' can be given on the command line instead of +`mips-dec-ultrix4.2'. `configure' runs a script called `config.sub' to +canonicalize system type aliases. + + +File: autoconf.info, Node: Canonicalizing, Next: System Type Variables, Prev: Specifying Names, Up: Manual Configuration + +Getting the Canonical System Type +================================= + + The following macros make the system type available to `configure' +scripts. They run the shell script `config.guess' to determine any +values for the host, target, and build types that they need and the user +did not specify on the command line. They run `config.sub' to +canonicalize any aliases the user gave. If you use these macros, you +must distribute those two shell scripts along with your source code. +*Note Output::, for information about the `AC_CONFIG_AUX_DIR' macro +which you can use to control which directory `configure' looks for +those scripts in. If you do not use either of these macros, +`configure' ignores any `--host', `--target', and `--build' options +given to it. + + - Macro: AC_CANONICAL_SYSTEM + Determine the system type and set output variables to the names of + the canonical system types. *Note System Type Variables::, for + details about the variables this macro sets. + + - Macro: AC_CANONICAL_HOST + Perform only the subset of `AC_CANONICAL_SYSTEM' relevant to the + host type. This is all that is needed for programs that are not + part of a compiler toolchain. + + +File: autoconf.info, Node: System Type Variables, Next: Using System Type, Prev: Canonicalizing, Up: Manual Configuration + +System Type Variables +===================== + + After calling `AC_CANONICAL_SYSTEM', the following output variables +contain the system type information. After `AC_CANONICAL_HOST', only +the `host' variables below are set. + +``build', `host', `target'' + the canonical system names; + +``build_alias', `host_alias', `target_alias'' + the names the user specified, or the canonical names if + `config.guess' was used; + +``build_cpu', `build_vendor', `build_os'' +``host_cpu', `host_vendor', `host_os'' +``target_cpu', `target_vendor', `target_os'' + the individual parts of the canonical names (for convenience). + + +File: autoconf.info, Node: Using System Type, Prev: System Type Variables, Up: Manual Configuration + +Using the System Type +===================== + + How do you use a canonical system type? Usually, you use it in one +or more `case' statements in `configure.in' to select system-specific C +files. Then link those files, which have names based on the system +name, to generic names, such as `host.h' or `target.c'. The `case' +statement patterns can use shell wildcards to group several cases +together, like in this fragment: + + case "$target" in + i386-*-mach* | i386-*-gnu*) obj_format=aout emulation=mach bfd_gas=yes ;; + i960-*-bout) obj_format=bout ;; + esac + + - Macro: AC_LINK_FILES (SOURCE..., DEST...) + Make `AC_OUTPUT' link each of the existing files SOURCE to the + corresponding link name DEST. Makes a symbolic link if possible, + otherwise a hard link. The DEST and SOURCE names should be + relative to the top level source or build directory. + + For example, this call: + + AC_LINK_FILES(config/${machine}.h config/${obj_format}.h, host.h object.h) + + creates in the current directory `host.h', which is a link to + `SRCDIR/config/${machine}.h', and `object.h', which is a link to + `SRCDIR/config/${obj_format}.h'. + + +File: autoconf.info, Node: Site Configuration, Next: Invoking configure, Prev: Manual Configuration, Up: Top + +Site Configuration +****************** + + `configure' scripts support several kinds of local configuration +decisions. There are ways for users to specify where external software +packages are, include or exclude optional features, install programs +under modified names, and set default values for `configure' options. + +* Menu: + +* External Software:: Working with other optional software. +* Package Options:: Selecting optional features. +* Site Details:: Configuring site details. +* Transforming Names:: Changing program names when installing. +* Site Defaults:: Giving `configure' local defaults. + + +File: autoconf.info, Node: External Software, Next: Package Options, Up: Site Configuration + +Working With External Software +============================== + + Some packages require, or can optionally use, other software packages +which are already installed. The user can give `configure' command +line options to specify which such external software to use. The +options have one of these forms: + + --with-PACKAGE[=ARG] + --without-PACKAGE + + For example, `--with-gnu-ld' means work with the GNU linker instead +of some other linker. `--with-x11' means work with X11. + + The user can give an argument by following the package name with `=' +and the argument. Giving an argument of `no' is for packages that are +used by default; it says to *not* use the package. An argument that is +neither `yes' nor `no' could include a name or number of a version of +the other package, to specify more precisely which other package this +program is supposed to work with. If no argument is given, it defaults +to `yes'. `--without-PACKAGE' is equivalent to `--with-PACKAGE=no'. + + For each external software package that may be used, `configure.in' +should call `AC_ARG_WITH' to detect whether the `configure' user asked +to use it. Whether each package is used or not by default, and which +arguments are valid, is up to you. + + - Macro: AC_ARG_WITH (PACKAGE, HELP-STRING, ACTION-IF-TRUE [, + ACTION-IF-FALSE]) + If the user gave `configure' the option `--with-PACKAGE' or + `--without-PACKAGE', run shell commands ACTION-IF-TRUE. Otherwise + run shell commands ACTION-IF-FALSE. The name PACKAGE indicates + another software package that this program should work with. It + should consist only of alphanumeric characters and dashes. + + The option's argument is available to the shell commands + ACTION-IF-TRUE in the shell variable `withval'. + + The argument HELP-STRING is a description of the option which + looks like this: + --with-readline support fancy command line editing + + HELP-STRING may be more than one line long, if more detail is + needed. Just make sure the columns line up in `configure --help'. + Avoid tabs in the help string. You'll need to enclose it in `[' + and `]' in order to produce the leading spaces. + + - Macro: AC_WITH (PACKAGE, ACTION-IF-TRUE [, ACTION-IF-FALSE]) + This is an obsolete version of `AC_ARG_WITH' that does not support + providing a help string. + + +File: autoconf.info, Node: Package Options, Next: Site Details, Prev: External Software, Up: Site Configuration + +Choosing Package Options +======================== + + If a software package has optional compile-time features, the user +can give `configure' command line options to specify whether to compile +them. The options have one of these forms: + + --enable-FEATURE[=ARG] + --disable-FEATURE + + These options allow users to choose which optional features to build +and install. `--enable-FEATURE' options should never make a feature +behave differently or cause one feature to replace another. They +should only cause parts of the program to be built rather than left out. + + The user can give an argument by following the feature name with `=' +and the argument. Giving an argument of `no' requests that the feature +*not* be made available. A feature with an argument looks like +`--enable-debug=stabs'. If no argument is given, it defaults to `yes'. +`--disable-FEATURE' is equivalent to `--enable-FEATURE=no'. + + For each optional feature, `configure.in' should call +`AC_ARG_ENABLE' to detect whether the `configure' user asked to include +it. Whether each feature is included or not by default, and which +arguments are valid, is up to you. + + - Macro: AC_ARG_ENABLE (FEATURE, HELP-STRING, ACTION-IF-TRUE [, + ACTION-IF-FALSE]) + If the user gave `configure' the option `--enable-FEATURE' or + `--disable-FEATURE', run shell commands ACTION-IF-TRUE. Otherwise + run shell commands ACTION-IF-FALSE. The name FEATURE indicates an + optional user-level facility. It should consist only of + alphanumeric characters and dashes. + + The option's argument is available to the shell commands + ACTION-IF-TRUE in the shell variable `enableval'. The HELP-STRING + argument is like that of `AC_ARG_WITH' (*note External + Software::.). + + - Macro: AC_ENABLE (FEATURE, ACTION-IF-TRUE [, ACTION-IF-FALSE]) + This is an obsolete version of `AC_ARG_ENABLE' that does not + support providing a help string. + + +File: autoconf.info, Node: Site Details, Next: Transforming Names, Prev: Package Options, Up: Site Configuration + +Configuring Site Details +======================== + + Some software packages require complex site-specific information. +Some examples are host names to use for certain services, company +names, and email addresses to contact. Since some configuration +scripts generated by Metaconfig ask for such information interactively, +people sometimes wonder how to get that information in +Autoconf-generated configuration scripts, which aren't interactive. + + Such site configuration information should be put in a file that is +edited *only by users*, not by programs. The location of the file can +either be based on the `prefix' variable, or be a standard location +such as the user's home directory. It could even be specified by an +environment variable. The programs should examine that file at run +time, rather than at compile time. That approach is more convenient +for users and makes the configuration process simpler than getting the +information while configuring. *Note Variables for Installation +Directories: (standards)Directory Variables, for more information on +where to put data files. + diff --git a/util/autoconf/autoconf.info-4 b/util/autoconf/autoconf.info-4 new file mode 100644 index 0000000..f296435 --- /dev/null +++ b/util/autoconf/autoconf.info-4 @@ -0,0 +1,1123 @@ +This is Info file autoconf.info, produced by Makeinfo-1.55 from the +input file ./autoconf.texi. + +START-INFO-DIR-ENTRY +* Autoconf: (autoconf). Create source code configuration scripts. +END-INFO-DIR-ENTRY + + This file documents the GNU Autoconf package for creating scripts to +configure source code packages using templates and an `m4' macro +package. + + Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. + + Permission is granted to make and distribute verbatim copies of this +manual provided the copyright notice and this permission notice are +preserved on all copies. + + Permission is granted to copy and distribute modified versions of +this manual under the conditions for verbatim copying, provided that +the entire resulting derived work is distributed under the terms of a +permission notice identical to this one. + + Permission is granted to copy and distribute translations of this +manual into another language, under the above conditions for modified +versions, except that this permission notice may be stated in a +translation approved by the Foundation. + + +File: autoconf.info, Node: Transforming Names, Next: Site Defaults, Prev: Site Details, Up: Site Configuration + +Transforming Program Names When Installing +========================================== + + Autoconf supports changing the names of programs when installing +them. In order to use these transformations, `configure.in' must call +the macro `AC_ARG_PROGRAM'. + + - Macro: AC_ARG_PROGRAM + Place in output variable `program_transform_name' a sequence of + `sed' commands for changing the names of installed programs. + + If any of the options described below are given to `configure', + program names are transformed accordingly. Otherwise, if + `AC_CANONICAL_SYSTEM' has been called and a `--target' value is + given that differs from the host type (specified with `--host' or + defaulted by `config.sub'), the target type followed by a dash is + used as a prefix. Otherwise, no program name transformation is + done. + +* Menu: + +* Transformation Options:: `configure' options to transforme names. +* Transformation Examples:: Sample uses of transforming names. +* Transformation Rules:: `Makefile' uses of transforming names. + + +File: autoconf.info, Node: Transformation Options, Next: Transformation Examples, Up: Transforming Names + +Transformation Options +---------------------- + + You can specify name transformations by giving `configure' these +command line options: + +`--program-prefix=PREFIX' + prepend PREFIX to the names; + +`--program-suffix=SUFFIX' + append SUFFIX to the names; + +`--program-transform-name=EXPRESSION' + perform `sed' substitution EXPRESSION on the names. + + +File: autoconf.info, Node: Transformation Examples, Next: Transformation Rules, Prev: Transformation Options, Up: Transforming Names + +Transformation Examples +----------------------- + + These transformations are useful with programs that can be part of a +cross-compilation development environment. For example, a +cross-assembler running on a Sun 4 configured with +`--target=i960-vxworks' is normally installed as `i960-vxworks-as', +rather than `as', which could be confused with a native Sun 4 assembler. + + You can force a program name to begin with `g', if you don't want +GNU programs installed on your system to shadow other programs with the +same name. For example, if you configure GNU `diff' with +`--program-prefix=g', then when you run `make install' it is installed +as `/usr/local/bin/gdiff'. + + As a more sophistocated example, you could use + --program-transform-name='s/^/g/; s/^gg/g/; s/^gless/less/' + +to prepend `g' to most of the program names in a source tree, excepting +those like `gdb' that already have one and those like `less' and +`lesskey' that aren't GNU programs. (That is assuming that you have a +source tree containing those programs that is set up to use this +feature.) + + One way to install multiple versions of some programs simultaneously +is to append a version number to the name of one or both. For example, +if you want to keep Autoconf version 1 around for awhile, you can +configure Autoconf version 2 using `--program-suffix=2' to install the +programs as `/usr/local/bin/autoconf2', `/usr/local/bin/autoheader2', +etc. + + +File: autoconf.info, Node: Transformation Rules, Prev: Transformation Examples, Up: Transforming Names + +Transformation Rules +-------------------- + + Here is how to use the variable `program_transform_name' in a +`Makefile.in': + + transform=@program_transform_name@ + install: all + $(INSTALL_PROGRAM) myprog $(bindir)/`echo myprog|sed '$(transform)'` + + uninstall: + rm -f $(bindir)/`echo myprog|sed '$(transform)'` + +If you have more than one program to install, you can do it in a loop: + + PROGRAMS=cp ls rm + install: + for p in $(PROGRAMS); do \ + $(INSTALL_PROGRAM) $$p $(bindir)/`echo $$p|sed '$(transform)'`; \ + done + + uninstall: + for p in $(PROGRAMS); do \ + rm -f $(bindir)/`echo $$p|sed '$(transform)'`; \ + done + + Whether to do the transformations on documentation files (Texinfo or +`man') is a tricky question; there seems to be no perfect answer, due +to the several reasons for name transforming. Documentation is not +usually particular to a specific architecture, and Texinfo files do not +conflict with system documentation. But they might conflict with +earlier versions of the same files, and `man' pages sometimes do +conflict with system documentation. As a compromise, it is probably +best to do name transformations on `man' pages but not on Texinfo +manuals. + + +File: autoconf.info, Node: Site Defaults, Prev: Transforming Names, Up: Site Configuration + +Setting Site Defaults +===================== + + Autoconf-generated `configure' scripts allow your site to provide +default values for some configuration values. You do this by creating +site- and system-wide initialization files. + + If the environment variable `CONFIG_SITE' is set, `configure' uses +its value as the name of a shell script to read. Otherwise, it reads +the shell script `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Thus, settings in +machine-specific files override those in machine-independent ones in +case of conflict. + + Site files can be arbitrary shell scripts, but only certain kinds of +code are really appropriate to be in them. Because `configure' reads +any cache file after it has read any site files, a site file can define +a default cache file to be shared between all Autoconf-generated +`configure' scripts run on that system. If you set a default cache +file in a site file, it is a good idea to also set the output variable +`CC' in that site file, because the cache file is only valid for a +particular compiler, but many systems have several available. + + Site files are also good places to set default values for other +output variables, such as `CFLAGS', if you need to give them non-default +values: anything you would normally do, repetitively, on the command +line. If you use non-default values for PREFIX or EXEC_PREFIX +(wherever you locate the site file), you can set them in the site file +if you specify it with the `CONFIG_SITE' environment variable. + + You can set some cache values in the site file itself. Doing this is +useful if you are cross-compiling, so it is impossible to check features +that require running a test program. You could "prime the cache" by +setting those values correctly for that system in +`PREFIX/etc/config.site'. To find out the names of the cache variables +you need to set, look for shell variables with `_cv_' in their names in +the affected `configure' scripts, or in the Autoconf `m4' source code +for those macros. + + The cache file is careful to not override any variables set in the +site files. Similarly, you should not override command-line options in +the site files. Your code should check that variables such as `prefix' +and `cache_file' have their default values (as set near the top of +`configure') before changing them. + + Here is a sample file `/usr/share/local/gnu/share/config.site'. The +command `configure --prefix=/usr/share/local/gnu' would read this file +(if `CONFIG_SITE' is not set to a different file). + + # config.site for configure + # + # Default --prefix and --exec-prefix. + test "$prefix" = NONE && prefix=/usr/share/local/gnu + test "$exec_prefix" = NONE && exec_prefix=/usr/local/gnu + # + # Give Autoconf 2.x generated configure scripts a shared default + # cache file for feature test results, architecture-specific. + if test "$cache_file" = ./config.cache; then + cache_file="$prefix/var/config.cache" + # A cache file is only valid for one C compiler. + CC=gcc + fi + + +File: autoconf.info, Node: Invoking configure, Next: Invoking config.status, Prev: Site Configuration, Up: Top + +Running `configure' Scripts +*************************** + + Below are instructions on how to configure a package that uses a +`configure' script, suitable for inclusion as an `INSTALL' file in the +package. A plain-text version of `INSTALL' which you may use comes +with Autoconf. + +* Menu: + +* Basic Installation:: Instructions for typical cases. +* Compilers and Options:: Selecting compilers and optimization. +* Build Directory:: Configuring in a different directory. +* Installation Names:: Installing in different directories. +* Optional Features:: Selecting optional features. +* System Type:: Specifying the system type. +* Sharing Defaults:: Setting site-wide defaults for `configure'. +* Operation Controls:: Changing how `configure' runs. + + +File: autoconf.info, Node: Basic Installation, Next: Compilers and Options, Up: Invoking configure + +Basic Installation +================== + + These are generic installation instructions. + + The `configure' shell script attempts to guess correct values for +various system-dependent variables used during compilation. It uses +those values to create a `Makefile' in each directory of the package. +It may also create one or more `.h' files containing system-dependent +definitions. Finally, it creates a shell script `config.status' that +you can run in the future to recreate the current configuration, a file +`config.cache' that saves the results of its tests to speed up +reconfiguring, and a file `config.log' containing compiler output +(useful mainly for debugging `configure'). + + If you need to do unusual things to compile the package, please try +to figure out how `configure' could check whether to do them, and mail +diffs or instructions to the address given in the `README' so they can +be considered for the next release. If at some point `config.cache' +contains results you don't want to keep, you may remove or edit it. + + The file `configure.in' is used to create `configure' by a program +called `autoconf'. You only need `configure.in' if you want to change +it or regenerate `configure' using a newer version of `autoconf'. + +The simplest way to compile this package is: + + 1. `cd' to the directory containing the package's source code and type + `./configure' to configure the package for your system. If you're + using `csh' on an old version of System V, you might need to type + `sh ./configure' instead to prevent `csh' from trying to execute + `configure' itself. + + Running `configure' takes awhile. While running, it prints some + messages telling which features it is checking for. + + 2. Type `make' to compile the package. + + 3. Optionally, type `make check' to run any self-tests that come with + the package. + + 4. Type `make install' to install the programs and any data files and + documentation. + + 5. You can remove the program binaries and object files from the + source directory by typing `make clean'. To also remove the files + that `configure' created (so you can compile the package for a + different kind of computer), type `make distclean'. + + +File: autoconf.info, Node: Compilers and Options, Next: Build Directory, Prev: Basic Installation, Up: Invoking configure + +Compilers and Options +===================== + + Some systems require unusual options for compilation or linking that +the `configure' script does not know about. You can give `configure' +initial values for variables by setting them in the environment. Using +a Bourne-compatible shell, you can do that on the command line like +this: + CC=c89 CFLAGS=-O2 LIBS=-lposix ./configure + +Or on systems that have the `env' program, you can do it like this: + env CPPFLAGS=-I/usr/local/include LDFLAGS=-s ./configure + + +File: autoconf.info, Node: Build Directory, Next: Installation Names, Prev: Compilers and Options, Up: Invoking configure + +Using a Different Build Directory +================================= + + You can compile the package in a different directory from the one +containing the source code. Doing so allows you to compile it on more +than one kind of computer at the same time. To do this, you must use a +version of `make' that supports the `VPATH' variable, such as GNU +`make'. `cd' to the directory where you want the object files and +executables to go and run the `configure' script. `configure' +automatically checks for the source code in the directory that +`configure' is in and in `..'. + + +File: autoconf.info, Node: Installation Names, Next: Optional Features, Prev: Build Directory, Up: Invoking configure + +Installation Names +================== + + By default, `make install' will install the package's files in +`/usr/local/bin', `/usr/local/man', etc. You can specify an +installation prefix other than `/usr/local' by giving `configure' the +option `--prefix=PATH'. + + You can specify separate installation prefixes for +architecture-specific files and architecture-independent files. If you +give `configure' the option `--exec-prefix=PATH', the package will use +PATH as the prefix for installing programs and libraries. +Documentation and other data files will still use the regular prefix. + + If the package supports it, you can cause programs to be installed +with an extra prefix or suffix on their names by giving `configure' the +option `--program-prefix=PREFIX' or `--program-suffix=SUFFIX'. + + +File: autoconf.info, Node: Optional Features, Next: System Type, Prev: Installation Names, Up: Invoking configure + +Optional Features +================= + + Some packages pay attention to `--enable-FEATURE' options to +`configure', where FEATURE indicates an optional part of the package. +They may also pay attention to `--with-PACKAGE' options, where PACKAGE +is something like `gnu-as' or `x' (for the X Window System). The +`README' should mention any `--enable-' and `--with-' options that the +package recognizes. + + For packages that use the X Window System, `configure' can usually +find the X include and library files automatically, but if it doesn't, +you can use the `configure' options `--x-includes=DIR' and +`--x-libraries=DIR' to specify their locations. + + +File: autoconf.info, Node: System Type, Next: Sharing Defaults, Prev: Optional Features, Up: Invoking configure + +Specifying the System Type +========================== + + There may be some features `configure' can not figure out +automatically, but needs to determine by the type of host the package +will run on. Usually `configure' can figure that out, but if it prints +a message saying it can not guess the host type, give it the +`--host=TYPE' option. TYPE can either be a short name for the system +type, such as `sun4', or a canonical name with three fields: + CPU-COMPANY-SYSTEM + +See the file `config.sub' for the possible values of each field. If +`config.sub' isn't included in this package, then this package doesn't +need to know the host type. + + If you are building compiler tools for cross-compiling, you can also +use the `--target=TYPE' option to select the type of system they will +produce code for and the `--build=TYPE' option to select the type of +system on which you are compiling the package. + + +File: autoconf.info, Node: Sharing Defaults, Next: Operation Controls, Prev: System Type, Up: Invoking configure + +Sharing Defaults +================ + + If you want to set default values for `configure' scripts to share, +you can create a site shell script called `config.site' that gives +default values for variables like `CC', `cache_file', and `prefix'. +`configure' looks for `PREFIX/share/config.site' if it exists, then +`PREFIX/etc/config.site' if it exists. Or, you can set the +`CONFIG_SITE' environment variable to the location of the site script. +A warning: not all `configure' scripts look for a site script. + + +File: autoconf.info, Node: Operation Controls, Prev: Sharing Defaults, Up: Invoking configure + +Operation Controls +================== + + `configure' recognizes the following options to control how it +operates. + +`--cache-file=FILE' + Save the results of the tests in FILE instead of `config.cache'. + Set FILE to `/dev/null' to disable caching, for debugging + `configure'. + +`--help' + Print a summary of the options to `configure', and exit. + +`--quiet' +`--silent' +`-q' + Do not print messages saying which checks are being made. + +`--srcdir=DIR' + Look for the package's source code in directory DIR. Usually + `configure' can determine that directory automatically. + +`--version' + Print the version of Autoconf used to generate the `configure' + script, and exit. + +`configure' also accepts some other, not widely useful, options. + + +File: autoconf.info, Node: Invoking config.status, Next: Questions, Prev: Invoking configure, Up: Top + +Recreating a Configuration +************************** + + The `configure' script creates a file named `config.status' which +describes which configuration options were specified when the package +was last configured. This file is a shell script which, if run, will +recreate the same configuration. + + You can give `config.status' the `--recheck' option to update +itself. This option is useful if you change `configure', so that the +results of some tests might be different from the previous run. The +`--recheck' option re-runs `configure' with the same arguments you used +before, plus the `--no-create' option, which prevent `configure' from +running `config.status' and creating `Makefile' and other files, and +the `--no-recursion' option, which prevents `configure' from running +other `configure' scripts in subdirectories. (This is so other +`Makefile' rules can run `config.status' when it changes; *note +Automatic Remaking::., for an example). + + `config.status' also accepts the options `--help', which prints a +summary of the options to `config.status', and `--version', which +prints the version of Autoconf used to create the `configure' script +that generated `config.status'. + + `config.status' checks several optional environment variables that +can alter its behavior: + + - Variable: CONFIG_SHELL + The shell with which to run `configure' for the `--recheck' + option. It must be Bourne-compatible. The default is `/bin/sh'. + + - Variable: CONFIG_STATUS + The file name to use for the shell script that records the + configuration. The default is `./config.status'. This variable is + useful when one package uses parts of another and the `configure' + scripts shouldn't be merged because they are maintained separately. + + The following variables provide one way for separately distributed +packages to share the values computed by `configure'. Doing so can be +useful if some of the packages need a superset of the features that one +of them, perhaps a common library, does. These variables allow a +`config.status' file to create files other than the ones that its +`configure.in' specifies, so it can be used for a different package. + + - Variable: CONFIG_FILES + The files in which to perform `@VARIABLE@' substitutions. The + default is the arguments given to `AC_OUTPUT' in `configure.in'. + + - Variable: CONFIG_HEADERS + The files in which to substitute C `#define' statements. The + default is the arguments given to `AC_CONFIG_HEADER'; if that + macro was not called, `config.status' ignores this variable. + + These variables also allow you to write `Makefile' rules that +regenerate only some of the files. For example, in the dependencies +given above (*note Automatic Remaking::.), `config.status' is run twice +when `configure.in' has changed. If that bothers you, you can make +each run only regenerate the files for that rule: + + config.h: stamp-h + stamp-h: config.h.in config.status + CONFIG_FILES= CONFIG_HEADERS=config.h ./config.status + echo > stamp-h + + Makefile: Makefile.in config.status + CONFIG_FILES=Makefile CONFIG_HEADERS= ./config.status + +(If `configure.in' does not call `AC_CONFIG_HEADER', there is no need +to set `CONFIG_HEADERS' in the `make' rules.) + + +File: autoconf.info, Node: Questions, Next: Upgrading, Prev: Invoking config.status, Up: Top + +Questions About Autoconf +************************ + + Several questions about Autoconf come up occasionally. Here some of +them are addressed. + +* Menu: + +* Distributing:: Distributing `configure' scripts. +* Why GNU m4:: Why not use the standard `m4'? +* Bootstrapping:: Autoconf and GNU `m4' require each other? +* Why Not Imake:: Why GNU uses `configure' instead of Imake. + + +File: autoconf.info, Node: Distributing, Next: Why GNU m4, Up: Questions + +Distributing `configure' Scripts +================================ + + What are the restrictions on distributing `configure' + scripts that Autoconf generates? How does that affect my + programs that use them? + + There are no restrictions on how the configuration scripts that +Autoconf produces may be distributed or used. In Autoconf version 1, +they were covered by the GNU General Public License. We still +encourage software authors to distribute their work under terms like +those of the GPL, but doing so is not required to use Autoconf. + + Of the other files that might be used with `configure', +`config.h.in' is under whatever copyright you use for your +`configure.in', since it is derived from that file and from the public +domain file `acconfig.h'. `config.sub' and `config.guess' have an +exception to the GPL when they are used with an Autoconf-generated +`configure' script, which permits you to distribute them under the same +terms as the rest of your package. `install-sh' is from the X +Consortium and is not copyrighted. + + +File: autoconf.info, Node: Why GNU m4, Next: Bootstrapping, Prev: Distributing, Up: Questions + +Why Require GNU `m4'? +===================== + + Why does Autoconf require GNU `m4'? + + Many `m4' implementations have hard-coded limitations on the size +and number of macros, which Autoconf exceeds. They also lack several +builtin macros that it would be difficult to get along without in a +sophisticated application like Autoconf, including: + + builtin + indir + patsubst + __file__ + __line__ + + Since only software maintainers need to use Autoconf, and since GNU +`m4' is simple to configure and install, it seems reasonable to require +GNU `m4' to be installed also. Many maintainers of GNU and other free +software already have most of the GNU utilities installed, since they +prefer them. + + +File: autoconf.info, Node: Bootstrapping, Next: Why Not Imake, Prev: Why GNU m4, Up: Questions + +How Can I Bootstrap? +==================== + + If Autoconf requires GNU `m4' and GNU `m4' has an + Autoconf `configure' script, how do I bootstrap? It seems + like a chicken and egg problem! + + This is a misunderstanding. Although GNU `m4' does come with a +`configure' script produced by Autoconf, Autoconf is not required in +order to run the script and install GNU `m4'. Autoconf is only +required if you want to change the `m4' `configure' script, which few +people have to do (mainly its maintainer). + + +File: autoconf.info, Node: Why Not Imake, Prev: Bootstrapping, Up: Questions + +Why Not Imake? +============== + + Why not use Imake instead of `configure' scripts? + + Several people have written addressing this question, so I include +adaptations of their explanations here. + + The following answer is based on one written by Richard Pixley: + + Autoconf generated scripts frequently work on machines which it has +never been set up to handle before. That is, it does a good job of +inferring a configuration for a new system. Imake cannot do this. + + Imake uses a common database of host specific data. For X11, this +makes sense because the distribution is made as a collection of tools, +by one central authority who has control over the database. + + GNU tools are not released this way. Each GNU tool has a maintainer; +these maintainers are scattered across the world. Using a common +database would be a maintenance nightmare. Autoconf may appear to be +this kind of database, but in fact it is not. Instead of listing host +dependencies, it lists program requirements. + + Imake is special-purpose. It is directed at building the X11 +distribution. By comparison to the GNU tools, this is a simple problem. +If you view the GNU suite as a collection of native tools, then the +problems are similar. But the GNU tools are more powerful than that. +The development tools can be configured as cross tools in almost any +host+target permutation. All of these configurations can be installed +concurrently. They can even be configured to share host independent +files across hosts. Imake doesn't address these issues. + + Imake templates are a form of standardization. The GNU coding +standards address the same issues without necessarily imposing the same +restrictions. + + Here is some further explanation, written by Per Bothner: + + One of the advantages of Imake is that it easy to generate large +Makefiles using `cpp''s `#include' and macro mechanisms. However, +`cpp' is not programmable: it has limited conditional facilities, and +no looping. And `cpp' cannot inspect its environment. + + All of these problems are solved by using `sh' instead of `cpp'. +The shell is fully programmable, has macro substitution, can execute +(or source) other shell scripts, and can inspect its environment. + + Paul Eggert elaborates more: + + With Autoconf, installers need not assume that Imake itself is +already installed and working well. This may not seem like much of an +advantage to people who are accustomed to Imake. But on many hosts +Imake is not installed or the default installation is not working well, +and requiring Imake to install a package hinders the acceptance of that +package on those hosts. For example, the Imake template and +configuration files might not be installed properly on a host, or the +Imake build procedure might wrongly assume that all source files are in +one big directory tree, or the Imake configuration might assume one +compiler whereas the package or the installer needs to use another, or +there might be a version mismatch between the Imake expected by the +package and the Imake suported by the host. These problems are much +rarer with Autoconf, where each package comes with its own independent +configuration processor. + + Also, Imake often suffers from unexpected interactions between +`make' and the installer's C preprocessor. The fundamental problem +here is that the C preprocessor was designed to preprocess C programs, +not `Makefile's. This is much less of a problem with Autoconf, which +uses the general-purpose preprocessor `m4', and where the package's +author (rather than the installer) does the preprocessing in a standard +way. + + Finally, Mark Eichin notes: + + Imake isn't all that extensible, either. In order to add new +features to Imake, you need to provide you own project template, and +duplicate most of the features of the existing one. This means that +for a sophisticated project, using the vendor-provided Imake templates +fails to provide any leverage--since they don't cover anything that +your own project needs (unless it is an X11 program). + + On the other side, though: + + The one advantage that Imake has over `configure': `Imakefile's tend +to be much shorter (likewise, less redundant) than `Makefile.in's. +There is a fix to this, however--at least for the Kerberos V5 tree, +we've modified things to call in common `post.in' and `pre.in' +`Makefile' fragments for the entire tree. This means that a lot of +common things don't have to be duplicated, even though they normally +are in `configure' setups. + + +File: autoconf.info, Node: Upgrading, Next: History, Prev: Questions, Up: Top + +Upgrading From Version 1 +************************ + + Autoconf version 2 is mostly backward compatible with version 1. +However, it introduces better ways to do some things, and doesn't +support some of the ugly things in version 1. So, depending on how +sophisticated your `configure.in' files are, you might have to do some +manual work in order to upgrade to version 2. This chapter points out +some problems to watch for when upgrading. Also, perhaps your +`configure' scripts could benefit from some of the new features in +version 2; the changes are summarized in the file `NEWS' in the +Autoconf distribution. + + First, make sure you have GNU `m4' version 1.1 or higher installed, +preferably 1.3 or higher. Versions before 1.1 have bugs that prevent +them from working with Autoconf version 2. Versions 1.3 and later are +much faster than earlier versions, because as of version 1.3, GNU `m4' +has a more efficient implementation of diversions and can freeze its +internal state in a file that it can read back quickly. + +* Menu: + +* Changed File Names:: Files you might rename. +* Changed Makefiles:: New things to put in `Makefile.in'. +* Changed Macros:: Macro calls you might replace. +* Invoking autoupdate:: Replacing old macro names in `configure.in'. +* Changed Results:: Changes in how to check test results. +* Changed Macro Writing:: Better ways to write your own macros. + + +File: autoconf.info, Node: Changed File Names, Next: Changed Makefiles, Up: Upgrading + +Changed File Names +================== + + If you have an `aclocal.m4' installed with Autoconf (as opposed to +in a particular package's source directory), you must rename it to +`acsite.m4'. *Note Invoking autoconf::. + + If you distribute `install.sh' with your package, rename it to +`install-sh' so `make' builtin rules won't inadvertantly create a file +called `install' from it. `AC_PROG_INSTALL' looks for the script under +both names, but it is best to use the new name. + + If you were using `config.h.top' or `config.h.bot', you still can, +but you will have less clutter if you merge them into `acconfig.h'. +*Note Invoking autoheader::. + + +File: autoconf.info, Node: Changed Makefiles, Next: Changed Macros, Prev: Changed File Names, Up: Upgrading + +Changed Makefiles +================= + + Add `@CFLAGS@', `@CPPFLAGS@', and `@LDFLAGS@' in your `Makefile.in' +files, so they can take advantage of the values of those variables in +the environment when `configure' is run. Doing this isn't necessary, +but it's a convenience for users. + + Also add `@configure_input@' in a comment to each input file for +`AC_OUTPUT', so that the output files will contain a comment saying +they were produced by `configure'. Automatically selecting the right +comment syntax for all the kinds of files that people call `AC_OUTPUT' +on became too much work. + + Add `config.log' and `config.cache' to the list of files you remove +in `distclean' targets. + + If you have the following in `Makefile.in': + + prefix = /usr/local + exec_prefix = ${prefix} + +you must change it to: + + prefix = @prefix@ + exec_prefix = @exec_prefix@ + +The old feature of replacing those variables without `@' characters +around them has been removed. + + +File: autoconf.info, Node: Changed Macros, Next: Invoking autoupdate, Prev: Changed Makefiles, Up: Upgrading + +Changed Macros +============== + + Many of the macros were renamed in Autoconf version 2. You can still +use the old names, but the new ones are clearer, and it's easier to find +the documentation for them. *Note Old Macro Names::, for a table +showing the new names for the old macros. Use the `autoupdate' program +to convert your `configure.in' to using the new macro names. *Note +Invoking autoupdate::. + + Some macros have been superseded by similar ones that do the job +better, but are not call-compatible. If you get warnings about calling +obsolete macros while running `autoconf', you may safely ignore them, +but your `configure' script will generally work better if you follow +the advice it prints about what to replace the obsolete macros with. In +particular, the mechanism for reporting the results of tests has +changed. If you were using `echo' or `AC_VERBOSE' (perhaps via +`AC_COMPILE_CHECK'), your `configure' script's output will look better +if you switch to `AC_MSG_CHECKING' and `AC_MSG_RESULT'. *Note Printing +Messages::. Those macros work best in conjunction with cache +variables. *Note Caching Results::. + + +File: autoconf.info, Node: Invoking autoupdate, Next: Changed Results, Prev: Changed Macros, Up: Upgrading + +Using `autoupdate' to Modernize `configure' +=========================================== + + The `autoupdate' program updates a `configure.in' file that calls +Autoconf macros by their old names to use the current macro names. In +version 2 of Autoconf, most of the macros were renamed to use a more +uniform and descriptive naming scheme. *Note Macro Names::, for a +description of the new scheme. Although the old names still work +(*note Old Macro Names::., for a list of the old macro names and the +corresponding new names), you can make your `configure.in' files more +readable and make it easier to use the current Autoconf documentation +if you update them to use the new macro names. + + If given no arguments, `autoupdate' updates `configure.in', backing +up the original version with the suffix `~' (or the value of the +environment variable `SIMPLE_BACKUP_SUFFIX', if that is set). If you +give `autoupdate' an argument, it reads that file instead of +`configure.in' and writes the updated file to the standard output. + +`autoupdate' accepts the following options: + +`--help' +`-h' + Print a summary of the command line options and exit. + +`--macrodir=DIR' +`-m DIR' + Look for the Autoconf macro files in directory DIR instead of the + default installation directory. You can also set the `AC_MACRODIR' + environment variable to a directory; this option overrides the + environment variable. + +`--version' + Print the version number of `autoupdate' and exit. + + +File: autoconf.info, Node: Changed Results, Next: Changed Macro Writing, Prev: Invoking autoupdate, Up: Upgrading + +Changed Results +=============== + + If you were checking the results of previous tests by examining the +shell variable `DEFS', you need to switch to checking the values of the +cache variables for those tests. `DEFS' no longer exists while +`configure' is running; it is only created when generating output +files. This difference from version 1 is because properly quoting the +contents of that variable turned out to be too cumbersome and +inefficient to do every time `AC_DEFINE' is called. *Note Cache +Variable Names::. + + For example, here is a `configure.in' fragment written for Autoconf +version 1: + + AC_HAVE_FUNCS(syslog) + case "$DEFS" in + *-DHAVE_SYSLOG*) ;; + *) # syslog is not in the default libraries. See if it's in some other. + saved_LIBS="$LIBS" + for lib in bsd socket inet; do + AC_CHECKING(for syslog in -l$lib) + LIBS="$saved_LIBS -l$lib" + AC_HAVE_FUNCS(syslog) + case "$DEFS" in + *-DHAVE_SYSLOG*) break ;; + *) ;; + esac + LIBS="$saved_LIBS" + done ;; + esac + + Here is a way to write it for version 2: + + AC_CHECK_FUNCS(syslog) + if test $ac_cv_func_syslog = no; then + # syslog is not in the default libraries. See if it's in some other. + for lib in bsd socket inet; do + AC_CHECK_LIB($lib, syslog, [AC_DEFINE(HAVE_SYSLOG) + LIBS="$LIBS $lib"; break]) + done + fi + + If you were working around bugs in `AC_DEFINE_UNQUOTED' by adding +backslashes before quotes, you need to remove them. It now works +predictably, and does not treat quotes (except backquotes) specially. +*Note Setting Output Variables::. + + All of the boolean shell variables set by Autoconf macros now use +`yes' for the true value. Most of them use `no' for false, though for +backward compatibility some use the empty string instead. If you were +relying on a shell variable being set to something like 1 or `t' for +true, you need to change your tests. + + +File: autoconf.info, Node: Changed Macro Writing, Prev: Changed Results, Up: Upgrading + +Changed Macro Writing +===================== + + When defining your own macros, you should now use `AC_DEFUN' instead +of `define'. `AC_DEFUN' automatically calls `AC_PROVIDE' and ensures +that macros called via `AC_REQUIRE' do not interrupt other macros, to +prevent nested `checking...' messages on the screen. There's no actual +harm in continuing to use the older way, but it's less convenient and +attractive. *Note Macro Definitions::. + + You probably looked at the macros that came with Autoconf as a guide +for how to do things. It would be a good idea to take a look at the new +versions of them, as the style is somewhat improved and they take +advantage of some new features. + + If you were doing tricky things with undocumented Autoconf internals +(macros, variables, diversions), check whether you need to change +anything to account for changes that have been made. Perhaps you can +even use an officially supported technique in version 2 instead of +kludging. Or perhaps not. + + To speed up your locally written feature tests, add caching to them. +See whether any of your tests are of general enough usefulness to +encapsulate into macros that you can share. + + +File: autoconf.info, Node: History, Next: Old Macro Names, Prev: Upgrading, Up: Top + +History of Autoconf +******************* + + You may be wondering, Why was Autoconf originally written? How did +it get into its present form? (Why does it look like gorilla spit?) If +you're not wondering, then this chapter contains no information useful +to you, and you might as well skip it. If you *are* wondering, then +let there be light... + +* Menu: + +* Genesis:: Prehistory and naming of `configure'. +* Exodus:: The plagues of `m4' and Perl. +* Leviticus:: The priestly code of portability arrives. +* Numbers:: Growth and contributors. +* Deuteronomy:: Approaching the promises of easy configuration. + + +File: autoconf.info, Node: Genesis, Next: Exodus, Up: History + +Genesis +======= + + In June 1991 I was maintaining many of the GNU utilities for the Free +Software Foundation. As they were ported to more platforms and more +programs were added, the number of `-D' options that users had to +select in the `Makefile' (around 20) became burdensome. Especially for +me--I had to test each new release on a bunch of different systems. So +I wrote a little shell script to guess some of the correct settings for +the fileutils package, and released it as part of fileutils 2.0. That +`configure' script worked well enough that the next month I adapted it +(by hand) to create similar `configure' scripts for several other GNU +utilities packages. Brian Berliner also adapted one of my scripts for +his CVS revision control system. + + Later that summer, I learned that Richard Stallman and Richard Pixley +were developing similar scripts to use in the GNU compiler tools; so I +adapted my `configure' scripts to support their evolving interface: +using the file name `Makefile.in' as the templates; adding `+srcdir', +the first option (of many); and creating `config.status' files. + + +File: autoconf.info, Node: Exodus, Next: Leviticus, Prev: Genesis, Up: History + +Exodus +====== + + As I got feedback from users, I incorporated many improvements, using +Emacs to search and replace, cut and paste, similar changes in each of +the scripts. As I adapted more GNU utilities packages to use +`configure' scripts, updating them all by hand became impractical. +Rich Murphey, the maintainer of the GNU graphics utilities, sent me mail +saying that the `configure' scripts were great, and asking if I had a +tool for generating them that I could send him. No, I thought, but I +should! So I started to work out how to generate them. And the +journey from the slavery of hand-written `configure' scripts to the +abundance and ease of Autoconf began. + + Cygnus `configure', which was being developed at around that time, +is table driven; it is meant to deal mainly with a discrete number of +system types with a small number of mainly unguessable features (such as +details of the object file format). The automatic configuration system +that Brian Fox had developed for Bash takes a similar approach. For +general use, it seems to me a hopeless cause to try to maintain an +up-to-date database of which features each variant of each operating +system has. It's easier and more reliable to check for most features on +the fly--especially on hybrid systems that people have hacked on +locally or that have patches from vendors installed. + + I considered using an architecture similar to that of Cygnus +`configure', where there is a single `configure' script that reads +pieces of `configure.in' when run. But I didn't want to have to +distribute all of the feature tests with every package, so I settled on +having a different `configure' made from each `configure.in' by a +preprocessor. That approach also offered more control and flexibility. + + I looked briefly into using the Metaconfig package, by Larry Wall, +Harlan Stenn, and Raphael Manfredi, but I decided not to for several +reasons. The `Configure' scripts it produces are interactive, which I +find quite inconvenient; I didn't like the ways it checked for some +features (such as library functions); I didn't know that it was still +being maintained, and the `Configure' scripts I had seen didn't work on +many modern systems (such as System V R4 and NeXT); it wasn't very +flexible in what it could do in response to a feature's presence or +absence; I found it confusing to learn; and it was too big and complex +for my needs (I didn't realize then how much Autoconf would eventually +have to grow). + + I considered using Perl to generate my style of `configure' scripts, +but decided that `m4' was better suited to the job of simple textual +substitutions: it gets in the way less, because output is implicit. +Plus, everyone already has it. (Initially I didn't rely on the GNU +extensions to `m4'.) Also, some of my friends at the University of +Maryland had recently been putting `m4' front ends on several programs, +including `tvtwm', and I was interested in trying out a new language. + + +File: autoconf.info, Node: Leviticus, Next: Numbers, Prev: Exodus, Up: History + +Leviticus +========= + + Since my `configure' scripts determine the system's capabilities +automatically, with no interactive user intervention, I decided to call +the program that generates them Autoconfig. But with a version number +tacked on, that name would be too long for old UNIX file systems, so I +shortened it to Autoconf. + + In the fall of 1991 I called together a group of fellow questers +after the Holy Grail of portability (er, that is, alpha testers) to +give me feedback as I encapsulated pieces of my handwritten scripts in +`m4' macros and continued to add features and improve the techniques +used in the checks. Prominent among the testers were Franc,ois Pinard, +who came up with the idea of making an `autoconf' shell script to run +`m4' and check for unresolved macro calls; Richard Pixley, who +suggested running the compiler instead of searching the file system to +find include files and symbols, for more accurate results; Karl Berry, +who got Autoconf to configure TeX and added the macro index to the +documentation; and Ian Taylor, who added support for creating a C +header file as an alternative to putting `-D' options in a `Makefile', +so he could use Autoconf for his UUCP package. The alpha testers +cheerfully adjusted their files again and again as the names and +calling conventions of the Autoconf macros changed from release to +release. They all contributed many specific checks, great ideas, and +bug fixes. + + +File: autoconf.info, Node: Numbers, Next: Deuteronomy, Prev: Leviticus, Up: History + +Numbers +======= + + In July 1992, after months of alpha testing, I released Autoconf 1.0, +and converted many GNU packages to use it. I was surprised by how +positive the reaction to it was. More people started using it than I +could keep track of, including people working on software that wasn't +part of the GNU Project (such as TCL, FSP, and Kerberos V5). Autoconf +continued to improve rapidly, as many people using the `configure' +scripts reported problems they encountered. + + Autoconf turned out to be a good torture test for `m4' +implementations. UNIX `m4' started to dump core because of the length +of the macros that Autoconf defined, and several bugs showed up in GNU +`m4' as well. Eventually, we realized that we needed to use some +features that only GNU `m4' has. 4.3BSD `m4', in particular, has an +impoverished set of builtin macros; the System V version is better, but +still doesn't provide everything we need. + + More development occurred as people put Autoconf under more stresses +(and to uses I hadn't anticipated). Karl Berry added checks for X11. +david zuhn contributed C++ support. Franc,ois Pinard made it diagnose +invalid arguments. Jim Blandy bravely coerced it into configuring GNU +Emacs, laying the groundwork for several later improvements. Roland +McGrath got it to configure the GNU C Library, wrote the `autoheader' +script to automate the creation of C header file templates, and added a +`--verbose' option to `configure'. Noah Friedman added the +`--macrodir' option and `AC_MACRODIR' environment variable. (He also +coined the term "autoconfiscate" to mean "adapt a software package to +use Autoconf".) Roland and Noah improved the quoting protection in +`AC_DEFINE' and fixed many bugs, especially when I got sick of dealing +with portability problems from February through June, 1993. + + +File: autoconf.info, Node: Deuteronomy, Prev: Numbers, Up: History + +Deuteronomy +=========== + + A long wish list for major features had accumulated, and the effect +of several years of patching by various people had left some residual +cruft. In April 1994, while working for Cygnus Support, I began a major +revision of Autoconf. I added most of the features of the Cygnus +`configure' that Autoconf had lacked, largely by adapting the relevant +parts of Cygnus `configure' with the help of david zuhn and Ken +Raeburn. These features include support for using `config.sub', +`config.guess', `--host', and `--target'; making links to files; and +running `configure' scripts in subdirectories. Adding these features +enabled Ken to convert GNU `as', and Rob Savoye to convert DejaGNU, to +using Autoconf. + + I added more features in response to other peoples' requests. Many +people had asked for `configure' scripts to share the results of the +checks between runs, because (particularly when configuring a large +source tree, like Cygnus does) they were frustratingly slow. Mike +Haertel suggested adding site-specific initialization scripts. People +distributing software that had to unpack on MS-DOS asked for a way to +override the `.in' extension on the file names, which produced file +names like `config.h.in' containing two dots. Jim Avera did an +extensive examination of the problems with quoting in `AC_DEFINE' and +`AC_SUBST'; his insights led to significant improvements. Richard +Stallman asked that compiler output be sent to `config.log' instead of +`/dev/null', to help people debug the Emacs `configure' script. + + I made some other changes because of my dissatisfaction with the +quality of the program. I made the messages showing results of the +checks less ambiguous, always printing a result. I regularized the +names of the macros and cleaned up coding style inconsistencies. I +added some auxiliary utilities that I had developed to help convert +source code packages to use Autoconf. With the help of Franc,ois +Pinard, I made the macros not interrupt each others' messages. (That +feature revealed some performance bottlenecks in GNU `m4', which he +hastily corrected!) I reorganized the documentation around problems +people want to solve. And I began a testsuite, because experience had +shown that Autoconf has a pronounced tendency to regress when we change +it. + + Again, several alpha testers gave invaluable feedback, especially +Franc,ois Pinard, Jim Meyering, Karl Berry, Rob Savoye, Ken Raeburn, +and Mark Eichin. + + Finally, version 2.0 was ready. And there was much rejoicing. (And +I have free time again. I think. Yeah, right.) + diff --git a/util/autoconf/autoconf.texi b/util/autoconf/autoconf.texi new file mode 100644 index 0000000..3ec9655 --- /dev/null +++ b/util/autoconf/autoconf.texi @@ -0,0 +1,5125 @@ +\input texinfo @c -*-texinfo-*- +@c %**start of header +@setfilename autoconf.info +@settitle Autoconf +@c For double-sided printing, uncomment: +@c @setchapternewpage odd +@c %**end of header + +@set EDITION 2.1 +@set VERSION 2.1 +@set UPDATED November 1994 + +@iftex +@finalout +@end iftex + +@ifinfo +@format +START-INFO-DIR-ENTRY +* Autoconf: (autoconf). Create source code configuration scripts. +END-INFO-DIR-ENTRY +@end format + +This file documents the GNU Autoconf package for creating scripts to +configure source code packages using templates and an @code{m4} macro +package. + +Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +@ignore +Permission is granted to process this file through TeX and print the +results, provided the printed document carries copying permission +notice identical to this one except for the removal of this paragraph +(this paragraph not being relevant to the printed manual). + +@end ignore +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation approved +by the Foundation. +@end ifinfo + +@titlepage +@title Autoconf +@subtitle Creating Automatic Configuration Scripts +@subtitle Edition @value{EDITION}, for Autoconf version @value{VERSION} +@subtitle @value{UPDATED} +@author by David MacKenzie +@c I think I've rewritten all of Noah and Roland's contributions by now. + +@page +@vskip 0pt plus 1filll +Copyright @copyright{} 1992, 1993, 1994 Free Software Foundation, Inc. + +Permission is granted to make and distribute verbatim copies of +this manual provided the copyright notice and this permission notice +are preserved on all copies. + +Permission is granted to copy and distribute modified versions of this +manual under the conditions for verbatim copying, provided that the entire +resulting derived work is distributed under the terms of a permission +notice identical to this one. + +Permission is granted to copy and distribute translations of this manual +into another language, under the above conditions for modified versions, +except that this permission notice may be stated in a translation approved +by the Foundation. +@end titlepage + +@c Define an environment variable index. +@defcodeindex ev +@c Define an output variable index. +@defcodeindex ov +@c Define a CPP variable index. +@defcodeindex cv +@c Define a macro index that @@defmac doesn't write to. +@defcodeindex ma + +@node Top, Introduction, , (dir) +@comment node-name, next, previous, up + +@ifinfo +This file documents the GNU Autoconf package for creating scripts to +configure source code packages using templates and an @code{m4} macro +package. This is edition @value{EDITION}, for Autoconf version @value{VERSION}. + +@end ifinfo + +@c The master menu, created with texinfo-master-menu, goes here. + +@menu +* Introduction:: Autoconf's purpose, strengths, and weaknesses. +* Making configure Scripts:: How to organize and produce Autoconf scripts. +* Setup:: Initialization and output. +* Existing Tests:: Macros that check for particular features. +* Writing Tests:: How to write new feature checks. +* Results:: What to do with results from feature checks. +* Writing Macros:: Adding new macros to Autoconf. +* Manual Configuration:: Selecting features that can't be guessed. +* Site Configuration:: Local defaults for @code{configure}. +* Invoking configure:: How to use the Autoconf output. +* Invoking config.status:: Recreating a configuration. +* Questions:: Questions about Autoconf, with answers. +* Upgrading:: Tips for upgrading from version 1. +* History:: History of Autoconf. +* Old Macro Names:: Backward compatibility macros. +* Environment Variable Index:: Index of environment variables used. +* Output Variable Index:: Index of variables set in output files. +* Preprocessor Symbol Index:: Index of C preprocessor symbols defined. +* Macro Index:: Index of Autoconf macros. + + --- The Detailed Node Listing --- + +Making @code{configure} Scripts + +* Writing configure.in:: What to put in an Autoconf input file. +* Invoking autoscan:: Semi-automatic @file{configure.in} writing. +* Invoking ifnames:: Listing the conditionals in source code. +* Invoking autoconf:: How to create configuration scripts. +* Invoking autoreconf:: Remaking multiple @code{configure} scripts. + +Initialization and Output Files + +* Input:: Where Autoconf should find files. +* Output:: Creating output files. +* Makefile Substitutions:: Using output variables in @file{Makefile}s. +* Configuration Headers:: Creating a configuration header file. +* Subdirectories:: Configuring independent packages together. +* Default Prefix:: Changing the default installation prefix. +* Versions:: Version numbers in @code{configure}. + +Substitutions in Makefiles + +* Preset Output Variables:: Output variables that are always set. +* Build Directories:: Compiling in a different directory. +* Automatic Remaking:: Makefile rules for configuring. + +Configuration Header Files + +* Header Templates:: Input for the configuration headers. +* Invoking autoheader:: How to create configuration templates. + +Existing Tests + +* Alternative Programs:: Selecting between alternative programs. +* Libraries:: Library archives that might be missing. +* Library Functions:: C library functions that might be missing. +* Header Files:: Header files that might be missing. +* Structures:: Structures or members that might be missing. +* Typedefs:: @code{typedef}s that might be missing. +* Compiler Characteristics:: C compiler or machine architecture features. +* System Services:: Operating system services. +* UNIX Variants:: Special kludges for specific UNIX variants. + +Alternative Programs + +* Particular Programs:: Special handling to find certain programs. +* Generic Programs:: How to find other programs. + +Library Functions + +* Particular Functions:: Special handling to find certain functions. +* Generic Functions:: How to find other functions. + +Header Files + +* Particular Headers:: Special handling to find certain headers. +* Generic Headers:: How to find other headers. + +Typedefs + +* Particular Typedefs:: Special handling to find certain types. +* Generic Typedefs:: How to find other types. + +Writing Tests + +* Examining Declarations:: Detecting header files and declarations. +* Examining Syntax:: Detecting language syntax features. +* Examining Libraries:: Detecting functions and global variables. +* Run Time:: Testing for run-time features. +* Portable Shell:: Shell script portability pitfalls. +* Testing Values and Files:: Checking strings and files. +* Multiple Cases:: Tests for several possible values. +* Language Choice:: Selecting which language to use for testing. + +Checking Run Time Behavior + +* Test Programs:: Running test programs. +* Guidelines:: General rules for writing test programs. +* Test Functions:: Avoiding pitfalls in test programs. + +Results of Tests + +* Defining Symbols:: Defining C preprocessor symbols. +* Setting Output Variables:: Replacing variables in output files. +* Caching Results:: Speeding up subsequent @code{configure} runs. +* Printing Messages:: Notifying users of progress or problems. + +Caching Results + +* Cache Variable Names:: Shell variables used in caches. +* Cache Files:: Files @code{configure} uses for caching. + +Writing Macros + +* Macro Definitions:: Basic format of an Autoconf macro. +* Macro Names:: What to call your new macros. +* Quoting:: Protecting macros from unwanted expansion. +* Dependencies Between Macros:: What to do when macros depend on other macros. + +Dependencies Between Macros + +* Prerequisite Macros:: Ensuring required information. +* Suggested Ordering:: Warning about possible ordering problems. +* Obsolete Macros:: Warning about old ways of doing things. + +Manual Configuration + +* Specifying Names:: Specifying the system type. +* Canonicalizing:: Getting the canonical system type. +* System Type Variables:: Variables containing the system type. +* Using System Type:: What to do with the system type. + +Site Configuration + +* External Software:: Working with other optional software. +* Package Options:: Selecting optional features. +* Site Details:: Configuring site details. +* Transforming Names:: Changing program names when installing. +* Site Defaults:: Giving @code{configure} local defaults. + +Transforming Program Names When Installing + +* Transformation Options:: @code{configure} options to transforme names. +* Transformation Examples:: Sample uses of transforming names. +* Transformation Rules:: @file{Makefile} uses of transforming names. + +Running @code{configure} Scripts + +* Basic Installation:: Instructions for typical cases. +* Compilers and Options:: Selecting compilers and optimization. +* Build Directory:: Configuring in a different directory. +* Installation Names:: Installing in different directories. +* Optional Features:: Selecting optional features. +* System Type:: Specifying the system type. +* Sharing Defaults:: Setting site-wide defaults for @code{configure}. +* Operation Controls:: Changing how @code{configure} runs. + +Questions About Autoconf + +* Distributing:: Distributing @code{configure} scripts. +* Why GNU m4:: Why not use the standard @code{m4}? +* Bootstrapping:: Autoconf and GNU @code{m4} require each other? +* Why Not Imake:: Why GNU uses @code{configure} instead of Imake. + +Upgrading From Version 1 + +* Changed File Names:: Files you might rename. +* Changed Makefiles:: New things to put in @file{Makefile.in}. +* Changed Macros:: Macro calls you might replace. +* Invoking autoupdate:: Replacing old macro names in @code{configure.in}. +* Changed Results:: Changes in how to check test results. +* Changed Macro Writing:: Better ways to write your own macros. + +History of Autoconf + +* Genesis:: Prehistory and naming of @code{configure}. +* Exodus:: The plagues of @code{m4} and Perl. +* Leviticus:: The priestly code of portability arrives. +* Numbers:: Growth and contributors. +* Deuteronomy:: Approaching the promises of easy configuration. +@end menu + +@node Introduction, Making configure Scripts, Top, Top +@chapter Introduction + +@display +A physicist, an engineer, and a computer scientist were +discussing the nature of God. Surely a Physicist, said the +physicist, because early in the Creation, God made Light; and you +know, Maxwell's equations, the dual nature of electro-magnetic +waves, the relativist consequences@dots{} An Engineer!, said the +engineer, because before making Light, God split the Chaos into +Land and Water; it takes a hell of an engineer to handle that big +amount of mud, and orderly separation of solids from +liquids@dots{} The computer scientist shouted: And the Chaos, +where do you think it was coming from, hmm? + +---Anonymous +@end display +@c (via Franc,ois Pinard) + +Autoconf is a tool for producing shell scripts that automatically +configure software source code packages to adapt to many kinds of +UNIX-like systems. The configuration scripts produced by Autoconf are +independent of Autoconf when they are run, so their users do not need to +have Autoconf. + +The configuration scripts produced by Autoconf require no manual user +intervention when run; they do not normally even need an argument +specifying the system type. Instead, they test for the presence of each +feature that the software package they are for might need individually. +(Before each check, they print a one-line message stating what they are +checking for, so the user doesn't get too bored while waiting for the +script to finish.) As a result, they deal well with systems that are +hybrids or customized from the more common UNIX variants. There is no +need to maintain files that list the features supported by each release +of each variant of UNIX. + +For each software package that Autoconf is used with, it creates a +configuration script from a template file that lists the +system features that the package needs or can use. After the shell code to +recognize and respond to a system feature has been written, +Autoconf allows it to be shared by many software packages that can +use (or need) that feature. If it later turns out that the shell code +needs adjustment for some reason, it needs to be changed in only one +place; all of the configuration scripts can be regenerated +automatically to take advantage of the updated code. + +The Metaconfig package is similar in purpose to Autoconf, but +the scripts it produces require manual user intervention, which is quite +inconvenient when configuring large source trees. Unlike Metaconfig +scripts, Autoconf scripts can support cross-compiling, if some care is +taken in writing them. + +There are several jobs related to making portable software packages +that Autoconf currently does not do. Among these are automatically +creating @file{Makefile} files with all of the standard targets, and +supplying replacements for standard library functions and header files on +systems that lack them. Work is in progress to add those features in +the future. + +Autoconf imposes some restrictions on the names of macros used with +@code{#ifdef} in C programs (@pxref{Preprocessor Symbol Index}). + +Autoconf requires GNU @code{m4} in order to generate the scripts. It +uses features that some UNIX versions of @code{m4} do not have. It also +overflows internal limits of some versions of @code{m4}, including GNU +@code{m4} 1.0. You must use version 1.1 or later of GNU @code{m4}. +Using version 1.3 or later will be much faster than 1.1 or 1.2. + +@xref{Upgrading}, for information about upgrading from version 1. +@xref{History}, for the story of Autoconf's development. +@xref{Questions}, for answers to some common questions about Autoconf. + +Mail suggestions and bug reports for Autoconf to +@code{bug-gnu-utils@@prep.ai.mit.edu}. Please include the Autoconf version +number, which you can get by running @samp{autoconf --version}. + +@node Making configure Scripts, Setup, Introduction, Top +@chapter Making @code{configure} Scripts + +The configuration scripts that Autoconf produces are by convention +called @code{configure}. When run, @code{configure} creates several +files, replacing configuration parameters in them with appropriate +values. The files that @code{configure} creates are: + +@itemize @bullet +@item +one or more @file{Makefile} files, one in each subdirectory of the +package (@pxref{Makefile Substitutions}); + +@item +optionally, a C header file, the name of which is configurable, +containing @code{#define} directives (@pxref{Configuration Headers}); + +@item +a shell script called @file{config.status} that, when run, will recreate +the files listed above (@pxref{Invoking config.status}); + +@item +a shell script called @file{config.cache} that saves the results of +running many of the tests (@pxref{Cache Files}); + +@item +a file called @file{config.log} containing any messages produced by +compilers, to help debugging if @code{configure} makes a mistake. +@end itemize + +To create a @code{configure} script with Autoconf, you need to write an +Autoconf input file @file{configure.in} and run @code{autoconf} on it. +If you write your own feature tests to supplement those that come with +Autoconf, you might also write files called @file{aclocal.m4} and +@file{acsite.m4}. If you use a C header file to contain @code{#define} +directives, you might also write @file{acconfig.h}, and you will +distribute the Autoconf-generated file @file{config.h.in} with the +package. + +Here is a diagram showing how the files that can be used in +configuration are produced. Programs that are executed are suffixed by +@samp{*}. Optional files are enclosed in square brackets (@samp{[]}). +@code{autoconf} and @code{autoheader} also read the installed Autoconf +macro files (by reading @file{autoconf.m4}). + +@noindent +Files used in preparing a software package for distribution: +@example +@group +your source files --> [autoscan*] --> [configure.scan] --> configure.in + +configure.in --. .------> autoconf* -----> configure + +---+ +[aclocal.m4] --+ `---. +[acsite.m4] ---' | + +--> [autoheader*] -> [config.h.in] +[acconfig.h] ----. | + +-----' +[config.h.top] --+ +[config.h.bot] --' + +Makefile.in -------------------------------> Makefile.in +@end group +@end example + +@noindent +Files used in configuring a software package: +@example +@group + .-------------> config.cache +configure* ------------+-------------> config.log + | +[config.h.in] -. v .-> [config.h] -. + +--> config.status* -+ +--> make* +Makefile.in ---' `-> Makefile ---' +@end group +@end example + +@menu +* Writing configure.in:: What to put in an Autoconf input file. +* Invoking autoscan:: Semi-automatic @file{configure.in} writing. +* Invoking ifnames:: Listing the conditionals in source code. +* Invoking autoconf:: How to create configuration scripts. +* Invoking autoreconf:: Remaking multiple @code{configure} scripts. +@end menu + +@node Writing configure.in, Invoking autoscan, , Making configure Scripts +@section Writing @file{configure.in} + +To produce a @code{configure} script for a software package, create a +file called @file{configure.in} that contains invocations of the +Autoconf macros that test the system features your package needs or can +use. Autoconf macros already exist to check for many features; see +@ref{Existing Tests}, for their descriptions. For most other +features, you can use Autoconf template macros to produce custom checks; +see @ref{Writing Tests}, for information about them. For especially +tricky or specialized features, @file{configure.in} might need to +contain some hand-crafted shell commands. The @code{autoscan} +program can give you a good start in writing @file{configure.in} +(@pxref{Invoking autoscan}, for more information). + +The order in which @file{configure.in} calls the Autoconf macros +is not important, with a few exceptions. Every +@file{configure.in} must contain a call to @code{AC_INIT} before +the checks, and a call to @code{AC_OUTPUT} at the end +(@pxref{Output}). Additionally, some macros rely on other macros +having been called first, because they check previously set +values of some variables to decide what to do. These macros are +noted in the individual descriptions (@pxref{Existing Tests}), +and they also warn you when creating @code{configure} if they are +called out of order. + +To encourage consistency, here is a suggested order for calling the +Autoconf macros. Generally speaking, the things near the end of this +list could depend on things earlier in it. For example, library +functions could be affected by typedefs and libraries. + +@display +@group +@code{AC_INIT(@var{file})} +checks for programs +checks for libraries +checks for header files +checks for typedefs +checks for structures +checks for compiler characteristics +checks for library functions +checks for system services +@code{AC_OUTPUT(@r{[}@var{file@dots{}}@r{]})} +@end group +@end display + +It is best to put each macro call on its own line in +@file{configure.in}. Most of the macros don't add extra newlines; they +rely on the newline after the macro call to terminate the commands. +This approach makes the generated @code{configure} script a little +easier to read by not inserting lots of blank lines. It is generally +safe to set shell variables on the same line as a macro call, because +the shell allows assignments without intervening newlines. + +When calling macros that take arguments, there must not be any blank +space between the macro name and the open parenthesis. Arguments can be +more than one line long if they are enclosed within the @code{m4} quote +characters @samp{[} and @samp{]}. If you have a long line such as a +list of file names, you can generally use a backslash at the end of a +line to continue it logically on the next line (this is implemented by +the shell, not by anything special that Autoconf does). + +Some macros handle two cases: what to do if the given condition is met, +and what to do if the condition is not met. In some places you might +want to do something if a condition is true but do nothing if it's +false, or vice versa. To omit the true case, pass an empty value for +the @var{action-if-found} argument to the macro. To omit the false +case, omit the @var{action-if-not-found} argument to the macro, +including the comma before it. + +You can include comments in @file{configure.in} files by starting them +with the @code{m4} builtin macro @code{dnl}, which discards text up +through the next newline. These comments do not appear in the generated +@code{configure} scripts. For example, it is helpful to begin +@file{configure.in} files with a line like this: + +@example +dnl Process this file with autoconf to produce a configure script. +@end example + +@node Invoking autoscan, Invoking ifnames, Writing configure.in, Making configure Scripts +@section Using @code{autoscan} to Create @file{configure.in} + +The @code{autoscan} program can help you create a @file{configure.in} +file for a software package. @code{autoscan} examines source files in +the directory tree rooted at a directory given as a command line +argument, or the current directory if none is given. It searches the +source files for common portability problems and creates a file +@file{configure.scan} which is a preliminary @file{configure.in} for +that package. + +You should manually examine @file{configure.scan} before renaming it to +@file{configure.in}; it will probably need some adjustments. +Occasionally @code{autoscan} outputs a macro in the wrong order relative +to another macro, so that @code{autoconf} produces a warning; you need +to move such macros manually. Also, if you want the package to use a +configuration header file, you must add a call to +@code{AC_CONFIG_HEADER} (@pxref{Configuration Headers}). You might also +have to change or add some @code{#if} directives to your program in +order to make it work with Autoconf (@pxref{Invoking ifnames}, for +information about a program that can help with that job). + +@code{autoscan} uses several data files, which are installed along with the +distributed Autoconf macro files, to determine which macros to output +when it finds particular symbols in a package's source files. These +files all have the same format. Each line consists of a symbol, +whitespace, and the Autoconf macro to output if that symbol is +encountered. Lines starting with @samp{#} are comments. + +@code{autoscan} is only installed if you already have Perl installed. +@code{autoscan} accepts the following options: + +@table @code +@item --help +Print a summary of the command line options and exit. + +@item --macrodir=@var{dir} +@evindex AC_MACRODIR +Look for the data files in directory @var{dir} instead of the default +installation directory. You can also set the @code{AC_MACRODIR} +environment variable to a directory; this option overrides the +environment variable. + +@item --verbose +Print the names of the files it examines and the potentially interesting +symbols it finds in them. This output can be voluminous. + +@item --version +Print the version number of Autoconf and exit. +@end table + +@node Invoking ifnames, Invoking autoconf, Invoking autoscan, Making configure Scripts +@section Using @code{ifnames} to List Conditionals + +@code{ifnames} can help when writing a @file{configure.in} for a +software package. It prints the identifiers that the package already +uses in C preprocessor conditionals. If a package has already been set +up to have some portability, this program can help you figure out what +its @code{configure} needs to check for. It may help fill in some gaps +in a @file{configure.in} generated by @code{autoscan} (@pxref{Invoking +autoscan}). + +@code{ifnames} scans all of the C source files named on the command line +(or the standard input, if none are given) and writes to the standard +output a sorted list of all the identifiers that appear in those files +in @code{#if}, @code{#elif}, @code{#ifdef}, or @code{#ifndef} +directives. It prints each identifier on a line, followed by a +space-separated list of the files in which that identifier occurs. + +@noindent +@code{ifnames} accepts the following options: + +@table @code +@item --help +@itemx -h +Print a summary of the command line options and exit. + +@item --macrodir=@var{dir} +@itemx -m @var{dir} +@evindex AC_MACRODIR +Look for the Autoconf macro files in directory @var{dir} instead of the +default installation directory. Only used to get the version number. +You can also set the @code{AC_MACRODIR} +environment variable to a directory; this option overrides the +environment variable. + +@item --version +Print the version number of Autoconf and exit. +@end table + +@node Invoking autoconf, Invoking autoreconf, Invoking ifnames, Making configure Scripts +@section Using @code{autoconf} to Create @code{configure} + +To create @code{configure} from @file{configure.in}, run the +@code{autoconf} program with no arguments. @code{autoconf} processes +@file{configure.in} with the @code{m4} macro processor, using the +Autoconf macros. If you give @code{autoconf} an argument, it reads that +file instead of @file{configure.in} and writes the configuration script +to the standard output instead of to @code{configure}. If you give +@code{autoconf} the argument @samp{-}, it reads the standard input +instead of @file{configure.in} and writes the configuration script on +the standard output. + +The Autoconf macros are defined in several files. Some of the files are +distributed with Autoconf; @code{autoconf} reads them first. Then it +looks for the optional file @file{acsite.m4} in the directory that +contains the distributed Autoconf macro files, and for the optional file +@file{aclocal.m4} in the current directory. Those files can contain +your site's or the package's own Autoconf macro definitions +(@pxref{Writing Macros}, for more information). If a macro is defined +in more than one of the files that @code{autoconf} reads, the last +definition it reads overrides the earlier ones. + +@code{autoconf} accepts the following options: + +@table @code +@item --help +@itemx -h +Print a summary of the command line options and exit. + +@item --localdir=@var{dir} +@itemx -l @var{dir} +Look for the package file @file{aclocal.m4} in directory @var{dir} +instead of in the current directory. + +@item --macrodir=@var{dir} +@itemx -m @var{dir} +@evindex AC_MACRODIR +Look for the installed macro files in directory @var{dir}. You can also +set the @code{AC_MACRODIR} environment variable to a directory; this +option overrides the environment variable. + +@item --version +Print the version number of Autoconf and exit. +@end table + +@node Invoking autoreconf, , Invoking autoconf, Making configure Scripts +@section Using @code{autoreconf} to Update @code{configure} Scripts + +If you have a lot of Autoconf-generated @code{configure} scripts, the +@code{autoreconf} program can save you some work. It runs +@code{autoconf} (and @code{autoheader}, where appropriate) repeatedly to +remake the Autoconf @code{configure} scripts and configuration header +templates in the directory tree rooted at the current directory. By +default, it only remakes those files that are older than their +@file{configure.in} or (if present) @file{aclocal.m4}. Since +@code{autoheader} does not change the timestamp of its output file if +the file wouldn't be changing, this is not necessarily the minimum +amount of work. If you install a new version of Autoconf, you can make +@code{autoreconf} remake @emph{all} of the files by giving it the +@samp{--force} option. + +If you give @code{autoreconf} the @samp{--macrodir=@var{dir}} or +@samp{--localdir=@var{dir}} options, it passes them down to +@code{autoconf} and @code{autoheader} (with relative paths adjusted +properly). + +@xref{Automatic Remaking}, for @file{Makefile} rules to automatically +remake @code{configure} scripts when their source files change. That +method handles the timestamps of configuration header templates +properly, but does not pass @samp{--macrodir=@var{dir}} or +@samp{--localdir=@var{dir}}. + +@noindent +@code{autoreconf} accepts the following options: + +@table @code +@item --help +@itemx -h +Print a summary of the command line options and exit. + +@item --force +@itemx -f +Remake even @file{configure} scripts and configuration headers that are +newer than their input files (@file{configure.in} and, if present, +@file{aclocal.m4}). + +@item --localdir=@var{dir} +@itemx -l @var{dir} +Look for the package files @file{aclocal.m4} and @file{acconfig.h} (but +not @file{@var{file}.top} and @file{@var{file}.bot}) in directory +@var{dir} instead of in the directory containing each @file{configure.in}. + +@item --macrodir=@var{dir} +@itemx -m @var{dir} +@evindex AC_MACRODIR +Look for the Autoconf macro files in directory @var{dir} instead of the +default installation directory. +You can also set the @code{AC_MACRODIR} +environment variable to a directory; this option overrides the +environment variable. + +@item --verbose +Print the name of each directory where @code{autoreconf} runs +@code{autoconf} (and @code{autoheader}, if appropriate). + +@item --version +Print the version number of Autoconf and exit. +@end table + +@node Setup, Existing Tests, Making configure Scripts, Top +@chapter Initialization and Output Files + +Autoconf-generated @code{configure} scripts need some information about +how to initialize, such as how to find the package's source files; and +about the output files to produce. The following sections describe +initialization and creating output files. + +@menu +* Input:: Where Autoconf should find files. +* Output:: Creating output files. +* Makefile Substitutions:: Using output variables in @file{Makefile}s. +* Configuration Headers:: Creating a configuration header file. +* Subdirectories:: Configuring independent packages together. +* Default Prefix:: Changing the default installation prefix. +* Versions:: Version numbers in @code{configure}. +@end menu + +@node Input, Output, , Setup +@section Finding @code{configure} Input + +Every @code{configure} script must call @code{AC_INIT} before doing +anything else. The only other required macro is @code{AC_OUTPUT} +(@pxref{Output}). + +@defmac AC_INIT (@var{unique-file-in-source-dir}) +@maindex INIT +Process any command-line arguments and find the source code directory. +@var{unique-file-in-source-dir} is some file that is in the package's +source directory; @code{configure} checks for this file's existence to +make sure that the directory that it is told contains the source code in +fact does (@pxref{Invoking configure}, for more information). +@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 +it looks are correct for most cases. + +@defmac AC_CONFIG_AUX_DIR(@var{dir}) +@maindex CONFIG_AUX_DIR +Use the @file{install-sh}, @file{config.sub}, @file{config.guess}, and +Cygnus @code{configure} scripts that are in directory @var{dir}. These +are auxiliary files used in configuration. @var{dir} can be either +absolute or relative to @file{@var{srcdir}}. The default is +@file{@var{srcdir}} or @file{@var{srcdir}/..} or +@file{@var{srcdir}/../..}, whichever is the first that contains +@file{install-sh}. The other files are not checked for, so that using +@code{AC_PROG_INSTALL} does not automatically require distributing the +other auxiliary files. It checks for @file{install.sh} also, but that +name is obsolete because some @code{make} programs have a rule that +creates @file{install} from it if there is no @file{Makefile}. +@end defmac + +@node Output, Makefile Substitutions, Input, Setup +@section Creating Output Files + +Every Autoconf-generated @code{configure} script must finish by calling +@code{AC_OUTPUT}. It is the macro that creates the @file{Makefile}s and +optional other files resulting from configuration. The only other +required macro is @code{AC_INIT} (@pxref{Input}). + +@defmac AC_OUTPUT (@r{[}@var{file}@dots{}@r{] [,}@var{extra-cmds}@r{] [,}@var{init-cmds}@r{]}) +@maindex OUTPUT +Create output files. The @var{file}@dots{} argument is a +whitespace-separated list of output files; it may be empty. This macro +creates each file @file{@var{file}} by copying an input file (by default +named @file{@var{file}.in}), substituting the output variable values. +@xref{Makefile Substitutions}, for more information on using output variables. +@xref{Setting Output Variables}, for more information on creating them. This +macro creates the directory that the file is in if it doesn't exist (but +not the parents of that directory). Usually, @file{Makefile}s are +created this way, but other files, such as @file{.gdbinit}, can be +specified as well. + +If @code{AC_CONFIG_HEADER}, @code{AC_LINK_FILES}, or +@code{AC_CONFIG_SUBDIRS} has been called, this macro also creates the +files named as their arguments. + +A typical call to @code{AC_OUTPUT} looks like this: +@example +AC_OUTPUT(Makefile src/Makefile man/Makefile X/Imakefile) +@end example + +You can override an input file name by appending it to @var{file}, +separated by a colon. For example, +@example +AC_OUTPUT(Makefile:templates/top.mk lib/Makefile:templates/lib.mk) +@end example + +If you pass @var{extra-cmds}, those commands will be inserted into +@file{config.status} to be run after all its other processing. If +@var{init-cmds} are given, they are inserted just before +@var{extra-cmds}, with shell variable, command, and backslash +substitutions performed on them in @code{configure}. You can use +@var{init-cmds} to pass variables from @code{configure} to the +@var{extra-cmds}. +@end defmac + +If you run @code{make} on subdirectories, you should run it using the +@code{make} variable @code{MAKE}. Most versions of @code{make} set +@code{MAKE} to the name of the @code{make} program plus any options it +was given. (But many do not include in it the values of any variables +set on the command line, so those are not passed on automatically.) +Some old versions of @code{make} do not set this variable. The +following macro allows you to use it even with those versions. + +@defmac AC_PROG_MAKE_SET +@maindex PROG_MAKE_SET +@ovindex SET_MAKE +If @code{make} predefines the variable @code{MAKE}, define output +variable @code{SET_MAKE} to be empty. Otherwise, define @code{SET_MAKE} +to contain @samp{MAKE=make}. Calls @code{AC_SUBST} for @code{SET_MAKE}. +@end defmac + +To use this macro, place a line like this in each @file{Makefile.in} +that runs @code{MAKE} on other directories: + +@example +@@SET_MAKE@@ +@end example + +@node Makefile Substitutions, Configuration Headers, Output, Setup +@section Substitutions in Makefiles + +Each subdirectory in a distribution that contains something to be +compiled or installed should come with a file @file{Makefile.in}, from +which @code{configure} will create a @file{Makefile} in that directory. +To create a @file{Makefile}, @code{configure} performs a simple variable +substitution, replacing occurrences of @samp{@@@var{variable}@@} in +@file{Makefile.in} with the value that @code{configure} has determined +for that variable. Variables that are substituted into output files in +this way are called @dfn{output variables}. They are ordinary shell +variables that are set in @code{configure}. To make @code{configure} +substitute a particular variable into the output files, the macro +@code{AC_SUBST} must be called with that variable name as an argument. +Any occurrences of @samp{@@@var{variable}@@} for other variables are +left unchanged. @xref{Setting Output Variables}, for more information on +creating output variables with @code{AC_SUBST}. + +A software package that uses a @code{configure} script should be +distributed with a file @file{Makefile.in}, but no @file{Makefile}; that +way, the user has to properly configure the package for the local system +before compiling it. + +@xref{Makefile Conventions, , Makefile Conventions, standards.info, The +GNU Coding Standards}, for more information on what to put in +@file{Makefile}s. + +@menu +* Preset Output Variables:: Output variables that are always set. +* Build Directories:: Compiling in a different directory. +* Automatic Remaking:: Makefile rules for configuring. +@end menu + +@node Preset Output Variables, Build Directories, , Makefile Substitutions +@subsection Preset Output Variables + +Some output variables are preset by the Autoconf macros. Some of the +Autoconf macros set additional output variables, which are mentioned in +the descriptions for those macros. @xref{Output Variable Index}, for a +complete list of output variables. Here is what each of the preset ones +contains. + +@defvar configure_input +@ovindex configure_input +A comment saying that the file was generated automatically by +@code{configure} and giving the name of the input file. +@code{AC_OUTPUT} adds a comment line containing this variable to the top +of every @file{Makefile} it creates. For other files, you should +reference this variable in a comment at the top of each input file. For +example, an input shell script should begin like this: + +@example +#!/bin/sh +# @@configure_input@@ +@end example + +@noindent +The presence of that line also reminds people editing the file that it +needs to be processed by @code{configure} in order to be used. +@end defvar + +@defvar exec_prefix +@ovindex exec_prefix +The installation prefix for architecture-dependent files. +@end defvar + +@defvar prefix +@ovindex prefix +The installation prefix for architecture-independent files. +@end defvar + +@defvar srcdir +@ovindex srcdir +The directory that contains the source code for that @file{Makefile}. +@end defvar + +@defvar top_srcdir +@ovindex top_srcdir +The top-level source code directory for the package. In the top-level +directory, this is the same as @code{srcdir}. +@end defvar + +@defvar CFLAGS +@ovindex CFLAGS +Debugging and optimization options for the C compiler. If it is not set +in the environment when @code{configure} runs, the default value is set +when you call @code{AC_PROG_CC} (or empty if you don't). @code{configure} +uses this variable when compiling programs to test for C features. +@end defvar + +@defvar CPPFLAGS +@ovindex CPPFLAGS +Header file search directory (@samp{-I@var{dir}}) and any other +miscellaneous options for the C preprocessor and compiler. If it is not +set in the environment when @code{configure} runs, the default value is +empty. @code{configure} uses this variable when compiling or +preprocessing programs to test for C features. +@end defvar + +@defvar CXXFLAGS +@ovindex CXXFLAGS +Debugging and optimization options for the C++ compiler. If it is not +set in the environment when @code{configure} runs, the default value is +set when you call @code{AC_PROG_CXX} (or empty if you don't). +@code{configure} uses this variable when compiling programs to test for +C++ features. +@end defvar + +@defvar DEFS +@ovindex DEFS +@samp{-D} options to pass to the C compiler. If @code{AC_CONFIG_HEADER} +is called, @code{configure} replaces @samp{@@DEFS@@} with +@samp{-DHAVE_CONFIG_H} instead (@pxref{Configuration Headers}). This +variable is not defined while @code{configure} is performing its tests, +only when creating the output files. @xref{Setting Output Variables}, for +how to check the results of previous tests. +@end defvar + +@defvar LDFLAGS +@ovindex LDFLAGS +Stripping (@samp{-s}) and any other miscellaneous options for the +linker. If it is not set in the environment when @code{configure} runs, +the default value is empty. @code{configure} uses this variable when +linking programs to test for C features. +@end defvar + +@defvar LIBS +@ovindex LIBS +@samp{-l} and @samp{-L} options to pass to the linker. +@end defvar + +@node Build Directories, Automatic Remaking, Preset Output Variables, Makefile Substitutions +@subsection Build Directories + +You might want to compile a software package in a different directory +from the one that contains the source code. Doing this allows you to +compile the package for several architectures simultaneously from the +same copy of the source code and keep multiple sets of object files on +disk. + +To support doing this, @code{make} uses the @code{VPATH} variable to +find the files that are in the source directory. GNU @code{make} and +most other recent @code{make} programs can do this. Older @code{make} +programs do not support @code{VPATH}; when using them, the source code +must be in the same directory as the object files. + +To support @code{VPATH}, each @file{Makefile.in} should contain two +lines that look like: + +@example +srcdir = @@srcdir@@ +VPATH = @@srcdir@@ +@end example + +Do not set @code{VPATH} to the value of another variable, for example +@samp{VPATH = $(srcdir)}, because some versions of @code{make} do not do +variable substitutions on the value of @code{VPATH}. + +@code{configure} substitutes in the correct value for @code{srcdir} when +it produces @file{Makefile.in}. + +Do not use the @code{make} variable @code{$<}, which expands to the +pathname of the file in the source directory (found with @code{VPATH}), +except in implicit rules. (An implicit rule is one such as @samp{.c.o}, +which tells how to create a @file{.o} file from a @file{.c} file.) Some +versions of @code{make} do not set @code{$<} in explicit rules; they +expand it to an empty value. + +Instead, @file{Makefile} command lines should always refer to source +files by prefixing them with @samp{$(srcdir)/}. For example: + +@example +time.info: time.texinfo + $(MAKEINFO) $(srcdir)/time.texinfo +@end example + +@node Automatic Remaking, , Build Directories, Makefile Substitutions +@subsection Automatic Remaking + +You can put rules like the following in the top-level @file{Makefile.in} +for a package to automatically update the configuration information when +you change the configuration files. This example includes all of the +optional files, such as @file{aclocal.m4} and those related to +configuration header files. Omit from the @file{Makefile.in} rules any +of these files that your package does not use. + +The @samp{$@{srcdir@}/} prefix is included because of limitations in the +@code{VPATH} mechanism. + +The @file{stamp-} files are necessary because the timestamps of +@file{config.h.in} and @file{config.h} will not be changed if remaking +them does not change their contents. This feature avoids unnecessary +recompilation. You should include the file @file{stamp-h.in} your +package's distribution, so @code{make} will consider @file{config.h.in} +up to date. On some old BSD systems, @code{touch} or any command that +results in an empty file does not update the timestamps, so use a +command like @code{date} as a workaround. + +@example +@group +$@{srcdir@}/configure: configure.in aclocal.m4 + cd $@{srcdir@} && autoconf + +# autoheader might not change config.h.in, so touch a stamp file. +$@{srcdir@}/config.h.in: stamp-h.in +$@{srcdir@}/stamp-h.in: configure.in aclocal.m4 acconfig.h \ + config.h.top config.h.bot + cd $@{srcdir@} && autoheader + date > $@{srcdir@}/stamp-h.in + +config.h: stamp-h +stamp-h: config.h.in config.status + ./config.status + +Makefile: Makefile.in config.status + ./config.status + +config.status: configure + ./config.status --recheck +@end group +@end example + +In addition, you should pass @samp{date > stamp-h} in the @var{extra-cmds} +argument to @code{AC_OUTPUT}, so @file{config.status} will ensure that +@file{config.h} is considered up to date. @xref{Output}, for more +information about @code{AC_OUTPUT}. + +@xref{Invoking config.status}, for more examples of handling +configuration-related dependencies. + +@node Configuration Headers, Subdirectories, Makefile Substitutions, Setup +@section Configuration Header Files + +When a package tests more than a few C preprocessor symbols, the command +lines to pass @samp{-D} options to the compiler can get quite long. +This causes two problems. One is that the @code{make} output is hard to +visually scan for errors. More seriously, the command lines can exceed +the length limits of some operating systems. As an alternative to +passing @samp{-D} options to the compiler, @code{configure} scripts can +create a C header file containing @samp{#define} directives. The +@code{AC_CONFIG_HEADER} macro selects this kind of output. It should be +called right after @code{AC_INIT}. + +The package should @samp{#include} the configuration header file before +any other header files, to prevent inconsistencies in declarations (for +example, if it redefines @code{const}). Use @samp{#include <config.h>} +instead of @samp{#include "config.h"}, and pass the C compiler a +@samp{-I.} option (or @samp{-I..}; whichever directory contains +@file{config.h}). That way, even if the source directory is configured +itself (perhaps to make a distribution), other build directories can +also be configured without finding the @file{config.h} from the source +directory. + +@defmac AC_CONFIG_HEADER (@var{header-to-create} @dots{}) +@maindex CONFIG_HEADER +@cvindex HAVE_CONFIG_H +Make @code{AC_OUTPUT} create the file(s) in the whitespace-separated +list @var{header-to-create} containing C preprocessor @code{#define} +statements, and replace @samp{@@DEFS@@} in generated files with +@samp{-DHAVE_CONFIG_H} instead of the value of @code{DEFS}. The usual +name for @var{header-to-create} is @file{config.h}. + +If @var{header-to-create} already exists and its contents are identical +to what @code{AC_OUTPUT} would put in it, it is left alone. Doing this +allows some changes in configuration without needlessly causing object +files that depend on the header file to be recompiled. + +Usually the input file is named @file{@var{header-to-create}.in}; +however, you can override the input file name by appending it to +@var{header-to-create}, separated by a colon. For example, +@example +AC_CONFIG_HEADER(defines.h:defines.hin) +@end example +@noindent +Doing this allows you to keep your filenames acceptable to MS-DOS. +@end defmac + +@menu +* Header Templates:: Input for the configuration headers. +* Invoking autoheader:: How to create configuration templates. +@end menu + +@node Header Templates, Invoking autoheader, , Configuration Headers +@subsection Configuration Header Templates + +Your distribution should contain a template file that looks as you want +the final header file to look, including comments, with default values +in the @code{#define} statements. For example, suppose your +@file{configure.in} makes these calls: + +@example +AC_CONFIG_HEADER(conf.h) +AC_CHECK_HEADERS(unistd.h) +@end example + +@noindent +Then you could have code like the following in @file{conf.h.in}. +On systems that have @file{unistd.h}, @code{configure} will change the 0 +to a 1. On other systems, it will leave the line unchanged. + +@example +@group +/* Define as 1 if you have unistd.h. */ +#define HAVE_UNISTD_H 0 +@end group +@end example + +Alternately, if your code tests for configuration options using +@code{#ifdef} instead of @code{#if}, a default value can be to +@code{#undef} the variable instead of to define it to a value. On +systems that have @file{unistd.h}, @code{configure} will change the +second line to read @samp{#define HAVE_UNISTD_H 1}. On other systems, +it will comment that line out (in case the system predefines that +symbol). + +@example +@group +/* Define if you have unistd.h. */ +#undef HAVE_UNISTD_H +@end group +@end example + +@node Invoking autoheader, , Header Templates, Configuration Headers +@subsection Using @code{autoheader} to Create @file{config.h.in} + +The @code{autoheader} program can create a template file of C +@samp{#define} statements for @code{configure} to use. If +@file{configure.in} invokes @code{AC_CONFIG_HEADER(@var{file})}, +@code{autoheader} creates @file{@var{file}.in}. Otherwise, +@code{autoheader} creates @file{config.h.in}. + +If you give @code{autoheader} an argument, it uses that file instead of +@file{configure.in} and writes the header file to the standard output +instead of to @file{config.h.in}. If you give @code{autoheader} an +argument of @samp{-}, it reads the standard input instead of +@file{configure.in} and writes the header file to the standard output. + +@code{autoheader} scans @file{configure.in} and figures out which C +preprocessor symbols it might define. It copies comments and +@code{#define} and @code{#undef} statements from a file called +@file{acconfig.h}, which comes with and is installed with Autoconf. It +also uses a file called @file{acconfig.h} in the current directory, if +present. If you @code{AC_DEFINE} any additional symbols, you must +create that file with entries for them. For symbols defined by +@code{AC_CHECK_HEADERS}, @code{AC_CHECK_FUNCS}, @code{AC_CHECK_SIZEOF}, +or @code{AC_CHECK_LIB}, @code{autoheader} generates comments and +@code{#undef} statements itself rather than copying them from a file, +since the possible symbols are effectively limitless. + +The file that @code{autoheader} creates contains mainly @code{#define} +and @code{#undef} statements and their accompanying comments. If +@file{./acconfig.h} contains the string @samp{@@TOP@@}, +@code{autoheader} copies the lines before the line containing +@samp{@@TOP@@} into the top of the file that it generates. Similarly, +if @file{./acconfig.h} contains the string @samp{@@BOTTOM@@}, +@code{autoheader} copies the lines after that line to the end of the +file it generates. Either or both of those strings may be omitted. + +An alternate way to produce the same effect is to create the files +@file{@var{file}.top} (typically @file{config.h.top}) and/or +@file{@var{file}.bot} in the current directory. If they exist, +@code{autoheader} copies them to the beginning and end, respectively, of +its output. Their use is discouraged because they have file names that +contain two periods, and so can not be stored on MS-DOS; also, they are +two more files to clutter up the directory. But if you use the +@samp{--localdir=@var{dir}} option to use an @file{acconfig.h} in another +directory, they give you a way to put custom boilerplate in each +individual @file{config.h.in}. + +@code{autoheader} accepts the following options: + +@table @code +@item --help +@itemx -h +Print a summary of the command line options and exit. + +@item --localdir=@var{dir} +@itemx -l @var{dir} +Look for the package files @file{aclocal.m4} and @file{acconfig.h} (but +not @file{@var{file}.top} and @file{@var{file}.bot}) in directory +@var{dir} instead of in the current directory. + +@item --macrodir=@var{dir} +@itemx -m @var{dir} +@evindex AC_MACRODIR +Look for the installed macro files and @file{acconfig.h} in directory +@var{dir}. You can also set the @code{AC_MACRODIR} environment variable +to a directory; this option overrides the environment variable. + +@item --version +Print the version number of Autoconf and exit. +@end table + +@node Subdirectories, Default Prefix, Configuration Headers, Setup +@section Configuring Other Packages in Subdirectories + +In most situations, calling @code{AC_OUTPUT} is sufficient to produce +@file{Makefile}s in subdirectories. However, @code{configure} scripts +that control more than one independent package can use +@code{AC_CONFIG_SUBDIRS} to run @code{configure} scripts for other +packages in subdirectories. + +@defmac AC_CONFIG_SUBDIRS (@var{dir} @dots{}) +@maindex CONFIG_SUBDIRS +@ovindex subdirs +Make @code{AC_OUTPUT} run @code{configure} in each subdirectory +@var{dir} in the given whitespace-separated list. If a given @var{dir} +is not found, no error is reported, so a @code{configure} script can +configure whichever parts of a large source tree are present. If a +given @var{dir} contains @file{configure.in} but no @code{configure}, +the Cygnus @code{configure} script found by @code{AC_CONFIG_AUXDIR} is +used. The subdirectory @code{configure} scripts are given the same +command line options that were given to this @code{configure} script, +with minor changes if needed (e.g., to adjust a relative path for the +cache file or source directory). This macro also sets the output +variable @code{subdirs} to the list of directories @samp{@var{dir} +@dots{}}. @file{Makefile} rules can use this variable to determine +which subdirectories to recurse into. +@end defmac + +@node Default Prefix, Versions, Subdirectories, Setup +@section Default Prefix + +By default, @code{configure} sets the prefix for files it installs to +@file{/usr/local}. The user of @code{configure} can select a different +prefix using the @samp{--prefix} and @samp{--exec-prefix} options. +There are two ways to change the default: when creating +@code{configure}, and when running it. + +Some software packages might want to install in a directory besides +@file{/usr/local} by default. To accomplish that, use the +@code{AC_PREFIX_DEFAULT} macro. + +@defmac AC_PREFIX_DEFAULT (@var{prefix}) +Set the default installation prefix to @var{prefix} instead of @file{/usr/local}. +@end defmac + +It may be convenient for users to have @code{configure} guess the +installation prefix from the location of a related program that they +have already installed. If you wish to do that, you can call +@code{AC_PREFIX_PROGRAM}. + +@defmac AC_PREFIX_PROGRAM (@var{program}) +@maindex PREFIX_PROGRAM +If the user did not specify an installation prefix (using the +@samp{--prefix} option), guess a value for it by looking for +@var{program} in @code{PATH}, the way the shell does. If @var{program} +is found, set the prefix to the parent of the directory containing +@var{program}; otherwise leave the prefix specified in +@file{Makefile.in} unchanged. For example, if @var{program} is +@code{gcc} and the @code{PATH} contains @file{/usr/local/gnu/bin/gcc}, +set the prefix to @file{/usr/local/gnu}. +@end defmac + +@node Versions, , Default Prefix, Setup +@section Version Numbers in @code{configure} + +The following macros manage version numbers for @code{configure} +scripts. Using them is optional. + +@defmac AC_PREREQ (@var{version}) +@maindex PREREQ +Ensure that a recent enough version of Autoconf is being used. If the +version of Autoconf being used to create @code{configure} is earlier +than @var{version}, print an error message on the standard error output +and do not create @code{configure}. For example: + +@example +AC_PREREQ(1.8) +@end example + +This macro is useful if your @file{configure.in} relies on non-obvious +behavior that changed between Autoconf releases. If it merely needs +recently added macros, then @code{AC_PREREQ} is less useful, because the +@code{autoconf} program already tells the user which macros are not +found. The same thing happens if @file{configure.in} is processed by a +version of Autoconf older than when @code{AC_PREREQ} was added. +@end defmac + +@defmac AC_REVISION (@var{revision-info}) +@maindex REVISION +Copy revision stamp @var{revision-info} into the @code{configure} +script, with any dollar signs or double-quotes removed. This macro lets +you put a revision stamp from @file{configure.in} into @code{configure} +without RCS or CVS changing it when you check in @code{configure}. That +way, you can determine easily which revision of @file{configure.in} a +particular @code{configure} corresponds to. + +It is a good idea to call this macro before @code{AC_INIT} so that the +revision number is near the top of both @file{configure.in} and +@code{configure}. To support doing that, the @code{AC_REVISION} output +begins with @samp{#!/bin/sh}, like the normal start of a +@code{configure} script does. + +For example, this line in @file{configure.in}: + +@c The asis prevents RCS from changing the example in the manual. +@example +AC_REVISION($@asis{Revision: 1.30 }$)dnl +@end example + +@noindent +produces this in @code{configure}: + +@example +#!/bin/sh +# From configure.in Revision: 1.30 +@end example +@end defmac + +@node Existing Tests, Writing Tests, Setup, Top +@chapter Existing Tests + +These macros test for particular system features that packages +might need or want to use. If you need to test for a kind of feature +that none of these macros check for, you can probably do it by calling +primitive test macros with appropriate arguments (@pxref{Writing Tests}). + +These tests print messages telling the user which feature they're +checking for, and what they find. They cache their results for future +@code{configure} runs (@pxref{Caching Results}). + +Some of these macros set output variables. @xref{Makefile +Substitutions}, for how to get their values. The phrase ``define +@var{name}'' is used below as a shorthand to mean ``define C +preprocessor symbol @var{name} to the value 1''. @xref{Defining +Symbols}, for how to get those symbol definitions into your program. + +@menu +* Alternative Programs:: Selecting between alternative programs. +* Libraries:: Library archives that might be missing. +* Library Functions:: C library functions that might be missing. +* Header Files:: Header files that might be missing. +* Structures:: Structures or members that might be missing. +* Typedefs:: @code{typedef}s that might be missing. +* Compiler Characteristics:: C compiler or machine architecture features. +* System Services:: Operating system services. +* UNIX Variants:: Special kludges for specific UNIX variants. +@end menu + +@node Alternative Programs, Libraries, , Existing Tests +@section Alternative Programs + +These macros check for the presence or behavior of particular programs. +They are used to choose between several alternative programs and to +decide what to do once one has been chosen. +If there is no macro specifically defined to check for a program you need, +and you don't need to check for any special properties of +it, then you can use one of the general program check macros. + +@menu +* Particular Programs:: Special handling to find certain programs. +* Generic Programs:: How to find other programs. +@end menu + +@node Particular Programs, Generic Programs, , Alternative Programs +@subsection Particular Program Checks + +These macros check for particular programs---whether they exist, and +in some cases whether they support certain features. + +@defmac AC_DECL_YYTEXT +@maindex DECL_YYTEXT +@cvindex YYTEXT_POINTER +@ovindex LEX_OUTPUT_ROOT +Define @code{YYTEXT_POINTER} if @code{yytext} is a @samp{char *} instead +of a @samp{char []}. Also set output variable @code{LEX_OUTPUT_ROOT} to +the base of the file name that the lexer generates; usually +@file{lex.yy}, but sometimes something else. These results vary +according to whether @code{lex} or @code{flex} is being used. +@end defmac + +@defmac AC_PROG_AWK +@maindex PROG_AWK +@ovindex AWK +Check for @code{mawk}, @code{gawk}, @code{nawk}, and @code{awk}, in that +order, and set output variable @code{AWK} to the first one that it +finds. It tries @code{mawk} first because that is reported to be the +fastest implementation. +@end defmac + +@defmac AC_PROG_CC +@maindex PROG_CC +@ovindex CC +@ovindex CFLAGS +Determine a C compiler to use. If @code{CC} is not already set in the +environment, check for @code{gcc}, and use @code{cc} if it's not found. +Set output variable @code{CC} to the name of the compiler found. + +If using the GNU C compiler, set shell variable @code{GCC} to +@samp{yes}, empty otherwise. If output variable @code{CFLAGS} was +not already set, set it to @samp{-g -O} for the GNU C compiler +(@samp{-O} on systems where GCC does not accept @samp{-g}), or @samp{-g} +for other compilers. +@end defmac + +@defmac AC_PROG_CC_C_O +@maindex PROG_CC_C_O +@cvindex NO_MINUS_C_MINUS_O +If the C compiler does not accept the @samp{-c} and @samp{-o} options +simultaneously, define @code{NO_MINUS_C_MINUS_O}. +@end defmac + +@defmac AC_PROG_CPP +@maindex PROG_CPP +@ovindex CPP +Set output variable @code{CPP} to a command that runs the +C preprocessor. If @samp{$CC -E} doesn't work, it uses @file{/lib/cpp}. +It is only portable to run @code{CPP} on files with a @file{.c} +extension. + +If the current language is C (@pxref{Language Choice}), many of the +specific test macros use the value of @code{CPP} indirectly by calling +@code{AC_TRY_CPP}, @code{AC_CHECK_HEADER}, @code{AC_EGREP_HEADER}, or +@code{AC_EGREP_CPP}. +@end defmac + +@defmac AC_PROG_CXX +@maindex PROG_CXX +@ovindex CXX +@ovindex CXXFLAGS +Determine a C++ compiler to use. Check if the environment variable +@code{CXX} or @code{CCC} (in that order) is set; if so, set output +variable @code{CXX} to its value. Otherwise search for a C++ compiler +under likely names (@code{c++}, @code{g++}, @code{gcc}, @code{CC}, and +@code{cxx}). If none of those checks succeed, as a last resort set +@code{CXX} to @code{gcc}. + +If using the GNU C++ compiler, set shell variable @code{GXX} to +@samp{yes}, empty otherwise. If output variable @code{CXXFLAGS} was +not already set, set it to @samp{-g -O} for the GNU C++ compiler +(@samp{-O} on systems where G++ does not accept @samp{-g}), or @samp{-g} +for other compilers. +@end defmac + +@defmac AC_PROG_CXXCPP +@maindex PROG_CXXCPP +@ovindex CXXCPP +Set output variable @code{CXXCPP} to a command that runs the +C++ preprocessor. If @samp{$CXX -E} doesn't work, it uses @file{/lib/cpp}. +It is only portable to run @code{CXXCPP} on files with a @file{.c}, +@file{.C}, or @file{.cc} extension. + +If the current language is C++ (@pxref{Language Choice}), many of the +specific test macros use the value of @code{CXXCPP} indirectly by +calling @code{AC_TRY_CPP}, @code{AC_CHECK_HEADER}, +@code{AC_EGREP_HEADER}, or @code{AC_EGREP_CPP}. +@end defmac + +@defmac AC_PROG_GCC_TRADITIONAL +@maindex PROG_GCC_TRADITIONAL +@ovindex CC +Add @samp{-traditional} to output variable @code{CC} if using the +GNU C compiler and @code{ioctl} does not work properly without +@samp{-traditional}. That usually happens when the fixed header files +have not been installed on an old system. Since recent versions of the +GNU C compiler fix the header files automatically when installed, this +is becoming a less prevalent problem. +@end defmac + +@defmac AC_PROG_INSTALL +@maindex PROG_INSTALL +@ovindex INSTALL +@ovindex INSTALL_PROGRAM +@ovindex INSTALL_DATA +Set output variable @code{INSTALL} to the path of a BSD compatible +@code{install} program, if one is found in the current @code{PATH}. +Otherwise, set @code{INSTALL} to @samp{@var{dir}/install-sh -c}, +checking the directories specified to @code{AC_CONFIG_AUX_DIR} (or its +default directories) to determine @var{dir} (@pxref{Output}). Also set +the variable @code{INSTALL_PROGRAM} to @samp{$@{INSTALL@}} and +@code{INSTALL_DATA} to @samp{$@{INSTALL@} -m 644}. + +This macro screens out various instances of @code{install} known to not +work. It prefers to find a C program rather than a shell script, for +speed. Instead of @file{install-sh}, it can also use @file{install.sh}, +but that name is obsolete because some @code{make} programs have a rule +that creates @file{install} from it if there is no @file{Makefile}. + +A copy of @file{install-sh} which you may use comes with Autoconf. If +you use @code{AC_PROG_INSTALL}, you must include either +@file{install-sh} or @file{install.sh} in your distribution, or +@code{configure} will produce an error message saying it can't find +them---even if the system you're on has a good @code{install} program. +This check is a safety measure to prevent you from accidentally leaving +that file out, which would prevent your package from installing on +systems that don't have a BSD-compatible @code{install} program. + +If you need to use your own installation program because it has +features not found in standard @code{install} programs, there is no +reason to use @code{AC_PROG_INSTALL}; just put the pathname of your +program into your @file{Makefile.in} files. +@end defmac + +@defmac AC_PROG_LEX +@maindex PROG_LEX +@ovindex LEX +@ovindex LEXLIB +If @code{flex} is found, set output variable @code{LEX} to +@samp{flex} and @code{LEXLIB} to @samp{-lfl}, if that library is in a +standard place. Otherwise set @code{LEX} to @samp{lex} and +@code{LEXLIB} to @samp{-ll}. +@end defmac + +@defmac AC_PROG_LN_S +@maindex PROG_LN_S +@ovindex LN_S +If @samp{ln -s} works on the current filesystem (the operating system +and filesystem support symbolic links), set output +variable @code{LN_S} to @samp{ln -s}, otherwise set it to @samp{ln}. +@end defmac + +@defmac AC_PROG_RANLIB +@maindex PROG_RANLIB +@ovindex RANLIB +Set output variable @code{RANLIB} to @samp{ranlib} if @code{ranlib} +is found, otherwise to @samp{:} (do nothing). +@end defmac + +@defmac AC_PROG_YACC +@maindex PROG_YACC +@ovindex YACC +If @code{bison} is found, set output variable @code{YACC} to +@samp{bison -y}. Otherwise, if @code{byacc} is found, set @code{YACC} +to @samp{byacc}. Otherwise set @code{YACC} to @samp{yacc}. +@end defmac + +@node Generic Programs, , Particular Programs, Alternative Programs +@subsection Generic Program Checks + +These macros are used to find programs not covered by the particular +test macros. If you need to check the behavior of a program as well as +find out whether it is present, you have to write your own test for +it (@pxref{Writing Tests}). + +@defmac AC_CHECK_PROG (@var{variable}, @var{prog-to-check-for}, @var{value-if-found} @r{[}, @var{value-if-not-found}@r{]}) +@maindex CHECK_PROG +Check whether program @var{prog-to-check-for} exists in @code{PATH}. If +it is found, set @var{variable} to @var{value-if-found}, otherwise to +@var{value-if-not-found}, if given. If @var{variable} was already set, +do nothing. Calls @code{AC_SUBST} for @var{variable}. +@end defmac + +@defmac AC_CHECK_PROGS (@var{variable}, @var{progs-to-check-for} @r{[}, @var{value-if-not-found}@r{]}) +@maindex CHECK_PROGS +Check for each program in the whitespace-separated list +@var{progs-to-check-for} exists in @code{PATH}. If it is found, set +@var{variable} to the name of that program. Otherwise, continue +checking the next program in the list. If none of the programs in the +list are found, set @var{variable} to @var{value-if-not-found}; if +@var{value-if-not-found} is not specified, the value of @var{variable} +is not changed. Calls @code{AC_SUBST} for @var{variable}. +@end defmac + +@defmac AC_PATH_PROG (@var{variable}, @var{prog-to-check-for} @r{[}, @var{value-if-not-found}@r{]}) +@maindex PATH_PROG +Like @code{AC_CHECK_PROG}, but set @var{variable} to the entire +path of @var{prog-to-check-for} if found. +@end defmac + +@defmac AC_PATH_PROGS (@var{variable}, @var{progs-to-check-for} @r{[}, @var{value-if-not-found}@r{]}) +@maindex PATH_PROGS +Like @code{AC_CHECK_PROGS}, but if any of @var{progs-to-check-for} +are found, set @var{variable} to the entire path of the program +found. +@end defmac + +@node Libraries, Library Functions, Alternative Programs, Existing Tests +@section Library Files + +The following macros check for the presence of certain C library archive +files. + +@defmac AC_CHECK_LIB (@var{library}, @var{function} @r{[}, @var{action-if-found} @r{[}, @var{action-if-not-found} @r{[}, @var{other-libraries}@r{]]]}) +@maindex CHECK_LIB +Try to ensure that C function @var{function} is available by checking +whether a test C program can be linked with the library @var{library} to +get the function. @var{library} is the base name of the library; e.g., +to check for @samp{-lmp}, use @samp{mp} as the @var{library} argument. + +@var{action-if-found} is a list of shell commands to run if the link +with the library succeeds; @var{action-if-not-found} is a list of shell +commands to run if the link fails. If @var{action-if-found} and +@var{action-if-not-found} are not specified, the default action is to +add @samp{-l@var{library}} to @code{LIBS} and define +@samp{HAVE_LIB@var{library}} (in all capitals). + +If linking with @var{library} results in unresolved symbols, which would +be resolved by linking with additional libraries, give those libraries +as the @var{other-libraries} argument, separated by spaces: @samp{-lX11 +-lXt}. Otherwise this macro will fail to detect that @var{library} is +present, because linking the test program will always fail with +unresolved symbols. +@end defmac + +@defmac AC_HAVE_LIBRARY (@var{library}, @r{[}, @var{action-if-found} @r{[}, @var{action-if-not-found} @r{[}, @var{other-libraries}@r{]]]}) +@maindex HAVE_LIBRARY +This macro is equivalent to calling @code{AC_CHECK_LIB} with a +@var{function} argument of @code{main}. In addition, @var{library} can +be written as any of @samp{foo}, @samp{-lfoo}, or @samp{libfoo.a}. In +all of those cases, the compiler is passed @samp{-lfoo}. However, +@var{library} can not be a shell variable; it must be a literal name. +This macro is considered obsolete. +@end defmac + +@node Library Functions, Header Files, Libraries, Existing Tests +@section Library Functions + +The following macros check for particular C library functions. +If there is no macro specifically defined to check for a function you need, +and you don't need to check for any special properties of +it, then you can use one of the general function check macros. + +@menu +* Particular Functions:: Special handling to find certain functions. +* Generic Functions:: How to find other functions. +@end menu + +@node Particular Functions, Generic Functions, , Library Functions +@subsection Particular Function Checks + +These macros check for particular C functions---whether they exist, and +in some cases how they respond when given certain arguments. + +@defmac AC_FUNC_ALLOCA +@maindex FUNC_ALLOCA +@cvindex C_ALLOCA +@cvindex HAVE_ALLOCA_H +@ovindex ALLOCA +Check how to get @code{alloca}. Tries to get a builtin version by +checking for @file{alloca.h} or the predefined C preprocessor macros +@code{__GNUC__} and @code{_AIX}. If this macro finds @file{alloca.h}, +it defines @code{HAVE_ALLOCA_H}. + +If those attempts fail, it looks for the function in the standard C +library. If any of those methods succeed, it defines +@code{HAVE_ALLOCA}. Otherwise, it sets the output variable +@code{ALLOCA} to @samp{alloca.o} and defines @code{C_ALLOCA} (so +programs can periodically call @samp{alloca(0)} to garbage collect). +This variable is separate from @code{LIBOBJS} so multiple programs can +share the value of @code{ALLOCA} without needing to create an actual +library, in case only some of them use the code in @code{LIBOBJS}. + +This macro does not try to get @code{alloca} from the System V R3 +@file{libPW} or the System V R4 @file{libucb} because those libraries +contain some incompatible functions that cause trouble. Some versions +do not even contain @code{alloca} or contain a buggy version. If you +still want to use their @code{alloca}, use @code{ar} to extract +@file{alloca.o} from them instead of compiling @file{alloca.c}. + +Source files that use @code{alloca} should start with a piece of code +like the following, to declare it properly. In some versions +of AIX, the declaration of @code{alloca} must precede everything else +except for comments and preprocessor directives. The @code{#pragma} +directive is indented so that pre-ANSI C compilers will ignore it, +rather than choke on it. + +@example +@group +/* AIX requires this to be the first thing in the file. */ +#ifdef __GNUC__ +# define alloca __builtin_alloca +#else +# if HAVE_ALLOCA_H +# include <alloca.h> +# else +# ifdef _AIX + #pragma alloca +# else +# ifndef alloca /* predefined by HP cc +Olibcalls */ +char *alloca (); +# endif +# endif +# endif +#endif +@end group +@end example +@end defmac + +@defmac AC_FUNC_CLOSEDIR_VOID +@maindex FUNC_CLOSEDIR_VOID +@cvindex CLOSEDIR_VOID +If the @code{closedir} function does not return a meaningful value, +define @code{CLOSEDIR_VOID}. Otherwise, callers ought to check its +return value for an error indicator. +@end defmac + +@defmac AC_FUNC_GETLOADAVG +@maindex FUNC_GETLOADAVG +@cvindex SVR4 +@cvindex DGUX +@cvindex UMAX +@cvindex UMAX4_3 +@cvindex NLIST_STRUCT +@cvindex NLIST_NAME_UNION +@cvindex GETLODAVG_PRIVILEGED +@cvindex NEED_SETGID +@ovindex LIBOBJS +@ovindex NEED_SETGID +@ovindex KMEM_GROUP +Check how to get the system load averages. If the system has the +@code{getloadavg} function, this macro defines @code{HAVE_GETLOADAVG}, +and adds to @code{LIBS} any libraries needed to get that function. + +Otherwise, it adds @samp{getloadavg.o} to the output variable +@code{LIBOBJS}, and possibly defines several other C preprocessor +macros and output variables: + +@enumerate +@item +It defines @code{SVR4}, @code{DGUX}, @code{UMAX}, or @code{UMAX4_3} if +on those systems. + +@item +If it finds @file{nlist.h}, it defines @code{NLIST_STRUCT}. + +@item +If @samp{struct nlist} has an @samp{n_un} member, it defines +@code{NLIST_NAME_UNION}. + +@item +If compiling @file{getloadavg.c} defines @code{LDAV_PRIVILEGED}, +programs need to be installed specially on this system for +@code{getloadavg} to work, and this macro defines +@code{GETLOADAVG_PRIVILEGED}. + +@item +This macro sets the output variable @code{NEED_SETGID}. The value is +@samp{true} if special installation is required, @samp{false} if not. +If @code{NEED_SETGID} is @samp{true}, this macro sets @code{KMEM_GROUP} +to the name of the group that should own the installed program. +@end enumerate +@end defmac + +@defmac AC_FUNC_GETMNTENT +@maindex FUNC_GETMNTENT +@cvindex HAVE_GETMNTENT +Check for the @code{getmntent} in the @file{sun} and @file{seq} +libraries, for Irix 4 and PTX, respectively. Then, if @code{getmntent} is +available, define @code{HAVE_GETMNTENT}. +@end defmac + +@defmac AC_FUNC_MEMCMP +@maindex FUNC_MEMCMP +@ovindex LIBOBJS +If the @code{memcmp} function is not available, or does not work on +8-bit data (like the one on SunOS 4.1.3), add @samp{memcmp.o} to output +variable @code{LIBOBJS}. +@end defmac + +@defmac AC_FUNC_MMAP +@maindex FUNC_MMAP +@cvindex HAVE_MMAP +If the @code{mmap} function exists and works correctly on memory mapped +files, define @code{HAVE_MMAP}. +@end defmac + +@defmac AC_FUNC_SETVBUF_REVERSED +@maindex FUNC_SETVBUF_REVERSED +@cvindex SETVBUF_REVERSED +If @code{setvbuf} takes the buffering type as its second argument and +the buffer pointer as the third, instead of the other way around, define +@code{SETVBUF_REVERSED}. This is the case on System V before release 3. +@end defmac + +@defmac AC_FUNC_STRCOLL +@maindex FUNC_STRCOLL +@cvindex HAVE_STRCOLL +If the @code{strcoll} function exists and works correctly, define +@code{HAVE_STRCOLL}. This does a bit more than +@samp{AC_CHECK_FUNCS(strcoll)}, because some systems have incorrect +definitions of @code{strcoll}, which should not be used. +@end defmac + +@defmac AC_FUNC_STRFTIME +@maindex FUNC_STRFTIME +@cvindex HAVE_STRFTIME +Check for @code{strftime} in the @file{intl} library, for SCO UNIX. +Then, if @code{strftime} is available, define @code{HAVE_STRFTIME}. +@end defmac + +@defmac AC_FUNC_UTIME_NULL +@maindex FUNC_UTIME_NULL +@cvindex HAVE_UTIME_NULL +If @samp{utime(@var{file}, NULL)} sets @var{file}'s timestamp to +the present, define @code{HAVE_UTIME_NULL}. +@end defmac + +@defmac AC_FUNC_VFORK +@maindex FUNC_VFORK +@cvindex HAVE_VFORK_H +@cvindex vfork +If @file{vfork.h} is found, define @code{HAVE_VFORK_H}. If a working +@code{vfork} is not found, define @code{vfork} to be @code{fork}. This +macro checks for several known errors in implementations of @code{vfork} +and considers the system to not have a working @code{vfork} if it +detects any of them. +@end defmac + +@defmac AC_FUNC_VPRINTF +@maindex FUNC_VPRINTF +@cvindex HAVE_VPRINTF +@cvindex HAVE_DOPRNT +If @code{vprintf} is found, define @code{HAVE_VPRINTF}. Otherwise, if +@code{_doprnt} is found, define @code{HAVE_DOPRNT}. (If @code{vprintf} +is available, you may assume that @code{vfprintf} and @code{vsprintf} +are also available.) +@end defmac + +@defmac AC_FUNC_WAIT3 +@maindex FUNC_WAIT3 +@cvindex HAVE_WAIT3 +If @code{wait3} is found and fills in the contents of its third argument +(a @samp{struct rusage *}), which HP-UX does not do, define +@code{HAVE_WAIT3}. +@end defmac + +@node Generic Functions, , Particular Functions, Library Functions +@subsection Generic Function Checks + +These macros are used to find functions not covered by the particular +test macros. If the functions might be in libraries other than the +default C library, first call @code{AC_CHECK_LIB} for those libraries. +If you need to check the behavior of a function as well as find out +whether it is present, you have to write your own test for +it (@pxref{Writing Tests}). + +@defmac AC_CHECK_FUNC (@var{function}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]}) +@maindex CHECK_FUNC +If C function @var{function} is available, run shell commands +@var{action-if-found}, otherwise @var{action-if-not-found}. If you just +want to define a symbol if the function is available, consider using +@code{AC_CHECK_FUNCS} instead. This macro checks for functions with C +linkage even when @code{AC_LANG_CPLUSPLUS} has been called, since C++ is +more standardized than C is. (@pxref{Language Choice}, for more +information about selecting the language for checks.) +@end defmac + +@defmac AC_CHECK_FUNCS (@var{function}@dots{} @r{[}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]]}) +@maindex CHECK_FUNCS +@cvindex HAVE_@var{function} +For each given @var{function} in the whitespace-separated argument list +that is available, define @code{HAVE_@var{function}} (in all capitals). If +@var{action-if-found} is given, it is additional shell code to execute +when one of the functions is found. You can give it a value of +@samp{break} to break out of the loop on the first match. If +@var{action-if-not-found} is given, it is executed when one of the +functions is not found. +@end defmac + +@defmac AC_REPLACE_FUNCS (@var{function-name}@dots{}) +@maindex REPLACE_FUNCS +@ovindex LIBOBJS +For each given @var{function-name} in the whitespace-separated argument +list that is not in the C library, add @samp{@var{function-name}.o} to +the value of the output variable @code{LIBOBJS}. +@end defmac + +@node Header Files, Structures, Library Functions, Existing Tests +@section Header Files + +The following macros check for the presence of certain C header files. +If there is no macro specifically defined to check for a header file you need, +and you don't need to check for any special properties of +it, then you can use one of the general header file check macros. + +@menu +* Particular Headers:: Special handling to find certain headers. +* Generic Headers:: How to find other headers. +@end menu + +@node Particular Headers, Generic Headers, , Header Files +@subsection Particular Header Checks + +These macros check for particular system header files---whether they +exist, and in some cases whether they declare certain symbols. + +@defmac AC_DECL_SYS_SIGLIST +@maindex DECL_SYS_SIGLIST +@cvindex SYS_SIGLIST_DECLARED +Define @code{SYS_SIGLIST_DECLARED} if the variable @code{sys_siglist} is +declared in a system header file, either @file{signal.h} or +@file{unistd.h}. +@end defmac + +@defmac AC_DIR_HEADER +@maindex DIR_HEADER +@cvindex DIRENT +@cvindex SYSDIR +@cvindex SYSNDIR +@cvindex NDIR +@cvindex VOID_CLOSEDIR +Like calling @code{AC_HEADER_DIRENT} and @code{AC_FUNC_CLOSEDIR_VOID}, +but defines a different set of C preprocessor macros to indicate which +header file is found. This macro and the names it defines are +considered obsolete. The names it defines are: + +@c The printed table looks too spaced out with blank lines between the entries. +@table @file +@item dirent.h +@code{DIRENT} +@item sys/ndir.h +@code{SYSNDIR} +@item sys/dir.h +@code{SYSDIR} +@item ndir.h +@code{NDIR} +@end table + +In addition, if the @code{closedir} function does not return a +meaningful value, define @code{VOID_CLOSEDIR}. +@end defmac + +@defmac AC_HEADER_DIRENT +@maindex HEADER_DIRENT +@cvindex HAVE_DIRENT_H +@cvindex HAVE_NDIR_H +@cvindex HAVE_SYS_DIR_H +@cvindex HAVE_SYS_NDIR_H +Check for the following header files, and for the first one that is +found and defines @samp{DIR}, define the listed C preprocessor macro: + +@c The printed table looks too spaced out with blank lines between the entries. +@table @file +@item dirent.h +@code{HAVE_DIRENT_H} +@item sys/ndir.h +@code{HAVE_SYS_NDIR_H} +@item sys/dir.h +@code{HAVE_SYS_DIR_H} +@item ndir.h +@code{HAVE_NDIR_H} +@end table + +The directory library declarations in the source code should look +something like the following: + +@example +@group +#if HAVE_DIRENT_H +# include <dirent.h> +# define NAMLEN(dirent) strlen((dirent)->d_name) +#else +# define dirent direct +# define NAMLEN(dirent) (dirent)->d_namlen +# if HAVE_SYS_NDIR_H +# include <sys/ndir.h> +# endif +# if HAVE_SYS_DIR_H +# include <sys/dir.h> +# endif +# if HAVE_NDIR_H +# include <ndir.h> +# endif +#endif +@end group +@end example + +Using the above declarations, the program would declare variables to be +type @code{struct dirent}, not @code{struct direct}, and would access +the length of a directory entry name by passing a pointer to a +@code{struct dirent} to the @code{NAMLEN} macro. + +This macro also checks for the SCO Xenix @file{dir} and @file{x} libraries. +@end defmac + +@defmac AC_HEADER_MAJOR +@maindex HEADER_MAJOR +@cvindex MAJOR_IN_MKDEV +@cvindex MAJOR_IN_SYSMACROS +If @file{sys/types.h} does not define @code{major}, @code{minor}, and +@code{makedev}, but @file{sys/mkdev.h} does, define +@code{MAJOR_IN_MKDEV}; otherwise, if @file{sys/sysmacros.h} does, define +@code{MAJOR_IN_SYSMACROS}. +@end defmac + +@defmac AC_HEADER_STDC +@maindex HEADER_STDC +@cvindex STDC_HEADERS +Define @code{STDC_HEADERS} if the system has ANSI C header files. +Specifically, this macro checks for @file{stdlib.h}, @file{stdarg.h}, +@file{string.h}, and @file{float.h}; if the system has those, it +probably has the rest of the ANSI C header files. This macro also +checks whether @file{string.h} declares @code{memchr} (and thus +presumably the other @code{mem} functions), whether @file{stdlib.h} +declare @code{free} (and thus presumably @code{malloc} and other related +functions), and whether the @file{ctype.h} macros work on characters +with the high bit set, as ANSI C requires. + +Use @code{STDC_HEADERS} instead of @code{__STDC__} to determine whether +the system has ANSI-compliant header files (and probably C library +functions) because many systems that have GCC do not have ANSI C header +files. + +On systems without ANSI C headers, there is so much variation that it is +probably easier to declare the functions you use than to figure out +exactly what the system header files declare. Some systems contain a +mix of functions ANSI and BSD; some are mostly ANSI but lack +@samp{memmove}; some define the BSD functions as macros in +@file{string.h} or @file{strings.h}; some have only the BSD functions +but @file{string.h}; some declare the memory functions in +@file{memory.h}, some in @file{string.h}; etc. It is probably +sufficient to check for one string function and one memory function; if +the library has the ANSI versions of those then it probably has most of +the others. If you put the following in @file{configure.in}: + +@example +AC_HEADER_STDC +AC_CHECK_FUNCS(strchr memcpy) +@end example + +@noindent +then, in your code, you can put declarations like this: + +@example +@group +#if STDC_HEADERS +# include <string.h> +#else +# ifndef HAVE_STRCHR +# define strchr index +# define strrchr rindex +# endif +char *strchr (), *strrchr (); +# ifndef HAVE_MEMCPY +# define memcpy(d, s, n) bcopy ((s), (d), (n)) +# define memmove(d, s, n) bcopy ((s), (d), (n)) +# endif +#endif +@end group +@end example + +@noindent +If you use a function like @code{memchr}, @code{memset}, @code{strtok}, +or @code{strspn}, which have no BSD equivalent, then macros won't +suffice; you must provide an implementation of each function. An easy +way to incorporate your implementations only when needed (since the ones +in system C libraries may be hand optimized) is to, taking @code{memchr} +for example, put it in @file{memchr.c} and use +@samp{AC_REPLACE_FUNCS(memchr)}. +@end defmac + +@defmac AC_HEADER_SYS_WAIT +@maindex HEADER_SYS_WAIT +@cvindex HAVE_SYS_WAIT_H +If @file{sys/wait.h} exists and is compatible with POSIX.1, define +@code{HAVE_SYS_WAIT_H}. Incompatibility can occur if @file{sys/wait.h} +does not exist, or if it uses the old BSD @code{union wait} instead of +@code{int} to store a status value. If @file{sys/wait.h} is not POSIX.1 +compatible, then instead of including it, define the POSIX.1 macros with +their usual interpretations. Here is an example: + +@example +@group +#include <sys/types.h> +#if HAVE_SYS_WAIT_H +# include <sys/wait.h> +#endif +#ifndef WEXITSTATUS +# define WEXITSTATUS(stat_val) ((unsigned)(stat_val) >> 8) +#endif +#ifndef WIFEXITED +# define WIFEXITED(stat_val) (((stat_val) & 255) == 0) +#endif +@end group +@end example +@end defmac + +@defmac AC_MEMORY_H +@maindex MEMORY_H +@cvindex NEED_MEMORY_H +Define @code{NEED_MEMORY_H} if @code{memcpy}, @code{memcmp}, etc. are +not declared in @file{string.h} and @file{memory.h} exists. This macro +is obsolete; instead, use @code{AC_CHECK_HEADERS(memory.h)}. See the +example for @code{AC_HEADER_STDC}. +@end defmac + +@defmac AC_UNISTD_H +@maindex UNISTD_H +@cvindex HAVE_UNISTD_H +Define @code{HAVE_UNISTD_H} if the system has @file{unistd.h}. This +macro is obsolete; instead, use @samp{AC_CHECK_HEADERS(unistd.h)}. + +The way to check if the system supports POSIX.1 is: + +@example +@group +#if HAVE_UNISTD_H +# include <sys/types.h> +# include <unistd.h> +#endif + +#ifdef _POSIX_VERSION +/* Code for POSIX.1 systems. */ +#endif +@end group +@end example + +@cvindex _POSIX_VERSION +@code{_POSIX_VERSION} is defined when @file{unistd.h} is included on +POSIX.1 systems. If there is no @file{unistd.h}, it is definitely not a +POSIX.1 system. However, some non-POSIX.1 systems do have @file{unistd.h}. +@end defmac + +@defmac AC_USG +@maindex USG +@cvindex USG +Define @code{USG} if the system does not have @file{strings.h}, +@code{rindex}, @code{bzero}, etc. This implies that it has +@file{string.h}, @code{strrchr}, @code{memset}, etc. + +The symbol @code{USG} is obsolete. Instead of this macro, see the +example for @code{AC_HEADER_STDC}. +@end defmac + +@node Generic Headers, , Particular Headers, Header Files +@subsection Generic Header Checks + +These macros are used to find system header files not covered by the +particular test macros. If you need to check the contents of a header +as well as find out whether it is present, you have to write your own +test for it (@pxref{Writing Tests}). + +@defmac AC_CHECK_HEADER (@var{header-file}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]}) +@maindex CHECK_HEADER +If the system header file @var{header-file} exists, execute shell commands +@var{action-if-found}, otherwise execute @var{action-if-not-found}. If +you just want to define a symbol if the header file is available, +consider using @code{AC_CHECK_HEADERS} instead. +@end defmac + +@defmac AC_CHECK_HEADERS (@var{header-file}@dots{} @r{[}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]]}) +@maindex CHECK_HEADERS +@cvindex HAVE_@var{header} +For each given system header file @var{header-file} in the +whitespace-separated argument list that exists, define +@code{HAVE_@var{header-file}} (in all capitals). If @var{action-if-found} +is given, it is additional shell code to execute when one of the header +files is found. You can give it a value of @samp{break} to break out of +the loop on the first match. If @var{action-if-not-found} is given, it +is executed when one of the header files is not found. +@end defmac + +@node Structures, Typedefs, Header Files, Existing Tests +@section Structures + +The following macros check for certain structures or structure members. +To check structures not listed here, use @code{AC_EGREP_CPP} +(@pxref{Examining Declarations}) or @code{AC_TRY_COMPILE} +(@pxref{Examining Syntax}). + +@defmac AC_HEADER_STAT +@maindex HEADER_STAT +@maindex STAT_MACROS_BROKEN +If the macros @code{S_ISDIR}, @code{S_ISREG} et al. defined in +@file{sys/stat.h} do not work properly (returning false positives), +define @code{STAT_MACROS_BROKEN}. This is the case on Tektronix UTekV, +Amdahl UTS and Motorola System V/88. +@end defmac + +@defmac AC_HEADER_TIME +@maindex HEADER_TIME +@cvindex TIME_WITH_SYS_TIME +If a program may include both @file{time.h} and @file{sys/time.h}, +define @code{TIME_WITH_SYS_TIME}. On some older systems, +@file{sys/time.h} includes @file{time.h}, but @file{time.h} is not +protected against multiple inclusion, so programs should not explicitly +include both files. This macro is useful in programs that use, for +example, @code{struct timeval} or @code{struct timezone} as well as +@code{struct tm}. It is best used in conjunction with +@code{HAVE_SYS_TIME_H}, which can be checked for using +@code{AC_CHECK_HEADERS(sys/time.h)}. + +@example +@group +#if TIME_WITH_SYS_TIME +# include <sys/time.h> +# include <time.h> +#else +# if HAVE_SYS_TIME_H +# include <sys/time.h> +# else +# include <time.h> +# endif +#endif +@end group +@end example +@end defmac + +@defmac AC_STRUCT_ST_BLKSIZE +@maindex STRUCT_ST_BLKSIZE +@cvindex HAVE_ST_BLKSIZE +If @code{struct stat} contains an @code{st_blksize} member, define +@code{HAVE_ST_BLKSIZE}. +@end defmac + +@defmac AC_STRUCT_ST_BLOCKS +@maindex STRUCT_ST_BLOCKS +@cvindex HAVE_ST_BLOCKS +@ovindex LIBOBJS +If @code{struct stat} contains an @code{st_blocks} member, define +@code{HAVE_ST_BLOCKS}. Otherwise, add @samp{fileblocks.o} to the +output variable @code{LIBOBJS}. +@end defmac + +@defmac AC_STRUCT_ST_RDEV +@maindex STRUCT_ST_RDEV +@cvindex HAVE_ST_RDEV +If @code{struct stat} contains an @code{st_rdev} member, define +@code{HAVE_ST_RDEV}. +@end defmac + +@defmac AC_STRUCT_TM +@maindex STRUCT_TM +@cvindex TM_IN_SYS_TIME +If @file{time.h} does not define @code{struct tm}, define +@code{TM_IN_SYS_TIME}, which means that including @file{sys/time.h} +had better define @code{struct tm}. +@end defmac + +@defmac AC_STRUCT_TIMEZONE +@maindex STRUCT_TIMEZONE +@cvindex HAVE_TM_ZONE +@cvindex HAVE_TZNAME +Figure out how to get the current timezone. If @code{struct tm} has a +@code{tm_zone} member, define @code{HAVE_TM_ZONE}. Otherwise, if the +external array @code{tzname} is found, define @code{HAVE_TZNAME}. +@end defmac + +@node Typedefs, Compiler Characteristics, Structures, Existing Tests +@section Typedefs + +The following macros check for C typedefs. If there is no macro +specifically defined to check for a typedef you need, and you don't need +to check for any special properties of it, then you can use a general +typedef check macro. + +@menu +* Particular Typedefs:: Special handling to find certain types. +* Generic Typedefs:: How to find other types. +@end menu + +@node Particular Typedefs, Generic Typedefs, , Typedefs +@subsection Particular Typedef Checks + +These macros check for particular C typedefs in @file{sys/types.h} and +@file{stdlib.h} (if it exists). + +@defmac AC_TYPE_GETGROUPS +@maindex TYPE_GETGROUPS +@cvindex GETGROUPS_T +Define @code{GETGROUPS_T} to be whichever of @code{gid_t} or @code{int} +is the base type of the array argument to @code{getgroups}. +@end defmac + +@defmac AC_TYPE_MODE_T +@maindex TYPE_MODE_T +@cvindex mode_t +If @code{mode_t} is not defined, define @code{mode_t} to be @code{int}. +@end defmac + +@defmac AC_TYPE_OFF_T +@maindex TYPE_OFF_T +@cvindex off_t +If @code{off_t} is not defined, define @code{off_t} to be @code{long}. +@end defmac + +@defmac AC_TYPE_PID_T +@maindex TYPE_PID_T +@cvindex pid_t +If @code{pid_t} is not defined, define @code{pid_t} to be @code{int}. +@end defmac + +@defmac AC_TYPE_SIGNAL +@maindex TYPE_SIGNAL +@cvindex RETSIGTYPE +If @file{signal.h} declares @code{signal} as returning a pointer to a +function returning @code{void}, define @code{RETSIGTYPE} to be +@code{void}; otherwise, define it to be @code{int}. + +Define signal handlers as returning type @code{RETSIGTYPE}: + +@example +@group +RETSIGTYPE +hup_handler () +@{ +@dots{} +@} +@end group +@end example +@end defmac + +@defmac AC_TYPE_SIZE_T +@maindex TYPE_SIZE_T +@cvindex size_t +If @code{size_t} is not defined, define @code{size_t} to be +@code{unsigned}. +@end defmac + +@defmac AC_TYPE_UID_T +@maindex TYPE_UID_T +@cvindex uid_t +@cvindex gid_t +If @code{uid_t} is not defined, define @code{uid_t} to be @code{int} and +@code{gid_t} to be @code{int}. +@end defmac + +@node Generic Typedefs, , Particular Typedefs, Typedefs +@subsection Generic Typedef Checks + +This macro is used to check for typedefs not covered by the particular +test macros. + +@defmac AC_CHECK_TYPE (@var{type}, @var{default}) +@maindex CHECK_TYPE +If the type @var{type} is not defined in @file{sys/types.h} or +@file{stdlib.h} (if it exists), define it to be the C (or C++) +builtin type @var{default}; e.g., @samp{short} or @samp{unsigned}. +@end defmac + +@node Compiler Characteristics, System Services, Typedefs, Existing Tests +@section Compiler Characteristics + +The following macros check for C compiler or machine architecture +features. To check for characteristics not listed here, use +@code{AC_TRY_COMPILE} (@pxref{Examining Syntax}) or @code{AC_TRY_RUN} +(@pxref{Run Time}) + +@defmac AC_C_BIGENDIAN +@maindex C_BIGENDIAN +@cvindex WORDS_BIGENDIAN +If words are stored with the most significant byte first (like Motorola +and SPARC, but not Intel and VAX, CPUs), define @code{WORDS_BIGENDIAN}. +@end defmac + +@defmac AC_C_CONST +@maindex C_CONST +@cvindex const +If the C compiler does not fully support the keyword @code{const}, +define @code{const} to be empty. Some C compilers that do not define +@code{__STDC__} do support @code{const}; some compilers that define +@code{__STDC__} do not completely support @code{const}. Programs can +simply use @code{const} as if every C compiler supported it; for those +that don't, the @file{Makefile} or configuration header file will define +it as empty. +@end defmac + +@defmac AC_C_INLINE +@maindex C_INLINE +@cvindex inline +If the C compiler is a version of GCC that supports the keyword +@code{__inline} but not @code{inline} (such as some NeXT versions), +define @code{inline} to be @code{__inline}. +@end defmac + +@defmac AC_C_CHAR_UNSIGNED +@maindex C_CHAR_UNSIGNED +@cvindex __CHAR_UNSIGNED__ +If the C type @code{char} is unsigned, define @code{__CHAR_UNSIGNED__}, +unless the C compiler predefines it. +@end defmac + +@defmac AC_C_LONG_DOUBLE +@maindex C_LONG_DOUBLE +@cvindex HAVE_LONG_DOUBLE +If the C compiler supports the @code{long double} type, define +@code{HAVE_LONG_DOUBLE}. Some C compilers that do not define +@code{__STDC__} do support the @code{long double} type; some compilers +that define @code{__STDC__} do not support @code{long double}. +@end defmac + +@defmac AC_CHECK_SIZEOF (@var{type}) +@maindex CHECK_SIZEOF +Define @code{SIZEOF_@var{uctype}} to be the size in bytes of the C (or +C++) builtin type @var{type}, e.g. @samp{int} or @samp{char *}. If +@samp{type} is unknown to the compiler, it gets a size of 0. @var{uctype} +is @var{type}, with lowercase converted to uppercase, spaces changed to +underscores, and asterisks changed to @samp{P}. For example, the call +@example +AC_CHECK_SIZEOF(int *) +@end example +@noindent +defines @code{SIZEOF_INT_P} to be 8 on DEC Alpha AXP systems. +@end defmac + +@defmac AC_INT_16_BITS +@maindex INT_16_BITS +@cvindex INT_16_BITS +If the C type @code{int} is 16 bits wide, define @code{INT_16_BITS}. +This macro is obsolete; it is more general to use +@samp{AC_CHECK_SIZEOF(int)} instead. +@end defmac + +@defmac AC_LONG_64_BITS +@maindex LONG_64_BITS +@cvindex LONG_64_BITS +If the C type @code{long int} is 64 bits wide, define +@code{LONG_64_BITS}. This macro is obsolete; it is more general to use +@samp{AC_CHECK_SIZEOF(long)} instead. +@end defmac + +@node System Services, UNIX Variants, Compiler Characteristics, Existing Tests +@section System Services + +The following macros check for operating system services or capabilities. + +@defmac AC_SYS_INTERPRETER +@maindex SYS_INTERPRETER +Check whether the system supports starting scripts with a line of the +form @samp{#!/bin/csh} to select the interpreter to use for the script. +After running this macro, shell code in @code{configure.in} can check +the variable @code{ac_cv_sys_interpreter}; it will be set to @samp{yes} +if the system supports @samp{#!}, @samp{no} if not. +@end defmac + +@defmac AC_PATH_X +@maindex PATH_X +Try to locate the X Window System include files and libraries. If the +user gave the command line options @samp{--x-includes=@var{dir}} and +@samp{--x-libraries=@var{dir}}, use those directories. If either or +both were not given, get the missing values by running @code{xmkmf} on a +trivial @file{Imakefile} and examining the @file{Makefile} that it +produces. If that fails (such as if @code{xmkmf} is not present), look +for them in several directories where they often reside. If either +method is successful, set the shell variables @code{x_includes} and +@code{x_libraries} to their locations, unless they are in directories +the compiler searches by default. + +If both methods fail, or the user gave the command line option +@samp{--without-x}, set the shell variable @code{no_x} to @samp{yes}; +otherwise set it to the empty string. +@end defmac + +@defmac AC_PATH_XTRA +@maindex PATH_XTRA +@ovindex X_CFLAGS +@ovindex X_LIBS +@ovindex X_EXTRA_LIBS +@ovindex X_PRE_LIBS +An enhanced version of @code{AC_PATH_X}. Add the C compiler flags that +X needs to output variable @code{X_CFLAGS}, and the X linker flags to +@code{X_LIBS}. If X is not available, add @samp{-DX_DISPLAY_MISSING} to +@code{X_CFLAGS}. + +Also check for special libraries that some systems need in order to +compile X programs. Add any that the system needs to output variable +@code{X_EXTRA_LIBS}. And check for special X11R6 libraries that need to +be linked with before @samp{-lX11}, and add any found to the output +variable @code{X_PRE_LIBS}. +@end defmac + +@defmac AC_SYS_LONG_FILE_NAMES +@maindex SYS_LONG_FILE_NAMES +@cvindex HAVE_LONG_FILE_NAMES +If the system supports file names longer than 14 characters, define +@code{HAVE_LONG_FILE_NAMES}. +@end defmac + +@defmac AC_SYS_RESTARTABLE_SYSCALLS +@maindex SYS_RESTARTABLE_SYSCALLS +@cvindex HAVE_RESTARTABLE_SYSCALLS +If the system automatically restarts a system call that is interrupted +by a signal, define @code{HAVE_RESTARTABLE_SYSCALLS}. +@end defmac + +@node UNIX Variants, , System Services, Existing Tests +@section UNIX Variants + +The following macros check for certain operating systems that need +special treatment for some programs, due to exceptional oddities in +their header files or libraries. These macros are warts; they will be +replaced by a more systematic approach, based on the functions they make +available or the environments they provide. + +@defmac AC_AIX +@maindex AIX +@cvindex _ALL_SOURCE +If on AIX, define @code{_ALL_SOURCE}. Allows the use of some BSD +functions. Should be called before any macros that run the C compiler. +@end defmac + +@defmac AC_DYNIX_SEQ +@maindex DYNIX_SEQ +If on Dynix/PTX (Sequent UNIX), add @samp{-lseq} to output +variable @code{LIBS}. This macro is obsolete; instead, use +@code{AC_FUNC_GETMNTENT}. +@end defmac + +@defmac AC_IRIX_SUN +@maindex IRIX_SUN +If on IRIX (Silicon Graphics UNIX), add @samp{-lsun} to output variable +@code{LIBS}. This macro is obsolete. If you were using it to get +@code{getmntent}, use @code{AC_FUNC_GETMNTENT} instead. If you used it +for the NIS versions of the password and group functions, use +@samp{AC_CHECK_LIB(sun, getpwnam)}. +@end defmac + +@defmac AC_ISC_POSIX +@maindex ISC_POSIX +@cvindex _POSIX_SOURCE +@ovindex CC +If on a POSIXized ISC UNIX, define @code{_POSIX_SOURCE} and add +@samp{-posix} (for the GNU C compiler) or @samp{-Xp} (for other C +compilers) to output variable @code{CC}. This allows the use of +POSIX facilities. Must be called after @code{AC_PROG_CC} and before +any other macros that run the C compiler. +@end defmac + +@defmac AC_MINIX +@maindex MINIX +@cvindex _MINIX +@cvindex _POSIX_SOURCE +@cvindex _POSIX_1_SOURCE +If on Minix, define @code{_MINIX} and @code{_POSIX_SOURCE} and define +@code{_POSIX_1_SOURCE} to be 2. This allows the use of POSIX +facilities. Should be called before any macros that run the C compiler. +@end defmac + +@defmac AC_SCO_INTL +@maindex SCO_INTL +@ovindex LIBS +If on SCO UNIX, add @samp{-lintl} to output variable @code{LIBS}. +This macro is obsolete; instead, use @code{AC_FUNC_STRFTIME}. +@end defmac + +@defmac AC_XENIX_DIR +@maindex XENIX_DIR +@ovindex LIBS +If on Xenix, add @samp{-lx} to output variable @code{LIBS}. Also, if +@file{dirent.h} is being used, add @samp{-ldir} to @code{LIBS}. This +macro is obsolete; use @code{AC_HEADER_DIRENT} instead. +@end defmac + +@node Writing Tests, Results, Existing Tests, Top +@chapter Writing Tests + +If the existing feature tests don't do something you need, you have to +write new ones. These macros are the building blocks. They provide +ways for other macros to check whether various kinds of features are +available and report the results. + +This chapter contains some suggestions and some of the reasons why the +existing tests are written the way they are. You can also learn a lot +about how to write Autoconf tests by looking at the existing ones. If +something goes wrong in one or more of the Autoconf tests, this +information can help you understand the assumptions behind them, which +might help you figure out how to best solve the problem. + +These macros check the output of the C compiler system. They do +not cache the results of their tests for future use (@pxref{Caching +Results}), because they don't know enough about the information they are +checking for to generate a cache variable name. They also do not print +any messages, for the same reason. The checks for particular kinds of C +features call these macros and do cache their results and print messages +about what they're checking for. + +@menu +* Examining Declarations:: Detecting header files and declarations. +* Examining Syntax:: Detecting language syntax features. +* Examining Libraries:: Detecting functions and global variables. +* Run Time:: Testing for run-time features. +* Portable Shell:: Shell script portability pitfalls. +* Testing Values and Files:: Checking strings and files. +* Multiple Cases:: Tests for several possible values. +* Language Choice:: Selecting which language to use for testing. +@end menu + +@node Examining Declarations, Examining Syntax, , Writing Tests +@section Examining Declarations + +The macro @code{AC_TRY_CPP} is used to check whether particular header +files exist. You can check for one at a time, or more than one if you +need several header files to all exist for some purpose. + +@defmac AC_TRY_CPP (@var{includes}, @var{action-if-true} @r{[}, @var{action-if-false}@r{]}) +@maindex TRY_CPP +@var{includes} is C or C++ @code{#include} statements and declarations, +on which shell variable, backquote, and backslash substitutions are +performed. (Actually, it can be any C program, but other statements are +probably not useful.) If the preprocessor produces no error messages +while processing it, run shell commands @var{action-if-true}. Otherwise +run shell commands @var{action-if-false}. + +This macro uses @code{CPPFLAGS}, but not @code{CFLAGS}, because +@samp{-g}, @samp{-O}, etc. are not valid options to many C +preprocessors. +@end defmac + +Here is now to find out whether a header file contains a particular +declaration, such as a typedef, a structure, a structure member, or a +function. Use @code{AC_EGREP_HEADER} instead of running @code{grep} +directly on the header file; on some systems the symbol might be defined +in another header file that the file you are checking @samp{#include}s. + +@defmac AC_EGREP_HEADER (@var{pattern}, @var{header-file}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]}) +@maindex EGREP_HEADER +If the output of running the preprocessor on the system header file +@var{header-file} matches the @code{egrep} regular expression +@var{pattern}, execute shell commands @var{action-if-found}, otherwise +execute @var{action-if-not-found}. +@end defmac + +To check for C preprocessor symbols, either defined by header files or +predefined by the C preprocessor, use @code{AC_EGREP_CPP}. Here is an +example of the latter: + +@example +AC_EGREP_CPP(yes, +[#ifdef _AIX + yes +#endif +], is_aix=yes, is_aix=no) +@end example + +@defmac AC_EGREP_CPP (@var{pattern}, @var{program}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]}) +@maindex EGREP_CPP +@var{program} is the text of a C or C++ program, on which shell +variable, backquote, and backslash substitutions are performed. If the +output of running the preprocessor on @var{program} matches the +@code{egrep} regular expression @var{pattern}, execute shell commands +@var{action-if-found}, otherwise execute @var{action-if-not-found}. + +This macro calls @code{AC_PROG_CPP} or @code{AC_PROG_CXXCPP} (depending +on which language is current, @pxref{Language Choice}), if it hasn't +been called already. +@end defmac + +@node Examining Syntax, Examining Libraries, Examining Declarations, Writing Tests +@section Examining Syntax + +To check for a syntax feature of the C or C++ compiler, such as whether +it recognizes a certain keyword, use @code{AC_TRY_COMPILE} to try to +compile a small program that uses that feature. You can also use it to +check for structures and structure members that are not present on all +systems. + +@defmac AC_TRY_COMPILE (@var{includes}, @var{function-body}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]}) +@maindex TRY_COMPILE +Create a test C program to see whether a function whose body consists of +@var{function-body} can be compiled; @var{includes} is any +@code{#include} statements needed by the code in @var{function-body}. +If the file compiles successfully, run shell commands +@var{action-if-found}, otherwise run @var{action-if-not-found}. This +macro uses @code{CFLAGS} or @code{CXXFLAGS}, and @code{CPPFLAGS}, when +compiling. It does not try to link; use @code{AC_TRY_LINK} if you need +to do that (@pxref{Examining Libraries}). +@end defmac + +@node Examining Libraries, Run Time, Examining Syntax, Writing Tests +@section Examining Libraries + +To check for a library, a function, or a global variable, Autoconf +@code{configure} scripts try to compile and link a small program that +uses it. This is unlike Metaconfig, which by default uses @code{nm} +or @code{ar} on the C library to try to figure out which functions are +available. Trying to link with the function is usually a more reliable +approach because it avoids dealing with the variations in the options +and output formats of @code{nm} and @code{ar} and in the location of the +standard libraries. It also allows configuring for cross-compilation or +checking a function's runtime behavior if needed. On the other hand, it +can be slower than scanning the libraries once. + +A few systems have linkers that do not return a failure exit status when +there are unresolved functions in the link. This bug makes the +configuration scripts produced by Autoconf unusable on those systems. +However, some of them can be given options that make the exit status +correct. This is a problem that Autoconf does not currently handle +automatically. + +@code{AC_TRY_LINK} is used to compile test programs to test for +functions and global variables. It is also used (by +@code{AC_CHECK_LIB}) to check for libraries, by adding the library being +checked for to @code{LIBS} temporarily and trying to link a small +program. + +@defmac AC_TRY_LINK (@var{includes}, @var{function-body}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]}) +@maindex TRY_LINK +Create a test C program to see whether a function whose body consists of +@var{function-body} can be compiled and linked; @var{includes} is any +@code{#include} statements needed by the code in @var{function-body}. +If the file compiles and links successfully, run shell commands +@var{action-if-found}, otherwise run @var{action-if-not-found}. This +macro uses @code{CFLAGS} or @code{CXXFLAGS}, @code{CPPFLAGS}, +@code{LDFLAGS}, and @code{LIBS} when compiling. +@end defmac + +@defmac AC_COMPILE_CHECK (@var{echo-text}, @var{includes}, @var{function-body}, @var{action-if-found} @r{[}, @var{action-if-not-found}@r{]}) +@maindex COMPILE_CHECK +This is an obsolete version of @code{AC_TRY_LINK}, with the addition that it +prints @samp{checking for @var{echo-text}} to the standard output first, +if @var{echo-text} is non-empty. Use @code{AC_MSG_CHECKING} and +@code{AC_MSG_RESULT} instead to print messages (@pxref{Printing Messages}). +@end defmac + +@node Run Time, Portable Shell, Examining Libraries, Writing Tests +@section Checking Run Time Behavior + +Sometimes you need to find out how a system performs at run time, such +as whether a given function has a certain capability or bug. If you +can, make such checks when your program runs instead of when it is +configured. You can check for things like the machine's endianness when +your program initializes itself. + +If you really need to test for a run-time behavior while configuring, +you can write a test program to determine the result, and compile and +run it using @code{AC_TRY_RUN}. Avoid running test programs if +possible, because using them prevents people from configuring your +package for cross-compiling. + +@menu +* Test Programs:: Running test programs. +* Guidelines:: General rules for writing test programs. +* Test Functions:: Avoiding pitfalls in test programs. +@end menu + +@node Test Programs, Guidelines, , Run Time +@subsection Running Test Programs + +Use the following macro if you need to test run-time behavior of the +system while configuring. + +@defmac AC_TRY_RUN (@var{program}, @var{action-if-true} @r{[}, @var{action-if-false} @r{[}, @var{action-if-cross-compiling}@r{]]}) +@maindex TRY_RUN +@var{program} is the text of a C program, on which shell variable and +backquote substitutions are performed. If it compiles and links +successfully and returns an exit status of 0 when executed, run shell +commands @var{action-if-true}. Otherwise run shell commands +@var{action-if-false}; the exit status of the program is available in +the shell variable @samp{$?}. This macro uses @code{CFLAGS} or +@code{CXXFLAGS}, @code{CPPFLAGS}, @code{LDFLAGS}, and @code{LIBS} when +compiling. + +If the C compiler being used does not produce executables that run on +the system where @code{configure} is being run, then the test program is +not run. If the optional shell commands @var{action-if-cross-compiling} +are given, they are run instead and this macro calls @code{AC_C_CROSS} +if it has not already been called. Otherwise, @code{configure} prints +an error message and exits. +@end defmac + +Try to provide a pessimistic default value to use when cross-compiling +makes run-time tests impossible. You do this by passing the optional +last argument to @code{AC_TRY_RUN}. @code{autoconf} prints a warning +message when creating @code{configure} each time it encounters a call to +@code{AC_TRY_RUN} with no @var{action-if-cross-compiling} argument +given. You may ignore the warning, though users will not be able to +configure your package for cross-compiling. A few of the macros +distributed with Autoconf produce this warning message. + +To configure for cross-compiling you can also choose a value for those +parameters based on the canonical system name (@pxref{Manual +Configuration}). Alternatively, set up a test results cache file with +the correct values for the target system (@pxref{Caching Results}). + +To provide a default for calls of @code{AC_TRY_RUN} that are embedded in +other macros, including a few of the ones that come with Autoconf, you +can call @code{AC_C_CROSS} before running them. Then, if the shell +variable @code{cross_compiling} is set to @samp{yes}, use an alternate +method to get the results instead of calling the macros. + +@defmac AC_C_CROSS +@maindex C_CROSS +If the C compiler being used does not produce executables that can run +on the system where @code{configure} is being run, set the shell +variable @code{cross_compiling} to @samp{yes}, otherwise @samp{no}. +@end defmac + +@node Guidelines, Test Functions, Test Programs, Run Time +@subsection Guidelines for Test Programs + +Test programs should not write anything to the standard output. They +should return 0 if the test succeeds, nonzero otherwise, so that success +can be distinguished easily from a core dump or other failure; +segmentation violations and other failures produce a nonzero exit +status. Test programs should @code{exit}, not @code{return}, from +@code{main}, because on some systems (old Suns, at least) the argument +to @code{return} in @code{main} is ignored. + +Test programs can use @code{#if} or @code{#ifdef} to check the values of +preprocessor macros defined by tests that have already run. For +example, if you call @code{AC_HEADER_STDC}, then later on in +@file{configure.in} you can have a test program that includes an ANSI C +header file conditionally: + +@example +@group +#if STDC_HEADERS +# include <stdlib.h> +#endif +@end group +@end example + +If a test program needs to use or create a data file, give it a name +that starts with @file{conftest}, such as @file{conftestdata}. The +@code{configure} script cleans up by running @samp{rm -rf conftest*} +after running test programs and if the script is interrupted. + +@node Test Functions, , Guidelines, Run Time +@subsection Test Functions + +Function declarations in test programs should have a prototype +conditionalized for C++. In practice, though, test programs rarely need +functions that take arguments. + +@example +#ifdef __cplusplus +foo(int i) +#else +foo(i) int i; +#endif +@end example + +Functions that test programs declare should also be conditionalized for +C++, which requires @samp{extern "C"} prototypes. Make sure to not +include any header files containing clashing prototypes. + +@example +#ifdef __cplusplus +extern "C" void *malloc(size_t); +#else +char *malloc(); +#endif +@end example + +If a test program calls a function with invalid parameters (just to see +whether it exists), organize the program to ensure that it never invokes +that function. You can do this by calling it in another function that is +never invoked. You can't do it by putting it after a call to +@code{exit}, because GCC version 2 knows that @code{exit} never returns +and optimizes out any code that follows it in the same block. + +If you include any header files, make sure to call the functions +relevant to them with the correct number of arguments, even if they are +just 0, to avoid compilation errors due to prototypes. GCC version 2 +has internal prototypes for several functions that it automatically +inlines; for example, @code{memcpy}. To avoid errors when checking for +them, either pass them the correct number of arguments or redeclare them +with a different return type (such as @code{char}). + +@node Portable Shell, Testing Values and Files, Run Time, Writing Tests +@section Portable Shell Programming + +When writing your own checks, there are some shell script programming +techniques you should avoid in order to make your code portable. The +Bourne shell and upward-compatible shells like Bash and the Korn shell +have evolved over the years, but to prevent trouble, do not take +advantage of features that were added after UNIX version 7, circa 1977. +You should not use shell functions, aliases, negated character classes, +or other features that are not found in all Bourne-compatible shells; +restrict yourself to the lowest common denominator. Even @code{unset} +is not supported by all shells! + +The set of external programs you should run in a @code{configure} script +is fairly small. @xref{Utilities in Makefiles, , Utilities in +Makefiles, standards.info, GNU Coding Standards}, for the list. This +restriction allows users to start out with a fairly small set of +programs and build the rest, avoiding too many interdependencies between +packages. + +Some of these external utilities have a portable subset of features, as +well; for example, don't rely on @code{ln} having a @samp{-f} option or +@code{cat} having any options. @code{sed} scripts should not contain +comments or use branch labels longer than 8 characters. Don't use +@samp{grep -s} to suppress output, because @samp{grep -s} on System V +does not suppress output, only error messages. Instead, redirect the +standard output and standard error (in case the file doesn't exist) of +@code{grep} to @file{/dev/null}. Check the exit status of @code{grep} +to determine whether it found a match. + +@node Testing Values and Files, Multiple Cases, Portable Shell, Writing Tests +@section Testing Values and Files + +@code{configure} scripts need to test properties of many files and +strings. Here are some portability problems to watch out for when doing +those tests. + +The @code{test} program is the way to perform many file and string +tests. It is often invoked by the alternate name @samp{[}, but using +that name in Autoconf code is asking for trouble since it is an +@code{m4} quote character. + +If you need to make multiple checks using @code{test}, combine +them with the shell operators @samp{&&} and @samp{||} instead of using +the @code{test} operators @samp{-a} and @samp{-o}. On System V, the +precedence of @samp{-a} and @samp{-o} is wrong relative to the unary +operators; consequently, POSIX does not specify them, so using them is +nonportable. If you combine @samp{&&} and @samp{||} in the same +statement, keep in mind that they have equal precedence. + +To enable @code{configure} scripts to support cross-compilation, they +shouldn't do anything that tests features of the host system instead of +the target system. But occasionally you may find it necessary to check +whether some arbitrary file exists. To do so, use @samp{test -f} or +@samp{test -r}. Do not use @samp{test -x}, because 4.3BSD does not have +it. + +Another nonportable shell programming construction is +@example +@var{var}=$@{@var{var}:-@var{value}@} +@end example +@noindent +The intent is to set @var{var} to @var{value} only if it is not already +set, but if @var{var} has any value, even the empty string, to leave it +alone. Old BSD shells, including the Ultrix @code{sh}, don't accept +the colon, and complain and die. A portable equivalent is +@example +: $@{@var{var}=@var{value}@} +@end example + +@node Multiple Cases, Language Choice, Testing Values and Files, Writing Tests +@section Multiple Cases + +Some operations are accomplished in several possible ways, depending on +the UNIX variant. Checking for them essentially requires a ``case +statement''. Autoconf does not directly provide one; however, it is +easy to simulate by using a shell variable to keep track of whether a +way to perform the operation has been found yet. + +Here is an example that uses the shell variable @code{fstype} to keep +track of whether the remaining cases need to be checked. + +@example +@group +AC_MSG_CHECKING(how to get filesystem type) +fstype=no +# The order of these tests is important. +AC_TRY_CPP([#include <sys/statvfs.h> +#include <sys/fstyp.h>], AC_DEFINE(FSTYPE_STATVFS) fstype=SVR4) +if test $fstype = no; then +AC_TRY_CPP([#include <sys/statfs.h> +#include <sys/fstyp.h>], AC_DEFINE(FSTYPE_USG_STATFS) fstype=SVR3) +fi +if test $fstype = no; then +AC_TRY_CPP([#include <sys/statfs.h> +#include <sys/vmount.h>], AC_DEFINE(FSTYPE_AIX_STATFS) fstype=AIX) +fi +# (more cases omitted here) +AC_MSG_RESULT($fstype) +@end group +@end example + +@node Language Choice, , Multiple Cases, Writing Tests +@section Language Choice + +Packages that use both C and C++ need to test features of both +compilers. Autoconf-generated @code{configure} scripts check for C +features by default. The following macros determine which language's +compiler is used in tests that follow in @file{configure.in}. + +@defmac AC_LANG_C +@maindex LANG_C +Do compilation tests using @code{CC} and @code{CPP} and use extension +@file{.c} for test programs. +@end defmac + +@defmac AC_LANG_CPLUSPLUS +@maindex LANG_CPLUSPLUS +Do compilation tests using @code{CXX} and @code{CXXCPP} and use +extension @file{.C} for test programs. +@end defmac + +@defmac AC_LANG_SAVE +@maindex LANG_SAVE +Remember the current language (as set by @code{AC_LANG_C} or +@code{AC_LANG_CPLUSPLUS}) on a stack. Does not change which language is +current. Use this macro and @code{AC_LANG_RESTORE} in macros that need +to temporarily switch to a particular language. +@end defmac + +@defmac AC_LANG_RESTORE +@maindex LANG_RESTORE +Select the language that is saved on the top of the stack, as set by +@code{AC_LANG_SAVE}, and remove it from the stack. This macro is +equivalent to either @code{AC_LANG_C} or @code{AC_LANG_CPLUSPLUS}, +whichever had been run most recently when @code{AC_LANG_SAVE} was last +called. + +Do not call this macro more times than @code{AC_LANG_SAVE}. +@end defmac + +@defmac AC_REQUIRE_CPP +@maindex REQUIRE_CPP +Ensure that whichever preprocessor would currently be used for tests has +been found. Calls @code{AC_REQUIRE} (@pxref{Prerequisite Macros}) with an +argument of either @code{AC_PROG_CPP} or @code{AC_PROG_CXXCPP}, +depending on which language is current. +@end defmac + +@node Results, Writing Macros, Writing Tests, Top +@chapter Results of Tests + +Once @code{configure} has determined whether a feature exists, what can +it do to record that information? There are four sorts of things it can +do: define a C preprocessor symbol, set a variable in the output files, +save the result in a cache file for future @code{configure} runs, and +print a message letting the user know the result of the test. + +@menu +* Defining Symbols:: Defining C preprocessor symbols. +* Setting Output Variables:: Replacing variables in output files. +* Caching Results:: Speeding up subsequent @code{configure} runs. +* Printing Messages:: Notifying users of progress or problems. +@end menu + +@node Defining Symbols, Setting Output Variables, , Results +@section Defining C Preprocessor Symbols + +A common action to take in response to a feature test is to define a C +preprocessor symbol indicating the results of the test. That is done by +calling @code{AC_DEFINE} or @code{AC_DEFINE_UNQUOTED}. + +By default, @code{AC_OUTPUT} places the symbols defined by these macros +into the output variable @code{DEFS}, which contains an option +@samp{-D@var{symbol}=@var{value}} for each symbol defined. Unlike in +Autoconf version 1, there is no variable @code{DEFS} defined while +@code{configure} is running. To check whether Autoconf macros have +already defined a certain C preprocessor symbol, test the value of the +appropriate cache variable, as in this example: + +@example +AC_CHECK_FUNC(vprintf, AC_DEFINE(HAVE_VPRINTF)) +if test "$ac_cv_func_vprintf" != yes; then +AC_CHECK_FUNC(_doprnt, AC_DEFINE(HAVE_DOPRNT)) +fi +@end example + +If @code{AC_CONFIG_HEADER} has been called, then instead of creating +@code{DEFS}, @code{AC_OUTPUT} creates a header file by substituting the +correct values into @code{#define} statements in a template file. +@xref{Configuration Headers}, for more information about this kind of +output. + +@defmac AC_DEFINE (@var{variable} @r{[}, @var{value}@r{]}) +@maindex DEFINE +Define C preprocessor variable @var{variable}. If @var{value} is given, +set @var{variable} to that value (verbatim), otherwise set it to 1. +@var{value} should not contain literal newlines, and if you are not +using @code{AC_CONFIG_HEADER} it should not contain any @samp{#} +characters, as @code{make} tends to eat them. To use a shell variable +(which you need to do in order to define a value containing the +@code{m4} quote characters @samp{[} or @samp{]}), use +@code{AC_DEFINE_UNQUOTED} instead. The following example defines the C +preprocessor variable @code{EQUATION} to be the string constant +@samp{"$a > $b"}: + +@example +AC_DEFINE(EQUATION, "$a > $b") +@end example +@end defmac + +@defmac AC_DEFINE_UNQUOTED (@var{variable} @r{[}, @var{value}@r{]}) +@maindex DEFINE_UNQUOTED +Like @code{AC_DEFINE}, but three shell expansions are +performed---once---on @var{variable} and @var{value}: variable expansion +(@samp{$}), command substitution (@samp{`}), and backslash escaping +(@samp{\}). Single and double quote characters in the value have no +special meaning. Use this macro instead of @code{AC_DEFINE} when +@var{variable} or @var{value} is a shell variable. Examples: + +@example +AC_DEFINE_UNQUOTED(config_machfile, "$@{machfile@}") +AC_DEFINE_UNQUOTED(GETGROUPS_T, $ac_cv_type_getgroups) +AC_DEFINE_UNQUOTED($@{ac_tr_hdr@}) +@end example +@end defmac + +Due to the syntactical bizarreness of the Bourne shell, do not use +semicolons to separate @code{AC_DEFINE} or @code{AC_DEFINE_UNQUOTED} +calls from other macro calls or shell code; that can cause syntax errors +in the resulting @code{configure} script. Use either spaces or +newlines. That is, do this: + +@example +AC_CHECK_HEADER(elf.h, AC_DEFINE(SVR4) LIBS="$LIBS -lelf") +@end example + +@noindent +or this: + +@example +AC_CHECK_HEADER(elf.h, + AC_DEFINE(SVR4) + LIBS="$LIBS -lelf") +@end example + +@noindent +instead of this: + +@example +AC_CHECK_HEADER(elf.h, AC_DEFINE(SVR4); LIBS="$LIBS -lelf") +@end example + +@node Setting Output Variables, Caching Results, Defining Symbols, Results +@section Setting Output Variables + +One way to record the results of tests is to set @dfn{output variables}, +which are shell variables whose values are substituted into files that +@code{configure} outputs. The two macros below create new output +variables. @xref{Preset Output Variables}, for a list of output +variables that are always available. + +@defmac AC_SUBST (@var{variable}) +@maindex SUBST +Create an output variable from a shell variable. Make @code{AC_OUTPUT} +substitute the variable @var{variable} into output files (typically one +or more @file{Makefile}s). This means that @code{AC_OUTPUT} will +replace instances of @samp{@@@var{variable}@@} in input files with the +value that the shell variable @var{variable} has when @code{AC_OUTPUT} +is called. The value of @var{variable} should not contain literal +newlines. +@end defmac + +@defmac AC_SUBST_FILE (@var{variable}) +@maindex SUBST_FILE +Another way to create an output variable from a shell variable. Make +@code{AC_OUTPUT} insert (without substitutions) the contents of the file +named by shell variable @var{variable} into output files. This means +that @code{AC_OUTPUT} will replace instances of +@samp{@@@var{variable}@@} in output files (such as @file{Makefile.in}) +with the contents of the file that the shell variable @var{variable} +names when @code{AC_OUTPUT} is called. Set the variable to +@file{/dev/null} for cases that do not have a file to insert. + +This macro is useful for inserting @file{Makefile} fragments containing +special dependencies or other @code{make} directives for particular host +or target types into @file{Makefile}s. For example, @file{configure.in} +could contain: + +@example +AC_SUBST_FILE(host_frag)dnl +host_frag=$srcdir/conf/sun4.mh +@end example + +@noindent +and then a @file{Makefile.in} could contain: + +@example +@@host_frag@@ +@end example +@end defmac + +@node Caching Results, Printing Messages, Setting Output Variables, Results +@section Caching Results + +To avoid checking for the same features repeatedly in various +@code{configure} scripts (or repeated runs of one script), +@code{configure} saves the results of many of its checks in a @dfn{cache +file}. If, when a @code{configure} script runs, it finds a cache file, +it reads from it the results from previous runs and avoids rerunning +those checks. As a result, @code{configure} can run much faster than if +it had to perform all of the checks every time. + +@defmac AC_CACHE_VAL (@var{cache-id}, @var{commands-to-set-it}) +@maindex CACHE_VAL +Ensure that the results of the check identified by @var{cache-id} are +available. If the results of the check were in the cache file that was +read, and @code{configure} was not given the @samp{--quiet} or +@samp{--silent} option, print a message saying that the result was +cached; otherwise, run the shell commands @var{commands-to-set-it}. +Those commands should have no side effects except for setting the +variable @var{cache-id}. In particular, they should not call +@code{AC_DEFINE}; the code that follows the call to @code{AC_CACHE_VAL} +should do that, based on the cached value. Also, they should not print +any messages, for example with @code{AC_MSG_CHECKING}; do that before +calling @code{AC_CACHE_VAL}, so the messages are printed regardless of +whether the results of the check are retrieved from the cache or +determined by running the shell commands. If the shell commands are run +to determine the value, the value will be saved in the cache file just +before @code{configure} creates its output files. @xref{Cache +Variable Names}, for how to choose the name of the @var{cache-id} variable. +@end defmac + +@menu +* Cache Variable Names:: Shell variables used in caches. +* Cache Files:: Files @code{configure} uses for caching. +@end menu + +@node Cache Variable Names, Cache Files, , Caching Results +@subsection Cache Variable Names + +The names of cache variables should have the following format: + +@example +@var{package-prefix}_cv_@var{value-type}_@var{specific-value}@r{[}_@var{additional-options}@r{]} +@end example + +@noindent +for example, @samp{ac_cv_header_stat_broken} or +@samp{ac_cv_prog_gcc_traditional}. The parts of the variable name are: + +@table @asis +@item @var{package-prefix} +An abbreviation for your package or organization; the same prefix you +begin local Autoconf macros with, except lowercase by convention. +For cache values used by the distributed Autoconf macros, this value is +@samp{ac}. + +@item @code{_cv_} +Indicates that this shell variable is a cache value. + +@item @var{value-type} +A convention for classifying cache values, to produce a rational naming +system. The values used in Autoconf are listed in @ref{Macro Names}. + +@item @var{specific-value} +Which member of the class of cache values this test applies to. +For example, which function (@samp{alloca}), program (@samp{gcc}), or +output variable (@samp{INSTALL}). + +@item @var{additional-options} +Any particular behavior of the specific member that this test applies to. +For example, @samp{broken} or @samp{set}. This part of the name may +be omitted if it does not apply. +@end table + +Like their names, the values that may be assigned to cache variables +have a few restrictions. The values may not contain single quotes or +curly braces. Usually, their values will be boolean (@samp{yes} or +@samp{no}) or the names of files or functions; so this is not an +important restriction. + +@node Cache Files, , Cache Variable Names, Caching Results +@subsection Cache Files + +A cache file is a shell script that caches the results of configure +tests run on one system so they can be shared between configure scripts +and configure runs. It is not useful on other systems. If its contents +are invalid for some reason, the user may delete or edit it. + +By default, configure uses @file{./config.cache} as the cache file, +creating it if it does not exist already. @code{configure} accepts the +@samp{--cache-file=@var{file}} option to use a different cache file; +that is what @code{configure} does when it calls @code{configure} +scripts in subdirectories, so they share the cache. Giving +@samp{--cache-file=/dev/null} disables caching, for debugging +@code{configure}. @xref{Subdirectories}, for information on configuring +subdirectories with the @code{AC_CONFIG_SUBDIRS} macro. +@file{config.status} only pays attention to the cache file if it is +given the @samp{--recheck} option, which makes it rerun +@code{configure}. + +It is wrong to try to distribute cache files for particular system types. +There is too much room for error in doing that, and too much +administrative overhead in maintaining them. For any features that +can't be guessed automatically, use the standard method of the canonical +system type and linking files (@pxref{Manual Configuration}). + +The cache file on a particular system will gradually accumulate whenever +someone runs a @code{configure} script; it will be initially +nonexistent. Running @code{configure} merges the new cache results with +the existing cache file. The site initialization script can specify a +site-wide cache file to use instead of the default, to make it work +transparently, as long as the same C compiler is used every time +(@pxref{Site Defaults}). + +@node Printing Messages, , Caching Results, Results +@section Printing Messages + +@code{configure} scripts need to give users running them several kinds +of information. The following macros print messages in ways appropriate +for each kind. The arguments to all of them get enclosed in shell +double quotes, so the shell performs variable and backquote substitution +on them. + +These macros are all wrappers around the @code{echo} shell command. +@code{configure} scripts should rarely need to run @code{echo} directly +to print messages for the user. Using these macros makes it easy to +change how and when each kind of message is printed; such changes need +only be made to the macro definitions, and all of the callers change +automatically. + +@defmac AC_MSG_CHECKING (@var{feature-description}) +@maindex MSG_CHECKING +Notify the user that @code{configure} is checking for a particular +feature. This macro prints a message that starts with @samp{checking } +and ends with @samp{...} and no newline. It must be followed by a call +to @code{AC_MSG_RESULT} to print the result of the check and the +newline. The @var{feature-description} should be something like +@samp{whether the Fortran compiler accepts C++ comments} or @samp{for +c89}. + +This macro prints nothing if @code{configure} is run with the +@samp{--quiet} or @samp{--silent} option. +@end defmac + +@defmac AC_MSG_RESULT (@var{result-description}) +@maindex MSG_RESULT +Notify the user of the results of a check. @var{result-description} is +almost always the value of the cache variable for the check, typically +@samp{yes}, @samp{no}, or a file name. This macro should follow a call +to @code{AC_MSG_CHECKING}, and the @var{result-description} should be +the completion of the message printed by the call to +@code{AC_MSG_CHECKING}. + +This macro prints nothing if @code{configure} is run with the +@samp{--quiet} or @samp{--silent} option. +@end defmac + +@defmac AC_MSG_ERROR (@var{error-description}) +@maindex MSG_ERROR +Notify the user of an error that prevents @code{configure} from +completing. This macro prints an error message on the standard error +stream and exits @code{configure} with a nonzero status. +@var{error-description} should be something like @samp{invalid value +$HOME for \$HOME}. +@end defmac + +@defmac AC_MSG_WARN (@var{problem-description}) +@maindex MSG_WARN +Notify the @code{configure} user of a possible problem. This macro +prints the message on the standard error stream; @code{configure} +continues running afterward, so macros that call @code{AC_MSG_WARN} should +provide a default (back-up) behavior for the situations they warn about. +@var{problem-description} should be something like @samp{ln -s seems to +make hard links}. +@end defmac + +The following two macros are an obsolete alternative to +@code{AC_MSG_CHECKING} and @code{AC_MSG_RESULT}. + +@defmac AC_CHECKING (@var{feature-description}) +@maindex CHECKING +This macro is similar to @code{AC_MSG_CHECKING}, except that it prints a +newline after the @var{feature-description}. It is useful mainly to +print a general description of the overall purpose of a group of feature +checks, e.g., + +@example +AC_CHECKING(if stack overflow is detectable) +@end example +@end defmac + +@defmac AC_VERBOSE (@var{result-description}) +@maindex VERBOSE +This macro is similar to @code{AC_MSG_RESULT}, except that it is meant +to follow a call to @code{AC_CHECKING} instead of +@code{AC_MSG_CHECKING}; it starts the message it prints with a tab. It +is considered obsolete. +@end defmac + +@node Writing Macros, Manual Configuration, Results, Top +@chapter Writing Macros + +When you write a feature test that could be applicable to more than one +software package, the best thing to do is encapsulate it in a new macro. +Here are some instructions and guidelines for writing Autoconf macros. + +@menu +* Macro Definitions:: Basic format of an Autoconf macro. +* Macro Names:: What to call your new macros. +* Quoting:: Protecting macros from unwanted expansion. +* Dependencies Between Macros:: What to do when macros depend on other macros. +@end menu + +@node Macro Definitions, Macro Names, , Writing Macros +@section Macro Definitions + +@maindex DEFUN +Autoconf macros are defined using the @code{AC_DEFUN} macro, which is +similar to the @code{m4} builtin @code{define} macro. In addition to +defining a macro, @code{AC_DEFUN} adds to it some code which is used to +constrain the order in which macros are called (@pxref{Prerequisite +Macros}). + +An Autoconf macro definition looks like this: + +@example +AC_DEFUN(@var{macro-name}, [@var{macro-body}]) +@end example + +@noindent +The square brackets here do not indicate optional text: they should +literally be present in the macro definition to avoid macro expansion +problems (@pxref{Quoting}). You can refer to any arguments passed to +the macro as @samp{$1}, @samp{$2}, etc. + +To introduce comments in @code{m4}, use the @code{m4} builtin +@code{dnl}; it causes @code{m4} to discard the text through the next +newline. It is not needed between macro definitions in @file{acsite.m4} +and @file{aclocal.m4}, because all output is discarded until +@code{AC_INIT} is called. + +@xref{Definitions, , How to define new macros, m4.info, GNU m4}, for +more complete information on writing @code{m4} macros. + +@node Macro Names, Quoting, Macro Definitions, Writing Macros +@section Macro Names + +All of the Autoconf macros have all-uppercase names starting with +@samp{AC_} to prevent them from accidentally conflicting with other +text. All shell variables that they use for internal purposes have +mostly-lowercase names starting with @samp{ac_}. To ensure that your +macros don't conflict with present or future Autoconf macros, you should +prefix your own macro names and any shell variables they use with some +other sequence. Possibilities include your initials, or an abbreviation +for the name of your organization or software package. + +Most of the Autoconf macros' names follow a structured naming convention +that indicates the kind of feature check by the name. The macro names +consist of several words, separated by underscores, going from most +general to most specific. The names of their cache variables use the +same convention (@pxref{Cache Variable Names}, for more information on them). + +The first word of the name after @samp{AC_} usually tells the category +of feature being tested. Here are the categories used in Autoconf for +specific test macros, the kind of macro that you are more likely to +write. They are also used for cache variables, in all-lowercase. Use +them where applicable; where they're not, invent your own categories. + +@table @code +@item C +C language builtin features. +@item DECL +Declarations of C variables in header files. +@item FUNC +Functions in libraries. +@item GROUP +UNIX group owners of files. +@item HEADER +Header files. +@item LIB +C libraries. +@item PATH +The full path names to files, including programs. +@item PROG +The base names of programs. +@item STRUCT +Definitions of C structures in header files. +@item SYS +Operating system features. +@item TYPE +C builtin or declared types. +@item VAR +C variables in libraries. +@end table + +After the category comes the name of the particular feature being +tested. Any further words in the macro name indicate particular aspects +of the feature. For example, @code{AC_FUNC_UTIME_NULL} checks the +behavior of the @code{utime} function when called with a @code{NULL} +pointer. + +A macro that is an internal subroutine of another macro should have a +name that starts with the name of that other macro, followed by one or +more words saying what the internal macro does. For example, +@code{AC_PATH_X} has internal macros @code{AC_PATH_X_XMKMF} and +@code{AC_PATH_X_DIRECT}. + +@node Quoting, Dependencies Between Macros, Macro Names, Writing Macros +@section Quoting + +Macros that are called by other macros are evaluated by @code{m4} +several times; each evaluation might require another layer of quotes to +prevent unwanted expansions of macros or @code{m4} builtins, such as +@samp{define} and @samp{$1}. Quotes are also required around macro +arguments that contain commas, since commas separate the arguments from +each other. It's a good idea to quote any macro arguments that contain +newlines or calls to other macros, as well. + +Autoconf changes the @code{m4} quote characters +from the default @samp{`} and @samp{'} to @samp{[} and @samp{]}, because +many of the macros use @samp{`} and @samp{'}, mismatched. However, in a +few places the macros need to use brackets (usually in C program text or +regular expressions). In those places, they use the @code{m4} builtin +command @code{changequote} to temporarily change the quote characters to +@samp{<<} and @samp{>>}. (Sometimes, if they don't need to quote +anything, they disable quoting entirely instead by setting the quote +characters to empty strings.) Here is an example: + +@example +AC_TRY_LINK( +changequote(<<, >>)dnl +<<#include <time.h> +#ifndef tzname /* For SGI. */ +extern char *tzname[]; /* RS6000 and others reject char **tzname. */ +#endif>>, +changequote([, ])dnl +[atoi(*tzname);], ac_cv_var_tzname=yes, ac_cv_var_tzname=no) +@end example + +When you create a @code{configure} script using newly written macros, +examine it carefully to check whether you need to add more quotes in +your macros. If one or more words have disappeared in the @code{m4} +output, you need more quotes. When in doubt, quote. + +However, it's also possible to put on too many layers of quotes. If +this happens, the resulting @code{configure} script will contain +unexpanded macros. The @code{autoconf} program checks for this problem +by doing @samp{grep AC_ configure}. + +@node Dependencies Between Macros, , Quoting, Writing Macros +@section Dependencies Between Macros + +Some Autoconf macros depend on other macros having been called first in +order to work correctly. Autoconf provides a way to ensure that certain +macros are called if needed and a way to warn the user if macros are +called in an order that might cause incorrect operation. + +@menu +* Prerequisite Macros:: Ensuring required information. +* Suggested Ordering:: Warning about possible ordering problems. +* Obsolete Macros:: Warning about old ways of doing things. +@end menu + +@node Prerequisite Macros, Suggested Ordering, , Dependencies Between Macros +@subsection Prerequisite Macros + +A macro that you write might need to use values that have previously +been computed by other macros. For example, @code{AC_DECL_YYTEXT} +examines the output of @code{flex} or @code{lex}, so it depends on +@code{AC_PROG_LEX} having been called first to set the shell variable +@code{LEX}. + +Rather than forcing the user of the macros to keep track of the +dependencies between them, you can use the @code{AC_REQUIRE} macro to do +it automatically. @code{AC_REQUIRE} can ensure that a macro is only +called if it is needed, and only called once. + +@defmac AC_REQUIRE (@var{macro-name}) +@maindex REQUIRE +If the @code{m4} macro @var{macro-name} has not already been called, +call it (without any arguments). Make sure to quote @var{macro-name} +with square brackets. @var{macro-name} must have been defined using +@code{AC_DEFUN} or else contain a call to @code{AC_PROVIDE} to indicate +that it has been called. +@end defmac + +An alternative to using @code{AC_DEFUN} is to use @code{define} and call +@code{AC_PROVIDE}. Because this technique does not prevent nested +messages, it is considered obsolete. + +@defmac AC_PROVIDE (@var{this-macro-name}) +@maindex PROVIDE +Record the fact that @var{this-macro-name} has been called. +@var{this-macro-name} should be the name of the macro that is calling +@code{AC_PROVIDE}. An easy way to get it is from the @code{m4} builtin +variable @code{$0}, like this: + +@example +AC_PROVIDE([$0]) +@end example +@end defmac + +@node Suggested Ordering, Obsolete Macros, Prerequisite Macros, Dependencies Between Macros +@subsection Suggested Ordering + +Some macros should be run before another macro if both are called, but +neither @emph{requires} that the other be called. For example, a macro +that changes the behavior of the C compiler should be called before any +macros that run the C compiler. Many of these dependencies are noted in +the documentation. + +Autoconf provides the @code{AC_BEFORE} macro to warn users when macros +with this kind of dependency appear out of order in a +@file{configure.in} file. The warning occurs when creating +@code{configure} from @file{configure.in}, not when running +@code{configure}. +For example, @code{AC_PROG_CPP} checks whether the C compiler +can run the C preprocessor when given the @samp{-E} option. It should +therefore be called after any macros that change which C compiler is +being used, such as @code{AC_PROG_CC}. So @code{AC_PROG_CC} contains: + +@example +AC_BEFORE([$0], [AC_PROG_CPP])dnl +@end example + +@noindent +This warns the user if a call to @code{AC_PROG_CPP} has already occurred +when @code{AC_PROG_CC} is called. + +@defmac AC_BEFORE (@var{this-macro-name}, @var{called-macro-name}) +@maindex BEFORE +Make @code{m4} print a warning message on the standard error output if +@var{called-macro-name} has already been called. @var{this-macro-name} +should be the name of the macro that is calling @code{AC_BEFORE}. The +macro @var{called-macro-name} must have been defined using +@code{AC_DEFUN} or else contain a call to @code{AC_PROVIDE} to indicate +that it has been called. +@end defmac + +@node Obsolete Macros, , Suggested Ordering, Dependencies Between Macros +@subsection Obsolete Macros + +Configuration and portability technology has evolved over the years. +Often better ways of solving a particular problem are developed, or +ad-hoc approaches are systematized. This process has occurred in many +parts of Autoconf. One result is that some of the macros are now +considered @dfn{obsolete}; they still work, but are no longer considered +the best thing to do. Autoconf provides the @code{AC_OBSOLETE} macro to +warn users producing @code{configure} scripts when they use obsolete +macros, to encourage them to modernize. A sample call is: + +@example +AC_OBSOLETE([$0], [; use AC_CHECK_HEADERS(unistd.h) instead])dnl +@end example + +@defmac AC_OBSOLETE (@var{this-macro-name} @r{[}, @var{suggestion}@r{]}) +@maindex OBSOLETE +Make @code{m4} print a message on the standard error output warning that +@var{this-macro-name} is obsolete, and giving the file and line number +where it was called. @var{this-macro-name} should be the name of the +macro that is calling @code{AC_OBSOLETE}. If @var{suggestion} is given, +it is printed at the end of the warning message; for example, it can be +a suggestion for what to use instead of @var{this-macro-name}. +@end defmac + +@node Manual Configuration, Site Configuration, Writing Macros, Top +@chapter Manual Configuration + +A few kinds of features can't be guessed automatically by running test +programs. For example, the details of the object file format, or +special options that need to be passed to the compiler or linker. It is +possible to check for such features using ad-hoc means, such as having +@code{configure} check the output of the @code{uname} program, or +looking for libraries that are unique to particular systems. However, +Autoconf provides a uniform method for handling unguessable features. + +@menu +* Specifying Names:: Specifying the system type. +* Canonicalizing:: Getting the canonical system type. +* System Type Variables:: Variables containing the system type. +* Using System Type:: What to do with the system type. +@end menu + +@node Specifying Names, Canonicalizing, , Manual Configuration +@section Specifying the System Type + +Like other GNU @code{configure} scripts, Autoconf-generated +@code{configure} scripts can make decisions based on a canonical name +for the system type, which has the form: + +@example +@var{cpu}-@var{company}-@var{system} +@end example + +@code{configure} can usually guess the canonical name for the type of +system it's running on. To do so it runs a script called +@code{config.guess}, which derives the name using the @code{uname} +command or symbols predefined by the C preprocessor. + +Alternately, the user can specify the system type with command line +arguments to @code{configure}. Doing so is necessary when +cross-compiling. In the most complex case of cross-compiling, three +system types are involved. The options to specify them are: + +@table @code +@item --build=@var{build-type} +the type of system on which the package is being configured and +compiled (rarely needed); + +@item --host=@var{host-type} +the type of system on which the package will run; + +@item --target=@var{target-type} +the type of system for which any compiler tools in the package will +produce code. +@end table + +@noindent +If the user gives @code{configure} a non-option argument, it is used as +the default for the host, target, and build system types if the user +does not specify them explicitly with options. The target and build +types default to the host type if it is given and they are not. If you +are cross-compiling, you still have to specify the names of the +cross-tools you use, in particular the C compiler, on the +@code{configure} command line, e.g., + +@example +CC=m68k-coff-gcc configure --target=m68k-coff +@end example + +@code{configure} recognizes short aliases for many system types; for +example, @samp{decstation} can be given on the command line instead of +@samp{mips-dec-ultrix4.2}. @code{configure} runs a script called +@code{config.sub} to canonicalize system type aliases. + +@node Canonicalizing, System Type Variables, Specifying Names, Manual Configuration +@section Getting the Canonical System Type + +The following macros make the system type available to @code{configure} +scripts. They run the shell script @code{config.guess} to determine any +values for the host, target, and build types that they need and the user +did not specify on the command line. They run @code{config.sub} to +canonicalize any aliases the user gave. If you use these macros, you +must distribute those two shell scripts along with your source code. +@xref{Output}, for information about the @code{AC_CONFIG_AUX_DIR} macro +which you can use to control which directory @code{configure} looks for +those scripts in. If you do not use either of these macros, +@code{configure} ignores any @samp{--host}, @samp{--target}, and +@samp{--build} options given to it. + +@defmac AC_CANONICAL_SYSTEM +@maindex CANONICAL_SYSTEM +Determine the system type and set output variables to the names of the +canonical system types. @xref{System Type Variables}, for details about +the variables this macro sets. +@end defmac + +@defmac AC_CANONICAL_HOST +@maindex CANONICAL_HOST +Perform only the subset of @code{AC_CANONICAL_SYSTEM} relevant to the +host type. This is all that is needed for programs that are not part of +a compiler toolchain. +@end defmac + +@node System Type Variables, Using System Type, Canonicalizing, Manual Configuration +@section System Type Variables + +After calling @code{AC_CANONICAL_SYSTEM}, the following output variables +contain the system type information. After @code{AC_CANONICAL_HOST}, +only the @code{host} variables below are set. + +@table @code +@ovindex build +@ovindex host +@ovindex target +@item @code{build}, @code{host}, @code{target} +the canonical system names; + +@item @code{build_alias}, @code{host_alias}, @code{target_alias} +@ovindex build_alias +@ovindex host_alias +@ovindex target_alias +the names the user specified, or the canonical names if +@code{config.guess} was used; + +@item @code{build_cpu}, @code{build_vendor}, @code{build_os} +@itemx @code{host_cpu}, @code{host_vendor}, @code{host_os} +@itemx @code{target_cpu}, @code{target_vendor}, @code{target_os} +@ovindex build_cpu +@ovindex host_cpu +@ovindex target_cpu +@ovindex build_vendor +@ovindex host_vendor +@ovindex target_vendor +@ovindex build_os +@ovindex host_os +@ovindex target_os +the individual parts of the canonical names (for convenience). +@end table + +@node Using System Type, , System Type Variables, Manual Configuration +@section Using the System Type + +How do you use a canonical system type? Usually, you use it in one or +more @code{case} statements in @file{configure.in} to select +system-specific C files. Then link those files, which have names based +on the system name, to generic names, such as @file{host.h} or +@file{target.c}. The @code{case} statement patterns can use shell +wildcards to group several cases together, like in this fragment: + +@example +case "$target" in +i386-*-mach* | i386-*-gnu*) obj_format=aout emulation=mach bfd_gas=yes ;; +i960-*-bout) obj_format=bout ;; +esac +@end example + +@defmac AC_LINK_FILES (@var{source}@dots{}, @var{dest}@dots{}) +@maindex LINK_FILES +Make @code{AC_OUTPUT} link each of the existing files @var{source} to +the corresponding link name @var{dest}. Makes a symbolic link if +possible, otherwise a hard link. The @var{dest} and @var{source} names +should be relative to the top level source or build directory. + +For example, this call: + +@example +AC_LINK_FILES(config/$@{machine@}.h config/$@{obj_format@}.h, host.h object.h) +@end example + +@noindent +creates in the current directory @file{host.h}, which is a link to +@file{@var{srcdir}/config/$@{machine@}.h}, and @file{object.h}, which is a link +to @file{@var{srcdir}/config/$@{obj_format@}.h}. +@end defmac + +@node Site Configuration, Invoking configure, Manual Configuration, Top +@chapter Site Configuration + +@code{configure} scripts support several kinds of local configuration +decisions. There are ways for users to specify where external software +packages are, include or exclude optional features, install programs +under modified names, and set default values for @code{configure} +options. + +@menu +* External Software:: Working with other optional software. +* Package Options:: Selecting optional features. +* Site Details:: Configuring site details. +* Transforming Names:: Changing program names when installing. +* Site Defaults:: Giving @code{configure} local defaults. +@end menu + +@node External Software, Package Options, , Site Configuration +@section Working With External Software + +Some packages require, or can optionally use, other software packages +which are already installed. The user can give @code{configure} +command line options to specify which such external software to use. +The options have one of these forms: + +@example +--with-@var{package}@r{[}=@var{arg}@r{]} +--without-@var{package} +@end example + +For example, @samp{--with-gnu-ld} means work with the GNU linker instead +of some other linker. @samp{--with-x11} means work with X11. + +The user can give an argument by following the package name with +@samp{=} and the argument. Giving an argument of @samp{no} is for +packages that are used by default; it says to @emph{not} use the +package. An argument that is neither @samp{yes} nor @samp{no} could +include a name or number of a version of the other package, to specify +more precisely which other package this program is supposed to work +with. If no argument is given, it defaults to @samp{yes}. +@samp{--without-@var{package}} is equivalent to +@samp{--with-@var{package}=no}. + +For each external software package that may be used, @file{configure.in} +should call @code{AC_ARG_WITH} to detect whether the @code{configure} +user asked to use it. Whether each package is used or not by +default, and which arguments are valid, is up to you. + +@defmac AC_ARG_WITH (@var{package}, @var{help-string}, @var{action-if-true} @r{[}, @var{action-if-false}@r{]}) +@maindex ARG_WITH +If the user gave @code{configure} the option @samp{--with-@var{package}} +or @samp{--without-@var{package}}, run shell commands +@var{action-if-true}. Otherwise run shell commands +@var{action-if-false}. The name @var{package} indicates another +software package that this program should work with. It should consist +only of alphanumeric characters and dashes. + +The option's argument is available to the shell commands +@var{action-if-true} in the shell variable @code{withval}. + +The argument @var{help-string} is a description of the option which +looks like this: +@example + --with-readline support fancy command line editing +@end example +@noindent +@var{help-string} may be more than one line long, if more detail is +needed. Just make sure the columns line up in @samp{configure --help}. +Avoid tabs in the help string. You'll need to enclose it in @samp{[} +and @samp{]} in order to produce the leading spaces. +@end defmac + +@defmac AC_WITH (@var{package}, @var{action-if-true} @r{[}, @var{action-if-false}@r{]}) +@maindex WITH +This is an obsolete version of @code{AC_ARG_WITH} that does not +support providing a help string. +@end defmac + +@node Package Options, Site Details, External Software, Site Configuration +@section Choosing Package Options + +If a software package has optional compile-time features, the user can +give @code{configure} command line options to specify whether to +compile them. The options have one of these forms: + +@example +--enable-@var{feature}@r{[}=@var{arg}@r{]} +--disable-@var{feature} +@end example + +These options allow users to choose which optional features to build and +install. @samp{--enable-@var{feature}} options should never make a +feature behave differently or cause one feature to replace another. +They should only cause parts of the program to be built rather than left +out. + +The user can give an argument by following the feature name with +@samp{=} and the argument. Giving an argument of @samp{no} requests +that the feature @emph{not} be made available. A feature with an +argument looks like @samp{--enable-debug=stabs}. If no argument is +given, it defaults to @samp{yes}. @samp{--disable-@var{feature}} is +equivalent to @samp{--enable-@var{feature}=no}. + +For each optional feature, @file{configure.in} should call +@code{AC_ARG_ENABLE} to detect whether the @code{configure} user asked +to include it. Whether each feature is included or not by default, and +which arguments are valid, is up to you. + +@defmac AC_ARG_ENABLE (@var{feature}, @var{help-string}, @var{action-if-true} @r{[}, @var{action-if-false}@r{]}) +@maindex ARG_ENABLE +If the user gave @code{configure} the option +@samp{--enable-@var{feature}} or @samp{--disable-@var{feature}}, run +shell commands @var{action-if-true}. Otherwise run shell commands +@var{action-if-false}. The name @var{feature} indicates an optional +user-level facility. It should consist only of alphanumeric characters +and dashes. + +The option's argument is available to the shell commands +@var{action-if-true} in the shell variable @code{enableval}. +The @var{help-string} argument is like that of @code{AC_ARG_WITH} +(@pxref{External Software}). +@end defmac + +@defmac AC_ENABLE (@var{feature}, @var{action-if-true} @r{[}, @var{action-if-false}@r{]}) +@maindex ENABLE +This is an obsolete version of @code{AC_ARG_ENABLE} that does not +support providing a help string. +@end defmac + +@node Site Details, Transforming Names, Package Options, Site Configuration +@section Configuring Site Details + +Some software packages require complex site-specific information. Some +examples are host names to use for certain services, company names, and +email addresses to contact. Since some configuration scripts generated +by Metaconfig ask for such information interactively, people sometimes +wonder how to get that information in Autoconf-generated configuration +scripts, which aren't interactive. + +Such site configuration information should be put in a file that is +edited @emph{only by users}, not by programs. The location of the file +can either be based on the @code{prefix} variable, or be a standard +location such as the user's home directory. It could even be specified +by an environment variable. The programs should examine that file at +run time, rather than at compile time. That approach is more convenient +for users and makes the configuration process simpler than getting the +information while configuring. @xref{Directory Variables, , Variables +for Installation Directories, standards, GNU Coding Standards}, for more +information on where to put data files. + +@node Transforming Names, Site Defaults, Site Details, Site Configuration +@section Transforming Program Names When Installing + +Autoconf supports changing the names of programs when installing them. +In order to use these transformations, @file{configure.in} must call the +macro @code{AC_ARG_PROGRAM}. + +@defmac AC_ARG_PROGRAM +@maindex ARG_PROGRAM +@ovindex program_transform_name +Place in output variable @code{program_transform_name} a sequence of +@code{sed} commands for changing the names of installed programs. + +If any of the options described below are given to @code{configure}, +program names are transformed accordingly. Otherwise, if +@code{AC_CANONICAL_SYSTEM} has been called and a @samp{--target} value +is given that differs from the host type (specified with @samp{--host} +or defaulted by @code{config.sub}), the target type followed by a dash +is used as a prefix. Otherwise, no program name transformation is done. +@end defmac + +@menu +* Transformation Options:: @code{configure} options to transforme names. +* Transformation Examples:: Sample uses of transforming names. +* Transformation Rules:: @file{Makefile} uses of transforming names. +@end menu + +@node Transformation Options, Transformation Examples, , Transforming Names +@subsection Transformation Options + +You can specify name transformations by giving @code{configure} these +command line options: + +@table @code +@item --program-prefix=@var{prefix} +prepend @var{prefix} to the names; + +@item --program-suffix=@var{suffix} +append @var{suffix} to the names; + +@item --program-transform-name=@var{expression} +perform @code{sed} substitution @var{expression} on the names. +@end table + +@node Transformation Examples, Transformation Rules, Transformation Options, Transforming Names +@subsection Transformation Examples + +These transformations are useful with programs that can be part of a +cross-compilation development environment. For example, a +cross-assembler running on a Sun 4 configured with +@samp{--target=i960-vxworks} is normally installed as +@file{i960-vxworks-as}, rather than @file{as}, which could be confused +with a native Sun 4 assembler. + +You can force a program name to begin with @file{g}, if you don't want +GNU programs installed on your system to shadow other programs with the +same name. For example, if you configure GNU @code{diff} with +@samp{--program-prefix=g}, then when you run @samp{make install} it is +installed as @file{/usr/local/bin/gdiff}. + +As a more sophistocated example, you could use +@example +--program-transform-name='s/^/g/; s/^gg/g/; s/^gless/less/' +@end example +@noindent +to prepend @samp{g} to most of the program names in a source tree, +excepting those like @code{gdb} that already have one and those like +@code{less} and @code{lesskey} that aren't GNU programs. (That is +assuming that you have a source tree containing those programs that is +set up to use this feature.) + +One way to install multiple versions of some programs simultaneously is +to append a version number to the name of one or both. For example, if +you want to keep Autoconf version 1 around for awhile, you can configure +Autoconf version 2 using @samp{--program-suffix=2} to install the +programs as @file{/usr/local/bin/autoconf2}, +@file{/usr/local/bin/autoheader2}, etc. + +@node Transformation Rules, , Transformation Examples, Transforming Names +@subsection Transformation Rules + +Here is how to use the variable @code{program_transform_name} in a +@file{Makefile.in}: + +@example +transform=@@program_transform_name@@ +install: all + $(INSTALL_PROGRAM) myprog $(bindir)/`echo myprog|sed '$(transform)'` + +uninstall: + rm -f $(bindir)/`echo myprog|sed '$(transform)'` +@end example + +@noindent +If you have more than one program to install, you can do it in a loop: + +@example +PROGRAMS=cp ls rm +install: + for p in $(PROGRAMS); do \ + $(INSTALL_PROGRAM) $$p $(bindir)/`echo $$p|sed '$(transform)'`; \ + done + +uninstall: + for p in $(PROGRAMS); do \ + rm -f $(bindir)/`echo $$p|sed '$(transform)'`; \ + done +@end example + +Whether to do the transformations on documentation files (Texinfo or +@code{man}) is a tricky question; there seems to be no perfect answer, +due to the several reasons for name transforming. Documentation is not +usually particular to a specific architecture, and Texinfo files do not +conflict with system documentation. But they might conflict with +earlier versions of the same files, and @code{man} pages sometimes do +conflict with system documentation. As a compromise, it is probably +best to do name transformations on @code{man} pages but not on Texinfo +manuals. + +@node Site Defaults, , Transforming Names, Site Configuration +@section Setting Site Defaults + +Autoconf-generated @code{configure} scripts allow your site to provide +default values for some configuration values. You do this by creating +site- and system-wide initialization files. + +@evindex CONFIG_SITE +If the environment variable @code{CONFIG_SITE} is set, @code{configure} +uses its value as the name of a shell script to read. Otherwise, it +reads the shell script @file{@var{prefix}/share/config.site} if it exists, +then @file{@var{prefix}/etc/config.site} if it exists. Thus, +settings in machine-specific files override those in machine-independent +ones in case of conflict. + +Site files can be arbitrary shell scripts, but only certain kinds of +code are really appropriate to be in them. Because @code{configure} +reads any cache file after it has read any site files, a site file can +define a default cache file to be shared between all Autoconf-generated +@code{configure} scripts run on that system. If you set a default cache +file in a site file, it is a good idea to also set the output variable +@code{CC} in that site file, because the cache file is only valid for a +particular compiler, but many systems have several available. + +Site files are also good places to set default values for other output +variables, such as @code{CFLAGS}, if you need to give them non-default +values: anything you would normally do, repetitively, on the command +line. If you use non-default values for @var{prefix} or +@var{exec_prefix} (wherever you locate the site file), you can set them +in the site file if you specify it with the @code{CONFIG_SITE} +environment variable. + +You can set some cache values in the site file itself. Doing this is +useful if you are cross-compiling, so it is impossible to check features +that require running a test program. You could ``prime the cache'' by +setting those values correctly for that system in +@file{@var{prefix}/etc/config.site}. To find out the names of the cache +variables you need to set, look for shell variables with @samp{_cv_} in +their names in the affected @code{configure} scripts, or in the Autoconf +@code{m4} source code for those macros. + +The cache file is careful to not override any variables set in the site +files. Similarly, you should not override command-line options in the +site files. Your code should check that variables such as @code{prefix} +and @code{cache_file} have their default values (as set near the top of +@code{configure}) before changing them. + +Here is a sample file @file{/usr/share/local/gnu/share/config.site}. The +command @samp{configure --prefix=/usr/share/local/gnu} would read this +file (if @code{CONFIG_SITE} is not set to a different file). + +@example +# config.site for configure +# +# Default --prefix and --exec-prefix. +test "$prefix" = NONE && prefix=/usr/share/local/gnu +test "$exec_prefix" = NONE && exec_prefix=/usr/local/gnu +# +# Give Autoconf 2.x generated configure scripts a shared default +# cache file for feature test results, architecture-specific. +if test "$cache_file" = ./config.cache; then + cache_file="$prefix/var/config.cache" + # A cache file is only valid for one C compiler. + CC=gcc +fi +@end example + +@node Invoking configure, Invoking config.status, Site Configuration, Top +@chapter Running @code{configure} Scripts + +Below are instructions on how to configure a package that uses a +@code{configure} script, suitable for inclusion as an @file{INSTALL} +file in the package. A plain-text version of @file{INSTALL} which you +may use comes with Autoconf. + +@menu +* Basic Installation:: Instructions for typical cases. +* Compilers and Options:: Selecting compilers and optimization. +* Build Directory:: Configuring in a different directory. +* Installation Names:: Installing in different directories. +* Optional Features:: Selecting optional features. +* System Type:: Specifying the system type. +* Sharing Defaults:: Setting site-wide defaults for @code{configure}. +* Operation Controls:: Changing how @code{configure} runs. +@end menu + +@include install.texi + +@node Invoking config.status, Questions, Invoking configure, Top +@chapter Recreating a Configuration + +The @code{configure} script creates a file named @file{config.status} +which describes which configuration options were specified when the +package was last configured. This file is a shell script which, +if run, will recreate the same configuration. + +You can give @file{config.status} the @samp{--recheck} option to update +itself. This option is useful if you change @code{configure}, so that +the results of some tests might be different from the previous run. The +@samp{--recheck} option re-runs @code{configure} with the same arguments +you used before, plus the @samp{--no-create} option, which prevent +@code{configure} from running @file{config.status} and creating +@file{Makefile} and other files, and the @samp{--no-recursion} option, +which prevents @code{configure} from running other @code{configure} +scripts in subdirectories. (This is so other @file{Makefile} rules can +run @file{config.status} when it changes; @pxref{Automatic Remaking}, +for an example). + +@file{config.status} also accepts the options @samp{--help}, which +prints a summary of the options to @file{config.status}, and +@samp{--version}, which prints the version of Autoconf used to create +the @code{configure} script that generated @file{config.status}. + +@file{config.status} checks several optional environment variables that +can alter its behavior: + +@defvar CONFIG_SHELL +@evindex CONFIG_SHELL +The shell with which to run @code{configure} for the @samp{--recheck} +option. It must be Bourne-compatible. The default is @file{/bin/sh}. +@end defvar + +@defvar CONFIG_STATUS +@evindex CONFIG_STATUS +The file name to use for the shell script that records the +configuration. The default is @file{./config.status}. This variable is +useful when one package uses parts of another and the @code{configure} +scripts shouldn't be merged because they are maintained separately. +@end defvar + +The following variables provide one way for separately distributed +packages to share the values computed by @code{configure}. Doing so can +be useful if some of the packages need a superset of the features that +one of them, perhaps a common library, does. These variables allow a +@file{config.status} file to create files other than the ones that its +@file{configure.in} specifies, so it can be used for a different package. + +@defvar CONFIG_FILES +@evindex CONFIG_FILES +The files in which to perform @samp{@@@var{variable}@@} substitutions. +The default is the arguments given to @code{AC_OUTPUT} in @file{configure.in}. +@end defvar + +@defvar CONFIG_HEADERS +@evindex CONFIG_HEADERS +The files in which to substitute C @code{#define} statements. +The default is the arguments given to @code{AC_CONFIG_HEADER}; if that +macro was not called, @file{config.status} ignores this variable. +@end defvar + +These variables also allow you to write @file{Makefile} rules that +regenerate only some of the files. For example, in the dependencies +given above (@pxref{Automatic Remaking}), @file{config.status} is run +twice when @file{configure.in} has changed. If that bothers you, you +can make each run only regenerate the files for that rule: + +@example +@group +config.h: stamp-h +stamp-h: config.h.in config.status + CONFIG_FILES= CONFIG_HEADERS=config.h ./config.status + echo > stamp-h + +Makefile: Makefile.in config.status + CONFIG_FILES=Makefile CONFIG_HEADERS= ./config.status +@end group +@end example + +@noindent +(If @file{configure.in} does not call @code{AC_CONFIG_HEADER}, there is +no need to set @code{CONFIG_HEADERS} in the @code{make} rules.) + +@node Questions, Upgrading, Invoking config.status, Top +@chapter Questions About Autoconf + +Several questions about Autoconf come up occasionally. Here some of them +are addressed. + +@menu +* Distributing:: Distributing @code{configure} scripts. +* Why GNU m4:: Why not use the standard @code{m4}? +* Bootstrapping:: Autoconf and GNU @code{m4} require each other? +* Why Not Imake:: Why GNU uses @code{configure} instead of Imake. +@end menu + +@node Distributing, Why GNU m4, , Questions +@section Distributing @code{configure} Scripts + +@display +What are the restrictions on distributing @code{configure} +scripts that Autoconf generates? How does that affect my +programs that use them? +@end display + +There are no restrictions on how the configuration scripts that Autoconf +produces may be distributed or used. In Autoconf version 1, they were +covered by the GNU General Public License. We still encourage software +authors to distribute their work under terms like those of the GPL, but +doing so is not required to use Autoconf. + +Of the other files that might be used with @code{configure}, +@file{config.h.in} is under whatever copyright you use for your +@file{configure.in}, since it is derived from that file and from the +public domain file @file{acconfig.h}. @file{config.sub} and +@file{config.guess} have an exception to the GPL when they are used with +an Autoconf-generated @code{configure} script, which permits you to +distribute them under the same terms as the rest of your package. +@file{install-sh} is from the X Consortium and is not copyrighted. + +@node Why GNU m4, Bootstrapping, Distributing, Questions +@section Why Require GNU @code{m4}? + +@display +Why does Autoconf require GNU @code{m4}? +@end display + +Many @code{m4} implementations have hard-coded limitations on the size +and number of macros, which Autoconf exceeds. They also lack several +builtin macros that it would be difficult to get along without in a +sophisticated application like Autoconf, including: + +@example +builtin +indir +patsubst +__file__ +__line__ +@end example + +Since only software maintainers need to use Autoconf, and since GNU +@code{m4} is simple to configure and install, it seems reasonable to +require GNU @code{m4} to be installed also. Many maintainers of GNU and +other free software already have most of the GNU utilities installed, +since they prefer them. + +@node Bootstrapping, Why Not Imake, Why GNU m4, Questions +@section How Can I Bootstrap? + +@display +If Autoconf requires GNU @code{m4} and GNU @code{m4} has an +Autoconf @code{configure} script, how do I bootstrap? It seems +like a chicken and egg problem! +@end display + +This is a misunderstanding. Although GNU @code{m4} does come with a +@code{configure} script produced by Autoconf, Autoconf is not required +in order to run the script and install GNU @code{m4}. Autoconf is only +required if you want to change the @code{m4} @code{configure} script, +which few people have to do (mainly its maintainer). + +@node Why Not Imake, , Bootstrapping, Questions +@section Why Not Imake? + +@display +Why not use Imake instead of @code{configure} scripts? +@end display + +Several people have written addressing this question, so I include +adaptations of their explanations here. + +The following answer is based on one written by Richard Pixley: + +Autoconf generated scripts frequently work on machines which it has +never been set up to handle before. That is, it does a good job of +inferring a configuration for a new system. Imake cannot do this. + +Imake uses a common database of host specific data. For X11, this makes +sense because the distribution is made as a collection of tools, by one +central authority who has control over the database. + +GNU tools are not released this way. Each GNU tool has a maintainer; +these maintainers are scattered across the world. Using a common +database would be a maintenance nightmare. Autoconf may appear to be +this kind of database, but in fact it is not. Instead of listing host +dependencies, it lists program requirements. + +Imake is special-purpose. It is directed at building the X11 +distribution. By comparison to the GNU tools, this is a simple problem. +If you view the GNU suite as a collection of native tools, then the +problems are similar. But the GNU tools are more powerful than that. +The development tools can be configured as cross tools in almost any +host+target permutation. All of these configurations can be installed +concurrently. They can even be configured to share host independent +files across hosts. Imake doesn't address these issues. + +Imake templates are a form of standardization. The GNU coding standards +address the same issues without necessarily imposing the same +restrictions. + +Here is some further explanation, written by Per Bothner: + +One of the advantages of Imake is that it easy to generate large +Makefiles using @code{cpp}'s @samp{#include} and macro mechanisms. +However, @code{cpp} is not programmable: it has limited conditional +facilities, and no looping. And @code{cpp} cannot inspect its +environment. + +All of these problems are solved by using @code{sh} instead of +@code{cpp}. The shell is fully programmable, has macro substitution, +can execute (or source) other shell scripts, and can inspect its +environment. + +Paul Eggert elaborates more: + +With Autoconf, installers need not assume that Imake itself is already +installed and working well. This may not seem like much of an advantage +to people who are accustomed to Imake. But on many hosts Imake is not +installed or the default installation is not working well, and requiring +Imake to install a package hinders the acceptance of that package on +those hosts. For example, the Imake template and configuration files +might not be installed properly on a host, or the Imake build procedure +might wrongly assume that all source files are in one big directory +tree, or the Imake configuration might assume one compiler whereas the +package or the installer needs to use another, or there might be a +version mismatch between the Imake expected by the package and the Imake +suported by the host. These problems are much rarer with Autoconf, +where each package comes with its own independent configuration +processor. + +Also, Imake often suffers from unexpected interactions between +@code{make} and the installer's C preprocessor. The fundamental problem +here is that the C preprocessor was designed to preprocess C programs, +not @file{Makefile}s. This is much less of a problem with Autoconf, +which uses the general-purpose preprocessor @code{m4}, and where the +package's author (rather than the installer) does the preprocessing in a +standard way. + +Finally, Mark Eichin notes: + +Imake isn't all that extensible, either. In order to add new features to +Imake, you need to provide you own project template, and duplicate most +of the features of the existing one. This means that for a sophisticated +project, using the vendor-provided Imake templates fails to provide any +leverage---since they don't cover anything that your own project needs +(unless it is an X11 program). + +On the other side, though: + +The one advantage that Imake has over @code{configure}: +@file{Imakefile}s tend to be much shorter (likewise, less redundant) +than @file{Makefile.in}s. There is a fix to this, however---at least +for the Kerberos V5 tree, we've modified things to call in common +@file{post.in} and @file{pre.in} @file{Makefile} fragments for the +entire tree. This means that a lot of common things don't have to be +duplicated, even though they normally are in @code{configure} setups. + +@node Upgrading, History, Questions, Top +@chapter Upgrading From Version 1 + +Autoconf version 2 is mostly backward compatible with version 1. +However, it introduces better ways to do some things, and doesn't +support some of the ugly things in version 1. So, depending on how +sophisticated your @file{configure.in} files are, you might have to do +some manual work in order to upgrade to version 2. This chapter points +out some problems to watch for when upgrading. Also, perhaps your +@code{configure} scripts could benefit from some of the new features in +version 2; the changes are summarized in the file @file{NEWS} in the +Autoconf distribution. + +First, make sure you have GNU @code{m4} version 1.1 or higher installed, +preferably 1.3 or higher. Versions before 1.1 have bugs that prevent +them from working with Autoconf version 2. Versions 1.3 and later are +much faster than earlier versions, because as of version 1.3, GNU +@code{m4} has a more efficient implementation of diversions and can +freeze its internal state in a file that it can read back quickly. + +@menu +* Changed File Names:: Files you might rename. +* Changed Makefiles:: New things to put in @file{Makefile.in}. +* Changed Macros:: Macro calls you might replace. +* Invoking autoupdate:: Replacing old macro names in @code{configure.in}. +* Changed Results:: Changes in how to check test results. +* Changed Macro Writing:: Better ways to write your own macros. +@end menu + +@node Changed File Names, Changed Makefiles, , Upgrading +@section Changed File Names + +If you have an @file{aclocal.m4} installed with Autoconf (as opposed to +in a particular package's source directory), you must rename it to +@file{acsite.m4}. @xref{Invoking autoconf}. + +If you distribute @file{install.sh} with your package, rename it to +@file{install-sh} so @code{make} builtin rules won't inadvertantly +create a file called @file{install} from it. @code{AC_PROG_INSTALL} +looks for the script under both names, but it is best to use the new name. + +If you were using @file{config.h.top} or @file{config.h.bot}, you still +can, but you will have less clutter if you merge them into +@file{acconfig.h}. @xref{Invoking autoheader}. + +@node Changed Makefiles, Changed Macros, Changed File Names, Upgrading +@section Changed Makefiles + +Add @samp{@@CFLAGS@@}, @samp{@@CPPFLAGS@@}, and @samp{@@LDFLAGS@@} in +your @file{Makefile.in} files, so they can take advantage of the values +of those variables in the environment when @code{configure} is run. +Doing this isn't necessary, but it's a convenience for users. + +Also add @samp{@@configure_input@@} in a comment to each input file for +@code{AC_OUTPUT}, so that the output files will contain a comment saying +they were produced by @code{configure}. Automatically selecting the +right comment syntax for all the kinds of files that people call +@code{AC_OUTPUT} on became too much work. + +Add @file{config.log} and @file{config.cache} to the list of files you +remove in @code{distclean} targets. + +If you have the following in @file{Makefile.in}: + +@example +prefix = /usr/local +exec_prefix = $@{prefix@} +@end example + +@noindent +you must change it to: + +@example +prefix = @@prefix@@ +exec_prefix = @@exec_prefix@@ +@end example + +@noindent +The old feature of replacing those variables without @samp{@@} +characters around them has been removed. + +@node Changed Macros, Invoking autoupdate, Changed Makefiles, Upgrading +@section Changed Macros + +Many of the macros were renamed in Autoconf version 2. You can still +use the old names, but the new ones are clearer, and it's easier to find +the documentation for them. @xref{Old Macro Names}, for a table showing +the new names for the old macros. Use the @code{autoupdate} program to +convert your @file{configure.in} to using the new macro names. +@xref{Invoking autoupdate}. + +Some macros have been superseded by similar ones that do the job better, +but are not call-compatible. If you get warnings about calling obsolete +macros while running @code{autoconf}, you may safely ignore them, but +your @code{configure} script will generally work better if you follow +the advice it prints about what to replace the obsolete macros with. In +particular, the mechanism for reporting the results of tests has +changed. If you were using @code{echo} or @code{AC_VERBOSE} (perhaps +via @code{AC_COMPILE_CHECK}), your @code{configure} script's output will +look better if you switch to @code{AC_MSG_CHECKING} and +@code{AC_MSG_RESULT}. @xref{Printing Messages}. Those macros work best +in conjunction with cache variables. @xref{Caching Results}. + +@node Invoking autoupdate, Changed Results, Changed Macros, Upgrading +@section Using @code{autoupdate} to Modernize @code{configure} + +The @code{autoupdate} program updates a @file{configure.in} file that +calls Autoconf macros by their old names to use the current macro names. +In version 2 of Autoconf, most of the macros were renamed to use a more +uniform and descriptive naming scheme. @xref{Macro Names}, for a +description of the new scheme. Although the old names still work +(@pxref{Old Macro Names}, for a list of the old macro names and the +corresponding new names), you can make your @file{configure.in} files +more readable and make it easier to use the current Autoconf +documentation if you update them to use the new macro names. + +@evindex SIMPLE_BACKUP_SUFFIX +If given no arguments, @code{autoupdate} updates @file{configure.in}, +backing up the original version with the suffix @file{~} (or the value +of the environment variable @code{SIMPLE_BACKUP_SUFFIX}, if that is +set). If you give @code{autoupdate} an argument, it reads that file +instead of @file{configure.in} and writes the updated file to the +standard output. + +@noindent +@code{autoupdate} accepts the following options: + +@table @code +@item --help +@itemx -h +Print a summary of the command line options and exit. + +@item --macrodir=@var{dir} +@itemx -m @var{dir} +@evindex AC_MACRODIR +Look for the Autoconf macro files in directory @var{dir} instead of the +default installation directory. +You can also set the @code{AC_MACRODIR} +environment variable to a directory; this option overrides the +environment variable. + +@item --version +Print the version number of @code{autoupdate} and exit. +@end table + +@node Changed Results, Changed Macro Writing, Invoking autoupdate, Upgrading +@section Changed Results + +If you were checking the results of previous tests by examining the +shell variable @code{DEFS}, you need to switch to checking the values of +the cache variables for those tests. @code{DEFS} no longer exists while +@code{configure} is running; it is only created when generating output +files. This difference from version 1 is because properly quoting the +contents of that variable turned out to be too cumbersome and +inefficient to do every time @code{AC_DEFINE} is called. @xref{Cache +Variable Names}. + +For example, here is a @file{configure.in} fragment written for Autoconf +version 1: + +@example +AC_HAVE_FUNCS(syslog) +case "$DEFS" in +*-DHAVE_SYSLOG*) ;; +*) # syslog is not in the default libraries. See if it's in some other. + saved_LIBS="$LIBS" + for lib in bsd socket inet; do + AC_CHECKING(for syslog in -l$lib) + LIBS="$saved_LIBS -l$lib" + AC_HAVE_FUNCS(syslog) + case "$DEFS" in + *-DHAVE_SYSLOG*) break ;; + *) ;; + esac + LIBS="$saved_LIBS" + done ;; +esac +@end example + +Here is a way to write it for version 2: + +@example +AC_CHECK_FUNCS(syslog) +if test $ac_cv_func_syslog = no; then + # syslog is not in the default libraries. See if it's in some other. + for lib in bsd socket inet; do + AC_CHECK_LIB($lib, syslog, [AC_DEFINE(HAVE_SYSLOG) + LIBS="$LIBS $lib"; break]) + done +fi +@end example + +If you were working around bugs in @code{AC_DEFINE_UNQUOTED} by adding +backslashes before quotes, you need to remove them. It now works +predictably, and does not treat quotes (except backquotes) specially. +@xref{Setting Output Variables}. + +All of the boolean shell variables set by Autoconf macros now use +@samp{yes} for the true value. Most of them use @samp{no} for false, +though for backward compatibility some use the empty string instead. If +you were relying on a shell variable being set to something like 1 or +@samp{t} for true, you need to change your tests. + +@node Changed Macro Writing, , Changed Results, Upgrading +@section Changed Macro Writing + +When defining your own macros, you should now use @code{AC_DEFUN} +instead of @code{define}. @code{AC_DEFUN} automatically calls +@code{AC_PROVIDE} and ensures that macros called via @code{AC_REQUIRE} +do not interrupt other macros, to prevent nested @samp{checking@dots{}} +messages on the screen. There's no actual harm in continuing to use the +older way, but it's less convenient and attractive. @xref{Macro +Definitions}. + +You probably looked at the macros that came with Autoconf as a guide for +how to do things. It would be a good idea to take a look at the new +versions of them, as the style is somewhat improved and they take +advantage of some new features. + +If you were doing tricky things with undocumented Autoconf internals +(macros, variables, diversions), check whether you need to change +anything to account for changes that have been made. Perhaps you can +even use an officially supported technique in version 2 instead of +kludging. Or perhaps not. + +To speed up your locally written feature tests, add caching to them. +See whether any of your tests are of general enough usefulness to +encapsulate into macros that you can share. + +@node History, Old Macro Names, Upgrading, Top +@chapter History of Autoconf + +You may be wondering, Why was Autoconf originally written? How did it +get into its present form? (Why does it look like gorilla spit?) If +you're not wondering, then this chapter contains no information useful +to you, and you might as well skip it. If you @emph{are} wondering, +then let there be light@dots{} + +@menu +* Genesis:: Prehistory and naming of @code{configure}. +* Exodus:: The plagues of @code{m4} and Perl. +* Leviticus:: The priestly code of portability arrives. +* Numbers:: Growth and contributors. +* Deuteronomy:: Approaching the promises of easy configuration. +@end menu + +@node Genesis, Exodus, , History +@section Genesis + +In June 1991 I was maintaining many of the GNU utilities for the Free +Software Foundation. As they were ported to more platforms and more +programs were added, the number of @samp{-D} options that users had to +select in the @file{Makefile} (around 20) became burdensome. Especially +for me---I had to test each new release on a bunch of different systems. +So I wrote a little shell script to guess some of the correct settings +for the fileutils package, and released it as part of fileutils 2.0. +That @code{configure} script worked well enough that the next month I +adapted it (by hand) to create similar @code{configure} scripts for +several other GNU utilities packages. Brian Berliner also adapted one +of my scripts for his CVS revision control system. + +Later that summer, I learned that Richard Stallman and Richard Pixley +were developing similar scripts to use in the GNU compiler tools; so I +adapted my @code{configure} scripts to support their evolving interface: +using the file name @file{Makefile.in} as the templates; adding +@samp{+srcdir}, the first option (of many); and creating +@file{config.status} files. + +@node Exodus, Leviticus, Genesis, History +@section Exodus + +As I got feedback from users, I incorporated many improvements, using +Emacs to search and replace, cut and paste, similar changes in each of +the scripts. As I adapted more GNU utilities packages to use +@code{configure} scripts, updating them all by hand became impractical. +Rich Murphey, the maintainer of the GNU graphics utilities, sent me mail +saying that the @code{configure} scripts were great, and asking if I had +a tool for generating them that I could send him. No, I thought, but +I should! So I started to work out how to generate them. And the +journey from the slavery of hand-written @code{configure} scripts to the +abundance and ease of Autoconf began. + +Cygnus @code{configure}, which was being developed at around that time, +is table driven; it is meant to deal mainly with a discrete number of +system types with a small number of mainly unguessable features (such as +details of the object file format). The automatic configuration system +that Brian Fox had developed for Bash takes a similar approach. For +general use, it seems to me a hopeless cause to try to maintain an +up-to-date database of which features each variant of each operating +system has. It's easier and more reliable to check for most features on +the fly---especially on hybrid systems that people have hacked on +locally or that have patches from vendors installed. + +I considered using an architecture similar to that of Cygnus +@code{configure}, where there is a single @code{configure} script that +reads pieces of @file{configure.in} when run. But I didn't want to have +to distribute all of the feature tests with every package, so I settled +on having a different @code{configure} made from each +@file{configure.in} by a preprocessor. That approach also offered more +control and flexibility. + +I looked briefly into using the Metaconfig package, by Larry Wall, +Harlan Stenn, and Raphael Manfredi, but I decided not to for several +reasons. The @code{Configure} scripts it produces are interactive, +which I find quite inconvenient; I didn't like the ways it checked for +some features (such as library functions); I didn't know that it was +still being maintained, and the @code{Configure} scripts I had +seen didn't work on many modern systems (such as System V R4 and NeXT); +it wasn't very flexible in what it could do in response to a feature's +presence or absence; I found it confusing to learn; and it was too big +and complex for my needs (I didn't realize then how much Autoconf would +eventually have to grow). + +I considered using Perl to generate my style of @code{configure} scripts, +but decided that @code{m4} was better suited to the job of simple +textual substitutions: it gets in the way less, because output is +implicit. Plus, everyone already has it. (Initially I didn't rely on +the GNU extensions to @code{m4}.) Also, some of my friends at the +University of Maryland had recently been putting @code{m4} front ends on +several programs, including @code{tvtwm}, and I was interested in trying +out a new language. + +@node Leviticus, Numbers, Exodus, History +@section Leviticus + +Since my @code{configure} scripts determine the system's capabilities +automatically, with no interactive user intervention, I decided to call +the program that generates them Autoconfig. But with a version number +tacked on, that name would be too long for old UNIX file systems, so +I shortened it to Autoconf. + +In the fall of 1991 I called together a group of fellow questers after +the Holy Grail of portability (er, that is, alpha testers) to give me +feedback as I encapsulated pieces of my handwritten scripts in @code{m4} +macros and continued to add features and improve the techniques used in +the checks. Prominent among the testers were +@ifinfo +Franc,ois +@end ifinfo +@tex +Fran\c cois +@end tex +Pinard, who came up with the idea of making an @file{autoconf} shell +script to run @code{m4} and check for unresolved macro calls; Richard +Pixley, who suggested running the compiler instead of searching the file +system to find include files and symbols, for more accurate results; +Karl Berry, who got Autoconf to configure @TeX{} and added the +macro index to the documentation; and Ian Taylor, who added support for +creating a C header file as an alternative to putting @samp{-D} options +in a @file{Makefile}, so he could use Autoconf for his UUCP package. The +alpha testers cheerfully adjusted their files again and again as the +names and calling conventions of the Autoconf macros changed from +release to release. They all contributed many specific checks, great +ideas, and bug fixes. + +@node Numbers, Deuteronomy, Leviticus, History +@section Numbers + +In July 1992, after months of alpha testing, I released Autoconf 1.0, +and converted many GNU packages to use it. I was surprised by how +positive the reaction to it was. More people started using it than I +could keep track of, including people working on software that wasn't +part of the GNU Project (such as TCL, FSP, and Kerberos V5). +Autoconf continued to improve rapidly, as many people using the +@code{configure} scripts reported problems they encountered. + +Autoconf turned out to be a good torture test for @code{m4} +implementations. UNIX @code{m4} started to dump core because of the +length of the macros that Autoconf defined, and several bugs showed up +in GNU @code{m4} as well. Eventually, we realized that we needed to use +some features that only GNU @code{m4} has. 4.3BSD @code{m4}, in +particular, has an impoverished set of builtin macros; the System V +version is better, but still doesn't provide everything we need. + +More development occurred as people put Autoconf under more stresses +(and to uses I hadn't anticipated). Karl Berry added checks for X11. +david zuhn contributed C++ support. +@ifinfo +Franc,ois +@end ifinfo +@tex +Fran\c cois +@end tex +Pinard made it diagnose invalid arguments. Jim Blandy bravely coerced +it into configuring GNU Emacs, laying the groundwork for several later +improvements. Roland McGrath got it to configure the GNU C Library, +wrote the @code{autoheader} script to automate the creation of C header +file templates, and added a @samp{--verbose} option to @code{configure}. +Noah Friedman added the @samp{--macrodir} option and @code{AC_MACRODIR} +environment variable. (He also coined the term @dfn{autoconfiscate} to +mean ``adapt a software package to use Autoconf''.) Roland and Noah +improved the quoting protection in @code{AC_DEFINE} and fixed many bugs, +especially when I got sick of dealing with portability problems from +February through June, 1993. + +@node Deuteronomy, , Numbers, History +@section Deuteronomy + +A long wish list for major features had accumulated, and the effect of +several years of patching by various people had left some residual +cruft. In April 1994, while working for Cygnus Support, I began a major +revision of Autoconf. I added most of the features of the Cygnus +@code{configure} that Autoconf had lacked, largely by adapting the +relevant parts of Cygnus @code{configure} with the help of david zuhn +and Ken Raeburn. These features include support for using +@file{config.sub}, @file{config.guess}, @samp{--host}, and +@samp{--target}; making links to files; and running @code{configure} +scripts in subdirectories. Adding these features enabled Ken to convert +GNU @code{as}, and Rob Savoye to convert DejaGNU, to using Autoconf. + +I added more features in response to other peoples' requests. Many +people had asked for @code{configure} scripts to share the results of +the checks between runs, because (particularly when configuring a large +source tree, like Cygnus does) they were frustratingly slow. Mike +Haertel suggested adding site-specific initialization scripts. People +distributing software that had to unpack on MS-DOS asked for a way to +override the @file{.in} extension on the file names, which produced file +names like @file{config.h.in} containing two dots. Jim Avera did an +extensive examination of the problems with quoting in @code{AC_DEFINE} +and @code{AC_SUBST}; his insights led to significant improvements. +Richard Stallman asked that compiler output be sent to @file{config.log} +instead of @file{/dev/null}, to help people debug the Emacs +@code{configure} script. + +I made some other changes because of my dissatisfaction with the quality +of the program. I made the messages showing results of the checks less +ambiguous, always printing a result. I regularized the names of the +macros and cleaned up coding style inconsistencies. I added some +auxiliary utilities that I had developed to help convert source code +packages to use Autoconf. With the help of +@ifinfo +Franc,ois +@end ifinfo +@tex +Fran\c cois +@end tex +Pinard, I made the macros not interrupt each others' messages. +(That feature revealed some performance bottlenecks in GNU @code{m4}, +which he hastily corrected!) +I reorganized the documentation around problems people want to solve. +And I began a testsuite, because experience +had shown that Autoconf has a pronounced tendency to regress when we +change it. + +Again, several alpha testers gave invaluable feedback, especially +@ifinfo +Franc,ois +@end ifinfo +@tex +Fran\c cois +@end tex +Pinard, Jim Meyering, Karl Berry, Rob Savoye, Ken Raeburn, and Mark Eichin. + +Finally, version 2.0 was ready. And there was much rejoicing. +(And I have free time again. I think. Yeah, right.) + +@node Old Macro Names, Environment Variable Index, History, Top +@chapter Old Macro Names + +In version 2 of Autoconf, most of the macros were renamed to use a more +uniform and descriptive naming scheme. Here are the old names of the +macros that were renamed, followed by the current names of those macros. +Although the old names are still accepted by the @code{autoconf} program +for backward compatibility, the old names are considered obsolete. +@xref{Macro Names}, for a description of the new naming scheme. + +@table @code +@item AC_ALLOCA +@maindex ALLOCA +@code{AC_FUNC_ALLOCA} +@item AC_ARG_ARRAY +@maindex ARG_ARRAY +removed because of limited usefulness +@item AC_CHAR_UNSIGNED +@maindex CHAR_UNSIGNED +@code{AC_C_CHAR_UNSIGNED} +@item AC_CONST +@maindex CONST +@code{AC_C_CONST} +@item AC_CROSS_CHECK +@maindex CROSS_CHECK +@code{AC_C_CROSS} +@item AC_ERROR +@maindex ERROR +@code{AC_MSG_ERROR} +@item AC_FIND_X +@maindex FIND_X +@code{AC_PATH_X} +@item AC_FIND_XTRA +@maindex FIND_XTRA +@code{AC_PATH_XTRA} +@item AC_FUNC_CHECK +@maindex FUNC_CHECK +@code{AC_CHECK_FUNC} +@item AC_GCC_TRADITIONAL +@maindex GCC_TRADITIONAL +@code{AC_PROG_GCC_TRADITIONAL} +@item AC_GETGROUPS_T +@maindex GETGROUPS_T +@code{AC_TYPE_GETGROUPS} +@item AC_GETLOADAVG +@maindex GETLOADAVG +@code{AC_FUNC_GETLOADAVG} +@item AC_HAVE_FUNCS +@maindex HAVE_FUNCS +@code{AC_CHECK_FUNCS} +@item AC_HAVE_HEADERS +@maindex HAVE_HEADERS +@code{AC_CHECK_HEADERS} +@item AC_HAVE_POUNDBANG +@maindex HAVE_POUNDBANG +@code{AC_SYS_INTERPRETER} (different calling convention) +@item AC_HEADER_CHECK +@maindex HEADER_CHECK +@code{AC_CHECK_HEADER} +@item AC_HEADER_EGREP +@maindex HEADER_EGREP +@code{AC_EGREP_HEADER} +@item AC_INLINE +@maindex INLINE +@code{AC_C_INLINE} +@item AC_LN_S +@maindex LN_S +@code{AC_PROG_LN_S} +@item AC_LONG_DOUBLE +@maindex LONG_DOUBLE +@code{AC_C_LONG_DOUBLE} +@item AC_LONG_FILE_NAMES +@maindex LONG_FILE_NAMES +@code{AC_SYS_LONG_FILE_NAMES} +@item AC_MAJOR_HEADER +@maindex MAJOR_HEADER +@code{AC_HEADER_MAJOR} +@item AC_MINUS_C_MINUS_O +@maindex MINUS_C_MINUS_O +@code{AC_PROG_CC_C_O} +@item AC_MMAP +@maindex MMAP +@code{AC_FUNC_MMAP} +@item AC_MODE_T +@maindex MODE_T +@code{AC_TYPE_MODE_T} +@item AC_OFF_T +@maindex OFF_T +@code{AC_TYPE_OFF_T} +@item AC_PID_T +@maindex PID_T +@code{AC_TYPE_PID_T} +@item AC_PREFIX +@maindex PREFIX +@code{AC_PREFIX_PROGRAM} +@item AC_PROGRAMS_CHECK +@maindex PROGRAMS_CHECK +@code{AC_CHECK_PROGS} +@item AC_PROGRAMS_PATH +@maindex PROGRAMS_PATH +@code{AC_PATH_PROGS} +@item AC_PROGRAM_CHECK +@maindex PROGRAM_CHECK +@code{AC_CHECK_PROG} +@item AC_PROGRAM_EGREP +@maindex PROGRAM_EGREP +@code{AC_EGREP_CPP} +@item AC_PROGRAM_PATH +@maindex PROGRAM_PATH +@code{AC_PATH_PROG} +@item AC_REMOTE_TAPE +@maindex REMOTE_TAPE +removed because of limited usefulness +@item AC_RESTARTABLE_SYSCALLS +@maindex RESTARTABLE_SYSCALLS +@code{AC_SYS_RESTARTABLE_SYSCALLS} +@item AC_RETSIGTYPE +@maindex RETSIGTYPE +@code{AC_TYPE_SIGNAL} +@item AC_RSH +@maindex RSH +removed because of limited usefulness +@item AC_SETVBUF_REVERSED +@maindex SETVBUF_REVERSED +@code{AC_FUNC_SETVBUF_REVERSED} +@item AC_SET_MAKE +@maindex SET_MAKE +@code{AC_PROG_MAKE_SET} +@item AC_SIZEOF_TYPE +@maindex SIZEOF_TYPE +@code{AC_CHECK_SIZEOF} +@item AC_SIZE_T +@maindex SIZE_T +@code{AC_TYPE_SIZE_T} +@item AC_STAT_MACROS_BROKEN +@maindex STAT_MACROS_BROKEN +@code{AC_HEADER_STAT} +@item AC_STDC_HEADERS +@maindex STDC_HEADERS +@code{AC_HEADER_STDC} +@item AC_STRCOLL +@maindex STRCOLL +@code{AC_FUNC_STRCOLL} +@item AC_ST_BLKSIZE +@maindex ST_BLKSIZE +@code{AC_STRUCT_ST_BLKSIZE} +@item AC_ST_BLOCKS +@maindex ST_BLOCKS +@code{AC_STRUCT_ST_BLOCKS} +@item AC_ST_RDEV +@maindex ST_RDEV +@code{AC_STRUCT_ST_RDEV} +@item AC_SYS_SIGLIST_DECLARED +@maindex SYS_SIGLIST_DECLARED +@code{AC_DECL_SYS_SIGLIST} +@item AC_TEST_CPP +@maindex TEST_CPP +@code{AC_TRY_CPP} +@item AC_TEST_PROGRAM +@maindex TEST_PROGRAM +@code{AC_TRY_RUN} +@item AC_TIMEZONE +@maindex TIMEZONE +@code{AC_STRUCT_TIMEZONE} +@item AC_TIME_WITH_SYS_TIME +@maindex TIME_WITH_SYS_TIME +@code{AC_HEADER_TIME} +@item AC_UID_T +@maindex UID_T +@code{AC_TYPE_UID_T} +@item AC_UTIME_NULL +@maindex UTIME_NULL +@code{AC_FUNC_UTIME_NULL} +@item AC_VFORK +@maindex VFORK +@code{AC_FUNC_VFORK} +@item AC_VPRINTF +@maindex VPRINTF +@code{AC_FUNC_VPRINTF} +@item AC_WAIT3 +@maindex WAIT3 +@code{AC_FUNC_WAIT3} +@item AC_WARN +@maindex WARN +@code{AC_MSG_WARN} +@item AC_WORDS_BIGENDIAN +@maindex WORDS_BIGENDIAN +@code{AC_C_BIGENDIAN} +@item AC_YYTEXT_POINTER +@maindex YYTEXT_POINTER +@code{AC_DECL_YYTEXT} +@end table + +@node Environment Variable Index, Output Variable Index, Old Macro Names, Top +@unnumbered Environment Variable Index + +This is an alphabetical list of the environment variables that Autoconf +checks. + +@printindex ev + +@node Output Variable Index, Preprocessor Symbol Index, Environment Variable Index, Top +@unnumbered Output Variable Index + +This is an alphabetical list of the variables that Autoconf can +substitute into files that it creates, typically one or more +@file{Makefile}s. @xref{Setting Output Variables}, for more information on how +this is done. + +@printindex ov + +@node Preprocessor Symbol Index, Macro Index, Output Variable Index, Top +@unnumbered Preprocessor Symbol Index + +This is an alphabetical list of the C preprocessor symbols that the +Autoconf macros define. To work with Autoconf, C source code needs to +use these names in @code{#if} directives. + +@printindex cv + +@node Macro Index, , Preprocessor Symbol Index, Top +@unnumbered Macro Index + +This is an alphabetical list of the Autoconf macros. To make the list +easier to use, the macros are listed without their preceding @samp{AC_}. + +@printindex ma + +@contents +@bye diff --git a/util/autoconf/autoreconf.sh b/util/autoconf/autoreconf.sh new file mode 100644 index 0000000..4b83f80 --- /dev/null +++ b/util/autoconf/autoreconf.sh @@ -0,0 +1,149 @@ +#!/bin/sh +# autoreconf - remake all Autoconf configure scripts in a directory tree +# Copyright (C) 1994 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +usage="\ +Usage: autoreconf [-f] [-h] [--help] [-m dir] [--macrodir=dir] + [-l dir] [--localdir=dir] [--force] [--verbose] [--version]" + +localdir= +verbose=no +show_version=no +force=no + +test -z "$AC_MACRODIR" && AC_MACRODIR=@datadir@ + +while test $# -gt 0; do + case "$1" in + -h | --help | --h*) + echo "$usage"; exit 0 ;; + --localdir=* | --l*=* ) + localdir="`echo \"${1}\" | sed -e 's/^[^=]*=//'`" + shift ;; + -l | --localdir | --l*) + shift + test $# -eq 0 && { echo "${usage}" 1>&2; exit 1; } + localdir="${1}" + shift ;; + --macrodir=* | --m*=* ) + AC_MACRODIR="`echo \"$1\" | sed -e 's/^[^=]*=//'`" + shift ;; + -m | --macrodir | --m*) + shift + test $# -eq 0 && { echo "$usage" 1>&2; exit 1; } + AC_MACRODIR="$1" + shift ;; + --verbose | --verb*) + verbose=yes; shift ;; + -f | --force) + force=yes; shift ;; + --version | --vers*) + show_version=yes; shift ;; + --) # Stop option processing. + shift; break ;; + -*) echo "$usage" 1>&2; exit 1 ;; + *) break ;; + esac +done + +if test $show_version = yes; then + version=`sed -n 's/define.AC_ACVERSION.[ ]*\([0-9.]*\).*/\1/p' \ + $AC_MACRODIR/acgeneral.m4` + echo "Autoconf version $version" + exit 0 +fi + +if test $# -ne 0; then + echo "$usage" 1>&2; exit 1 +fi + +top_autoconf=`echo $0|sed s%autoreconf%autoconf%` +top_autoheader=`echo $0|sed s%autoreconf%autoheader%` + +# The xargs grep filters out Cygnus configure.in files. +find . -name configure.in -print | +xargs grep -l AC_OUTPUT | +sed 's%/configure\.in$%%; s%^./%%' | +while read dir; do + ( + cd $dir || continue + + case "$dir" in + .) dots= ;; + *) # A "../" for each directory in /$dir. + dots=`echo /$dir|sed 's%/[^/]*%../%g'` ;; + esac + + case "$0" in + /*) autoconf=$top_autoconf; autoheader=$top_autoheader ;; + */*) autoconf=$dots$top_autoconf; autoheader=$dots$top_autoheader ;; + *) autoconf=$top_autoconf; autoheader=$top_autoheader ;; + esac + + case "$AC_MACRODIR" in + /*) macrodir_opt="--macrodir=$AC_MACRODIR" ;; + *) macrodir_opt="--macrodir=$dots$AC_MACRODIR" ;; + esac + + case "$localdir" in + "") localdir_opt= + aclocal=aclocal.m4 ;; + /*) localdir_opt="--localdir=$localdir" + aclocal=$localdir/aclocal.m4 ;; + *) localdir_opt="--localdir=$dots$localdir" + aclocal=$dots$localdir/aclocal.m4 ;; + esac + + test ! -f $aclocal && aclocal= + + if test $force = no && test -f configure && + ls -lt configure configure.in $aclocal | sed 1q | + grep 'configure$' > /dev/null + then + : + else + test $verbose = yes && echo running autoconf in $dir + $autoconf $macrodir_opt $localdir_opt + fi + + if grep AC_CONFIG_HEADER configure.in >/dev/null; then + template=`sed -n '/AC_CONFIG_HEADER/{ +s%[^#]*AC_CONFIG_HEADER(\([^)]*\).*%\1% +t here +: here +s%.*:%% +t colon +s%$%.in% +: colon +p +q +}' configure.in` + if test ! -f $template || grep autoheader $template >/dev/null; then + if test $force = no && test -f $template && + ls -lt $template configure.in $aclocal | sed 1q | + grep "$template$" > /dev/null + then + : + else + test $verbose = yes && echo running autoheader in $dir + $autoheader $macrodir_opt $localdir_opt + fi + fi + fi + ) +done + diff --git a/util/autoconf/autoscan.pl b/util/autoconf/autoscan.pl new file mode 100644 index 0000000..9f26bfb --- /dev/null +++ b/util/autoconf/autoscan.pl @@ -0,0 +1,394 @@ +#!@PERL@ +# autoscan - Create configure.scan (a preliminary configure.in) for a package. +# Copyright (C) 1994 Free Software Foundation, Inc. + +# This program is free software; you can redistribute it and/or modify +# it under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2, or (at your option) +# any later version. + +# This program is distributed in the hope that it will be useful, +# but WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the +# GNU General Public License for more details. + +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +# Written by David MacKenzie <djm@gnu.ai.mit.edu>. + +require "find.pl"; + +$datadir = $ENV{"AC_MACRODIR"} || "@datadir@"; +$verbose = 0; +# Reference these variables to pacify perl -w. +undef %identifiers_macros; +undef %makevars_macros; +undef %programs_macros; + +&parse_args; +&init_tables; +&find('.'); +&scan_files; +&output; + +exit 0; + +# Process any command line arguments. +sub parse_args +{ + local ($usage) = + "Usage: autoscan [--macrodir=dir] [--help] [--verbose] [--version] [srcdir]\n"; + + foreach $_ (@ARGV) { + if (/^--m[a-z]*=(.*)/) { + $datadir = $1; + } elsif (/^--h/) { + print "$usage"; + exit 0; + } elsif (/^--verb/) { + $verbose = 1; + } elsif (/^--vers/) { + &version; + } elsif (/^[^-]/) { + die "$usage" if defined($srcdir); + # Top level directory of the package being autoscanned. + $srcdir = $_; + } else { + die "$usage"; + } + } + + $srcdir="." if !defined($srcdir); + + print "srcdir=$srcdir\n" if $verbose; + chdir $srcdir || die "$0: cannot cd to $srcdir: $!\n"; + + open(CONF, ">configure.scan") || + die "$0: cannot create configure.scan: $!\n"; +} + +# Print the version number and exit. +sub version +{ + open(ACG, "<$datadir/acgeneral.m4") || + die "$0: cannot open $datadir/acgeneral.m4: $!\n"; + while (<ACG>) { + if (/define.AC_ACVERSION.\s*([0-9.]+)/) { + print "Autoconf version $1\n"; + exit 0; + } + } + die "Autoconf version unknown\n"; +} + +# Put values in the tables of what to do with each token. +sub init_tables +{ + local($kind, $word, $macro); + + # Initialize a table of C keywords (to ignore). + # Taken from K&R 1st edition p. 180. + # ANSI C, GNU C, and C++ keywords can introduce portability problems, + # so don't ignore them. + foreach $word ('int', 'char', 'float', 'double', 'struct', 'union', + 'long', 'short', 'unsigned', 'auto', 'extern', 'register', + 'typedef', 'static', 'goto', 'return', 'sizeof', 'break', + 'continue', 'if', 'else', 'for', 'do', 'while', 'switch', + 'case', 'default') { + $c_keywords{$word} = 0; + } + + # The data file format supports only one line of macros per function. + # If more than that is required for a common portability problem, + # a new Autoconf macro should probably be written for that case, + # instead of duplicating the code in lots of configure.in files. + + foreach $kind ('functions', 'headers', 'identifiers', 'programs', + 'makevars') { + open(TABLE, "<$datadir/ac$kind") || + die "$0: cannot open $datadir/ac$kind: $!\n"; + while (<TABLE>) { + next if /^\s*$/ || /^\s*#/; # Ignore blank lines and comments. + ($word, $macro) = split; + eval "\$$kind" . "_macros{\$word} = \$macro"; + } + close(TABLE); + } +} + +# Collect names of various kinds of files in the package. +# Called by &find on each file. +sub wanted +{ + if (/^.*\.[chlymC]$/ || /^.*\.cc$/) { + $name =~ s?^\./??; push(@cfiles, $name); + } + elsif (/^[Mm]akefile$/ || /^[Mm]akefile\.in$/ || /^GNUmakefile$/) { + $name =~ s?^\./??; push(@makefiles, $name); + } + elsif (/^.*\.sh$/) { + $name =~ s?^\./??; push(@shfiles, $name); + } +} + +# Read through the files and collect lists of tokens in them +# that might create nonportabilities. +sub scan_files +{ + $initfile = $cfiles[0]; # Pick one at random. + + if ($verbose) { + print "cfiles:", join(" ", @cfiles), "\n"; + print "makefiles:", join(" ", @makefiles), "\n"; + print "shfiles:", join(" ", @shfiles), "\n"; + } + + foreach $file (@cfiles) { + &scan_c_file($file); + } + + foreach $file (@makefiles) { + &scan_makefile($file); + } + + foreach $file (@shfiles) { + &scan_sh_file($file); + } +} + +sub scan_c_file +{ + local($file) = @_; + local($in_comment) = 0; # Nonzero if in a multiline comment. + + open(CFILE, "<$file") || die "$0: cannot open $file: $!\n"; + while (<CFILE>) { + # Strip out comments, approximately. + # Ending on this line. + if ($in_comment && m,\*/,) { + s,.*\*/,,; + $in_comment = 0; + } + # All on one line. + s,/\*.*\*/,,g; + # Starting on this line. + if (m,/\*,) { + $in_comment = 1; + } + # Continuing on this line. + next if $in_comment; + + # Preprocessor directives. + if (/^\s*#\s*include\s*<([^>]*)>/) { + $headers{$1}++; + } + # Ignore other preprocessor directives. + next if /^\s*#/; + + # Remove string and character constants. + s,\"[^\"]*\",,g; + s,\'[^\']*\',,g; + + # Tokens in the code. + # Maybe we should ignore function definitions (in column 0)? + while (s/\W([a-zA-Z_]\w*)\s*\(/ /) { + $functions{$1}++ if !defined($c_keywords{$1}); + } + while (s/\W([a-zA-Z_]\w*)\W/ /) { + $identifiers{$1}++ if !defined($c_keywords{$1}); + } + } + close(CFILE); + + if ($verbose) { + local($word); + + print "\n$file functions:\n"; + foreach $word (sort keys %functions) { + print "$word $functions{$word}\n"; + } + + print "\n$file identifiers:\n"; + foreach $word (sort keys %identifiers) { + print "$word $identifiers{$word}\n"; + } + + print "\n$file headers:\n"; + foreach $word (sort keys %headers) { + print "$word $headers{$word}\n"; + } + } +} + +sub scan_makefile +{ + local($file) = @_; + + open(MFILE, "<$file") || die "$0: cannot open $file: $!\n"; + while (<MFILE>) { + # Strip out comments and variable references. + s/#.*//; + s/\$\([^\)]*\)//g; + s/\${[^\}]*}//g; + s/@[^@]*@//g; + + # Variable assignments. + while (s/\W([a-zA-Z_]\w*)\s*=/ /) { + $makevars{$1}++; + } + # Libraries. + while (s/\W-l([a-zA-Z_]\w*)\W/ /) { + $libraries{$1}++; + } + # Tokens in the code. + while (s/\W([a-zA-Z_]\w*)\W/ /) { + $programs{$1}++; + } + } + close(MFILE); + + if ($verbose) { + local($word); + + print "\n$file makevars:\n"; + foreach $word (sort keys %makevars) { + print "$word $makevars{$word}\n"; + } + + print "\n$file libraries:\n"; + foreach $word (sort keys %libraries) { + print "$word $libraries{$word}\n"; + } + + print "\n$file programs:\n"; + foreach $word (sort keys %programs) { + print "$word $programs{$word}\n"; + } + } +} + +sub scan_sh_file +{ + local($file) = @_; + + open(MFILE, "<$file") || die "$0: cannot open $file: $!\n"; + while (<MFILE>) { + # Strip out comments and variable references. + s/#.*//; + s/\${[^\}]*}//g; + s/@[^@]*@//g; + + # Tokens in the code. + while (s/\W([a-zA-Z_]\w*)\W/ /) { + $programs{$1}++; + } + } + close(MFILE); + + if ($verbose) { + local($word); + + print "\n$file programs:\n"; + foreach $word (sort keys %programs) { + print "$word $programs{$word}\n"; + } + } +} + +# Print a configure.in. +sub output +{ + local (%unique_makefiles); + + print CONF "dnl Process this file with autoconf to produce a configure script.\n"; + print CONF "AC_INIT($initfile)\n"; + + &output_programs; + &output_headers; + &output_identifiers; + &output_functions; + + # Change DIR/Makefile.in to DIR/Makefile. + foreach $_ (@makefiles) { + s/\.in$//; + $unique_makefiles{$_}++; + } + print CONF "\nAC_OUTPUT(", join(" ", keys(%unique_makefiles)), ")\n"; + + close CONF; +} + +# Print Autoconf macro $1 if it's not undef and hasn't been printed already. +sub print_unique +{ + local($macro) = @_; + + if (defined($macro) && !defined($printed{$macro})) { + print CONF "$macro\n"; + $printed{$macro} = 1; + } +} + +sub output_programs +{ + local ($word); + + print CONF "\ndnl Checks for programs.\n"; + foreach $word (sort keys %programs) { + &print_unique($programs_macros{$word}); + } + foreach $word (sort keys %makevars) { + &print_unique($makevars_macros{$word}); + } + print CONF "\ndnl Checks for libraries.\n"; + foreach $word (sort keys %libraries) { + print CONF "dnl Replace `\main\' with a function in -l$word:\n"; + print CONF "AC_CHECK_LIB($word, main)\n"; + } +} + +sub output_headers +{ + local ($word); + + print CONF "\ndnl Checks for header files.\n"; + foreach $word (sort keys %headers) { + if (defined($headers_macros{$word}) && + $headers_macros{$word} eq 'AC_CHECK_HEADERS') { + push(@have_headers, $word); + } else { + &print_unique($headers_macros{$word}); + } + } + print CONF "AC_CHECK_HEADERS(" . join(' ', sort(@have_headers)) . ")\n" + if defined(@have_headers); +} + +sub output_identifiers +{ + local ($word); + + print CONF "\ndnl Checks for typedefs, structures, and compiler characteristics.\n"; + foreach $word (sort keys %identifiers) { + &print_unique($identifiers_macros{$word}); + } +} + +sub output_functions +{ + local ($word); + + print CONF "\ndnl Checks for library functions.\n"; + foreach $word (sort keys %functions) { + if (defined($functions_macros{$word}) && + $functions_macros{$word} eq 'AC_CHECK_FUNCS') { + push(@have_funcs, $word); + } else { + &print_unique($functions_macros{$word}); + } + } + print CONF "AC_CHECK_FUNCS(" . join(' ', sort(@have_funcs)) . ")\n" + if defined(@have_funcs); +} diff --git a/util/autoconf/config.guess b/util/autoconf/config.guess new file mode 100755 index 0000000..bc2cbcb --- /dev/null +++ b/util/autoconf/config.guess @@ -0,0 +1,470 @@ +#!/bin/sh +# Attempt to guess a canonical system name. +# Copyright (C) 1992, 1993, 1994 Free Software Foundation, Inc. +# +# This file is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License as published by +# the Free Software Foundation; either version 2 of the License, or +# (at your option) any later version. +# +# This program is distributed in the hope that it will be useful, but +# WITHOUT ANY WARRANTY; without even the implied warranty of +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +# General Public License for more details. +# +# You should have received a copy of the GNU General Public License +# along with this program; if not, write to the Free Software +# Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. +# +# As a special exception to the GNU General Public License, if you +# distribute this file as part of a program that contains a +# configuration script generated by Autoconf, you may include it under +# the same distribution terms that you use for the rest of that program. + +# Written by Per Bothner <bothner@cygnus.com>. +# The master version of this file is at the FSF in /home/gd/gnu/lib. +# +# This script attempts to guess a canonical system name similar to +# config.sub. If it succeeds, it prints the system name on stdout, and +# exits with 0. Otherwise, it exits with 1. +# +# The plan is that this can be called by configure scripts if you +# don't specify an explicit system type (host/target name). +# +# Only a few systems have been added to this list; please add others +# (but try to keep the structure clean). +# + +# This is needed to find uname on a Pyramid OSx when run in the BSD universe. +# (ghazi@noc.rutgers.edu 8/24/94.) +if (test -f /.attbin/uname) >/dev/null 2>&1 ; then + PATH=$PATH:/.attbin ; export PATH +fi + +UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown +UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown +UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown +UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown + +trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15 + +# Note: order is significant - the case branches are not exclusive. + +case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in + alpha:OSF1:V*:*) + # After 1.2, OSF1 uses "V1.3" for uname -r. + echo alpha-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^V//'` + exit 0 ;; + alpha:OSF1:*:*) + # 1.2 uses "1.2" for uname -r. + echo alpha-dec-osf${UNAME_RELEASE} + exit 0 ;; + arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) + echo arm-acorn-riscix${UNAME_RELEASE} + exit 0;; + Pyramid*:OSx*:*:*) + if test "`(/bin/universe) 2>/dev/null`" = att ; then + echo pyramid-pyramid-sysv3 + else + echo pyramid-pyramid-bsd + fi + exit 0 ;; + sun4*:SunOS:5.*:*) + echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:6*:*) + # According to config.sub, this is the proper way to canonicalize + # SunOS6. Hard to guess exactly what SunOS6 will be like, but + # it's likely to be more like Solaris than SunOS4. + echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` + exit 0 ;; + sun4*:SunOS:*:*) + # Japanese Language versions have a version number like `4.1.3-JL'. + echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` + exit 0 ;; + sun3*:SunOS:*:*) + echo m68k-sun-sunos${UNAME_RELEASE} + exit 0 ;; + RISC*:ULTRIX:*:*) + echo mips-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + VAX*:ULTRIX*:*:*) + echo vax-dec-ultrix${UNAME_RELEASE} + exit 0 ;; + mips:*:5*:RISCos) + echo mips-mips-riscos${UNAME_RELEASE} + exit 0 ;; + m88k:CX/UX:7*:*) + echo m88k-harris-cxux7 + exit 0 ;; + m88k:*:4*:R4*) + echo m88k-motorola-sysv4 + exit 0 ;; + m88k:*:3*:R3*) + echo m88k-motorola-sysv3 + exit 0 ;; + AViiON:dgux:*:*) + if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \ + -o ${TARGET_BINARY_INTERFACE}x = x ] ; then + echo m88k-dg-dgux${UNAME_RELEASE} + else + echo m88k-dg-dguxbcs${UNAME_RELEASE} + fi + exit 0 ;; + M88*:DolphinOS:*:*) # DolphinOS (SVR3) + echo m88k-dolphin-sysv3 + exit 0 ;; + M88*:*:R3*:*) + # Delta 88k system running SVR3 + echo m88k-motorola-sysv3 + exit 0 ;; + XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) + echo m88k-tektronix-sysv3 + exit 0 ;; + Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) + echo m68k-tektronix-bsd + exit 0 ;; + *:IRIX:*:*) + echo mips-sgi-irix${UNAME_RELEASE} + exit 0 ;; + i[34]86:AIX:*:*) + echo i386-ibm-aix + exit 0 ;; + *:AIX:2:3) + if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then + sed 's/^ //' << EOF >dummy.c + #include <sys/systemcfg.h> + + main() + { + if (!__power_pc()) + exit(1); + puts("powerpc-ibm-aix3.2.5"); + exit(0); + } +EOF + ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + echo rs6000-ibm-aix3.2.5 + elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then + echo rs6000-ibm-aix3.2.4 + else + echo rs6000-ibm-aix3.2 + fi + exit 0 ;; + *:AIX:*:4) + if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then + IBM_ARCH=rs6000 + else + IBM_ARCH=powerpc + fi + if grep bos410 /usr/include/stdio.h >/dev/null 2>&1; then + IBM_REV=4.1 + elif grep bos411 /usr/include/stdio.h >/dev/null 2>&1; then + IBM_REV=4.1.1 + else + IBM_REV=4.${UNAME_RELEASE} + fi + echo ${IBM_ARCH}-ibm-aix${IBM_REV} + exit 0 ;; + *:AIX:*:*) + echo rs6000-ibm-aix + exit 0 ;; + *:BOSX:*:*) + echo rs6000-bull-bosx + exit 0 ;; + DPX/2?00:B.O.S.:*:*) + echo m68k-bull-sysv3 + exit 0 ;; + 9000/[34]??:4.3bsd:1.*:*) + echo m68k-hp-bsd + exit 0 ;; + hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) + echo m68k-hp-bsd4.4 + exit 0 ;; + 9000/[3478]??:HP-UX:*:*) + case "${UNAME_MACHINE}" in + 9000/31? ) HP_ARCH=m68000 ;; + 9000/[34]?? ) HP_ARCH=m68k ;; + 9000/7?? | 9000/8?7 ) HP_ARCH=hppa1.1 ;; + 9000/8?? ) HP_ARCH=hppa1.0 ;; + esac + HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` + echo ${HP_ARCH}-hp-hpux${HPUX_REV} + exit 0 ;; + 3050*:HI-UX:*:*) + sed 's/^ //' << EOF >dummy.c + #include <unistd.h> + int + main () + { + long cpu = sysconf (_SC_CPU_VERSION); + /* The order matters, because CPU_IS_HP_MC68K erroneously returns + true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct + results, however. */ + if (CPU_IS_PA_RISC (cpu)) + { + switch (cpu) + { + case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; + case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; + case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; + default: puts ("hppa-hitachi-hiuxwe2"); break; + } + } + else if (CPU_IS_HP_MC68K (cpu)) + puts ("m68k-hitachi-hiuxwe2"); + else puts ("unknown-hitachi-hiuxwe2"); + exit (0); + } +EOF + ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 + rm -f dummy.c dummy + echo unknown-hitachi-hiuxwe2 + exit 0 ;; + 9000/7??:4.3bsd:*:* | 9000/8?7:4.3bsd:*:* ) + echo hppa1.1-hp-bsd + exit 0 ;; + 9000/8??:4.3bsd:*:*) + echo hppa1.0-hp-bsd + exit 0 ;; + hp7??:OSF1:*:* | hp8?7:OSF1:*:* ) + echo hppa1.1-hp-osf + exit 0 ;; + hp8??:OSF1:*:*) + echo hppa1.0-hp-osf + exit 0 ;; + C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) + echo c1-convex-bsd + exit 0 ;; + C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) + echo c34-convex-bsd + exit 0 ;; + C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) + echo c38-convex-bsd + exit 0 ;; + C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) + echo c4-convex-bsd + exit 0 ;; + CRAY*X-MP:UNICOS:*:*) + echo xmp-cray-unicos + exit 0 ;; + CRAY*Y-MP:UNICOS:*:*) + echo ymp-cray-unicos + exit 0 ;; + CRAY-2:UNICOS:*:*) + echo cray2-cray-unicos + exit 0 ;; + hp3[0-9][05]:NetBSD:*:*) + echo m68k-hp-netbsd${UNAME_RELEASE} + exit 0 ;; + i[34]86:BSD/386:*:*) + echo ${UNAME_MACHINE}-unknown-bsdi${UNAME_RELEASE} + exit 0 ;; + *:FreeBSD:*:*) + echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` + exit 0 ;; + *:NetBSD:*:*) + echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` + exit 0 ;; + *:GNU:*:*) + echo `echo ${UNAME_MACHINE}|sed -e 's,/.*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` + exit 0 ;; + *:Linux:*:*) + echo ${UNAME_MACHINE}-unknown-linux + exit 0 ;; +# ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions +# are messed up and put the nodename in both sysname and nodename. + i[34]86:DYNIX/ptx:4*:*) + echo i386-sequent-sysv4 + exit 0 ;; + i[34]86:*:4.*:* | i[34]86:SYSTEM_V:4.*:*) + if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then + echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE} + else + echo ${UNAME_MACHINE}-unknown-sysv${UNAME_RELEASE} + fi + exit 0 ;; + i[34]86:*:3.2:*) + if /bin/uname -X 2>/dev/null >/dev/null ; then + UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` + (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 + echo ${UNAME_MACHINE}-unknown-sco$UNAME_REL + elif test -f /usr/options/cb.name; then + UNAME_REL=`sed -n 's/.*Version //p' </usr/options/cb.name` + echo ${UNAME_MACHINE}-unknown-isc$UNAME_REL + else + echo ${UNAME_MACHINE}-unknown-sysv32 + fi + exit 0 ;; + Intel:Mach:3*:*) + echo i386-unknown-mach3 + exit 0 ;; + i860:*:4.*:*) # i860-SVR4 + if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then + echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 + else # Add other i860-SVR4 vendors below as they are discovered. + echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 + fi + exit 0 ;; + mini*:CTIX:SYS*5:*) + # "miniframe" + echo m68010-convergent-sysv + exit 0 ;; + M680[234]0:*:R3V[567]*:*) + test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; + 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0) + uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4.3 && exit 0 ;; + 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) + uname -p 2>/dev/null | grep 86 >/dev/null \ + && echo i486-ncr-sysv4 && exit 0 ;; + m680[234]0:LynxOS:2.2*:*) + echo m68k-lynx-lynxos${UNAME_RELEASE} + exit 0 ;; + mc68030:UNIX_System_V:4.*:*) + echo m68k-atari-sysv4 + exit 0 ;; + i[34]86:LynxOS:2.2*:*) + echo i386-lynx-lynxos${UNAME_RELEASE} + exit 0 ;; + TSUNAMI:LynxOS:2.2*:*) + echo sparc-lynx-lynxos${UNAME_RELEASE} + exit 0 ;; + rs6000:LynxOS:2.2*:*) + echo rs6000-lynx-lynxos${UNAME_RELEASE} + exit 0 ;; + RM*:SINIX-*:*:*) + echo mips-sni-sysv4 + exit 0 ;; + *:SINIX-*:*:*) + if uname -p 2>/dev/null >/dev/null ; then + UNAME_MACHINE=`(uname -p) 2>/dev/null` + echo ${UNAME_MACHINE}-sni-sysv4 + else + echo ns32k-sni-sysv + fi + exit 0 ;; +esac + +#echo '(No uname command or uname output not recognized.)' 1>&2 +#echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 + +cat >dummy.c <<EOF +main () +{ +#if defined (sony) +#if defined (MIPSEB) + /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, + I don't know.... */ + printf ("mips-sony-bsd\n"); exit (0); +#else + printf ("m68k-sony-newsos\n"); exit (0); +#endif +#endif + +#if defined (__arm) && defined (__acorn) && defined (__unix) + printf ("arm-acorn-riscix"); exit (0); +#endif + +#if defined (hp300) && !defined (hpux) + printf ("m68k-hp-bsd\n"); exit (0); +#endif + +#if defined (NeXT) +#if !defined (__ARCHITECTURE__) +#define __ARCHITECTURE__ "m68k" +#endif + int version; + version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; + printf ("%s-next-nextstep%s\n", __ARCHITECTURE__, version==2 ? "2" : "3"); + exit (0); +#endif + +#if defined (MULTIMAX) || defined (n16) +#if defined (UMAXV) + printf ("ns32k-encore-sysv\n"); exit (0); +#else +#if defined (CMU) + printf ("ns32k-encore-mach\n"); exit (0); +#else + printf ("ns32k-encore-bsd\n"); exit (0); +#endif +#endif +#endif + +#if defined (__386BSD__) + printf ("i386-unknown-bsd\n"); exit (0); +#endif + +#if defined (sequent) +#if defined (i386) + printf ("i386-sequent-dynix\n"); exit (0); +#endif +#if defined (ns32000) + printf ("ns32k-sequent-dynix\n"); exit (0); +#endif +#endif + +#if defined (_SEQUENT_) + printf ("i386-sequent-ptx\n"); exit (0); +#endif + +#if defined (vax) +#if !defined (ultrix) + printf ("vax-dec-bsd\n"); exit (0); +#else + printf ("vax-dec-ultrix\n"); exit (0); +#endif +#endif + +#if defined (alliant) && defined (i860) + printf ("i860-alliant-bsd\n"); exit (0); +#endif + + exit (1); +} +EOF + +${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0 +rm -f dummy.c dummy + +# Apollos put the system type in the environment. + +test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } + +# Convex versions that predate uname can use getsysinfo(1) + +if [ -x /usr/convex/getsysinfo ] +then + case `getsysinfo -f cpu_type` in + c1*) + echo c1-convex-bsd + exit 0 ;; + c2*) + if getsysinfo -f scalar_acc + then echo c32-convex-bsd + else echo c2-convex-bsd + fi + exit 0 ;; + c34*) + echo c34-convex-bsd + exit 0 ;; + c38*) + echo c38-convex-bsd + exit 0 ;; + c4*) + echo c4-convex-bsd + exit 0 ;; + esac +fi + +#echo '(Unable to guess system type)' 1>&2 + +exit 1 diff --git a/util/autoconf/texinfo.tex b/util/autoconf/texinfo.tex new file mode 100644 index 0000000..e544dc6 --- /dev/null +++ b/util/autoconf/texinfo.tex @@ -0,0 +1,4355 @@ +%% TeX macros to handle texinfo files + +% Copyright (C) 1985, 86, 88, 90, 91, 92, 93, 1994 Free Software Foundation, Inc. + +%This texinfo.tex file is free software; you can redistribute it and/or +%modify it under the terms of the GNU General Public License as +%published by the Free Software Foundation; either version 2, or (at +%your option) any later version. + +%This texinfo.tex file is distributed in the hope that it will be +%useful, but WITHOUT ANY WARRANTY; without even the implied warranty +%of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU +%General Public License for more details. + +%You should have received a copy of the GNU General Public License +%along with this texinfo.tex file; see the file COPYING. If not, write +%to the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, +%USA. + + +%In other words, you are welcome to use, share and improve this program. +%You are forbidden to forbid anyone else to use, share and improve +%what you give them. Help stamp out software-hoarding! + +% This automatically updates the version number based on RCS. +\def\deftexinfoversion$#1: #2 ${\def\texinfoversion{#2}} +\deftexinfoversion$Revision$ +\message{Loading texinfo package [Version \texinfoversion]:} + +% Print the version number if in a .fmt file. +\everyjob{\message{[Texinfo version \texinfoversion]}\message{}} + +% Save some parts of plain tex whose names we will redefine. + +\let\ptextilde=\~ +\let\ptexlbrace=\{ +\let\ptexrbrace=\} +\let\ptexdots=\dots +\let\ptexdot=\. +\let\ptexstar=\* +\let\ptexend=\end +\let\ptexbullet=\bullet +\let\ptexb=\b +\let\ptexc=\c +\let\ptexi=\i +\let\ptext=\t +\let\ptexl=\l +\let\ptexL=\L + +% Be sure we're in horizontal mode when doing a tie, since we make space +% equivalent to this in @example-like environments. Otherwise, a space +% at the beginning of a line will start with \penalty -- and +% since \penalty is valid in vertical mode, we'd end up putting the +% penalty on the vertical list instead of in the new paragraph. +{\catcode`@ = 11 + \gdef\tie{\leavevmode\penalty\@M\ } +} +\let\~ = \tie % And make it available as @~. + +\message{Basics,} +\chardef\other=12 + +% If this character appears in an error message or help string, it +% starts a new line in the output. +\newlinechar = `^^J + +% Set up fixed words for English. +\ifx\putwordChapter\undefined{\gdef\putwordChapter{Chapter}}\fi% +\def\putwordInfo{Info}% +\ifx\putwordSee\undefined{\gdef\putwordSee{See}}\fi% +\ifx\putwordsee\undefined{\gdef\putwordsee{see}}\fi% +\ifx\putwordfile\undefined{\gdef\putwordfile{file}}\fi% +\ifx\putwordpage\undefined{\gdef\putwordpage{page}}\fi% +\ifx\putwordsection\undefined{\gdef\putwordsection{section}}\fi% +\ifx\putwordSection\undefined{\gdef\putwordSection{Section}}\fi% +\ifx\putwordTableofContents\undefined{\gdef\putwordTableofContents{Table of Contents}}\fi% +\ifx\putwordShortContents\undefined{\gdef\putwordShortContents{Short Contents}}\fi% +\ifx\putwordAppendix\undefined{\gdef\putwordAppendix{Appendix}}\fi% + +% Ignore a token. +% +\def\gobble#1{} + +\hyphenation{ap-pen-dix} +\hyphenation{mini-buf-fer mini-buf-fers} +\hyphenation{eshell} + +% Margin to add to right of even pages, to left of odd pages. +\newdimen \bindingoffset \bindingoffset=0pt +\newdimen \normaloffset \normaloffset=\hoffset +\newdimen\pagewidth \newdimen\pageheight +\pagewidth=\hsize \pageheight=\vsize + +% Sometimes it is convenient to have everything in the transcript file +% and nothing on the terminal. We don't just call \tracingall here, +% since that produces some useless output on the terminal. +% +\def\gloggingall{\begingroup \globaldefs = 1 \loggingall \endgroup}% +\def\loggingall{\tracingcommands2 \tracingstats2 + \tracingpages1 \tracingoutput1 \tracinglostchars1 + \tracingmacros2 \tracingparagraphs1 \tracingrestores1 + \showboxbreadth\maxdimen\showboxdepth\maxdimen +}% + +%---------------------Begin change----------------------- +% +%%%% For @cropmarks command. +% Dimensions to add cropmarks at corners Added by P. A. MacKay, 12 Nov. 1986 +% +\newdimen\cornerlong \newdimen\cornerthick +\newdimen \topandbottommargin +\newdimen \outerhsize \newdimen \outervsize +\cornerlong=1pc\cornerthick=.3pt % These set size of cropmarks +\outerhsize=7in +%\outervsize=9.5in +% Alternative @smallbook page size is 9.25in +\outervsize=9.25in +\topandbottommargin=.75in +% +%---------------------End change----------------------- + +% \onepageout takes a vbox as an argument. Note that \pagecontents +% does insertions itself, but you have to call it yourself. +\chardef\PAGE=255 \output={\onepageout{\pagecontents\PAGE}} +\def\onepageout#1{\hoffset=\normaloffset +\ifodd\pageno \advance\hoffset by \bindingoffset +\else \advance\hoffset by -\bindingoffset\fi +{\escapechar=`\\\relax % makes sure backslash is used in output files. +\shipout\vbox{{\let\hsize=\pagewidth \makeheadline} \pagebody{#1}% +{\let\hsize=\pagewidth \makefootline}}}% +\advancepageno \ifnum\outputpenalty>-20000 \else\dosupereject\fi} + +%%%% For @cropmarks command %%%% + +% Here is a modification of the main output routine for Near East Publications +% This provides right-angle cropmarks at all four corners. +% The contents of the page are centerlined into the cropmarks, +% and any desired binding offset is added as an \hskip on either +% site of the centerlined box. (P. A. MacKay, 12 November, 1986) +% +\def\croppageout#1{\hoffset=0pt % make sure this doesn't mess things up +{\escapechar=`\\\relax % makes sure backslash is used in output files. + \shipout + \vbox to \outervsize{\hsize=\outerhsize + \vbox{\line{\ewtop\hfill\ewtop}} + \nointerlineskip + \line{\vbox{\moveleft\cornerthick\nstop} + \hfill + \vbox{\moveright\cornerthick\nstop}} + \vskip \topandbottommargin + \centerline{\ifodd\pageno\hskip\bindingoffset\fi + \vbox{ + {\let\hsize=\pagewidth \makeheadline} + \pagebody{#1} + {\let\hsize=\pagewidth \makefootline}} + \ifodd\pageno\else\hskip\bindingoffset\fi} + \vskip \topandbottommargin plus1fill minus1fill + \boxmaxdepth\cornerthick + \line{\vbox{\moveleft\cornerthick\nsbot} + \hfill + \vbox{\moveright\cornerthick\nsbot}} + \nointerlineskip + \vbox{\line{\ewbot\hfill\ewbot}} + }} + \advancepageno + \ifnum\outputpenalty>-20000 \else\dosupereject\fi} +% +% Do @cropmarks to get crop marks +\def\cropmarks{\let\onepageout=\croppageout } + +\def\pagebody#1{\vbox to\pageheight{\boxmaxdepth=\maxdepth #1}} +{\catcode`\@ =11 +\gdef\pagecontents#1{\ifvoid\topins\else\unvbox\topins\fi +\dimen@=\dp#1 \unvbox#1 +\ifvoid\footins\else\vskip\skip\footins\footnoterule \unvbox\footins\fi +\ifr@ggedbottom \kern-\dimen@ \vfil \fi} +} + +% +% Here are the rules for the cropmarks. Note that they are +% offset so that the space between them is truly \outerhsize or \outervsize +% (P. A. MacKay, 12 November, 1986) +% +\def\ewtop{\vrule height\cornerthick depth0pt width\cornerlong} +\def\nstop{\vbox + {\hrule height\cornerthick depth\cornerlong width\cornerthick}} +\def\ewbot{\vrule height0pt depth\cornerthick width\cornerlong} +\def\nsbot{\vbox + {\hrule height\cornerlong depth\cornerthick width\cornerthick}} + +% Parse an argument, then pass it to #1. The argument is the rest of +% the input line (except we remove a trailing comment). #1 should be a +% macro which expects an ordinary undelimited TeX argument. +% +\def\parsearg#1{% + \let\next = #1% + \begingroup + \obeylines + \futurelet\temp\parseargx +} + +% If the next token is an obeyed space (from an @example environment or +% the like), remove it and recurse. Otherwise, we're done. +\def\parseargx{% + % \obeyedspace is defined far below, after the definition of \sepspaces. + \ifx\obeyedspace\temp + \expandafter\parseargdiscardspace + \else + \expandafter\parseargline + \fi +} + +% Remove a single space (as the delimiter token to the macro call). +{\obeyspaces % + \gdef\parseargdiscardspace {\futurelet\temp\parseargx}} + +{\obeylines % + \gdef\parseargline#1^^M{% + \endgroup % End of the group started in \parsearg. + % + % First remove any @c comment, then any @comment. + % Result of each macro is put in \toks0. + \argremovec #1\c\relax % + \expandafter\argremovecomment \the\toks0 \comment\relax % + % + % Call the caller's macro, saved as \next in \parsearg. + \expandafter\next\expandafter{\the\toks0}% + }% +} + +% Since all \c{,omment} does is throw away the argument, we can let TeX +% do that for us. The \relax here is matched by the \relax in the call +% in \parseargline; it could be more or less anything, its purpose is +% just to delimit the argument to the \c. +\def\argremovec#1\c#2\relax{\toks0 = {#1}} +\def\argremovecomment#1\comment#2\relax{\toks0 = {#1}} + +% \argremovec{,omment} might leave us with trailing spaces, though; e.g., +% @end itemize @c foo +% will have two active spaces as part of the argument with the +% `itemize'. Here we remove all active spaces from #1, and assign the +% result to \toks0. +% +% This loses if there are any *other* active characters besides spaces +% in the argument -- _ ^ +, for example -- since they get expanded. +% Fortunately, Texinfo does not define any such commands. (If it ever +% does, the catcode of the characters in questionwill have to be changed +% here.) But this means we cannot call \removeactivespaces as part of +% \argremovec{,omment}, since @c uses \parsearg, and thus the argument +% that \parsearg gets might well have any character at all in it. +% +\def\removeactivespaces#1{% + \begingroup + \ignoreactivespaces + \edef\temp{#1}% + \global\toks0 = \expandafter{\temp}% + \endgroup +} + +% Change the active space to expand to nothing. +% +\begingroup + \obeyspaces + \gdef\ignoreactivespaces{\obeyspaces\let =\empty} +\endgroup + + +\def\flushcr{\ifx\par\lisppar \def\next##1{}\else \let\next=\relax \fi \next} + +%% These are used to keep @begin/@end levels from running away +%% Call \inENV within environments (after a \begingroup) +\newif\ifENV \ENVfalse \def\inENV{\ifENV\relax\else\ENVtrue\fi} +\def\ENVcheck{% +\ifENV\errmessage{Still within an environment. Type Return to continue.} +\endgroup\fi} % This is not perfect, but it should reduce lossage + +% @begin foo is the same as @foo, for now. +\newhelp\EMsimple{Type <Return> to continue.} + +\outer\def\begin{\parsearg\beginxxx} + +\def\beginxxx #1{% +\expandafter\ifx\csname #1\endcsname\relax +{\errhelp=\EMsimple \errmessage{Undefined command @begin #1}}\else +\csname #1\endcsname\fi} + +% @end foo executes the definition of \Efoo. +% +\def\end{\parsearg\endxxx} +\def\endxxx #1{% + \removeactivespaces{#1}% + \edef\endthing{\the\toks0}% + % + \expandafter\ifx\csname E\endthing\endcsname\relax + \expandafter\ifx\csname \endthing\endcsname\relax + % There's no \foo, i.e., no ``environment'' foo. + \errhelp = \EMsimple + \errmessage{Undefined command `@end \endthing'}% + \else + \unmatchedenderror\endthing + \fi + \else + % Everything's ok; the right environment has been started. + \csname E\endthing\endcsname + \fi +} + +% There is an environment #1, but it hasn't been started. Give an error. +% +\def\unmatchedenderror#1{% + \errhelp = \EMsimple + \errmessage{This `@end #1' doesn't have a matching `@#1'}% +} + +% Define the control sequence \E#1 to give an unmatched @end error. +% +\def\defineunmatchedend#1{% + \expandafter\def\csname E#1\endcsname{\unmatchedenderror{#1}}% +} + + +% Single-spacing is done by various environments (specifically, in +% \nonfillstart and \quotations). +\newskip\singlespaceskip \singlespaceskip = 12.5pt +\def\singlespace{% + % Why was this kern here? It messes up equalizing space above and below + % environments. --karl, 6may93 + %{\advance \baselineskip by -\singlespaceskip + %\kern \baselineskip}% + \setleading \singlespaceskip +} + +%% Simple single-character @ commands + +% @@ prints an @ +% Kludge this until the fonts are right (grr). +\def\@{{\tt \char '100}} + +% This is turned off because it was never documented +% and you can use @w{...} around a quote to suppress ligatures. +%% Define @` and @' to be the same as ` and ' +%% but suppressing ligatures. +%\def\`{{`}} +%\def\'{{'}} + +% Used to generate quoted braces. + +\def\mylbrace {{\tt \char '173}} +\def\myrbrace {{\tt \char '175}} +\let\{=\mylbrace +\let\}=\myrbrace + +% @: forces normal size whitespace following. +\def\:{\spacefactor=1000 } + +% @* forces a line break. +\def\*{\hfil\break\hbox{}\ignorespaces} + +% @. is an end-of-sentence period. +\def\.{.\spacefactor=3000 } + +% @enddots{} is an end-of-sentence ellipsis. +\gdef\enddots{$\mathinner{\ldotp\ldotp\ldotp\ldotp}$\spacefactor=3000} + +% @! is an end-of-sentence bang. +\gdef\!{!\spacefactor=3000 } + +% @? is an end-of-sentence query. +\gdef\?{?\spacefactor=3000 } + +% @w prevents a word break. Without the \leavevmode, @w at the +% beginning of a paragraph, when TeX is still in vertical mode, would +% produce a whole line of output instead of starting the paragraph. +\def\w#1{\leavevmode\hbox{#1}} + +% @group ... @end group forces ... to be all on one page, by enclosing +% it in a TeX vbox. We use \vtop instead of \vbox to construct the box +% to keep its height that of a normal line. According to the rules for +% \topskip (p.114 of the TeXbook), the glue inserted is +% max (\topskip - \ht (first item), 0). If that height is large, +% therefore, no glue is inserted, and the space between the headline and +% the text is small, which looks bad. +% +\def\group{\begingroup + \ifnum\catcode13=\active \else + \errhelp = \groupinvalidhelp + \errmessage{@group invalid in context where filling is enabled}% + \fi + % + % The \vtop we start below produces a box with normal height and large + % depth; thus, TeX puts \baselineskip glue before it, and (when the + % next line of text is done) \lineskip glue after it. (See p.82 of + % the TeXbook.) Thus, space below is not quite equal to space + % above. But it's pretty close. + \def\Egroup{% + \egroup % End the \vtop. + \endgroup % End the \group. + }% + % + \vtop\bgroup + % We have to put a strut on the last line in case the @group is in + % the midst of an example, rather than completely enclosing it. + % Otherwise, the interline space between the last line of the group + % and the first line afterwards is too small. But we can't put the + % strut in \Egroup, since there it would be on a line by itself. + % Hence this just inserts a strut at the beginning of each line. + \everypar = {\strut}% + % + % Since we have a strut on every line, we don't need any of TeX's + % normal interline spacing. + \offinterlineskip + % + % OK, but now we have to do something about blank + % lines in the input in @example-like environments, which normally + % just turn into \lisppar, which will insert no space now that we've + % turned off the interline space. Simplest is to make them be an + % empty paragraph. + \ifx\par\lisppar + \edef\par{\leavevmode \par}% + % + % Reset ^^M's definition to new definition of \par. + \obeylines + \fi + % + % Do @comment since we are called inside an environment such as + % @example, where each end-of-line in the input causes an + % end-of-line in the output. We don't want the end-of-line after + % the `@group' to put extra space in the output. Since @group + % should appear on a line by itself (according to the Texinfo + % manual), we don't worry about eating any user text. + \comment +} +% +% TeX puts in an \escapechar (i.e., `@') at the beginning of the help +% message, so this ends up printing `@group can only ...'. +% +\newhelp\groupinvalidhelp{% +group can only be used in environments such as @example,^^J% +where each line of input produces a line of output.} + +% @need space-in-mils +% forces a page break if there is not space-in-mils remaining. + +\newdimen\mil \mil=0.001in + +\def\need{\parsearg\needx} + +% Old definition--didn't work. +%\def\needx #1{\par % +%% This method tries to make TeX break the page naturally +%% if the depth of the box does not fit. +%{\baselineskip=0pt% +%\vtop to #1\mil{\vfil}\kern -#1\mil\penalty 10000 +%\prevdepth=-1000pt +%}} + +\def\needx#1{% + % Go into vertical mode, so we don't make a big box in the middle of a + % paragraph. + \par + % + % Don't add any leading before our big empty box, but allow a page + % break, since the best break might be right here. + \allowbreak + \nointerlineskip + \vtop to #1\mil{\vfil}% + % + % TeX does not even consider page breaks if a penalty added to the + % main vertical list is 10000 or more. But in order to see if the + % empty box we just added fits on the page, we must make it consider + % page breaks. On the other hand, we don't want to actually break the + % page after the empty box. So we use a penalty of 9999. + % + % There is an extremely small chance that TeX will actually break the + % page at this \penalty, if there are no other feasible breakpoints in + % sight. (If the user is using lots of big @group commands, which + % almost-but-not-quite fill up a page, TeX will have a hard time doing + % good page breaking, for example.) However, I could not construct an + % example where a page broke at this \penalty; if it happens in a real + % document, then we can reconsider our strategy. + \penalty9999 + % + % Back up by the size of the box, whether we did a page break or not. + \kern -#1\mil + % + % Do not allow a page break right after this kern. + \nobreak +} + +% @br forces paragraph break + +\let\br = \par + +% @dots{} output some dots + +\def\dots{$\ldots$} + +% @page forces the start of a new page + +\def\page{\par\vfill\supereject} + +% @exdent text.... +% outputs text on separate line in roman font, starting at standard page margin + +% This records the amount of indent in the innermost environment. +% That's how much \exdent should take out. +\newskip\exdentamount + +% This defn is used inside fill environments such as @defun. +\def\exdent{\parsearg\exdentyyy} +\def\exdentyyy #1{{\hfil\break\hbox{\kern -\exdentamount{\rm#1}}\hfil\break}} + +% This defn is used inside nofill environments such as @example. +\def\nofillexdent{\parsearg\nofillexdentyyy} +\def\nofillexdentyyy #1{{\advance \leftskip by -\exdentamount +\leftline{\hskip\leftskip{\rm#1}}}} + +%\hbox{{\rm#1}}\hfil\break}} + +% @include file insert text of that file as input. + +\def\include{\parsearg\includezzz} +%Use \input\thisfile to avoid blank after \input, which may be an active +%char (in which case the blank would become the \input argument). +%The grouping keeps the value of \thisfile correct even when @include +%is nested. +\def\includezzz #1{\begingroup +\def\thisfile{#1}\input\thisfile +\endgroup} + +\def\thisfile{} + +% @center line outputs that line, centered + +\def\center{\parsearg\centerzzz} +\def\centerzzz #1{{\advance\hsize by -\leftskip +\advance\hsize by -\rightskip +\centerline{#1}}} + +% @sp n outputs n lines of vertical space + +\def\sp{\parsearg\spxxx} +\def\spxxx #1{\par \vskip #1\baselineskip} + +% @comment ...line which is ignored... +% @c is the same as @comment +% @ignore ... @end ignore is another way to write a comment + +\def\comment{\catcode 64=\other \catcode 123=\other \catcode 125=\other% +\parsearg \commentxxx} + +\def\commentxxx #1{\catcode 64=0 \catcode 123=1 \catcode 125=2 } + +\let\c=\comment + +% Prevent errors for section commands. +% Used in @ignore and in failing conditionals. +\def\ignoresections{% +\let\chapter=\relax +\let\unnumbered=\relax +\let\top=\relax +\let\unnumberedsec=\relax +\let\unnumberedsection=\relax +\let\unnumberedsubsec=\relax +\let\unnumberedsubsection=\relax +\let\unnumberedsubsubsec=\relax +\let\unnumberedsubsubsection=\relax +\let\section=\relax +\let\subsec=\relax +\let\subsubsec=\relax +\let\subsection=\relax +\let\subsubsection=\relax +\let\appendix=\relax +\let\appendixsec=\relax +\let\appendixsection=\relax +\let\appendixsubsec=\relax +\let\appendixsubsection=\relax +\let\appendixsubsubsec=\relax +\let\appendixsubsubsection=\relax +\let\contents=\relax +\let\smallbook=\relax +\let\titlepage=\relax +} + +% Used in nested conditionals, where we have to parse the Texinfo source +% and so want to turn off most commands, in case they are used +% incorrectly. +% +\def\ignoremorecommands{% + \let\defcv = \relax + \let\deffn = \relax + \let\deffnx = \relax + \let\defindex = \relax + \let\defivar = \relax + \let\defmac = \relax + \let\defmethod = \relax + \let\defop = \relax + \let\defopt = \relax + \let\defspec = \relax + \let\deftp = \relax + \let\deftypefn = \relax + \let\deftypefun = \relax + \let\deftypevar = \relax + \let\deftypevr = \relax + \let\defun = \relax + \let\defvar = \relax + \let\defvr = \relax + \let\ref = \relax + \let\xref = \relax + \let\printindex = \relax + \let\pxref = \relax + \let\settitle = \relax + \let\include = \relax + \let\lowersections = \relax + \let\down = \relax + \let\raisesections = \relax + \let\up = \relax + \let\set = \relax + \let\clear = \relax + \let\item = \relax + \let\message = \relax +} + +% Ignore @ignore ... @end ignore. +% +\def\ignore{\doignore{ignore}} + +% Also ignore @ifinfo, @ifhtml, @html, @menu, and @direntry text. +% +\def\ifinfo{\doignore{ifinfo}} +\def\ifhtml{\doignore{ifhtml}} +\def\html{\doignore{html}} +\def\menu{\doignore{menu}} +\def\direntry{\doignore{direntry}} + +% Ignore text until a line `@end #1'. +% +\def\doignore#1{\begingroup + % Don't complain about control sequences we have declared \outer. + \ignoresections + % + % Define a command to swallow text until we reach `@end #1'. + \long\def\doignoretext##1\end #1{\enddoignore}% + % + % Make sure that spaces turn into tokens that match what \doignoretext wants. + \catcode32 = 10 + % + % And now expand that command. + \doignoretext +} + +% What we do to finish off ignored text. +% +\def\enddoignore{\endgroup\ignorespaces}% + +\newif\ifwarnedobs\warnedobsfalse +\def\obstexwarn{% + \ifwarnedobs\relax\else + % We need to warn folks that they may have trouble with TeX 3.0. + % This uses \immediate\write16 rather than \message to get newlines. + \immediate\write16{} + \immediate\write16{***WARNING*** for users of Unix TeX 3.0!} + \immediate\write16{This manual trips a bug in TeX version 3.0 (tex hangs).} + \immediate\write16{If you are running another version of TeX, relax.} + \immediate\write16{If you are running Unix TeX 3.0, kill this TeX process.} + \immediate\write16{ Then upgrade your TeX installation if you can.} + \immediate\write16{If you are stuck with version 3.0, run the} + \immediate\write16{ script ``tex3patch'' from the Texinfo distribution} + \immediate\write16{ to use a workaround.} + \immediate\write16{} + \warnedobstrue + \fi +} + +% **In TeX 3.0, setting text in \nullfont hangs tex. For a +% workaround (which requires the file ``dummy.tfm'' to be installed), +% uncomment the following line: +%%%%%\font\nullfont=dummy\let\obstexwarn=\relax + +% Ignore text, except that we keep track of conditional commands for +% purposes of nesting, up to an `@end #1' command. +% +\def\nestedignore#1{% + \obstexwarn + % We must actually expand the ignored text to look for the @end + % command, so that nested ignore constructs work. Thus, we put the + % text into a \vbox and then do nothing with the result. To minimize + % the change of memory overflow, we follow the approach outlined on + % page 401 of the TeXbook: make the current font be a dummy font. + % + \setbox0 = \vbox\bgroup + % Don't complain about control sequences we have declared \outer. + \ignoresections + % + % Define `@end #1' to end the box, which will in turn undefine the + % @end command again. + \expandafter\def\csname E#1\endcsname{\egroup\ignorespaces}% + % + % We are going to be parsing Texinfo commands. Most cause no + % trouble when they are used incorrectly, but some commands do + % complicated argument parsing or otherwise get confused, so we + % undefine them. + % + % We can't do anything about stray @-signs, unfortunately; + % they'll produce `undefined control sequence' errors. + \ignoremorecommands + % + % Set the current font to be \nullfont, a TeX primitive, and define + % all the font commands to also use \nullfont. We don't use + % dummy.tfm, as suggested in the TeXbook, because not all sites + % might have that installed. Therefore, math mode will still + % produce output, but that should be an extremely small amount of + % stuff compared to the main input. + % + \nullfont + \let\tenrm = \nullfont \let\tenit = \nullfont \let\tensl = \nullfont + \let\tenbf = \nullfont \let\tentt = \nullfont \let\smallcaps = \nullfont + \let\tensf = \nullfont + % Similarly for index fonts (mostly for their use in + % smallexample) + \let\indrm = \nullfont \let\indit = \nullfont \let\indsl = \nullfont + \let\indbf = \nullfont \let\indtt = \nullfont \let\indsc = \nullfont + \let\indsf = \nullfont + % + % Don't complain when characters are missing from the fonts. + \tracinglostchars = 0 + % + % Don't bother to do space factor calculations. + \frenchspacing + % + % Don't report underfull hboxes. + \hbadness = 10000 + % + % Do minimal line-breaking. + \pretolerance = 10000 + % + % Do not execute instructions in @tex + \def\tex{\doignore{tex}} +} + +% @set VAR sets the variable VAR to an empty value. +% @set VAR REST-OF-LINE sets VAR to the value REST-OF-LINE. +% +% Since we want to separate VAR from REST-OF-LINE (which might be +% empty), we can't just use \parsearg; we have to insert a space of our +% own to delimit the rest of the line, and then take it out again if we +% didn't need it. +% +\def\set{\parsearg\setxxx} +\def\setxxx#1{\setyyy#1 \endsetyyy} +\def\setyyy#1 #2\endsetyyy{% + \def\temp{#2}% + \ifx\temp\empty \global\expandafter\let\csname SET#1\endcsname = \empty + \else \setzzz{#1}#2\endsetzzz % Remove the trailing space \setxxx inserted. + \fi +} +\def\setzzz#1#2 \endsetzzz{\expandafter\xdef\csname SET#1\endcsname{#2}} + +% @clear VAR clears (i.e., unsets) the variable VAR. +% +\def\clear{\parsearg\clearxxx} +\def\clearxxx#1{\global\expandafter\let\csname SET#1\endcsname=\relax} + +% @value{foo} gets the text saved in variable foo. +% +\def\value#1{\expandafter + \ifx\csname SET#1\endcsname\relax + {\{No value for ``#1''\}} + \else \csname SET#1\endcsname \fi} + +% @ifset VAR ... @end ifset reads the `...' iff VAR has been defined +% with @set. +% +\def\ifset{\parsearg\ifsetxxx} +\def\ifsetxxx #1{% + \expandafter\ifx\csname SET#1\endcsname\relax + \expandafter\ifsetfail + \else + \expandafter\ifsetsucceed + \fi +} +\def\ifsetsucceed{\conditionalsucceed{ifset}} +\def\ifsetfail{\nestedignore{ifset}} +\defineunmatchedend{ifset} + +% @ifclear VAR ... @end ifclear reads the `...' iff VAR has never been +% defined with @set, or has been undefined with @clear. +% +\def\ifclear{\parsearg\ifclearxxx} +\def\ifclearxxx #1{% + \expandafter\ifx\csname SET#1\endcsname\relax + \expandafter\ifclearsucceed + \else + \expandafter\ifclearfail + \fi +} +\def\ifclearsucceed{\conditionalsucceed{ifclear}} +\def\ifclearfail{\nestedignore{ifclear}} +\defineunmatchedend{ifclear} + +% @iftex always succeeds; we read the text following, through @end +% iftex). But `@end iftex' should be valid only after an @iftex. +% +\def\iftex{\conditionalsucceed{iftex}} +\defineunmatchedend{iftex} + +% We can't just want to start a group at @iftex (for example) and end it +% at @end iftex, since then @set commands inside the conditional have no +% effect (they'd get reverted at the end of the group). So we must +% define \Eiftex to redefine itself to be its previous value. (We can't +% just define it to fail again with an ``unmatched end'' error, since +% the @ifset might be nested.) +% +\def\conditionalsucceed#1{% + \edef\temp{% + % Remember the current value of \E#1. + \let\nece{prevE#1} = \nece{E#1}% + % + % At the `@end #1', redefine \E#1 to be its previous value. + \def\nece{E#1}{\let\nece{E#1} = \nece{prevE#1}}% + }% + \temp +} + +% We need to expand lots of \csname's, but we don't want to expand the +% control sequences after we've constructed them. +% +\def\nece#1{\expandafter\noexpand\csname#1\endcsname} + +% @asis just yields its argument. Used with @table, for example. +% +\def\asis#1{#1} + +% @math means output in math mode. +% We don't use $'s directly in the definition of \math because control +% sequences like \math are expanded when the toc file is written. Then, +% we read the toc file back, the $'s will be normal characters (as they +% should be, according to the definition of Texinfo). So we must use a +% control sequence to switch into and out of math mode. +% +% This isn't quite enough for @math to work properly in indices, but it +% seems unlikely it will ever be needed there. +% +\let\implicitmath = $ +\def\math#1{\implicitmath #1\implicitmath} + +% @bullet and @minus need the same treatment as @math, just above. +\def\bullet{\implicitmath\ptexbullet\implicitmath} +\def\minus{\implicitmath-\implicitmath} + +\def\node{\ENVcheck\parsearg\nodezzz} +\def\nodezzz#1{\nodexxx [#1,]} +\def\nodexxx[#1,#2]{\gdef\lastnode{#1}} +\let\nwnode=\node +\let\lastnode=\relax + +\def\donoderef{\ifx\lastnode\relax\else +\expandafter\expandafter\expandafter\setref{\lastnode}\fi +\global\let\lastnode=\relax} + +\def\unnumbnoderef{\ifx\lastnode\relax\else +\expandafter\expandafter\expandafter\unnumbsetref{\lastnode}\fi +\global\let\lastnode=\relax} + +\def\appendixnoderef{\ifx\lastnode\relax\else +\expandafter\expandafter\expandafter\appendixsetref{\lastnode}\fi +\global\let\lastnode=\relax} + +\let\refill=\relax + +% @setfilename is done at the beginning of every texinfo file. +% So open here the files we need to have open while reading the input. +% This makes it possible to make a .fmt file for texinfo. +\def\setfilename{% + \readauxfile + \opencontents + \openindices + \fixbackslash % Turn off hack to swallow `\input texinfo'. + \global\let\setfilename=\comment % Ignore extra @setfilename cmds. + \comment % Ignore the actual filename. +} + +\outer\def\bye{\pagealignmacro\tracingstats=1\ptexend} + +\def\inforef #1{\inforefzzz #1,,,,**} +\def\inforefzzz #1,#2,#3,#4**{\putwordSee{} \putwordInfo{} \putwordfile{} \file{\ignorespaces #3{}}, + node \samp{\ignorespaces#1{}}} + +\message{fonts,} + +% Font-change commands. + +% Texinfo supports the sans serif font style, which plain TeX does not. +% So we set up a \sf analogous to plain's \rm, etc. +\newfam\sffam +\def\sf{\fam=\sffam \tensf} +\let\li = \sf % Sometimes we call it \li, not \sf. + +%% Try out Computer Modern fonts at \magstephalf +\let\mainmagstep=\magstephalf + +\ifx\bigger\relax +\let\mainmagstep=\magstep1 +\font\textrm=cmr12 +\font\texttt=cmtt12 +\else +\font\textrm=cmr10 scaled \mainmagstep +\font\texttt=cmtt10 scaled \mainmagstep +\fi +% Instead of cmb10, you many want to use cmbx10. +% cmbx10 is a prettier font on its own, but cmb10 +% looks better when embedded in a line with cmr10. +\font\textbf=cmb10 scaled \mainmagstep +\font\textit=cmti10 scaled \mainmagstep +\font\textsl=cmsl10 scaled \mainmagstep +\font\textsf=cmss10 scaled \mainmagstep +\font\textsc=cmcsc10 scaled \mainmagstep +\font\texti=cmmi10 scaled \mainmagstep +\font\textsy=cmsy10 scaled \mainmagstep + +% A few fonts for @defun, etc. +\font\defbf=cmbx10 scaled \magstep1 %was 1314 +\font\deftt=cmtt10 scaled \magstep1 +\def\df{\let\tentt=\deftt \let\tenbf = \defbf \bf} + +% Fonts for indices and small examples. +% We actually use the slanted font rather than the italic, +% because texinfo normally uses the slanted fonts for that. +% Do not make many font distinctions in general in the index, since they +% aren't very useful. +\font\ninett=cmtt9 +\font\indrm=cmr9 +\font\indit=cmsl9 +\let\indsl=\indit +\let\indtt=\ninett +\let\indsf=\indrm +\let\indbf=\indrm +\let\indsc=\indrm +\font\indi=cmmi9 +\font\indsy=cmsy9 + +% Fonts for headings +\font\chaprm=cmbx12 scaled \magstep2 +\font\chapit=cmti12 scaled \magstep2 +\font\chapsl=cmsl12 scaled \magstep2 +\font\chaptt=cmtt12 scaled \magstep2 +\font\chapsf=cmss12 scaled \magstep2 +\let\chapbf=\chaprm +\font\chapsc=cmcsc10 scaled\magstep3 +\font\chapi=cmmi12 scaled \magstep2 +\font\chapsy=cmsy10 scaled \magstep3 + +\font\secrm=cmbx12 scaled \magstep1 +\font\secit=cmti12 scaled \magstep1 +\font\secsl=cmsl12 scaled \magstep1 +\font\sectt=cmtt12 scaled \magstep1 +\font\secsf=cmss12 scaled \magstep1 +\font\secbf=cmbx12 scaled \magstep1 +\font\secsc=cmcsc10 scaled\magstep2 +\font\seci=cmmi12 scaled \magstep1 +\font\secsy=cmsy10 scaled \magstep2 + +% \font\ssecrm=cmbx10 scaled \magstep1 % This size an font looked bad. +% \font\ssecit=cmti10 scaled \magstep1 % The letters were too crowded. +% \font\ssecsl=cmsl10 scaled \magstep1 +% \font\ssectt=cmtt10 scaled \magstep1 +% \font\ssecsf=cmss10 scaled \magstep1 + +%\font\ssecrm=cmb10 scaled 1315 % Note the use of cmb rather than cmbx. +%\font\ssecit=cmti10 scaled 1315 % Also, the size is a little larger than +%\font\ssecsl=cmsl10 scaled 1315 % being scaled magstep1. +%\font\ssectt=cmtt10 scaled 1315 +%\font\ssecsf=cmss10 scaled 1315 + +%\let\ssecbf=\ssecrm + +\font\ssecrm=cmbx12 scaled \magstephalf +\font\ssecit=cmti12 scaled \magstephalf +\font\ssecsl=cmsl12 scaled \magstephalf +\font\ssectt=cmtt12 scaled \magstephalf +\font\ssecsf=cmss12 scaled \magstephalf +\font\ssecbf=cmbx12 scaled \magstephalf +\font\ssecsc=cmcsc10 scaled \magstep1 +\font\sseci=cmmi12 scaled \magstephalf +\font\ssecsy=cmsy10 scaled \magstep1 +% The smallcaps and symbol fonts should actually be scaled \magstep1.5, +% but that is not a standard magnification. + +% Fonts for title page: +\font\titlerm = cmbx12 scaled \magstep3 +\let\authorrm = \secrm + +% In order for the font changes to affect most math symbols and letters, +% we have to define the \textfont of the standard families. Since +% texinfo doesn't allow for producing subscripts and superscripts, we +% don't bother to reset \scriptfont and \scriptscriptfont (which would +% also require loading a lot more fonts). +% +\def\resetmathfonts{% + \textfont0 = \tenrm \textfont1 = \teni \textfont2 = \tensy + \textfont\itfam = \tenit \textfont\slfam = \tensl \textfont\bffam = \tenbf + \textfont\ttfam = \tentt \textfont\sffam = \tensf +} + + +% The font-changing commands redefine the meanings of \tenSTYLE, instead +% of just \STYLE. We do this so that font changes will continue to work +% in math mode, where it is the current \fam that is relevant in most +% cases, not the current. Plain TeX does, for example, +% \def\bf{\fam=\bffam \tenbf} By redefining \tenbf, we obviate the need +% to redefine \bf itself. +\def\textfonts{% + \let\tenrm=\textrm \let\tenit=\textit \let\tensl=\textsl + \let\tenbf=\textbf \let\tentt=\texttt \let\smallcaps=\textsc + \let\tensf=\textsf \let\teni=\texti \let\tensy=\textsy + \resetmathfonts} +\def\chapfonts{% + \let\tenrm=\chaprm \let\tenit=\chapit \let\tensl=\chapsl + \let\tenbf=\chapbf \let\tentt=\chaptt \let\smallcaps=\chapsc + \let\tensf=\chapsf \let\teni=\chapi \let\tensy=\chapsy + \resetmathfonts} +\def\secfonts{% + \let\tenrm=\secrm \let\tenit=\secit \let\tensl=\secsl + \let\tenbf=\secbf \let\tentt=\sectt \let\smallcaps=\secsc + \let\tensf=\secsf \let\teni=\seci \let\tensy=\secsy + \resetmathfonts} +\def\subsecfonts{% + \let\tenrm=\ssecrm \let\tenit=\ssecit \let\tensl=\ssecsl + \let\tenbf=\ssecbf \let\tentt=\ssectt \let\smallcaps=\ssecsc + \let\tensf=\ssecsf \let\teni=\sseci \let\tensy=\ssecsy + \resetmathfonts} +\def\indexfonts{% + \let\tenrm=\indrm \let\tenit=\indit \let\tensl=\indsl + \let\tenbf=\indbf \let\tentt=\indtt \let\smallcaps=\indsc + \let\tensf=\indsf \let\teni=\indi \let\tensy=\indsy + \resetmathfonts} + +% Set up the default fonts, so we can use them for creating boxes. +% +\textfonts + +% Count depth in font-changes, for error checks +\newcount\fontdepth \fontdepth=0 + +% Fonts for short table of contents. +\font\shortcontrm=cmr12 +\font\shortcontbf=cmbx12 +\font\shortcontsl=cmsl12 + +%% Add scribe-like font environments, plus @l for inline lisp (usually sans +%% serif) and @ii for TeX italic + +% \smartitalic{ARG} outputs arg in italics, followed by an italic correction +% unless the following character is such as not to need one. +\def\smartitalicx{\ifx\next,\else\ifx\next-\else\ifx\next.\else\/\fi\fi\fi} +\def\smartitalic#1{{\sl #1}\futurelet\next\smartitalicx} + +\let\i=\smartitalic +\let\var=\smartitalic +\let\dfn=\smartitalic +\let\emph=\smartitalic +\let\cite=\smartitalic + +\def\b#1{{\bf #1}} +\let\strong=\b + +% We can't just use \exhyphenpenalty, because that only has effect at +% the end of a paragraph. Restore normal hyphenation at the end of the +% group within which \nohyphenation is presumably called. +% +\def\nohyphenation{\hyphenchar\font = -1 \aftergroup\restorehyphenation} +\def\restorehyphenation{\hyphenchar\font = `- } + +\def\t#1{% + {\tt \nohyphenation \rawbackslash \frenchspacing #1}% + \null +} +\let\ttfont = \t +%\def\samp #1{`{\tt \rawbackslash \frenchspacing #1}'\null} +\def\samp #1{`\tclose{#1}'\null} +\def\key #1{{\tt \nohyphenation \uppercase{#1}}\null} +\def\ctrl #1{{\tt \rawbackslash \hat}#1} + +\let\file=\samp + +% @code is a modification of @t, +% which makes spaces the same size as normal in the surrounding text. +\def\tclose#1{% + {% + % Change normal interword space to be same as for the current font. + \spaceskip = \fontdimen2\font + % + % Switch to typewriter. + \tt + % + % But `\ ' produces the large typewriter interword space. + \def\ {{\spaceskip = 0pt{} }}% + % + % Turn off hyphenation. + \nohyphenation + % + \rawbackslash + \frenchspacing + #1% + }% + \null +} + +% We *must* turn on hyphenation at `-' and `_' in \code. +% Otherwise, it is too hard to avoid overful hboxes +% in the Emacs manual, the Library manual, etc. + +% Unfortunately, TeX uses one parameter (\hyphenchar) to control +% both hyphenation at - and hyphenation within words. +% We must therefore turn them both off (\tclose does that) +% and arrange explicitly to hyphenate an a dash. +% -- rms. +{ +\catcode`\-=\active +\catcode`\_=\active +\global\def\code{\begingroup \catcode`\-=\active \let-\codedash \catcode`\_=\active \let_\codeunder \codex} +% The following is used by \doprintindex to insure that long function names +% wrap around. It is necessary for - and _ to be active before the index is +% read from the file, as \entry parses the arguments long before \code is +% ever called. -- mycroft +\global\def\indexbreaks{\catcode`\-=\active \let-\realdash \catcode`\_=\active \let_\realunder} +} +\def\realdash{-} +\def\realunder{_} +\def\codedash{-\discretionary{}{}{}} +\def\codeunder{\normalunderscore\discretionary{}{}{}} +\def\codex #1{\tclose{#1}\endgroup} + +%\let\exp=\tclose %Was temporary + +% @kbd is like @code, except that if the argument is just one @key command, +% then @kbd has no effect. + +\def\xkey{\key} +\def\kbdfoo#1#2#3\par{\def\one{#1}\def\three{#3}\def\threex{??}% +\ifx\one\xkey\ifx\threex\three \key{#2}% +\else\tclose{\look}\fi +\else\tclose{\look}\fi} + +% Typeset a dimension, e.g., `in' or `pt'. The only reason for the +% argument is to make the input look right: @dmn{pt} instead of +% @dmn{}pt. +% +\def\dmn#1{\thinspace #1} + +\def\kbd#1{\def\look{#1}\expandafter\kbdfoo\look??\par} + +\def\l#1{{\li #1}\null} % + +\def\r#1{{\rm #1}} % roman font +% Use of \lowercase was suggested. +\def\sc#1{{\smallcaps#1}} % smallcaps font +\def\ii#1{{\it #1}} % italic font + +\message{page headings,} + +\newskip\titlepagetopglue \titlepagetopglue = 1.5in +\newskip\titlepagebottomglue \titlepagebottomglue = 2pc + +% First the title page. Must do @settitle before @titlepage. +\def\titlefont#1{{\titlerm #1}} + +\newif\ifseenauthor +\newif\iffinishedtitlepage + +\def\shorttitlepage{\parsearg\shorttitlepagezzz} +\def\shorttitlepagezzz #1{\begingroup\hbox{}\vskip 1.5in \chaprm \centerline{#1}% + \endgroup\page\hbox{}\page} + +\def\titlepage{\begingroup \parindent=0pt \textfonts + \let\subtitlerm=\tenrm +% I deinstalled the following change because \cmr12 is undefined. +% This change was not in the ChangeLog anyway. --rms. +% \let\subtitlerm=\cmr12 + \def\subtitlefont{\subtitlerm \normalbaselineskip = 13pt \normalbaselines}% + % + \def\authorfont{\authorrm \normalbaselineskip = 16pt \normalbaselines}% + % + % Leave some space at the very top of the page. + \vglue\titlepagetopglue + % + % Now you can print the title using @title. + \def\title{\parsearg\titlezzz}% + \def\titlezzz##1{\leftline{\titlefont{##1}} + % print a rule at the page bottom also. + \finishedtitlepagefalse + \vskip4pt \hrule height 4pt width \hsize \vskip4pt}% + % No rule at page bottom unless we print one at the top with @title. + \finishedtitlepagetrue + % + % Now you can put text using @subtitle. + \def\subtitle{\parsearg\subtitlezzz}% + \def\subtitlezzz##1{{\subtitlefont \rightline{##1}}}% + % + % @author should come last, but may come many times. + \def\author{\parsearg\authorzzz}% + \def\authorzzz##1{\ifseenauthor\else\vskip 0pt plus 1filll\seenauthortrue\fi + {\authorfont \leftline{##1}}}% + % + % Most title ``pages'' are actually two pages long, with space + % at the top of the second. We don't want the ragged left on the second. + \let\oldpage = \page + \def\page{% + \iffinishedtitlepage\else + \finishtitlepage + \fi + \oldpage + \let\page = \oldpage + \hbox{}}% +% \def\page{\oldpage \hbox{}} +} + +\def\Etitlepage{% + \iffinishedtitlepage\else + \finishtitlepage + \fi + % It is important to do the page break before ending the group, + % because the headline and footline are only empty inside the group. + % If we use the new definition of \page, we always get a blank page + % after the title page, which we certainly don't want. + \oldpage + \endgroup + \HEADINGSon +} + +\def\finishtitlepage{% + \vskip4pt \hrule height 2pt width \hsize + \vskip\titlepagebottomglue + \finishedtitlepagetrue +} + +%%% Set up page headings and footings. + +\let\thispage=\folio + +\newtoks \evenheadline % Token sequence for heading line of even pages +\newtoks \oddheadline % Token sequence for heading line of odd pages +\newtoks \evenfootline % Token sequence for footing line of even pages +\newtoks \oddfootline % Token sequence for footing line of odd pages + +% Now make Tex use those variables +\headline={{\textfonts\rm \ifodd\pageno \the\oddheadline + \else \the\evenheadline \fi}} +\footline={{\textfonts\rm \ifodd\pageno \the\oddfootline + \else \the\evenfootline \fi}\HEADINGShook} +\let\HEADINGShook=\relax + +% Commands to set those variables. +% For example, this is what @headings on does +% @evenheading @thistitle|@thispage|@thischapter +% @oddheading @thischapter|@thispage|@thistitle +% @evenfooting @thisfile|| +% @oddfooting ||@thisfile + +\def\evenheading{\parsearg\evenheadingxxx} +\def\oddheading{\parsearg\oddheadingxxx} +\def\everyheading{\parsearg\everyheadingxxx} + +\def\evenfooting{\parsearg\evenfootingxxx} +\def\oddfooting{\parsearg\oddfootingxxx} +\def\everyfooting{\parsearg\everyfootingxxx} + +{\catcode`\@=0 % + +\gdef\evenheadingxxx #1{\evenheadingyyy #1@|@|@|@|\finish} +\gdef\evenheadingyyy #1@|#2@|#3@|#4\finish{% +\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\gdef\oddheadingxxx #1{\oddheadingyyy #1@|@|@|@|\finish} +\gdef\oddheadingyyy #1@|#2@|#3@|#4\finish{% +\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\gdef\everyheadingxxx #1{\everyheadingyyy #1@|@|@|@|\finish} +\gdef\everyheadingyyy #1@|#2@|#3@|#4\finish{% +\global\evenheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}} +\global\oddheadline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\gdef\evenfootingxxx #1{\evenfootingyyy #1@|@|@|@|\finish} +\gdef\evenfootingyyy #1@|#2@|#3@|#4\finish{% +\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\gdef\oddfootingxxx #1{\oddfootingyyy #1@|@|@|@|\finish} +\gdef\oddfootingyyy #1@|#2@|#3@|#4\finish{% +\global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} + +\gdef\everyfootingxxx #1{\everyfootingyyy #1@|@|@|@|\finish} +\gdef\everyfootingyyy #1@|#2@|#3@|#4\finish{% +\global\evenfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}} +\global\oddfootline={\rlap{\centerline{#2}}\line{#1\hfil#3}}} +% +}% unbind the catcode of @. + +% @headings double turns headings on for double-sided printing. +% @headings single turns headings on for single-sided printing. +% @headings off turns them off. +% @headings on same as @headings double, retained for compatibility. +% @headings after turns on double-sided headings after this page. +% @headings doubleafter turns on double-sided headings after this page. +% @headings singleafter turns on single-sided headings after this page. +% By default, they are off. + +\def\headings #1 {\csname HEADINGS#1\endcsname} + +\def\HEADINGSoff{ +\global\evenheadline={\hfil} \global\evenfootline={\hfil} +\global\oddheadline={\hfil} \global\oddfootline={\hfil}} +\HEADINGSoff +% When we turn headings on, set the page number to 1. +% For double-sided printing, put current file name in lower left corner, +% chapter name on inside top of right hand pages, document +% title on inside top of left hand pages, and page numbers on outside top +% edge of all pages. +\def\HEADINGSdouble{ +%\pagealignmacro +\global\pageno=1 +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\folio\hfil\thistitle}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +} +% For single-sided printing, chapter title goes across top left of page, +% page number on top right. +\def\HEADINGSsingle{ +%\pagealignmacro +\global\pageno=1 +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\thischapter\hfil\folio}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +} +\def\HEADINGSon{\HEADINGSdouble} + +\def\HEADINGSafter{\let\HEADINGShook=\HEADINGSdoublex} +\let\HEADINGSdoubleafter=\HEADINGSafter +\def\HEADINGSdoublex{% +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\folio\hfil\thistitle}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +} + +\def\HEADINGSsingleafter{\let\HEADINGShook=\HEADINGSsinglex} +\def\HEADINGSsinglex{% +\global\evenfootline={\hfil} +\global\oddfootline={\hfil} +\global\evenheadline={\line{\thischapter\hfil\folio}} +\global\oddheadline={\line{\thischapter\hfil\folio}} +} + +% Subroutines used in generating headings +% Produces Day Month Year style of output. +\def\today{\number\day\space +\ifcase\month\or +January\or February\or March\or April\or May\or June\or +July\or August\or September\or October\or November\or December\fi +\space\number\year} + +% Use this if you want the Month Day, Year style of output. +%\def\today{\ifcase\month\or +%January\or February\or March\or April\or May\or June\or +%July\or August\or September\or October\or November\or December\fi +%\space\number\day, \number\year} + +% @settitle line... specifies the title of the document, for headings +% It generates no output of its own + +\def\thistitle{No Title} +\def\settitle{\parsearg\settitlezzz} +\def\settitlezzz #1{\gdef\thistitle{#1}} + +\message{tables,} + +% @tabs -- simple alignment + +% These don't work. For one thing, \+ is defined as outer. +% So these macros cannot even be defined. + +%\def\tabs{\parsearg\tabszzz} +%\def\tabszzz #1{\settabs\+#1\cr} +%\def\tabline{\parsearg\tablinezzz} +%\def\tablinezzz #1{\+#1\cr} +%\def\&{&} + +% Tables -- @table, @ftable, @vtable, @item(x), @kitem(x), @xitem(x). + +% default indentation of table text +\newdimen\tableindent \tableindent=.8in +% default indentation of @itemize and @enumerate text +\newdimen\itemindent \itemindent=.3in +% margin between end of table item and start of table text. +\newdimen\itemmargin \itemmargin=.1in + +% used internally for \itemindent minus \itemmargin +\newdimen\itemmax + +% Note @table, @vtable, and @vtable define @item, @itemx, etc., with +% these defs. +% They also define \itemindex +% to index the item name in whatever manner is desired (perhaps none). + +\newif\ifitemxneedsnegativevskip + +\def\itemxpar{\par\ifitemxneedsnegativevskip\vskip-\parskip\nobreak\fi} + +\def\internalBitem{\smallbreak \parsearg\itemzzz} +\def\internalBitemx{\itemxpar \parsearg\itemzzz} + +\def\internalBxitem "#1"{\def\xitemsubtopix{#1} \smallbreak \parsearg\xitemzzz} +\def\internalBxitemx "#1"{\def\xitemsubtopix{#1} \itemxpar \parsearg\xitemzzz} + +\def\internalBkitem{\smallbreak \parsearg\kitemzzz} +\def\internalBkitemx{\itemxpar \parsearg\kitemzzz} + +\def\kitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \lastfunction}}% + \itemzzz {#1}} + +\def\xitemzzz #1{\dosubind {kw}{\code{#1}}{for {\bf \xitemsubtopic}}% + \itemzzz {#1}} + +\def\itemzzz #1{\begingroup % + \advance\hsize by -\rightskip + \advance\hsize by -\tableindent + \setbox0=\hbox{\itemfont{#1}}% + \itemindex{#1}% + \nobreak % This prevents a break before @itemx. + % + % Be sure we are not still in the middle of a paragraph. + %{\parskip = 0in + %\par + %}% + % + % If the item text does not fit in the space we have, put it on a line + % by itself, and do not allow a page break either before or after that + % line. We do not start a paragraph here because then if the next + % command is, e.g., @kindex, the whatsit would get put into the + % horizontal list on a line by itself, resulting in extra blank space. + \ifdim \wd0>\itemmax + % + % Make this a paragraph so we get the \parskip glue and wrapping, + % but leave it ragged-right. + \begingroup + \advance\leftskip by-\tableindent + \advance\hsize by\tableindent + \advance\rightskip by0pt plus1fil + \leavevmode\unhbox0\par + \endgroup + % + % We're going to be starting a paragraph, but we don't want the + % \parskip glue -- logically it's part of the @item we just started. + \nobreak \vskip-\parskip + % + % Stop a page break at the \parskip glue coming up. Unfortunately + % we can't prevent a possible page break at the following + % \baselineskip glue. + \nobreak + \endgroup + \itemxneedsnegativevskipfalse + \else + % The item text fits into the space. Start a paragraph, so that the + % following text (if any) will end up on the same line. Since that + % text will be indented by \tableindent, we make the item text be in + % a zero-width box. + \noindent + \rlap{\hskip -\tableindent\box0}\ignorespaces% + \endgroup% + \itemxneedsnegativevskiptrue% + \fi +} + +\def\item{\errmessage{@item while not in a table}} +\def\itemx{\errmessage{@itemx while not in a table}} +\def\kitem{\errmessage{@kitem while not in a table}} +\def\kitemx{\errmessage{@kitemx while not in a table}} +\def\xitem{\errmessage{@xitem while not in a table}} +\def\xitemx{\errmessage{@xitemx while not in a table}} + +%% Contains a kludge to get @end[description] to work +\def\description{\tablez{\dontindex}{1}{}{}{}{}} + +\def\table{\begingroup\inENV\obeylines\obeyspaces\tablex} +{\obeylines\obeyspaces% +\gdef\tablex #1^^M{% +\tabley\dontindex#1 \endtabley}} + +\def\ftable{\begingroup\inENV\obeylines\obeyspaces\ftablex} +{\obeylines\obeyspaces% +\gdef\ftablex #1^^M{% +\tabley\fnitemindex#1 \endtabley +\def\Eftable{\endgraf\afterenvbreak\endgroup}% +\let\Etable=\relax}} + +\def\vtable{\begingroup\inENV\obeylines\obeyspaces\vtablex} +{\obeylines\obeyspaces% +\gdef\vtablex #1^^M{% +\tabley\vritemindex#1 \endtabley +\def\Evtable{\endgraf\afterenvbreak\endgroup}% +\let\Etable=\relax}} + +\def\dontindex #1{} +\def\fnitemindex #1{\doind {fn}{\code{#1}}}% +\def\vritemindex #1{\doind {vr}{\code{#1}}}% + +{\obeyspaces % +\gdef\tabley#1#2 #3 #4 #5 #6 #7\endtabley{\endgroup% +\tablez{#1}{#2}{#3}{#4}{#5}{#6}}} + +\def\tablez #1#2#3#4#5#6{% +\aboveenvbreak % +\begingroup % +\def\Edescription{\Etable}% Neccessary kludge. +\let\itemindex=#1% +\ifnum 0#3>0 \advance \leftskip by #3\mil \fi % +\ifnum 0#4>0 \tableindent=#4\mil \fi % +\ifnum 0#5>0 \advance \rightskip by #5\mil \fi % +\def\itemfont{#2}% +\itemmax=\tableindent % +\advance \itemmax by -\itemmargin % +\advance \leftskip by \tableindent % +\exdentamount=\tableindent +\parindent = 0pt +\parskip = \smallskipamount +\ifdim \parskip=0pt \parskip=2pt \fi% +\def\Etable{\endgraf\afterenvbreak\endgroup}% +\let\item = \internalBitem % +\let\itemx = \internalBitemx % +\let\kitem = \internalBkitem % +\let\kitemx = \internalBkitemx % +\let\xitem = \internalBxitem % +\let\xitemx = \internalBxitemx % +} + +% This is the counter used by @enumerate, which is really @itemize + +\newcount \itemno + +\def\itemize{\parsearg\itemizezzz} + +\def\itemizezzz #1{% + \begingroup % ended by the @end itemsize + \itemizey {#1}{\Eitemize} +} + +\def\itemizey #1#2{% +\aboveenvbreak % +\itemmax=\itemindent % +\advance \itemmax by -\itemmargin % +\advance \leftskip by \itemindent % +\exdentamount=\itemindent +\parindent = 0pt % +\parskip = \smallskipamount % +\ifdim \parskip=0pt \parskip=2pt \fi% +\def#2{\endgraf\afterenvbreak\endgroup}% +\def\itemcontents{#1}% +\let\item=\itemizeitem} + +% Set sfcode to normal for the chars that usually have another value. +% These are `.?!:;,' +\def\frenchspacing{\sfcode46=1000 \sfcode63=1000 \sfcode33=1000 + \sfcode58=1000 \sfcode59=1000 \sfcode44=1000 } + +% \splitoff TOKENS\endmark defines \first to be the first token in +% TOKENS, and \rest to be the remainder. +% +\def\splitoff#1#2\endmark{\def\first{#1}\def\rest{#2}}% + +% Allow an optional argument of an uppercase letter, lowercase letter, +% or number, to specify the first label in the enumerated list. No +% argument is the same as `1'. +% +\def\enumerate{\parsearg\enumeratezzz} +\def\enumeratezzz #1{\enumeratey #1 \endenumeratey} +\def\enumeratey #1 #2\endenumeratey{% + \begingroup % ended by the @end enumerate + % + % If we were given no argument, pretend we were given `1'. + \def\thearg{#1}% + \ifx\thearg\empty \def\thearg{1}\fi + % + % Detect if the argument is a single token. If so, it might be a + % letter. Otherwise, the only valid thing it can be is a number. + % (We will always have one token, because of the test we just made. + % This is a good thing, since \splitoff doesn't work given nothing at + % all -- the first parameter is undelimited.) + \expandafter\splitoff\thearg\endmark + \ifx\rest\empty + % Only one token in the argument. It could still be anything. + % A ``lowercase letter'' is one whose \lccode is nonzero. + % An ``uppercase letter'' is one whose \lccode is both nonzero, and + % not equal to itself. + % Otherwise, we assume it's a number. + % + % We need the \relax at the end of the \ifnum lines to stop TeX from + % continuing to look for a <number>. + % + \ifnum\lccode\expandafter`\thearg=0\relax + \numericenumerate % a number (we hope) + \else + % It's a letter. + \ifnum\lccode\expandafter`\thearg=\expandafter`\thearg\relax + \lowercaseenumerate % lowercase letter + \else + \uppercaseenumerate % uppercase letter + \fi + \fi + \else + % Multiple tokens in the argument. We hope it's a number. + \numericenumerate + \fi +} + +% An @enumerate whose labels are integers. The starting integer is +% given in \thearg. +% +\def\numericenumerate{% + \itemno = \thearg + \startenumeration{\the\itemno}% +} + +% The starting (lowercase) letter is in \thearg. +\def\lowercaseenumerate{% + \itemno = \expandafter`\thearg + \startenumeration{% + % Be sure we're not beyond the end of the alphabet. + \ifnum\itemno=0 + \errmessage{No more lowercase letters in @enumerate; get a bigger + alphabet}% + \fi + \char\lccode\itemno + }% +} + +% The starting (uppercase) letter is in \thearg. +\def\uppercaseenumerate{% + \itemno = \expandafter`\thearg + \startenumeration{% + % Be sure we're not beyond the end of the alphabet. + \ifnum\itemno=0 + \errmessage{No more uppercase letters in @enumerate; get a bigger + alphabet} + \fi + \char\uccode\itemno + }% +} + +% Call itemizey, adding a period to the first argument and supplying the +% common last two arguments. Also subtract one from the initial value in +% \itemno, since @item increments \itemno. +% +\def\startenumeration#1{% + \advance\itemno by -1 + \itemizey{#1.}\Eenumerate\flushcr +} + +% @alphaenumerate and @capsenumerate are abbreviations for giving an arg +% to @enumerate. +% +\def\alphaenumerate{\enumerate{a}} +\def\capsenumerate{\enumerate{A}} +\def\Ealphaenumerate{\Eenumerate} +\def\Ecapsenumerate{\Eenumerate} + +% Definition of @item while inside @itemize. + +\def\itemizeitem{% +\advance\itemno by 1 +{\let\par=\endgraf \smallbreak}% +\ifhmode \errmessage{\in hmode at itemizeitem}\fi +{\parskip=0in \hskip 0pt +\hbox to 0pt{\hss \itemcontents\hskip \itemmargin}% +\vadjust{\penalty 1200}}% +\flushcr} + +% @multitable macros +% Amy Hendrickson, 8/18/94 +% +% @multitable ... @endmultitable will make as many columns as desired. +% Contents of each column will wrap at width given in preamble. Width +% can be specified either with sample text given in a template line, +% or in percent of \hsize, the current width of text on page. + +% Table can continue over pages but will only break between lines. + +% To make preamble: +% +% Either define widths of columns in terms of percent of \hsize: +% @multitable @percentofhsize .2 .3 .5 +% @item ... +% +% Numbers following @percentofhsize are the percent of the total +% current hsize to be used for each column. You may use as many +% columns as desired. + +% Or use a template: +% @multitable {Column 1 template} {Column 2 template} {Column 3 template} +% @item ... +% using the widest term desired in each column. + + +% Each new table line starts with @item, each subsequent new column +% starts with @tab. Empty columns may be produced by supplying @tab's +% with nothing between them for as many times as empty columns are needed, +% ie, @tab@tab@tab will produce two empty columns. + +% @item, @tab, @multicolumn or @endmulticolumn do not need to be on their +% own lines, but it will not hurt if they are. + +% Sample multitable: + +% @multitable {Column 1 template} {Column 2 template} {Column 3 template} +% @item first col stuff @tab second col stuff @tab third col +% @item +% first col stuff +% @tab +% second col stuff +% @tab +% third col +% @item first col stuff @tab second col stuff +% @tab Many paragraphs of text may be used in any column. +% +% They will wrap at the width determined by the template. +% @item@tab@tab This will be in third column. +% @endmultitable + +% Default dimensions may be reset by user. +% @intableparskip will set vertical space between paragraphs in table. +% @intableparindent will set paragraph indent in table. +% @spacebetweencols will set horizontal space to be left between columns. +% @spacebetweenlines will set vertical space to be left between lines. + +%%%% +% Dimensions + +\newdimen\intableparskip +\newdimen\intableparindent +\newdimen\spacebetweencols +\newdimen\spacebetweenlines +\intableparskip=0pt +\intableparindent=6pt +\spacebetweencols=12pt +\spacebetweenlines=12pt + +%%%% +% Macros used to set up halign preamble: +\let\endsetuptable\relax +\def\xendsetuptable{\endsetuptable} +\let\percentofhsize\relax +\def\xpercentofhsize{\percentofhsize} +\newif\ifsetpercent + +\newcount\colcount +\def\setuptable#1{\def\firstarg{#1}% +\ifx\firstarg\xendsetuptable\let\go\relax% +\else + \ifx\firstarg\xpercentofhsize\global\setpercenttrue% + \else + \ifsetpercent + \if#1.\else% + \global\advance\colcount by1 % + \expandafter\xdef\csname col\the\colcount\endcsname{.#1\hsize}% + \fi + \else + \global\advance\colcount by1 + \setbox0=\hbox{#1}% + \expandafter\xdef\csname col\the\colcount\endcsname{\the\wd0}% + \fi% + \fi% + \let\go\setuptable% +\fi\go} +%%%% +% multitable syntax +\def\tab{&} + +%%%% +% @multitable ... @endmultitable definitions: + +\def\multitable#1\item{\bgroup +\let\item\cr +\tolerance=9500 +\hbadness=9500 +\parskip=\intableparskip +\parindent=\intableparindent +\overfullrule=0pt +\global\colcount=0\relax% +\def\Emultitable{\global\setpercentfalse\global\everycr{}\cr\egroup\egroup}% + % To parse everything between @multitable and @item : +\def\one{#1}\expandafter\setuptable\one\endsetuptable + % Need to reset this to 0 after \setuptable. +\global\colcount=0\relax% + % + % This preamble sets up a generic column definition, which will + % be used as many times as user calls for columns. + % \vtop will set a single line and will also let text wrap and + % continue for many paragraphs if desired. +\halign\bgroup&\global\advance\colcount by 1\relax% +\vtop{\hsize=\expandafter\csname col\the\colcount\endcsname + % In order to keep entries from bumping into each other + % we will add a \leftskip of \spacebetweencols to all columns after + % the first one. + % If a template has been used, we will add \spacebetweencols + % to the width of each template entry. + % If user has set preamble in terms of percent of \hsize + % we will use that dimension as the width of the column, and + % the \leftskip will keep entries from bumping into each other. + % Table will start at left margin and final column will justify at + % right margin. +\ifnum\colcount=1 +\else + \ifsetpercent + \else + % If user has <not> set preamble in terms of percent of \hsize + % we will advance \hsize by \spacebetweencols + \advance\hsize by \spacebetweencols + \fi + % In either case we will make \leftskip=\spacebetweencols: +\leftskip=\spacebetweencols +\fi +\noindent##}\cr% + % \everycr will reset column counter, \colcount, at the end of + % each line. Every column entry will cause \colcount to advance by one. + % The table preamble + % looks at the current \colcount to find the correct column width. +\global\everycr{\noalign{\nointerlineskip\vskip\spacebetweenlines +\filbreak%% keeps underfull box messages off when table breaks over pages. +\global\colcount=0\relax}}} + +\message{indexing,} +% Index generation facilities + +% Define \newwrite to be identical to plain tex's \newwrite +% except not \outer, so it can be used within \newindex. +{\catcode`\@=11 +\gdef\newwrite{\alloc@7\write\chardef\sixt@@n}} + +% \newindex {foo} defines an index named foo. +% It automatically defines \fooindex such that +% \fooindex ...rest of line... puts an entry in the index foo. +% It also defines \fooindfile to be the number of the output channel for +% the file that accumulates this index. The file's extension is foo. +% The name of an index should be no more than 2 characters long +% for the sake of vms. + +\def\newindex #1{ +\expandafter\newwrite \csname#1indfile\endcsname% Define number for output file +\openout \csname#1indfile\endcsname \jobname.#1 % Open the file +\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex +\noexpand\doindex {#1}} +} + +% @defindex foo == \newindex{foo} + +\def\defindex{\parsearg\newindex} + +% Define @defcodeindex, like @defindex except put all entries in @code. + +\def\newcodeindex #1{ +\expandafter\newwrite \csname#1indfile\endcsname% Define number for output file +\openout \csname#1indfile\endcsname \jobname.#1 % Open the file +\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex +\noexpand\docodeindex {#1}} +} + +\def\defcodeindex{\parsearg\newcodeindex} + +% @synindex foo bar makes index foo feed into index bar. +% Do this instead of @defindex foo if you don't want it as a separate index. +\def\synindex #1 #2 {% +\expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname +\expandafter\let\csname#1indfile\endcsname=\synindexfoo +\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex +\noexpand\doindex {#2}}% +} + +% @syncodeindex foo bar similar, but put all entries made for index foo +% inside @code. +\def\syncodeindex #1 #2 {% +\expandafter\let\expandafter\synindexfoo\expandafter=\csname#2indfile\endcsname +\expandafter\let\csname#1indfile\endcsname=\synindexfoo +\expandafter\xdef\csname#1index\endcsname{% % Define \xxxindex +\noexpand\docodeindex {#2}}% +} + +% Define \doindex, the driver for all \fooindex macros. +% Argument #1 is generated by the calling \fooindex macro, +% and it is "foo", the name of the index. + +% \doindex just uses \parsearg; it calls \doind for the actual work. +% This is because \doind is more useful to call from other macros. + +% There is also \dosubind {index}{topic}{subtopic} +% which makes an entry in a two-level index such as the operation index. + +\def\doindex#1{\edef\indexname{#1}\parsearg\singleindexer} +\def\singleindexer #1{\doind{\indexname}{#1}} + +% like the previous two, but they put @code around the argument. +\def\docodeindex#1{\edef\indexname{#1}\parsearg\singlecodeindexer} +\def\singlecodeindexer #1{\doind{\indexname}{\code{#1}}} + +\def\indexdummies{% +% Take care of the plain tex accent commands. +\def\"{\realbackslash "}% +\def\`{\realbackslash `}% +\def\'{\realbackslash '}% +\def\^{\realbackslash ^}% +\def\~{\realbackslash ~}% +\def\={\realbackslash =}% +\def\b{\realbackslash b}% +\def\c{\realbackslash c}% +\def\d{\realbackslash d}% +\def\u{\realbackslash u}% +\def\v{\realbackslash v}% +\def\H{\realbackslash H}% +% Take care of the plain tex special European modified letters. +\def\oe{\realbackslash oe}% +\def\ae{\realbackslash ae}% +\def\aa{\realbackslash aa}% +\def\OE{\realbackslash OE}% +\def\AE{\realbackslash AE}% +\def\AA{\realbackslash AA}% +\def\o{\realbackslash o}% +\def\O{\realbackslash O}% +\def\l{\realbackslash l}% +\def\L{\realbackslash L}% +\def\ss{\realbackslash ss}% +% Take care of texinfo commands likely to appear in an index entry. +\def\_{{\realbackslash _}}% +\def\w{\realbackslash w }% +\def\bf{\realbackslash bf }% +\def\rm{\realbackslash rm }% +\def\sl{\realbackslash sl }% +\def\sf{\realbackslash sf}% +\def\tt{\realbackslash tt}% +\def\gtr{\realbackslash gtr}% +\def\less{\realbackslash less}% +\def\hat{\realbackslash hat}% +\def\char{\realbackslash char}% +\def\TeX{\realbackslash TeX}% +\def\dots{\realbackslash dots }% +\def\copyright{\realbackslash copyright }% +\def\tclose##1{\realbackslash tclose {##1}}% +\def\code##1{\realbackslash code {##1}}% +\def\samp##1{\realbackslash samp {##1}}% +\def\t##1{\realbackslash r {##1}}% +\def\r##1{\realbackslash r {##1}}% +\def\i##1{\realbackslash i {##1}}% +\def\b##1{\realbackslash b {##1}}% +\def\cite##1{\realbackslash cite {##1}}% +\def\key##1{\realbackslash key {##1}}% +\def\file##1{\realbackslash file {##1}}% +\def\var##1{\realbackslash var {##1}}% +\def\kbd##1{\realbackslash kbd {##1}}% +\def\dfn##1{\realbackslash dfn {##1}}% +\def\emph##1{\realbackslash emph {##1}}% +} + +% \indexnofonts no-ops all font-change commands. +% This is used when outputting the strings to sort the index by. +\def\indexdummyfont#1{#1} +\def\indexdummytex{TeX} +\def\indexdummydots{...} + +\def\indexnofonts{% +% Just ignore accents. +\let\"=\indexdummyfont +\let\`=\indexdummyfont +\let\'=\indexdummyfont +\let\^=\indexdummyfont +\let\~=\indexdummyfont +\let\==\indexdummyfont +\let\b=\indexdummyfont +\let\c=\indexdummyfont +\let\d=\indexdummyfont +\let\u=\indexdummyfont +\let\v=\indexdummyfont +\let\H=\indexdummyfont +% Take care of the plain tex special European modified letters. +\def\oe{oe}% +\def\ae{ae}% +\def\aa{aa}% +\def\OE{OE}% +\def\AE{AE}% +\def\AA{AA}% +\def\o{o}% +\def\O{O}% +\def\l{l}% +\def\L{L}% +\def\ss{ss}% +\let\w=\indexdummyfont +\let\t=\indexdummyfont +\let\r=\indexdummyfont +\let\i=\indexdummyfont +\let\b=\indexdummyfont +\let\emph=\indexdummyfont +\let\strong=\indexdummyfont +\let\cite=\indexdummyfont +\let\sc=\indexdummyfont +%Don't no-op \tt, since it isn't a user-level command +% and is used in the definitions of the active chars like <, >, |... +%\let\tt=\indexdummyfont +\let\tclose=\indexdummyfont +\let\code=\indexdummyfont +\let\file=\indexdummyfont +\let\samp=\indexdummyfont +\let\kbd=\indexdummyfont +\let\key=\indexdummyfont +\let\var=\indexdummyfont +\let\TeX=\indexdummytex +\let\dots=\indexdummydots +} + +% To define \realbackslash, we must make \ not be an escape. +% We must first make another character (@) an escape +% so we do not become unable to do a definition. + +{\catcode`\@=0 \catcode`\\=\other +@gdef@realbackslash{\}} + +\let\indexbackslash=0 %overridden during \printindex. + +\def\doind #1#2{% +{\count10=\lastpenalty % +{\indexdummies % Must do this here, since \bf, etc expand at this stage +\escapechar=`\\% +{\let\folio=0% Expand all macros now EXCEPT \folio +\def\rawbackslashxx{\indexbackslash}% \indexbackslash isn't defined now +% so it will be output as is; and it will print as backslash in the indx. +% +% Now process the index-string once, with all font commands turned off, +% to get the string to sort the index by. +{\indexnofonts +\xdef\temp1{#2}% +}% +% Now produce the complete index entry. We process the index-string again, +% this time with font commands expanded, to get what to print in the index. +\edef\temp{% +\write \csname#1indfile\endcsname{% +\realbackslash entry {\temp1}{\folio}{#2}}}% +\temp }% +}\penalty\count10}} + +\def\dosubind #1#2#3{% +{\count10=\lastpenalty % +{\indexdummies % Must do this here, since \bf, etc expand at this stage +\escapechar=`\\% +{\let\folio=0% +\def\rawbackslashxx{\indexbackslash}% +% +% Now process the index-string once, with all font commands turned off, +% to get the string to sort the index by. +{\indexnofonts +\xdef\temp1{#2 #3}% +}% +% Now produce the complete index entry. We process the index-string again, +% this time with font commands expanded, to get what to print in the index. +\edef\temp{% +\write \csname#1indfile\endcsname{% +\realbackslash entry {\temp1}{\folio}{#2}{#3}}}% +\temp }% +}\penalty\count10}} + +% The index entry written in the file actually looks like +% \entry {sortstring}{page}{topic} +% or +% \entry {sortstring}{page}{topic}{subtopic} +% The texindex program reads in these files and writes files +% containing these kinds of lines: +% \initial {c} +% before the first topic whose initial is c +% \entry {topic}{pagelist} +% for a topic that is used without subtopics +% \primary {topic} +% for the beginning of a topic that is used with subtopics +% \secondary {subtopic}{pagelist} +% for each subtopic. + +% Define the user-accessible indexing commands +% @findex, @vindex, @kindex, @cindex. + +\def\findex {\fnindex} +\def\kindex {\kyindex} +\def\cindex {\cpindex} +\def\vindex {\vrindex} +\def\tindex {\tpindex} +\def\pindex {\pgindex} + +\def\cindexsub {\begingroup\obeylines\cindexsub} +{\obeylines % +\gdef\cindexsub "#1" #2^^M{\endgroup % +\dosubind{cp}{#2}{#1}}} + +% Define the macros used in formatting output of the sorted index material. + +% This is what you call to cause a particular index to get printed. +% Write +% @unnumbered Function Index +% @printindex fn + +\def\printindex{\parsearg\doprintindex} + +\def\doprintindex#1{% + \tex + \dobreak \chapheadingskip {10000} + \catcode`\%=\other\catcode`\&=\other\catcode`\#=\other + \catcode`\$=\other + \catcode`\~=\other + \indexbreaks + % + % The following don't help, since the chars were translated + % when the raw index was written, and their fonts were discarded + % due to \indexnofonts. + %\catcode`\"=\active + %\catcode`\^=\active + %\catcode`\_=\active + %\catcode`\|=\active + %\catcode`\<=\active + %\catcode`\>=\active + % % + \def\indexbackslash{\rawbackslashxx} + \indexfonts\rm \tolerance=9500 \advance\baselineskip -1pt + \begindoublecolumns + % + % See if the index file exists and is nonempty. + \openin 1 \jobname.#1s + \ifeof 1 + % \enddoublecolumns gets confused if there is no text in the index, + % and it loses the chapter title and the aux file entries for the + % index. The easiest way to prevent this problem is to make sure + % there is some text. + (Index is nonexistent) + \else + % + % If the index file exists but is empty, then \openin leaves \ifeof + % false. We have to make TeX try to read something from the file, so + % it can discover if there is anything in it. + \read 1 to \temp + \ifeof 1 + (Index is empty) + \else + \input \jobname.#1s + \fi + \fi + \closein 1 + \enddoublecolumns + \Etex +} + +% These macros are used by the sorted index file itself. +% Change them to control the appearance of the index. + +% Same as \bigskipamount except no shrink. +% \balancecolumns gets confused if there is any shrink. +\newskip\initialskipamount \initialskipamount 12pt plus4pt + +\def\initial #1{% +{\let\tentt=\sectt \let\tt=\sectt \let\sf=\sectt +\ifdim\lastskip<\initialskipamount +\removelastskip \penalty-200 \vskip \initialskipamount\fi +\line{\secbf#1\hfill}\kern 2pt\penalty10000}} + +% This typesets a paragraph consisting of #1, dot leaders, and then #2 +% flush to the right margin. It is used for index and table of contents +% entries. The paragraph is indented by \leftskip. +% +\def\entry #1#2{\begingroup + % + % Start a new paragraph if necessary, so our assignments below can't + % affect previous text. + \par + % + % Do not fill out the last line with white space. + \parfillskip = 0in + % + % No extra space above this paragraph. + \parskip = 0in + % + % Do not prefer a separate line ending with a hyphen to fewer lines. + \finalhyphendemerits = 0 + % + % \hangindent is only relevant when the entry text and page number + % don't both fit on one line. In that case, bob suggests starting the + % dots pretty far over on the line. Unfortunately, a large + % indentation looks wrong when the entry text itself is broken across + % lines. So we use a small indentation and put up with long leaders. + % + % \hangafter is reset to 1 (which is the value we want) at the start + % of each paragraph, so we need not do anything with that. + \hangindent=2em + % + % When the entry text needs to be broken, just fill out the first line + % with blank space. + \rightskip = 0pt plus1fil + % + % Start a ``paragraph'' for the index entry so the line breaking + % parameters we've set above will have an effect. + \noindent + % + % Insert the text of the index entry. TeX will do line-breaking on it. + #1% + % The following is kluged to not output a line of dots in the index if + % there are no page numbers. The next person who breaks this will be + % cursed by a Unix daemon. + \def\tempa{{\rm }}% + \def\tempb{#2}% + \edef\tempc{\tempa}% + \edef\tempd{\tempb}% + \ifx\tempc\tempd\ \else% + % + % If we must, put the page number on a line of its own, and fill out + % this line with blank space. (The \hfil is overwhelmed with the + % fill leaders glue in \indexdotfill if the page number does fit.) + \hfil\penalty50 + \null\nobreak\indexdotfill % Have leaders before the page number. + % + % The `\ ' here is removed by the implicit \unskip that TeX does as + % part of (the primitive) \par. Without it, a spurious underfull + % \hbox ensues. + \ #2% The page number ends the paragraph. + \fi% + \par +\endgroup} + +% Like \dotfill except takes at least 1 em. +\def\indexdotfill{\cleaders + \hbox{$\mathsurround=0pt \mkern1.5mu ${\it .}$ \mkern1.5mu$}\hskip 1em plus 1fill} + +\def\primary #1{\line{#1\hfil}} + +\newskip\secondaryindent \secondaryindent=0.5cm + +\def\secondary #1#2{ +{\parfillskip=0in \parskip=0in +\hangindent =1in \hangafter=1 +\noindent\hskip\secondaryindent\hbox{#1}\indexdotfill #2\par +}} + +%% Define two-column mode, which is used in indexes. +%% Adapted from the TeXbook, page 416. +\catcode `\@=11 + +\newbox\partialpage + +\newdimen\doublecolumnhsize + +\def\begindoublecolumns{\begingroup + % Grab any single-column material above us. + \output = {\global\setbox\partialpage + =\vbox{\unvbox255\kern -\topskip \kern \baselineskip}}% + \eject + % + % Now switch to the double-column output routine. + \output={\doublecolumnout}% + % + % Change the page size parameters. We could do this once outside this + % routine, in each of @smallbook, @afourpaper, and the default 8.5x11 + % format, but then we repeat the same computation. Repeating a couple + % of assignments once per index is clearly meaningless for the + % execution time, so we may as well do it once. + % + % First we halve the line length, less a little for the gutter between + % the columns. We compute the gutter based on the line length, so it + % changes automatically with the paper format. The magic constant + % below is chosen so that the gutter has the same value (well, +- < + % 1pt) as it did when we hard-coded it. + % + % We put the result in a separate register, \doublecolumhsize, so we + % can restore it in \pagesofar, after \hsize itself has (potentially) + % been clobbered. + % + \doublecolumnhsize = \hsize + \advance\doublecolumnhsize by -.04154\hsize + \divide\doublecolumnhsize by 2 + \hsize = \doublecolumnhsize + % + % Double the \vsize as well. (We don't need a separate register here, + % since nobody clobbers \vsize.) + \vsize = 2\vsize + \doublecolumnpagegoal +} + +\def\enddoublecolumns{\eject \endgroup \pagegoal=\vsize \unvbox\partialpage} + +\def\doublecolumnsplit{\splittopskip=\topskip \splitmaxdepth=\maxdepth + \global\dimen@=\pageheight \global\advance\dimen@ by-\ht\partialpage + \global\setbox1=\vsplit255 to\dimen@ \global\setbox0=\vbox{\unvbox1} + \global\setbox3=\vsplit255 to\dimen@ \global\setbox2=\vbox{\unvbox3} + \ifdim\ht0>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi + \ifdim\ht2>\dimen@ \setbox255=\vbox{\unvbox0\unvbox2} \global\setbox255=\copy5 \fi +} +\def\doublecolumnpagegoal{% + \dimen@=\vsize \advance\dimen@ by-2\ht\partialpage \global\pagegoal=\dimen@ +} +\def\pagesofar{\unvbox\partialpage % + \hsize=\doublecolumnhsize % have to restore this since output routine + \wd0=\hsize \wd2=\hsize \hbox to\pagewidth{\box0\hfil\box2}} +\def\doublecolumnout{% + \setbox5=\copy255 + {\vbadness=10000 \doublecolumnsplit} + \ifvbox255 + \setbox0=\vtop to\dimen@{\unvbox0} + \setbox2=\vtop to\dimen@{\unvbox2} + \onepageout\pagesofar \unvbox255 \penalty\outputpenalty + \else + \setbox0=\vbox{\unvbox5} + \ifvbox0 + \dimen@=\ht0 \advance\dimen@ by\topskip \advance\dimen@ by-\baselineskip + \divide\dimen@ by2 \splittopskip=\topskip \splitmaxdepth=\maxdepth + {\vbadness=10000 + \loop \global\setbox5=\copy0 + \setbox1=\vsplit5 to\dimen@ + \setbox3=\vsplit5 to\dimen@ + \ifvbox5 \global\advance\dimen@ by1pt \repeat + \setbox0=\vbox to\dimen@{\unvbox1} + \setbox2=\vbox to\dimen@{\unvbox3} + \global\setbox\partialpage=\vbox{\pagesofar} + \doublecolumnpagegoal + } + \fi + \fi +} + +\catcode `\@=\other +\message{sectioning,} +% Define chapters, sections, etc. + +\newcount \chapno +\newcount \secno \secno=0 +\newcount \subsecno \subsecno=0 +\newcount \subsubsecno \subsubsecno=0 + +% This counter is funny since it counts through charcodes of letters A, B, ... +\newcount \appendixno \appendixno = `\@ +\def\appendixletter{\char\the\appendixno} + +\newwrite \contentsfile +% This is called from \setfilename. +\def\opencontents{\openout \contentsfile = \jobname.toc} + +% Each @chapter defines this as the name of the chapter. +% page headings and footings can use it. @section does likewise + +\def\thischapter{} \def\thissection{} +\def\seccheck#1{\if \pageno<0 % +\errmessage{@#1 not allowed after generating table of contents}\fi +% +} + +\def\chapternofonts{% +\let\rawbackslash=\relax% +\let\frenchspacing=\relax% +\def\result{\realbackslash result} +\def\equiv{\realbackslash equiv} +\def\expansion{\realbackslash expansion} +\def\print{\realbackslash print} +\def\TeX{\realbackslash TeX} +\def\dots{\realbackslash dots} +\def\copyright{\realbackslash copyright} +\def\tt{\realbackslash tt} +\def\bf{\realbackslash bf } +\def\w{\realbackslash w} +\def\less{\realbackslash less} +\def\gtr{\realbackslash gtr} +\def\hat{\realbackslash hat} +\def\char{\realbackslash char} +\def\tclose##1{\realbackslash tclose {##1}} +\def\code##1{\realbackslash code {##1}} +\def\samp##1{\realbackslash samp {##1}} +\def\r##1{\realbackslash r {##1}} +\def\b##1{\realbackslash b {##1}} +\def\key##1{\realbackslash key {##1}} +\def\file##1{\realbackslash file {##1}} +\def\kbd##1{\realbackslash kbd {##1}} +% These are redefined because @smartitalic wouldn't work inside xdef. +\def\i##1{\realbackslash i {##1}} +\def\cite##1{\realbackslash cite {##1}} +\def\var##1{\realbackslash var {##1}} +\def\emph##1{\realbackslash emph {##1}} +\def\dfn##1{\realbackslash dfn {##1}} +} + +\newcount\absseclevel % used to calculate proper heading level +\newcount\secbase\secbase=0 % @raise/lowersections modify this count + +% @raisesections: treat @section as chapter, @subsection as section, etc. +\def\raisesections{\global\advance\secbase by -1} +\let\up=\raisesections % original BFox name + +% @lowersections: treat @chapter as section, @section as subsection, etc. +\def\lowersections{\global\advance\secbase by 1} +\let\down=\lowersections % original BFox name + +% Choose a numbered-heading macro +% #1 is heading level if unmodified by @raisesections or @lowersections +% #2 is text for heading +\def\numhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 +\ifcase\absseclevel + \chapterzzz{#2} +\or + \seczzz{#2} +\or + \numberedsubseczzz{#2} +\or + \numberedsubsubseczzz{#2} +\else + \ifnum \absseclevel<0 + \chapterzzz{#2} + \else + \numberedsubsubseczzz{#2} + \fi +\fi +} + +% like \numhead, but chooses appendix heading levels +\def\apphead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 +\ifcase\absseclevel + \appendixzzz{#2} +\or + \appendixsectionzzz{#2} +\or + \appendixsubseczzz{#2} +\or + \appendixsubsubseczzz{#2} +\else + \ifnum \absseclevel<0 + \appendixzzz{#2} + \else + \appendixsubsubseczzz{#2} + \fi +\fi +} + +% like \numhead, but chooses numberless heading levels +\def\unnmhead#1#2{\absseclevel=\secbase\advance\absseclevel by #1 +\ifcase\absseclevel + \unnumberedzzz{#2} +\or + \unnumberedseczzz{#2} +\or + \unnumberedsubseczzz{#2} +\or + \unnumberedsubsubseczzz{#2} +\else + \ifnum \absseclevel<0 + \unnumberedzzz{#2} + \else + \unnumberedsubsubseczzz{#2} + \fi +\fi +} + + +\def\thischaptername{No Chapter Title} +\outer\def\chapter{\parsearg\chapteryyy} +\def\chapteryyy #1{\numhead0{#1}} % normally numhead0 calls chapterzzz +\def\chapterzzz #1{\seccheck{chapter}% +\secno=0 \subsecno=0 \subsubsecno=0 +\global\advance \chapno by 1 \message{Chapter \the\chapno}% +\chapmacro {#1}{\the\chapno}% +\gdef\thissection{#1}% +\gdef\thischaptername{#1}% +% We don't substitute the actual chapter name into \thischapter +% because we don't want its macros evaluated now. +\xdef\thischapter{\putwordChapter{} \the\chapno: \noexpand\thischaptername}% +{\chapternofonts% +\edef\temp{{\realbackslash chapentry {#1}{\the\chapno}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\donoderef % +\global\let\section = \numberedsec +\global\let\subsection = \numberedsubsec +\global\let\subsubsection = \numberedsubsubsec +}} + +\outer\def\appendix{\parsearg\appendixyyy} +\def\appendixyyy #1{\apphead0{#1}} % normally apphead0 calls appendixzzz +\def\appendixzzz #1{\seccheck{appendix}% +\secno=0 \subsecno=0 \subsubsecno=0 +\global\advance \appendixno by 1 \message{Appendix \appendixletter}% +\chapmacro {#1}{\putwordAppendix{} \appendixletter}% +\gdef\thissection{#1}% +\gdef\thischaptername{#1}% +\xdef\thischapter{\putwordAppendix{} \appendixletter: \noexpand\thischaptername}% +{\chapternofonts% +\edef\temp{{\realbackslash chapentry + {#1}{\putwordAppendix{} \appendixletter}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\appendixnoderef % +\global\let\section = \appendixsec +\global\let\subsection = \appendixsubsec +\global\let\subsubsection = \appendixsubsubsec +}} + +\outer\def\top{\parsearg\unnumberedyyy} +\outer\def\unnumbered{\parsearg\unnumberedyyy} +\def\unnumberedyyy #1{\unnmhead0{#1}} % normally unnmhead0 calls unnumberedzzz +\def\unnumberedzzz #1{\seccheck{unnumbered}% +\secno=0 \subsecno=0 \subsubsecno=0 +% +% This used to be simply \message{#1}, but TeX fully expands the +% argument to \message. Therefore, if #1 contained @-commands, TeX +% expanded them. For example, in `@unnumbered The @cite{Book}', TeX +% expanded @cite (which turns out to cause errors because \cite is meant +% to be executed, not expanded). +% +% Anyway, we don't want the fully-expanded definition of @cite to appear +% as a result of the \message, we just want `@cite' itself. We use +% \the<toks register> to achieve this: TeX expands \the<toks> only once, +% simply yielding the contents of the <toks register>. +\toks0 = {#1}\message{(\the\toks0)}% +% +\unnumbchapmacro {#1}% +\gdef\thischapter{#1}\gdef\thissection{#1}% +{\chapternofonts% +\edef\temp{{\realbackslash unnumbchapentry {#1}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\unnumbnoderef % +\global\let\section = \unnumberedsec +\global\let\subsection = \unnumberedsubsec +\global\let\subsubsection = \unnumberedsubsubsec +}} + +\outer\def\numberedsec{\parsearg\secyyy} +\def\secyyy #1{\numhead1{#1}} % normally calls seczzz +\def\seczzz #1{\seccheck{section}% +\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % +\gdef\thissection{#1}\secheading {#1}{\the\chapno}{\the\secno}% +{\chapternofonts% +\edef\temp{{\realbackslash secentry % +{#1}{\the\chapno}{\the\secno}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\donoderef % +\penalty 10000 % +}} + +\outer\def\appenixsection{\parsearg\appendixsecyyy} +\outer\def\appendixsec{\parsearg\appendixsecyyy} +\def\appendixsecyyy #1{\apphead1{#1}} % normally calls appendixsectionzzz +\def\appendixsectionzzz #1{\seccheck{appendixsection}% +\subsecno=0 \subsubsecno=0 \global\advance \secno by 1 % +\gdef\thissection{#1}\secheading {#1}{\appendixletter}{\the\secno}% +{\chapternofonts% +\edef\temp{{\realbackslash secentry % +{#1}{\appendixletter}{\the\secno}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\appendixnoderef % +\penalty 10000 % +}} + +\outer\def\unnumberedsec{\parsearg\unnumberedsecyyy} +\def\unnumberedsecyyy #1{\unnmhead1{#1}} % normally calls unnumberedseczzz +\def\unnumberedseczzz #1{\seccheck{unnumberedsec}% +\plainsecheading {#1}\gdef\thissection{#1}% +{\chapternofonts% +\edef\temp{{\realbackslash unnumbsecentry{#1}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\unnumbnoderef % +\penalty 10000 % +}} + +\outer\def\numberedsubsec{\parsearg\numberedsubsecyyy} +\def\numberedsubsecyyy #1{\numhead2{#1}} % normally calls numberedsubseczzz +\def\numberedsubseczzz #1{\seccheck{subsection}% +\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % +\subsecheading {#1}{\the\chapno}{\the\secno}{\the\subsecno}% +{\chapternofonts% +\edef\temp{{\realbackslash subsecentry % +{#1}{\the\chapno}{\the\secno}{\the\subsecno}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\donoderef % +\penalty 10000 % +}} + +\outer\def\appendixsubsec{\parsearg\appendixsubsecyyy} +\def\appendixsubsecyyy #1{\apphead2{#1}} % normally calls appendixsubseczzz +\def\appendixsubseczzz #1{\seccheck{appendixsubsec}% +\gdef\thissection{#1}\subsubsecno=0 \global\advance \subsecno by 1 % +\subsecheading {#1}{\appendixletter}{\the\secno}{\the\subsecno}% +{\chapternofonts% +\edef\temp{{\realbackslash subsecentry % +{#1}{\appendixletter}{\the\secno}{\the\subsecno}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\appendixnoderef % +\penalty 10000 % +}} + +\outer\def\unnumberedsubsec{\parsearg\unnumberedsubsecyyy} +\def\unnumberedsubsecyyy #1{\unnmhead2{#1}} %normally calls unnumberedsubseczzz +\def\unnumberedsubseczzz #1{\seccheck{unnumberedsubsec}% +\plainsecheading {#1}\gdef\thissection{#1}% +{\chapternofonts% +\edef\temp{{\realbackslash unnumbsubsecentry{#1}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\unnumbnoderef % +\penalty 10000 % +}} + +\outer\def\numberedsubsubsec{\parsearg\numberedsubsubsecyyy} +\def\numberedsubsubsecyyy #1{\numhead3{#1}} % normally numberedsubsubseczzz +\def\numberedsubsubseczzz #1{\seccheck{subsubsection}% +\gdef\thissection{#1}\global\advance \subsubsecno by 1 % +\subsubsecheading {#1} + {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno}% +{\chapternofonts% +\edef\temp{{\realbackslash subsubsecentry % + {#1} + {\the\chapno}{\the\secno}{\the\subsecno}{\the\subsubsecno} + {\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\donoderef % +\penalty 10000 % +}} + +\outer\def\appendixsubsubsec{\parsearg\appendixsubsubsecyyy} +\def\appendixsubsubsecyyy #1{\apphead3{#1}} % normally appendixsubsubseczzz +\def\appendixsubsubseczzz #1{\seccheck{appendixsubsubsec}% +\gdef\thissection{#1}\global\advance \subsubsecno by 1 % +\subsubsecheading {#1} + {\appendixletter}{\the\secno}{\the\subsecno}{\the\subsubsecno}% +{\chapternofonts% +\edef\temp{{\realbackslash subsubsecentry{#1}% + {\appendixletter} + {\the\secno}{\the\subsecno}{\the\subsubsecno}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\appendixnoderef % +\penalty 10000 % +}} + +\outer\def\unnumberedsubsubsec{\parsearg\unnumberedsubsubsecyyy} +\def\unnumberedsubsubsecyyy #1{\unnmhead3{#1}} %normally unnumberedsubsubseczzz +\def\unnumberedsubsubseczzz #1{\seccheck{unnumberedsubsubsec}% +\plainsecheading {#1}\gdef\thissection{#1}% +{\chapternofonts% +\edef\temp{{\realbackslash unnumbsubsubsecentry{#1}{\noexpand\folio}}}% +\escapechar=`\\% +\write \contentsfile \temp % +\unnumbnoderef % +\penalty 10000 % +}} + +% These are variants which are not "outer", so they can appear in @ifinfo. +% Actually, they should now be obsolete; ordinary section commands should work. +\def\infotop{\parsearg\unnumberedzzz} +\def\infounnumbered{\parsearg\unnumberedzzz} +\def\infounnumberedsec{\parsearg\unnumberedseczzz} +\def\infounnumberedsubsec{\parsearg\unnumberedsubseczzz} +\def\infounnumberedsubsubsec{\parsearg\unnumberedsubsubseczzz} + +\def\infoappendix{\parsearg\appendixzzz} +\def\infoappendixsec{\parsearg\appendixseczzz} +\def\infoappendixsubsec{\parsearg\appendixsubseczzz} +\def\infoappendixsubsubsec{\parsearg\appendixsubsubseczzz} + +\def\infochapter{\parsearg\chapterzzz} +\def\infosection{\parsearg\sectionzzz} +\def\infosubsection{\parsearg\subsectionzzz} +\def\infosubsubsection{\parsearg\subsubsectionzzz} + +% These macros control what the section commands do, according +% to what kind of chapter we are in (ordinary, appendix, or unnumbered). +% Define them by default for a numbered chapter. +\global\let\section = \numberedsec +\global\let\subsection = \numberedsubsec +\global\let\subsubsection = \numberedsubsubsec + +% Define @majorheading, @heading and @subheading + +% NOTE on use of \vbox for chapter headings, section headings, and +% such: +% 1) We use \vbox rather than the earlier \line to permit +% overlong headings to fold. +% 2) \hyphenpenalty is set to 10000 because hyphenation in a +% heading is obnoxious; this forbids it. +% 3) Likewise, headings look best if no \parindent is used, and +% if justification is not attempted. Hence \raggedright. + + +\def\majorheading{\parsearg\majorheadingzzz} +\def\majorheadingzzz #1{% +{\advance\chapheadingskip by 10pt \chapbreak }% +{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}\bigskip \par\penalty 200} + +\def\chapheading{\parsearg\chapheadingzzz} +\def\chapheadingzzz #1{\chapbreak % +{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}\bigskip \par\penalty 200} + +\def\heading{\parsearg\secheadingi} + +\def\subheading{\parsearg\subsecheadingi} + +\def\subsubheading{\parsearg\subsubsecheadingi} + +% These macros generate a chapter, section, etc. heading only +% (including whitespace, linebreaking, etc. around it), +% given all the information in convenient, parsed form. + +%%% Args are the skip and penalty (usually negative) +\def\dobreak#1#2{\par\ifdim\lastskip<#1\removelastskip\penalty#2\vskip#1\fi} + +\def\setchapterstyle #1 {\csname CHAPF#1\endcsname} + +%%% Define plain chapter starts, and page on/off switching for it +% Parameter controlling skip before chapter headings (if needed) + +\newskip \chapheadingskip \chapheadingskip = 30pt plus 8pt minus 4pt + +\def\chapbreak{\dobreak \chapheadingskip {-4000}} +\def\chappager{\par\vfill\supereject} +\def\chapoddpage{\chappager \ifodd\pageno \else \hbox to 0pt{} \chappager\fi} + +\def\setchapternewpage #1 {\csname CHAPPAG#1\endcsname} + +\def\CHAPPAGoff{ +\global\let\pchapsepmacro=\chapbreak +\global\let\pagealignmacro=\chappager} + +\def\CHAPPAGon{ +\global\let\pchapsepmacro=\chappager +\global\let\pagealignmacro=\chappager +\global\def\HEADINGSon{\HEADINGSsingle}} + +\def\CHAPPAGodd{ +\global\let\pchapsepmacro=\chapoddpage +\global\let\pagealignmacro=\chapoddpage +\global\def\HEADINGSon{\HEADINGSdouble}} + +\CHAPPAGon + +\def\CHAPFplain{ +\global\let\chapmacro=\chfplain +\global\let\unnumbchapmacro=\unnchfplain} + +\def\chfplain #1#2{% + \pchapsepmacro + {% + \chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #2\enspace #1}% + }% + \bigskip + \penalty5000 +} + +\def\unnchfplain #1{% +\pchapsepmacro % +{\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}\bigskip \par\penalty 10000 % +} +\CHAPFplain % The default + +\def\unnchfopen #1{% +\chapoddpage {\chapfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}\bigskip \par\penalty 10000 % +} + +\def\chfopen #1#2{\chapoddpage {\chapfonts +\vbox to 3in{\vfil \hbox to\hsize{\hfil #2} \hbox to\hsize{\hfil #1} \vfil}}% +\par\penalty 5000 % +} + +\def\CHAPFopen{ +\global\let\chapmacro=\chfopen +\global\let\unnumbchapmacro=\unnchfopen} + +% Parameter controlling skip before section headings. + +\newskip \subsecheadingskip \subsecheadingskip = 17pt plus 8pt minus 4pt +\def\subsecheadingbreak{\dobreak \subsecheadingskip {-500}} + +\newskip \secheadingskip \secheadingskip = 21pt plus 8pt minus 4pt +\def\secheadingbreak{\dobreak \secheadingskip {-1000}} + +% @paragraphindent is defined for the Info formatting commands only. +\let\paragraphindent=\comment + +% Section fonts are the base font at magstep2, which produces +% a size a bit more than 14 points in the default situation. + +\def\secheading #1#2#3{\secheadingi {#2.#3\enspace #1}} +\def\plainsecheading #1{\secheadingi {#1}} +\def\secheadingi #1{{\advance \secheadingskip by \parskip % +\secheadingbreak}% +{\secfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}% +\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 } + + +% Subsection fonts are the base font at magstep1, +% which produces a size of 12 points. + +\def\subsecheading #1#2#3#4{\subsecheadingi {#2.#3.#4\enspace #1}} +\def\subsecheadingi #1{{\advance \subsecheadingskip by \parskip % +\subsecheadingbreak}% +{\subsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}% +\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000 } + +\def\subsubsecfonts{\subsecfonts} % Maybe this should change: + % Perhaps make sssec fonts scaled + % magstep half +\def\subsubsecheading #1#2#3#4#5{\subsubsecheadingi {#2.#3.#4.#5\enspace #1}} +\def\subsubsecheadingi #1{{\advance \subsecheadingskip by \parskip % +\subsecheadingbreak}% +{\subsubsecfonts \vbox{\hyphenpenalty=10000\tolerance=5000 + \parindent=0pt\raggedright + \rm #1\hfill}}% +\ifdim \parskip<10pt \kern 10pt\kern -\parskip\fi \penalty 10000} + + +\message{toc printing,} + +% Finish up the main text and prepare to read what we've written +% to \contentsfile. + +\newskip\contentsrightmargin \contentsrightmargin=1in +\def\startcontents#1{% + \pagealignmacro + \immediate\closeout \contentsfile + \ifnum \pageno>0 + \pageno = -1 % Request roman numbered pages. + \fi + % Don't need to put `Contents' or `Short Contents' in the headline. + % It is abundantly clear what they are. + \unnumbchapmacro{#1}\def\thischapter{}% + \begingroup % Set up to handle contents files properly. + \catcode`\\=0 \catcode`\{=1 \catcode`\}=2 \catcode`\@=11 + \raggedbottom % Worry more about breakpoints than the bottom. + \advance\hsize by -\contentsrightmargin % Don't use the full line length. +} + + +% Normal (long) toc. +\outer\def\contents{% + \startcontents{\putwordTableofContents}% + \input \jobname.toc + \endgroup + \vfill \eject +} + +% And just the chapters. +\outer\def\summarycontents{% + \startcontents{\putwordShortContents}% + % + \let\chapentry = \shortchapentry + \let\unnumbchapentry = \shortunnumberedentry + % We want a true roman here for the page numbers. + \secfonts + \let\rm=\shortcontrm \let\bf=\shortcontbf \let\sl=\shortcontsl + \rm + \advance\baselineskip by 1pt % Open it up a little. + \def\secentry ##1##2##3##4{} + \def\unnumbsecentry ##1##2{} + \def\subsecentry ##1##2##3##4##5{} + \def\unnumbsubsecentry ##1##2{} + \def\subsubsecentry ##1##2##3##4##5##6{} + \def\unnumbsubsubsecentry ##1##2{} + \input \jobname.toc + \endgroup + \vfill \eject +} +\let\shortcontents = \summarycontents + +% These macros generate individual entries in the table of contents. +% The first argument is the chapter or section name. +% The last argument is the page number. +% The arguments in between are the chapter number, section number, ... + +% Chapter-level things, for both the long and short contents. +\def\chapentry#1#2#3{\dochapentry{#2\labelspace#1}{#3}} + +% See comments in \dochapentry re vbox and related settings +\def\shortchapentry#1#2#3{% + \tocentry{\shortchaplabel{#2}\labelspace #1}{\doshortpageno{#3}}% +} + +% Typeset the label for a chapter or appendix for the short contents. +% The arg is, e.g. `Appendix A' for an appendix, or `3' for a chapter. +% We could simplify the code here by writing out an \appendixentry +% command in the toc file for appendices, instead of using \chapentry +% for both, but it doesn't seem worth it. +\setbox0 = \hbox{\shortcontrm \putwordAppendix } +\newdimen\shortappendixwidth \shortappendixwidth = \wd0 + +\def\shortchaplabel#1{% + % We typeset #1 in a box of constant width, regardless of the text of + % #1, so the chapter titles will come out aligned. + \setbox0 = \hbox{#1}% + \dimen0 = \ifdim\wd0 > \shortappendixwidth \shortappendixwidth \else 0pt \fi + % + % This space should be plenty, since a single number is .5em, and the + % widest letter (M) is 1em, at least in the Computer Modern fonts. + % (This space doesn't include the extra space that gets added after + % the label; that gets put in in \shortchapentry above.) + \advance\dimen0 by 1.1em + \hbox to \dimen0{#1\hfil}% +} + +\def\unnumbchapentry#1#2{\dochapentry{#1}{#2}} +\def\shortunnumberedentry#1#2{\tocentry{#1}{\doshortpageno{#2}}} + +% Sections. +\def\secentry#1#2#3#4{\dosecentry{#2.#3\labelspace#1}{#4}} +\def\unnumbsecentry#1#2{\dosecentry{#1}{#2}} + +% Subsections. +\def\subsecentry#1#2#3#4#5{\dosubsecentry{#2.#3.#4\labelspace#1}{#5}} +\def\unnumbsubsecentry#1#2{\dosubsecentry{#1}{#2}} + +% And subsubsections. +\def\subsubsecentry#1#2#3#4#5#6{% + \dosubsubsecentry{#2.#3.#4.#5\labelspace#1}{#6}} +\def\unnumbsubsubsecentry#1#2{\dosubsubsecentry{#1}{#2}} + + +% This parameter controls the indentation of the various levels. +\newdimen\tocindent \tocindent = 3pc + +% Now for the actual typesetting. In all these, #1 is the text and #2 is the +% page number. +% +% If the toc has to be broken over pages, we would want to be at chapters +% if at all possible; hence the \penalty. +\def\dochapentry#1#2{% + \penalty-300 \vskip\baselineskip + \begingroup + \chapentryfonts + \tocentry{#1}{\dopageno{#2}}% + \endgroup + \nobreak\vskip .25\baselineskip +} + +\def\dosecentry#1#2{\begingroup + \secentryfonts \leftskip=\tocindent + \tocentry{#1}{\dopageno{#2}}% +\endgroup} + +\def\dosubsecentry#1#2{\begingroup + \subsecentryfonts \leftskip=2\tocindent + \tocentry{#1}{\dopageno{#2}}% +\endgroup} + +\def\dosubsubsecentry#1#2{\begingroup + \subsubsecentryfonts \leftskip=3\tocindent + \tocentry{#1}{\dopageno{#2}}% +\endgroup} + +% Final typesetting of a toc entry; we use the same \entry macro as for +% the index entries, but we want to suppress hyphenation here. (We +% can't do that in the \entry macro, since index entries might consist +% of hyphenated-identifiers-that-do-not-fit-on-a-line-and-nothing-else.) +% +\def\tocentry#1#2{\begingroup + \hyphenpenalty = 10000 + \entry{#1}{#2}% +\endgroup} + +% Space between chapter (or whatever) number and the title. +\def\labelspace{\hskip1em \relax} + +\def\dopageno#1{{\rm #1}} +\def\doshortpageno#1{{\rm #1}} + +\def\chapentryfonts{\secfonts \rm} +\def\secentryfonts{\textfonts} +\let\subsecentryfonts = \textfonts +\let\subsubsecentryfonts = \textfonts + + +\message{environments,} + +% Since these characters are used in examples, it should be an even number of +% \tt widths. Each \tt character is 1en, so two makes it 1em. +% Furthermore, these definitions must come after we define our fonts. +\newbox\dblarrowbox \newbox\longdblarrowbox +\newbox\pushcharbox \newbox\bullbox +\newbox\equivbox \newbox\errorbox + +\let\ptexequiv = \equiv + +%{\tentt +%\global\setbox\dblarrowbox = \hbox to 1em{\hfil$\Rightarrow$\hfil} +%\global\setbox\longdblarrowbox = \hbox to 1em{\hfil$\mapsto$\hfil} +%\global\setbox\pushcharbox = \hbox to 1em{\hfil$\dashv$\hfil} +%\global\setbox\equivbox = \hbox to 1em{\hfil$\ptexequiv$\hfil} +% Adapted from the manmac format (p.420 of TeXbook) +%\global\setbox\bullbox = \hbox to 1em{\kern.15em\vrule height .75ex width .85ex +% depth .1ex\hfil} +%} + +\def\point{$\star$} + +\def\result{\leavevmode\raise.15ex\hbox to 1em{\hfil$\Rightarrow$\hfil}} +\def\expansion{\leavevmode\raise.1ex\hbox to 1em{\hfil$\mapsto$\hfil}} +\def\print{\leavevmode\lower.1ex\hbox to 1em{\hfil$\dashv$\hfil}} + +\def\equiv{\leavevmode\lower.1ex\hbox to 1em{\hfil$\ptexequiv$\hfil}} + +% Adapted from the TeXbook's \boxit. +{\tentt \global\dimen0 = 3em}% Width of the box. +\dimen2 = .55pt % Thickness of rules +% The text. (`r' is open on the right, `e' somewhat less so on the left.) +\setbox0 = \hbox{\kern-.75pt \tensf error\kern-1.5pt} + +\global\setbox\errorbox=\hbox to \dimen0{\hfil + \hsize = \dimen0 \advance\hsize by -5.8pt % Space to left+right. + \advance\hsize by -2\dimen2 % Rules. + \vbox{ + \hrule height\dimen2 + \hbox{\vrule width\dimen2 \kern3pt % Space to left of text. + \vtop{\kern2.4pt \box0 \kern2.4pt}% Space above/below. + \kern3pt\vrule width\dimen2}% Space to right. + \hrule height\dimen2} + \hfil} + +% The @error{} command. +\def\error{\leavevmode\lower.7ex\copy\errorbox} + +% @tex ... @end tex escapes into raw Tex temporarily. +% One exception: @ is still an escape character, so that @end tex works. +% But \@ or @@ will get a plain tex @ character. + +\def\tex{\begingroup +\catcode `\\=0 \catcode `\{=1 \catcode `\}=2 +\catcode `\$=3 \catcode `\&=4 \catcode `\#=6 +\catcode `\^=7 \catcode `\_=8 \catcode `\~=13 \let~=\tie +\catcode `\%=14 +\catcode 43=12 +\catcode`\"=12 +\catcode`\==12 +\catcode`\|=12 +\catcode`\<=12 +\catcode`\>=12 +\escapechar=`\\ +% +\let\~=\ptextilde +\let\{=\ptexlbrace +\let\}=\ptexrbrace +\let\.=\ptexdot +\let\*=\ptexstar +\let\dots=\ptexdots +\def\@{@}% +\let\bullet=\ptexbullet +\let\b=\ptexb \let\c=\ptexc \let\i=\ptexi \let\t=\ptext \let\l=\ptexl +\let\L=\ptexL +% +\let\Etex=\endgroup} + +% Define @lisp ... @endlisp. +% @lisp does a \begingroup so it can rebind things, +% including the definition of @endlisp (which normally is erroneous). + +% Amount to narrow the margins by for @lisp. +\newskip\lispnarrowing \lispnarrowing=0.4in + +% This is the definition that ^^M gets inside @lisp, @example, and other +% such environments. \null is better than a space, since it doesn't +% have any width. +\def\lisppar{\null\endgraf} + +% Make each space character in the input produce a normal interword +% space in the output. Don't allow a line break at this space, as this +% is used only in environments like @example, where each line of input +% should produce a line of output anyway. +% +{\obeyspaces % +\gdef\sepspaces{\obeyspaces\let =\tie}} + +% Define \obeyedspace to be our active space, whatever it is. This is +% for use in \parsearg. +{\sepspaces% +\global\let\obeyedspace= } + +% This space is always present above and below environments. +\newskip\envskipamount \envskipamount = 0pt + +% Make spacing and below environment symmetrical. We use \parskip here +% to help in doing that, since in @example-like environments \parskip +% is reset to zero; thus the \afterenvbreak inserts no space -- but the +% start of the next paragraph will insert \parskip +% +\def\aboveenvbreak{{\advance\envskipamount by \parskip +\endgraf \ifdim\lastskip<\envskipamount +\removelastskip \penalty-50 \vskip\envskipamount \fi}} + +\let\afterenvbreak = \aboveenvbreak + +% \nonarrowing is a flag. If "set", @lisp etc don't narrow margins. +\let\nonarrowing=\relax + +%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% +% \cartouche: draw rectangle w/rounded corners around argument +\font\circle=lcircle10 +\newdimen\circthick +\newdimen\cartouter\newdimen\cartinner +\newskip\normbskip\newskip\normpskip\newskip\normlskip +\circthick=\fontdimen8\circle +% +\def\ctl{{\circle\char'013\hskip -6pt}}% 6pt from pl file: 1/2charwidth +\def\ctr{{\hskip 6pt\circle\char'010}} +\def\cbl{{\circle\char'012\hskip -6pt}} +\def\cbr{{\hskip 6pt\circle\char'011}} +\def\carttop{\hbox to \cartouter{\hskip\lskip + \ctl\leaders\hrule height\circthick\hfil\ctr + \hskip\rskip}} +\def\cartbot{\hbox to \cartouter{\hskip\lskip + \cbl\leaders\hrule height\circthick\hfil\cbr + \hskip\rskip}} +% +\newskip\lskip\newskip\rskip + +\long\def\cartouche{% +\begingroup + \lskip=\leftskip \rskip=\rightskip + \leftskip=0pt\rightskip=0pt %we want these *outside*. + \cartinner=\hsize \advance\cartinner by-\lskip + \advance\cartinner by-\rskip + \cartouter=\hsize + \advance\cartouter by 18pt % allow for 3pt kerns on either +% side, and for 6pt waste from +% each corner char + \normbskip=\baselineskip \normpskip=\parskip \normlskip=\lineskip + % Flag to tell @lisp, etc., not to narrow margin. + \let\nonarrowing=\comment + \vbox\bgroup + \baselineskip=0pt\parskip=0pt\lineskip=0pt + \carttop + \hbox\bgroup + \hskip\lskip + \vrule\kern3pt + \vbox\bgroup + \hsize=\cartinner + \kern3pt + \begingroup + \baselineskip=\normbskip + \lineskip=\normlskip + \parskip=\normpskip + \vskip -\parskip +\def\Ecartouche{% + \endgroup + \kern3pt + \egroup + \kern3pt\vrule + \hskip\rskip + \egroup + \cartbot + \egroup +\endgroup +}} + + +% This macro is called at the beginning of all the @example variants, +% inside a group. +\def\nonfillstart{% + \aboveenvbreak + \inENV % This group ends at the end of the body + \hfuzz = 12pt % Don't be fussy + \sepspaces % Make spaces be word-separators rather than space tokens. + \singlespace + \let\par = \lisppar % don't ignore blank lines + \obeylines % each line of input is a line of output + \parskip = 0pt + \parindent = 0pt + \emergencystretch = 0pt % don't try to avoid overfull boxes + % @cartouche defines \nonarrowing to inhibit narrowing + % at next level down. + \ifx\nonarrowing\relax + \advance \leftskip by \lispnarrowing + \exdentamount=\lispnarrowing + \let\exdent=\nofillexdent + \let\nonarrowing=\relax + \fi +} + +% To ending an @example-like environment, we first end the paragraph +% (via \afterenvbreak's vertical glue), and then the group. That way we +% keep the zero \parskip that the environments set -- \parskip glue +% will be inserted at the beginning of the next paragraph in the +% document, after the environment. +% +\def\nonfillfinish{\afterenvbreak\endgroup}% + +% This macro is +\def\lisp{\begingroup + \nonfillstart + \let\Elisp = \nonfillfinish + \tt + \rawbackslash % have \ input char produce \ char from current font + \gobble +} + +% Define the \E... control sequence only if we are inside the +% environment, so the error checking in \end will work. +% +% We must call \lisp last in the definition, since it reads the +% return following the @example (or whatever) command. +% +\def\example{\begingroup \def\Eexample{\nonfillfinish\endgroup}\lisp} +\def\smallexample{\begingroup \def\Esmallexample{\nonfillfinish\endgroup}\lisp} +\def\smalllisp{\begingroup \def\Esmalllisp{\nonfillfinish\endgroup}\lisp} + +% @smallexample and @smalllisp. This is not used unless the @smallbook +% command is given. Originally contributed by Pavel@xerox. +% +\def\smalllispx{\begingroup + \nonfillstart + \let\Esmalllisp = \nonfillfinish + \let\Esmallexample = \nonfillfinish + % + % Smaller interline space and fonts for small examples. + \setleading{10pt}% + \indexfonts \tt + \rawbackslash % make \ output the \ character from the current font (tt) + \gobble +} + +% This is @display; same as @lisp except use roman font. +% +\def\display{\begingroup + \nonfillstart + \let\Edisplay = \nonfillfinish + \gobble +} + +% This is @format; same as @display except don't narrow margins. +% +\def\format{\begingroup + \let\nonarrowing = t + \nonfillstart + \let\Eformat = \nonfillfinish + \gobble +} + +% @flushleft (same as @format) and @flushright. +% +\def\flushleft{\begingroup + \let\nonarrowing = t + \nonfillstart + \let\Eflushleft = \nonfillfinish + \gobble +} +\def\flushright{\begingroup + \let\nonarrowing = t + \nonfillstart + \let\Eflushright = \nonfillfinish + \advance\leftskip by 0pt plus 1fill + \gobble} + +% @quotation does normal linebreaking (hence we can't use \nonfillstart) +% and narrows the margins. +% +\def\quotation{% + \begingroup\inENV %This group ends at the end of the @quotation body + {\parskip=0pt \aboveenvbreak}% because \aboveenvbreak inserts \parskip + \singlespace + \parindent=0pt + % We have retained a nonzero parskip for the environment, since we're + % doing normal filling. So to avoid extra space below the environment... + \def\Equotation{\parskip = 0pt \nonfillfinish}% + % + % @cartouche defines \nonarrowing to inhibit narrowing at next level down. + \ifx\nonarrowing\relax + \advance\leftskip by \lispnarrowing + \advance\rightskip by \lispnarrowing + \exdentamount = \lispnarrowing + \let\nonarrowing = \relax + \fi +} + +\message{defuns,} +% Define formatter for defuns +% First, allow user to change definition object font (\df) internally +\def\setdeffont #1 {\csname DEF#1\endcsname} + +\newskip\defbodyindent \defbodyindent=.4in +\newskip\defargsindent \defargsindent=50pt +\newskip\deftypemargin \deftypemargin=12pt +\newskip\deflastargmargin \deflastargmargin=18pt + +\newcount\parencount +% define \functionparens, which makes ( and ) and & do special things. +% \functionparens affects the group it is contained in. +\def\activeparens{% +\catcode`\(=\active \catcode`\)=\active \catcode`\&=\active +\catcode`\[=\active \catcode`\]=\active} + +% Make control sequences which act like normal parenthesis chars. +\let\lparen = ( \let\rparen = ) + +{\activeparens % Now, smart parens don't turn on until &foo (see \amprm) + +% Be sure that we always have a definition for `(', etc. For example, +% if the fn name has parens in it, \boldbrax will not be in effect yet, +% so TeX would otherwise complain about undefined control sequence. +\global\let(=\lparen \global\let)=\rparen +\global\let[=\lbrack \global\let]=\rbrack + +\gdef\functionparens{\boldbrax\let&=\amprm\parencount=0 } +\gdef\boldbrax{\let(=\opnr\let)=\clnr\let[=\lbrb\let]=\rbrb} + +% Definitions of (, ) and & used in args for functions. +% This is the definition of ( outside of all parentheses. +\gdef\oprm#1 {{\rm\char`\(}#1 \bf \let(=\opnested % +\global\advance\parencount by 1 } +% +% This is the definition of ( when already inside a level of parens. +\gdef\opnested{\char`\(\global\advance\parencount by 1 } +% +\gdef\clrm{% Print a paren in roman if it is taking us back to depth of 0. +% also in that case restore the outer-level definition of (. +\ifnum \parencount=1 {\rm \char `\)}\sl \let(=\oprm \else \char `\) \fi +\global\advance \parencount by -1 } +% If we encounter &foo, then turn on ()-hacking afterwards +\gdef\amprm#1 {{\rm\}\let(=\oprm \let)=\clrm\ } +% +\gdef\normalparens{\boldbrax\let&=\ampnr} +} % End of definition inside \activeparens +%% These parens (in \boldbrax) actually are a little bolder than the +%% contained text. This is especially needed for [ and ] +\def\opnr{{\sf\char`\(}} \def\clnr{{\sf\char`\)}} \def\ampnr{\&} +\def\lbrb{{\bf\char`\[}} \def\rbrb{{\bf\char`\]}} + +% First, defname, which formats the header line itself. +% #1 should be the function name. +% #2 should be the type of definition, such as "Function". + +\def\defname #1#2{% +% Get the values of \leftskip and \rightskip as they were +% outside the @def... +\dimen2=\leftskip +\advance\dimen2 by -\defbodyindent +\dimen3=\rightskip +\advance\dimen3 by -\defbodyindent +\noindent % +\setbox0=\hbox{\hskip \deflastargmargin{\rm #2}\hskip \deftypemargin}% +\dimen0=\hsize \advance \dimen0 by -\wd0 % compute size for first line +\dimen1=\hsize \advance \dimen1 by -\defargsindent %size for continuations +\parshape 2 0in \dimen0 \defargsindent \dimen1 % +% Now output arg 2 ("Function" or some such) +% ending at \deftypemargin from the right margin, +% but stuck inside a box of width 0 so it does not interfere with linebreaking +{% Adjust \hsize to exclude the ambient margins, +% so that \rightline will obey them. +\advance \hsize by -\dimen2 \advance \hsize by -\dimen3 +\rlap{\rightline{{\rm #2}\hskip \deftypemargin}}}% +% Make all lines underfull and no complaints: +\tolerance=10000 \hbadness=10000 +\advance\leftskip by -\defbodyindent +\exdentamount=\defbodyindent +{\df #1}\enskip % Generate function name +} + +% Actually process the body of a definition +% #1 should be the terminating control sequence, such as \Edefun. +% #2 should be the "another name" control sequence, such as \defunx. +% #3 should be the control sequence that actually processes the header, +% such as \defunheader. + +\def\defparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2{\begingroup\obeylines\activeparens\spacesplit#3}% +\parindent=0in +\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup % +\catcode 61=\active % 61 is `=' +\obeylines\activeparens\spacesplit#3} + +\def\defmethparsebody #1#2#3#4 {\begingroup\inENV % +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2##1 {\begingroup\obeylines\activeparens\spacesplit{#3{##1}}}% +\parindent=0in +\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup\obeylines\activeparens\spacesplit{#3{#4}}} + +\def\defopparsebody #1#2#3#4#5 {\begingroup\inENV % +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2##1 ##2 {\def#4{##1}% +\begingroup\obeylines\activeparens\spacesplit{#3{##2}}}% +\parindent=0in +\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup\obeylines\activeparens\spacesplit{#3{#5}}} + +% These parsing functions are similar to the preceding ones +% except that they do not make parens into active characters. +% These are used for "variables" since they have no arguments. + +\def\defvarparsebody #1#2#3{\begingroup\inENV% Environment for definitionbody +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2{\begingroup\obeylines\spacesplit#3}% +\parindent=0in +\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup % +\catcode 61=\active % +\obeylines\spacesplit#3} + +% This is used for \def{tp,vr}parsebody. It could probably be used for +% some of the others, too, with some judicious conditionals. +% +\def\parsebodycommon#1#2#3{% + \begingroup\inENV % + \medbreak % + % Define the end token that this defining construct specifies + % so that it will exit this group. + \def#1{\endgraf\endgroup\medbreak}% + \def#2##1 {\begingroup\obeylines\spacesplit{#3{##1}}}% + \parindent=0in + \advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent + \exdentamount=\defbodyindent + \begingroup\obeylines +} + +\def\defvrparsebody#1#2#3#4 {% + \parsebodycommon{#1}{#2}{#3}% + \spacesplit{#3{#4}}% +} + +% This loses on `@deftp {Data Type} {struct termios}' -- it thinks the +% type is just `struct', because we lose the braces in `{struct +% termios}' when \spacesplit reads its undelimited argument. Sigh. +% \let\deftpparsebody=\defvrparsebody +% +% So, to get around this, we put \empty in with the type name. That +% way, TeX won't find exactly `{...}' as an undelimited argument, and +% won't strip off the braces. +% +\def\deftpparsebody #1#2#3#4 {% + \parsebodycommon{#1}{#2}{#3}% + \spacesplit{\parsetpheaderline{#3{#4}}}\empty +} + +% Fine, but then we have to eventually remove the \empty *and* the +% braces (if any). That's what this does, putting the result in \tptemp. +% +\def\removeemptybraces\empty#1\relax{\def\tptemp{#1}}% + +% After \spacesplit has done its work, this is called -- #1 is the final +% thing to call, #2 the type name (which starts with \empty), and #3 +% (which might be empty) the arguments. +% +\def\parsetpheaderline#1#2#3{% + \removeemptybraces#2\relax + #1{\tptemp}{#3}% +}% + +\def\defopvarparsebody #1#2#3#4#5 {\begingroup\inENV % +\medbreak % +% Define the end token that this defining construct specifies +% so that it will exit this group. +\def#1{\endgraf\endgroup\medbreak}% +\def#2##1 ##2 {\def#4{##1}% +\begingroup\obeylines\spacesplit{#3{##2}}}% +\parindent=0in +\advance\leftskip by \defbodyindent \advance \rightskip by \defbodyindent +\exdentamount=\defbodyindent +\begingroup\obeylines\spacesplit{#3{#5}}} + +% Split up #2 at the first space token. +% call #1 with two arguments: +% the first is all of #2 before the space token, +% the second is all of #2 after that space token. +% If #2 contains no space token, all of it is passed as the first arg +% and the second is passed as empty. + +{\obeylines +\gdef\spacesplit#1#2^^M{\endgroup\spacesplitfoo{#1}#2 \relax\spacesplitfoo}% +\long\gdef\spacesplitfoo#1#2 #3#4\spacesplitfoo{% +\ifx\relax #3% +#1{#2}{}\else #1{#2}{#3#4}\fi}} + +% So much for the things common to all kinds of definitions. + +% Define @defun. + +% First, define the processing that is wanted for arguments of \defun +% Use this to expand the args and terminate the paragraph they make up + +\def\defunargs #1{\functionparens \sl +% Expand, preventing hyphenation at `-' chars. +% Note that groups don't affect changes in \hyphenchar. +\hyphenchar\tensl=0 +#1% +\hyphenchar\tensl=45 +\ifnum\parencount=0 \else \errmessage{unbalanced parens in @def arguments}\fi% +\interlinepenalty=10000 +\advance\rightskip by 0pt plus 1fil +\endgraf\penalty 10000\vskip -\parskip\penalty 10000% +} + +\def\deftypefunargs #1{% +% Expand, preventing hyphenation at `-' chars. +% Note that groups don't affect changes in \hyphenchar. +\functionparens +\tclose{#1}% avoid \code because of side effects on active chars +\interlinepenalty=10000 +\advance\rightskip by 0pt plus 1fil +\endgraf\penalty 10000\vskip -\parskip\penalty 10000% +} + +% Do complete processing of one @defun or @defunx line already parsed. + +% @deffn Command forward-char nchars + +\def\deffn{\defmethparsebody\Edeffn\deffnx\deffnheader} + +\def\deffnheader #1#2#3{\doind {fn}{\code{#2}}% +\begingroup\defname {#2}{#1}\defunargs{#3}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @defun == @deffn Function + +\def\defun{\defparsebody\Edefun\defunx\defunheader} + +\def\defunheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index +\begingroup\defname {#1}{Function}% +\defunargs {#2}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @deftypefun int foobar (int @var{foo}, float @var{bar}) + +\def\deftypefun{\defparsebody\Edeftypefun\deftypefunx\deftypefunheader} + +% #1 is the data type. #2 is the name and args. +\def\deftypefunheader #1#2{\deftypefunheaderx{#1}#2 \relax} +% #1 is the data type, #2 the name, #3 the args. +\def\deftypefunheaderx #1#2 #3\relax{% +\doind {fn}{\code{#2}}% Make entry in function index +\begingroup\defname {\defheaderxcond#1\relax$$$#2}{Function}% +\deftypefunargs {#3}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @deftypefn {Library Function} int foobar (int @var{foo}, float @var{bar}) + +\def\deftypefn{\defmethparsebody\Edeftypefn\deftypefnx\deftypefnheader} + +% \defheaderxcond#1\relax$$$ +% puts #1 in @code, followed by a space, but does nothing if #1 is null. +\def\defheaderxcond#1#2$$${\ifx#1\relax\else\code{#1#2} \fi} + +% #1 is the classification. #2 is the data type. #3 is the name and args. +\def\deftypefnheader #1#2#3{\deftypefnheaderx{#1}{#2}#3 \relax} +% #1 is the classification, #2 the data type, #3 the name, #4 the args. +\def\deftypefnheaderx #1#2#3 #4\relax{% +\doind {fn}{\code{#3}}% Make entry in function index +\begingroup +\normalparens % notably, turn off `&' magic, which prevents +% at least some C++ text from working +\defname {\defheaderxcond#2\relax$$$#3}{#1}% +\deftypefunargs {#4}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @defmac == @deffn Macro + +\def\defmac{\defparsebody\Edefmac\defmacx\defmacheader} + +\def\defmacheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index +\begingroup\defname {#1}{Macro}% +\defunargs {#2}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% @defspec == @deffn Special Form + +\def\defspec{\defparsebody\Edefspec\defspecx\defspecheader} + +\def\defspecheader #1#2{\doind {fn}{\code{#1}}% Make entry in function index +\begingroup\defname {#1}{Special Form}% +\defunargs {#2}\endgroup % +\catcode 61=\other % Turn off change made in \defparsebody +} + +% This definition is run if you use @defunx +% anywhere other than immediately after a @defun or @defunx. + +\def\deffnx #1 {\errmessage{@deffnx in invalid context}} +\def\defunx #1 {\errmessage{@defunx in invalid context}} +\def\defmacx #1 {\errmessage{@defmacx in invalid context}} +\def\defspecx #1 {\errmessage{@defspecx in invalid context}} +\def\deftypefnx #1 {\errmessage{@deftypefnx in invalid context}} +\def\deftypeunx #1 {\errmessage{@deftypeunx in invalid context}} + +% @defmethod, and so on + +% @defop {Funny Method} foo-class frobnicate argument + +\def\defop #1 {\def\defoptype{#1}% +\defopparsebody\Edefop\defopx\defopheader\defoptype} + +\def\defopheader #1#2#3{% +\dosubind {fn}{\code{#2}}{on #1}% Make entry in function index +\begingroup\defname {#2}{\defoptype{} on #1}% +\defunargs {#3}\endgroup % +} + +% @defmethod == @defop Method + +\def\defmethod{\defmethparsebody\Edefmethod\defmethodx\defmethodheader} + +\def\defmethodheader #1#2#3{% +\dosubind {fn}{\code{#2}}{on #1}% entry in function index +\begingroup\defname {#2}{Method on #1}% +\defunargs {#3}\endgroup % +} + +% @defcv {Class Option} foo-class foo-flag + +\def\defcv #1 {\def\defcvtype{#1}% +\defopvarparsebody\Edefcv\defcvx\defcvarheader\defcvtype} + +\def\defcvarheader #1#2#3{% +\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index +\begingroup\defname {#2}{\defcvtype{} of #1}% +\defvarargs {#3}\endgroup % +} + +% @defivar == @defcv {Instance Variable} + +\def\defivar{\defvrparsebody\Edefivar\defivarx\defivarheader} + +\def\defivarheader #1#2#3{% +\dosubind {vr}{\code{#2}}{of #1}% Make entry in var index +\begingroup\defname {#2}{Instance Variable of #1}% +\defvarargs {#3}\endgroup % +} + +% These definitions are run if you use @defmethodx, etc., +% anywhere other than immediately after a @defmethod, etc. + +\def\defopx #1 {\errmessage{@defopx in invalid context}} +\def\defmethodx #1 {\errmessage{@defmethodx in invalid context}} +\def\defcvx #1 {\errmessage{@defcvx in invalid context}} +\def\defivarx #1 {\errmessage{@defivarx in invalid context}} + +% Now @defvar + +% First, define the processing that is wanted for arguments of @defvar. +% This is actually simple: just print them in roman. +% This must expand the args and terminate the paragraph they make up +\def\defvarargs #1{\normalparens #1% +\interlinepenalty=10000 +\endgraf\penalty 10000\vskip -\parskip\penalty 10000} + +% @defvr Counter foo-count + +\def\defvr{\defvrparsebody\Edefvr\defvrx\defvrheader} + +\def\defvrheader #1#2#3{\doind {vr}{\code{#2}}% +\begingroup\defname {#2}{#1}\defvarargs{#3}\endgroup} + +% @defvar == @defvr Variable + +\def\defvar{\defvarparsebody\Edefvar\defvarx\defvarheader} + +\def\defvarheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index +\begingroup\defname {#1}{Variable}% +\defvarargs {#2}\endgroup % +} + +% @defopt == @defvr {User Option} + +\def\defopt{\defvarparsebody\Edefopt\defoptx\defoptheader} + +\def\defoptheader #1#2{\doind {vr}{\code{#1}}% Make entry in var index +\begingroup\defname {#1}{User Option}% +\defvarargs {#2}\endgroup % +} + +% @deftypevar int foobar + +\def\deftypevar{\defvarparsebody\Edeftypevar\deftypevarx\deftypevarheader} + +% #1 is the data type. #2 is the name. +\def\deftypevarheader #1#2{% +\doind {vr}{\code{#2}}% Make entry in variables index +\begingroup\defname {\defheaderxcond#1\relax$$$#2}{Variable}% +\interlinepenalty=10000 +\endgraf\penalty 10000\vskip -\parskip\penalty 10000 +\endgroup} + +% @deftypevr {Global Flag} int enable + +\def\deftypevr{\defvrparsebody\Edeftypevr\deftypevrx\deftypevrheader} + +\def\deftypevrheader #1#2#3{\doind {vr}{\code{#3}}% +\begingroup\defname {\defheaderxcond#2\relax$$$#3}{#1} +\interlinepenalty=10000 +\endgraf\penalty 10000\vskip -\parskip\penalty 10000 +\endgroup} + +% This definition is run if you use @defvarx +% anywhere other than immediately after a @defvar or @defvarx. + +\def\defvrx #1 {\errmessage{@defvrx in invalid context}} +\def\defvarx #1 {\errmessage{@defvarx in invalid context}} +\def\defoptx #1 {\errmessage{@defoptx in invalid context}} +\def\deftypevarx #1 {\errmessage{@deftypevarx in invalid context}} +\def\deftypevrx #1 {\errmessage{@deftypevrx in invalid context}} + +% Now define @deftp +% Args are printed in bold, a slight difference from @defvar. + +\def\deftpargs #1{\bf \defvarargs{#1}} + +% @deftp Class window height width ... + +\def\deftp{\deftpparsebody\Edeftp\deftpx\deftpheader} + +\def\deftpheader #1#2#3{\doind {tp}{\code{#2}}% +\begingroup\defname {#2}{#1}\deftpargs{#3}\endgroup} + +% This definition is run if you use @deftpx, etc +% anywhere other than immediately after a @deftp, etc. + +\def\deftpx #1 {\errmessage{@deftpx in invalid context}} + +\message{cross reference,} +% Define cross-reference macros +\newwrite \auxfile + +\newif\ifhavexrefs % True if xref values are known. +\newif\ifwarnedxrefs % True if we warned once that they aren't known. + +% \setref{foo} defines a cross-reference point named foo. + +\def\setref#1{% +\dosetq{#1-title}{Ytitle}% +\dosetq{#1-pg}{Ypagenumber}% +\dosetq{#1-snt}{Ysectionnumberandtype}} + +\def\unnumbsetref#1{% +\dosetq{#1-title}{Ytitle}% +\dosetq{#1-pg}{Ypagenumber}% +\dosetq{#1-snt}{Ynothing}} + +\def\appendixsetref#1{% +\dosetq{#1-title}{Ytitle}% +\dosetq{#1-pg}{Ypagenumber}% +\dosetq{#1-snt}{Yappendixletterandtype}} + +% \xref, \pxref, and \ref generate cross-references to specified points. +% For \xrefX, #1 is the node name, #2 the name of the Info +% cross-reference, #3 the printed node name, #4 the name of the Info +% file, #5 the name of the printed manual. All but the node name can be +% omitted. +% +\def\pxref#1{\putwordsee{} \xrefX[#1,,,,,,,]} +\def\xref#1{\putwordSee{} \xrefX[#1,,,,,,,]} +\def\ref#1{\xrefX[#1,,,,,,,]} +\def\xrefX[#1,#2,#3,#4,#5,#6]{\begingroup + \def\printedmanual{\ignorespaces #5}% + \def\printednodename{\ignorespaces #3}% + \setbox1=\hbox{\printedmanual}% + \setbox0=\hbox{\printednodename}% + \ifdim \wd0 = 0pt + % No printed node name was explicitly given. + \ifx\SETxref-automatic-section-title\relax % + % Use the actual chapter/section title appear inside + % the square brackets. Use the real section title if we have it. + \ifdim \wd1>0pt% + % It is in another manual, so we don't have it. + \def\printednodename{\ignorespaces #1}% + \else + \ifhavexrefs + % We know the real title if we have the xref values. + \def\printednodename{\refx{#1-title}}% + \else + % Otherwise just copy the Info node name. + \def\printednodename{\ignorespaces #1}% + \fi% + \fi + \def\printednodename{#1-title}% + \else + % Use the node name inside the square brackets. + \def\printednodename{\ignorespaces #1}% + \fi + \fi + % + % If we use \unhbox0 and \unhbox1 to print the node names, TeX does not + % insert empty discretionaries after hyphens, which means that it will + % not find a line break at a hyphen in a node names. Since some manuals + % are best written with fairly long node names, containing hyphens, this + % is a loss. Therefore, we give the text of the node name again, so it + % is as if TeX is seeing it for the first time. + \ifdim \wd1 > 0pt + \putwordsection{} ``\printednodename'' in \cite{\printedmanual}% + \else + % _ (for example) has to be the character _ for the purposes of the + % control sequence corresponding to the node, but it has to expand + % into the usual \leavevmode...\vrule stuff for purposes of + % printing. So we \turnoffactive for the \refx-snt, back on for the + % printing, back off for the \refx-pg. + {\turnoffactive \refx{#1-snt}{}}% + \space [\printednodename],\space + \turnoffactive \putwordpage\tie\refx{#1-pg}{}% + \fi +\endgroup} + +% \dosetq is the interface for calls from other macros + +% Use \turnoffactive so that punctuation chars such as underscore +% work in node names. +\def\dosetq #1#2{{\let\folio=0 \turnoffactive% +\edef\next{\write\auxfile{\internalsetq {#1}{#2}}}% +\next}} + +% \internalsetq {foo}{page} expands into +% CHARACTERS 'xrdef {foo}{...expansion of \Ypage...} +% When the aux file is read, ' is the escape character + +\def\internalsetq #1#2{'xrdef {#1}{\csname #2\endcsname}} + +% Things to be expanded by \internalsetq + +\def\Ypagenumber{\folio} + +\def\Ytitle{\thissection} + +\def\Ynothing{} + +\def\Ysectionnumberandtype{% +\ifnum\secno=0 \putwordChapter\xreftie\the\chapno % +\else \ifnum \subsecno=0 \putwordSection\xreftie\the\chapno.\the\secno % +\else \ifnum \subsubsecno=0 % +\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno % +\else % +\putwordSection\xreftie\the\chapno.\the\secno.\the\subsecno.\the\subsubsecno % +\fi \fi \fi } + +\def\Yappendixletterandtype{% +\ifnum\secno=0 \putwordAppendix\xreftie'char\the\appendixno{}% +\else \ifnum \subsecno=0 \putwordSection\xreftie'char\the\appendixno.\the\secno % +\else \ifnum \subsubsecno=0 % +\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno % +\else % +\putwordSection\xreftie'char\the\appendixno.\the\secno.\the\subsecno.\the\subsubsecno % +\fi \fi \fi } + +\gdef\xreftie{'tie} + +% Use TeX 3.0's \inputlineno to get the line number, for better error +% messages, but if we're using an old version of TeX, don't do anything. +% +\ifx\inputlineno\thisisundefined + \let\linenumber = \empty % Non-3.0. +\else + \def\linenumber{\the\inputlineno:\space} +\fi + +% Define \refx{NAME}{SUFFIX} to reference a cross-reference string named NAME. +% If its value is nonempty, SUFFIX is output afterward. + +\def\refx#1#2{% + \expandafter\ifx\csname X#1\endcsname\relax + % If not defined, say something at least. + $\langle$un\-de\-fined$\rangle$% + \ifhavexrefs + \message{\linenumber Undefined cross reference `#1'.}% + \else + \ifwarnedxrefs\else + \global\warnedxrefstrue + \message{Cross reference values unknown; you must run TeX again.}% + \fi + \fi + \else + % It's defined, so just use it. + \csname X#1\endcsname + \fi + #2% Output the suffix in any case. +} + +% Read the last existing aux file, if any. No error if none exists. + +% This is the macro invoked by entries in the aux file. +\def\xrdef #1#2{ +{\catcode`\'=\other\expandafter \gdef \csname X#1\endcsname {#2}}} + +\def\readauxfile{% +\begingroup +\catcode `\^^@=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\^^C=\other +\catcode `\^^D=\other +\catcode `\^^E=\other +\catcode `\^^F=\other +\catcode `\^^G=\other +\catcode `\^^H=\other +\catcode `\=\other +\catcode `\^^L=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode `\=\other +\catcode 26=\other +\catcode `\^^[=\other +\catcode `\^^\=\other +\catcode `\^^]=\other +\catcode `\^^^=\other +\catcode `\^^_=\other +\catcode `\@=\other +\catcode `\^=\other +\catcode `\~=\other +\catcode `\[=\other +\catcode `\]=\other +\catcode`\"=\other +\catcode`\_=\other +\catcode`\|=\other +\catcode`\<=\other +\catcode`\>=\other +\catcode `\$=\other +\catcode `\#=\other +\catcode `\&=\other +% `\+ does not work, so use 43. +\catcode 43=\other +% Make the characters 128-255 be printing characters +{% + \count 1=128 + \def\loop{% + \catcode\count 1=\other + \advance\count 1 by 1 + \ifnum \count 1<256 \loop \fi + }% +}% +% the aux file uses ' as the escape. +% Turn off \ as an escape so we do not lose on +% entries which were dumped with control sequences in their names. +% For example, 'xrdef {$\leq $-fun}{page ...} made by @defun ^^ +% Reference to such entries still does not work the way one would wish, +% but at least they do not bomb out when the aux file is read in. +\catcode `\{=1 \catcode `\}=2 +\catcode `\%=\other +\catcode `\'=0 +\catcode `\\=\other +\openin 1 \jobname.aux +\ifeof 1 \else \closein 1 \input \jobname.aux \global\havexrefstrue +\global\warnedobstrue +\fi +% Open the new aux file. Tex will close it automatically at exit. +\openout \auxfile=\jobname.aux +\endgroup} + + +% Footnotes. + +\newcount \footnoteno + +% The trailing space in the following definition for supereject is +% vital for proper filling; pages come out unaligned when you do a +% pagealignmacro call if that space before the closing brace is +% removed. +\def\supereject{\par\penalty -20000\footnoteno =0 } + +% @footnotestyle is meaningful for info output only.. +\let\footnotestyle=\comment + +\let\ptexfootnote=\footnote + +{\catcode `\@=11 +% +% Auto-number footnotes. Otherwise like plain. +\gdef\footnote{% + \global\advance\footnoteno by \@ne + \edef\thisfootno{$^{\the\footnoteno}$}% + % + % In case the footnote comes at the end of a sentence, preserve the + % extra spacing after we do the footnote number. + \let\@sf\empty + \ifhmode\edef\@sf{\spacefactor\the\spacefactor}\/\fi + % + % Remove inadvertent blank space before typesetting the footnote number. + \unskip + \thisfootno\@sf + \footnotezzz +}% + +% Don't bother with the trickery in plain.tex to not require the +% footnote text as a parameter. Our footnotes don't need to be so general. +% +\long\gdef\footnotezzz#1{\insert\footins{% + % We want to typeset this text as a normal paragraph, even if the + % footnote reference occurs in (for example) a display environment. + % So reset some parameters. + \interlinepenalty\interfootnotelinepenalty + \splittopskip\ht\strutbox % top baseline for broken footnotes + \splitmaxdepth\dp\strutbox + \floatingpenalty\@MM + \leftskip\z@skip + \rightskip\z@skip + \spaceskip\z@skip + \xspaceskip\z@skip + \parindent\defaultparindent + % + % Hang the footnote text off the number. + \hang + \textindent{\thisfootno}% + % + % Don't crash into the line above the footnote text. Since this + % expands into a box, it must come within the paragraph, lest it + % provide a place where TeX can split the footnote. + \footstrut + #1\strut}% +} + +}%end \catcode `\@=11 + +% Set the baselineskip to #1, and the lineskip and strut size +% correspondingly. There is no deep meaning behind these magic numbers +% used as factors; they just match (closely enough) what Knuth defined. +% +\def\lineskipfactor{.08333} +\def\strutheightpercent{.70833} +\def\strutdepthpercent {.29167} +% +\def\setleading#1{% + \normalbaselineskip = #1\relax + \normallineskip = \lineskipfactor\normalbaselineskip + \normalbaselines + \setbox\strutbox =\hbox{% + \vrule width0pt height\strutheightpercent\baselineskip + depth \strutdepthpercent \baselineskip + }% +} + +% @| inserts a changebar to the left of the current line. It should +% surround any changed text. This approach does *not* work if the +% change spans more than two lines of output. To handle that, we would +% have adopt a much more difficult approach (putting marks into the main +% vertical list for the beginning and end of each change). +% +\def\|{% + % \vadjust can only be used in horizontal mode. + \leavevmode + % + % Append this vertical mode material after the current line in the output. + \vadjust{% + % We want to insert a rule with the height and depth of the current + % leading; that is exactly what \strutbox is supposed to record. + \vskip-\baselineskip + % + % \vadjust-items are inserted at the left edge of the type. So + % the \llap here moves out into the left-hand margin. + \llap{% + % + % For a thicker or thinner bar, change the `1pt'. + \vrule height\baselineskip width1pt + % + % This is the space between the bar and the text. + \hskip 12pt + }% + }% +} + +% For a final copy, take out the rectangles +% that mark overfull boxes (in case you have decided +% that the text looks ok even though it passes the margin). +% +\def\finalout{\overfullrule=0pt} + + +% End of control word definitions. + +\message{and turning on texinfo input format.} + +\def\openindices{% + \newindex{cp}% + \newcodeindex{fn}% + \newcodeindex{vr}% + \newcodeindex{tp}% + \newcodeindex{ky}% + \newcodeindex{pg}% +} + +% Set some numeric style parameters, for 8.5 x 11 format. + +%\hsize = 6.5in +\newdimen\defaultparindent \defaultparindent = 15pt +\parindent = \defaultparindent +\parskip 18pt plus 1pt +\setleading{15pt} +\advance\topskip by 1.2cm + +% Prevent underfull vbox error messages. +\vbadness=10000 + +% Following George Bush, just get rid of widows and orphans. +\widowpenalty=10000 +\clubpenalty=10000 + +% Use TeX 3.0's \emergencystretch to help line breaking, but if we're +% using an old version of TeX, don't do anything. We want the amount of +% stretch added to depend on the line length, hence the dependence on +% \hsize. This makes it come to about 9pt for the 8.5x11 format. +% +\ifx\emergencystretch\thisisundefined + % Allow us to assign to \emergencystretch anyway. + \def\emergencystretch{\dimen0}% +\else + \emergencystretch = \hsize + \divide\emergencystretch by 45 +\fi + +% Use @smallbook to reset parameters for 7x9.5 format (or else 7x9.25) +\def\smallbook{ + +% These values for secheadingskip and subsecheadingskip are +% experiments. RJC 7 Aug 1992 +\global\secheadingskip = 17pt plus 6pt minus 3pt +\global\subsecheadingskip = 14pt plus 6pt minus 3pt + +\global\lispnarrowing = 0.3in +\setleading{12pt} +\advance\topskip by -1cm +\global\parskip 3pt plus 1pt +\global\hsize = 5in +\global\vsize=7.5in +\global\tolerance=700 +\global\hfuzz=1pt +\global\contentsrightmargin=0pt +\global\deftypemargin=0pt +\global\defbodyindent=.5cm + +\global\pagewidth=\hsize +\global\pageheight=\vsize + +\global\let\smalllisp=\smalllispx +\global\let\smallexample=\smalllispx +\global\def\Esmallexample{\Esmalllisp} +} + +% Use @afourpaper to print on European A4 paper. +\def\afourpaper{ +\global\tolerance=700 +\global\hfuzz=1pt +\setleading{12pt} +\global\parskip 15pt plus 1pt + +\global\vsize= 53\baselineskip +\advance\vsize by \topskip +%\global\hsize= 5.85in % A4 wide 10pt +\global\hsize= 6.5in +\global\outerhsize=\hsize +\global\advance\outerhsize by 0.5in +\global\outervsize=\vsize +\global\advance\outervsize by 0.6in + +\global\pagewidth=\hsize +\global\pageheight=\vsize +} + +% Allow control of the text dimensions. Parameters in order: textheight; +% textwidth; \voffset; \hoffset (!); binding offset. All require a dimension; +% header is additional; added length extends the bottom of the page. + +\def\changepagesizes#1#2#3#4#5 +{\global\vsize= #1 + \advance\vsize by \topskip + \global\voffset= #3 + \global\hsize= #2 + \global\outerhsize=\hsize + \global\advance\outerhsize by 0.5in + \global\outervsize=\vsize + \global\advance\outervsize by 0.6in + \global\pagewidth=\hsize + \global\pageheight=\vsize + \global\normaloffset= #4 + \global\bindingoffset= #5} + +% This layout is compatible with Latex on A4 paper. + +\def\afourlatex{\changepagesizes{22cm}{15cm}{7mm}{4.6mm}{5mm}} + +% Define macros to output various characters with catcode for normal text. +\catcode`\"=\other +\catcode`\~=\other +\catcode`\^=\other +\catcode`\_=\other +\catcode`\|=\other +\catcode`\<=\other +\catcode`\>=\other +\catcode`\+=\other +\def\normaldoublequote{"} +\def\normaltilde{~} +\def\normalcaret{^} +\def\normalunderscore{_} +\def\normalverticalbar{|} +\def\normalless{<} +\def\normalgreater{>} +\def\normalplus{+} + +% This macro is used to make a character print one way in ttfont +% where it can probably just be output, and another way in other fonts, +% where something hairier probably needs to be done. +% +% #1 is what to print if we are indeed using \tt; #2 is what to print +% otherwise. Since all the Computer Modern typewriter fonts have zero +% interword stretch (and shrink), and it is reasonable to expect all +% typewriter fonts to have this, we can check that font parameter. +% +\def\ifusingtt#1#2{\ifdim \fontdimen3\the\font=0pt #1\else #2\fi} + +% Turn off all special characters except @ +% (and those which the user can use as if they were ordinary). +% Most of these we simply print from the \tt font, but for some, we can +% use math or other variants that look better in normal text. + +\catcode`\"=\active +\def\activedoublequote{{\tt \char '042}} +\let"=\activedoublequote +\catcode`\~=\active +\def~{{\tt \char '176}} +\chardef\hat=`\^ +\catcode`\^=\active +\def^{{\tt \hat}} + +\catcode`\_=\active +\def_{\ifusingtt\normalunderscore\_} +% Subroutine for the previous macro. +\def\_{\lvvmode \kern.06em \vbox{\hrule width.3em height.1ex}} + +% \lvvmode is equivalent in function to \leavevmode. +% Using \leavevmode runs into trouble when written out to +% an index file due to the expansion of \leavevmode into ``\unhbox +% \voidb@x'' ---which looks to TeX like ``\unhbox \voidb\x'' due to our +% magic tricks with @. +\def\lvvmode{\vbox to 0pt{}} + +\catcode`\|=\active +\def|{{\tt \char '174}} +\chardef \less=`\< +\catcode`\<=\active +\def<{{\tt \less}} +\chardef \gtr=`\> +\catcode`\>=\active +\def>{{\tt \gtr}} +\catcode`\+=\active +\def+{{\tt \char 43}} +%\catcode 27=\active +%\def^^[{$\diamondsuit$} + +% Set up an active definition for =, but don't enable it most of the time. +{\catcode`\==\active +\global\def={{\tt \char 61}}} + +\catcode`\@=0 + +% \rawbackslashxx output one backslash character in current font +\global\chardef\rawbackslashxx=`\\ +%{\catcode`\\=\other +%@gdef@rawbackslashxx{\}} + +% \rawbackslash redefines \ as input to do \rawbackslashxx. +{\catcode`\\=\active +@gdef@rawbackslash{@let\=@rawbackslashxx }} + +% \normalbackslash outputs one backslash in fixed width font. +\def\normalbackslash{{\tt\rawbackslashxx}} + +% Say @foo, not \foo, in error messages. +\escapechar=`\@ + +% \catcode 17=0 % Define control-q +\catcode`\\=\active + +% Used sometimes to turn off (effectively) the active characters +% even after parsing them. +@def@turnoffactive{@let"=@normaldoublequote +@let\=@realbackslash +@let~=@normaltilde +@let^=@normalcaret +@let_=@normalunderscore +@let|=@normalverticalbar +@let<=@normalless +@let>=@normalgreater +@let+=@normalplus} + +@def@normalturnoffactive{@let"=@normaldoublequote +@let\=@normalbackslash +@let~=@normaltilde +@let^=@normalcaret +@let_=@normalunderscore +@let|=@normalverticalbar +@let<=@normalless +@let>=@normalgreater +@let+=@normalplus} + +% If a .fmt file is being used, we don't want the `\input texinfo' to show up. +% That is what \eatinput is for; after that, the `\' should revert to printing +% a backslash. +% +@gdef@eatinput input texinfo{@fixbackslash} +@global@let\ = @eatinput + +% On the other hand, perhaps the file did not have a `\input texinfo'. Then +% the first `\{ in the file would cause an error. This macro tries to fix +% that, assuming it is called before the first `\' could plausibly occur. +% +@gdef@fixbackslash{@ifx\@eatinput @let\ = @normalbackslash @fi} + +%% These look ok in all fonts, so just make them not special. The @rm below +%% makes sure that the current font starts out as the newly loaded cmr10 +@catcode`@$=@other @catcode`@%=@other @catcode`@&=@other @catcode`@#=@other + +@textfonts +@rm + +@c Local variables: +@c page-delimiter: "^\\\\message" +@c End: diff --git a/util/et/ChangeLog b/util/et/ChangeLog new file mode 100644 index 0000000..2e7f1eb --- /dev/null +++ b/util/et/ChangeLog @@ -0,0 +1,69 @@ +Fri Nov 18 00:34:29 1994 Mark Eichin <eichin@cygnus.com> + + * configure.in: add caching to perror check (from epeisach). + +Fri Oct 21 21:06:48 1994 (tytso@rsx-11) + + * Makefile.in (SED): Don't specify an explicit pathname for sed. + +Tue Oct 11 12:43:00 1994 Theodore Y. Ts'o (tytso@dcl) + + * Makefile.in: Don't rm the awk and sed scripts during a make clean! + +Thu Oct 6 19:39:11 1994 Theodore Y. Ts'o (tytso@dcl) + + * compile_et.sh: Replace basename with sed -- more portable. + +Mon Oct 3 17:27:28 1994 Theodore Y. Ts'o (tytso@dcl) + + * Makefile.in: + configure.in: Don't try to compile compile_et. Use awk/sed + version instead. It's more apt to be portable, since it + doesn't use awk or sed. :-( + + +Fri Sep 30 17:12:15 1994 Theodore Y. Ts'o (tytso@dcl) + + * compile_et.c: Add declaration of error_message() manually. + + * internal.h: Use autoconf to determine whether or not to declare + perror(). + + * configure.in: + compiler.h: + internal.h: + compilet_et.c: + init_et.c: Let configure take care of removing const with AC_CONST. + +Thu Sep 8 22:33:07 1994 Theodore Y. Ts'o (tytso@pinata) + + * com_err.c (default_com_err_proc): Reversed order of \n\r to make + jik happy. + +Wed Jul 13 23:19:34 1994 Tom Yu (tlyu at dragons-lair) + + * Makefile.in: nuke the libcom_err.a.bak stuff + +Sun Jul 3 07:48:04 1994 Tom Yu (tlyu at dragons-lair) + + * Makefile.in: cleaning up to not spew ignored errors + +Wed Jun 22 18:47:36 1994 Mark Eichin (eichin@tweedledumber.cygnus.com) + + * com_err.h: Only set STDARG_PROTOTYPES based on STDC if it isn't + set already (clean up warnings.) + +Wed Jun 22 17:55:48 1994 Mark Eichin (eichin@cygnus.com) + + * Makefile.in (CP): set CP so CopySrcHeader actually works. + +Tue Jun 21 00:20:44 1994 Tom Yu (tlyu at dragons-lair) + + * Makefile.in: add "includes" to "all" dependencies + + * configure.in: should be CopySrcHeader + +Mon Jun 20 21:59:37 1994 Tom Yu (tlyu at dragons-lair) + + * configure.in: install com_err.h during build + diff --git a/util/reconf b/util/reconf new file mode 100755 index 0000000..f10f3ea --- /dev/null +++ b/util/reconf @@ -0,0 +1,18 @@ +#!/bin/sh + +force= + +usage="Usage: ./config.status [--recheck] [--version] [--help]" +for option +do + case "$option" in + --force | -f) + echo "Remaking all configuration files" + force=--force ;; + -help | --help | --hel | --he | --h) + echo "$usage"; exit 0 ;; + *) echo "$usage"; exit 1 ;; + esac +done + +./util/autoconf/autoreconf -m util/autoconf -l . --verbose $force |