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