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