Imported Upstream version 1.8.7
[debian/sudo] / aclocal.m4
index 1276746a6d2a2ce742bc4cd13998aa014d80a2ca..e87c852657aec3062df9ba8428cd924dabed0684 100644 (file)
@@ -1,6 +1,6 @@
 dnl Local m4 macros for autoconf (used by sudo)
 dnl
-dnl Copyright (c) 1994-1996, 1998-2005, 2007-2009
+dnl Copyright (c) 1994-1996, 1998-2005, 2007-2013
 dnl    Todd C. Miller <Todd.Miller@courtesan.com>
 dnl
 dnl XXX - should cache values in all cases!!!
@@ -10,7 +10,7 @@ dnl checks for programs
 dnl
 dnl check for sendmail in well-known locations
 dnl
-AC_DEFUN(SUDO_PROG_SENDMAIL, [AC_MSG_CHECKING([for sendmail])
+AC_DEFUN([SUDO_PROG_SENDMAIL], [AC_MSG_CHECKING([for sendmail])
 found=no
 for p in "/usr/sbin/sendmail" "/usr/lib/sendmail" "/usr/etc/sendmail" "/usr/ucblib/sendmail" "/usr/local/lib/sendmail" "/usr/local/bin/sendmail"; do
     if test -f "$p"; then
@@ -28,7 +28,7 @@ fi
 dnl
 dnl check for vi in well-known locations
 dnl
-AC_DEFUN(SUDO_PROG_VI, [AC_MSG_CHECKING([for vi])
+AC_DEFUN([SUDO_PROG_VI], [AC_MSG_CHECKING([for vi])
 found=no
 for editor in "/usr/bin/vi" "/bin/vi" "/usr/ucb/vi" "/usr/bsd/vi" "/usr/local/bin/vi"; do
     if test -f "$editor"; then
@@ -46,7 +46,7 @@ fi
 dnl
 dnl check for mv in well-known locations
 dnl
-AC_DEFUN(SUDO_PROG_MV, [AC_MSG_CHECKING([for mv])
+AC_DEFUN([SUDO_PROG_MV], [AC_MSG_CHECKING([for mv])
 found=no
 for p in "/usr/bin/mv" "/bin/mv" "/usr/ucb/mv" "/usr/sbin/mv"; do
     if test -f "$p"; then
@@ -64,7 +64,7 @@ fi
 dnl
 dnl check for bourne shell in well-known locations
 dnl
-AC_DEFUN(SUDO_PROG_BSHELL, [AC_MSG_CHECKING([for bourne shell])
+AC_DEFUN([SUDO_PROG_BSHELL], [AC_MSG_CHECKING([for bourne shell])
 found=no
 for p in "/bin/sh" "/usr/bin/sh" "/sbin/sh" "/usr/sbin/sh" "/bin/ksh" "/usr/bin/ksh" "/bin/bash" "/usr/bin/bash"; do
     if test -f "$p"; then
@@ -79,10 +79,28 @@ if test X"$found" != X"yes"; then
 fi
 ])dnl
 
+dnl
+dnl check for utmp file
+dnl
+AC_DEFUN([SUDO_PATH_UTMP], [AC_MSG_CHECKING([for utmp file path])
+found=no
+for p in "/var/run/utmp" "/var/adm/utmp" "/etc/utmp"; do
+    if test -r "$p"; then
+       found=yes
+       AC_MSG_RESULT([$p])
+       SUDO_DEFINE_UNQUOTED(_PATH_UTMP, "$p")
+       break
+    fi
+done
+if test X"$found" != X"yes"; then
+    AC_MSG_RESULT([not found])
+fi
+])dnl
+
 dnl
 dnl Where the log file goes, use /var/log if it exists, else /{var,usr}/adm
 dnl
-AC_DEFUN(SUDO_LOGFILE, [AC_MSG_CHECKING(for log file location)
+AC_DEFUN([SUDO_LOGFILE], [AC_MSG_CHECKING(for log file location)
 if test -n "$with_logpath"; then
     AC_MSG_RESULT($with_logpath)
     SUDO_DEFINE_UNQUOTED(_PATH_SUDO_LOGFILE, "$with_logpath")
@@ -103,7 +121,7 @@ fi
 dnl
 dnl Where the timestamp files go.
 dnl
-AC_DEFUN(SUDO_TIMEDIR, [AC_MSG_CHECKING(for timestamp file location)
+AC_DEFUN([SUDO_TIMEDIR], [AC_MSG_CHECKING(for timestamp file location)
 timedir="$with_timedir"
 if test -z "$timedir"; then
     for d in /var/db /var/lib /var/adm /usr/adm; do
@@ -121,73 +139,27 @@ dnl
 dnl Where the I/O log files go, use /var/log/sudo-io if
 dnl /var/log exists, else /{var,usr}/adm/sudo-io
 dnl
-AC_DEFUN(SUDO_IO_LOGDIR, [
+AC_DEFUN([SUDO_IO_LOGDIR], [
     AC_MSG_CHECKING(for I/O log dir location)
     if test "${with_iologdir-yes}" != "yes"; then
-       :
+       iolog_dir="$with_iologdir"
     elif test -d "/var/log"; then
-       with_iologdir="/var/log/sudo-io"
+       iolog_dir="/var/log/sudo-io"
     elif test -d "/var/adm"; then
-       with_iologdir="/var/adm/sudo-io"
+       iolog_dir="/var/adm/sudo-io"
     else
-       with_iologdir="/usr/adm/sudo-io"
+       iolog_dir="/usr/adm/sudo-io"
     fi
-    if test "${with_iologdir-yes}" != "no"; then
-       SUDO_DEFINE_UNQUOTED(_PATH_SUDO_IO_LOGDIR, "$with_iologdir")
+    if test "${with_iologdir}" != "no"; then
+       SUDO_DEFINE_UNQUOTED(_PATH_SUDO_IO_LOGDIR, "$iolog_dir")
     fi
-    AC_MSG_RESULT($with_iologdir)
+    AC_MSG_RESULT($iolog_dir)
 ])dnl
 
-dnl
-dnl SUDO_CHECK_TYPE(TYPE, DEFAULT)
-dnl XXX - should require the check for unistd.h...
-dnl
-AC_DEFUN(SUDO_CHECK_TYPE,
-[AC_REQUIRE([AC_HEADER_STDC])dnl
-AC_MSG_CHECKING(for $1)
-AC_CACHE_VAL(sudo_cv_type_$1,
-[AC_EGREP_CPP($1, [#include <sys/types.h>
-#include <stdio.h>
-#if STDC_HEADERS
-#include <stdlib.h>
-#endif
-#if HAVE_UNISTD_H
-#include <unistd.h>
-#endif], sudo_cv_type_$1=yes, sudo_cv_type_$1=no)])dnl
-AC_MSG_RESULT($sudo_cv_type_$1)
-if test $sudo_cv_type_$1 = no; then
-  AC_DEFINE($1, $2, [Define if your system lacks the $1 type.])
-fi
-])
-
-dnl
-dnl Check for size_t declation
-dnl
-AC_DEFUN(SUDO_TYPE_SIZE_T,
-[SUDO_CHECK_TYPE(size_t, int)])
-
-dnl
-dnl Check for ssize_t declation
-dnl
-AC_DEFUN(SUDO_TYPE_SSIZE_T,
-[SUDO_CHECK_TYPE(ssize_t, int)])
-
-dnl
-dnl Check for dev_t declation
-dnl
-AC_DEFUN(SUDO_TYPE_DEV_T,
-[SUDO_CHECK_TYPE(dev_t, int)])
-
-dnl
-dnl Check for ino_t declation
-dnl
-AC_DEFUN(SUDO_TYPE_INO_T,
-[SUDO_CHECK_TYPE(ino_t, unsigned int)])
-
 dnl
 dnl check for working fnmatch(3)
 dnl
-AC_DEFUN(SUDO_FUNC_FNMATCH,
+AC_DEFUN([SUDO_FUNC_FNMATCH],
 [AC_MSG_CHECKING([for working fnmatch with FNM_CASEFOLD])
 AC_CACHE_VAL(sudo_cv_func_fnmatch,
 [rm -f conftestdata; > conftestdata
@@ -198,6 +170,23 @@ rm -f core core.* *.core])
 AC_MSG_RESULT($sudo_cv_func_fnmatch)
 AS_IF([test $sudo_cv_func_fnmatch = yes], [$1], [$2])])
 
+dnl
+dnl Attempt to check for working PIE support.
+dnl This is a bit of a hack but on Solaris 10 with GNU ld and GNU as
+dnl we can end up with strange values from malloc().
+dnl A better check would be to verify that ASLR works with PIE.
+dnl
+AC_DEFUN([SUDO_WORKING_PIE],
+[AC_MSG_CHECKING([for working PIE support])
+AC_CACHE_VAL(sudo_cv_working_pie,
+[rm -f conftestdata; > conftestdata
+AC_TRY_RUN(AC_INCLUDES_DEFAULT([])
+[main() { char *p = malloc(1024); if (p == NULL) return 1; memset(p, 0, 1024); return 0; }], [sudo_cv_working_pie=yes], [sudo_cv_working_pie=no],
+  [sudo_cv_working_pie=no])
+rm -f core core.* *.core])
+AC_MSG_RESULT($sudo_cv_working_pie)
+AS_IF([test $sudo_cv_working_pie = yes], [$1], [$2])])
+
 dnl
 dnl check for isblank(3)
 dnl
@@ -213,6 +202,28 @@ AC_DEFUN([SUDO_FUNC_ISBLANK],
   fi
 ])
 
+AC_DEFUN([SUDO_CHECK_LIB], [
+    _sudo_check_lib_extras=`echo "$5"|sed -e 's/[      ]*//g' -e 's/-l/_/g'`
+    AC_MSG_CHECKING([for $2 in -l$1${5+ }$5])
+    AC_CACHE_VAL([sudo_cv_lib_$1''_$2$_sudo_check_lib_extras], [
+       SUDO_CHECK_LIB_OLIBS="$LIBS"
+       LIBS="$LIBS -l$1${5+ }$5"
+       AC_LINK_IFELSE(
+           [AC_LANG_CALL([], [$2])],
+           [eval sudo_cv_lib_$1''_$2$_sudo_check_lib_extras=yes],
+           [eval sudo_cv_lib_$1''_$2$_sudo_check_lib_extras=no]
+       )
+       LIBS="$SUDO_CHECK_LIB_OLIBS"
+    ])
+    if eval test \$sudo_cv_lib_$1''_$2$_sudo_check_lib_extras = "yes"; then
+       AC_MSG_RESULT([yes])
+       $3
+    else
+       AC_MSG_RESULT([no])
+       $4
+    fi
+])
+
 dnl
 dnl check unsetenv() return value
 dnl
@@ -238,7 +249,7 @@ dnl
 dnl check putenv() argument for const
 dnl
 AC_DEFUN([SUDO_FUNC_PUTENV_CONST],
-[AC_CACHE_CHECK([whether putenv has a const argument],
+[AC_CACHE_CHECK([whether putenv takes a const argument],
 sudo_cv_func_putenv_const,
 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
 int putenv(const char *string) {return 0;}], [])],
@@ -246,16 +257,18 @@ int putenv(const char *string) {return 0;}], [])],
     [sudo_cv_func_putenv_const=no])
   ])
   if test $sudo_cv_func_putenv_const = yes; then
-    AC_DEFINE(PUTENV_CONST, 1, [Define to 1 if the `putenv' has a const argument.])
+    AC_DEFINE(PUTENV_CONST, const, [Define to const if the `putenv' takes a const argument.])
+  else
+    AC_DEFINE(PUTENV_CONST, [])
   fi
 ])
 
 dnl
 dnl check for sa_len field in struct sockaddr
 dnl
-AC_DEFUN(SUDO_SOCK_SA_LEN, [
+AC_DEFUN([SUDO_SOCK_SA_LEN], [
     AC_CHECK_MEMBER([struct sockaddr.sa_len], 
-       [AC_DEFINE(HAVE_SA_LEN, 1, [Define if your struct sockadr has an sa_len field.])],    
+       [AC_DEFINE(HAVE_STRUCT_SOCKADDR_SA_LEN, 1, [Define if your struct sockadr has an sa_len field.])],    
        [],
        [ #include <sys/types.h>
          #include <sys/socket.h>] 
@@ -266,7 +279,7 @@ dnl check for max length of uid_t in string representation.
 dnl we can't really trust UID_MAX or MAXUID since they may exist
 dnl only for backwards compatibility.
 dnl
-AC_DEFUN(SUDO_UID_T_LEN,
+AC_DEFUN([SUDO_UID_T_LEN],
 [AC_REQUIRE([AC_TYPE_UID_T])
 AC_MSG_CHECKING(max length of uid_t)
 AC_CACHE_VAL(sudo_cv_uid_t_len,
@@ -297,34 +310,49 @@ AC_DEFINE_UNQUOTED(MAX_UID_T_LEN, $sudo_cv_uid_t_len, [Define to the max length
 ])
 
 dnl
-dnl append a libpath to an LDFLAGS style variable
+dnl Append a libpath to an LDFLAGS style variable if not already present.
+dnl Also appends to the _R version unless rpath is disabled.
+dnl
+AC_DEFUN([SUDO_APPEND_LIBPATH], [
+    case "${$1}" in
+       *"-L$2"|*"-L$2 ")
+           ;;
+       *)
+           $1="${$1} -L$2"
+           if test X"$enable_rpath" = X"yes"; then
+               $1_R="${$1_R} -R$2"
+           fi
+           ;;
+    esac
+])
+
 dnl
-AC_DEFUN(SUDO_APPEND_LIBPATH, [
-    if test X"$with_rpath" = X"yes"; then
-       case "$host" in
-           *-*-hpux*)  $1="${$1} -L$2 -Wl,+b,$2"
-                       ;;
-           *)          $1="${$1} -L$2 -Wl,-R$2"
-                       ;;
-       esac
-    else
-       $1="${$1} -L$2"
-    fi
-    if test X"$blibpath" != X"" -a "$1" = "SUDO_LDFLAGS"; then
-       blibpath_add="${blibpath_add}:$2"
-    fi
+dnl Append a directory to CPPFLAGS if not already present.
+dnl
+AC_DEFUN([SUDO_APPEND_CPPFLAGS], [
+    case "${CPPFLAGS}" in
+       *"$1"|*"$1 ")
+           ;;
+       *)
+           if test X"${CPPFLAGS}" = X""; then
+               CPPFLAGS="$1"
+           else
+               CPPFLAGS="${CPPFLAGS} $1"
+           fi
+           ;;
+    esac
 ])
 
 dnl
 dnl Determine the mail spool location
 dnl NOTE: must be run *after* check for paths.h
 dnl
-AC_DEFUN(SUDO_MAILDIR, [
+AC_DEFUN([SUDO_MAILDIR], [
 maildir=no
 if test X"$ac_cv_header_paths_h" = X"yes"; then
 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
-#include <paths.h>
-int main() {char *p = _PATH_MAILDIR;}], [])], [maildir=yes], [])
+#include <paths.h>],
+[char *p = _PATH_MAILDIR;])], [maildir=yes], [])
 fi
 if test $maildir = no; then
     # Solaris has maillock.h which defines MAILDIR
@@ -368,8 +396,13 @@ EOF
 dnl
 dnl Pull in libtool macros
 dnl
-m4_include([libtool.m4])
-m4_include([ltoptions.m4])
-m4_include([ltsugar.m4])
-m4_include([ltversion.m4])
-m4_include([lt~obsolete.m4])
+m4_include([m4/libtool.m4])
+m4_include([m4/ltoptions.m4])
+m4_include([m4/ltsugar.m4])
+m4_include([m4/ltversion.m4])
+m4_include([m4/lt~obsolete.m4])
+dnl
+dnl Pull in other non-standard macros
+dnl
+m4_include([m4/ax_check_compile_flag.m4])
+m4_include([m4/ax_check_link_flag.m4])