]> git.ipfire.org Git - thirdparty/autoconf.git/commitdiff
support --program* options
authorDavid MacKenzie <djm@djmnet.org>
Wed, 7 Sep 1994 03:06:34 +0000 (03:06 +0000)
committerDavid MacKenzie <djm@djmnet.org>
Wed, 7 Sep 1994 03:06:34 +0000 (03:06 +0000)
NEWS
TODO
acgeneral.m4
acspecific.m4
autoconf.texi
doc/autoconf.texi
lib/autoconf/general.m4
lib/autoconf/specific.m4

diff --git a/NEWS b/NEWS
index 5197cd6de85c5b14aac7ee7603687cde8edc4cb4..f627f22794ad7d6e7a8f3be134f3a5b41fac0b8e 100644 (file)
--- a/NEWS
+++ b/NEWS
@@ -22,6 +22,9 @@ Major changes in release 2.0:
 * 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, which uses the options --program-prefix,
+  --program-suffix, and --program-transform-name to change the names
+  of programs being installed.
 * AC_CHECK_TYPE, which checks whether sys/types.h defines a given type.
 * AC_CHECK_LIB, which checks for a particular function in a library.
 * AC_MSG_CHECKING and AC_MSG_RESULT to print test results, on a single line,
@@ -42,6 +45,7 @@ Major changes in release 2.0:
 * 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, with default values.
+* AC_PROG_CC and AC_PROG_CXX now set CFLAGS and CXXFLAGS, respectively.
 * AC_PROG_INSTALL looks for 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.
@@ -57,7 +61,7 @@ Major changes in release 2.0:
   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.
+  take arguments, for consistency with all of the other specific checks.
 
 ** New utilities:
 * autoscan to generate a preliminary configure.in for a package by
diff --git a/TODO b/TODO
index 2dd91eaf38f19efabb9950e6d7d3d5624087c01e..8e76af1886663b06cbd1af8f7b4250bf8db72590 100644 (file)
--- a/TODO
+++ b/TODO
@@ -1,17 +1,20 @@
 -*- outline -*-
 
-Things it would be nice to maybe do someday:
+Things it might be nice to do someday:
 
 ------------------------------------------------------------------------------
 
 * Replace the current ad-hoc macros for Dynix, SCO, ISC, etc.
 Perhaps there should be macros for certain functions (statfs, wait) or
 classes of functions (POSIX, NIS) that do everything necessary, instead.
-Select the right CONFIG_SHELL automatically (Ultrix, Lynx esp.)
 Select the right C compiler and POSIX/ANSI C options automatically.
 
 ------------------------------------------------------------------------------
 
+* Select the right CONFIG_SHELL automatically (for Ultrix, Lynx especially.)
+
+------------------------------------------------------------------------------
+
 * Support copying and adding "dir" commands to .gdbinit.
 
 ------------------------------------------------------------------------------
