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