changeset 15126:067699edef86

configure.ac: Re-organize to follow Autoconf layout guidelines * configure.ac: Re-organize to follow Autoconf layout guidelines
author Rik <rik@octave.org>
date Tue, 07 Aug 2012 13:34:22 -0700
parents 0464e3ceb85b
children 25200c04bc25
files configure.ac
diffstat 1 files changed, 292 insertions(+), 280 deletions(-) [+]
line wrap: on
line diff
--- a/configure.ac
+++ b/configure.ac
@@ -27,6 +27,7 @@
 EXTERN_CFLAGS="$CFLAGS"
 EXTERN_CXXFLAGS="$CXXFLAGS"
 
+AC_PREREQ([2.62])
 AC_INIT([GNU Octave], [3.7.0+], [http://octave.org/bugs.html], [octave])
 
 dnl PACKAGE_VERSION is set by the AC_INIT VERSION arg
@@ -41,8 +42,9 @@
 AC_SUBST(OCTAVE_RELEASE_DATE)
 AC_SUBST(OCTAVE_COPYRIGHT)
 
-AC_REVISION($Revision: 1.603 $)
-AC_PREREQ([2.62])
+dnl FIXME: We should auto-insert the Mercurial changeset ID into the
+dnl        AC_REVISION field whenever configure.ac is modified.
+dnl AC_REVISION($Revision: 1.603 $)
 AC_CONFIG_SRCDIR([src/octave.cc])
 AC_CONFIG_HEADERS([config.h])
 AC_CONFIG_AUX_DIR([build-aux])
@@ -54,24 +56,6 @@
 
 AC_DEFINE(OCTAVE_SOURCE, 1, [Define to 1 if this is Octave.])
   
-dnl FIXME: Can this MSVC test be moved down to the section on finding a
-dnl        a C compiler which already has an MSVC exception test?
-dnl FIXME: We should probably only generate this file if it is missing.
-### Produce unistd.h for MSVC target, this simplifies changes in
-### Octave source tree and avoid problems with lex-generated code.
-case "$canonical_host_type" in
-  *-*-msdosmsvc)
-    AC_MSG_NOTICE([Generating replacement for <unistd.h> for MSVC])
-    cat << \EOF > unistd.h
-/* File generated by configure script. */
-#include <direct.h>
-#include <io.h>
-#include <process.h>
-EOF
-    CPPFLAGS="-I. $CPPFLAGS"
-    ;;
-esac
-
 AC_USE_SYSTEM_EXTENSIONS
 
 ### Path separator.
@@ -259,10 +243,6 @@
 fi
 AC_SUBST(CXX_VERSION)
 
-OCTAVE_CXX_NEW_FRIEND_TEMPLATE_DECL
-OCTAVE_CXX_ISO_COMPLIANT_LIBRARY
-OCTAVE_CXX_BROKEN_REINTERPRET_CAST
-
 ### Determine which C compiler to use (we expect to find gcc).
 
 AC_PROG_CC
@@ -341,7 +321,7 @@
 ### Check for pthread library
 
 AX_PTHREAD
-## Include pthread libs and flags here in case other tests need them.
+## Include pthread libs and flags early in case other tests need them.
 ## They seem to be required for the OpenGL tests on Debian systems.
 LIBS="$PTHREAD_LIBS $LIBS"
 CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
@@ -456,20 +436,6 @@
   esac
 fi
 
-dnl FIXME: This is OS-specific tests.  Can this be moved further down in
-dnl configure.ac to reside with other similar tests?
-### Use -static if compiling on Alpha OSF/1 1.3 systems.
-
-case "$canonical_host_type" in
-  alpha*-dec-osf1.3)
-    LD_STATIC_FLAG=-static
-  ;;
-esac
-if test -n "$LD_STATIC_FLAG"; then
-  AC_MSG_NOTICE([defining LD_STATIC_FLAG to be $LD_STATIC_FLAG])
-fi
-AC_SUBST(LD_STATIC_FLAG)
-
 ### Defaults for cross compiling.  BUILD_CC and BUILD_CXX are
 ### the compilers that we use for building tools on the build system.
 ### For now, we assume that the only cross compiling we can do is
@@ -639,14 +605,6 @@
 AC_SUBST(F77_FLOAT_STORE_FLAG)
 ])
 
