diff options
-rw-r--r-- | NEWS | 13 | ||||
-rw-r--r-- | README | 41 | ||||
-rw-r--r-- | configure.ac | 31 | ||||
-rw-r--r-- | m4/gssapi.m4 | 101 | ||||
-rw-r--r-- | m4/krb5.m4 | 164 | ||||
-rw-r--r-- | m4/lib-depends.m4 | 4 | ||||
-rw-r--r-- | m4/lib-pathname.m4 | 55 | ||||
-rw-r--r-- | m4/remctl.m4 | 79 | ||||
-rw-r--r-- | m4/snprintf.m4 | 17 | ||||
-rw-r--r-- | m4/vamacros.m4 | 55 | ||||
-rw-r--r-- | portable/snprintf.c | 7 |
11 files changed, 368 insertions, 199 deletions
@@ -50,6 +50,19 @@ wallet 0.10 (unreleased) implementation than the wallet client. This primarily helps with testing. + Update to rra-c-util 3.0: + + * Sanity-check the results of krb5-config before proceeding. + * Fall back on manual probing if krb5-config results don't work. + * Add --with-krb5-include and --with-krb5-lib configure options. + * Add --with-remctl-include and --with-remctl-lib configure options. + * Add --with-gssapi-include and --with-gssapi-lib configure options. + * Don't break if the user clobbers CPPFLAGS at build time. + * Suppress error output from krb5-config probes. + * Prefer KRB5_CONFIG over a path constructed from --with-*. + * Update GSS-API probes for Solaris 10's native implementation. + * Change AC_TRY_* to AC_*_IFELSE as recommended by Autoconf. + wallet 0.9 (2008-04-24) The wallet command-line client now reads the data for store from a @@ -3,9 +3,10 @@ Written by Russ Allbery <rra@stanford.edu> - Copyright 2006, 2007, 2008 Board of Trustees, Leland Stanford Jr. - University. This software is distributed under a BSD-style license. - Please see the file LICENSE in the distribution for more information. + Copyright 2006, 2007, 2008, 2009, 2010 Board of Trustees, Leland + Stanford Jr. University. This software is distributed under a BSD-style + license. Please see the file LICENSE in the distribution for more + information. This software is beta-quality and should be treated with caution. It is currently being tested for production deployment at Stanford. @@ -159,9 +160,9 @@ BUILD AND INSTALLATION If remctl was installed in a path not normally searched by your compiler, you must specify its installation prefix to configure with the - --with-remctl=DIR option. If the GSS-API libraries used by remctl - aren't in a path normally searched by your compiler, you must generally - also specify its installation prefix with the --with-gssapi=DIR option. + --with-remctl=DIR option, or alternately set the path to the include + files and libraries separately with --with-remctl-include=DIR and + --with-remctl-lib=DIR. Normally, configure will use krb5-config to determine the flags to use to compile with your Kerberos libraries. If krb5-config isn't found, it @@ -170,9 +171,16 @@ BUILD AND INSTALLATION path is not the one corresponding to the Kerberos libraries you want to use or if your Kerberos libraries and includes aren't in a location searched by default by your compiler, you need to specify - --with-krb5=PATH: + --with-krb5=PATH and --with-gssapi=PATH: - ./configure --with-krb5=/usr/pubsw + ./configure --with-krb5=/usr/pubsw --with-gssapi=/usr/pubsw + + You can also individually set the paths to the include directory and the + library directory with --with-krb5-include, --with-krb5-lib, + --with-gssapi-include, and --with-gssapi-lib. You may need to do this + if Autoconf can't figure out whether to use lib, lib32, or lib64 on your + platform. Note that these settings aren't used if a krb5-config script + is found. To specify a particular krb5-config script to use, either set the KRB5_CONFIG environment variable or pass it to configure like: @@ -184,18 +192,6 @@ BUILD AND INSTALLATION ./configure KRB5_CONFIG=/nonexistent - To build with AFS kaserver synchronization support, pass --with-kaserver - to configure. You may need to include the path to the AFS include files - and libraries, such as: - - ./configure --with-kaserver=/usr/afsws - - The AFS kaserver support also requires Kerberos v4 libraries and tries - to use krb5-config to find such libraries. If your Kerberos v4 - libraries aren't somewhere found by your compiler and the krb5-config - script doesn't produce correct results, you need to specify - --with-krb4=PATH giving the root path of the Kerberos v4 installation. - You can build wallet in a different directory from the source if you wish. To do this, create a new empty directory, cd to that directory, and then give the path to configure when running configure. Everything @@ -228,10 +224,7 @@ TESTING perl/t/data/README and follow the instructions in those files to enable the full test - suite. Note that testing the AFS kaserver requires creating a srvtab - with ADMIN access to a running AFS kaserver; if you don't care about AFS - kaserver synchronization, you may want to skip that part of the test - suite configuration. + suite. The test suite also requires some additional software be installed that isn't otherwise used by the wallet. See REQUIREMENTS above for the full diff --git a/configure.ac b/configure.ac index 8d00229..78fecea 100644 --- a/configure.ac +++ b/configure.ac @@ -1,32 +1,40 @@ -dnl Process this file with Autoconf to produce a configure script. +dnl Autoconf configuration for wallet. dnl dnl Written by Russ Allbery <rra@stanford.edu> -dnl Copyright 2006, 2007, 2008 +dnl Copyright 2006, 2007, 2008, 2010 dnl Board of Trustees, Leland Stanford Jr. University dnl dnl See LICENSE for licensing terms. -AC_REVISION([$Revision$]) -AC_PREREQ([2.61]) +dnl We cannot use -Wall -Werror with AM_INIT_AUTOMAKE since we override +dnl distuninstallcheck (not supported by Perl). +AC_PREREQ([2.64]) AC_INIT([wallet], [0.9], [rra@stanford.edu]) AC_CONFIG_AUX_DIR([build-aux]) AC_CONFIG_LIBOBJ_DIR([portable]) -AM_INIT_AUTOMAKE([1.10]) +AC_CONFIG_MACRO_DIR([m4]) +AM_INIT_AUTOMAKE([1.11 check-news]) AM_MAINTAINER_MODE AC_PROG_CC +AC_USE_SYSTEM_EXTENSIONS AM_PROG_CC_C_O AC_PROG_INSTALL AC_PROG_RANLIB -AC_AIX -AC_GNU_SOURCE + +RRA_LIB_REMCTL +RRA_LIB_KRB5 +RRA_LIB_KRB5_SWITCH +AC_CHECK_FUNCS([krb5_kt_free_entry]) +AC_CHECK_MEMBERS([krb5_keytab_entry.keyblock], , , [#include <krb5.h>]) +RRA_LIB_KRB5_RESTORE AC_HEADER_STDBOOL AC_CHECK_HEADERS([sys/bitypes.h syslog.h]) AC_CHECK_DECLS([snprintf, vsnprintf]) RRA_C_C99_VAMACROS RRA_C_GNU_VAMACROS -AC_CHECK_TYPES([long long]) +AC_TYPE_LONG_LONG_INT RRA_FUNC_SNPRINTF AC_CHECK_FUNCS([setrlimit]) AC_REPLACE_FUNCS([asprintf strlcat strlcpy]) @@ -43,13 +51,6 @@ AC_ARG_WITH([wallet-port], [AC_DEFINE_UNQUOTED([WALLET_PORT], [$withval], [Define to the default server port.])])]) -RRA_LIB_REMCTL -RRA_LIB_KRB5 -RRA_LIB_KRB5_SWITCH -AC_CHECK_FUNCS([krb5_kt_free_entry]) -AC_CHECK_MEMBERS([krb5_keytab_entry.keyblock], , , [#include <krb5.h>]) -RRA_LIB_KRB5_RESTORE - AC_ARG_VAR([REMCTLD], [Path to the remctld binary]) AC_PATH_PROG([REMCTLD], [remctld], , [$PATH:/usr/sbin:/usr/local/sbin]) AS_IF([test x"$REMCTLD" != x], diff --git a/m4/gssapi.m4 b/m4/gssapi.m4 index a352e38..4b08569 100644 --- a/m4/gssapi.m4 +++ b/m4/gssapi.m4 @@ -1,30 +1,24 @@ -dnl gssapi.m4 -- Find the compiler and linker flags for GSS-API. +dnl Find the compiler and linker flags for GSS-API. dnl -dnl Finds the compiler and linker flags for linking with GSS-API libraries -dnl and sets the substitution variables GSSAPI_CPPFLAGS, GSSAPI_LDFLAGS, and -dnl GSSAPI_LIBS. Provides the --with-gssapi configure option to specify a -dnl non-standard path to the GSS-API libraries. Uses krb5-config where -dnl available unless reduced dependencies is requested. +dnl Finds the compiler and linker flags for linking with GSS-API libraries. +dnl Provides the --with-gssapi, --with-gssapi-include, and --with-gssapi-lib +dnl configure option to specify a non-standard path to the GSS-API libraries. +dnl Uses krb5-config where available unless reduced dependencies is requested. dnl dnl Provides the macro RRA_LIB_GSSAPI and sets the substitution variables dnl GSSAPI_CPPFLAGS, GSSAPI_LDFLAGS, and GSSAPI_LIBS. Also provides -dnl RRA_LIB_GSSAPI_SET to set CPPFLAGS, LDFLAGS, and LIBS to include the -dnl GSS-API libraries; RRA_LIB_GSSAPI_SWITCH to do the same but save the -dnl current values first; and RRA_LIB_GSSAPI_RESTORE to restore those settings -dnl to before the last RRA_LIB_GSSAPI_SWITCH. +dnl RRA_LIB_GSSAPI_SWITCH to set CPPFLAGS, LDFLAGS, and LIBS to include the +dnl GSS-API libraries, saving the ecurrent values, and RRA_LIB_GSSAPI_RESTORE +dnl to restore those settings to before the last RRA_LIB_GSSAPI_SWITCH. +dnl +dnl Depends on RRA_ENABLE_REDUCED_DEPENDS and RRA_SET_LDFLAGS. dnl dnl Written by Russ Allbery <rra@stanford.edu> -dnl Copyright 2005, 2006, 2007, 2008 +dnl Copyright 2005, 2006, 2007, 2008, 2009 dnl Board of Trustees, Leland Stanford Jr. University dnl dnl See LICENSE for licensing terms. -dnl Set CPPFLAGS, LDFLAGS, and LIBS to values including the GSS-API settings. -AC_DEFUN([RRA_LIB_GSSAPI_SET], -[CPPFLAGS="$GSSAPI_CPPFLAGS $CPPFLAGS" - LDFLAGS="$GSSAPI_LDFLAGS $LDFLAGS" - LIBS="$GSSAPI_LIBS $LIBS"]) - dnl Save the current CPPFLAGS, LDFLAGS, and LIBS settings and switch to dnl versions that include the GSS-API flags. Used as a wrapper, with dnl RRA_LIB_GSSAPI_RESTORE, around tests. @@ -32,7 +26,9 @@ AC_DEFUN([RRA_LIB_GSSAPI_SWITCH], [rra_gssapi_save_CPPFLAGS="$CPPFLAGS" rra_gssapi_save_LDFLAGS="$LDFLAGS" rra_gssapi_save_LIBS="$LIBS" - RRA_LIB_GSSAPI_SET]) + CPPFLAGS="$GSSAPI_CPPFLAGS $CPPFLAGS" + LDFLAGS="$GSSAPI_LDFLAGS $LDFLAGS" + LIBS="$GSSAPI_LIBS $LIBS"]) dnl Restore CPPFLAGS, LDFLAGS, and LIBS to their previous values (before dnl RRA_LIB_GSSAPI_SWITCH was called). @@ -41,12 +37,18 @@ AC_DEFUN([RRA_LIB_GSSAPI_RESTORE], LDFLAGS="$rra_gssapi_save_LDFLAGS" LIBS="$rra_gssapi_save_LIBS"]) -dnl Set GSSAPI_CPPFLAGS and GSSAPI_LDFLAGS based on rra_gssapi_root. +dnl Set GSSAPI_CPPFLAGS and GSSAPI_LDFLAGS based on rra_gssapi_root, +dnl rra_gssapi_libdir, and rra_gssapi_includedir. AC_DEFUN([_RRA_LIB_GSSAPI_PATHS], -[AS_IF([test x"$rra_gssapi_root" != x], - [AS_IF([test x"$rra_gssapi_root" != x/usr], - [GSSAPI_CPPFLAGS="-I${rra_gssapi_root}/include"]) - GSSAPI_LDFLAGS="-L${rra_gssapi_root}/lib"])]) +[AS_IF([test x"$rra_gssapi_libdir" != x], + [GSSAPI_LDFLAGS="-L$rra_gssapi_libdir"], + [AS_IF([test x"$rra_gssapi_root" != x], + [RRA_SET_LDFLAGS([GSSAPI_LDFLAGS], [$rra_gssapi_root])])]) + AS_IF([test x"$rra_gssapi_includedir" != x], + [GSSAPI_CPPFLAGS="-I$rra_gssapi_includedir"], + [AS_IF([test x"$rra_gssapi_root" != x], + [AS_IF([test x"$rra_gssapi_root" != x/usr], + [GSSAPI_CPPFLAGS="-I${rra_gssapi_root}/include"])])])]) dnl Does the appropriate library checks for reduced-dependency GSS-API dnl linkage. @@ -54,10 +56,13 @@ AC_DEFUN([_RRA_LIB_GSSAPI_REDUCED], [RRA_LIB_GSSAPI_SWITCH AC_CHECK_LIB([gssapi_krb5], [gss_import_name], [GSSAPI_LIBS="-lgssapi_krb5"], [AC_CHECK_LIB([gssapi], [gss_import_name], [GSSAPI_LIBS="-lgssapi"], - [AC_MSG_ERROR([cannot find usable GSS-API library])])])]) + [AC_CHECK_LIB([gss], [gss_import_name], [GSSAPI_LIBS="-lgss"], + [AC_MSG_ERROR([cannot find usable GSS-API library])])])])]) dnl Does the appropriate library checks for GSS-API linkage when we don't -dnl have krb5-config or reduced dependencies. +dnl have krb5-config or reduced dependencies. libgss is used as a last +dnl resort, since it may be a non-functional mech-independent wrapper, but +dnl it's the right choice on Solaris 10. AC_DEFUN([_RRA_LIB_GSSAPI_MANUAL], [RRA_LIB_GSSAPI_SWITCH rra_gssapi_extra= @@ -91,53 +96,73 @@ AC_DEFUN([_RRA_LIB_GSSAPI_MANUAL], rra_gssapi_extra="-lkrb5 $rra_gssapi_extra" AC_CHECK_LIB([gssapi_krb5], [gss_import_name], [GSSAPI_LIBS="-lgssapi_krb5 $rra_gssapi_extra"], - [AC_MSG_ERROR([cannot find usable GSS-API library])], + [AC_CHECK_LIB([gss], [gss_import_name], + [GSSAPI_LIBS="-lgss"], + [AC_MSG_ERROR([cannot find usable GSS-API library])])], [$rra_gssapi_extra])], [-lkrb5 -lasn1 -lroken -lcrypto -lcom_err $rra_gssapi_extra]) RRA_LIB_GSSAPI_RESTORE]) dnl Sanity-check the results of krb5-config and be sure we can really link a -dnl GSS-API program. +dnl GSS-API program. If not, fall back on the manual check. AC_DEFUN([_RRA_LIB_GSSAPI_CHECK], [RRA_LIB_GSSAPI_SWITCH - AC_CHECK_FUNC([gss_import_name], , - [AC_MSG_FAILURE([krb5-config results fail for GSS-API])]) - RRA_LIB_GSSAPI_RESTORE]) + AC_CHECK_FUNC([gss_import_name], + [RRA_LIB_GSSAPI_RESTORE], + [RRA_LIB_GSSAPI_RESTORE + GSSAPI_CPPFLAGS= + GSSAPI_LIBS= + _RRA_LIB_GSSAPI_PATHS + _RRA_LIB_GSSAPI_MANUAL])]) dnl The main macro. AC_DEFUN([RRA_LIB_GSSAPI], [AC_REQUIRE([RRA_ENABLE_REDUCED_DEPENDS]) rra_gssapi_root= + rra_gssapi_libdir= + rra_gssapi_includedir= GSSAPI_CPPFLAGS= GSSAPI_LDFLAGS= GSSAPI_LIBS= AC_SUBST([GSSAPI_CPPFLAGS]) AC_SUBST([GSSAPI_LDFLAGS]) AC_SUBST([GSSAPI_LIBS]) + AC_ARG_WITH([gssapi], - [AC_HELP_STRING([--with-gssapi=DIR], + [AS_HELP_STRING([--with-gssapi=DIR], [Location of GSS-API headers and libraries])], [AS_IF([test x"$withval" != xyes && test x"$withval" != xno], [rra_gssapi_root="$withval"])]) + AC_ARG_WITH([gssapi-include], + [AS_HELP_STRING([--with-gssapi-include=DIR], + [Location of GSS-API headers])], + [AS_IF([test x"$withval" != xyes && test x"$withval" != xno], + [rra_gssapi_includedir="$withval"])]) + AC_ARG_WITH([gssapi-lib], + [AS_HELP_STRING([--with-gssapi-lib=DIR], + [Location of GSS-API libraries])], + [AS_IF([test x"$withval" != xyes && test x"$withval" != xno], + [rra_gssapi_libdir="$withval"])]) + AS_IF([test x"$rra_reduced_depends" = xtrue], [_RRA_LIB_GSSAPI_PATHS _RRA_LIB_GSSAPI_REDUCED], [AC_ARG_VAR([KRB5_CONFIG], [Path to krb5-config]) - AS_IF([test x"$rra_gssapi_root" != x], + AS_IF([test x"$rra_gssapi_root" != x && test -z "$KRB5_CONFIG"], [AS_IF([test -x "${rra_gssapi_root}/bin/krb5-config"], [KRB5_CONFIG="${rra_gssapi_root}/bin/krb5-config"])], [AC_PATH_PROG([KRB5_CONFIG], [krb5-config])]) - AS_IF([test x"$KRB5_CONFIG" != x], + AS_IF([test x"$KRB5_CONFIG" != x && test -x "$KRB5_CONFIG"], [AC_CACHE_CHECK([for gssapi support in krb5-config], [rra_cv_lib_gssapi_config], - [AS_IF(["$KRB5_CONFIG" | grep gssapi > /dev/null 2>&1], + [AS_IF(["$KRB5_CONFIG" 2>&1 | grep gssapi >/dev/null 2>&1], [rra_cv_lib_gssapi_config=yes], [rra_cv_lib_gssapi_config=no])]) AS_IF([test "$rra_cv_lib_gssapi_config" = yes], - [GSSAPI_CPPFLAGS=`"$KRB5_CONFIG" --cflags gssapi` - GSSAPI_LIBS=`"$KRB5_CONFIG" --libs gssapi`], - [GSSAPI_CPPFLAGS=`"$KRB5_CONFIG" --cflags` - GSSAPI_LIBS=`"$KRB5_CONFIG" --libs`]) + [GSSAPI_CPPFLAGS=`"$KRB5_CONFIG" --cflags gssapi 2>/dev/null` + GSSAPI_LIBS=`"$KRB5_CONFIG" --libs gssapi 2>/dev/null`], + [GSSAPI_CPPFLAGS=`"$KRB5_CONFIG" --cflags 2>/dev/null` + GSSAPI_LIBS=`"$KRB5_CONFIG" --libs 2>/dev/null`]) GSSAPI_CPPFLAGS=`echo "$GSSAPI_CPPFLAGS" \ | sed 's%-I/usr/include ?%%'` _RRA_LIB_GSSAPI_CHECK], @@ -1,41 +1,36 @@ -dnl krb5.m4 -- Find the compiler and linker flags for Kerberos v5. +dnl Find the compiler and linker flags for Kerberos v5. dnl -dnl Finds the compiler and linker flags for linking with Kerberos v5 libraries -dnl and sets the substitution variables KRB5_CPPFLAGS, KRB5_LDFLAGS, and -dnl KRB5_LIBS. Provides the --with-krb5 configure option to specify a -dnl non-standard path to the Kerberos libraries. Uses krb5-config where -dnl available unless reduced dependencies is requested. -dnl -dnl Sets an Automake conditional saying whether we use com_err, since if we're -dnl also linking with AFS libraries, we may have to change library ordering in -dnl that case. +dnl Finds the compiler and linker flags for linking with Kerberos v5 +dnl libraries. Provides the --with-krb5, --with-krb5-include, and +dnl --with-krb5-lib configure options to specify non-standards paths to the +dnl Kerberos libraries. Uses krb5-config where available unless reduced +dnl dependencies is requested. dnl dnl Provides the macro RRA_LIB_KRB5 and sets the substitution variables dnl KRB5_CPPFLAGS, KRB5_LDFLAGS, and KRB5_LIBS. Also provides -dnl RRA_LIB_KRB5_SET to set CPPFLAGS, LDFLAGS, and LIBS to include the -dnl Kerberos libraries; RRA_LIB_KRB5_SWITCH to do the same but save the -dnl current values first; and RRA_LIB_KRB5_RESTORE to restore those settings -dnl to before the last RRA_LIB_KRB5_SWITCH. +dnl RRA_LIB_KRB5_SWITCH to set CPPFLAGS, LDFLAGS, and LIBS to include the +dnl Kerberos libraries, saving the current values first, and +dnl RRA_LIB_KRB5_RESTORE to restore those settings to before the last +dnl RRA_LIB_KRB5_SWITCH. dnl -dnl Also provides the RRA_LIB_KRB5_OPTIONAL macro, which should be used if -dnl Kerberos support is optional. This macro will still always set the -dnl substitution variables, but they'll be empty unless --with-krb5 is used. -dnl Also, HAVE_KERBEROS will be defined if --with-krb5 is given and +dnl Provides the RRA_LIB_KRB5_OPTIONAL macro, which should be used if Kerberos +dnl support is optional. This macro will still always set the substitution +dnl variables, but they'll be empty unless --with-krb5 is given. Also, +dnl HAVE_KERBEROS will be defined if --with-krb5 is given and dnl $rra_use_kerberos will be set to "true". dnl +dnl Sets the Automake conditional KRB5_USES_COM_ERR saying whether we use +dnl com_err, since if we're also linking with AFS libraries, we may have to +dnl change library ordering in that case. +dnl +dnl Depends on RRA_ENABLE_REDUCED_DEPENDS and RRA_SET_LDFLAGS. +dnl dnl Written by Russ Allbery <rra@stanford.edu> -dnl Copyright 2005, 2006, 2007, 2008 +dnl Copyright 2005, 2006, 2007, 2008, 2009 dnl Board of Trustees, Leland Stanford Jr. University dnl dnl See LICENSE for licensing terms. -dnl Set CPPFLAGS, LDFLAGS, and LIBS to values including the Kerberos v5 -dnl settings. -AC_DEFUN([RRA_LIB_KRB5_SET], -[CPPFLAGS="$KRB5_CPPFLAGS $CPPFLAGS" - LDFLAGS="$KRB5_LDFLAGS $LDFLAGS" - LIBS="$KRB5_LIBS $LIBS"]) - dnl Save the current CPPFLAGS, LDFLAGS, and LIBS settings and switch to dnl versions that include the Kerberos v5 flags. Used as a wrapper, with dnl RRA_LIB_KRB5_RESTORE, around tests. @@ -43,7 +38,9 @@ AC_DEFUN([RRA_LIB_KRB5_SWITCH], [rra_krb5_save_CPPFLAGS="$CPPFLAGS" rra_krb5_save_LDFLAGS="$LDFLAGS" rra_krb5_save_LIBS="$LIBS" - RRA_LIB_KRB5_SET]) + CPPFLAGS="$KRB5_CPPFLAGS $CPPFLAGS" + LDFLAGS="$KRB5_LDFLAGS $LDFLAGS" + LIBS="$KRB5_LIBS $LIBS"]) dnl Restore CPPFLAGS, LDFLAGS, and LIBS to their previous values (before dnl RRA_LIB_KRB5_SWITCH was called). @@ -52,12 +49,18 @@ AC_DEFUN([RRA_LIB_KRB5_RESTORE], LDFLAGS="$rra_krb5_save_LDFLAGS" LIBS="$rra_krb5_save_LIBS"]) -dnl Set KRB5_CPPFLAGS and KRB5_LDFLAGS based on rra_krb5_root. +dnl Set KRB5_CPPFLAGS and KRB5_LDFLAGS based on rra_krb5_root, +dnl rra_krb5_libdir, and rra_krb5_includedir. AC_DEFUN([_RRA_LIB_KRB5_PATHS], -[AS_IF([test x"$rra_krb5_root" != x], - [AS_IF([test x"$rra_krb5_root" != x/usr], - [KRB5_CPPFLAGS="-I${rra_krb5_root}/include"]) - KRB5_LDFLAGS="-L${rra_krb5_root}/lib"])]) +[AS_IF([test x"$rra_krb5_libdir" != x], + [KRB5_LDFLAGS="-L$rra_krb5_libdir"], + [AS_IF([test x"$rra_krb5_root" != x], + [RRA_SET_LDFLAGS([KRB5_LDFLAGS], [$rra_krb5_root])])]) + AS_IF([test x"$rra_krb5_includedir" != x], + [KRB5_CPPFLAGS="-I$rra_krb5_includedir"], + [AS_IF([test x"$rra_krb5_root" != x], + [AS_IF([test x"$rra_krb5_root" != x/usr], + [KRB5_CPPFLAGS="-I${rra_krb5_root}/include"])])])]) dnl Does the appropriate library checks for reduced-dependency Kerberos v5 dnl linkage. The single argument, if true, says to fail if Kerberos could not @@ -70,15 +73,16 @@ AC_DEFUN([_RRA_LIB_KRB5_REDUCED], LIBS="$KRB5_LIBS $LIBS" AC_CHECK_FUNCS([krb5_get_error_message], [AC_CHECK_FUNCS([krb5_free_error_message])], - [AC_CHECK_FUNCS([krb5_get_err_txt], , - [AC_CHECK_LIB([ksvc], [krb5_svc_get_msg], - [KRB5_LIBS="$KRB5_LIBS -lksvc" - AC_DEFINE([HAVE_KRB5_SVC_GET_MSG], [1]) - AC_CHECK_HEADERS([ibm_svc/krb5_svc.h])], - [AC_CHECK_LIB([com_err], [com_err], - [KRB5_LIBS="$KRB5_LIBS -lcom_err"], - [AC_MSG_ERROR([cannot find usable com_err library])]) - AC_CHECK_HEADERS([et/com_err.h])])])]) + [AC_CHECK_FUNCS([krb5_get_error_string], , + [AC_CHECK_FUNCS([krb5_get_err_txt], , + [AC_CHECK_LIB([ksvc], [krb5_svc_get_msg], + [KRB5_LIBS="$KRB5_LIBS -lksvc" + AC_DEFINE([HAVE_KRB5_SVC_GET_MSG], [1]) + AC_CHECK_HEADERS([ibm_svc/krb5_svc.h])], + [AC_CHECK_LIB([com_err], [com_err], + [KRB5_LIBS="$KRB5_LIBS -lcom_err"], + [AC_MSG_ERROR([cannot find usable com_err library])]) + AC_CHECK_HEADERS([et/com_err.h])])])])]) RRA_LIB_KRB5_RESTORE]) dnl Does the appropriate library checks for Kerberos v5 linkage when we don't @@ -125,24 +129,26 @@ AC_DEFUN([_RRA_LIB_KRB5_MANUAL], LIBS="$KRB5_LIBS $LIBS" AC_CHECK_FUNCS([krb5_get_error_message], [AC_CHECK_FUNCS([krb5_free_error_message])], - [AC_CHECK_FUNCS([krb5_get_err_txt], , - [AC_CHECK_FUNCS([krb5_svc_get_msg], - [AC_CHECK_HEADERS([ibm_svc/krb5_svc.h])], - [AC_CHECK_HEADERS([et/com_err.h])])])]) + [AC_CHECK_FUNCS([krb5_get_error_string], , + [AC_CHECK_FUNCS([krb5_get_err_txt], , + [AC_CHECK_FUNCS([krb5_svc_get_msg], + [AC_CHECK_HEADERS([ibm_svc/krb5_svc.h])], + [AC_CHECK_HEADERS([et/com_err.h])])])])]) RRA_LIB_KRB5_RESTORE]) dnl Sanity-check the results of krb5-config and be sure we can really link a -dnl Kerberos program. The first option says whether to fail if Kerberos was -dnl not found. If we shouldn't fail, clear KRB5_CPPFLAGS and KRB5_LIBS so -dnl that we know we don't have usable flags. +dnl Kerberos program. If that fails, clear KRB5_CPPFLAGS and KRB5_LIBS so +dnl that we know we don't have usable flags and fall back on the manual +dnl check. AC_DEFUN([_RRA_LIB_KRB5_CHECK], [RRA_LIB_KRB5_SWITCH - AC_CHECK_FUNC([krb5_init_context], , - [AS_IF([test x"$1" = xtrue], - [AC_MSG_FAILURE([krb5-config results fail for Kerberos v5])]) + AC_CHECK_FUNC([krb5_init_context], + [RRA_LIB_KRB5_RESTORE], + [RRA_LIB_KRB5_RESTORE KRB5_CPPFLAGS= - KRB5_LIBS=]) - RRA_LIB_KRB5_RESTORE]) + KRB5_LIBS= + _RRA_LIB_KRB5_PATHS + _RRA_LIB_KRB5_MANUAL([$1])])]) dnl The core of the library checking, shared between RRA_LIB_KRB5 and dnl RRA_LIB_KRB5_OPTIONAL. The single argument, if "true", says to fail if @@ -160,23 +166,24 @@ AC_DEFUN([_RRA_LIB_KRB5_INTERNAL], AS_IF([test x"$KRB5_CONFIG" != x && test -x "$KRB5_CONFIG"], [AC_CACHE_CHECK([for krb5 support in krb5-config], [rra_cv_lib_krb5_config], - [AS_IF(["$KRB5_CONFIG" | grep krb5 > /dev/null 2>&1], + [AS_IF(["$KRB5_CONFIG" 2>&1 | grep krb5 >/dev/null 2>&1], [rra_cv_lib_krb5_config=yes], [rra_cv_lib_krb5_config=no])]) - AS_IF([test "$rra_cv_lib_krb5_config" = yes], - [KRB5_CPPFLAGS=`"$KRB5_CONFIG" --cflags krb5` - KRB5_LIBS=`"$KRB5_CONFIG" --libs krb5`], - [KRB5_CPPFLAGS=`"$KRB5_CONFIG" --cflags` - KRB5_LIBS=`"$KRB5_CONFIG" --libs`]) + AS_IF([test x"$rra_cv_lib_krb5_config" = xyes], + [KRB5_CPPFLAGS=`"$KRB5_CONFIG" --cflags krb5 2>/dev/null` + KRB5_LIBS=`"$KRB5_CONFIG" --libs krb5 2>/dev/null`], + [KRB5_CPPFLAGS=`"$KRB5_CONFIG" --cflags 2>/dev/null` + KRB5_LIBS=`"$KRB5_CONFIG" --libs 2>/dev/null`]) KRB5_CPPFLAGS=`echo "$KRB5_CPPFLAGS" | sed 's%-I/usr/include ?%%'` _RRA_LIB_KRB5_CHECK([$1]) RRA_LIB_KRB5_SWITCH AC_CHECK_FUNCS([krb5_get_error_message], [AC_CHECK_FUNCS([krb5_free_error_message])], - [AC_CHECK_FUNCS([krb5_get_err_txt], , - [AC_CHECK_FUNCS([krb5_svc_get_msg], - [AC_CHECK_HEADERS([ibm_svc/krb5_svc.h])], - [AC_CHECK_HEADERS([et/com_err.h])])])]) + [AC_CHECK_FUNCS([krb5_get_error_string], , + [AC_CHECK_FUNCS([krb5_get_err_txt], , + [AC_CHECK_FUNCS([krb5_svc_get_msg], + [AC_CHECK_HEADERS([ibm_svc/krb5_svc.h])], + [AC_CHECK_HEADERS([et/com_err.h])])])])]) RRA_LIB_KRB5_RESTORE], [_RRA_LIB_KRB5_PATHS _RRA_LIB_KRB5_MANUAL([$1])])]) @@ -191,22 +198,37 @@ AC_DEFUN([_RRA_LIB_KRB5_INTERNAL], dnl The main macro for packages with mandatory Kerberos support. AC_DEFUN([RRA_LIB_KRB5], [rra_krb5_root= + rra_krb5_libdir= + rra_krb5_includedir= KRB5_CPPFLAGS= KRB5_LDFLAGS= KRB5_LIBS= AC_SUBST([KRB5_CPPFLAGS]) AC_SUBST([KRB5_LDFLAGS]) AC_SUBST([KRB5_LIBS]) + AC_ARG_WITH([krb5], - [AC_HELP_STRING([--with-krb5=DIR], + [AS_HELP_STRING([--with-krb5=DIR], [Location of Kerberos v5 headers and libraries])], [AS_IF([test x"$withval" != xyes && test x"$withval" != xno], [rra_krb5_root="$withval"])]) + AC_ARG_WITH([krb5-include], + [AS_HELP_STRING([--with-krb5-include=DIR], + [Location of Kerberos v5 headers])], + [AS_IF([test x"$withval" != xyes && test x"$withval" != xno], + [rra_krb5_includedir="$withval"])]) + AC_ARG_WITH([krb5-lib], + [AS_HELP_STRING([--with-krb5-lib=DIR], + [Location of Kerberos v5 libraries])], + [AS_IF([test x"$withval" != xyes && test x"$withval" != xno], + [rra_krb5_libdir="$withval"])]) _RRA_LIB_KRB5_INTERNAL([true])]) dnl The main macro for packages with optional Kerberos support. AC_DEFUN([RRA_LIB_KRB5_OPTIONAL], [rra_krb5_root= + rra_krb5_libdir= + rra_krb5_includedir= rra_use_kerberos= KRB5_CPPFLAGS= KRB5_LDFLAGS= @@ -214,13 +236,25 @@ AC_DEFUN([RRA_LIB_KRB5_OPTIONAL], AC_SUBST([KRB5_CPPFLAGS]) AC_SUBST([KRB5_LDFLAGS]) AC_SUBST([KRB5_LIBS]) + AC_ARG_WITH([krb5], - [AC_HELP_STRING([--with-krb5@<:@=DIR@:>@], + [AS_HELP_STRING([--with-krb5@<:@=DIR@:>@], [Location of Kerberos v5 headers and libraries])], [AS_IF([test x"$withval" = xno], [rra_use_kerberos=false], [AS_IF([test x"$withval" != xyes], [rra_krb5_root="$withval"]) rra_use_kerberos=true])]) + AC_ARG_WITH([krb5-include], + [AS_HELP_STRING([--with-krb5-include=DIR], + [Location of Kerberos v5 headers])], + [AS_IF([test x"$withval" != xyes && test x"$withval" != xno], + [rra_krb5_includedir="$withval"])]) + AC_ARG_WITH([krb5-lib], + [AS_HELP_STRING([--with-krb5-lib=DIR], + [Location of Kerberos v5 libraries])], + [AS_IF([test x"$withval" != xyes && test x"$withval" != xno], + [rra_krb5_libdir="$withval"])]) + AS_IF([test x"$rra_use_kerberos" != xfalse], [AS_IF([test x"$rra_use_kerberos" = xtrue], [_RRA_LIB_KRB5_INTERNAL([true])], diff --git a/m4/lib-depends.m4 b/m4/lib-depends.m4 index 1d7e769..039e245 100644 --- a/m4/lib-depends.m4 +++ b/m4/lib-depends.m4 @@ -1,4 +1,4 @@ -dnl lib-depends.m4 -- Provides option to change library probes. +dnl Provides option to change library probes. dnl dnl This file provides RRA_ENABLE_REDUCED_DEPENDS, which adds the configure dnl option --enable-reduced-depends to request that library probes assume @@ -18,6 +18,6 @@ dnl See LICENSE for licensing terms. AC_DEFUN([RRA_ENABLE_REDUCED_DEPENDS], [rra_reduced_depends=false AC_ARG_ENABLE([reduced-depends], - [AC_HELP_STRING([--enable-reduced-depends], + [AS_HELP_STRING([--enable-reduced-depends], [Try to minimize shared library dependencies])], [AS_IF([test x"$enableval" = xyes], [rra_reduced_depends=true])])]) diff --git a/m4/lib-pathname.m4 b/m4/lib-pathname.m4 new file mode 100644 index 0000000..fc326a0 --- /dev/null +++ b/m4/lib-pathname.m4 @@ -0,0 +1,55 @@ +dnl Determine the library path name. +dnl +dnl Red Hat systems and some other Linux systems use lib64 and lib32 rather +dnl than just lib in some circumstances. This file provides an Autoconf +dnl macro, RRA_SET_LDFLAGS, which given a variable, a prefix, and an optional +dnl suffix, adds -Lprefix/lib, -Lprefix/lib32, or -Lprefix/lib64 to the +dnl variable depending on which directories exist and the size of a long in +dnl the compilation environment. If a suffix is given, a slash and that +dnl suffix will be appended, to allow for adding a subdirectory of the library +dnl directory. +dnl +dnl This file also provides the Autoconf macro RRA_SET_LIBDIR, which sets the +dnl libdir variable to PREFIX/lib{,32,64} as appropriate. +dnl +dnl Written by Russ Allbery <rra@stanford.edu> +dnl Copyright 2008, 2009 Board of Trustees, Leland Stanford Jr. University +dnl +dnl See LICENSE for licensing terms. + +dnl Probe for the alternate library name that we should attempt on this +dnl architecture, given the size of an int, and set rra_lib_arch_name to that +dnl name. Separated out so that it can be AC_REQUIRE'd and not run multiple +dnl times. +dnl +dnl There is an unfortunate abstraction violation here where we assume we know +dnl the cache variable name used by Autoconf. Unfortunately, Autoconf doesn't +dnl provide any other way of getting at that information in shell that I can +dnl see. +AC_DEFUN([_RRA_LIB_ARCH_NAME], +[rra_lib_arch_name=lib + AC_CHECK_SIZEOF([long]) + AS_IF([test "$ac_cv_sizeof_long" -eq 4 && test -d /usr/lib32], + [rra_lib_arch_name=lib32], + [AS_IF([test "$ac_cv_sizeof_long" -eq 8 && test -d /usr/lib64], + [rra_lib_arch_name=lib64])])]) + +dnl Set VARIABLE to -LPREFIX/lib{,32,64} or -LPREFIX/lib{,32,64}/SUFFIX as +dnl appropriate. +AC_DEFUN([RRA_SET_LDFLAGS], +[AC_REQUIRE([_RRA_LIB_ARCH_NAME]) + AS_IF([test -d "$2/$rra_lib_arch_name"], + [AS_IF([test x"$3" = x], + [$1="[$]$1 -L$2/${rra_lib_arch_name}"], + [$1="[$]$1 -L$2/${rra_lib_arch_name}/$3"])], + [AS_IF([test x"$3" = x], + [$1="[$]$1 -L$2/lib"], + [$1="[$]$1 -L$2/lib/$3"])]) + $1=`echo "[$]$1" | sed -e 's/^ *//'`]) + +dnl Set libdir to PREFIX/lib{,32,64} as appropriate. +AC_DEFUN([RRA_SET_LIBDIR], +[AC_REQUIRE([_RRA_LIB_ARCH_NAME]) + AS_IF([test -d "$1/$rra_lib_arch_name"], + [libdir="$1/${rra_lib_arch_name}"], + [libdir="$1/lib"])]) diff --git a/m4/remctl.m4 b/m4/remctl.m4 index 5705a26..8ee3c16 100644 --- a/m4/remctl.m4 +++ b/m4/remctl.m4 @@ -1,27 +1,25 @@ -dnl remctl.m4 -- Find the compiler and linker flags for remctl. +dnl Find the compiler and linker flags for remctl. dnl -dnl This file provides RRA_LIB_REMCTL, which finds the compiler and linker -dnl flags for linking with remctl libraries and sets the substitution -dnl variables REMCTL_CPPFLAGS, REMCTL_LDFLAGS, and REMCTL_LIBS. Also provides -dnl RRA_LIB_REMCTL_SET to set CPPFLAGS, LDFLAGS, and LIBS to include the -dnl remctl libraries; RRA_LIB_REMCTL_SWITCH to do the same but save the -dnl current values first; and RRA_LIB_REMCTL_RESTORE to restore those settings -dnl to before the last RRA_LIB_REMCTL_SWITCH. +dnl Finds the compiler and linker flags for linking with remctl libraries. +dnl Provides the --with-remctl, --with-remctl-include, and --with-remctl-lib +dnl configure options to specify non-standard paths to the remctl headers and +dnl libraries. dnl -dnl This macro depends on RRA_ENABLE_REDUCED_DEPENDS and RRA_LIB_GSSAPI. +dnl Provides the macro RRA_LIB_REMCTL and sets the substitution variables +dnl REMCTL_CPPFLAGS, REMCTL_LDFLAGS, and REMCTL_LIBS. Also provides +dnl RRA_LIB_REMCTL_SWITCH to set CPPFLAGS, LDFLAGS, and LIBS to include the +dnl remctl libraries, saving the current values first, and +dnl RRA_LIB_REMCTL_RESTORE to restore those settings to before the last +dnl RRA_LIB_REMCTL_SWITCH. +dnl +dnl Depends on RRA_ENABLE_REDUCED_DEPENDS, RRA_SET_LDFLAGS, and +dnl RRA_LIB_GSSAPI. dnl dnl Written by Russ Allbery <rra@stanford.edu> -dnl Copyright 2008 Board of Trustees, Leland Stanford Jr. University +dnl Copyright 2008, 2009 Board of Trustees, Leland Stanford Jr. University dnl dnl See LICENSE for licensing terms. -dnl Set CPPFLAGS, LDFLAGS, and LIBS to values including the Kerberos v5 -dnl settings. -AC_DEFUN([RRA_LIB_REMCTL_SET], -[CPPFLAGS="$REMCTL_CPPFLAGS $CPPFLAGS" - LDFLAGS="$REMCTL_LDFLAGS $LDFLAGS" - LIBS="$REMCTL_LIBS $LIBS"]) - dnl Save the current CPPFLAGS, LDFLAGS, and LIBS settings and switch to dnl versions that include the Kerberos v5 flags. Used as a wrapper, with dnl RRA_LIB_REMCTL_RESTORE, around tests. @@ -29,7 +27,9 @@ AC_DEFUN([RRA_LIB_REMCTL_SWITCH], [rra_remctl_save_CPPFLAGS="$CPPFLAGS" rra_remctl_save_LDFLAGS="$LDFLAGS" rra_remctl_save_LIBS="$LIBS" - RRA_LIB_REMCTL_SET]) + CPPFLAGS="$REMCTL_CPPFLAGS $CPPFLAGS" + LDFLAGS="$REMCTL_LDFLAGS $LDFLAGS" + LIBS="$REMCTL_LIBS $LIBS"]) dnl Restore CPPFLAGS, LDFLAGS, and LIBS to their previous values (before dnl RRA_LIB_REMCTL_SWITCH was called). @@ -38,32 +38,61 @@ AC_DEFUN([RRA_LIB_REMCTL_RESTORE], LDFLAGS="$rra_remctl_save_LDFLAGS" LIBS="$rra_remctl_save_LIBS"]) -dnl Set REMCTL_CPPFLAGS and REMCTL_LDFLAGS based on rra_remctl_root. +dnl Set REMCTL_CPPFLAGS and REMCTL_LDFLAGS based on rra_remctl_root, +dnl rra_remctl_libdir, and rra_remctl_includedir. AC_DEFUN([_RRA_LIB_REMCTL_PATHS], -[AS_IF([test x"$rra_remctl_root" != x], - [AS_IF([test x"$rra_remctl_root" != x/usr], - [REMCTL_CPPFLAGS="-I${rra_remctl_root}/include"]) - REMCTL_LDFLAGS="-L${rra_remctl_root}/lib"])]) +[AS_IF([test x"$rra_remctl_libdir" != x], + [REMCTL_LDFLAGS="-L$rra_remctl_libdir"], + [AS_IF([test x"$rra_remctl_root" != x], + [RRA_SET_LDFLAGS([REMCTL_LDFLAGS], [$rra_remctl_root])])]) + AS_IF([test x"$rra_remctl_includedir" != x], + [REMCTL_CPPFLAGS="-I$rra_remctl_includedir"], + [AS_IF([test x"$rra_remctl_root" != x], + [AS_IF([test x"$rra_remctl_root" != x/usr], + [REMCTL_CPPFLAGS="-I${rra_remctl_root}/include"])])])]) + +dnl Sanity-check the results of the remctl library search to be sure we can +dnl really link a remctl program. +AC_DEFUN([_RRA_LIB_REMCTL_CHECK], +[RRA_LIB_REMCTL_SWITCH + AC_CHECK_FUNC([remctl_open], , + [AC_MSG_FAILURE([unable to link with remctl library])]) + RRA_LIB_REMCTL_RESTORE]) dnl The main macro. AC_DEFUN([RRA_LIB_REMCTL], [AC_REQUIRE([RRA_ENABLE_REDUCED_DEPENDS]) rra_remctl_root= + rra_remctl_libdir= + rra_remctl_includedir= REMCTL_CPPFLAGS= REMCTL_LDFLAGS= REMCTL_LIBS= AC_SUBST([REMCTL_CPPFLAGS]) AC_SUBST([REMCTL_LDFLAGS]) AC_SUBST([REMCTL_LIBS]) + AC_ARG_WITH([remctl], - [AC_HELP_STRING([--with-remctl=DIR], + [AS_HELP_STRING([--with-remctl=DIR], [Location of remctl headers and libraries])], [AS_IF([test x"$withval" != xyes && test x"$withval" != xno], [rra_remctl_root="$withval"])]) + AC_ARG_WITH([remctl-include], + [AS_HELP_STRING([--with-remctl-include=DIR], + [Location of remctl headers])], + [AS_IF([test x"$withval" != xyes && test x"$withval" != xno], + [rra_remctl_includedir="$withval"])]) + AC_ARG_WITH([remctl-lib], + [AS_HELP_STRING([--with-remctl-lib=DIR], + [Location of remctl libraries])], + [AS_IF([test x"$withval" != xyes && test x"$withval" != xno], + [rra_remctl_libdir="$withval"])]) + _RRA_LIB_REMCTL_PATHS AS_IF([test x"$rra_reduced_depends" = xtrue], [REMCTL_LIBS="-lremctl"], [RRA_LIB_GSSAPI REMCTL_CPPFLAGS="$REMCTL_CPPFLAGS $GSSAPI_CPPFLAGS" REMCTL_LDFLAGS="$REMCTL_LDFLAGS $GSSAPI_LDFLAGS" - REMCTL_LIBS="-lremctl $GSSAPI_LIBS"])]) + REMCTL_LIBS="-lremctl $GSSAPI_LIBS"]) + _RRA_LIB_REMCTL_CHECK]) diff --git a/m4/snprintf.m4 b/m4/snprintf.m4 index 79c0089..d933f55 100644 --- a/m4/snprintf.m4 +++ b/m4/snprintf.m4 @@ -1,4 +1,4 @@ -dnl snprintf.m4 -- Test for a working C99 snprintf. +dnl Test for a working C99 snprintf. dnl dnl Check for a working snprintf. Some systems have an snprintf that doesn't dnl nul-terminate if the buffer isn't large enough. Others return -1 if the @@ -10,12 +10,14 @@ dnl Provides RRA_FUNC_SNPRINTF, which adds snprintf.o to LIBOBJS unless a dnl fully working snprintf is found. dnl dnl Written by Russ Allbery <rra@stanford.edu> -dnl Copyright 2006, 2008 Board of Trustees, Leland Stanford Jr. University +dnl Copyright 2006, 2008, 2009 +dnl Board of Trustees, Leland Stanford Jr. University +dnl dnl See LICENSE for licensing terms. dnl Source used by RRA_FUNC_SNPRINTF. -define([_RRA_FUNC_SNPRINTF_SOURCE], -[[#include <stdio.h> +AC_DEFUN([_RRA_FUNC_SNPRINTF_SOURCE], [[ +#include <stdio.h> #include <stdarg.h> char buf[2]; @@ -37,16 +39,17 @@ main() { return ((test("%s", "abcd") == 4 && buf[0] == 'a' && buf[1] == '\0' && snprintf(NULL, 0, "%s", "abcd") == 4) ? 0 : 1); -}]]) +} +]]) dnl The user-callable test. AC_DEFUN([RRA_FUNC_SNPRINTF], [AC_CACHE_CHECK([for working snprintf], [rra_cv_func_snprintf_works], - [AC_TRY_RUN(_RRA_FUNC_SNPRINTF_SOURCE(), + [AC_RUN_IFELSE([AC_LANG_SOURCE([_RRA_FUNC_SNPRINTF_SOURCE])], [rra_cv_func_snprintf_works=yes], [rra_cv_func_snprintf_works=no], [rra_cv_func_snprintf_works=no])]) -AS_IF([test "$rra_cv_func_snprintf_works" = yes], + AS_IF([test x"$rra_cv_func_snprintf_works" = xyes], [AC_DEFINE([HAVE_SNPRINTF], 1, [Define if your system has a working snprintf function.])], [AC_LIBOBJ([snprintf])])]) diff --git a/m4/vamacros.m4 b/m4/vamacros.m4 index 6740d77..855bb40 100644 --- a/m4/vamacros.m4 +++ b/m4/vamacros.m4 @@ -1,4 +1,4 @@ -dnl vamacros.m4 -- Check for support for variadic macros. +dnl Check for support for variadic macros. dnl dnl This file defines two macros for probing for compiler support for variadic dnl macros. Provided are RRA_C_C99_VAMACROS, which checks for support for the @@ -14,30 +14,49 @@ dnl dnl They set HAVE_C99_VAMACROS or HAVE_GNU_VAMACROS as appropriate. dnl dnl Written by Russ Allbery <rra@stanford.edu> -dnl Copyright 2006, 2008 Board of Trustees, Leland Stanford Jr. University +dnl Copyright 2006, 2008, 2009 +dnl Board of Trustees, Leland Stanford Jr. University dnl dnl See LICENSE for licensing terms. +AC_DEFUN([_RRA_C_C99_VAMACROS_SOURCE], [[ +#include <stdio.h> +#define error(...) fprintf(stderr, __VA_ARGS__) + +int +main(void) { + error("foo"); + error("foo %d", 0); + return 0; +} +]]) + AC_DEFUN([RRA_C_C99_VAMACROS], [AC_CACHE_CHECK([for C99 variadic macros], [rra_cv_c_c99_vamacros], -[AC_TRY_COMPILE( -[#include <stdio.h> -#define error(...) fprintf(stderr, __VA_ARGS__)], - [error("foo"); error("foo %d", 0); return 0;], - [rra_cv_c_c99_vamacros=yes], - [rra_cv_c_c99_vamacros=no])]) -AS_IF([test $rra_cv_c_c99_vamacros = yes], + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_RRA_C_C99_VAMACROS_SOURCE])], + [rra_cv_c_c99_vamacros=yes], + [rra_cv_c_c99_vamacros=no])]) + AS_IF([test x"$rra_cv_c_c99_vamacros" = xyes], [AC_DEFINE([HAVE_C99_VAMACROS], 1, - [Define if the compiler supports C99 variadic macros.])])]) + [Define if the compiler supports C99 variadic macros.])])]) + +AC_DEFUN([_RRA_C_GNU_VAMACROS_SOURCE], [[ +#include <stdio.h> +#define error(args...) fprintf(stderr, args) + +int +main(void) { + error("foo"); + error("foo %d", 0); + return 0; +} +]]) AC_DEFUN([RRA_C_GNU_VAMACROS], [AC_CACHE_CHECK([for GNU-style variadic macros], [rra_cv_c_gnu_vamacros], -[AC_TRY_COMPILE( -[#include <stdio.h> -#define error(args...) fprintf(stderr, args)], - [error("foo"); error("foo %d", 0); return 0;], - [rra_cv_c_gnu_vamacros=yes], - [rra_cv_c_gnu_vamacros=no])]) -AS_IF([test $rra_cv_c_gnu_vamacros = yes], + [AC_COMPILE_IFELSE([AC_LANG_SOURCE([_RRA_C_GNU_VAMACROS_SOURCE])], + [rra_cv_c_gnu_vamacros=yes], + [rra_cv_c_gnu_vamacros=no])]) + AS_IF([test x"$rra_cv_c_gnu_vamacros" = xyes], [AC_DEFINE([HAVE_GNU_VAMACROS], 1, - [Define if the compiler supports GNU-style variadic macros.])])]) + [Define if the compiler supports GNU-style variadic macros.])])]) diff --git a/portable/snprintf.c b/portable/snprintf.c index 3775b8a..ab3121c 100644 --- a/portable/snprintf.c +++ b/portable/snprintf.c @@ -109,13 +109,10 @@ #define VA_SHIFT(v,t) ; /* no-op for ANSI */ #define VA_END va_end(ap) -#ifdef HAVE_LONG_DOUBLE +/* Assume all compilers support long double, per Autoconf documentation. */ #define LDOUBLE long double -#else -#define LDOUBLE double -#endif -#ifdef HAVE_LONG_LONG +#ifdef HAVE_LONG_LONG_INT # define LLONG long long #else # define LLONG long |