1 dnl Local m4 macros for autoconf (used by sudo)
3 dnl Copyright (c) 1994-1996, 1998-2005, 2007-2011
4 dnl Todd C. Miller <Todd.Miller@courtesan.com>
6 dnl XXX - should cache values in all cases!!!
8 dnl checks for programs
11 dnl check for sendmail in well-known locations
13 AC_DEFUN([SUDO_PROG_SENDMAIL], [AC_MSG_CHECKING([for sendmail])
15 for p in "/usr/sbin/sendmail" "/usr/lib/sendmail" "/usr/etc/sendmail" "/usr/ucblib/sendmail" "/usr/local/lib/sendmail" "/usr/local/bin/sendmail"; do
19 SUDO_DEFINE_UNQUOTED(_PATH_SUDO_SENDMAIL, "$p")
23 if test X"$found" != X"yes"; then
24 AC_MSG_RESULT([not found])
29 dnl check for vi in well-known locations
31 AC_DEFUN([SUDO_PROG_VI], [AC_MSG_CHECKING([for vi])
33 for editor in "/usr/bin/vi" "/bin/vi" "/usr/ucb/vi" "/usr/bsd/vi" "/usr/local/bin/vi"; do
34 if test -f "$editor"; then
36 AC_MSG_RESULT([$editor])
37 SUDO_DEFINE_UNQUOTED(_PATH_VI, "$editor")
41 if test X"$found" != X"yes"; then
42 AC_MSG_RESULT([not found])
47 dnl check for mv in well-known locations
49 AC_DEFUN([SUDO_PROG_MV], [AC_MSG_CHECKING([for mv])
51 for p in "/usr/bin/mv" "/bin/mv" "/usr/ucb/mv" "/usr/sbin/mv"; do
55 SUDO_DEFINE_UNQUOTED(_PATH_MV, "$p")
59 if test X"$found" != X"yes"; then
60 AC_MSG_RESULT([not found])
65 dnl check for bourne shell in well-known locations
67 AC_DEFUN([SUDO_PROG_BSHELL], [AC_MSG_CHECKING([for bourne shell])
69 for p in "/bin/sh" "/usr/bin/sh" "/sbin/sh" "/usr/sbin/sh" "/bin/ksh" "/usr/bin/ksh" "/bin/bash" "/usr/bin/bash"; do
73 SUDO_DEFINE_UNQUOTED(_PATH_BSHELL, "$p")
77 if test X"$found" != X"yes"; then
78 AC_MSG_RESULT([not found])
83 dnl check for utmp file
85 AC_DEFUN([SUDO_PATH_UTMP], [AC_MSG_CHECKING([for utmp file path])
87 for p in "/var/run/utmp" "/var/adm/utmp" "/etc/utmp"; do
91 SUDO_DEFINE_UNQUOTED(_PATH_UTMP, "$p")
95 if test X"$found" != X"yes"; then
96 AC_MSG_RESULT([not found])
101 dnl Where the log file goes, use /var/log if it exists, else /{var,usr}/adm
103 AC_DEFUN([SUDO_LOGFILE], [AC_MSG_CHECKING(for log file location)
104 if test -n "$with_logpath"; then
105 AC_MSG_RESULT($with_logpath)
106 SUDO_DEFINE_UNQUOTED(_PATH_SUDO_LOGFILE, "$with_logpath")
107 elif test -d "/var/log"; then
108 AC_MSG_RESULT(/var/log/sudo.log)
109 SUDO_DEFINE(_PATH_SUDO_LOGFILE, "/var/log/sudo.log")
110 elif test -d "/var/adm"; then
111 AC_MSG_RESULT(/var/adm/sudo.log)
112 SUDO_DEFINE(_PATH_SUDO_LOGFILE, "/var/adm/sudo.log")
113 elif test -d "/usr/adm"; then
114 AC_MSG_RESULT(/usr/adm/sudo.log)
115 SUDO_DEFINE(_PATH_SUDO_LOGFILE, "/usr/adm/sudo.log")
117 AC_MSG_RESULT(unknown, you will have to set _PATH_SUDO_LOGFILE by hand)
122 dnl Where the timestamp files go.
124 AC_DEFUN([SUDO_TIMEDIR], [AC_MSG_CHECKING(for timestamp file location)
125 timedir="$with_timedir"
126 if test -z "$timedir"; then
127 for d in /var/db /var/lib /var/adm /usr/adm; do
128 if test -d "$d"; then
134 AC_MSG_RESULT([$timedir])
135 SUDO_DEFINE_UNQUOTED(_PATH_SUDO_TIMEDIR, "$timedir")
139 dnl Where the I/O log files go, use /var/log/sudo-io if
140 dnl /var/log exists, else /{var,usr}/adm/sudo-io
142 AC_DEFUN([SUDO_IO_LOGDIR], [
143 AC_MSG_CHECKING(for I/O log dir location)
144 if test "${with_iologdir-yes}" != "yes"; then
145 iolog_dir="$with_iologdir"
146 elif test -d "/var/log"; then
147 iolog_dir="/var/log/sudo-io"
148 elif test -d "/var/adm"; then
149 iolog_dir="/var/adm/sudo-io"
151 iolog_dir="/usr/adm/sudo-io"
153 if test "${with_iologdir}" != "no"; then
154 SUDO_DEFINE_UNQUOTED(_PATH_SUDO_IO_LOGDIR, "$iolog_dir")
156 AC_MSG_RESULT($iolog_dir)
160 dnl SUDO_CHECK_TYPE(TYPE, DEFAULT)
161 dnl XXX - should require the check for unistd.h...
163 AC_DEFUN([SUDO_CHECK_TYPE],
164 [AC_REQUIRE([AC_HEADER_STDC])dnl
165 AC_MSG_CHECKING(for $1)
166 AC_CACHE_VAL(sudo_cv_type_$1,
167 [AC_EGREP_CPP($1, [#include <sys/types.h>
174 #endif], sudo_cv_type_$1=yes, sudo_cv_type_$1=no)])dnl
175 AC_MSG_RESULT($sudo_cv_type_$1)
176 if test $sudo_cv_type_$1 = no; then
177 AC_DEFINE($1, $2, [Define if your system lacks the $1 type.])
182 dnl Check for size_t declation
184 AC_DEFUN([SUDO_TYPE_SIZE_T],
185 [SUDO_CHECK_TYPE(size_t, int)])
188 dnl Check for ssize_t declation
190 AC_DEFUN([SUDO_TYPE_SSIZE_T],
191 [SUDO_CHECK_TYPE(ssize_t, int)])
194 dnl Check for dev_t declation
196 AC_DEFUN([SUDO_TYPE_DEV_T],
197 [SUDO_CHECK_TYPE(dev_t, int)])
200 dnl Check for ino_t declation
202 AC_DEFUN([SUDO_TYPE_INO_T],
203 [SUDO_CHECK_TYPE(ino_t, unsigned int)])
206 dnl check for working fnmatch(3)
208 AC_DEFUN([SUDO_FUNC_FNMATCH],
209 [AC_MSG_CHECKING([for working fnmatch with FNM_CASEFOLD])
210 AC_CACHE_VAL(sudo_cv_func_fnmatch,
211 [rm -f conftestdata; > conftestdata
212 AC_TRY_RUN([#include <fnmatch.h>
213 main() { exit(fnmatch("/*/bin/echo *", "/usr/bin/echo just a test", FNM_CASEFOLD)); }], [sudo_cv_func_fnmatch=yes], [sudo_cv_func_fnmatch=no],
214 [sudo_cv_func_fnmatch=no])
215 rm -f core core.* *.core])
216 AC_MSG_RESULT($sudo_cv_func_fnmatch)
217 AS_IF([test $sudo_cv_func_fnmatch = yes], [$1], [$2])])
220 dnl check for isblank(3)
222 AC_DEFUN([SUDO_FUNC_ISBLANK],
223 [AC_CACHE_CHECK([for isblank], [sudo_cv_func_isblank],
224 [AC_TRY_LINK([#include <ctype.h>], [return (isblank('a'));],
225 sudo_cv_func_isblank=yes, sudo_cv_func_isblank=no)])
227 if test "$sudo_cv_func_isblank" = "yes"; then
228 AC_DEFINE(HAVE_ISBLANK, 1, [Define if you have isblank(3).])
235 dnl check unsetenv() return value
237 AC_DEFUN([SUDO_FUNC_UNSETENV_VOID],
238 [AC_CACHE_CHECK([whether unsetenv returns void], [sudo_cv_func_unsetenv_void],
239 [AC_RUN_IFELSE([AC_LANG_PROGRAM(
243 [return unsetenv("FOO") != 0;]
246 [sudo_cv_func_unsetenv_void=no],
247 [sudo_cv_func_unsetenv_void=yes],
248 [sudo_cv_func_unsetenv_void=no])])
249 if test $sudo_cv_func_unsetenv_void = yes; then
250 AC_DEFINE(UNSETENV_VOID, 1,
251 [Define to 1 if the `unsetenv' function returns void instead of `int'.])
256 dnl check for sa_len field in struct sockaddr
258 AC_DEFUN([SUDO_SOCK_SA_LEN], [
259 AC_CHECK_MEMBER([struct sockaddr.sa_len],
260 [AC_DEFINE(HAVE_SA_LEN, 1, [Define if your struct sockadr has an sa_len field.])],
262 [ #include <sys/types.h>
263 #include <sys/socket.h>]
267 dnl check for max length of uid_t in string representation.
268 dnl we can't really trust UID_MAX or MAXUID since they may exist
269 dnl only for backwards compatibility.
271 AC_DEFUN([SUDO_UID_T_LEN],
272 [AC_REQUIRE([AC_TYPE_UID_T])
273 AC_MSG_CHECKING(max length of uid_t)
274 AC_CACHE_VAL(sudo_cv_uid_t_len,
280 #include <sys/types.h>
281 #include <sys/param.h>
285 uid_t u = (uid_t) -1;
287 if ((f = fopen("conftestdata", "w")) == NULL)
290 (void) sprintf(b, "%lu", (unsigned long) u);
291 (void) fprintf(f, "%d\n", strlen(b));
294 }], sudo_cv_uid_t_len=`cat conftestdata`, sudo_cv_uid_t_len=10, sudo_cv_uid_t_len=10)
297 AC_MSG_RESULT($sudo_cv_uid_t_len)
298 AC_DEFINE_UNQUOTED(MAX_UID_T_LEN, $sudo_cv_uid_t_len, [Define to the max length of a uid_t in string context (excluding the NUL).])
302 dnl append a libpath to an LDFLAGS style variable
304 AC_DEFUN([SUDO_APPEND_LIBPATH], [
305 if test X"$with_rpath" = X"yes"; then
307 *-*-hpux*) $1="${$1} -L$2 -Wl,+b,$2"
309 *) $1="${$1} -L$2 -Wl,-R$2"
315 if test X"$blibpath" != X"" -a "$1" = "SUDO_LDFLAGS"; then
316 blibpath_add="${blibpath_add}:$2"
321 dnl Determine the mail spool location
322 dnl NOTE: must be run *after* check for paths.h
324 AC_DEFUN([SUDO_MAILDIR], [
326 if test X"$ac_cv_header_paths_h" = X"yes"; then
327 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
329 [char *p = _PATH_MAILDIR;])], [maildir=yes], [])
331 if test $maildir = no; then
332 # Solaris has maillock.h which defines MAILDIR
333 AC_CHECK_HEADERS(maillock.h, [
334 SUDO_DEFINE(_PATH_MAILDIR, MAILDIR)
337 if test $maildir = no; then
338 for d in /var/mail /var/spool/mail /usr/spool/mail; do
339 if test -d "$d"; then
341 SUDO_DEFINE_UNQUOTED(_PATH_MAILDIR, "$d")
345 if test $maildir = no; then
346 # unable to find mail dir, hope for the best
347 SUDO_DEFINE_UNQUOTED(_PATH_MAILDIR, "/var/mail")
354 dnl private versions of AC_DEFINE and AC_DEFINE_UNQUOTED that don't support
355 dnl tracing that we use to define paths for pathnames.h so autoheader doesn't
356 dnl put them in config.h.in. An awful hack.
358 m4_define([SUDO_DEFINE],
359 [cat >>confdefs.h <<\EOF
360 [@%:@define] $1 m4_if($#, 2, [$2], $#, 3, [$2], 1)
364 m4_define([SUDO_DEFINE_UNQUOTED],
365 [cat >>confdefs.h <<EOF
366 [@%:@define] $1 m4_if($#, 2, [$2], $#, 3, [$2], 1)
371 dnl Pull in libtool macros
373 m4_include([libtool.m4])
374 m4_include([ltoptions.m4])
375 m4_include([ltsugar.m4])
376 m4_include([ltversion.m4])
377 m4_include([lt~obsolete.m4])