xref: /freebsd/crypto/openssh/configure.ac (revision 77b7cdf1999ee965ad494fddd184b18f532ac91a)
1# $Id: configure.ac,v 1.113 2003/03/21 01:18:09 mouring Exp $
2# $FreeBSD$
3
4AC_INIT
5AC_CONFIG_SRCDIR([ssh.c])
6
7AC_CONFIG_HEADER(config.h)
8AC_PROG_CC
9AC_CANONICAL_HOST
10AC_C_BIGENDIAN
11
12# Checks for programs.
13AC_PROG_CPP
14AC_PROG_RANLIB
15AC_PROG_INSTALL
16AC_PATH_PROG(AR, ar)
17AC_PATH_PROGS(PERL, perl5 perl)
18AC_PATH_PROG(SED, sed)
19AC_SUBST(PERL)
20AC_PATH_PROG(ENT, ent)
21AC_SUBST(ENT)
22AC_PATH_PROG(TEST_MINUS_S_SH, bash)
23AC_PATH_PROG(TEST_MINUS_S_SH, ksh)
24AC_PATH_PROG(TEST_MINUS_S_SH, sh)
25AC_PATH_PROG(SH, sh)
26
27# System features
28AC_SYS_LARGEFILE
29
30if test -z "$AR" ; then
31	AC_MSG_ERROR([*** 'ar' missing, please install or fix your \$PATH ***])
32fi
33
34# Use LOGIN_PROGRAM from environment if possible
35if test ! -z "$LOGIN_PROGRAM" ; then
36	AC_DEFINE_UNQUOTED(LOGIN_PROGRAM_FALLBACK, "$LOGIN_PROGRAM")
37else
38	# Search for login
39	AC_PATH_PROG(LOGIN_PROGRAM_FALLBACK, login)
40	if test ! -z "$LOGIN_PROGRAM_FALLBACK" ; then
41		AC_DEFINE_UNQUOTED(LOGIN_PROGRAM_FALLBACK, "$LOGIN_PROGRAM_FALLBACK")
42	fi
43fi
44
45if test -z "$LD" ; then
46	LD=$CC
47fi
48AC_SUBST(LD)
49
50AC_C_INLINE
51if test "$GCC" = "yes" || test "$GCC" = "egcs"; then
52	CFLAGS="$CFLAGS -Wall -Wpointer-arith -Wno-uninitialized"
53fi
54
55# Check for some target-specific stuff
56case "$host" in
57*-*-aix*)
58	AFS_LIBS="-lld"
59	CPPFLAGS="$CPPFLAGS -I/usr/local/include"
60	LDFLAGS="$LDFLAGS -L/usr/local/lib"
61	if (test "$LD" != "gcc" && test -z "$blibpath"); then
62		AC_MSG_CHECKING([if linkage editor ($LD) accepts -blibpath])
63		saved_LDFLAGS="$LDFLAGS"
64		LDFLAGS="$LDFLAGS -blibpath:/usr/lib:/lib:/usr/local/lib"
65		AC_TRY_LINK([],
66			[],
67			[
68				AC_MSG_RESULT(yes)
69				blibpath="/usr/lib:/lib:/usr/local/lib"
70			],
71			[ AC_MSG_RESULT(no) ]
72		)
73		LDFLAGS="$saved_LDFLAGS"
74	fi
75	AC_CHECK_FUNC(authenticate, [AC_DEFINE(WITH_AIXAUTHENTICATE)],
76		[AC_CHECK_LIB(s,authenticate,
77			[ AC_DEFINE(WITH_AIXAUTHENTICATE)
78				LIBS="$LIBS -ls"
79			])
80		])
81	AC_DEFINE(BROKEN_GETADDRINFO)
82	AC_DEFINE(BROKEN_REALPATH)
83	dnl AIX handles lastlog as part of its login message
84	AC_DEFINE(DISABLE_LASTLOG)
85	AC_DEFINE(LOGIN_NEEDS_UTMPX)
86	AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_CLOBBER_ARGV)
87	AC_DEFINE(SETPROCTITLE_PS_PADDING, '\0')
88	;;
89*-*-cygwin*)
90	check_for_libcrypt_later=1
91	LIBS="$LIBS /usr/lib/textmode.o"
92	AC_DEFINE(HAVE_CYGWIN)
93	AC_DEFINE(USE_PIPES)
94	AC_DEFINE(DISABLE_SHADOW)
95	AC_DEFINE(IPV4_DEFAULT)
96	AC_DEFINE(IP_TOS_IS_BROKEN)
97	AC_DEFINE(NO_X11_UNIX_SOCKETS)
98	AC_DEFINE(NO_IPPORT_RESERVED_CONCEPT)
99	AC_DEFINE(DISABLE_FD_PASSING)
100	AC_DEFINE(SETGROUPS_NOOP)
101	;;
102*-*-dgux*)
103	AC_DEFINE(IP_TOS_IS_BROKEN)
104	;;
105*-*-darwin*)
106	AC_MSG_CHECKING(if we have working getaddrinfo)
107	AC_TRY_RUN([#include <mach-o/dyld.h>
108main() { if (NSVersionOfRunTimeLibrary("System") >= (60 << 16))
109		exit(0);
110	else
111		exit(1);
112}], [AC_MSG_RESULT(working)],
113	[AC_MSG_RESULT(buggy)
114	AC_DEFINE(BROKEN_GETADDRINFO)],
115	[AC_MSG_RESULT(assume it is working)])
116	;;
117*-*-hpux10.26)
118	if test -z "$GCC"; then
119		CFLAGS="$CFLAGS -Ae"
120	fi
121	CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
122	IPADDR_IN_DISPLAY=yes
123	AC_DEFINE(HAVE_SECUREWARE)
124	AC_DEFINE(USE_PIPES)
125	AC_DEFINE(LOGIN_NO_ENDOPT)
126	AC_DEFINE(LOGIN_NEEDS_UTMPX)
127	AC_DEFINE(DISABLE_SHADOW)
128	AC_DEFINE(DISABLE_UTMP)
129	AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_PSTAT)
130	LIBS="$LIBS -lsec -lsecpw"
131	AC_CHECK_LIB(xnet, t_error, ,AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***]))
132	disable_ptmx_check=yes
133	;;
134*-*-hpux10*)
135	if test -z "$GCC"; then
136		CFLAGS="$CFLAGS -Ae"
137	fi
138	CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
139	IPADDR_IN_DISPLAY=yes
140	AC_DEFINE(USE_PIPES)
141	AC_DEFINE(LOGIN_NO_ENDOPT)
142	AC_DEFINE(LOGIN_NEEDS_UTMPX)
143	AC_DEFINE(DISABLE_SHADOW)
144	AC_DEFINE(DISABLE_UTMP)
145	AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_PSTAT)
146	LIBS="$LIBS -lsec"
147	AC_CHECK_LIB(xnet, t_error, ,AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***]))
148	;;
149*-*-hpux11*)
150	CPPFLAGS="$CPPFLAGS -D_HPUX_SOURCE -D_XOPEN_SOURCE -D_XOPEN_SOURCE_EXTENDED=1"
151	IPADDR_IN_DISPLAY=yes
152	AC_DEFINE(PAM_SUN_CODEBASE)
153	AC_DEFINE(USE_PIPES)
154	AC_DEFINE(LOGIN_NO_ENDOPT)
155	AC_DEFINE(LOGIN_NEEDS_UTMPX)
156	AC_DEFINE(DISABLE_SHADOW)
157	AC_DEFINE(DISABLE_UTMP)
158	AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_PSTAT)
159	LIBS="$LIBS -lsec"
160	AC_CHECK_LIB(xnet, t_error, ,AC_MSG_ERROR([*** -lxnet needed on HP-UX - check config.log ***]))
161	;;
162*-*-irix5*)
163	CPPFLAGS="$CPPFLAGS -I/usr/local/include"
164	LDFLAGS="$LDFLAGS"
165	PATH="$PATH:/usr/etc"
166	AC_DEFINE(BROKEN_INET_NTOA)
167	AC_DEFINE(WITH_ABBREV_NO_TTY)
168	;;
169*-*-irix6*)
170	CPPFLAGS="$CPPFLAGS -I/usr/local/include"
171	LDFLAGS="$LDFLAGS"
172	PATH="$PATH:/usr/etc"
173	AC_DEFINE(WITH_IRIX_ARRAY)
174	AC_DEFINE(WITH_IRIX_PROJECT)
175	AC_DEFINE(WITH_IRIX_AUDIT)
176	AC_CHECK_FUNC(jlimit_startjob, [AC_DEFINE(WITH_IRIX_JOBS)])
177	AC_DEFINE(BROKEN_INET_NTOA)
178	AC_DEFINE(WITH_ABBREV_NO_TTY)
179	;;
180*-*-linux*)
181	no_dev_ptmx=1
182	check_for_libcrypt_later=1
183	AC_DEFINE(DONT_TRY_OTHER_AF)
184	AC_DEFINE(PAM_TTY_KLUDGE)
185	AC_DEFINE(SETPROCTITLE_STRATEGY,PS_USE_CLOBBER_ARGV)
186	AC_DEFINE(SETPROCTITLE_PS_PADDING, '\0')
187	inet6_default_4in6=yes
188	;;
189mips-sony-bsd|mips-sony-newsos4)
190	AC_DEFINE(HAVE_NEWS4)
191	SONY=1
192	;;
193*-*-netbsd*)
194	check_for_libcrypt_before=1
195	need_dash_r=1
196	;;
197*-*-freebsd*)
198	check_for_libcrypt_later=1
199	;;
200*-next-*)
201	conf_lastlog_location="/usr/adm/lastlog"
202	conf_utmp_location=/etc/utmp
203	conf_wtmp_location=/usr/adm/wtmp
204	MAIL=/usr/spool/mail
205	AC_DEFINE(HAVE_NEXT)
206	AC_DEFINE(BROKEN_REALPATH)
207	AC_DEFINE(USE_PIPES)
208	AC_DEFINE(BROKEN_SAVED_UIDS)
209	CPPFLAGS="$CPPFLAGS -I/usr/local/include"
210	CFLAGS="$CFLAGS"
211	;;
212*-*-solaris*)
213	CPPFLAGS="$CPPFLAGS -I/usr/local/include"
214	LDFLAGS="$LDFLAGS -L/usr/local/lib -R/usr/local/lib"
215	need_dash_r=1
216	AC_DEFINE(PAM_SUN_CODEBASE)
217	AC_DEFINE(LOGIN_NEEDS_UTMPX)
218	AC_DEFINE(LOGIN_NEEDS_TERM)
219	AC_DEFINE(PAM_TTY_KLUDGE)
220	AC_DEFINE(STREAMS_PUSH_ACQUIRES_CTTY)
221	# hardwire lastlog location (can't detect it on some versions)
222	conf_lastlog_location="/var/adm/lastlog"
223	AC_MSG_CHECKING(for obsolete utmp and wtmp in solaris2.x)
224	sol2ver=`echo "$host"| sed -e 's/.*[[0-9]]\.//'`
225	if test "$sol2ver" -ge 8; then
226		AC_MSG_RESULT(yes)
227		AC_DEFINE(DISABLE_UTMP)
228		AC_DEFINE(DISABLE_WTMP)
229	else
230		AC_MSG_RESULT(no)
231	fi
232	;;
233*-*-sunos4*)
234	CPPFLAGS="$CPPFLAGS -DSUNOS4"
235	AC_CHECK_FUNCS(getpwanam)
236	AC_DEFINE(PAM_SUN_CODEBASE)
237	conf_utmp_location=/etc/utmp
238	conf_wtmp_location=/var/adm/wtmp
239	conf_lastlog_location=/var/adm/lastlog
240	AC_DEFINE(USE_PIPES)
241	;;
242*-ncr-sysv*)
243	CPPFLAGS="$CPPFLAGS -I/usr/local/include"
244	LDFLAGS="$LDFLAGS -L/usr/local/lib"
245	LIBS="$LIBS -lc89"
246	AC_DEFINE(USE_PIPES)
247	;;
248*-sni-sysv*)
249	CPPFLAGS="$CPPFLAGS -I/usr/local/include"
250	# /usr/ucblib MUST NOT be searched on ReliantUNIX
251	LDFLAGS="$LDFLAGS -L/usr/local/lib"
252	IPADDR_IN_DISPLAY=yes
253	AC_DEFINE(USE_PIPES)
254	AC_DEFINE(IP_TOS_IS_BROKEN)
255	# /usr/ucblib/libucb.a no longer needed on ReliantUNIX
256	# Attention: always take care to bind libsocket and libnsl before libc,
257	# otherwise you will find lots of "SIOCGPGRP errno 22" on syslog
258	;;
259*-*-sysv4.2*)
260	CPPFLAGS="$CPPFLAGS -I/usr/local/include"
261	LDFLAGS="$LDFLAGS -L/usr/local/lib"
262	AC_DEFINE(USE_PIPES)
263	;;
264*-*-sysv5*)
265	CPPFLAGS="$CPPFLAGS -I/usr/local/include"
266	LDFLAGS="$LDFLAGS -L/usr/local/lib"
267	AC_DEFINE(USE_PIPES)
268	;;
269*-*-sysv*)
270	CPPFLAGS="$CPPFLAGS -I/usr/local/include"
271	LDFLAGS="$LDFLAGS -L/usr/local/lib"
272	;;
273*-*-sco3.2v4*)
274	CPPFLAGS="$CPPFLAGS -Dftruncate=chsize -I/usr/local/include"
275	LDFLAGS="$LDFLAGS -L/usr/local/lib"
276	LIBS="$LIBS -los -lprot -lx -ltinfo -lm"
277	RANLIB=true
278	no_dev_ptmx=1
279	AC_DEFINE(BROKEN_SYS_TERMIO_H)
280	AC_DEFINE(USE_PIPES)
281	AC_DEFINE(HAVE_SECUREWARE)
282	AC_DEFINE(DISABLE_SHADOW)
283	AC_DEFINE(BROKEN_SAVED_UIDS)
284	AC_CHECK_FUNCS(getluid setluid)
285	MANTYPE=man
286	do_sco3_extra_lib_check=yes
287	;;
288*-*-sco3.2v5*)
289	if test -z "$GCC"; then
290		CFLAGS="$CFLAGS -belf"
291	fi
292	CPPFLAGS="$CPPFLAGS -I/usr/local/include"
293	LDFLAGS="$LDFLAGS -L/usr/local/lib"
294	LIBS="$LIBS -lprot -lx -ltinfo -lm"
295	no_dev_ptmx=1
296	AC_DEFINE(USE_PIPES)
297	AC_DEFINE(HAVE_SECUREWARE)
298	AC_DEFINE(DISABLE_SHADOW)
299	AC_DEFINE(DISABLE_FD_PASSING)
300	AC_CHECK_FUNCS(getluid setluid)
301	MANTYPE=man
302	;;
303*-*-unicosmk*)
304	AC_DEFINE(USE_PIPES)
305	AC_DEFINE(DISABLE_FD_PASSING)
306	LDFLAGS="$LDFLAGS"
307	LIBS="$LIBS -lgen -lrsc -lshare -luex -lacm"
308	MANTYPE=cat
309	;;
310*-*-unicos*)
311	AC_DEFINE(USE_PIPES)
312	AC_DEFINE(DISABLE_FD_PASSING)
313	AC_DEFINE(NO_SSH_LASTLOG)
314	LDFLAGS="$LDFLAGS -Wl,-Dmsglevel=334:fatal"
315	LIBS="$LIBS -lgen -lrsc -lshare -luex -lacm"
316	MANTYPE=cat
317	;;
318*-dec-osf*)
319	AC_MSG_CHECKING(for Digital Unix SIA)
320	no_osfsia=""
321	AC_ARG_WITH(osfsia,
322		[  --with-osfsia           Enable Digital Unix SIA],
323		[
324			if test "x$withval" = "xno" ; then
325				AC_MSG_RESULT(disabled)
326				no_osfsia=1
327			fi
328		],
329	)
330	if test -z "$no_osfsia" ; then
331		if test -f /etc/sia/matrix.conf; then
332			AC_MSG_RESULT(yes)
333			AC_DEFINE(HAVE_OSF_SIA)
334			AC_DEFINE(DISABLE_LOGIN)
335			AC_DEFINE(DISABLE_FD_PASSING)
336			LIBS="$LIBS -lsecurity -ldb -lm -laud"
337		else
338			AC_MSG_RESULT(no)
339		fi
340	fi
341	AC_DEFINE(DISABLE_FD_PASSING)
342	;;
343
344*-*-nto-qnx)
345	AC_DEFINE(USE_PIPES)
346	AC_DEFINE(NO_X11_UNIX_SOCKETS)
347	AC_DEFINE(MISSING_NFDBITS)
348	AC_DEFINE(MISSING_HOWMANY)
349	AC_DEFINE(MISSING_FD_MASK)
350	;;
351esac
352
353# Allow user to specify flags
354AC_ARG_WITH(cflags,
355	[  --with-cflags           Specify additional flags to pass to compiler],
356	[
357		if test "x$withval" != "xno" ; then
358			CFLAGS="$CFLAGS $withval"
359		fi
360	]
361)
362AC_ARG_WITH(cppflags,
363	[  --with-cppflags         Specify additional flags to pass to preprocessor] ,
364	[
365		if test "x$withval" != "xno"; then
366			CPPFLAGS="$CPPFLAGS $withval"
367		fi
368	]
369)
370AC_ARG_WITH(ldflags,
371	[  --with-ldflags          Specify additional flags to pass to linker],
372	[
373		if test "x$withval" != "xno" ; then
374			LDFLAGS="$LDFLAGS $withval"
375		fi
376	]
377)
378AC_ARG_WITH(libs,
379	[  --with-libs             Specify additional libraries to link with],
380	[
381		if test "x$withval" != "xno" ; then
382			LIBS="$LIBS $withval"
383		fi
384	]
385)
386
387# Checks for header files.
388AC_CHECK_HEADERS(bstring.h crypt.h endian.h floatingpoint.h \
389	getopt.h glob.h ia.h lastlog.h libgen.h limits.h login.h \
390	login_cap.h maillock.h netdb.h netgroup.h \
391	netinet/in_systm.h paths.h pty.h readpassphrase.h \
392	rpc/types.h security/pam_appl.h shadow.h stddef.h stdint.h \
393	strings.h sys/bitypes.h sys/bsdtty.h sys/cdefs.h \
394	sys/mman.h sys/pstat.h sys/select.h sys/stat.h \
395	sys/stropts.h sys/sysmacros.h sys/time.h sys/timers.h \
396	sys/un.h time.h tmpdir.h ttyent.h usersec.h \
397	util.h utime.h utmp.h utmpx.h)
398
399# Checks for libraries.
400AC_CHECK_FUNC(yp_match, , AC_CHECK_LIB(nsl, yp_match))
401AC_CHECK_FUNC(setsockopt, , AC_CHECK_LIB(socket, setsockopt))
402
403dnl SCO OS3 needs this for libwrap
404if test "x$with_tcp_wrappers" != "xno" ; then
405    if test "x$do_sco3_extra_lib_check" = "xyes" ; then
406	AC_CHECK_LIB(rpc, innetgr, LIBS="-lrpc -lyp -lrpc $LIBS" , , -lyp -lrpc)
407    fi
408fi
409
410AC_CHECK_FUNC(getspnam, ,
411	AC_CHECK_LIB(gen, getspnam, LIBS="$LIBS -lgen"))
412
413AC_ARG_WITH(rpath,
414	[  --without-rpath         Disable auto-added -R linker paths],
415	[
416		if test "x$withval" = "xno" ; then
417			need_dash_r=""
418		fi
419		if test "x$withval" = "xyes" ; then
420			need_dash_r=1
421		fi
422	]
423)
424
425dnl zlib is required
426AC_ARG_WITH(zlib,
427	[  --with-zlib=PATH        Use zlib in PATH],
428	[
429		if test "x$withval" = "xno" ; then
430			AC_MSG_ERROR([*** zlib is required ***])
431		fi
432		if test -d "$withval/lib"; then
433			if test -n "${need_dash_r}"; then
434				LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
435			else
436				LDFLAGS="-L${withval}/lib ${LDFLAGS}"
437			fi
438		else
439			if test -n "${need_dash_r}"; then
440				LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
441			else
442				LDFLAGS="-L${withval} ${LDFLAGS}"
443			fi
444		fi
445		if test -d "$withval/include"; then
446			CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
447		else
448			CPPFLAGS="-I${withval} ${CPPFLAGS}"
449		fi
450	]
451)
452
453AC_CHECK_LIB(z, deflate, ,AC_MSG_ERROR([*** zlib missing - please install first or check config.log ***]))
454
455dnl UnixWare 2.x
456AC_CHECK_FUNC(strcasecmp,
457	[], [ AC_CHECK_LIB(resolv, strcasecmp, LIBS="$LIBS -lresolv") ]
458)
459AC_CHECK_FUNC(utimes,
460	[], [ AC_CHECK_LIB(c89, utimes, [AC_DEFINE(HAVE_UTIMES)
461					LIBS="$LIBS -lc89"]) ]
462)
463
464dnl    Checks for libutil functions
465AC_CHECK_HEADERS(libutil.h)
466AC_SEARCH_LIBS(login, util bsd, [AC_DEFINE(HAVE_LOGIN)])
467AC_CHECK_FUNCS(logout updwtmp logwtmp)
468
469AC_FUNC_STRFTIME
470
471# Check for ALTDIRFUNC glob() extension
472AC_MSG_CHECKING(for GLOB_ALTDIRFUNC support)
473AC_EGREP_CPP(FOUNDIT,
474	[
475		#include <glob.h>
476		#ifdef GLOB_ALTDIRFUNC
477		FOUNDIT
478		#endif
479	],
480	[
481		AC_DEFINE(GLOB_HAS_ALTDIRFUNC)
482		AC_MSG_RESULT(yes)
483	],
484	[
485		AC_MSG_RESULT(no)
486	]
487)
488
489# Check for g.gl_matchc glob() extension
490AC_MSG_CHECKING(for gl_matchc field in glob_t)
491AC_EGREP_CPP(FOUNDIT,
492        [
493                #include <glob.h>
494		int main(void){glob_t g; g.gl_matchc = 1;}
495        ],
496        [
497                AC_DEFINE(GLOB_HAS_GL_MATCHC)
498                AC_MSG_RESULT(yes)
499        ],
500        [
501                AC_MSG_RESULT(no)
502        ]
503)
504
505AC_MSG_CHECKING([whether struct dirent allocates space for d_name])
506AC_TRY_RUN(
507	[
508#include <sys/types.h>
509#include <dirent.h>
510int main(void){struct dirent d;exit(sizeof(d.d_name)<=sizeof(char));}
511	],
512	[AC_MSG_RESULT(yes)],
513	[
514		AC_MSG_RESULT(no)
515		AC_DEFINE(BROKEN_ONE_BYTE_DIRENT_D_NAME)
516	]
517)
518
519# Check whether user wants S/Key support
520SKEY_MSG="no"
521AC_ARG_WITH(skey,
522	[  --with-skey[[=PATH]]      Enable S/Key support
523                            (optionally in PATH)],
524	[
525		if test "x$withval" != "xno" ; then
526
527			if test "x$withval" != "xyes" ; then
528				CPPFLAGS="$CPPFLAGS -I${withval}/include"
529				LDFLAGS="$LDFLAGS -L${withval}/lib"
530			fi
531
532			AC_DEFINE(SKEY)
533			LIBS="-lskey $LIBS"
534			SKEY_MSG="yes"
535
536			AC_MSG_CHECKING([for s/key support])
537			AC_TRY_RUN(
538				[
539#include <stdio.h>
540#include <skey.h>
541int main() { char *ff = skey_keyinfo(""); ff=""; exit(0); }
542				],
543				[AC_MSG_RESULT(yes)],
544				[
545					AC_MSG_RESULT(no)
546					AC_MSG_ERROR([** Incomplete or missing s/key libraries.])
547				])
548		fi
549	]
550)
551
552# Check whether user wants OPIE support
553OPIE_MSG="no"
554AC_ARG_WITH(opie,
555	[  --with-opie[[=PATH]]      Enable OPIE support
556                            (optionally in PATH)],
557	[
558		if test "x$withval" != "xno" ; then
559
560			if test "x$withval" != "xyes" ; then
561				CPPFLAGS="$CPPFLAGS -I${withval}/include"
562				LDFLAGS="$LDFLAGS -L${withval}/lib"
563			fi
564
565			AC_DEFINE(SKEY)
566			AC_DEFINE(OPIE)
567			LIBS="-lopie $LIBS"
568			OPIE_MSG="yes"
569
570			AC_MSG_CHECKING([for opie support])
571			AC_TRY_RUN(
572				[
573#include <sys/types.h>
574#include <stdio.h>
575#include <opie.h>
576int main() { char *ff = opie_keyinfo(""); ff=""; return 0; }
577				],
578				[AC_MSG_RESULT(yes)],
579				[
580					AC_MSG_RESULT(no)
581					AC_MSG_ERROR([** Incomplete or missing opie libraries.])
582				])
583		fi
584	]
585)
586
587# Check whether user wants TCP wrappers support
588TCPW_MSG="no"
589AC_ARG_WITH(tcp-wrappers,
590	[  --with-tcp-wrappers[[=PATH]]      Enable tcpwrappers support
591                            (optionally in PATH)],
592	[
593		if test "x$withval" != "xno" ; then
594			saved_LIBS="$LIBS"
595			saved_LDFLAGS="$LDFLAGS"
596			saved_CPPFLAGS="$CPPFLAGS"
597			if test -n "${withval}" -a "${withval}" != "yes"; then
598				if test -d "${withval}/lib"; then
599					if test -n "${need_dash_r}"; then
600						LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
601					else
602						LDFLAGS="-L${withval}/lib ${LDFLAGS}"
603					fi
604				else
605					if test -n "${need_dash_r}"; then
606						LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
607					else
608						LDFLAGS="-L${withval} ${LDFLAGS}"
609					fi
610				fi
611				if test -d "${withval}/include"; then
612					CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
613				else
614					CPPFLAGS="-I${withval} ${CPPFLAGS}"
615				fi
616			fi
617			LIBWRAP="-lwrap"
618			LIBS="$LIBWRAP $LIBS"
619			AC_MSG_CHECKING(for libwrap)
620			AC_TRY_LINK(
621				[
622#include <tcpd.h>
623					int deny_severity = 0, allow_severity = 0;
624				],
625				[hosts_access(0);],
626				[
627					AC_MSG_RESULT(yes)
628					AC_DEFINE(LIBWRAP)
629					AC_SUBST(LIBWRAP)
630					TCPW_MSG="yes"
631				],
632				[
633					AC_MSG_ERROR([*** libwrap missing])
634				]
635			)
636			LIBS="$saved_LIBS"
637		fi
638	]
639)
640
641dnl    Checks for library functions. Please keep in alphabetical order
642AC_CHECK_FUNCS(\
643	arc4random __b64_ntop b64_ntop __b64_pton b64_pton basename bcopy \
644	bindresvport_sa clock fchmod fchown freeaddrinfo futimes \
645	gai_strerror getaddrinfo getcwd getgrouplist getnameinfo getopt \
646	getpeereid _getpty getrlimit getrusage getttyent glob inet_aton \
647	inet_ntoa inet_ntop innetgr login_getcapbool md5_crypt memmove \
648	mkdtemp mmap ngetaddrinfo nsleep ogetaddrinfo openpty pstat \
649	readpassphrase realpath recvmsg rresvport_af sendmsg setdtablesize \
650	setegid setenv seteuid setgroups setlogin setpcred setproctitle \
651	setresgid setreuid setrlimit setsid setvbuf sigaction sigvec \
652	snprintf socketpair strerror strlcat strlcpy strmode strnvis \
653	sysconf tcgetpgrp truncate utimes vhangup vsnprintf waitpid \
654)
655
656AC_SEARCH_LIBS(nanosleep, rt posix4, AC_DEFINE(HAVE_NANOSLEEP))
657
658dnl Make sure strsep prototype is defined before defining HAVE_STRSEP
659AC_CHECK_DECL(strsep, [AC_CHECK_FUNCS(strsep)])
660
661dnl IRIX and Solaris 2.5.1 have dirname() in libgen
662AC_CHECK_FUNCS(dirname, [AC_CHECK_HEADERS(libgen.h)] ,[
663	AC_CHECK_LIB(gen, dirname,[
664		AC_CACHE_CHECK([for broken dirname],
665			ac_cv_have_broken_dirname, [
666			save_LIBS="$LIBS"
667			LIBS="$LIBS -lgen"
668			AC_TRY_RUN(
669				[
670#include <libgen.h>
671#include <string.h>
672
673int main(int argc, char **argv) {
674    char *s, buf[32];
675
676    strncpy(buf,"/etc", 32);
677    s = dirname(buf);
678    if (!s || strncmp(s, "/", 32) != 0) {
679	exit(1);
680    } else {
681	exit(0);
682    }
683}
684				],
685				[ ac_cv_have_broken_dirname="no" ],
686				[ ac_cv_have_broken_dirname="yes" ]
687			)
688			LIBS="$save_LIBS"
689		])
690		if test "x$ac_cv_have_broken_dirname" = "xno" ; then
691			LIBS="$LIBS -lgen"
692			AC_DEFINE(HAVE_DIRNAME)
693			AC_CHECK_HEADERS(libgen.h)
694		fi
695	])
696])
697
698dnl    Checks for time functions
699AC_CHECK_FUNCS(gettimeofday time)
700dnl    Checks for utmp functions
701AC_CHECK_FUNCS(endutent getutent getutid getutline pututline setutent)
702AC_CHECK_FUNCS(utmpname)
703dnl    Checks for utmpx functions
704AC_CHECK_FUNCS(endutxent getutxent getutxid getutxline pututxline )
705AC_CHECK_FUNCS(setutxent utmpxname)
706
707AC_CHECK_FUNC(daemon,
708	[AC_DEFINE(HAVE_DAEMON)],
709	[AC_CHECK_LIB(bsd, daemon, [LIBS="$LIBS -lbsd"; AC_DEFINE(HAVE_DAEMON)])]
710)
711
712AC_CHECK_FUNC(getpagesize,
713	[AC_DEFINE(HAVE_GETPAGESIZE)],
714	[AC_CHECK_LIB(ucb, getpagesize, [LIBS="$LIBS -lucb"; AC_DEFINE(HAVE_GETPAGESIZE)])]
715)
716
717# Check for broken snprintf
718if test "x$ac_cv_func_snprintf" = "xyes" ; then
719	AC_MSG_CHECKING([whether snprintf correctly terminates long strings])
720	AC_TRY_RUN(
721		[
722#include <stdio.h>
723int main(void){char b[5];snprintf(b,5,"123456789");exit(b[4]!='\0');}
724		],
725		[AC_MSG_RESULT(yes)],
726		[
727			AC_MSG_RESULT(no)
728			AC_DEFINE(BROKEN_SNPRINTF)
729			AC_MSG_WARN([****** Your snprintf() function is broken, complain to your vendor])
730		]
731	)
732fi
733
734dnl see whether mkstemp() requires XXXXXX
735if test "x$ac_cv_func_mkdtemp" = "xyes" ; then
736AC_MSG_CHECKING([for (overly) strict mkstemp])
737AC_TRY_RUN(
738	[
739#include <stdlib.h>
740main() { char template[]="conftest.mkstemp-test";
741if (mkstemp(template) == -1)
742	exit(1);
743unlink(template); exit(0);
744}
745	],
746	[
747		AC_MSG_RESULT(no)
748	],
749	[
750		AC_MSG_RESULT(yes)
751		AC_DEFINE(HAVE_STRICT_MKSTEMP)
752	],
753	[
754		AC_MSG_RESULT(yes)
755		AC_DEFINE(HAVE_STRICT_MKSTEMP)
756	]
757)
758fi
759
760AC_FUNC_GETPGRP
761
762# Check for PAM libs
763PAM_MSG="no"
764AC_ARG_WITH(pam,
765	[  --with-pam              Enable PAM support ],
766	[
767		if test "x$withval" != "xno" ; then
768			if test "x$ac_cv_header_security_pam_appl_h" != "xyes" ; then
769				AC_MSG_ERROR([PAM headers not found])
770			fi
771
772			AC_CHECK_LIB(dl, dlopen, , )
773			AC_CHECK_LIB(pam, pam_set_item, , AC_MSG_ERROR([*** libpam missing]))
774			AC_CHECK_FUNCS(pam_getenvlist)
775
776			disable_shadow=yes
777			PAM_MSG="yes"
778
779			AC_DEFINE(USE_PAM)
780			if test $ac_cv_lib_dl_dlopen = yes; then
781				LIBPAM="-lpam -ldl"
782			else
783				LIBPAM="-lpam"
784			fi
785			AC_SUBST(LIBPAM)
786		fi
787	]
788)
789
790# Check for older PAM
791if test "x$PAM_MSG" = "xyes" ; then
792	# Check PAM strerror arguments (old PAM)
793	AC_MSG_CHECKING([whether pam_strerror takes only one argument])
794	AC_TRY_COMPILE(
795		[
796#include <stdlib.h>
797#include <security/pam_appl.h>
798		],
799		[(void)pam_strerror((pam_handle_t *)NULL, -1);],
800		[AC_MSG_RESULT(no)],
801		[
802			AC_DEFINE(HAVE_OLD_PAM)
803			AC_MSG_RESULT(yes)
804			PAM_MSG="yes (old library)"
805		]
806	)
807fi
808
809# Some systems want crypt() from libcrypt, *not* the version in OpenSSL,
810# because the system crypt() is more featureful.
811if test "x$check_for_libcrypt_before" = "x1"; then
812	AC_CHECK_LIB(crypt, crypt)
813fi
814
815# Search for OpenSSL
816saved_CPPFLAGS="$CPPFLAGS"
817saved_LDFLAGS="$LDFLAGS"
818AC_ARG_WITH(ssl-dir,
819	[  --with-ssl-dir=PATH     Specify path to OpenSSL installation ],
820	[
821		if test "x$withval" != "xno" ; then
822			if test -d "$withval/lib"; then
823				if test -n "${need_dash_r}"; then
824					LDFLAGS="-L${withval}/lib -R${withval}/lib ${LDFLAGS}"
825				else
826					LDFLAGS="-L${withval}/lib ${LDFLAGS}"
827				fi
828			else
829				if test -n "${need_dash_r}"; then
830					LDFLAGS="-L${withval} -R${withval} ${LDFLAGS}"
831				else
832					LDFLAGS="-L${withval} ${LDFLAGS}"
833				fi
834			fi
835			if test -d "$withval/include"; then
836				CPPFLAGS="-I${withval}/include ${CPPFLAGS}"
837			else
838				CPPFLAGS="-I${withval} ${CPPFLAGS}"
839			fi
840		fi
841	]
842)
843LIBS="$LIBS -lcrypto"
844AC_TRY_LINK_FUNC(RAND_add, AC_DEFINE(HAVE_OPENSSL),
845	[
846		dnl Check default openssl install dir
847		if test -n "${need_dash_r}"; then
848			LDFLAGS="-L/usr/local/ssl/lib -R/usr/local/ssl/lib ${saved_LDFLAGS}"
849		else
850			LDFLAGS="-L/usr/local/ssl/lib ${saved_LDFLAGS}"
851		fi
852		CPPFLAGS="-I/usr/local/ssl/include ${saved_CPPFLAGS}"
853		AC_TRY_LINK_FUNC(RAND_add, AC_DEFINE(HAVE_OPENSSL),
854			[
855				AC_MSG_ERROR([*** Can't find recent OpenSSL libcrypto (see config.log for details) ***])
856			]
857		)
858	]
859)
860
861# Determine OpenSSL header version
862AC_MSG_CHECKING([OpenSSL header version])
863AC_TRY_RUN(
864	[
865#include <stdio.h>
866#include <string.h>
867#include <openssl/opensslv.h>
868#define DATA "conftest.sslincver"
869int main(void) {
870        FILE *fd;
871        int rc;
872
873        fd = fopen(DATA,"w");
874        if(fd == NULL)
875                exit(1);
876
877	if ((rc = fprintf(fd ,"%x (%s)\n", OPENSSL_VERSION_NUMBER, OPENSSL_VERSION_TEXT)) <0)
878		exit(1);
879
880	exit(0);
881}
882	],
883	[
884		ssl_header_ver=`cat conftest.sslincver`
885		AC_MSG_RESULT($ssl_header_ver)
886	],
887	[
888		AC_MSG_RESULT(not found)
889		AC_MSG_ERROR(OpenSSL version header not found.)
890	]
891)
892
893# Determine OpenSSL library version
894AC_MSG_CHECKING([OpenSSL library version])
895AC_TRY_RUN(
896	[
897#include <stdio.h>
898#include <string.h>
899#include <openssl/opensslv.h>
900#include <openssl/crypto.h>
901#define DATA "conftest.ssllibver"
902int main(void) {
903        FILE *fd;
904        int rc;
905
906        fd = fopen(DATA,"w");
907        if(fd == NULL)
908                exit(1);
909
910	if ((rc = fprintf(fd ,"%x (%s)\n", SSLeay(), SSLeay_version(SSLEAY_VERSION))) <0)
911		exit(1);
912
913	exit(0);
914}
915	],
916	[
917		ssl_library_ver=`cat conftest.ssllibver`
918		AC_MSG_RESULT($ssl_library_ver)
919	],
920	[
921		AC_MSG_RESULT(not found)
922		AC_MSG_ERROR(OpenSSL library not found.)
923	]
924)
925
926# Sanity check OpenSSL headers
927AC_MSG_CHECKING([whether OpenSSL's headers match the library])
928AC_TRY_RUN(
929	[
930#include <string.h>
931#include <openssl/opensslv.h>
932int main(void) { exit(SSLeay() == OPENSSL_VERSION_NUMBER ? 0 : 1); }
933	],
934	[
935		AC_MSG_RESULT(yes)
936	],
937	[
938		AC_MSG_RESULT(no)
939		AC_MSG_ERROR(Your OpenSSL headers do not match your library)
940	]
941)
942
943# Some Linux systems (Slackware) need crypt() from libcrypt, *not* the
944# version in OpenSSL. Skip this for PAM
945if test "x$PAM_MSG" = "xno" -a "x$check_for_libcrypt_later" = "x1"; then
946	AC_CHECK_LIB(crypt, crypt, LIBS="$LIBS -lcrypt")
947fi
948
949
950### Configure cryptographic random number support
951
952# Check wheter OpenSSL seeds itself
953AC_MSG_CHECKING([whether OpenSSL's PRNG is internally seeded])
954AC_TRY_RUN(
955	[
956#include <string.h>
957#include <openssl/rand.h>
958int main(void) { exit(RAND_status() == 1 ? 0 : 1); }
959	],
960	[
961		OPENSSL_SEEDS_ITSELF=yes
962		AC_MSG_RESULT(yes)
963	],
964	[
965		AC_MSG_RESULT(no)
966		# Default to use of the rand helper if OpenSSL doesn't
967		# seed itself
968		USE_RAND_HELPER=yes
969	]
970)
971
972
973# Do we want to force the use of the rand helper?
974AC_ARG_WITH(rand-helper,
975	[  --with-rand-helper      Use subprocess to gather strong randomness ],
976	[
977		if test "x$withval" = "xno" ; then
978			# Force use of OpenSSL's internal RNG, even if
979			# the previous test showed it to be unseeded.
980			if test -z "$OPENSSL_SEEDS_ITSELF" ; then
981				AC_MSG_WARN([*** Forcing use of OpenSSL's non-self-seeding PRNG])
982				OPENSSL_SEEDS_ITSELF=yes
983				USE_RAND_HELPER=""
984			fi
985		else
986			USE_RAND_HELPER=yes
987		fi
988	],
989)
990
991# Which randomness source do we use?
992if test ! -z "$OPENSSL_SEEDS_ITSELF" -a -z "$USE_RAND_HELPER" ; then
993	# OpenSSL only
994	AC_DEFINE(OPENSSL_PRNG_ONLY)
995	RAND_MSG="OpenSSL internal ONLY"
996	INSTALL_SSH_RAND_HELPER=""
997elif test ! -z "$USE_RAND_HELPER" ; then
998	# install rand helper
999	RAND_MSG="ssh-rand-helper"
1000	INSTALL_SSH_RAND_HELPER="yes"
1001fi
1002AC_SUBST(INSTALL_SSH_RAND_HELPER)
1003
1004### Configuration of ssh-rand-helper
1005
1006# PRNGD TCP socket
1007AC_ARG_WITH(prngd-port,
1008	[  --with-prngd-port=PORT  read entropy from PRNGD/EGD TCP localhost:PORT],
1009	[
1010		case "$withval" in
1011		no)
1012			withval=""
1013			;;
1014		[[0-9]]*)
1015			;;
1016		*)
1017			AC_MSG_ERROR(You must specify a numeric port number for --with-prngd-port)
1018			;;
1019		esac
1020		if test ! -z "$withval" ; then
1021			PRNGD_PORT="$withval"
1022			AC_DEFINE_UNQUOTED(PRNGD_PORT, $PRNGD_PORT)
1023		fi
1024	]
1025)
1026
1027# PRNGD Unix domain socket
1028AC_ARG_WITH(prngd-socket,
1029	[  --with-prngd-socket=FILE read entropy from PRNGD/EGD socket FILE (default=/var/run/egd-pool)],
1030	[
1031		case "$withval" in
1032		yes)
1033			withval="/var/run/egd-pool"
1034			;;
1035		no)
1036			withval=""
1037			;;
1038		/*)
1039			;;
1040		*)
1041			AC_MSG_ERROR(You must specify an absolute path to the entropy socket)
1042			;;
1043		esac
1044
1045		if test ! -z "$withval" ; then
1046			if test ! -z "$PRNGD_PORT" ; then
1047				AC_MSG_ERROR(You may not specify both a PRNGD/EGD port and socket)
1048			fi
1049			if test ! -r "$withval" ; then
1050				AC_MSG_WARN(Entropy socket is not readable)
1051			fi
1052			PRNGD_SOCKET="$withval"
1053			AC_DEFINE_UNQUOTED(PRNGD_SOCKET, "$PRNGD_SOCKET")
1054		fi
1055	],
1056	[
1057		# Check for existing socket only if we don't have a random device already
1058		if test "$USE_RAND_HELPER" = yes ; then
1059			AC_MSG_CHECKING(for PRNGD/EGD socket)
1060			# Insert other locations here
1061			for sock in /var/run/egd-pool /dev/egd-pool /etc/entropy; do
1062				if test -r $sock && $TEST_MINUS_S_SH -c "test -S $sock -o -p $sock" ; then
1063					PRNGD_SOCKET="$sock"
1064					AC_DEFINE_UNQUOTED(PRNGD_SOCKET, "$PRNGD_SOCKET")
1065					break;
1066				fi
1067			done
1068			if test ! -z "$PRNGD_SOCKET" ; then
1069				AC_MSG_RESULT($PRNGD_SOCKET)
1070			else
1071				AC_MSG_RESULT(not found)
1072			fi
1073		fi
1074	]
1075)
1076
1077# Change default command timeout for hashing entropy source
1078entropy_timeout=200
1079AC_ARG_WITH(entropy-timeout,
1080	[  --with-entropy-timeout  Specify entropy gathering command timeout (msec)],
1081	[
1082		if test "x$withval" != "xno" ; then
1083			entropy_timeout=$withval
1084		fi
1085	]
1086)
1087AC_DEFINE_UNQUOTED(ENTROPY_TIMEOUT_MSEC, $entropy_timeout)
1088
1089SSH_PRIVSEP_USER=sshd
1090AC_ARG_WITH(privsep-user,
1091	[  --with-privsep-user=user Specify non-privileged user for privilege separation],
1092	[
1093		if test -n "$withval"; then
1094			SSH_PRIVSEP_USER=$withval
1095		fi
1096	]
1097)
1098AC_DEFINE_UNQUOTED(SSH_PRIVSEP_USER, "$SSH_PRIVSEP_USER")
1099AC_SUBST(SSH_PRIVSEP_USER)
1100
1101# We do this little dance with the search path to insure
1102# that programs that we select for use by installed programs
1103# (which may be run by the super-user) come from trusted
1104# locations before they come from the user's private area.
1105# This should help avoid accidentally configuring some
1106# random version of a program in someone's personal bin.
1107
1108OPATH=$PATH
1109PATH=/bin:/usr/bin
1110test -h /bin 2> /dev/null && PATH=/usr/bin
1111test -d /sbin && PATH=$PATH:/sbin
1112test -d /usr/sbin && PATH=$PATH:/usr/sbin
1113PATH=$PATH:/etc:$OPATH
1114
1115# These programs are used by the command hashing source to gather entropy
1116OSSH_PATH_ENTROPY_PROG(PROG_LS, ls)
1117OSSH_PATH_ENTROPY_PROG(PROG_NETSTAT, netstat)
1118OSSH_PATH_ENTROPY_PROG(PROG_ARP, arp)
1119OSSH_PATH_ENTROPY_PROG(PROG_IFCONFIG, ifconfig)
1120OSSH_PATH_ENTROPY_PROG(PROG_JSTAT, jstat)
1121OSSH_PATH_ENTROPY_PROG(PROG_PS, ps)
1122OSSH_PATH_ENTROPY_PROG(PROG_SAR, sar)
1123OSSH_PATH_ENTROPY_PROG(PROG_W, w)
1124OSSH_PATH_ENTROPY_PROG(PROG_WHO, who)
1125OSSH_PATH_ENTROPY_PROG(PROG_LAST, last)
1126OSSH_PATH_ENTROPY_PROG(PROG_LASTLOG, lastlog)
1127OSSH_PATH_ENTROPY_PROG(PROG_DF, df)
1128OSSH_PATH_ENTROPY_PROG(PROG_VMSTAT, vmstat)
1129OSSH_PATH_ENTROPY_PROG(PROG_UPTIME, uptime)
1130OSSH_PATH_ENTROPY_PROG(PROG_IPCS, ipcs)
1131OSSH_PATH_ENTROPY_PROG(PROG_TAIL, tail)
1132# restore PATH
1133PATH=$OPATH
1134
1135# Where does ssh-rand-helper get its randomness from?
1136INSTALL_SSH_PRNG_CMDS=""
1137if test ! -z "$INSTALL_SSH_RAND_HELPER" ; then
1138	if test ! -z "$PRNGD_PORT" ; then
1139		RAND_HELPER_MSG="TCP localhost:$PRNGD_PORT"
1140	elif test ! -z "$PRNGD_SOCKET" ; then
1141		RAND_HELPER_MSG="Unix domain socket \"$PRNGD_SOCKET\""
1142	else
1143		RAND_HELPER_MSG="Command hashing (timeout $entropy_timeout)"
1144		RAND_HELPER_CMDHASH=yes
1145		INSTALL_SSH_PRNG_CMDS="yes"
1146	fi
1147fi
1148AC_SUBST(INSTALL_SSH_PRNG_CMDS)
1149
1150
1151# Cheap hack to ensure NEWS-OS libraries are arranged right.
1152if test ! -z "$SONY" ; then
1153  LIBS="$LIBS -liberty";
1154fi
1155
1156# Checks for data types
1157AC_CHECK_SIZEOF(char, 1)
1158AC_CHECK_SIZEOF(short int, 2)
1159AC_CHECK_SIZEOF(int, 4)
1160AC_CHECK_SIZEOF(long int, 4)
1161AC_CHECK_SIZEOF(long long int, 8)
1162
1163# Sanity check long long for some platforms (AIX)
1164if test "x$ac_cv_sizeof_long_long_int" = "x4" ; then
1165	ac_cv_sizeof_long_long_int=0
1166fi
1167
1168# More checks for data types
1169AC_CACHE_CHECK([for u_int type], ac_cv_have_u_int, [
1170	AC_TRY_COMPILE(
1171		[ #include <sys/types.h> ],
1172		[ u_int a; a = 1;],
1173		[ ac_cv_have_u_int="yes" ],
1174		[ ac_cv_have_u_int="no" ]
1175	)
1176])
1177if test "x$ac_cv_have_u_int" = "xyes" ; then
1178	AC_DEFINE(HAVE_U_INT)
1179	have_u_int=1
1180fi
1181
1182AC_CACHE_CHECK([for intXX_t types], ac_cv_have_intxx_t, [
1183	AC_TRY_COMPILE(
1184		[ #include <sys/types.h> ],
1185		[ int8_t a; int16_t b; int32_t c; a = b = c = 1;],
1186		[ ac_cv_have_intxx_t="yes" ],
1187		[ ac_cv_have_intxx_t="no" ]
1188	)
1189])
1190if test "x$ac_cv_have_intxx_t" = "xyes" ; then
1191	AC_DEFINE(HAVE_INTXX_T)
1192	have_intxx_t=1
1193fi
1194
1195if (test -z "$have_intxx_t" && \
1196           test "x$ac_cv_header_stdint_h" = "xyes")
1197then
1198    AC_MSG_CHECKING([for intXX_t types in stdint.h])
1199	AC_TRY_COMPILE(
1200		[ #include <stdint.h> ],
1201		[ int8_t a; int16_t b; int32_t c; a = b = c = 1;],
1202		[
1203			AC_DEFINE(HAVE_INTXX_T)
1204			AC_MSG_RESULT(yes)
1205		],
1206		[ AC_MSG_RESULT(no) ]
1207	)
1208fi
1209
1210AC_CACHE_CHECK([for int64_t type], ac_cv_have_int64_t, [
1211	AC_TRY_COMPILE(
1212		[
1213#include <sys/types.h>
1214#ifdef HAVE_STDINT_H
1215# include <stdint.h>
1216#endif
1217#include <sys/socket.h>
1218#ifdef HAVE_SYS_BITYPES_H
1219# include <sys/bitypes.h>
1220#endif
1221		],
1222		[ int64_t a; a = 1;],
1223		[ ac_cv_have_int64_t="yes" ],
1224		[ ac_cv_have_int64_t="no" ]
1225	)
1226])
1227if test "x$ac_cv_have_int64_t" = "xyes" ; then
1228	AC_DEFINE(HAVE_INT64_T)
1229fi
1230
1231AC_CACHE_CHECK([for u_intXX_t types], ac_cv_have_u_intxx_t, [
1232	AC_TRY_COMPILE(
1233		[ #include <sys/types.h> ],
1234		[ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;],
1235		[ ac_cv_have_u_intxx_t="yes" ],
1236		[ ac_cv_have_u_intxx_t="no" ]
1237	)
1238])
1239if test "x$ac_cv_have_u_intxx_t" = "xyes" ; then
1240	AC_DEFINE(HAVE_U_INTXX_T)
1241	have_u_intxx_t=1
1242fi
1243
1244if test -z "$have_u_intxx_t" ; then
1245    AC_MSG_CHECKING([for u_intXX_t types in sys/socket.h])
1246	AC_TRY_COMPILE(
1247		[ #include <sys/socket.h> ],
1248		[ u_int8_t a; u_int16_t b; u_int32_t c; a = b = c = 1;],
1249		[
1250			AC_DEFINE(HAVE_U_INTXX_T)
1251			AC_MSG_RESULT(yes)
1252		],
1253		[ AC_MSG_RESULT(no) ]
1254	)
1255fi
1256
1257AC_CACHE_CHECK([for u_int64_t types], ac_cv_have_u_int64_t, [
1258	AC_TRY_COMPILE(
1259		[ #include <sys/types.h> ],
1260		[ u_int64_t a; a = 1;],
1261		[ ac_cv_have_u_int64_t="yes" ],
1262		[ ac_cv_have_u_int64_t="no" ]
1263	)
1264])
1265if test "x$ac_cv_have_u_int64_t" = "xyes" ; then
1266	AC_DEFINE(HAVE_U_INT64_T)
1267	have_u_int64_t=1
1268fi
1269
1270if test -z "$have_u_int64_t" ; then
1271    AC_MSG_CHECKING([for u_int64_t type in sys/bitypes.h])
1272	AC_TRY_COMPILE(
1273		[ #include <sys/bitypes.h> ],
1274		[ u_int64_t a; a = 1],
1275		[
1276			AC_DEFINE(HAVE_U_INT64_T)
1277			AC_MSG_RESULT(yes)
1278		],
1279		[ AC_MSG_RESULT(no) ]
1280	)
1281fi
1282
1283if test -z "$have_u_intxx_t" ; then
1284	AC_CACHE_CHECK([for uintXX_t types], ac_cv_have_uintxx_t, [
1285		AC_TRY_COMPILE(
1286			[
1287#include <sys/types.h>
1288			],
1289			[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1; ],
1290			[ ac_cv_have_uintxx_t="yes" ],
1291			[ ac_cv_have_uintxx_t="no" ]
1292		)
1293	])
1294	if test "x$ac_cv_have_uintxx_t" = "xyes" ; then
1295		AC_DEFINE(HAVE_UINTXX_T)
1296	fi
1297fi
1298
1299if test -z "$have_uintxx_t" ; then
1300    AC_MSG_CHECKING([for uintXX_t types in stdint.h])
1301	AC_TRY_COMPILE(
1302		[ #include <stdint.h> ],
1303		[ uint8_t a; uint16_t b; uint32_t c; a = b = c = 1;],
1304		[
1305			AC_DEFINE(HAVE_UINTXX_T)
1306			AC_MSG_RESULT(yes)
1307		],
1308		[ AC_MSG_RESULT(no) ]
1309	)
1310fi
1311
1312if (test -z "$have_u_intxx_t" || test -z "$have_intxx_t" && \
1313           test "x$ac_cv_header_sys_bitypes_h" = "xyes")
1314then
1315	AC_MSG_CHECKING([for intXX_t and u_intXX_t types in sys/bitypes.h])
1316	AC_TRY_COMPILE(
1317		[
1318#include <sys/bitypes.h>
1319		],
1320		[
1321			int8_t a; int16_t b; int32_t c;
1322			u_int8_t e; u_int16_t f; u_int32_t g;
1323			a = b = c = e = f = g = 1;
1324		],
1325		[
1326			AC_DEFINE(HAVE_U_INTXX_T)
1327			AC_DEFINE(HAVE_INTXX_T)
1328			AC_MSG_RESULT(yes)
1329		],
1330		[AC_MSG_RESULT(no)]
1331	)
1332fi
1333
1334
1335AC_CACHE_CHECK([for u_char], ac_cv_have_u_char, [
1336	AC_TRY_COMPILE(
1337		[
1338#include <sys/types.h>
1339		],
1340		[ u_char foo; foo = 125; ],
1341		[ ac_cv_have_u_char="yes" ],
1342		[ ac_cv_have_u_char="no" ]
1343	)
1344])
1345if test "x$ac_cv_have_u_char" = "xyes" ; then
1346	AC_DEFINE(HAVE_U_CHAR)
1347fi
1348
1349TYPE_SOCKLEN_T
1350
1351AC_CHECK_TYPES(sig_atomic_t,,,[#include <signal.h>])
1352
1353AC_CACHE_CHECK([for size_t], ac_cv_have_size_t, [
1354	AC_TRY_COMPILE(
1355		[
1356#include <sys/types.h>
1357		],
1358		[ size_t foo; foo = 1235; ],
1359		[ ac_cv_have_size_t="yes" ],
1360		[ ac_cv_have_size_t="no" ]
1361	)
1362])
1363if test "x$ac_cv_have_size_t" = "xyes" ; then
1364	AC_DEFINE(HAVE_SIZE_T)
1365fi
1366
1367AC_CACHE_CHECK([for ssize_t], ac_cv_have_ssize_t, [
1368	AC_TRY_COMPILE(
1369		[
1370#include <sys/types.h>
1371		],
1372		[ ssize_t foo; foo = 1235; ],
1373		[ ac_cv_have_ssize_t="yes" ],
1374		[ ac_cv_have_ssize_t="no" ]
1375	)
1376])
1377if test "x$ac_cv_have_ssize_t" = "xyes" ; then
1378	AC_DEFINE(HAVE_SSIZE_T)
1379fi
1380
1381AC_CACHE_CHECK([for clock_t], ac_cv_have_clock_t, [
1382	AC_TRY_COMPILE(
1383		[
1384#include <time.h>
1385		],
1386		[ clock_t foo; foo = 1235; ],
1387		[ ac_cv_have_clock_t="yes" ],
1388		[ ac_cv_have_clock_t="no" ]
1389	)
1390])
1391if test "x$ac_cv_have_clock_t" = "xyes" ; then
1392	AC_DEFINE(HAVE_CLOCK_T)
1393fi
1394
1395AC_CACHE_CHECK([for sa_family_t], ac_cv_have_sa_family_t, [
1396	AC_TRY_COMPILE(
1397		[
1398#include <sys/types.h>
1399#include <sys/socket.h>
1400		],
1401		[ sa_family_t foo; foo = 1235; ],
1402		[ ac_cv_have_sa_family_t="yes" ],
1403		[ AC_TRY_COMPILE(
1404		  [
1405#include <sys/types.h>
1406#include <sys/socket.h>
1407#include <netinet/in.h>
1408		],
1409		[ sa_family_t foo; foo = 1235; ],
1410		[ ac_cv_have_sa_family_t="yes" ],
1411
1412		[ ac_cv_have_sa_family_t="no" ]
1413	)]
1414	)
1415])
1416if test "x$ac_cv_have_sa_family_t" = "xyes" ; then
1417	AC_DEFINE(HAVE_SA_FAMILY_T)
1418fi
1419
1420AC_CACHE_CHECK([for pid_t], ac_cv_have_pid_t, [
1421	AC_TRY_COMPILE(
1422		[
1423#include <sys/types.h>
1424		],
1425		[ pid_t foo; foo = 1235; ],
1426		[ ac_cv_have_pid_t="yes" ],
1427		[ ac_cv_have_pid_t="no" ]
1428	)
1429])
1430if test "x$ac_cv_have_pid_t" = "xyes" ; then
1431	AC_DEFINE(HAVE_PID_T)
1432fi
1433
1434AC_CACHE_CHECK([for mode_t], ac_cv_have_mode_t, [
1435	AC_TRY_COMPILE(
1436		[
1437#include <sys/types.h>
1438		],
1439		[ mode_t foo; foo = 1235; ],
1440		[ ac_cv_have_mode_t="yes" ],
1441		[ ac_cv_have_mode_t="no" ]
1442	)
1443])
1444if test "x$ac_cv_have_mode_t" = "xyes" ; then
1445	AC_DEFINE(HAVE_MODE_T)
1446fi
1447
1448
1449AC_CACHE_CHECK([for struct sockaddr_storage], ac_cv_have_struct_sockaddr_storage, [
1450	AC_TRY_COMPILE(
1451		[
1452#include <sys/types.h>
1453#include <sys/socket.h>
1454		],
1455		[ struct sockaddr_storage s; ],
1456		[ ac_cv_have_struct_sockaddr_storage="yes" ],
1457		[ ac_cv_have_struct_sockaddr_storage="no" ]
1458	)
1459])
1460if test "x$ac_cv_have_struct_sockaddr_storage" = "xyes" ; then
1461	AC_DEFINE(HAVE_STRUCT_SOCKADDR_STORAGE)
1462fi
1463
1464AC_CACHE_CHECK([for struct sockaddr_in6], ac_cv_have_struct_sockaddr_in6, [
1465	AC_TRY_COMPILE(
1466		[
1467#include <sys/types.h>
1468#include <netinet/in.h>
1469		],
1470		[ struct sockaddr_in6 s; s.sin6_family = 0; ],
1471		[ ac_cv_have_struct_sockaddr_in6="yes" ],
1472		[ ac_cv_have_struct_sockaddr_in6="no" ]
1473	)
1474])
1475if test "x$ac_cv_have_struct_sockaddr_in6" = "xyes" ; then
1476	AC_DEFINE(HAVE_STRUCT_SOCKADDR_IN6)
1477fi
1478
1479AC_CACHE_CHECK([for struct in6_addr], ac_cv_have_struct_in6_addr, [
1480	AC_TRY_COMPILE(
1481		[
1482#include <sys/types.h>
1483#include <netinet/in.h>
1484		],
1485		[ struct in6_addr s; s.s6_addr[0] = 0; ],
1486		[ ac_cv_have_struct_in6_addr="yes" ],
1487		[ ac_cv_have_struct_in6_addr="no" ]
1488	)
1489])
1490if test "x$ac_cv_have_struct_in6_addr" = "xyes" ; then
1491	AC_DEFINE(HAVE_STRUCT_IN6_ADDR)
1492fi
1493
1494AC_CACHE_CHECK([for struct addrinfo], ac_cv_have_struct_addrinfo, [
1495	AC_TRY_COMPILE(
1496		[
1497#include <sys/types.h>
1498#include <sys/socket.h>
1499#include <netdb.h>
1500		],
1501		[ struct addrinfo s; s.ai_flags = AI_PASSIVE; ],
1502		[ ac_cv_have_struct_addrinfo="yes" ],
1503		[ ac_cv_have_struct_addrinfo="no" ]
1504	)
1505])
1506if test "x$ac_cv_have_struct_addrinfo" = "xyes" ; then
1507	AC_DEFINE(HAVE_STRUCT_ADDRINFO)
1508fi
1509
1510AC_CACHE_CHECK([for struct timeval], ac_cv_have_struct_timeval, [
1511	AC_TRY_COMPILE(
1512		[ #include <sys/time.h> ],
1513		[ struct timeval tv; tv.tv_sec = 1;],
1514		[ ac_cv_have_struct_timeval="yes" ],
1515		[ ac_cv_have_struct_timeval="no" ]
1516	)
1517])
1518if test "x$ac_cv_have_struct_timeval" = "xyes" ; then
1519	AC_DEFINE(HAVE_STRUCT_TIMEVAL)
1520	have_struct_timeval=1
1521fi
1522
1523AC_CHECK_TYPES(struct timespec)
1524
1525# We need int64_t or else certian parts of the compile will fail.
1526if test "x$ac_cv_have_int64_t" = "xno" -a \
1527	"x$ac_cv_sizeof_long_int" != "x8" -a \
1528	"x$ac_cv_sizeof_long_long_int" = "x0" ; then
1529	echo "OpenSSH requires int64_t support.  Contact your vendor or install"
1530	echo "an alternative compiler (I.E., GCC) before continuing."
1531	echo ""
1532	exit 1;
1533else
1534dnl test snprintf (broken on SCO w/gcc)
1535	AC_TRY_RUN(
1536		[
1537#include <stdio.h>
1538#include <string.h>
1539#ifdef HAVE_SNPRINTF
1540main()
1541{
1542	char buf[50];
1543	char expected_out[50];
1544	int mazsize = 50 ;
1545#if (SIZEOF_LONG_INT == 8)
1546	long int num = 0x7fffffffffffffff;
1547#else
1548	long long num = 0x7fffffffffffffffll;
1549#endif
1550	strcpy(expected_out, "9223372036854775807");
1551	snprintf(buf, mazsize, "%lld", num);
1552	if(strcmp(buf, expected_out) != 0)
1553        	exit(1);
1554	exit(0);
1555}
1556#else
1557main() { exit(0); }
1558#endif
1559		], [ true ], [ AC_DEFINE(BROKEN_SNPRINTF) ]
1560	)
1561fi
1562
1563dnl Checks for structure members
1564OSSH_CHECK_HEADER_FOR_FIELD(ut_host, utmp.h, HAVE_HOST_IN_UTMP)
1565OSSH_CHECK_HEADER_FOR_FIELD(ut_host, utmpx.h, HAVE_HOST_IN_UTMPX)
1566OSSH_CHECK_HEADER_FOR_FIELD(syslen, utmpx.h, HAVE_SYSLEN_IN_UTMPX)
1567OSSH_CHECK_HEADER_FOR_FIELD(ut_pid, utmp.h, HAVE_PID_IN_UTMP)
1568OSSH_CHECK_HEADER_FOR_FIELD(ut_type, utmp.h, HAVE_TYPE_IN_UTMP)
1569OSSH_CHECK_HEADER_FOR_FIELD(ut_type, utmpx.h, HAVE_TYPE_IN_UTMPX)
1570OSSH_CHECK_HEADER_FOR_FIELD(ut_tv, utmp.h, HAVE_TV_IN_UTMP)
1571OSSH_CHECK_HEADER_FOR_FIELD(ut_id, utmp.h, HAVE_ID_IN_UTMP)
1572OSSH_CHECK_HEADER_FOR_FIELD(ut_id, utmpx.h, HAVE_ID_IN_UTMPX)
1573OSSH_CHECK_HEADER_FOR_FIELD(ut_addr, utmp.h, HAVE_ADDR_IN_UTMP)
1574OSSH_CHECK_HEADER_FOR_FIELD(ut_addr, utmpx.h, HAVE_ADDR_IN_UTMPX)
1575OSSH_CHECK_HEADER_FOR_FIELD(ut_addr_v6, utmp.h, HAVE_ADDR_V6_IN_UTMP)
1576OSSH_CHECK_HEADER_FOR_FIELD(ut_addr_v6, utmpx.h, HAVE_ADDR_V6_IN_UTMPX)
1577OSSH_CHECK_HEADER_FOR_FIELD(ut_exit, utmp.h, HAVE_EXIT_IN_UTMP)
1578OSSH_CHECK_HEADER_FOR_FIELD(ut_time, utmp.h, HAVE_TIME_IN_UTMP)
1579OSSH_CHECK_HEADER_FOR_FIELD(ut_time, utmpx.h, HAVE_TIME_IN_UTMPX)
1580OSSH_CHECK_HEADER_FOR_FIELD(ut_tv, utmpx.h, HAVE_TV_IN_UTMPX)
1581
1582AC_CHECK_MEMBERS([struct stat.st_blksize])
1583
1584AC_CACHE_CHECK([for ss_family field in struct sockaddr_storage],
1585		ac_cv_have_ss_family_in_struct_ss, [
1586	AC_TRY_COMPILE(
1587		[
1588#include <sys/types.h>
1589#include <sys/socket.h>
1590		],
1591		[ struct sockaddr_storage s; s.ss_family = 1; ],
1592		[ ac_cv_have_ss_family_in_struct_ss="yes" ],
1593		[ ac_cv_have_ss_family_in_struct_ss="no" ],
1594	)
1595])
1596if test "x$ac_cv_have_ss_family_in_struct_ss" = "xyes" ; then
1597	AC_DEFINE(HAVE_SS_FAMILY_IN_SS)
1598fi
1599
1600AC_CACHE_CHECK([for __ss_family field in struct sockaddr_storage],
1601		ac_cv_have___ss_family_in_struct_ss, [
1602	AC_TRY_COMPILE(
1603		[
1604#include <sys/types.h>
1605#include <sys/socket.h>
1606		],
1607		[ struct sockaddr_storage s; s.__ss_family = 1; ],
1608		[ ac_cv_have___ss_family_in_struct_ss="yes" ],
1609		[ ac_cv_have___ss_family_in_struct_ss="no" ]
1610	)
1611])
1612if test "x$ac_cv_have___ss_family_in_struct_ss" = "xyes" ; then
1613	AC_DEFINE(HAVE___SS_FAMILY_IN_SS)
1614fi
1615
1616AC_CACHE_CHECK([for pw_class field in struct passwd],
1617		ac_cv_have_pw_class_in_struct_passwd, [
1618	AC_TRY_COMPILE(
1619		[
1620#include <pwd.h>
1621		],
1622		[ struct passwd p; p.pw_class = 0; ],
1623		[ ac_cv_have_pw_class_in_struct_passwd="yes" ],
1624		[ ac_cv_have_pw_class_in_struct_passwd="no" ]
1625	)
1626])
1627if test "x$ac_cv_have_pw_class_in_struct_passwd" = "xyes" ; then
1628	AC_DEFINE(HAVE_PW_CLASS_IN_PASSWD)
1629fi
1630
1631AC_CACHE_CHECK([for pw_expire field in struct passwd],
1632		ac_cv_have_pw_expire_in_struct_passwd, [
1633	AC_TRY_COMPILE(
1634		[
1635#include <pwd.h>
1636		],
1637		[ struct passwd p; p.pw_expire = 0; ],
1638		[ ac_cv_have_pw_expire_in_struct_passwd="yes" ],
1639		[ ac_cv_have_pw_expire_in_struct_passwd="no" ]
1640	)
1641])
1642if test "x$ac_cv_have_pw_expire_in_struct_passwd" = "xyes" ; then
1643	AC_DEFINE(HAVE_PW_EXPIRE_IN_PASSWD)
1644fi
1645
1646AC_CACHE_CHECK([for pw_change field in struct passwd],
1647		ac_cv_have_pw_change_in_struct_passwd, [
1648	AC_TRY_COMPILE(
1649		[
1650#include <pwd.h>
1651		],
1652		[ struct passwd p; p.pw_change = 0; ],
1653		[ ac_cv_have_pw_change_in_struct_passwd="yes" ],
1654		[ ac_cv_have_pw_change_in_struct_passwd="no" ]
1655	)
1656])
1657if test "x$ac_cv_have_pw_change_in_struct_passwd" = "xyes" ; then
1658	AC_DEFINE(HAVE_PW_CHANGE_IN_PASSWD)
1659fi
1660
1661dnl make sure we're using the real structure members and not defines
1662AC_CACHE_CHECK([for msg_accrights field in struct msghdr],
1663		ac_cv_have_accrights_in_msghdr, [
1664	AC_TRY_RUN(
1665		[
1666#include <sys/types.h>
1667#include <sys/socket.h>
1668#include <sys/uio.h>
1669int main() {
1670#ifdef msg_accrights
1671exit(1);
1672#endif
1673struct msghdr m;
1674m.msg_accrights = 0;
1675exit(0);
1676}
1677		],
1678		[ ac_cv_have_accrights_in_msghdr="yes" ],
1679		[ ac_cv_have_accrights_in_msghdr="no" ]
1680	)
1681])
1682if test "x$ac_cv_have_accrights_in_msghdr" = "xyes" ; then
1683	AC_DEFINE(HAVE_ACCRIGHTS_IN_MSGHDR)
1684fi
1685
1686AC_CACHE_CHECK([for msg_control field in struct msghdr],
1687		ac_cv_have_control_in_msghdr, [
1688	AC_TRY_RUN(
1689		[
1690#include <sys/types.h>
1691#include <sys/socket.h>
1692#include <sys/uio.h>
1693int main() {
1694#ifdef msg_control
1695exit(1);
1696#endif
1697struct msghdr m;
1698m.msg_control = 0;
1699exit(0);
1700}
1701		],
1702		[ ac_cv_have_control_in_msghdr="yes" ],
1703		[ ac_cv_have_control_in_msghdr="no" ]
1704	)
1705])
1706if test "x$ac_cv_have_control_in_msghdr" = "xyes" ; then
1707	AC_DEFINE(HAVE_CONTROL_IN_MSGHDR)
1708fi
1709
1710AC_CACHE_CHECK([if libc defines __progname], ac_cv_libc_defines___progname, [
1711	AC_TRY_LINK([],
1712		[ extern char *__progname; printf("%s", __progname); ],
1713		[ ac_cv_libc_defines___progname="yes" ],
1714		[ ac_cv_libc_defines___progname="no" ]
1715	)
1716])
1717if test "x$ac_cv_libc_defines___progname" = "xyes" ; then
1718	AC_DEFINE(HAVE___PROGNAME)
1719fi
1720
1721AC_CACHE_CHECK([whether $CC implements __FUNCTION__], ac_cv_cc_implements___FUNCTION__, [
1722	AC_TRY_LINK([
1723#include <stdio.h>
1724],
1725		[ printf("%s", __FUNCTION__); ],
1726		[ ac_cv_cc_implements___FUNCTION__="yes" ],
1727		[ ac_cv_cc_implements___FUNCTION__="no" ]
1728	)
1729])
1730if test "x$ac_cv_cc_implements___FUNCTION__" = "xyes" ; then
1731	AC_DEFINE(HAVE___FUNCTION__)
1732fi
1733
1734AC_CACHE_CHECK([whether $CC implements __func__], ac_cv_cc_implements___func__, [
1735	AC_TRY_LINK([
1736#include <stdio.h>
1737],
1738		[ printf("%s", __func__); ],
1739		[ ac_cv_cc_implements___func__="yes" ],
1740		[ ac_cv_cc_implements___func__="no" ]
1741	)
1742])
1743if test "x$ac_cv_cc_implements___func__" = "xyes" ; then
1744	AC_DEFINE(HAVE___func__)
1745fi
1746
1747AC_CACHE_CHECK([whether getopt has optreset support],
1748		ac_cv_have_getopt_optreset, [
1749	AC_TRY_LINK(
1750		[
1751#if HAVE_GETOPT_H
1752#include <getopt.h>
1753#elif HAVE_UNISTD_H
1754#include <unistd.h>
1755#endif
1756		],
1757		[ extern int optreset; optreset = 0; ],
1758		[ ac_cv_have_getopt_optreset="yes" ],
1759		[ ac_cv_have_getopt_optreset="no" ]
1760	)
1761])
1762if test "x$ac_cv_have_getopt_optreset" = "xyes" ; then
1763	AC_DEFINE(HAVE_GETOPT_OPTRESET)
1764fi
1765
1766AC_CACHE_CHECK([if libc defines sys_errlist], ac_cv_libc_defines_sys_errlist, [
1767	AC_TRY_LINK([],
1768		[ extern const char *const sys_errlist[]; printf("%s", sys_errlist[0]);],
1769		[ ac_cv_libc_defines_sys_errlist="yes" ],
1770		[ ac_cv_libc_defines_sys_errlist="no" ]
1771	)
1772])
1773if test "x$ac_cv_libc_defines_sys_errlist" = "xyes" ; then
1774	AC_DEFINE(HAVE_SYS_ERRLIST)
1775fi
1776
1777
1778AC_CACHE_CHECK([if libc defines sys_nerr], ac_cv_libc_defines_sys_nerr, [
1779	AC_TRY_LINK([],
1780		[ extern int sys_nerr; printf("%i", sys_nerr);],
1781		[ ac_cv_libc_defines_sys_nerr="yes" ],
1782		[ ac_cv_libc_defines_sys_nerr="no" ]
1783	)
1784])
1785if test "x$ac_cv_libc_defines_sys_nerr" = "xyes" ; then
1786	AC_DEFINE(HAVE_SYS_NERR)
1787fi
1788
1789SCARD_MSG="no"
1790
1791# Check whether user wants sectok support
1792AC_ARG_WITH(sectok,
1793	[  --with-sectok           Enable smartcard support using libsectok],
1794	[
1795		if test "x$withval" != "xno" ; then
1796			if test "x$withval" != "xyes" ; then
1797				CPPFLAGS="$CPPFLAGS -I${withval}"
1798				LDFLAGS="$LDFLAGS -L${withval}"
1799				if test ! -z "$need_dash_r" ; then
1800					LDFLAGS="$LDFLAGS -R${withval}"
1801				fi
1802				if test ! -z "$blibpath" ; then
1803					blibpath="$blibpath:${withval}"
1804				fi
1805			fi
1806			AC_CHECK_HEADERS(sectok.h)
1807			if test "$ac_cv_header_sectok_h" != yes; then
1808				AC_MSG_ERROR(Can't find sectok.h)
1809			fi
1810			AC_CHECK_LIB(sectok, sectok_open)
1811			if test "$ac_cv_lib_sectok_sectok_open" != yes; then
1812				AC_MSG_ERROR(Can't find libsectok)
1813			fi
1814			AC_DEFINE(SMARTCARD)
1815			AC_DEFINE(USE_SECTOK)
1816			SCARD_MSG="yes, using sectok"
1817		fi
1818	]
1819)
1820
1821# Check whether user wants OpenSC support
1822AC_ARG_WITH(opensc,
1823	AC_HELP_STRING([--with-opensc=PFX],
1824		       [Enable smartcard support using OpenSC]),
1825	opensc_config_prefix="$withval", opensc_config_prefix="")
1826if test x$opensc_config_prefix != x ; then
1827  OPENSC_CONFIG=$opensc_config_prefix/bin/opensc-config
1828  AC_PATH_PROG(OPENSC_CONFIG, opensc-config, no)
1829  if test "$OPENSC_CONFIG" != "no"; then
1830    LIBOPENSC_CFLAGS=`$OPENSC_CONFIG --cflags`
1831    LIBOPENSC_LIBS=`$OPENSC_CONFIG --libs`
1832    CPPFLAGS="$CPPFLAGS $LIBOPENSC_CFLAGS"
1833    LDFLAGS="$LDFLAGS $LIBOPENSC_LIBS"
1834    AC_DEFINE(SMARTCARD)
1835    AC_DEFINE(USE_OPENSC)
1836    SCARD_MSG="yes, using OpenSC"
1837  fi
1838fi
1839
1840# Check whether user wants Kerberos 5 support
1841KRB5_MSG="no"
1842AC_ARG_WITH(kerberos5,
1843        [  --with-kerberos5=PATH   Enable Kerberos 5 support],
1844        [
1845                if test "x$withval" != "xno" ; then
1846                        if test "x$withval" = "xyes" ; then
1847                                KRB5ROOT="/usr/local"
1848                        else
1849                                KRB5ROOT=${withval}
1850                        fi
1851			CPPFLAGS="$CPPFLAGS -I${KRB5ROOT}/include"
1852                        LDFLAGS="$LDFLAGS -L${KRB5ROOT}/lib"
1853                        AC_DEFINE(KRB5)
1854			KRB5_MSG="yes"
1855                        AC_MSG_CHECKING(whether we are using Heimdal)
1856                        AC_TRY_COMPILE([ #include <krb5.h> ],
1857                                       [ char *tmp = heimdal_version; ],
1858                                       [ AC_MSG_RESULT(yes)
1859                                         AC_DEFINE(HEIMDAL)
1860                                         K5LIBS="-lkrb5 -ldes -lcom_err -lasn1 -lroken"
1861                                       ],
1862                                       [ AC_MSG_RESULT(no)
1863                                         K5LIBS="-lkrb5 -lk5crypto -lcom_err"
1864                                       ]
1865                        )
1866                        if test ! -z "$need_dash_r" ; then
1867                                LDFLAGS="$LDFLAGS -R${KRB5ROOT}/lib"
1868                        fi
1869                        if test ! -z "$blibpath" ; then
1870                                blibpath="$blibpath:${KRB5ROOT}/lib"
1871                        fi
1872                        AC_CHECK_LIB(resolv, dn_expand, , )
1873
1874                        KRB5=yes
1875                fi
1876        ]
1877)
1878# Check whether user wants Kerberos 4 support
1879KRB4_MSG="no"
1880AC_ARG_WITH(kerberos4,
1881	[  --with-kerberos4=PATH   Enable Kerberos 4 support],
1882	[
1883		if test "x$withval" != "xno" ; then
1884			if test "x$withval" != "xyes" ; then
1885				CPPFLAGS="$CPPFLAGS -I${withval}/include"
1886				LDFLAGS="$LDFLAGS -L${withval}/lib"
1887				if test ! -z "$need_dash_r" ; then
1888					LDFLAGS="$LDFLAGS -R${withval}/lib"
1889				fi
1890				if test ! -z "$blibpath" ; then
1891					blibpath="$blibpath:${withval}/lib"
1892				fi
1893			else
1894				if test -d /usr/include/kerberosIV ; then
1895					CPPFLAGS="$CPPFLAGS -I/usr/include/kerberosIV"
1896				fi
1897			fi
1898
1899			AC_CHECK_HEADERS(krb.h)
1900			if test "$ac_cv_header_krb_h" != yes; then
1901				AC_MSG_WARN([Cannot find krb.h, build may fail])
1902			fi
1903			AC_CHECK_LIB(krb, main)
1904			if test "$ac_cv_lib_krb_main" != yes; then
1905				AC_CHECK_LIB(krb4, main)
1906				if test "$ac_cv_lib_krb4_main" != yes; then
1907					AC_MSG_WARN([Cannot find libkrb nor libkrb4, build may fail])
1908				else
1909					KLIBS="-lkrb4"
1910				fi
1911			else
1912				KLIBS="-lkrb"
1913			fi
1914			AC_CHECK_LIB(des, des_cbc_encrypt)
1915			if test "$ac_cv_lib_des_des_cbc_encrypt" != yes; then
1916				AC_CHECK_LIB(des425, des_cbc_encrypt)
1917				if test "$ac_cv_lib_des425_des_cbc_encrypt" != yes; then
1918					AC_MSG_WARN([Cannot find libdes nor libdes425, build may fail])
1919				else
1920					KLIBS="-ldes425"
1921				fi
1922			else
1923				KLIBS="-ldes"
1924			fi
1925			AC_CHECK_LIB(resolv, dn_expand, , )
1926			KRB4=yes
1927			KRB4_MSG="yes"
1928			AC_DEFINE(KRB4)
1929		fi
1930	]
1931)
1932
1933# Check whether user wants AFS support
1934AFS_MSG="no"
1935AC_ARG_WITH(afs,
1936	[  --with-afs=PATH         Enable AFS support],
1937	[
1938		if test "x$withval" != "xno" ; then
1939
1940			if test "x$withval" != "xyes" ; then
1941				CPPFLAGS="$CPPFLAGS -I${withval}/include"
1942				LDFLAGS="$LDFLAGS -L${withval}/lib"
1943			fi
1944
1945			if test -z "$KRB4" ; then
1946				AC_MSG_WARN([AFS requires Kerberos IV support, build may fail])
1947			fi
1948
1949			LIBS="-lkafs $LIBS"
1950			if test ! -z "$AFS_LIBS" ; then
1951				LIBS="$LIBS $AFS_LIBS"
1952			fi
1953			AC_DEFINE(AFS)
1954			AFS_MSG="yes"
1955		fi
1956	]
1957)
1958LIBS="$LIBS $KLIBS $K5LIBS"
1959
1960# Looking for programs, paths and files
1961
1962PRIVSEP_PATH=/var/empty
1963AC_ARG_WITH(privsep-path,
1964	[  --with-privsep-path=xxx Path for privilege separation chroot (default=/var/empty)],
1965	[
1966		if test "x$withval" != "$no" ; then
1967			PRIVSEP_PATH=$withval
1968		fi
1969	]
1970)
1971AC_SUBST(PRIVSEP_PATH)
1972
1973AC_ARG_WITH(xauth,
1974	[  --with-xauth=PATH       Specify path to xauth program ],
1975	[
1976		if test "x$withval" != "xno" ; then
1977			xauth_path=$withval
1978		fi
1979	],
1980	[
1981		TestPath="$PATH"
1982		TestPath="${TestPath}${PATH_SEPARATOR}/usr/X/bin"
1983		TestPath="${TestPath}${PATH_SEPARATOR}/usr/bin/X11"
1984		TestPath="${TestPath}${PATH_SEPARATOR}/usr/X11R6/bin"
1985		TestPath="${TestPath}${PATH_SEPARATOR}/usr/openwin/bin"
1986		AC_PATH_PROG(xauth_path, xauth, , $TestPath)
1987		if (test ! -z "$xauth_path" && test -x "/usr/openwin/bin/xauth") ; then
1988			xauth_path="/usr/openwin/bin/xauth"
1989		fi
1990	]
1991)
1992
1993STRIP_OPT=-s
1994AC_ARG_ENABLE(strip,
1995	[  --disable-strip         Disable calling strip(1) on install],
1996	[
1997		if test "x$enableval" = "xno" ; then
1998			STRIP_OPT=
1999		fi
2000	]
2001)
2002AC_SUBST(STRIP_OPT)
2003
2004if test -z "$xauth_path" ; then
2005	XAUTH_PATH="undefined"
2006	AC_SUBST(XAUTH_PATH)
2007else
2008	AC_DEFINE_UNQUOTED(XAUTH_PATH, "$xauth_path")
2009	XAUTH_PATH=$xauth_path
2010	AC_SUBST(XAUTH_PATH)
2011fi
2012
2013# Check for mail directory (last resort if we cannot get it from headers)
2014if test ! -z "$MAIL" ; then
2015	maildir=`dirname $MAIL`
2016	AC_DEFINE_UNQUOTED(MAIL_DIRECTORY, "$maildir")
2017fi
2018
2019if test -z "$no_dev_ptmx" ; then
2020	if test "x$disable_ptmx_check" != "xyes" ; then
2021		AC_CHECK_FILE("/dev/ptmx",
2022			[
2023				AC_DEFINE_UNQUOTED(HAVE_DEV_PTMX)
2024				have_dev_ptmx=1
2025			]
2026		)
2027	fi
2028fi
2029AC_CHECK_FILE("/dev/ptc",
2030	[
2031		AC_DEFINE_UNQUOTED(HAVE_DEV_PTS_AND_PTC)
2032		have_dev_ptc=1
2033	]
2034)
2035
2036# Options from here on. Some of these are preset by platform above
2037AC_ARG_WITH(mantype,
2038	[  --with-mantype=man|cat|doc  Set man page type],
2039	[
2040		case "$withval" in
2041		man|cat|doc)
2042			MANTYPE=$withval
2043			;;
2044		*)
2045			AC_MSG_ERROR(invalid man type: $withval)
2046			;;
2047		esac
2048	]
2049)
2050if test -z "$MANTYPE"; then
2051	TestPath="/usr/bin${PATH_SEPARATOR}/usr/ucb"
2052	AC_PATH_PROGS(NROFF, nroff awf, /bin/false, $TestPath)
2053	if ${NROFF} -mdoc ${srcdir}/ssh.1 >/dev/null 2>&1; then
2054		MANTYPE=doc
2055	elif ${NROFF} -man ${srcdir}/ssh.1 >/dev/null 2>&1; then
2056		MANTYPE=man
2057	else
2058		MANTYPE=cat
2059	fi
2060fi
2061AC_SUBST(MANTYPE)
2062if test "$MANTYPE" = "doc"; then
2063	mansubdir=man;
2064else
2065	mansubdir=$MANTYPE;
2066fi
2067AC_SUBST(mansubdir)
2068
2069# Check whether to enable MD5 passwords
2070MD5_MSG="no"
2071AC_ARG_WITH(md5-passwords,
2072	[  --with-md5-passwords    Enable use of MD5 passwords],
2073	[
2074		if test "x$withval" != "xno" ; then
2075			AC_DEFINE(HAVE_MD5_PASSWORDS)
2076			MD5_MSG="yes"
2077		fi
2078	]
2079)
2080
2081# Whether to disable shadow password support
2082AC_ARG_WITH(shadow,
2083	[  --without-shadow        Disable shadow password support],
2084	[
2085		if test "x$withval" = "xno" ; then
2086			AC_DEFINE(DISABLE_SHADOW)
2087			disable_shadow=yes
2088		fi
2089	]
2090)
2091
2092if test -z "$disable_shadow" ; then
2093	AC_MSG_CHECKING([if the systems has expire shadow information])
2094	AC_TRY_COMPILE(
2095	[
2096#include <sys/types.h>
2097#include <shadow.h>
2098	struct spwd sp;
2099	],[ sp.sp_expire = sp.sp_lstchg = sp.sp_inact = 0; ],
2100	[ sp_expire_available=yes ], []
2101	)
2102
2103	if test "x$sp_expire_available" = "xyes" ; then
2104		AC_MSG_RESULT(yes)
2105		AC_DEFINE(HAS_SHADOW_EXPIRE)
2106	else
2107		AC_MSG_RESULT(no)
2108	fi
2109fi
2110
2111# Use ip address instead of hostname in $DISPLAY
2112if test ! -z "$IPADDR_IN_DISPLAY" ; then
2113	DISPLAY_HACK_MSG="yes"
2114	AC_DEFINE(IPADDR_IN_DISPLAY)
2115else
2116	DISPLAY_HACK_MSG="no"
2117	AC_ARG_WITH(ipaddr-display,
2118		[  --with-ipaddr-display   Use ip address instead of hostname in \$DISPLAY],
2119		[
2120			if test "x$withval" != "xno" ; then
2121				AC_DEFINE(IPADDR_IN_DISPLAY)
2122				DISPLAY_HACK_MSG="yes"
2123			fi
2124		]
2125	)
2126fi
2127
2128dnl BSD systems use /etc/login.conf so --with-default-path= has no effect
2129if test $ac_cv_func_login_getcapbool = "yes" -a \
2130	$ac_cv_header_login_cap_h = "yes" ; then
2131	USES_LOGIN_CONF=yes
2132fi
2133# Whether to mess with the default path
2134SERVER_PATH_MSG="(default)"
2135AC_ARG_WITH(default-path,
2136	[  --with-default-path=    Specify default \$PATH environment for server],
2137	[
2138		if test "$USES_LOGIN_CONF" = "yes" ; then
2139			AC_MSG_WARN([
2140--with-default-path=PATH has no effect on this system.
2141Edit /etc/login.conf instead.])
2142		elif test "x$withval" != "xno" ; then
2143			user_path="$withval"
2144			SERVER_PATH_MSG="$withval"
2145		fi
2146	],
2147	[ if test "$USES_LOGIN_CONF" = "yes" ; then
2148	AC_MSG_WARN([Make sure the path to scp is in /etc/login.conf])
2149	else
2150	AC_TRY_RUN(
2151		[
2152/* find out what STDPATH is */
2153#include <stdio.h>
2154#ifdef HAVE_PATHS_H
2155# include <paths.h>
2156#endif
2157#ifndef _PATH_STDPATH
2158# ifdef _PATH_USERPATH	/* Irix */
2159#  define _PATH_STDPATH _PATH_USERPATH
2160# else
2161#  define _PATH_STDPATH "/usr/bin:/bin:/usr/sbin:/sbin"
2162# endif
2163#endif
2164#include <sys/types.h>
2165#include <sys/stat.h>
2166#include <fcntl.h>
2167#define DATA "conftest.stdpath"
2168
2169main()
2170{
2171	FILE *fd;
2172	int rc;
2173
2174	fd = fopen(DATA,"w");
2175	if(fd == NULL)
2176		exit(1);
2177
2178	if ((rc = fprintf(fd,"%s", _PATH_STDPATH)) < 0)
2179		exit(1);
2180
2181	exit(0);
2182}
2183		], [ user_path=`cat conftest.stdpath` ],
2184		[ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ],
2185		[ user_path="/usr/bin:/bin:/usr/sbin:/sbin" ]
2186	)
2187# make sure $bindir is in USER_PATH so scp will work
2188		t_bindir=`eval echo ${bindir}`
2189		case $t_bindir in
2190			NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$prefix~"` ;;
2191		esac
2192		case $t_bindir in
2193			NONE/*) t_bindir=`echo $t_bindir | sed "s~NONE~$ac_default_prefix~"` ;;
2194		esac
2195		echo $user_path | grep ":$t_bindir"  > /dev/null 2>&1
2196		if test $? -ne 0  ; then
2197			echo $user_path | grep "^$t_bindir"  > /dev/null 2>&1
2198			if test $? -ne 0  ; then
2199				user_path=$user_path:$t_bindir
2200				AC_MSG_RESULT(Adding $t_bindir to USER_PATH so scp will work)
2201			fi
2202		fi
2203	fi ]
2204)
2205if test "$USES_LOGIN_CONF" != "yes" ; then
2206	AC_DEFINE_UNQUOTED(USER_PATH, "$user_path")
2207	AC_SUBST(user_path)
2208fi
2209
2210# Set superuser path separately to user path
2211AC_ARG_WITH(superuser-path,
2212	[  --with-superuser-path=  Specify different path for super-user],
2213	[
2214		if test "x$withval" != "xno" ; then
2215			AC_DEFINE_UNQUOTED(SUPERUSER_PATH, "$withval")
2216			superuser_path=$withval
2217		fi
2218	]
2219)
2220
2221
2222# Whether to force IPv4 by default (needed on broken glibc Linux)
2223IPV4_HACK_MSG="no"
2224AC_ARG_WITH(ipv4-default,
2225	[  --with-ipv4-default     Use IPv4 by connections unless '-6' specified],
2226	[
2227		if test "x$withval" != "xno" ; then
2228			AC_DEFINE(IPV4_DEFAULT)
2229			IPV4_HACK_MSG="yes"
2230		fi
2231	]
2232)
2233
2234AC_MSG_CHECKING([if we need to convert IPv4 in IPv6-mapped addresses])
2235IPV4_IN6_HACK_MSG="no"
2236AC_ARG_WITH(4in6,
2237	[  --with-4in6             Check for and convert IPv4 in IPv6 mapped addresses],
2238	[
2239		if test "x$withval" != "xno" ; then
2240			AC_MSG_RESULT(yes)
2241			AC_DEFINE(IPV4_IN_IPV6)
2242			IPV4_IN6_HACK_MSG="yes"
2243		else
2244			AC_MSG_RESULT(no)
2245		fi
2246	],[
2247		if test "x$inet6_default_4in6" = "xyes"; then
2248			AC_MSG_RESULT([yes (default)])
2249			AC_DEFINE(IPV4_IN_IPV6)
2250			IPV4_IN6_HACK_MSG="yes"
2251		else
2252			AC_MSG_RESULT([no (default)])
2253		fi
2254	]
2255)
2256
2257# Whether to enable BSD auth support
2258BSD_AUTH_MSG=no
2259AC_ARG_WITH(bsd-auth,
2260	[  --with-bsd-auth         Enable BSD auth support],
2261	[
2262		if test "x$withval" != "xno" ; then
2263			AC_DEFINE(BSD_AUTH)
2264			BSD_AUTH_MSG=yes
2265		fi
2266	]
2267)
2268
2269# Where to place sshd.pid
2270piddir=/var/run
2271# make sure the directory exists
2272if test ! -d $piddir ; then
2273	piddir=`eval echo ${sysconfdir}`
2274	case $piddir in
2275 		NONE/*) piddir=`echo $piddir | sed "s~NONE~$ac_default_prefix~"` ;;
2276	esac
2277fi
2278
2279AC_ARG_WITH(pid-dir,
2280	[  --with-pid-dir=PATH     Specify location of ssh.pid file],
2281	[
2282		if test "x$withval" != "xno" ; then
2283			piddir=$withval
2284			if test ! -d $piddir ; then
2285			AC_MSG_WARN([** no $piddir directory on this system **])
2286			fi
2287		fi
2288	]
2289)
2290
2291AC_DEFINE_UNQUOTED(_PATH_SSH_PIDDIR, "$piddir")
2292AC_SUBST(piddir)
2293
2294dnl allow user to disable some login recording features
2295AC_ARG_ENABLE(lastlog,
2296	[  --disable-lastlog       disable use of lastlog even if detected [no]],
2297	[ AC_DEFINE(DISABLE_LASTLOG) ]
2298)
2299AC_ARG_ENABLE(utmp,
2300	[  --disable-utmp          disable use of utmp even if detected [no]],
2301	[ AC_DEFINE(DISABLE_UTMP) ]
2302)
2303AC_ARG_ENABLE(utmpx,
2304	[  --disable-utmpx         disable use of utmpx even if detected [no]],
2305	[ AC_DEFINE(DISABLE_UTMPX) ]
2306)
2307AC_ARG_ENABLE(wtmp,
2308	[  --disable-wtmp          disable use of wtmp even if detected [no]],
2309	[ AC_DEFINE(DISABLE_WTMP) ]
2310)
2311AC_ARG_ENABLE(wtmpx,
2312	[  --disable-wtmpx         disable use of wtmpx even if detected [no]],
2313	[ AC_DEFINE(DISABLE_WTMPX) ]
2314)
2315AC_ARG_ENABLE(libutil,
2316	[  --disable-libutil       disable use of libutil (login() etc.) [no]],
2317	[ AC_DEFINE(DISABLE_LOGIN) ]
2318)
2319AC_ARG_ENABLE(pututline,
2320	[  --disable-pututline     disable use of pututline() etc. ([uw]tmp) [no]],
2321	[ AC_DEFINE(DISABLE_PUTUTLINE) ]
2322)
2323AC_ARG_ENABLE(pututxline,
2324	[  --disable-pututxline    disable use of pututxline() etc. ([uw]tmpx) [no]],
2325	[ AC_DEFINE(DISABLE_PUTUTXLINE) ]
2326)
2327AC_ARG_WITH(lastlog,
2328  [  --with-lastlog=FILE|DIR specify lastlog location [common locations]],
2329	[
2330		if test "x$withval" = "xno" ; then
2331			AC_DEFINE(DISABLE_LASTLOG)
2332		else
2333			conf_lastlog_location=$withval
2334		fi
2335	]
2336)
2337
2338dnl lastlog, [uw]tmpx? detection
2339dnl  NOTE: set the paths in the platform section to avoid the
2340dnl   need for command-line parameters
2341dnl lastlog and [uw]tmp are subject to a file search if all else fails
2342
2343dnl lastlog detection
2344dnl  NOTE: the code itself will detect if lastlog is a directory
2345AC_MSG_CHECKING([if your system defines LASTLOG_FILE])
2346AC_TRY_COMPILE([
2347#include <sys/types.h>
2348#include <utmp.h>
2349#ifdef HAVE_LASTLOG_H
2350#  include <lastlog.h>
2351#endif
2352#ifdef HAVE_PATHS_H
2353#  include <paths.h>
2354#endif
2355#ifdef HAVE_LOGIN_H
2356# include <login.h>
2357#endif
2358	],
2359	[ char *lastlog = LASTLOG_FILE; ],
2360	[ AC_MSG_RESULT(yes) ],
2361	[
2362		AC_MSG_RESULT(no)
2363		AC_MSG_CHECKING([if your system defines _PATH_LASTLOG])
2364		AC_TRY_COMPILE([
2365#include <sys/types.h>
2366#include <utmp.h>
2367#ifdef HAVE_LASTLOG_H
2368#  include <lastlog.h>
2369#endif
2370#ifdef HAVE_PATHS_H
2371#  include <paths.h>
2372#endif
2373		],
2374		[ char *lastlog = _PATH_LASTLOG; ],
2375		[ AC_MSG_RESULT(yes) ],
2376		[
2377			AC_MSG_RESULT(no)
2378			system_lastlog_path=no
2379		])
2380	]
2381)
2382
2383if test -z "$conf_lastlog_location"; then
2384	if test x"$system_lastlog_path" = x"no" ; then
2385		for f in /var/log/lastlog /usr/adm/lastlog /var/adm/lastlog /etc/security/lastlog ; do
2386				if (test -d "$f" || test -f "$f") ; then
2387					conf_lastlog_location=$f
2388				fi
2389		done
2390		if test -z "$conf_lastlog_location"; then
2391			AC_MSG_WARN([** Cannot find lastlog **])
2392			dnl Don't define DISABLE_LASTLOG - that means we don't try wtmp/wtmpx
2393		fi
2394	fi
2395fi
2396
2397if test -n "$conf_lastlog_location"; then
2398	AC_DEFINE_UNQUOTED(CONF_LASTLOG_FILE, "$conf_lastlog_location")
2399fi
2400
2401dnl utmp detection
2402AC_MSG_CHECKING([if your system defines UTMP_FILE])
2403AC_TRY_COMPILE([
2404#include <sys/types.h>
2405#include <utmp.h>
2406#ifdef HAVE_PATHS_H
2407#  include <paths.h>
2408#endif
2409	],
2410	[ char *utmp = UTMP_FILE; ],
2411	[ AC_MSG_RESULT(yes) ],
2412	[ AC_MSG_RESULT(no)
2413	  system_utmp_path=no ]
2414)
2415if test -z "$conf_utmp_location"; then
2416	if test x"$system_utmp_path" = x"no" ; then
2417		for f in /etc/utmp /usr/adm/utmp /var/run/utmp; do
2418			if test -f $f ; then
2419				conf_utmp_location=$f
2420			fi
2421		done
2422		if test -z "$conf_utmp_location"; then
2423			AC_DEFINE(DISABLE_UTMP)
2424		fi
2425	fi
2426fi
2427if test -n "$conf_utmp_location"; then
2428	AC_DEFINE_UNQUOTED(CONF_UTMP_FILE, "$conf_utmp_location")
2429fi
2430
2431dnl wtmp detection
2432AC_MSG_CHECKING([if your system defines WTMP_FILE])
2433AC_TRY_COMPILE([
2434#include <sys/types.h>
2435#include <utmp.h>
2436#ifdef HAVE_PATHS_H
2437#  include <paths.h>
2438#endif
2439	],
2440	[ char *wtmp = WTMP_FILE; ],
2441	[ AC_MSG_RESULT(yes) ],
2442	[ AC_MSG_RESULT(no)
2443	  system_wtmp_path=no ]
2444)
2445if test -z "$conf_wtmp_location"; then
2446	if test x"$system_wtmp_path" = x"no" ; then
2447		for f in /usr/adm/wtmp /var/log/wtmp; do
2448			if test -f $f ; then
2449				conf_wtmp_location=$f
2450			fi
2451		done
2452		if test -z "$conf_wtmp_location"; then
2453			AC_DEFINE(DISABLE_WTMP)
2454		fi
2455	fi
2456fi
2457if test -n "$conf_wtmp_location"; then
2458	AC_DEFINE_UNQUOTED(CONF_WTMP_FILE, "$conf_wtmp_location")
2459fi
2460
2461
2462dnl utmpx detection - I don't know any system so perverse as to require
2463dnl  utmpx, but not define UTMPX_FILE (ditto wtmpx.) No doubt it's out
2464dnl  there, though.
2465AC_MSG_CHECKING([if your system defines UTMPX_FILE])
2466AC_TRY_COMPILE([
2467#include <sys/types.h>
2468#include <utmp.h>
2469#ifdef HAVE_UTMPX_H
2470#include <utmpx.h>
2471#endif
2472#ifdef HAVE_PATHS_H
2473#  include <paths.h>
2474#endif
2475	],
2476	[ char *utmpx = UTMPX_FILE; ],
2477	[ AC_MSG_RESULT(yes) ],
2478	[ AC_MSG_RESULT(no)
2479	  system_utmpx_path=no ]
2480)
2481if test -z "$conf_utmpx_location"; then
2482	if test x"$system_utmpx_path" = x"no" ; then
2483		AC_DEFINE(DISABLE_UTMPX)
2484	fi
2485else
2486	AC_DEFINE_UNQUOTED(CONF_UTMPX_FILE, "$conf_utmpx_location")
2487fi
2488
2489dnl wtmpx detection
2490AC_MSG_CHECKING([if your system defines WTMPX_FILE])
2491AC_TRY_COMPILE([
2492#include <sys/types.h>
2493#include <utmp.h>
2494#ifdef HAVE_UTMPX_H
2495#include <utmpx.h>
2496#endif
2497#ifdef HAVE_PATHS_H
2498#  include <paths.h>
2499#endif
2500	],
2501	[ char *wtmpx = WTMPX_FILE; ],
2502	[ AC_MSG_RESULT(yes) ],
2503	[ AC_MSG_RESULT(no)
2504	  system_wtmpx_path=no ]
2505)
2506if test -z "$conf_wtmpx_location"; then
2507	if test x"$system_wtmpx_path" = x"no" ; then
2508		AC_DEFINE(DISABLE_WTMPX)
2509	fi
2510else
2511	AC_DEFINE_UNQUOTED(CONF_WTMPX_FILE, "$conf_wtmpx_location")
2512fi
2513
2514
2515if test ! -z "$blibpath" ; then
2516	LDFLAGS="$LDFLAGS -blibpath:$blibpath"
2517	AC_MSG_WARN([Please check and edit -blibpath in LDFLAGS in Makefile])
2518fi
2519
2520dnl remove pam and dl because they are in $LIBPAM
2521if test "$PAM_MSG" = yes ; then
2522	LIBS=`echo $LIBS | sed 's/-lpam //'`
2523fi
2524if test "$ac_cv_lib_pam_pam_set_item" = yes ; then
2525	LIBS=`echo $LIBS | sed 's/-ldl //'`
2526fi
2527
2528AC_EXEEXT
2529AC_CONFIG_FILES([Makefile openbsd-compat/Makefile scard/Makefile ssh_prng_cmds])
2530AC_OUTPUT
2531
2532# Print summary of options
2533
2534# Someone please show me a better way :)
2535A=`eval echo ${prefix}` ; A=`eval echo ${A}`
2536B=`eval echo ${bindir}` ; B=`eval echo ${B}`
2537C=`eval echo ${sbindir}` ; C=`eval echo ${C}`
2538D=`eval echo ${sysconfdir}` ; D=`eval echo ${D}`
2539E=`eval echo ${libexecdir}/ssh-askpass` ; E=`eval echo ${E}`
2540F=`eval echo ${mandir}/${mansubdir}X` ; F=`eval echo ${F}`
2541G=`eval echo ${piddir}` ; G=`eval echo ${G}`
2542H=`eval echo ${PRIVSEP_PATH}` ; H=`eval echo ${H}`
2543I=`eval echo ${user_path}` ; I=`eval echo ${I}`
2544J=`eval echo ${superuser_path}` ; J=`eval echo ${J}`
2545
2546echo ""
2547echo "OpenSSH has been configured with the following options:"
2548echo "                     User binaries: $B"
2549echo "                   System binaries: $C"
2550echo "               Configuration files: $D"
2551echo "                   Askpass program: $E"
2552echo "                      Manual pages: $F"
2553echo "                          PID file: $G"
2554echo "  Privilege separation chroot path: $H"
2555if test "$USES_LOGIN_CONF" = "yes" ; then
2556echo "   At runtime, sshd will use the path defined in /etc/login.conf"
2557else
2558echo "            sshd default user PATH: $I"
2559fi
2560if test ! -z "$superuser_path" ; then
2561echo "          sshd superuser user PATH: $J"
2562fi
2563echo "                    Manpage format: $MANTYPE"
2564echo "                       PAM support: ${PAM_MSG}"
2565echo "                KerberosIV support: $KRB4_MSG"
2566echo "                 KerberosV support: $KRB5_MSG"
2567echo "                 Smartcard support: $SCARD_MSG"
2568echo "                       AFS support: $AFS_MSG"
2569echo "                     S/KEY support: $SKEY_MSG"
2570echo "                      OPIE support: $OPIE_MSG"
2571echo "              TCP Wrappers support: $TCPW_MSG"
2572echo "              MD5 password support: $MD5_MSG"
2573echo "       IP address in \$DISPLAY hack: $DISPLAY_HACK_MSG"
2574echo "          Use IPv4 by default hack: $IPV4_HACK_MSG"
2575echo "           Translate v4 in v6 hack: $IPV4_IN6_HACK_MSG"
2576echo "                  BSD Auth support: $BSD_AUTH_MSG"
2577echo "              Random number source: $RAND_MSG"
2578if test ! -z "$USE_RAND_HELPER" ; then
2579echo "     ssh-rand-helper collects from: $RAND_HELPER_MSG"
2580fi
2581
2582echo ""
2583
2584echo "              Host: ${host}"
2585echo "          Compiler: ${CC}"
2586echo "    Compiler flags: ${CFLAGS}"
2587echo "Preprocessor flags: ${CPPFLAGS}"
2588echo "      Linker flags: ${LDFLAGS}"
2589echo "         Libraries: ${LIBWRAP} ${LIBPAM} ${LIBS}"
2590
2591echo ""
2592
2593if test "x$PAM_MSG" = "xyes" ; then
2594	echo "PAM is enabled. You may need to install a PAM control file "
2595	echo "for sshd, otherwise password authentication may fail. "
2596	echo "Example PAM control files can be found in the contrib/ "
2597	echo "subdirectory"
2598	echo ""
2599fi
2600
2601if test ! -z "$RAND_HELPER_CMDHASH" ; then
2602	echo "WARNING: you are using the builtin random number collection "
2603	echo "service. Please read WARNING.RNG and request that your OS "
2604	echo "vendor includes kernel-based random number collection in "
2605	echo "future versions of your OS."
2606	echo ""
2607fi
2608
2609