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