-### Check that C compiler and libraries support IEEE754 data format.
-OCTAVE_IEEE754_DATA_FORMAT
-
-### Check C++ library for various capabilities.
-OCTAVE_CXX_BITWISE_OP_TEMPLATES
-OCTAVE_CXX_COMPLEX_SETTERS
-OCTAVE_CXX_COMPLEX_REFERENCE_ACCESSORS
-
 ### Check for the Qhull library
 
 OCTAVE_CHECK_LIBRARY(qhull, QHull,
@@ -1088,6 +1046,17 @@
 
 ### Start determination of shared vs. static libraries
 
+## Use -static if compiling on Alpha OSF/1 1.3 systems.
+case "$canonical_host_type" in
+  alpha*-dec-osf1.3)
+    LD_STATIC_FLAG=-static
+  ;;
+esac
+if test -n "$LD_STATIC_FLAG"; then
+  AC_MSG_NOTICE([defining LD_STATIC_FLAG to be $LD_STATIC_FLAG])
+fi
+AC_SUBST(LD_STATIC_FLAG)
+
 OCTAVE_PROG_AR
 
 ifdef([LT_INIT], [], [
@@ -1639,25 +1608,7 @@
 AC_SUBST(library_path_var)
 AC_SUBST(ldpreloadsep)
 
-### special checks for odd OS specific things.
-
-AC_CHECK_FUNCS(getpwnam, [], [AC_CHECK_LIB(sun, getpwnam)])
-
-case "$canonical_host_type" in
-  *-*-mingw*)
-    if test "$have_msvc" = "yes"; then
-      AC_CHECK_LIB(dirent, opendir)
-      LIBS="$LIBS -ladvapi32 -lgdi32 -lws2_32 -luser32 -lkernel32"
-    else
-      LIBS="$LIBS -lgdi32 -lws2_32 -luser32 -lkernel32"
-    fi
-    LIBS="$LIBS -lgdi32 -lws2_32 -luser32 -lkernel32"
-  ;;
-  *-*-msdosmsvc*)
-    AC_CHECK_LIB(dirent, opendir)
-    LIBS="$LIBS -ladvapi32 -lgdi32 -lws2_32 -luser32 -lkernel32"
-  ;;
-esac
+### More configure argument checking related to linking
 
 AC_ARG_ENABLE([no-undefined],
   [AS_HELP_STRING([--enable-no-undefined],
@@ -1679,187 +1630,8 @@
    esac], [link_all_deps=false])
 AM_CONDITIONAL([AMCOND_LINK_ALL_DEPS], [test x$link_all_deps = xtrue])
 
-### Type stuff.
-
-AC_TYPE_MODE_T
-AC_TYPE_OFF_T
-AC_TYPE_PID_T
-AC_TYPE_SIZE_T
-AC_TYPE_UID_T
-AC_CHECK_TYPES([dev_t, ino_t])
-AC_CHECK_TYPES([long long int, unsigned long long int])
-
-### How big are ints and how are they oriented?  These could probably
-### be eliminated in favor of run-time checks.
-
-AC_CHECK_SIZEOF(short)
-AC_CHECK_SIZEOF(int)
-AC_CHECK_SIZEOF(long)
-AC_CHECK_SIZEOF(long long)
-
-### Does the C compiler handle alloca() and const correctly?
-
-AC_FUNC_ALLOCA
-
-### See if we should use placement delete.
-
-OCTAVE_PLACEMENT_DELETE
-
-### See if we can auto allocate variable sized arrays.
-
-OCTAVE_DYNAMIC_AUTO_ARRAYS
-
-### See if we can use fast integer arithmetics
-
-OCTAVE_FAST_INT_OPS
-
-### Check for long double type (for 64-bit integers)
-
-AC_CHECK_SIZEOF(long double)
-
-### Checks for header files.
-
-AC_HEADER_DIRENT
-AC_HEADER_SYS_WAIT
-
-### C headers
-
-AC_CHECK_HEADERS(curses.h direct.h dlfcn.h floatingpoint.h grp.h \
-  ieeefp.h inttypes.h locale.h memory.h ncurses.h poll.h pthread.h \
-  pwd.h sunmath.h sys/ioctl.h sys/param.h sys/poll.h sys/resource.h \
-  sys/select.h sys/utsname.h termcap.h)
-
-### C++ headers
-
-AC_LANG_PUSH(C++)
-AC_CHECK_HEADERS(sstream)
-AC_CHECK_HEADERS([unordered_map], [], [
-  AC_CHECK_HEADERS([tr1/unordered_map])])
-AC_MSG_CHECKING([whether unordered_map requires tr1 namespace])
-unordered_map_requires_tr1_namespace=no
-if test "$ac_cv_header_unordered_map" = "yes"; then
-  ## Have <unordered_map>, but still have to check whether
-  ## tr1 namespace is required (like MSVC, for instance).
-  AC_COMPILE_IFELSE([
-    AC_LANG_PROGRAM([
-      #include <unordered_map>
-    ], [
-      std::unordered_map<int,int> m;
-    ])], [], [unordered_map_requires_tr1_namespace=yes])
-elif test "$ac_cv_header_tr1_unordered_map" = "yes"; then
-  unordered_map_requires_tr1_namespace=yes
-fi
-if test "$unordered_map_requires_tr1_namespace" = "yes"; then
-  AC_DEFINE(USE_UNORDERED_MAP_WITH_TR1, 1, [Define to 1 if unordered_map requires the use of tr1 namespace.])
-fi
-AC_MSG_RESULT([$unordered_map_requires_tr1_namespace])
-AC_LANG_POP(C++)
-
-have_termios_h=no
-AC_CHECK_HEADERS(termios.h, have_termios_h=yes)
-AC_CHECK_HEADERS(termio.h, have_termio_h=yes, have_termio_h=no)
-AC_CHECK_HEADERS(sgtty.h, have_sgtty_h=yes, have_sgtty_h=no)
-AC_CHECK_HEADERS(fnmatch.h, have_fnmatch_h=yes, have_fnmatch_h=no)
-AC_CHECK_HEADERS(conio.h, have_conio_h=yes, have_conio_h=no)
-
-if test "$have_termios_h" = yes \
-    || test "$have_termio_h" = yes \
-    || test "$have_sgtty_h" = yes; then
-  true
-else
-  AC_MSG_WARN([I couldn't find termios.h, termio.h, or sgtty.h!])
-fi
-
-### For MSVC compilers, avoid #define of min/max from windows.h header
-if test "$have_msvc" = "yes"; then
-  AC_DEFINE(NOMINMAX, 1, [Define to 1 if you want to avoid min/max macro definition in Windows headers.])
-fi
-
-### Checks for functions and variables.
-
-AC_CHECK_FUNCS(basename canonicalize_file_name \
-  chmod dup2 endgrent endpwent execvp expm1 expm1f fork \
-  getegid geteuid getgid getgrent getgrgid getgrnam getpgrp getpid \
-  getppid getpwent getpwuid getuid getwd _kbhit kill \
-  lgamma lgammaf lgamma_r lgammaf_r localtime_r log1p log1pf \
-  mkstemp pipe putenv \
-  realpath resolvepath rindex roundl select setgrent setlocale \
-  setpwent setvbuf siglongjmp \
-  strsignal tempnam tgammaf umask \
-  uname utime waitpid \
-  _chmod x_utime _utime32)
-
-AC_LANG_PUSH(C++)
-AC_CHECK_DECLS([exp2, round, tgamma], [], [], [[#include <cmath>]])
-AC_CHECK_FUNCS([exp2 round tgamma])
-AH_VERBATIM([Z_FUNCS_AND_DECLS], [
-#if defined (__cplusplus)
-extern "C" {
-#endif
-#if HAVE_EXP2 && ! HAVE_DECL_EXP2
-double exp2 (double );
-#endif
-#if HAVE_ROUND && ! HAVE_DECL_ROUND
-double round (double);
-#endif
-#if HAVE_TGAMMA && ! HAVE_DECL_TGAMMA
-double tgamma (double);
-#endif
-#if defined (__cplusplus)
-}
-#endif
-])
-AC_LANG_POP(C++)
-
-case "$canonical_host_type" in
-  *-*-mingw*)
-    ## MinGW does not provide a mkstemp function.  However, it provides
-    ## the mkstemps function in libiberty.
-    AC_MSG_CHECKING([for mkstemps in libiberty])
-    save_LIBS="$LIBS"
-    LIBS="-liberty $LIBS"
-    AC_LINK_IFELSE([
-      AC_LANG_PROGRAM([[int mkstemps (char *pattern, int suffix_len);]], 
-       [[mkstemps ("XXXXXX", 0);]]
-    )],
-    [AC_MSG_RESULT(yes)
-     HAVE_MKSTEMPS=yes
-     AC_DEFINE(HAVE_MKSTEMPS, 1, [Define to 1 if mkstemps is available in libiberty.])
-    ],
-    [AC_MSG_RESULT(no)
-     HAVE_MKSTEMPS=no
-     LIBS="$save_LIBS"
-    ])
-   ;;
-esac
-
-OCTAVE_SMART_PUTENV
-
-case "$canonical_host_type" in
-  *-*-msdosmsvc | *-*-mingw*)
-    AC_MSG_CHECKING([for required _WIN32_WINNT])
-    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
-#include <windows.h>
-#if _WIN32_WINNT < 0x0403
-#error "Wrong version"
-#endif]], [])],
-      AC_MSG_RESULT([none]), [
-        AC_DEFINE(_WIN32_WINNT, 0x0403, [Define to 0x0403 to access InitializeCriticalSectionAndSpinCount.])
-        AC_MSG_RESULT([0x0403])])
-    AC_MSG_CHECKING([whether _USE_MATH_DEFINES needs to be defined])
-    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]],
-[[int x = M_LN2;]])],
-      AC_MSG_RESULT([no]), [
-        AC_DEFINE(_USE_MATH_DEFINES, 1, [Define to 1 if your system needs to define math constants like M_LN2.])
-        AC_MSG_RESULT([yes])])
-  ;;
-esac
-
-## Check for CGDisplayBitsPerPixel function on Mac OSX systems with Carbon
-OCTAVE_CARBON_CGDISPLAYBITSPERPIXEL
-
-### Dynamic linking is now enabled only if we are building shared
-### libs and some API for dynamic linking is detected.
+## Dynamic linking is now enabled only if we are building shared
+## libs and some API for dynamic linking has been detected.
 
 ## FIXME: A lot of the following duplicates the functionality of
 ## code generated by the dlopen option for LT_INIT.