index d047bb2f7c9f15ebfc99cc2800d26726142b6e48..430de8d39d9417b4bdae33b75b4de050372e7b82 100644 (file)
@@ -139,8 +139,7 @@ AC_DEFUN(AC_INIT_PARSE_ARGS,
 [# Save the original args to write them into config.status later.
 configure_args="[$]@"
 
-# Omit some internal, obsolete, or unimplemented options to make the
-# list less imposing.
+# Omit some internal or obsolete options to make the list less imposing.
 changequote(, )dnl
 ac_usage="Usage: configure [options] [host]
 Options: [defaults in brackets after descriptions]
@@ -150,10 +149,12 @@ Configuration:
   --no-create             do not create output files
   --quiet, --silent       do not print \`checking...' messages
   --version               print the version of autoconf that created configure
-Directories:
+Directory and file names:
   --exec-prefix=PREFIX    install host dependent files in PREFIX [/usr/local]
   --prefix=PREFIX         install host independent files in PREFIX [/usr/local]
   --srcdir=DIR            find the sources in DIR [configure dir or ..]
+  --program-prefix=PREFIX prepend PREFIX to installed program names
+  --program-suffix=SUFFIX append SUFFIX to installed program names
 Host type:
   --build=BUILD           configure for building on BUILD [BUILD=HOST]
   --host=HOST             configure for HOST [guessed]
@@ -179,9 +180,9 @@ no_create=
 nonopt=NONE
 no_recursion=
 prefix=NONE
-program_prefix=
-program_suffix=
-program_transform_name=
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=NONE
 silent=
 srcdir=
 target=NONE
@@ -457,8 +458,7 @@ This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 " 1>&AC_FD_CC
 
-# Save the original args if we used an alternate arg parser.
-ac_configure_temp="${configure_args-[$]@}"
+ac_configure_temp="$configure_args"
 # Strip out --no-create and --no-recursion so they do not pile up.
 # Also quote any args containing spaces.
 configure_args=
@@ -578,6 +578,30 @@ AC_ARG_WITH([$1], [  --with-$1], [$2], [$3])dnl
 ])
 
 
+dnl ### Transforming program names.
+
+
+dnl AC_ARG_PROGRAM()
+AC_DEFUN(AC_ARG_PROGRAM,
+[test "${program_transform_name}" = NONE && program_transform_name=
+if test -n "${program_transform_name}"; then
+  # Double any \ or $.
+  echo 's,\\,\\\\,g; s,\$,$$,g' > conftestsed
+  program_transform_name="-e `echo ${program_transform_name} | sed -f conftestsed`"
+  rm -f conftestsed
+fi
+test "${program_prefix}" != NONE &&
+  program_transform_name="-e s,^,${program_prefix}, ${program_transform_name}"
+# Use a double $ so make ignores it.
+test "${program_suffix}" != NONE &&
+  program_transform_name="-e s,\$\$,${program_suffix}, ${program_transform_name}"
+
+# sed with no file args requires a program.
+test "${program_transform_name}" = "" && program_transform_name="-e s,x,x,"
+AC_SUBST(program_transform_name)dnl
+])
+
+
 dnl ### Version numbers
 
 
@@ -655,6 +679,7 @@ AC_PROVIDE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
 dnl Canonicalize the host, target, and build system types.
 AC_DEFUN(AC_CANONICAL_SYSTEM,
 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
+AC_BEFORE([$0], [AC_ARG_PROGRAM])
 # Do some error checking and defaulting for the host and target type.
 # The inputs are:
 #    configure --host=HOST --target=TARGET --build=BUILD NONOPT
@@ -684,6 +709,9 @@ fi
 AC_CANONICAL_HOST
 AC_CANONICAL_TARGET
 AC_CANONICAL_BUILD
+test "${host_alias}" != "${target_alias}" &&
+  test "${program_prefix}${program_suffix}${program_transform_name}" = \
+    NONENONENONE && program_prefix=${target_alias}-
 ])
 
 dnl Subroutines of AC_CANONICAL_SYSTEM.
@@ -1299,6 +1327,18 @@ ifelse([$3], , , [$3
 fi
 ])
 
+dnl AC_CHECK_HEADERS(HEADER-FILE... [, ACTION])
+AC_DEFUN(AC_CHECK_HEADERS,
+[for ac_hdr in $1
+do
+AC_CHECK_HEADER(${ac_hdr},
+[changequote(, )dnl
+  ac_tr_hdr=HAVE_`echo $ac_hdr | tr '[a-z]./' '[A-Z]__'`
+changequote([, ])dnl
+  AC_DEFINE_UNQUOTED(${ac_tr_hdr}) $2])dnl
+done
+])
+
 dnl AC_CHECK_FUNC(FUNCTION, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
 AC_DEFUN(AC_CHECK_FUNC,
 [AC_MSG_CHECKING([for $1])
@@ -1341,19 +1381,6 @@ changequote([, ])dnl
 done
 ])
 
-dnl AC_CHECK_HEADERS(HEADER-FILE... [, ACTION])
-AC_DEFUN(AC_CHECK_HEADERS,
-[AC_REQUIRE_CPP()dnl Make sure the cpp check happens outside the loop.
-for ac_hdr in $1
-do
-AC_CHECK_HEADER(${ac_hdr},
-[changequote(, )dnl
-  ac_tr_hdr=HAVE_`echo $ac_hdr | tr '[a-z]./' '[A-Z]__'`
-changequote([, ])dnl
-  AC_DEFINE_UNQUOTED(${ac_tr_hdr}) $2])dnl
-done
-])
-
 dnl AC_REPLACE_FUNCS(FUNCTION-NAME...)
 AC_DEFUN(AC_REPLACE_FUNCS,
 [for ac_func in $1
index 94f327d0bce9c7cce5033d174cd1aabdf1c83603..9c32da44f29fd315f6ec2e5243dd64da1ded61cb 100644 (file)
@@ -61,10 +61,27 @@ fi])dnl
 AC_MSG_RESULT($ac_cv_prog_gcc)
 if test $ac_cv_prog_gcc = yes; then
   GCC=yes
-  test "${CFLAGS+set}" = set || CFLAGS='-g -O'
+  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'
+  test "${CFLAGS+set}" = set || CFLAGS="-g"
 fi
 ])
 
@@ -86,10 +103,27 @@ else
 fi])dnl
 if test $ac_cv_prog_gxx = yes; then
   GXX=yes
-  test "${CXXFLAGS+set}" = set || CXXFLAGS='-g -O'
+  if test "${CXXFLAGS+set}" != set; then
+    AC_MSG_CHECKING(whether ${CXX-gcc} accepts -g)
+AC_CACHE_VAL(ac_cv_prog_gxx_g,
+[echo 'void f(){}' > conftest.cc
+if test -z "`${CXX-gcc} -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'
+  test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
 fi
 ])
 
