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