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