@@ -97,7 +131,7 @@ 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 -traditional is needed)
+  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>
@@ -288,7 +322,9 @@ AC_SUBST(LEX_OUTPUT_ROOT)dnl
 
 AC_DEFUN(AC_PROG_INSTALL,
 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
-# Make sure to not get an incompatible install:
+# 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
@@ -305,7 +341,7 @@ AC_CACHE_VAL(ac_cv_path_install,
     ''|.|/etc|/usr/sbin|/usr/etc|/sbin|/usr/afsws/bin|/usr/ucb) ;;
     *)
       # OSF1, X11, and SCO ODT 3.0 have their own names for install.
-      for ac_prog in ginstall installbsd bsdinst scoinst install; do
+      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
@@ -445,17 +481,49 @@ fi
 ])
 
 AC_DEFUN(AC_HEADER_DIRENT,
-[ac_header_dir=no
-AC_CHECK_HEADERS(dirent.h sys/ndir.h sys/dir.h ndir.h,
-  [ac_header_dir=$ac_hdr; break])
+[ac_header_dirent=no
+AC_CHECK_HEADERS_DIRENT(dirent.h sys/ndir.h sys/dir.h ndir.h,
+  [ac_header_dirent=$ac_hdr; break])
 ])
 
+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 './' '__'`
+AC_MSG_CHECKING([for $1 that defines DIR])
+AC_CACHE_VAL(ac_cv_header_dirent_$ac_safe,
+[AC_TRY_LINK([#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])
+AC_DEFUN(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]./' '[A-Z]__'`
+changequote([, ])dnl
+  AC_DEFINE_UNQUOTED(${ac_tr_hdr}) $2])dnl
+done])
+
 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_dir>
+#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)
@@ -466,12 +534,12 @@ fi
 
 dnl Obsolete.
 AC_DEFUN(AC_DIR_HEADER,
-[ac_header_dir=no
+[ac_header_dirent=no
 for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
-  AC_CHECK_HEADER($ac_hdr, [ac_header_dir=$ac_hdr; break])
+  AC_CHECK_HEADER_DIRENT($ac_hdr, [ac_header_dirent=$ac_hdr; break])
 done
 
-case "$ac_header_dir" in
+case "$ac_header_dirent" in
 dirent.h) AC_DEFINE(DIRENT) ;;
 sys/ndir.h) AC_DEFINE(SYSNDIR) ;;
 sys/dir.h) AC_DEFINE(SYSDIR) ;;
@@ -481,7 +549,7 @@ 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_dir>
+#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)
@@ -1211,7 +1279,7 @@ 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(){exit(0);}],
+[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)
@@ -1748,7 +1816,7 @@ AC_EGREP_CPP(yes,
 ], [AC_MSG_RESULT(yes); XENIX=yes], [AC_MSG_RESULT(no); XENIX=])
 if test "$XENIX" = yes; then
   LIBS="$LIBS -lx"
-  if test $ac_header_dir != sys/ndir.h; then
+  if test $ac_header_dirent != sys/ndir.h; then
     LIBS="-ldir $LIBS" # Make sure -ldir precedes -lx.
   fi
 fi
index 10e308c23e0dbc157fe45237c58241aa435402b2..f2d93eee1016c8702b286f364b1b303ca68cd363 100644 (file)
@@ -133,6 +133,7 @@ Controlling Autoconf Operation
 * Input::                       Where Autoconf should find files.
 * Output::                     Controlling Autoconf output files.
 * Package Options::             Selecting optional features.
+* Transforming Names::          Changing program names when installing.
 * Versions::                    Version numbers in producing @code{configure}.
 
 Existing Tests
@@ -169,7 +170,7 @@ Library Functions
 
 Primitives For Building Tests
 
-* C System Output::             Checking output of C compiler system.
+* C System Output::             Checking output of the C compiler system.
 * Setting Variables::          Setting shell and @code{make} variables.
 * Printing Messages::           Notifying users of progress or problems.
 * Language Choice::             Selecting which language to use for testing.
