1 dnl Local m4 macros for autoconf (used by sudo)
3 dnl Copyright (c) 1994-1996, 1998-2005, 2007-2009
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 Where the log file goes, use /var/log if it exists, else /{var,usr}/adm
85 AC_DEFUN(SUDO_LOGFILE, [AC_MSG_CHECKING(for log file location)
86 if test -n "$with_logpath"; then
87 AC_MSG_RESULT($with_logpath)
88 SUDO_DEFINE_UNQUOTED(_PATH_SUDO_LOGFILE, "$with_logpath")
89 elif test -d "/var/log"; then
90 AC_MSG_RESULT(/var/log/sudo.log)
91 SUDO_DEFINE(_PATH_SUDO_LOGFILE, "/var/log/sudo.log")
92 elif test -d "/var/adm"; then
93 AC_MSG_RESULT(/var/adm/sudo.log)
94 SUDO_DEFINE(_PATH_SUDO_LOGFILE, "/var/adm/sudo.log")
95 elif test -d "/usr/adm"; then
96 AC_MSG_RESULT(/usr/adm/sudo.log)
97 SUDO_DEFINE(_PATH_SUDO_LOGFILE, "/usr/adm/sudo.log")
99 AC_MSG_RESULT(unknown, you will have to set _PATH_SUDO_LOGFILE by hand)
104 dnl Where the timestamp files go.
106 AC_DEFUN(SUDO_TIMEDIR, [AC_MSG_CHECKING(for timestamp file location)
107 timedir="$with_timedir"
108 if test -z "$timedir"; then
109 for d in /var/db /var/lib /var/adm /usr/adm; do
110 if test -d "$d"; then
116 AC_MSG_RESULT([$timedir])
117 SUDO_DEFINE_UNQUOTED(_PATH_SUDO_TIMEDIR, "$timedir")
121 dnl Where the I/O log files go, use /var/log/sudo-io if
122 dnl /var/log exists, else /{var,usr}/adm/sudo-io
124 AC_DEFUN(SUDO_IO_LOGDIR, [
125 AC_MSG_CHECKING(for I/O log dir location)
126 if test "${with_iologdir-yes}" != "yes"; then
128 elif test -d "/var/log"; then
129 with_iologdir="/var/log/sudo-io"
130 elif test -d "/var/adm"; then
131 with_iologdir="/var/adm/sudo-io"
133 with_iologdir="/usr/adm/sudo-io"
135 if test "${with_iologdir-yes}" != "no"; then
136 SUDO_DEFINE_UNQUOTED(_PATH_SUDO_IO_LOGDIR, "$with_iologdir")
138 AC_MSG_RESULT($with_iologdir)
142 dnl SUDO_CHECK_TYPE(TYPE, DEFAULT)
143 dnl XXX - should require the check for unistd.h...
145 AC_DEFUN(SUDO_CHECK_TYPE,
146 [AC_REQUIRE([AC_HEADER_STDC])dnl
147 AC_MSG_CHECKING(for $1)
148 AC_CACHE_VAL(sudo_cv_type_$1,
149 [AC_EGREP_CPP($1, [#include <sys/types.h>
156 #endif], sudo_cv_type_$1=yes, sudo_cv_type_$1=no)])dnl
157 AC_MSG_RESULT($sudo_cv_type_$1)
158 if test $sudo_cv_type_$1 = no; then
159 AC_DEFINE($1, $2, [Define if your system lacks the $1 type.])
164 dnl Check for size_t declation
166 AC_DEFUN(SUDO_TYPE_SIZE_T,
167 [SUDO_CHECK_TYPE(size_t, int)])
170 dnl Check for ssize_t declation
172 AC_DEFUN(SUDO_TYPE_SSIZE_T,
173 [SUDO_CHECK_TYPE(ssize_t, int)])
176 dnl Check for dev_t declation
178 AC_DEFUN(SUDO_TYPE_DEV_T,
179 [SUDO_CHECK_TYPE(dev_t, int)])
182 dnl Check for ino_t declation
184 AC_DEFUN(SUDO_TYPE_INO_T,
185 [SUDO_CHECK_TYPE(ino_t, unsigned int)])
188 dnl check for working fnmatch(3)
190 AC_DEFUN(SUDO_FUNC_FNMATCH,
191 [AC_MSG_CHECKING([for working fnmatch with FNM_CASEFOLD])
192 AC_CACHE_VAL(sudo_cv_func_fnmatch,
193 [rm -f conftestdata; > conftestdata
194 AC_TRY_RUN([#include <fnmatch.h>
195 main() { exit(fnmatch("/*/bin/echo *", "/usr/bin/echo just a test", FNM_CASEFOLD)); }], [sudo_cv_func_fnmatch=yes], [sudo_cv_func_fnmatch=no],
196 [sudo_cv_func_fnmatch=no])
197 rm -f core core.* *.core])
198 AC_MSG_RESULT($sudo_cv_func_fnmatch)
199 AS_IF([test $sudo_cv_func_fnmatch = yes], [$1], [$2])])
202 dnl check for isblank(3)
204 AC_DEFUN([SUDO_FUNC_ISBLANK],
205 [AC_CACHE_CHECK([for isblank], [sudo_cv_func_isblank],
206 [AC_TRY_LINK([#include <ctype.h>], [return (isblank('a'));],
207 sudo_cv_func_isblank=yes, sudo_cv_func_isblank=no)])
209 if test "$sudo_cv_func_isblank" = "yes"; then
210 AC_DEFINE(HAVE_ISBLANK, 1, [Define if you have isblank(3).])
217 dnl check unsetenv() return value
219 AC_DEFUN([SUDO_FUNC_UNSETENV_VOID],
220 [AC_CACHE_CHECK([whether unsetenv returns void], [sudo_cv_func_unsetenv_void],
221 [AC_RUN_IFELSE([AC_LANG_PROGRAM(
225 [return unsetenv("FOO") != 0;]
228 [sudo_cv_func_unsetenv_void=no],
229 [sudo_cv_func_unsetenv_void=yes],
230 [sudo_cv_func_unsetenv_void=no])])
231 if test $sudo_cv_func_unsetenv_void = yes; then
232 AC_DEFINE(UNSETENV_VOID, 1,
233 [Define to 1 if the `unsetenv' function returns void instead of `int'.])
238 dnl check putenv() argument for const
240 AC_DEFUN([SUDO_FUNC_PUTENV_CONST],
241 [AC_CACHE_CHECK([whether putenv has a const argument],
242 sudo_cv_func_putenv_const,
243 [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
244 int putenv(const char *string) {return 0;}], [])],
245 [sudo_cv_func_putenv_const=yes],
246 [sudo_cv_func_putenv_const=no])
248 if test $sudo_cv_func_putenv_const = yes; then
249 AC_DEFINE(PUTENV_CONST, 1, [Define to 1 if the `putenv' has a const argument.])
254 dnl check for sa_len field in struct sockaddr
256 AC_DEFUN(SUDO_SOCK_SA_LEN, [
257 AC_CHECK_MEMBER([struct sockaddr.sa_len],
258 [AC_DEFINE(HAVE_SA_LEN, 1, [Define if your struct sockadr has an sa_len field.])],
260 [ #include <sys/types.h>
261 #include <sys/socket.h>]
265 dnl check for max length of uid_t in string representation.
266 dnl we can't really trust UID_MAX or MAXUID since they may exist
267 dnl only for backwards compatibility.
269 AC_DEFUN(SUDO_UID_T_LEN,
270 [AC_REQUIRE([AC_TYPE_UID_T])
271 AC_MSG_CHECKING(max length of uid_t)
272 AC_CACHE_VAL(sudo_cv_uid_t_len,
278 #include <sys/types.h>
279 #include <sys/param.h>
283 uid_t u = (uid_t) -1;
285 if ((f = fopen("conftestdata", "w")) == NULL)
288 (void) sprintf(b, "%lu", (unsigned long) u);
289 (void) fprintf(f, "%d\n", strlen(b));
292 }], sudo_cv_uid_t_len=`cat conftestdata`, sudo_cv_uid_t_len=10, sudo_cv_uid_t_len=10)
295 AC_MSG_RESULT($sudo_cv_uid_t_len)
296 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).])
300 dnl append a libpath to an LDFLAGS style variable
302 AC_DEFUN(SUDO_APPEND_LIBPATH, [
303 if test X"$with_rpath" = X"yes"; then
305 *-*-hpux*) $1="${$1} -L$2 -Wl,+b,$2"
307 *) $1="${$1} -L$2 -Wl,-R$2"
313 if test X"$blibpath" != X"" -a "$1" = "SUDO_LDFLAGS"; then
314 blibpath_add="${blibpath_add}:$2"
319 dnl Determine the mail spool location
320 dnl NOTE: must be run *after* check for paths.h
322 AC_DEFUN(SUDO_MAILDIR, [
324 if test X"$ac_cv_header_paths_h" = X"yes"; then
325 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
327 int main() {char *p = _PATH_MAILDIR;}], [])], [maildir=yes], [])
329 if test $maildir = no; then
330 # Solaris has maillock.h which defines MAILDIR
331 AC_CHECK_HEADERS(maillock.h, [
332 SUDO_DEFINE(_PATH_MAILDIR, MAILDIR)
335 if test $maildir = no; then
336 for d in /var/mail /var/spool/mail /usr/spool/mail; do
337 if test -d "$d"; then
339 SUDO_DEFINE_UNQUOTED(_PATH_MAILDIR, "$d")
343 if test $maildir = no; then
344 # unable to find mail dir, hope for the best
345 SUDO_DEFINE_UNQUOTED(_PATH_MAILDIR, "/var/mail")
352 dnl private versions of AC_DEFINE and AC_DEFINE_UNQUOTED that don't support
353 dnl tracing that we use to define paths for pathnames.h so autoheader doesn't
354 dnl put them in config.h.in. An awful hack.
356 m4_define([SUDO_DEFINE],
357 [cat >>confdefs.h <<\EOF
358 [@%:@define] $1 m4_if($#, 2, [$2], $#, 3, [$2], 1)
362 m4_define([SUDO_DEFINE_UNQUOTED],
363 [cat >>confdefs.h <<EOF
364 [@%:@define] $1 m4_if($#, 2, [$2], $#, 3, [$2], 1)
369 dnl Pull in libtool macros
371 m4_include([libtool.m4])
372 m4_include([ltoptions.m4])
373 m4_include([ltsugar.m4])
374 m4_include([ltversion.m4])
375 m4_include([lt~obsolete.m4])