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