@@ -720,6 +721,7 @@ optional features of the user's package.
 * Input::                       Where Autoconf should find files.
 * Output::                     Controlling Autoconf output files.
 * Package Options::             Selecting optional features.
+* Transforming Names::          Changing program names when installing.
 * Versions::                    Version numbers in producing @code{configure}.
 @end menu
 
@@ -835,7 +837,7 @@ substitutions performed on them in @code{configure}.  You can use
 @var{extra-cmds}.
 @end defmac
 
-@node Package Options, Versions, Output, Operation
+@node Package Options, Transforming Names, Output, Operation
 @section Checking for Package Options
 
 These macros check whether the user gave @code{configure} command line
@@ -923,7 +925,75 @@ This is an obsolete version of @code{AC_ARG_WITH} that does not
 support providing a help string.
 @end defmac
 
-@node Versions, , Package Options, Operation
+@node Transforming Names, Versions, Package Options, Operation
+@section Transforming Program Names When Installing
+
+Autoconf supports giving @code{configure} the following command line
+options to change the names of programs being installed:
+
+@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.  The main
+use for this option is to prevent the automatic addition of a target
+name prefix to program names (see below) by giving an empty
+@var{expression}.  As another possibility,
+@samp{--program-transform-name='s,^\(........\).*,\1.exe,'} could be used to
+truncate installed program names to 8 characters and append @file{.exe}.
+@end table
+
+In order to use the values given to those options, @file{configure.in}
+must call the macro @code{AC_ARG_PROGRAM}.
+
+@defmac AC_ARG_PROGRAM
+@maindex ARG_PROGRAM
+Place in @file{Makefile} variable @code{program_transform_name} a
+sequence of @code{sed} commands for changing the names of installed
+programs.
+
+If any of the above options 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.
+
+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.
+
+They can also force a program name to begin with @file{g}, if you don't
+want GNU programs installed on your system to shadow system programs by
+the same name.  For example, if GNU @code{make} used this macro, you
+could configure it with @samp{--program-prefix=g} and when you ran
+@samp{make install}, it would be installed as
+@file{/usr/local/bin/gmake}.
+
+Use the variable @code{program_transform_name} as in this example for
+an assembler, compiled as @file{as.new}.  The shell variable @code{t}
+is needed in case @code{program_transform_name} contains any shell
+special characters.  With quoting and variable substitutions, whitespace
+still properly separates @code{sed} arguments, but other special
+characters have no effect.
+
+@example
+program_transform_name=@@program_transform_name@@
+install: all
+        name=`t='$(program_transform_name)'; echo as | sed $$t` ; \
+        $(INSTALL_PROGRAM) as.new $(bindir)/$$name
+@end example
+@end defmac
+
+
+@node Versions, , Transforming Names, Operation
 @section Controlling Autoconf Versions
 
 The following macros manage version numbers for @code{configure} scripts.
@@ -1056,10 +1126,12 @@ finds.
 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 @code{make} variable @code{CC} to the name of the compiler found.
-Set shell variable @code{GCC} to @samp{yes} if using the GNU C
-compiler, empty otherwise, and if @code{make} variable @code{CFLAGS} was
-not already set, set it to @samp{-g -O} for the GNU C compiler or
-@samp{-g} for other compilers.
+
+If using the GNU C compiler, set shell variable @code{GCC} to
+@samp{yes}, empty otherwise.  If @code{make} 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
@@ -1091,10 +1163,13 @@ Determine a C++ compiler to use.  Check if the environment variable
 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}.  Also set shell variable @code{GXX} to
-@samp{yes} if using the GNU C++ compiler, empty otherwise, and if
-@code{make} variable @code{CXXFLAGS} was not already set, set it to
-@samp{-g -O} for the GNU C++ compiler or @samp{-g} for other compilers.
+@code{CXX} to @code{gcc}.
+
+If using the GNU C++ compiler, set shell variable @code{GXX} to
+@samp{yes}, empty otherwise.  If @code{make} 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
@@ -1278,10 +1353,7 @@ This macro is equivalent to calling @code{AC_CHECK_LIB} with a
 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, because some linkers (e.g., Apollo's)
-do not fail when asked to link with a nonexistent library if there are
-no unresolved sybols.
+This macro is considered obsolete.
 @end defmac
 
 @node Header Files, Typedefs, Libraries, Existing Tests
@@ -1347,7 +1419,7 @@ define @code{VOID_CLOSEDIR}.
 @cvindex HAVE_SYS_DIR_H
 @cvindex HAVE_SYS_NDIR_H
 Check for the the following header files, and for the first one that is
-found, define the listed C preprocessor macro:
+found and defines @samp{DIR}, define the listed C preprocessor macro:
 
 @table @file
 @item dirent.h
@@ -2188,7 +2260,7 @@ kinds of features are available and report the results.  Within each
 section below, the macros are listed in alphabetical order.
 
 @menu
-* C System Output::             Checking output of C compiler system.
+* C System Output::             Checking output of the C compiler system.
 * Setting Variables::          Setting shell and @code{make} variables.
 * Printing Messages::           Notifying users of progress or problems.
 * Language Choice::             Selecting which language to use for testing.
@@ -2842,7 +2914,7 @@ 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])
+AC_BEFORE([$0], [AC_PROG_CPP])dnl
 @end example
 
 @noindent
