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=yes])])
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_MSG_CHECKING(for sa_len field in struct sockaddr)
258 AC_CACHE_VAL(sudo_cv_sock_sa_len,
259 [AC_TRY_RUN([#include <sys/types.h>
260 #include <sys/socket.h>
265 }], sudo_cv_sock_sa_len=yes, sudo_cv_sock_sa_len=no,
266 sudo_cv_sock_sa_len=no)
267 rm -f core core.* *.core])dnl
268 AC_MSG_RESULT($sudo_cv_sock_sa_len)
269 if test $sudo_cv_sock_sa_len = yes; then
270 AC_DEFINE(HAVE_SA_LEN, 1, [Define if your struct sockadr has an sa_len field.])
275 dnl check for max length of uid_t in string representation.
276 dnl we can't really trust UID_MAX or MAXUID since they may exist
277 dnl only for backwards compatibility.
279 AC_DEFUN(SUDO_UID_T_LEN,
280 [AC_REQUIRE([AC_TYPE_UID_T])
281 AC_MSG_CHECKING(max length of uid_t)
282 AC_CACHE_VAL(sudo_cv_uid_t_len,
288 #include <sys/types.h>
289 #include <sys/param.h>
293 uid_t u = (uid_t) -1;
295 if ((f = fopen("conftestdata", "w")) == NULL)
298 (void) sprintf(b, "%lu", (unsigned long) u);
299 (void) fprintf(f, "%d\n", strlen(b));
302 }], sudo_cv_uid_t_len=`cat conftestdata`, sudo_cv_uid_t_len=10)
305 AC_MSG_RESULT($sudo_cv_uid_t_len)
306 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).])
310 dnl Check for presence of long long and for sizeof(long long) == sizeof(long)
312 AC_DEFUN(SUDO_TYPE_LONG_LONG,
313 [AC_CHECK_TYPES(long long, [AC_DEFINE(HAVE_LONG_LONG, 1, [Define if your compiler supports the "long long" type.])]
314 [AC_MSG_CHECKING(for long and long long equivalence)
315 AC_CACHE_VAL(sudo_cv_type_long_is_quad,
318 if (sizeof(long long) == sizeof(long)) exit(0);
320 }], [sudo_cv_type_long_is_quad=yes],
321 [sudo_cv_type_long_is_quad=no], [sudo_cv_type_long_is_quad=no])
322 rm -f core core.* *.core])dnl
323 AC_MSG_RESULT($sudo_cv_type_long_is_quad)
324 if test $sudo_cv_type_long_is_quad = yes; then
325 AC_DEFINE(LONG_IS_QUAD, 1, [Define if sizeof(long) == sizeof(long long).])
330 dnl append a libpath to an LDFLAGS style variable
332 AC_DEFUN(SUDO_APPEND_LIBPATH, [
333 if test X"$with_rpath" = X"yes"; then
335 *-*-hpux*) $1="${$1} -L$2 -Wl,+b,$2"
337 *) $1="${$1} -L$2 -Wl,-R$2"
343 if test X"$blibpath" != X"" -a "$1" = "SUDO_LDFLAGS"; then
344 blibpath_add="${blibpath_add}:$2"
349 dnl Determine the mail spool location
350 dnl NOTE: must be run *after* check for paths.h
352 AC_DEFUN(SUDO_MAILDIR, [
354 if test X"$ac_cv_header_paths_h" = X"yes"; then
355 AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
357 int main() {char *p = _PATH_MAILDIR;}], [])], [maildir=yes], [])
359 if test $maildir = no; then
360 # Solaris has maillock.h which defines MAILDIR
361 AC_CHECK_HEADERS(maillock.h, [
362 SUDO_DEFINE(_PATH_MAILDIR, MAILDIR)
365 if test $maildir = no; then
366 for d in /var/mail /var/spool/mail /usr/spool/mail; do
367 if test -d "$d"; then
369 SUDO_DEFINE_UNQUOTED(_PATH_MAILDIR, "$d")
373 if test $maildir = no; then
374 # unable to find mail dir, hope for the best
375 SUDO_DEFINE_UNQUOTED(_PATH_MAILDIR, "/var/mail")
382 dnl private versions of AC_DEFINE and AC_DEFINE_UNQUOTED that don't support
383 dnl tracing that we use to define paths for pathnames.h so autoheader doesn't
384 dnl put them in config.h.in. An awful hack.
386 m4_define([SUDO_DEFINE],
387 [cat >>confdefs.h <<\EOF
388 [@%:@define] $1 m4_if($#, 2, [$2], $#, 3, [$2], 1)
392 m4_define([SUDO_DEFINE_UNQUOTED],
393 [cat >>confdefs.h <<EOF
394 [@%:@define] $1 m4_if($#, 2, [$2], $#, 3, [$2], 1)
399 dnl Pull in libtool macros
401 m4_include([libtool.m4])
402 m4_include([ltoptions.m4])
403 m4_include([ltsugar.m4])
404 m4_include([ltversion.m4])
405 m4_include([lt~obsolete.m4])