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