@@ -3429,7 +3501,9 @@ values by enclosing their names in @samp{@@} characters.
 @ifinfo
 @xref{Makefiles}, for more information on @samp{@@} substitutions.
 @end ifinfo
-The variables that are defined by the Autoconf macros are:
+The variables that are automatically defined by the Autoconf macros are
+listed here.  Some of the Autoconf macros define additional variables,
+which are mentioned in the descriptions for those macros.
 
 @defvar exec_prefix
 The installation prefix for architecture-specific files.
index 10e308c23e0dbc157fe45237c58241aa435402b2..f2d93eee1016c8702b286f364b1b303ca68cd363 100644 (file)
@@ -133,6 +133,7 @@ Controlling Autoconf Operation
 * Input::                       Where Autoconf should find files.
 * Output::                     Controlling Autoconf output files.
 * Package Options::             Selecting optional features.
+* Transforming Names::          Changing program names when installing.
 * Versions::                    Version numbers in producing @code{configure}.
 
 Existing Tests
@@ -169,7 +170,7 @@ Library Functions
 
 Primitives For Building Tests
 
-* C System Output::             Checking output of C compiler system.
+* C System Output::             Checking output of the C compiler system.
 * Setting Variables::          Setting shell and @code{make} variables.
 * Printing Messages::           Notifying users of progress or problems.
 * Language Choice::             Selecting which language to use for testing.
@@ -720,6 +721,7 @@ optional features of the user's package.
 * Input::                       Where Autoconf should find files.
 * Output::                     Controlling Autoconf output files.
 * Package Options::             Selecting optional features.
+* Transforming Names::          Changing program names when installing.
 * Versions::                    Version numbers in producing @code{configure}.
 @end menu
 
@@ -835,7 +837,7 @@ substitutions performed on them in @code{configure}.  You can use
 @var{extra-cmds}.
 @end defmac
 
-@node Package Options, Versions, Output, Operation
+@node Package Options, Transforming Names, Output, Operation
 @section Checking for Package Options
 
 These macros check whether the user gave @code{configure} command line
@@ -923,7 +925,75 @@ This is an obsolete version of @code{AC_ARG_WITH} that does not
 support providing a help string.
 @end defmac
 
-@node Versions, , Package Options, Operation
+@node Transforming Names, Versions, Package Options, Operation
+@section Transforming Program Names When Installing
+
+Autoconf supports giving @code{configure} the following command line
+options to change the names of programs being installed:
+
+@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.  The main
+use for this option is to prevent the automatic addition of a target
+name prefix to program names (see below) by giving an empty
+@var{expression}.  As another possibility,
+@samp{--program-transform-name='s,^\(........\).*,\1.exe,'} could be used to
+truncate installed program names to 8 characters and append @file{.exe}.
+@end table
+
+In order to use the values given to those options, @file{configure.in}
+must call the macro @code{AC_ARG_PROGRAM}.
+
+@defmac AC_ARG_PROGRAM
+@maindex ARG_PROGRAM
+Place in @file{Makefile} variable @code{program_transform_name} a
+sequence of @code{sed} commands for changing the names of installed
+programs.
+
+If any of the above options 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.
+
+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.
+
+They can also force a program name to begin with @file{g}, if you don't
+want GNU programs installed on your system to shadow system programs by
+the same name.  For example, if GNU @code{make} used this macro, you
+could configure it with @samp{--program-prefix=g} and when you ran
+@samp{make install}, it would be installed as
+@file{/usr/local/bin/gmake}.
+
+Use the variable @code{program_transform_name} as in this example for
+an assembler, compiled as @file{as.new}.  The shell variable @code{t}
+is needed in case @code{program_transform_name} contains any shell
+special characters.  With quoting and variable substitutions, whitespace
+still properly separates @code{sed} arguments, but other special
+characters have no effect.
+
+@example
+program_transform_name=@@program_transform_name@@
+install: all
+        name=`t='$(program_transform_name)'; echo as | sed $$t` ; \
+        $(INSTALL_PROGRAM) as.new $(bindir)/$$name
+@end example
+@end defmac
+
+
+@node Versions, , Transforming Names, Operation
 @section Controlling Autoconf Versions
 
 The following macros manage version numbers for @code{configure} scripts.