@@ -1933,7 +1705,219 @@
 AC_SUBST(LIBOCTAVE)
 AC_SUBST(LIBCRUFT)
 
-dnl Maybe <cmath> defines the IEEE functions we need.
+### Check for existence of various libraries
+
+## OS-specific test for dirent, opendir.
+case "$canonical_host_type" in
+  *-*-mingw*)
+    if test "$have_msvc" = "yes"; then
+      AC_CHECK_LIB(dirent, opendir)
+      LIBS="$LIBS -ladvapi32 -lgdi32 -lws2_32 -luser32 -lkernel32"
+    else
+      LIBS="$LIBS -lgdi32 -lws2_32 -luser32 -lkernel32"
+    fi
+    LIBS="$LIBS -lgdi32 -lws2_32 -luser32 -lkernel32"
+  ;;
+  *-*-msdosmsvc*)
+    AC_CHECK_LIB(dirent, opendir)
+    LIBS="$LIBS -ladvapi32 -lgdi32 -lws2_32 -luser32 -lkernel32"
+  ;;
+esac
+
+## Find a termlib to use.
+octave_found_termlib=no
+for termlib in ncurses curses termcap terminfo termlib; do
+  AC_CHECK_LIB(${termlib}, tputs, [
+    TERM_LIBS="-l${termlib}"
+    octave_found_termlib=yes
+    break])
+done
+
+if test "$octave_found_termlib" = no; then
+  warn_termlibs="I couldn't find -ltermcap, -lterminfo, -lncurses, -lcurses, o\
+r -ltermlib!"
+  AC_MSG_WARN([$warn_termlibs])
+fi
+AC_SUBST(TERM_LIBS)
+
+### Checks for header files.
+
+AC_HEADER_DIRENT
+AC_HEADER_SYS_WAIT
+
+dnl FIXME: We should probably only generate this file if it is missing.
+### Produce unistd.h for MSVC target, this simplifies changes in
+### Octave source tree and avoid problems with lex-generated code.
+case "$canonical_host_type" in
+  *-*-msdosmsvc)
+    AC_MSG_NOTICE([Generating replacement for <unistd.h> for MSVC])
+    cat << \EOF > unistd.h
+/* File generated by configure script. */
+#include <direct.h>
+#include <io.h>
+#include <process.h>
+EOF
+    CPPFLAGS="-I. $CPPFLAGS"
+    ;;
+esac
+
+## C headers
+
+AC_CHECK_HEADERS(curses.h direct.h dlfcn.h floatingpoint.h grp.h \
+  ieeefp.h inttypes.h locale.h memory.h ncurses.h poll.h pthread.h \
+  pwd.h sunmath.h sys/ioctl.h sys/param.h sys/poll.h sys/resource.h \
+  sys/select.h sys/utsname.h termcap.h)
+
+## C++ headers
+
+AC_LANG_PUSH(C++)
+AC_CHECK_HEADERS(sstream)
+AC_CHECK_HEADERS([unordered_map], [], [
+  AC_CHECK_HEADERS([tr1/unordered_map])])
+AC_MSG_CHECKING([whether unordered_map requires tr1 namespace])
+unordered_map_requires_tr1_namespace=no
+if test "$ac_cv_header_unordered_map" = "yes"; then
+  ## Have <unordered_map>, but still have to check whether
+  ## tr1 namespace is required (like MSVC, for instance).
+  AC_COMPILE_IFELSE([
+    AC_LANG_PROGRAM([
+      #include <unordered_map>
+    ], [
+      std::unordered_map<int,int> m;
+    ])], [], [unordered_map_requires_tr1_namespace=yes])
+elif test "$ac_cv_header_tr1_unordered_map" = "yes"; then
+  unordered_map_requires_tr1_namespace=yes
+fi
+if test "$unordered_map_requires_tr1_namespace" = "yes"; then
+  AC_DEFINE(USE_UNORDERED_MAP_WITH_TR1, 1, [Define to 1 if unordered_map requires the use of tr1 namespace.])
+fi
+AC_MSG_RESULT([$unordered_map_requires_tr1_namespace])
+AC_LANG_POP(C++)
+
+## Find a termio header to include.
+
+have_termios_h=no
+AC_CHECK_HEADERS(termios.h, have_termios_h=yes)
+AC_CHECK_HEADERS(termio.h, have_termio_h=yes, have_termio_h=no)
+AC_CHECK_HEADERS(sgtty.h, have_sgtty_h=yes, have_sgtty_h=no)
+AC_CHECK_HEADERS(fnmatch.h, have_fnmatch_h=yes, have_fnmatch_h=no)
+AC_CHECK_HEADERS(conio.h, have_conio_h=yes, have_conio_h=no)
+
+if test "$have_termios_h" = yes \
+    || test "$have_termio_h" = yes \
+    || test "$have_sgtty_h" = yes; then
+  true
+else
+  AC_MSG_WARN([I couldn't find termios.h, termio.h, or sgtty.h!])
+fi
+
+## For MSVC compilers, avoid #define of min/max from windows.h header
+if test "$have_msvc" = "yes"; then
+  AC_DEFINE(NOMINMAX, 1, [Define to 1 if you want to avoid min/max macro definition in Windows headers.])
+fi
+
+### Determine types and size of types.
+
+AC_TYPE_MODE_T
+AC_TYPE_OFF_T
+AC_TYPE_PID_T
+AC_TYPE_SIZE_T
+AC_TYPE_UID_T
+AC_CHECK_TYPES([dev_t, ino_t])
+AC_CHECK_TYPES([long long int, unsigned long long int])
+
+## How big are ints and how are they oriented?
+## These could probably be eliminated in favor of run-time checks.
+
+AC_CHECK_SIZEOF(short)
+AC_CHECK_SIZEOF(int)
+AC_CHECK_SIZEOF(long)
+AC_CHECK_SIZEOF(long long)
+## Check for long double type (for 64-bit integers)
+AC_CHECK_SIZEOF(long double)
+
+### Check structures and existence of necessary members
+
+AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_blocks, struct stat.st_rdev, struct group.gr_passwd])
+#AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_blocks, struct stat.st_rdev])
+#AC_CHECK_MEMBERS(struct group.gr_passwd)
+#AC_CHECK_MEMBERS(struct group.gr_passwd)
+
+AC_STRUCT_TIMEZONE
+
+### Check compiler characteristics.
+
+## Does compiler have support for new friend template declarations?
+OCTAVE_CXX_NEW_FRIEND_TEMPLATE_DECL
+
+## Does reinterpret_cast fail for function pointers?
+OCTAVE_CXX_BROKEN_REINTERPRET_CAST
+
+## Check if C++ compiler allows placement delete.
+OCTAVE_PLACEMENT_DELETE
+
+## Check if C++ compiler can auto allocate variable sized arrays.
+OCTAVE_DYNAMIC_AUTO_ARRAYS
+
+## Check that C compiler and libraries support IEEE754 data format.
+OCTAVE_IEEE754_DATA_FORMAT
+
+## Is C++ runtime library ISO compliant?
+OCTAVE_CXX_ISO_COMPLIANT_LIBRARY
+
+## Are bit_and, bit_or, and bit_xor defined as templated operators?
+OCTAVE_CXX_BITWISE_OP_TEMPLATES
+
+## Can complex class set components independently?
+OCTAVE_CXX_COMPLEX_SETTERS
+
+## Are there functions to access real/imag parts of numbers via references?
+OCTAVE_CXX_COMPLEX_REFERENCE_ACCESSORS
+
+## Check if fast integer arithmetics based on bit tricks is available.
+OCTAVE_FAST_INT_OPS
+
+## Does the C compiler handle alloca() and const correctly?
+AC_FUNC_ALLOCA
+
+### Checks for functions and variables.
+
+AC_CHECK_FUNCS(basename canonicalize_file_name \
+  chmod dup2 endgrent endpwent execvp expm1 expm1f fork \
+  getegid geteuid getgid getgrent getgrgid getgrnam getpgrp getpid \
+  getppid getpwent getpwuid getuid getwd _kbhit kill \
+  lgamma lgammaf lgamma_r lgammaf_r localtime_r log1p log1pf \
+  mkstemp pipe putenv \
+  realpath resolvepath rindex roundl select setgrent setlocale \
+  setpwent setvbuf siglongjmp \
+  strsignal tempnam tgammaf umask \
+  uname utime waitpid \
+  _chmod x_utime _utime32)
+
+## exp2, round, tgamma function checks
+AC_LANG_PUSH(C++)
+AC_CHECK_DECLS([exp2, round, tgamma], [], [], [[#include <cmath>]])
+AC_CHECK_FUNCS([exp2 round tgamma])
+AH_VERBATIM([Z_FUNCS_AND_DECLS], [
+#if defined (__cplusplus)
+extern "C" {
+#endif
+#if HAVE_EXP2 && ! HAVE_DECL_EXP2
+double exp2 (double);
+#endif
+#if HAVE_ROUND && ! HAVE_DECL_ROUND
+double round (double);
+#endif
+#if HAVE_TGAMMA && ! HAVE_DECL_TGAMMA
+double tgamma (double);
+#endif
+#if defined (__cplusplus)
+}
+#endif
+])
+AC_LANG_POP(C++)
+
+## Look in <cmath> for the IEEE functions isnan, isinf, isfinite that we need.
 
 OCTAVE_CMATH_FUNC(isnan)
 OCTAVE_CMATH_FUNC(isinf)
@@ -1962,36 +1946,73 @@
   ;;
 esac
 
-### Check for nonstandard but common math functions that we need.
+## Check for nonstandard, but common math functions, that we need.
 
 AC_CHECK_FUNCS(acosh acoshf asinh asinhf atanh atanhf erf erff erfc erfcf exp2f log2 log2f)
 AC_CHECK_FUNCS(hypotf _hypotf cbrt cbrtf)
 
-### Checks for OS specific cruft.
+## MinGW exception for mkstemp
+case "$canonical_host_type" in
+  *-*-mingw*)
+    ## MinGW does not provide a mkstemp function.  However, it provides
+    ## the mkstemps function in libiberty.
+    AC_MSG_CHECKING([for mkstemps in libiberty])
+    save_LIBS="$LIBS"
+    LIBS="-liberty $LIBS"
+    AC_LINK_IFELSE([
+      AC_LANG_PROGRAM([[int mkstemps (char *pattern, int suffix_len);]], 
+       [[mkstemps ("XXXXXX", 0);]]
+    )],
+    [AC_MSG_RESULT(yes)
+     HAVE_MKSTEMPS=yes
+     AC_DEFINE(HAVE_MKSTEMPS, 1, [Define to 1 if mkstemps is available in libiberty.])
+    ],
+    [AC_MSG_RESULT(no)
+     HAVE_MKSTEMPS=no
+     LIBS="$save_LIBS"
+    ])
+   ;;
+esac
 
-AC_CHECK_MEMBERS([struct stat.st_blksize, struct stat.st_blocks, struct stat.st_rdev])
+## Windows-specific tests for extra #defines
+case "$canonical_host_type" in
+  *-*-msdosmsvc | *-*-mingw*)
+    AC_MSG_CHECKING([for required _WIN32_WINNT])
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[
+#include <windows.h>
+#if _WIN32_WINNT < 0x0403
+#error "Wrong version"
+#endif]], [])],
+      AC_MSG_RESULT([none]), [
+        AC_DEFINE(_WIN32_WINNT, 0x0403, [Define to 0x0403 to access InitializeCriticalSectionAndSpinCount.])
+        AC_MSG_RESULT([0x0403])])
+    AC_MSG_CHECKING([whether _USE_MATH_DEFINES needs to be defined])
+    AC_COMPILE_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]],
+[[int x = M_LN2;]])],
+      AC_MSG_RESULT([no]), [
+        AC_DEFINE(_USE_MATH_DEFINES, 1, [Define to 1 if your system needs to define math constants like M_LN2.])
+        AC_MSG_RESULT([yes])])
+  ;;
+esac
 
