configure.in revision 29964
1dnl configure.in: Input for Autoconf
2dnl
3dnl %%% portions-copyright-cmetz-96
4dnl Portions of this software are Copyright 1996-1997 by Craig Metz, All Rights
5dnl Reserved. The Inner Net License Version 2 applies to these portions of
6dnl the software.
7dnl You should have received a copy of the license with this software. If
8dnl you didn't get a copy, you may request one from <license@inner.net>.
9dnl
10dnl Portions of this software are Copyright 1995 by Randall Atkinson and Dan
11dnl McDonald, All Rights Reserved. All Rights under this copyright are assigned
12dnl to the U.S. Naval Research Laboratory (NRL). The NRL Copyright Notice and
13dnl License Agreement applies to this software.   
14dnl
15dnl	History:
16dnl
17dnl	Modified by cmetz for OPIE 2.31. Put back manual utmp[x]/wtmp[x]
18dnl          checks -- too many OSs can't be trusted to tell us where they are.
19dnl	     Check for sys/select.h. Spell endutent right. Replace strtoul()
20dnl	     if needed. Removed duplicate check for sysconf. Added check for
21dnl          SunOS C2 shadow passwords (may need more work). Replace
22dnl          setutent. Added options to disable use of utmp/wtmp. Replace
23dnl          seteuid and setegid. Check for usleep. Moved options.h options
24dnl          here as enable/disable options.
25dnl     Modified by cmetz for OPIE 2.3. Removed redundant memset/memcpy.
26dnl	     Changed ls -g test around. Changed logindevperm/fbtab defines.
27dnl	     Added check for /etc/environment and /etc/src.sh. Check for
28dnl          /var/adm/sulog. Check for {get,put}utxline, provide libmissing
29dnl          versionf of {get,put}utline. Added --enable option for anonymous
30dnl          FTP. Got rid of a few unneeded checks. Check for functions only
31dnl	     used by libmissing only if the replacement function that needs
32dnl	     them is itself needed.
33dnl	Modified by cmetz for OPIE 2.22. Check for Solaris drain bamaged ls.
34dnl          Check for setlogin(). Removed duplicate checks for some funcs.
35dnl     Modified by cmetz for OPIE 2.21. Filename must be in utmp[x]/wtmp[x]
36dnl          defines.
37dnl     Modified by cmetz for OPIE 2.2. Misc changes. Changed for libmissing
38dnl          support and building its target object list. Changed to support
39dnl          FUNCTION declaration et al. Added a LOT of checks and a LOT of
40dnl          fixes.
41dnl	Created at NRL for OPIE 2.1.
42
43AC_INIT(README)
44AC_CONFIG_HEADER(config.h)
45AC_ARG_ENABLE(access-file, [  --enable-access-file=FILENAME
46                          Enable the OPIE access file FILENAME], AC_DEFINE_UNQUOTED(PATH_ACCESS_FILE, "$enable_access_file") echo "Using the access file in $enable_access_file -- don't say we didn't warn you!")
47ACCESS_FILE="$enable_access_file"
48AC_SUBST(ACCESS_FILE)
49AC_ARG_ENABLE(server-md4, [  --enable-server-md4     Use MD4 instead of MD5 for the server], AC_DEFINE(MDX, 4), AC_DEFINE(MDX, 5))
50
51set do_user_locking=1;
52AC_ARG_ENABLE(user-locking, [  --disable-user-locking  Disable user locking
53  --enable-user-locking[=DIR]
54                          Put user lock files in DIR [/etc/opielocks]],, set do_user_locking=0)
55if $do_user_locking;
56then
57  AC_DEFINE(USER_LOCKING)
58  if test -z "$enable_user_locking"
59  then
60    AC_DEFINE(OPIE_LOCK_DIR, "/etc/opielocks")
61  else
62    AC_DEFINE_UNQUOTED(OPIE_LOCK_DIR, "$enable_user_locking")
63  fi
64fi
65LOCK_DIR="$enable_user_locking"
66AC_SUBST(LOCK_DIR)
67
68AC_ARG_ENABLE(retype, [  --enable-retype         Ask users to re-type their secret pass phrases], AC_DEFINE(RETYPE))
69AC_ARG_ENABLE(su-star-check, [  --enable-su-star-check  Refuse to switch to disabled accounts], AC_DEFINE(SU_STAR_CHECK))
70AC_ARG_ENABLE(new-prompts, [  --disable-new-prompts   Use more compatible (but less informative) prompts],, AC_DEFINE(NEW_PROMPTS))
71AC_ARG_ENABLE(insecure-override, [  --enable-insecure-override
72                          Allow users to override insecure checks], AC_DEFINE(INSECURE_OVERRIDE))
73AC_ARG_ENABLE(anonymous-ftp, [  --enable-anonymous-ftp  Enable anonymous FTP support], AC_DEFINE(DOANONYMOUS) echo "Enabling anonymous FTP support in ftp -- don't say we didn't warn you!")
74AC_ARG_ENABLE(utmp, [  --disable-utmp          Disable utmp logging], AC_DEFINE(DISABLE_UTMP) echo "Disabling utmp logging")
75AC_ARG_ENABLE(wtmp, [  --disable-wtmp          Disable wtmp logging], AC_DEFINE(DISABLE_UTMP) echo "Disabling wtmp logging")
76
77dnl Checks for programs.
78AC_PROG_CC
79AC_PROG_CPP
80AC_PROG_LN_S
81AC_PROG_RANLIB
82AC_PROG_YACC
83
84AC_AIX
85AC_ISC_POSIX
86AC_MINIX
87
88dnl We'd put PATH in these checks, but it turns out that autoconf doesn't
89dnl work as documented when it comes to the colon separator...
90
91AC_PATH_PROG(CHOWN, chown, /bin/chown, /usr/bin /bin /usr/sbin /sbin /usr/etc /etc)
92
93AC_PATH_PROG(SU, su, /bin/su, /usr/bin /bin)
94AC_PATH_PROG(ALT_SU, su,, /usr/sbin /sbin)
95
96AC_PATH_PROG(SCHEME, scheme,, /usr/lib/iaf/scheme)
97AC_PATH_PROG(LOGIN, login, /bin/login, /usr/bin /bin)
98dnl AC_DEFINE_UNQUOTED(PATH_LOGIN, "$LOGIN")
99
100if test ! -z "$SCHEME";
101then
102	LOGIN="$SCHEME";
103fi
104
105AC_PATH_PROG(FTPD, ftpd,, /usr/libexec /usr/etc /etc /usr/sbin /sbin /usr/lbin)
106AC_PATH_PROG(INFTPD, in.ftpd,, /usr/libexec /usr/etc /etc /usr/sbin /sbin /usr/lbin)
107
108if test -z "$FTPD"
109then
110	if test ! -z "$INFTPD"
111	then
112		FTPD="$INFTPD"
113	fi
114fi
115
116AC_MSG_CHECKING(for default PATH entries)
117default_path=""
118save_IFS="$IFS"
119IFS=" "
120for i in /usr/bin /bin /usr/ucb /usr/sbin /usr/bsd /sbin /usr/bin/X11 /etc /usr/local/X11/bin /usr/X11R6/bin /your-system-is-broken
121do
122	IFS=":"
123	for j in $PATH
124	do
125		if test "$i" = "$j"
126		then
127			if test -d "$i"
128			then
129				if test -z "$default_path"
130				then
131					default_path="$i"
132				else
133					default_path="$default_path:$i"
134				fi
135			fi
136		fi
137	done
138	IFS=" "
139done
140AC_DEFINE_UNQUOTED(DEFAULT_PATH, "$default_path")
141AC_MSG_RESULT($default_path)
142
143AC_MSG_CHECKING(for test -e flag)
144if sh config.testeflag
145then
146	result=yes
147	EXISTS="-e"
148else
149	result=no
150	EXISTS="-f"
151fi
152AC_SUBST(EXISTS)
153AC_MSG_RESULT($result)
154
155AC_MSG_CHECKING(for mkdir -p flag)
156if test -d config.tmpdir
157then
158	rmdir config.tmpdir/foo/bar >/dev/null 2>/dev/null
159	rmdir config.tmpdir/foo >/dev/null 2>/dev/null
160	rmdir config.tmpdir >/dev/null 2>/dev/null
161fi
162
163result=no
164if mkdir -p config.tmpdir/foo/bar >/dev/null 2>/dev/null
165then
166	if test -d config.tmpdir
167	then
168		if test -d config.tmpdir/foo
169		then
170			if test -d config.tmpdir/foo/bar
171			then
172				result=yes
173				rmdir config.tmpdir/foo/bar >/dev/null 2>/dev/null
174			fi
175			rmdir config.tmpdir/foo >/dev/null 2>/dev/null
176		fi
177		rmdir config.tmpdir >/dev/null 2>/dev/null
178	fi
179fi
180
181if test "$result" = yes
182then
183	MKDIR="mkdir -p"
184else
185	MKDIR="mkdir"
186fi
187AC_SUBST(MKDIR)
188AC_MSG_RESULT($result)
189
190AC_MSG_CHECKING(for ls group field)
191lsg=`/bin/ls -ldg / | wc -w | awk '{print $1}'`;
192ls=`/bin/ls -ld / | wc -w | awk '{print $1}'`;
193result="no"
194if test $ls = 9;
195then
196	result="yes"
197else
198	if test "$ls" = 8 -a "$lsg" = 9;
199	then
200		result="yes, with -g"
201		AC_DEFINE(HAVE_LS_G_FLAG)
202	fi
203fi
204AC_MSG_RESULT($result)
205
206dnl Checks for various system characteristics
207AC_MSG_CHECKING(for /etc/default/login)
208if test $EXISTS /etc/default/login
209then
210	result=yes
211	AC_DEFINE(HAVE_ETC_DEFAULT_LOGIN)
212else
213	result=no
214fi
215AC_MSG_RESULT($result)
216
217AC_MSG_CHECKING(for /etc/securetty)
218if test $EXISTS /etc/securetty
219then
220	result=yes
221	AC_DEFINE(HAVE_SECURETTY)
222else
223	result=no
224fi
225AC_MSG_RESULT($result)
226
227AC_MSG_CHECKING(for /etc/logindevperm)
228if test $EXISTS /etc/logindevperm
229then
230	AC_MSG_RESULT(yes)
231	AC_DEFINE(HAVE_LOGIN_PERMFILE, "/etc/logindevperm")
232else
233	AC_MSG_RESULT(no)
234
235	AC_MSG_CHECKING(for /etc/fbtab)
236	if test $EXISTS /etc/fbtab
237	then
238		result=yes
239		AC_DEFINE(HAVE_LOGIN_PERMFILE, "/etc/fbtab")
240	else
241		result=no
242	fi
243	AC_MSG_RESULT($result)
244fi
245
246AC_MSG_CHECKING(for /etc/environment)
247if test $EXISTS /etc/environment
248then
249	AC_MSG_RESULT(yes)
250	AC_DEFINE(HAVE_LOGIN_ENVFILE, "/etc/environment")
251else
252	AC_MSG_RESULT(no)
253
254	AC_MSG_CHECKING(for /etc/src.sh)
255	if test $EXISTS /etc/src.sh
256	then
257		result=yes
258		AC_DEFINE(HAVE_LOGIN_ENVFILE, "/etc/src.sh")
259	else
260		result=no
261	fi
262	AC_MSG_RESULT($result)
263fi
264
265AC_MSG_CHECKING(for /etc/shadow)
266if test $EXISTS /etc/shadow
267then
268	result=yes
269	AC_DEFINE(HAVE_ETC_SHADOW)
270else
271	AC_MSG_RESULT(no)
272
273	AC_MSG_CHECKING(for /etc/security/passwd.adjunct)
274	if test $EXISTS /etc/security/passwd.adjunct
275	then
276		result=yes
277		AC_DEFINE(HAVE_SUNOS_C2_SHADOW)
278		LIBOBJS="$LIBOBJS getspnam.o endspent.o"
279	else
280		result=no
281	fi
282fi
283AC_MSG_RESULT($result)
284
285AC_MSG_CHECKING(for /var/adm/sulog)
286if test $EXISTS /var/adm/sulog
287then
288	result=yes
289	AC_DEFINE(HAVE_SULOG)
290else
291	result=no
292fi
293AC_MSG_RESULT($result)
294
295AC_MSG_CHECKING(mail spool location)
296mail_spool=""
297for i in /var/mail /usr/mail /var/spool/mail /usr/spool/mail
298do
299	if test -d $i
300	then
301		mail_spool="$i"
302	fi
303done
304if test -z "$mail_spool"
305then
306	result="not found"
307else
308	result="$mail_spool"
309	AC_DEFINE_UNQUOTED(PATH_MAIL, "$mail_spool")
310fi
311AC_MSG_RESULT($result)
312
313AC_MSG_CHECKING(where your system puts the utmp file)
314utmp_path=""
315for i in /var/run /var/adm /usr/adm /etc
316do
317	if test $EXISTS $i/utmp
318	then
319		utmp_path="$i"
320	fi
321done
322if test -z "$utmp_path"
323then
324	result="not found"
325else
326	result="$utmp_path"
327	AC_DEFINE_UNQUOTED(PATH_UTMP_AC, "$utmp_path/utmp")
328fi
329AC_MSG_RESULT($result)
330
331AC_MSG_CHECKING(where your system puts the utmpx file)
332utmp_path=""
333for i in /var/run /var/adm /usr/adm /etc
334do
335	if test $EXISTS $i/utmp
336	then
337		utmp_path="$i"
338	fi
339done
340if test -z "$utmp_path"
341then
342	result="not found"
343	AC_DEFINE_UNQUOTED(PATH_UTMP_AC, "$utmp_path/utmpx")
344fi
345AC_MSG_RESULT($result)
346
347AC_MSG_CHECKING(where your system puts the wtmp file)
348wtmp_path=""
349for i in /var/run /var/log /var/adm /usr/adm /etc
350do
351	if test $EXISTS $i/wtmp
352	then
353		wtmp_path="$i"
354	fi
355done
356if test -z "$wtmp_path"
357then
358	result="not found"
359else
360	result="$wtmp_path"
361	AC_DEFINE_UNQUOTED(PATH_WTMP_AC, "$wtmp_path/wtmp")
362fi
363AC_MSG_RESULT($result)
364
365AC_MSG_CHECKING(where your system puts the wtmpx file)
366wtmpx_path=""
367for i in /var/run /var/log /var/adm /usr/adm /etc
368do
369	if test $EXISTS $i/wtmpx
370	then
371		wtmpx_path="$i"
372	fi
373done
374if test -z "$wtmpx_path"
375then
376	result="not found"
377else
378	result="$wtmpx_path"
379	AC_DEFINE_UNQUOTED(PATH_WTMPX_AC, "$wtmpx_path/wtmpx")
380fi
381AC_MSG_RESULT($result)
382
383AC_MSG_CHECKING(whether the system profile displays the motd)
384result=no
385if test $EXISTS /etc/profile
386then
387	if grep motd /etc/profile >/dev/null 2>/dev/null
388	then
389		result=yes
390	fi
391fi
392if test "$result" = yes
393then
394	AC_DEFINE(HAVE_MOTD_IN_PROFILE)
395fi
396AC_MSG_RESULT($result)
397
398AC_MSG_CHECKING(whether the system profile checks for mail)
399result=no
400if test $EXISTS /etc/profile
401then
402	if grep 'mail\.' /etc/profile >/dev/null 2>/dev/null
403	then
404		result=yes
405	fi
406fi
407if test "$result" = yes
408then
409	AC_DEFINE(HAVE_MAILCHECK_IN_PROFILE)
410fi
411AC_MSG_RESULT($result)
412
413dnl Random checks
414AC_C_CONST
415
416AC_MSG_CHECKING(to see if your compiler can handle void arguments)
417AC_TRY_COMPILE(foo(void) { },, AC_DEFINE(HAVE_VOIDARG) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
418
419AC_MSG_CHECKING(to see if your compiler can handle void return values)
420AC_TRY_COMPILE(void foo() { },, AC_DEFINE(HAVE_VOIDRET) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
421
422AC_MSG_CHECKING(to see if your compiler can handle void pointers)
423AC_TRY_COMPILE(foo() { void *bar = (void *)0x42; bar = bar + 1; },, AC_DEFINE(HAVE_VOIDPTR) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
424
425AC_MSG_CHECKING(to see if your compiler can handle ANSI argument lists)
426AC_TRY_COMPILE(int foo(int bar, int baz) { return 0; },, AC_DEFINE(HAVE_ANSIDECL) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
427
428AC_MSG_CHECKING(to see if your compiler can handle ANSI prototypes)
429AC_TRY_COMPILE(extern int foo(int, int);,, AC_DEFINE(HAVE_ANSIPROTO) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
430
431AC_MSG_CHECKING(to see if your compiler can handle ANSI variable arguments)
432AC_TRY_COMPILE([#include <stdarg.h>
433int foo(int arg, ...) {
434	va_list ap;
435	va_start(ap, arg);
436	va_end(ap);
437	return 0;
438}],, AC_DEFINE(HAVE_ANSISTDARG) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
439
440AC_MSG_CHECKING(to see if you have an ANSI-style sprintf)
441AC_TRY_RUN([#include <stdio.h>
442int main(argc, argv)
443int argc;
444char *argv[];
445{
446  char buf[5];
447  int i = 2;
448  i += sprintf(buf, "1234");
449  return (i == 6) ? 0 : -1;
450}], AC_DEFINE(HAVE_ANSISPRINTF) AC_MSG_RESULT(yes), AC_MSG_RESULT(no), AC_MSG_RESULT(no))
451
452dnl Checks for libraries.
453AC_CHECK_LIB(crypt, crypt)
454AC_CHECK_LIB(nsl, gethostname)
455AC_CHECK_LIB(posix, main)
456AC_CHECK_LIB(socket, socket)
457
458dnl Checks for header files.
459AC_HEADER_DIRENT
460AC_HEADER_SYS_WAIT
461AC_CHECK_HEADERS(crypt.h fcntl.h limits.h termios.h sys/file.h sys/ioctl.h sys/time.h syslog.h unistd.h paths.h shadow.h signal.h sys/signal.h lastlog.h sys/utsname.h pwd.h sys/param.h string.h stdlib.h utmpx.h sys/select.h)
462
463dnl Checks for typedefs, structures, and compiler characteristics.
464dnl AC_TYPE_UID_T
465dnl AC_TYPE_OFF_T
466dnl AC_TYPE_PID_T
467dnl AC_STRUCT_ST_BLKSIZE
468dnl AC_STRUCT_TM
469
470AC_MSG_CHECKING(for ut_pid in struct utmp)
471AC_TRY_COMPILE([#include <sys/types.h>
472#include <utmp.h>], [struct utmp foo; return (int)foo.ut_pid;], AC_DEFINE(HAVE_UT_PID) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
473AC_MSG_CHECKING(for ut_type in struct utmp)
474AC_TRY_COMPILE([#include <sys/types.h>
475#include <utmp.h>], [struct utmp foo; return (int)foo.ut_type;], AC_DEFINE(HAVE_UT_TYPE) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
476AC_MSG_CHECKING(for ut_name in struct utmp)
477AC_TRY_COMPILE([#include <sys/types.h>
478#include <utmp.h>], [struct utmp foo; return (int)foo.ut_name[0];], AC_DEFINE(HAVE_UT_NAME) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
479dnl AC_MSG_CHECKING(for ut_user in struct utmp)
480dnl AC_TRY_COMPILE([#include <sys/types.h>
481dnl #include <utmp.h>], [struct utmp foo; return (int)foo.ut_user[0];], AC_DEFINE(HAVE_UT_USER) AC_MSG_RESULT(yes), AC_MSG_RESULT(no))
482AC_DEFINE(HAVE_UT_HOST)
483
484dnl Checks for library functions.
485dnl AC_PROG_GCC_TRADITIONAL
486AC_TYPE_SIGNAL
487AC_CHECK_FUNCS(gettimeofday socket strftime strstr setpriority getttynam setvbuf getspnam endspent setgroups getgroups fpurge setlogin lstat getutxline pututxline usleep)
488
489dnl Libmissing...
490AC_FUNC_MEMCMP
491AC_FUNC_ALLOCA
492AC_REPLACE_FUNCS(getusershell sigaddset sigemptyset strerror strncasecmp)
493MISSING="$LIBOBJS $ALLOCA " ;
494AC_CHECK_FUNC(atexit,, MISSING="${MISSING}atexit.o "; AC_CHECK_FUNCS(on_exit))
495AC_CHECK_FUNC(endutent,, MISSING="${MISSING}endutent.o ")
496AC_CHECK_FUNC(memcpy,, MISSING="${MISSING}memcpy.o "; AC_CHECK_FUNCS(bcopy))
497AC_CHECK_FUNC(memset,, MISSING="${MISSING}memset.o "; AC_CHECK_FUNCS(bzero))
498AC_CHECK_FUNC(getcwd,, MISSING="${MISSING}getcwd.o "; AC_CHECK_FUNCS(getwd))
499AC_CHECK_FUNC(getenv, AC_DEFINE(HAVE_GETENV), MISSING="${MISSING}env.o ")
500AC_CHECK_FUNC(getutline, AC_DEFINE(HAVE_GETUTLINE), MISSING="${MISSING}getutline.o "; AC_CHECK_FUNCS(ttyslot))
501AC_CHECK_FUNC(pututline,, MISSING="${MISSING}pututline.o "; AC_CHECK_FUNCS(ttyslot))
502AC_CHECK_FUNC(setenv, AC_DEFINE(HAVE_SETENV), MISSING="${MISSING}env.o ")
503AC_CHECK_FUNC(setegid,, MISSING="${MISSING}setegid.o "; AC_CHECK_FUNCS(setregid setresgid))
504AC_CHECK_FUNC(seteuid,, MISSING="${MISSING}seteuid.o "; AC_CHECK_FUNCS(setreuid setresuid))
505AC_CHECK_FUNC(setutent,, MISSING="${MISSING}setutent.o ")
506AC_CHECK_FUNC(sigprocmask,, MISSING="${MISSING}sigprocmask.o "; AC_CHECK_FUNCS(sigblock sigsetmask))
507AC_CHECK_FUNC(strchr,, MISSING="${MISSING}strchr.o "; AC_CHECK_FUNCS(index))
508AC_CHECK_FUNC(strrchr,, MISSING="${MISSING}strrchr.o "; AC_CHECK_FUNCS(rindex))
509AC_CHECK_FUNC(strtoul,, MISSING="${MISSING}strtoul.o ")
510AC_CHECK_FUNC(sysconf,, MISSING="${MISSING}sysconf.o "; AC_CHECK_FUNCS(getdtablesize))
511AC_CHECK_FUNC(uname,, MISSING="${MISSING}uname.o "; AC_CHECK_FUNCS(gethostname))
512AC_CHECK_FUNC(unsetenv, AC_DEFINE(HAVE_UNSETENV), MISSING="${MISSING}env.o ")
513AC_SUBST(MISSING)
514
515AC_MSG_CHECKING(for nonstandard gettimeofday)
516AC_TRY_COMPILE([
517#if HAVE_SYS_TIME_H
518#include <sys/time.h>
519#endif /* HAVE_SYS_TIME_H */
520#if HAVE_UNISTD_H
521#include <unistd.h>
522#endif /* HAVE_UNISTD_H */
523],
524[struct timeval tv;
525gettimeofday(&tv, NULL)], AC_MSG_RESULT(no), AC_MSG_RESULT(maybe) AC_TRY_COMPILE([
526#if HAVE_SYS_TIME_H
527#include <sys/time.h>
528#endif /* HAVE_SYS_TIME_H */
529#if HAVE_UNISTD_H
530#include <unistd.h>
531#endif /* HAVE_UNISTD_H */
532],
533[struct timeval tv;
534gettimeofday(&tv)], AC_DEFINE(HAVE_ONE_ARG_GETTIMEOFDAY) AC_MSG_RESULT(yes), AC_MSG_RESULT(no)))
535
536# Munge out LOCALBIN and LOCALMAN in canonical (no bletch) form
537AC_OUTPUT(configure.munger libmissing/Makefile libopie/Makefile Makefile.munge:Makefile.in)
538sh configure.munger
539