@@ -1056,10 +1126,12 @@ finds.
 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 @code{make} variable @code{CC} to the name of the compiler found.
-Set shell variable @code{GCC} to @samp{yes} if using the GNU C
-compiler, empty otherwise, and if @code{make} variable @code{CFLAGS} was
-not already set, set it to @samp{-g -O} for the GNU C compiler or
-@samp{-g} for other compilers.
+
+If using the GNU C compiler, set shell variable @code{GCC} to
+@samp{yes}, empty otherwise.  If @code{make} 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
@@ -1091,10 +1163,13 @@ Determine a C++ compiler to use.  Check if the environment variable
 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}.  Also set shell variable @code{GXX} to
-@samp{yes} if using the GNU C++ compiler, empty otherwise, and if
-@code{make} variable @code{CXXFLAGS} was not already set, set it to
-@samp{-g -O} for the GNU C++ compiler or @samp{-g} for other compilers.
+@code{CXX} to @code{gcc}.
+
+If using the GNU C++ compiler, set shell variable @code{GXX} to
+@samp{yes}, empty otherwise.  If @code{make} 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
@@ -1278,10 +1353,7 @@ This macro is equivalent to calling @code{AC_CHECK_LIB} with a
 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, because some linkers (e.g., Apollo's)
-do not fail when asked to link with a nonexistent library if there are
-no unresolved sybols.
+This macro is considered obsolete.
 @end defmac
 
 @node Header Files, Typedefs, Libraries, Existing Tests
@@ -1347,7 +1419,7 @@ define @code{VOID_CLOSEDIR}.
 @cvindex HAVE_SYS_DIR_H
 @cvindex HAVE_SYS_NDIR_H
 Check for the the following header files, and for the first one that is
-found, define the listed C preprocessor macro:
+found and defines @samp{DIR}, define the listed C preprocessor macro:
 
 @table @file
 @item dirent.h
@@ -2188,7 +2260,7 @@ kinds of features are available and report the results.  Within each
 section below, the macros are listed in alphabetical order.
 
 @menu
-* C System Output::             Checking output of C compiler system.
+* C System Output::             Checking output of the C compiler system.
 * Setting Variables::          Setting shell and @code{make} variables.
 * Printing Messages::           Notifying users of progress or problems.
 * Language Choice::             Selecting which language to use for testing.
@@ -2842,7 +2914,7 @@ 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])
+AC_BEFORE([$0], [AC_PROG_CPP])dnl
 @end example
 
 @noindent
@@ -3429,7 +3501,9 @@ values by enclosing their names in @samp{@@} characters.
 @ifinfo
 @xref{Makefiles}, for more information on @samp{@@} substitutions.
 @end ifinfo
-The variables that are defined by the Autoconf macros are:
+The variables that are automatically defined by the Autoconf macros are
+listed here.  Some of the Autoconf macros define additional variables,
+which are mentioned in the descriptions for those macros.
 
 @defvar exec_prefix
 The installation prefix for architecture-specific files.