-AC_STRUCT_TIMEZONE
+## Cygwin kluge for getrusage.
+AC_CHECK_FUNCS(getrusage)
+case "$canonical_host_type" in
+  *-*-cygwin*)
+    AC_DEFINE(RUSAGE_TIMES_ONLY, 1, [Define to 1 if your struct rusage only has time information.])
+  ;;
+esac
+
+## Check for CGDisplayBitsPerPixel function on Mac OSX systems with Carbon
+OCTAVE_CARBON_CGDISPLAYBITSPERPIXEL
+
+OCTAVE_SMART_PUTENV
+
+AC_CHECK_FUNCS(getpwnam, [], [AC_CHECK_LIB(sun, getpwnam)])
+
 AC_FUNC_CLOSEDIR_VOID
 
-AC_CHECK_MEMBERS(struct group.gr_passwd)
-
-octave_found_termlib=no
-for termlib in ncurses curses termcap terminfo termlib; do
-  AC_CHECK_LIB(${termlib}, tputs, [
-    TERM_LIBS="-l${termlib}"
-    octave_found_termlib=yes
-    break])
-done
-
-if test "$octave_found_termlib" = no; then
-  warn_termlibs="I couldn't find -ltermcap, -lterminfo, -lncurses, -lcurses, o\
-r -ltermlib!"
-  AC_MSG_WARN([$warn_termlibs])
-fi
-AC_SUBST(TERM_LIBS)
-
-### Return type of matherr() 
+## Return type of matherr() 
 AC_MSG_CHECKING([for struct exception in math.h])
 AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <math.h>]],
   [[struct exception *x; x->type; x->name;]])],
@@ -2000,7 +2021,7 @@
      [Define to 1 if your math.h declares struct exception for matherr().])],
   [AC_MSG_RESULT(no)])
 
-### Signal stuff.
+## Signal stuff.
 
 AC_CHECK_DECLS([sys_siglist], [], [],
 [#include <signal.h>
@@ -2010,15 +2031,6 @@
 #endif
 ])
 
-### A system dependent kludge or two.
-
-AC_CHECK_FUNCS(getrusage)
-case "$canonical_host_type" in
-  *-*-cygwin*)
-    AC_DEFINE(RUSAGE_TIMES_ONLY, 1, [Define to 1 if your struct rusage only has time information.])
-  ;;
-esac
-
 ### Checks for other programs used in building, testing, installing, and
 ### running Octave.