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