index d047bb2f7c9f15ebfc99cc2800d26726142b6e48..430de8d39d9417b4bdae33b75b4de050372e7b82 100644 (file)
@@ -139,8 +139,7 @@ AC_DEFUN(AC_INIT_PARSE_ARGS,
 [# Save the original args to write them into config.status later.
 configure_args="[$]@"
 
-# Omit some internal, obsolete, or unimplemented options to make the
-# list less imposing.
+# Omit some internal or obsolete options to make the list less imposing.
 changequote(, )dnl
 ac_usage="Usage: configure [options] [host]
 Options: [defaults in brackets after descriptions]
@@ -150,10 +149,12 @@ Configuration:
   --no-create             do not create output files
   --quiet, --silent       do not print \`checking...' messages
   --version               print the version of autoconf that created configure
-Directories:
+Directory and file names:
   --exec-prefix=PREFIX    install host dependent files in PREFIX [/usr/local]
   --prefix=PREFIX         install host independent files in PREFIX [/usr/local]
   --srcdir=DIR            find the sources in DIR [configure dir or ..]
+  --program-prefix=PREFIX prepend PREFIX to installed program names
+  --program-suffix=SUFFIX append SUFFIX to installed program names
 Host type:
   --build=BUILD           configure for building on BUILD [BUILD=HOST]
   --host=HOST             configure for HOST [guessed]
@@ -179,9 +180,9 @@ no_create=
 nonopt=NONE
 no_recursion=
 prefix=NONE
-program_prefix=
-program_suffix=
-program_transform_name=
+program_prefix=NONE
+program_suffix=NONE
+program_transform_name=NONE
 silent=
 srcdir=
 target=NONE
@@ -457,8 +458,7 @@ This file contains any messages produced by compilers while
 running configure, to aid debugging if configure makes a mistake.
 " 1>&AC_FD_CC
 
-# Save the original args if we used an alternate arg parser.
-ac_configure_temp="${configure_args-[$]@}"
+ac_configure_temp="$configure_args"
 # Strip out --no-create and --no-recursion so they do not pile up.
 # Also quote any args containing spaces.
 configure_args=
@@ -578,6 +578,30 @@ AC_ARG_WITH([$1], [  --with-$1], [$2], [$3])dnl
 ])
 
 
+dnl ### Transforming program names.
+
+
+dnl AC_ARG_PROGRAM()
+AC_DEFUN(AC_ARG_PROGRAM,
+[test "${program_transform_name}" = NONE && program_transform_name=
+if test -n "${program_transform_name}"; then
+  # Double any \ or $.
+  echo 's,\\,\\\\,g; s,\$,$$,g' > conftestsed
+  program_transform_name="-e `echo ${program_transform_name} | sed -f conftestsed`"
+  rm -f conftestsed
+fi
+test "${program_prefix}" != NONE &&
+  program_transform_name="-e s,^,${program_prefix}, ${program_transform_name}"
+# Use a double $ so make ignores it.
+test "${program_suffix}" != NONE &&
+  program_transform_name="-e s,\$\$,${program_suffix}, ${program_transform_name}"
+
+# sed with no file args requires a program.
+test "${program_transform_name}" = "" && program_transform_name="-e s,x,x,"
+AC_SUBST(program_transform_name)dnl
+])
+
+
 dnl ### Version numbers
 
 
@@ -655,6 +679,7 @@ AC_PROVIDE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
 dnl Canonicalize the host, target, and build system types.
 AC_DEFUN(AC_CANONICAL_SYSTEM,
 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
+AC_BEFORE([$0], [AC_ARG_PROGRAM])
 # Do some error checking and defaulting for the host and target type.
 # The inputs are:
 #    configure --host=HOST --target=TARGET --build=BUILD NONOPT
@@ -684,6 +709,9 @@ fi
 AC_CANONICAL_HOST
 AC_CANONICAL_TARGET
 AC_CANONICAL_BUILD
+test "${host_alias}" != "${target_alias}" &&
+  test "${program_prefix}${program_suffix}${program_transform_name}" = \
+    NONENONENONE && program_prefix=${target_alias}-
 ])
 
 dnl Subroutines of AC_CANONICAL_SYSTEM.
@@ -1299,6 +1327,18 @@ ifelse([$3], , , [$3
 fi
 ])
 
+dnl AC_CHECK_HEADERS(HEADER-FILE... [, ACTION])
+AC_DEFUN(AC_CHECK_HEADERS,
+[for ac_hdr in $1
+do
+AC_CHECK_HEADER(${ac_hdr},
+[changequote(, )dnl
+  ac_tr_hdr=HAVE_`echo $ac_hdr | tr '[a-z]./' '[A-Z]__'`
+changequote([, ])dnl
+  AC_DEFINE_UNQUOTED(${ac_tr_hdr}) $2])dnl
+done
+])
+
 dnl AC_CHECK_FUNC(FUNCTION, ACTION-IF-FOUND [, ACTION-IF-NOT-FOUND])
 AC_DEFUN(AC_CHECK_FUNC,
 [AC_MSG_CHECKING([for $1])
@@ -1341,19 +1381,6 @@ changequote([, ])dnl
 done
 ])
 
-dnl AC_CHECK_HEADERS(HEADER-FILE... [, ACTION])
-AC_DEFUN(AC_CHECK_HEADERS,
-[AC_REQUIRE_CPP()dnl Make sure the cpp check happens outside the loop.
-for ac_hdr in $1
-do
-AC_CHECK_HEADER(${ac_hdr},
-[changequote(, )dnl
-  ac_tr_hdr=HAVE_`echo $ac_hdr | tr '[a-z]./' '[A-Z]__'`
-changequote([, ])dnl
-  AC_DEFINE_UNQUOTED(${ac_tr_hdr}) $2])dnl
-done
-])
-
 dnl AC_REPLACE_FUNCS(FUNCTION-NAME...)
 AC_DEFUN(AC_REPLACE_FUNCS,
 [for ac_func in $1
index 94f327d0bce9c7cce5033d174cd1aabdf1c83603..9c32da44f29fd315f6ec2e5243dd64da1ded61cb 100644 (file)
@@ -61,10 +61,27 @@ fi])dnl
 AC_MSG_RESULT($ac_cv_prog_gcc)
 if test $ac_cv_prog_gcc = yes; then
   GCC=yes
-  test "${CFLAGS+set}" = set || CFLAGS='-g -O'
+  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'
+  test "${CFLAGS+set}" = set || CFLAGS="-g"
 fi
 ])
 
@@ -86,10 +103,27 @@ else
 fi])dnl
 if test $ac_cv_prog_gxx = yes; then
   GXX=yes
-  test "${CXXFLAGS+set}" = set || CXXFLAGS='-g -O'
+  if test "${CXXFLAGS+set}" != set; then
+    AC_MSG_CHECKING(whether ${CXX-gcc} accepts -g)
+AC_CACHE_VAL(ac_cv_prog_gxx_g,
+[echo 'void f(){}' > conftest.cc
+if test -z "`${CXX-gcc} -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'
+  test "${CXXFLAGS+set}" = set || CXXFLAGS="-g"
 fi
 ])
 
