Annotation of src/usr.bin/sudo/aclocal.m4, Revision 1.11
1.6 millert 1: dnl Local m4 macros for autoconf (used by sudo)
1.1 millert 2: dnl
1.11 ! millert 3: dnl Copyright (c) 1994-1996, 1998-2005, 2007-2009
! 4: dnl Todd C. Miller <Todd.Miller@courtesan.com>
1.1 millert 5: dnl
6: dnl XXX - should cache values in all cases!!!
7: dnl
8: dnl checks for programs
9:
10: dnl
11: dnl check for sendmail
12: dnl
13: AC_DEFUN(SUDO_PROG_SENDMAIL, [AC_MSG_CHECKING(for sendmail)
14: if test -f "/usr/sbin/sendmail"; then
15: AC_MSG_RESULT(/usr/sbin/sendmail)
16: SUDO_DEFINE(_PATH_SUDO_SENDMAIL, "/usr/sbin/sendmail")
17: elif test -f "/usr/lib/sendmail"; then
18: AC_MSG_RESULT(/usr/lib/sendmail)
19: SUDO_DEFINE(_PATH_SUDO_SENDMAIL, "/usr/lib/sendmail")
20: elif test -f "/usr/etc/sendmail"; then
21: AC_MSG_RESULT(/usr/etc/sendmail)
22: SUDO_DEFINE(_PATH_SUDO_SENDMAIL, "/usr/etc/sendmail")
23: elif test -f "/usr/ucblib/sendmail"; then
24: AC_MSG_RESULT(/usr/ucblib/sendmail)
25: SUDO_DEFINE(_PATH_SUDO_SENDMAIL, "/usr/ucblib/sendmail")
26: elif test -f "/usr/local/lib/sendmail"; then
27: AC_MSG_RESULT(/usr/local/lib/sendmail)
28: SUDO_DEFINE(_PATH_SUDO_SENDMAIL, "/usr/local/lib/sendmail")
29: elif test -f "/usr/local/bin/sendmail"; then
30: AC_MSG_RESULT(/usr/local/bin/sendmail)
31: SUDO_DEFINE(_PATH_SUDO_SENDMAIL, "/usr/local/bin/sendmail")
32: else
33: AC_MSG_RESULT(not found)
34: fi
35: ])dnl
36:
37: dnl
38: dnl check for vi
39: dnl
40: AC_DEFUN(SUDO_PROG_VI, [AC_MSG_CHECKING(for vi)
41: if test -f "/usr/bin/vi"; then
42: AC_MSG_RESULT(/usr/bin/vi)
43: SUDO_DEFINE(_PATH_VI, "/usr/bin/vi")
44: elif test -f "/usr/ucb/vi"; then
45: AC_MSG_RESULT(/usr/ucb/vi)
46: SUDO_DEFINE(_PATH_VI, "/usr/ucb/vi")
47: elif test -f "/usr/bsd/vi"; then
48: AC_MSG_RESULT(/usr/bsd/vi)
49: SUDO_DEFINE(_PATH_VI, "/usr/bsd/vi")
50: elif test -f "/bin/vi"; then
51: AC_MSG_RESULT(/bin/vi)
52: SUDO_DEFINE(_PATH_VI, "/bin/vi")
53: elif test -f "/usr/local/bin/vi"; then
54: AC_MSG_RESULT(/usr/local/bin/vi)
55: SUDO_DEFINE(_PATH_VI, "/usr/local/bin/vi")
56: else
57: AC_MSG_RESULT(not found)
58: fi
59: ])dnl
60:
61: dnl
62: dnl check for mv
63: dnl
64: AC_DEFUN(SUDO_PROG_MV, [AC_MSG_CHECKING(for mv)
65: if test -f "/usr/bin/mv"; then
66: AC_MSG_RESULT(/usr/bin/mv)
67: SUDO_DEFINE(_PATH_MV, "/usr/bin/mv")
68: elif test -f "/bin/mv"; then
69: AC_MSG_RESULT(/bin/mv)
70: SUDO_DEFINE(_PATH_MV, "/bin/mv")
71: elif test -f "/usr/ucb/mv"; then
72: AC_MSG_RESULT(/usr/ucb/mv)
73: SUDO_DEFINE(_PATH_MV, "/usr/ucb/mv")
74: elif test -f "/usr/sbin/mv"; then
75: AC_MSG_RESULT(/usr/sbin/mv)
76: SUDO_DEFINE(_PATH_MV, "/usr/sbin/mv")
77: else
78: AC_MSG_RESULT(not found)
79: fi
80: ])dnl
81:
82: dnl
83: dnl check for bourne shell
84: dnl
85: AC_DEFUN(SUDO_PROG_BSHELL, [AC_MSG_CHECKING(for bourne shell)
86: if test -f "/bin/sh"; then
87: AC_MSG_RESULT(/bin/sh)
88: SUDO_DEFINE(_PATH_BSHELL, "/bin/sh")
89: elif test -f "/usr/bin/sh"; then
90: AC_MSG_RESULT(/usr/bin/sh)
91: SUDO_DEFINE(_PATH_BSHELL, "/usr/bin/sh")
92: elif test -f "/sbin/sh"; then
93: AC_MSG_RESULT(/sbin/sh)
94: SUDO_DEFINE(_PATH_BSHELL, "/sbin/sh")
95: elif test -f "/usr/sbin/sh"; then
96: AC_MSG_RESULT(/usr/sbin/sh)
97: SUDO_DEFINE(_PATH_BSHELL, "/usr/sbin/sh")
98: elif test -f "/bin/ksh"; then
99: AC_MSG_RESULT(/bin/ksh)
100: SUDO_DEFINE(_PATH_BSHELL, "/bin/ksh")
101: elif test -f "/usr/bin/ksh"; then
102: AC_MSG_RESULT(/usr/bin/ksh)
103: SUDO_DEFINE(_PATH_BSHELL, "/usr/bin/ksh")
104: elif test -f "/bin/bash"; then
105: AC_MSG_RESULT(/bin/bash)
106: SUDO_DEFINE(_PATH_BSHELL, "/bin/bash")
107: elif test -f "/usr/bin/bash"; then
108: AC_MSG_RESULT(/usr/bin/bash)
109: SUDO_DEFINE(_PATH_BSHELL, "/usr/bin/bash")
110: else
111: AC_MSG_RESULT(not found)
112: fi
113: ])dnl
114:
115: dnl
116: dnl Where the log file goes, use /var/log if it exists, else /{var,usr}/adm
117: dnl
118: AC_DEFUN(SUDO_LOGFILE, [AC_MSG_CHECKING(for log file location)
119: if test -n "$with_logpath"; then
120: AC_MSG_RESULT($with_logpath)
121: SUDO_DEFINE_UNQUOTED(_PATH_SUDO_LOGFILE, "$with_logpath")
122: elif test -d "/var/log"; then
123: AC_MSG_RESULT(/var/log/sudo.log)
124: SUDO_DEFINE(_PATH_SUDO_LOGFILE, "/var/log/sudo.log")
125: elif test -d "/var/adm"; then
126: AC_MSG_RESULT(/var/adm/sudo.log)
127: SUDO_DEFINE(_PATH_SUDO_LOGFILE, "/var/adm/sudo.log")
128: elif test -d "/usr/adm"; then
129: AC_MSG_RESULT(/usr/adm/sudo.log)
130: SUDO_DEFINE(_PATH_SUDO_LOGFILE, "/usr/adm/sudo.log")
131: else
132: AC_MSG_RESULT(unknown, you will have to set _PATH_SUDO_LOGFILE by hand)
133: fi
134: ])dnl
135:
136: dnl
137: dnl Where the log file goes, use /var/log if it exists, else /{var,usr}/adm
138: dnl
139: AC_DEFUN(SUDO_TIMEDIR, [AC_MSG_CHECKING(for timestamp file location)
140: if test -n "$with_timedir"; then
141: AC_MSG_RESULT($with_timedir)
142: SUDO_DEFINE_UNQUOTED(_PATH_SUDO_TIMEDIR, "$with_timedir")
143: timedir="$with_timedir"
144: elif test -d "/var/run"; then
145: AC_MSG_RESULT(/var/run/sudo)
146: SUDO_DEFINE(_PATH_SUDO_TIMEDIR, "/var/run/sudo")
147: timedir="/var/run/sudo"
1.5 millert 148: elif test -d "/var/adm"; then
149: AC_MSG_RESULT(/var/adm/sudo)
150: SUDO_DEFINE(_PATH_SUDO_TIMEDIR, "/var/adm/sudo")
151: timedir="/var/adm/sudo"
1.1 millert 152: else
1.5 millert 153: AC_MSG_RESULT(/usr/adm/sudo)
154: SUDO_DEFINE(_PATH_SUDO_TIMEDIR, "/usr/adm/sudo")
155: timedir="/usr/adm/sudo"
1.1 millert 156: fi
157: ])dnl
158:
159: dnl
160: dnl SUDO_CHECK_TYPE(TYPE, DEFAULT)
161: dnl XXX - should require the check for unistd.h...
162: dnl
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>
168: #include <stdio.h>
169: #if STDC_HEADERS
170: #include <stdlib.h>
171: #endif
172: #if HAVE_UNISTD_H
173: #include <unistd.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.])
178: fi
179: ])
180:
181: dnl
182: dnl Check for size_t declation
183: dnl
184: AC_DEFUN(SUDO_TYPE_SIZE_T,
185: [SUDO_CHECK_TYPE(size_t, int)])
186:
187: dnl
188: dnl Check for ssize_t declation
189: dnl
190: AC_DEFUN(SUDO_TYPE_SSIZE_T,
191: [SUDO_CHECK_TYPE(ssize_t, int)])
192:
193: dnl
194: dnl Check for dev_t declation
195: dnl
196: AC_DEFUN(SUDO_TYPE_DEV_T,
197: [SUDO_CHECK_TYPE(dev_t, int)])
198:
199: dnl
200: dnl Check for ino_t declation
201: dnl
202: AC_DEFUN(SUDO_TYPE_INO_T,
203: [SUDO_CHECK_TYPE(ino_t, unsigned int)])
204:
205: dnl
206: dnl check for working fnmatch(3)
207: dnl
208: AC_DEFUN(SUDO_FUNC_FNMATCH,
1.6 millert 209: [AC_MSG_CHECKING([for working fnmatch with FNM_CASEFOLD])
1.1 millert 210: AC_CACHE_VAL(sudo_cv_func_fnmatch,
211: [rm -f conftestdata; > conftestdata
212: AC_TRY_RUN([#include <fnmatch.h>
1.6 millert 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])
1.1 millert 216: AC_MSG_RESULT($sudo_cv_func_fnmatch)
1.6 millert 217: AS_IF([test $sudo_cv_func_fnmatch = yes], [$1], [$2])])
1.1 millert 218:
219: dnl
220: dnl check for isblank(3)
221: dnl
222: AC_DEFUN([SUDO_FUNC_ISBLANK],
1.10 millert 223: [AC_CACHE_CHECK([for isblank], [sudo_cv_func_isblank],
1.7 millert 224: [AC_TRY_LINK([#include <ctype.h>], [return (isblank('a'));],
1.1 millert 225: sudo_cv_func_isblank=yes, sudo_cv_func_isblank=no)])
226: ] [
227: if test "$sudo_cv_func_isblank" = "yes"; then
228: AC_DEFINE(HAVE_ISBLANK, 1, [Define if you have isblank(3).])
1.9 millert 229: else
230: AC_LIBOBJ(isblank)
1.10 millert 231: fi
232: ])
233:
234: dnl
235: dnl check unsetenv() return value
236: dnl
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(
240: [AC_INCLUDES_DEFAULT
241: int unsetenv();
242: ], [
243: [return unsetenv("FOO") != 0;]
244: ])
245: ],
246: [sudo_cv_func_unsetenv_void=no],
247: [sudo_cv_func_unsetenv_void=yes],
248: [sudo_cv_func_unsetenv_void=yes])])
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'.])
252: fi
253: ])
254:
255: dnl
256: dnl check putenv() argument for const
257: dnl
258: AC_DEFUN([SUDO_FUNC_PUTENV_CONST],
259: [AC_CACHE_CHECK([whether putenv has a const argument],
260: sudo_cv_func_putenv_const,
261: [AC_COMPILE_IFELSE([AC_LANG_PROGRAM([AC_INCLUDES_DEFAULT
262: int putenv(const char *string) {return 0;}], [])],
263: [sudo_cv_func_putenv_const=yes],
264: [sudo_cv_func_putenv_const=no])
265: ])
266: if test $sudo_cv_func_putenv_const = yes; then
267: AC_DEFINE(PUTENV_CONST, 1, [Define to 1 if the `putenv' has a const argument.])
1.1 millert 268: fi
269: ])
270:
271: dnl
272: dnl check for sa_len field in struct sockaddr
273: dnl
274: AC_DEFUN(SUDO_SOCK_SA_LEN,
275: [AC_MSG_CHECKING(for sa_len field in struct sockaddr)
276: AC_CACHE_VAL(sudo_cv_sock_sa_len,
277: [AC_TRY_RUN([#include <sys/types.h>
278: #include <sys/socket.h>
279: main() {
280: struct sockaddr s;
281: s.sa_len = 0;
282: exit(0);
283: }], sudo_cv_sock_sa_len=yes, sudo_cv_sock_sa_len=no,
284: sudo_cv_sock_sa_len=no)
285: rm -f core core.* *.core])dnl
286: AC_MSG_RESULT($sudo_cv_sock_sa_len)
287: if test $sudo_cv_sock_sa_len = yes; then
288: AC_DEFINE(HAVE_SA_LEN, 1, [Define if your struct sockadr has an sa_len field.])
289: fi
290: ])
291:
292: dnl
293: dnl check for max length of uid_t in string representation.
294: dnl we can't really trust UID_MAX or MAXUID since they may exist
295: dnl only for backwards compatibility.
296: dnl
297: AC_DEFUN(SUDO_UID_T_LEN,
298: [AC_REQUIRE([AC_TYPE_UID_T])
299: AC_MSG_CHECKING(max length of uid_t)
300: AC_CACHE_VAL(sudo_cv_uid_t_len,
301: [rm -f conftestdata
302: AC_TRY_RUN(
303: [#include <stdio.h>
304: #include <pwd.h>
305: #include <limits.h>
306: #include <sys/types.h>
307: #include <sys/param.h>
308: main() {
309: FILE *f;
310: char b[1024];
311: uid_t u = (uid_t) -1;
312:
313: if ((f = fopen("conftestdata", "w")) == NULL)
314: exit(1);
315:
1.3 millert 316: (void) sprintf(b, "%lu", (unsigned long) u);
1.1 millert 317: (void) fprintf(f, "%d\n", strlen(b));
318: (void) fclose(f);
319: exit(0);
320: }], sudo_cv_uid_t_len=`cat conftestdata`, sudo_cv_uid_t_len=10)
321: ])
322: rm -f conftestdata
323: AC_MSG_RESULT($sudo_cv_uid_t_len)
324: 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).])
325: ])
326:
327: dnl
1.6 millert 328: dnl Check for presence of long long and for sizeof(long long) == sizeof(long)
1.1 millert 329: dnl
1.6 millert 330: AC_DEFUN(SUDO_TYPE_LONG_LONG,
331: [AC_CHECK_TYPES(long long, [AC_DEFINE(HAVE_LONG_LONG, 1, [Define if your compiler supports the "long long" type.])]
332: [AC_MSG_CHECKING(for long and long long equivalence)
333: AC_CACHE_VAL(sudo_cv_type_long_is_quad,
334: [AC_TRY_RUN([
335: main() {
336: if (sizeof(long long) == sizeof(long)) exit(0);
337: else exit(1);
338: }], [sudo_cv_type_long_is_quad=yes],
339: [sudo_cv_type_long_is_quad=no], [sudo_cv_type_long_is_quad=no])
340: rm -f core core.* *.core])dnl
341: AC_MSG_RESULT($sudo_cv_type_long_is_quad)
342: if test $sudo_cv_type_long_is_quad = yes; then
343: AC_DEFINE(LONG_IS_QUAD, 1, [Define if sizeof(long) == sizeof(long long).])
344: fi
345: ])])
1.1 millert 346:
347: dnl
1.4 millert 348: dnl append a libpath to an LDFLAGS style variable
349: dnl
350: AC_DEFUN(SUDO_APPEND_LIBPATH, [
351: if test X"$with_rpath" = X"yes"; then
352: $1="${$1} -L$2 -R$2"
353: else
354: $1="${$1} -L$2"
355: fi
356: if test X"$blibpath" != X"" -a "$1" = "SUDO_LDFLAGS"; then
357: blibpath_add="${blibpath_add}:$2"
358: fi
1.6 millert 359: ])
360:
361: dnl
1.1 millert 362: dnl private versions of AC_DEFINE and AC_DEFINE_UNQUOTED that don't support
363: dnl tracing that we use to define paths for pathnames.h so autoheader doesn't
364: dnl put them in config.h.in. An awful hack.
365: dnl
366: m4_define([SUDO_DEFINE],
367: [cat >>confdefs.h <<\EOF
368: [@%:@define] $1 m4_if($#, 2, [$2], $#, 3, [$2], 1)
369: EOF
370: ])
371:
372: m4_define([SUDO_DEFINE_UNQUOTED],
373: [cat >>confdefs.h <<EOF
374: [@%:@define] $1 m4_if($#, 2, [$2], $#, 3, [$2], 1)
375: EOF
376: ])