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