@@ -97,7 +131,7 @@ 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 -traditional is needed)
+  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>
@@ -288,7 +322,9 @@ AC_SUBST(LEX_OUTPUT_ROOT)dnl
 
 AC_DEFUN(AC_PROG_INSTALL,
 [AC_REQUIRE([AC_CONFIG_AUX_DIR_DEFAULT])dnl
-# Make sure to not get an incompatible install:
+# 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
@@ -305,7 +341,7 @@ AC_CACHE_VAL(ac_cv_path_install,
     ''|.|/etc|/usr/sbin|/usr/etc|/sbin|/usr/afsws/bin|/usr/ucb) ;;
     *)
       # OSF1, X11, and SCO ODT 3.0 have their own names for install.
-      for ac_prog in ginstall installbsd bsdinst scoinst install; do
+      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
@@ -445,17 +481,49 @@ fi
 ])
 
 AC_DEFUN(AC_HEADER_DIRENT,
-[ac_header_dir=no
-AC_CHECK_HEADERS(dirent.h sys/ndir.h sys/dir.h ndir.h,
-  [ac_header_dir=$ac_hdr; break])
+[ac_header_dirent=no
+AC_CHECK_HEADERS_DIRENT(dirent.h sys/ndir.h sys/dir.h ndir.h,
+  [ac_header_dirent=$ac_hdr; break])
 ])
 
+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 './' '__'`
+AC_MSG_CHECKING([for $1 that defines DIR])
+AC_CACHE_VAL(ac_cv_header_dirent_$ac_safe,
+[AC_TRY_LINK([#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])
+AC_DEFUN(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]./' '[A-Z]__'`
+changequote([, ])dnl
+  AC_DEFINE_UNQUOTED(${ac_tr_hdr}) $2])dnl
+done])
+
 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_dir>
+#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)
@@ -466,12 +534,12 @@ fi
 
 dnl Obsolete.
 AC_DEFUN(AC_DIR_HEADER,
-[ac_header_dir=no
+[ac_header_dirent=no
 for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h; do
-  AC_CHECK_HEADER($ac_hdr, [ac_header_dir=$ac_hdr; break])
+  AC_CHECK_HEADER_DIRENT($ac_hdr, [ac_header_dirent=$ac_hdr; break])
 done
 
-case "$ac_header_dir" in
+case "$ac_header_dirent" in
 dirent.h) AC_DEFINE(DIRENT) ;;
 sys/ndir.h) AC_DEFINE(SYSNDIR) ;;
 sys/dir.h) AC_DEFINE(SYSDIR) ;;
@@ -481,7 +549,7 @@ 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_dir>
+#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)
@@ -1211,7 +1279,7 @@ 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(){exit(0);}],
+[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)
@@ -1748,7 +1816,7 @@ AC_EGREP_CPP(yes,
 ], [AC_MSG_RESULT(yes); XENIX=yes], [AC_MSG_RESULT(no); XENIX=])
 if test "$XENIX" = yes; then
   LIBS="$LIBS -lx"
-  if test $ac_header_dir != sys/ndir.h; then
+  if test $ac_header_dirent != sys/ndir.h; then
     LIBS="-ldir $LIBS" # Make sure -ldir precedes -lx.
   fi
 fi