summaryrefslogtreecommitdiff
path: root/usr.bin/ssh/configure.in
blob: 84b06b0990e7f733bdbf97e67ef5b4b3ed7bbc71 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
#
# configure.in
#
# Author: Tatu Ylonen <ylo@cs.hut.fi>
#
# Copyright (c) 1995 Tatu Ylonen <ylo@cs.hut.fi>, Espoo, Finland
#                    All rights reserved
#
# Created: Wed Mar 22 18:02:48 1995 ylo
#
# $Id: configure.in,v 1.1 1999/09/26 20:53:35 deraadt Exp $
#

AC_INIT(sshd.c)
AC_CONFIG_HEADER(config.h)
AC_PREREQ(2.4)

AC_CANONICAL_HOST

AC_PROG_CC
AC_PROG_CPP

case "$host" in
  *-*-sunos4.1.1*)
    os_sunos=yes
    # Tim Adam <tma@osa.com.au> says speed_t is defined in stdtypes.h
    AC_DEFINE(SPEED_T_IN_STDTYPES_H)
    ;;
  *-*-sunos*)
    os_sunos=yes
    ;;
  *-sgi-irix5*)
    # Irix stuff from snabb@niksula.hut.fi and tsurmacz@asic.ict.pwr.wroc.pl.
    no_libsocket=yes
    no_libsun=yes
    ;;
  *-sgi-irix6*)
    # from d-champion@uchicago.edu
    no_libsocket=yes
    no_libsun=yes
    if test "`uname -s`" = "IRIX64"; then
      CFLAGS="-32 $CFLAGS"
      LDFLAGS="-32 $LDFLAGS"
    fi
    ;;
  *-ibm-aix3.2|*-ibm-aix3.2.0|*-ibm-aix3.2.1|*-ibm-aix3.2.2|*-ibm-aix3.2.3|*-ibm-aix3.2.4)
    os_aix=yes
    AC_CHECK_LIB(s, getuserattr)
    ;;
  *-ibm-aix*)
    os_aix=yes
    AC_CHECK_LIB(s, getuserattr)
    ;;
  mips-dec-mach3*)
    # Mach3 stuff from kivinen@hut.fi
    no_vhangup=yes
    ;;
  *-dec-ultrix*)
    # Ultrix stuff from dmckilli@qc.bell.ca, jbotz@orixa.mtholyoke.edu.
    AC_DEFINE(O_NONBLOCK_BROKEN)
    no_vhangup=yes
    AC_TRY_COMPILE([#include <syslog.h>],
		   [int foo = LOG_DAEMON; ],
		   ,
		   AC_DEFINE(NEED_SYS_SYSLOG_H))
    ;;
  *-*-hpux*)
    # HPUX flags from jgotts@engin.umich.edu
    if test -z "$GCC"; then
      CFLAGS="$CFLAGS -Aa -D_HPUX_SOURCE"
    fi
    AC_DEFINE(HPSUX_NONSTANDARD_X11_KLUDGE)
    ;;
  alpha-dec-osf*)
    AC_DEFINE(TTY_GROUP, "terminal")
    AC_CHECK_LIB(security, set_auth_parameters)
    AC_MSG_CHECKING(for OSF/1 C2 security package)
    osfc2sec=`/usr/sbin/setld -i | grep '^OSFC2SEC'`
    if test -n "$osfc2sec"; then
      AC_MSG_RESULT(yes)
      AC_DEFINE(HAVE_OSF1_C2_SECURITY)
      AC_CHECK_LIB(security, set_auth_parameters,
                   LIBS="$LIBS -lsecurity",
                   AC_MSG_ERROR("Could not find libsecurity even though C2 security installed."))
      CONFOBJS="$CONFOBJS osfc2.o"
    else
      AC_MSG_RESULT(no)
    fi
    ;;
  *-*-nextstep*)
    # Nextstep support from a person who wants to remain anonymous
    no_termios=yes
    AC_DEFINE(SPEED_T_IN_STDTYPES_H)
    ;;
  *-*-linux*)
    # Linux shadow password support (Andrew.Macpherson.1248566@bnr.co.uk)
    if test -f /etc/shadow && test -f /etc/login.defs; then
      AC_MSG_RESULT(Using linux John Haugh shadow passwords and pw_encrypt for password encryption)
      AC_DEFINE(crypt,pw_encrypt)
      LIBS="$LIBS -lshadow"
    fi
    ;;
  i*86-*-bsdi*)
    no_pipe=yes
    ;;
  i*86-unknown-bsd*)
    # Assume 386BSD.  pgut01@cs.auckland.ac.nz reported this makes it compile.
    AC_DEFINE(__FreeBSD__)
    ;;
  m68k-sony-newsos*)
    # From snabb@niksula.hut.fi
    no_vhangup=yes
    ;;
  m88k-dg-dgux*)
    AC_DEFINE(BROKEN_INET_ADDR)
    ;;
  *-cray-unicos*)
    CFLAGS="$CFLAGS -DCRAY_STACKSEG_END=_getb67"
    ;;
  *-*-sysv4*)
    AC_CHECK_LIB(gen, openlog)
    ;;
  *-*-machten*)
    AC_DEFINE(USE_STRLEN_FOR_AF_UNIX)
    ;;
  i*86-unknown-sco*)
    # From moi@dio.com
    AC_DEFINE(HAVE_SCO_ETC_SHADOW)
    AC_DEFINE(SCO)
    no_ranlib=yes
    LIBS="-L/usr/lib/libp -lprot -lx $LIBS"
    ;;
  *-convex-bsd*)
    # From mark.martinec@nsc.ijs.si
    # On Convex, getpwnam sets pw_passwd if running as root
    no_shadows_password_checking=yes
    ;;
  *-*-freebsd*)
    # From Ollivier Robert: FreeBSD and NetBSD use master.passwd, but set
    # pw_passwd automatically when running as root.
    no_shadow_password_checking=yes
    ;;
  *-*-netbsd*)
    # From Ollivier Robert: FreeBSD and NetBSD use master.passwd, but set
    # pw_passwd automatically when running as root.
    no_shadow_password_checking=yes
    ;;
  *-*-openbsd*)
    no_shadow_password_checking=yes
    ;;
  *)
    ;;
esac

# Socket pairs appear to be broken on several systems.  I don't know exactly
# where, so I'll use pipes everywhere for now.
AC_DEFINE(USE_PIPES)

AC_MSG_CHECKING([that the compiler works])
AC_TRY_RUN([ main(int ac, char **av) { return 0; } ],
    AC_MSG_RESULT(yes),
    AC_MSG_RESULT(no)
    AC_MSG_ERROR(Could not compile and run even a trivial ANSI C program - check CC.),
    AC_MSG_ERROR(Could not compile and run even a trivial ANSI C program - check CC.))

if test -z "$no_pipe"; then
if test -n "$GCC"; then
  AC_MSG_CHECKING([if the compiler understands -pipe])
  OLDCC="$CC"
  CC="$CC -pipe"
  AC_TRY_COMPILE(,,
    AC_MSG_RESULT(yes),
    CC="$OLDCC"
    AC_MSG_RESULT(no))
fi
fi

AC_ARG_ENABLE(warnings,
[  --enable-warnings       Enable -Wall if using gcc.],
[ if test -n "$GCC"; then 
    AC_MSG_RESULT(Adding -Wall to CFLAGS.)
    CFLAGS="$CFLAGS -Wall"
  fi])

if test -z "$no_vhangup"; then
  AC_CHECK_FUNCS(vhangup)
fi

if test -z "$no_setsid"; then
  AC_CHECK_FUNCS(setsid)
fi

AC_MSG_CHECKING(where to find mandatory GMP library)
AC_ARG_WITH(gmp,
[  --with-gmp[=PATH]      Where to find GMP library.],
[ case "$withval" in
  no)
    echo "GMP is mandatory! Aborting!"
    exit 1
    ;;
  *)
    ;;
  esac ],
[ with_gmp=yes ]
)
# gmp continued
echo argument="$with_gmp"
case "$with_gmp" in
yes)
  AC_CHECK_HEADERS(gmp.h)
  if test "$ac_cv_header_gmp_h" != yes; then
    echo "Can't find include file gmp.h! Aborting!"
    echo "You must first build and install GMP, please read the file INSTALL"
    exit 1
  fi
  AC_CHECK_LIB(gmp, main)
  if test "$ac_cv_lib_gmp_main" != yes; then
    echo "Can't find library gmp (libgmp.a)! Aborting"
    echo "You must first build and install GMP, please read the file INSTALL"
    exit 1
  fi
  GMPINCS=""
  GMPLIBS="-lgmp"
  ;;
*)
  GMPINCS="-I$with_gmp/include"
  GMPLIBS="-L$with_gmp/lib -lgmp"
  ;;
esac
AC_SUBST(GMPINCS) dnl
AC_SUBST(GMPLIBS) dnl

AC_CHECK_FUNCS(_getpty clock fchmod getdtablesize gethostname getrusage)
AC_CHECK_FUNCS(gettimeofday initgroups innetgr memcpy openpty popen seteuid)
AC_CHECK_FUNCS(setlogin setluid setrlimit strchr times ulimit umask vsnprintf)

AC_TYPE_SIGNAL
AC_TYPE_SIZE_T
AC_TYPE_UID_T
AC_TYPE_OFF_T
AC_TYPE_MODE_T
AC_STRUCT_ST_BLKSIZE

AC_C_CONST
AC_C_INLINE
AC_C_BIGENDIAN
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(short)

if test -z "$no_termios"; then
  AC_CHECK_HEADERS(termios.h)
fi

AC_HEADER_STDC
AC_HEADER_SYS_WAIT
AC_CHECK_HEADERS(unistd.h rusage.h sys/time.h lastlog.h utmp.h utmpx.h)
AC_CHECK_HEADERS(sgtty.h sys/select.h sys/ioctl.h sys/filio.h)
AC_CHECK_HEADERS(paths.h usersec.h utime.h netinet/in_systm.h ulimit.h)
AC_HEADER_TIME
AC_HEADER_DIRENT
AC_HEADER_STAT
AC_EGREP_HEADER(ut_pid, utmp.h, AC_DEFINE(HAVE_PID_IN_UTMP))
AC_EGREP_HEADER(ut_name, utmp.h, AC_DEFINE(HAVE_NAME_IN_UTMP))
AC_EGREP_HEADER(ut_id, utmp.h, AC_DEFINE(HAVE_ID_IN_UTMP))
AC_EGREP_HEADER(ut_host, utmp.h, AC_DEFINE(HAVE_HOST_IN_UTMP))
AC_EGREP_HEADER(ut_addr, utmp.h, AC_DEFINE(HAVE_ADDR_IN_UTMP))

AC_EGREP_HEADER(ut_session, utmpx.h, AC_DEFINE(HAVE_UT_SESSION))
AC_EGREP_HEADER(ut_syslen, utmpx.h, AC_DEFINE(HAVE_UT_SYSLEN))

AC_CHECK_LIB(c, crypt, [true], AC_CHECK_LIB(crypt, crypt))
AC_CHECK_LIB(nsl, main)
if test -z "$no_libsocket"; then
  AC_CHECK_LIB(socket, socket)
fi
if test -z "$no_libsun"; then
  AC_CHECK_LIB(sun, getpwnam)
fi
AC_CHECK_LIB(util, login, AC_DEFINE(HAVE_LIBUTIL_LOGIN)
			  LIBS="$LIBS -lutil")

AC_CHECK_LIB(des, main)

AC_REPLACE_FUNCS(strerror memmove remove random putenv socketpair)

AC_PROG_LN_S
AC_PROG_INSTALL
if test -z "$no_ranlib"; then
  AC_PROG_RANLIB
else
  RANLIB=":"
fi
AC_PROGRAMS_CHECK(MAKEDEP, makedepend makedep, makedepend)
AC_PATH_PROGS(WISH, wish8.0 wish wishx wish4.1 true)
if test `basename $WISH` = "true"; then
  AC_MSG_WARN(the wish program was not found - ssh-askpass will not work.)
  WISH="/usr/local/bin/wish"
fi
AC_PATH_PROG(XAUTH_PATH, xauth, , $PATH:/usr/X11R6/bin)
if test -n "$XAUTH_PATH"; then
  AC_DEFINE_UNQUOTED(XAUTH_PATH, "$XAUTH_PATH")
fi

AC_MSG_CHECKING(for pseudo ttys)
if test -c /dev/ptmx && test -c /dev/pts/0
then
  AC_DEFINE(HAVE_DEV_PTMX)
  AC_MSG_RESULT(streams ptys)
else
if test -c /dev/pts && test -c /dev/ptc
then
  AC_DEFINE(HAVE_DEV_PTS_AND_PTC)
  AC_MSG_RESULT(/dev/pts and /dev/ptc)
else
  AC_MSG_RESULT(bsd-style ptys)
fi
fi

AC_MSG_CHECKING(for /etc/default/login)
if test -f /etc/default/login; then
  AC_DEFINE(HAVE_ETC_DEFAULT_LOGIN)
  AC_MSG_RESULT(yes)
else
  AC_MSG_RESULT(no)
fi

if test -z "$no_shadows_password_checking"; then
  AC_MSG_CHECKING(for shadow passwords)
  if test -f /etc/shadow; then
    AC_DEFINE(HAVE_ETC_SHADOW)
    AC_MSG_RESULT(/etc/shadow)
  elif test -n "$os_aix"; then
    AC_DEFINE(HAVE_ETC_SECURITY_PASSWD)
    AC_MSG_RESULT(/etc/security/passwd)
  elif test -n "$os_sunos"; then
    AC_DEFINE(HAVE_ETC_SECURITY_PASSWD_ADJUNCT)
    AC_MSG_RESULT(/etc/security/passwd.adjunct)
  else
    AC_MSG_RESULT(no)
  fi
fi

AC_MSG_CHECKING(location of mail spool files)
for dir in /var/spool/mail /var/mail /usr/spool/mail /usr/mail NEWMAIL
do
  if test "$dir" = "NEWMAIL"; then
    AC_DEFINE(HAVE_TILDE_NEWMAIL)
    AC_MSG_RESULT(\$HOME/newmail)
    AC_MSG_WARN(mail spool directory was not found: assuming you use \$HOME/newmail)
  elif test -d $dir; then
    AC_DEFINE_UNQUOTED(MAIL_SPOOL_DIRECTORY, "$dir")
    AC_MSG_RESULT($dir)
    break
  fi
done

AC_MSG_CHECKING(location of utmp)
if test -f /var/run/utmp; then
  AC_DEFINE(SSH_UTMP, "/var/run/utmp")
  AC_MSG_RESULT(/var/run/utmp)
elif test -f /var/log/utmp; then
  AC_DEFINE(SSH_UTMP, "/var/log/utmp")
  AC_MSG_RESULT(/var/log/utmp)
elif test -f /var/adm/utmp; then
  AC_DEFINE(SSH_UTMP, "/var/adm/utmp")
  AC_MSG_RESULT(/var/adm/utmp)
elif test -f /usr/adm/utmp; then
  AC_DEFINE(SSH_UTMP, "/usr/adm/utmp")
  AC_MSG_RESULT(/usr/adm/utmp)
elif test -f /etc/utmp; then
  AC_DEFINE(SSH_UTMP, "/etc/utmp")
  AC_MSG_RESULT(/etc/utmp)
else
  AC_MSG_RESULT(not found)
fi

AC_MSG_CHECKING(location of wtmp)
if test -f /var/log/wtmp; then
  AC_DEFINE(SSH_WTMP, "/var/log/wtmp")
  AC_MSG_RESULT(/var/log/wtmp)
elif test -f /var/adm/wtmp; then
  AC_DEFINE(SSH_WTMP, "/var/adm/wtmp")
  AC_MSG_RESULT(/var/adm/wtmp)
elif test -f /usr/adm/wtmp; then
  AC_DEFINE(SSH_WTMP, "/usr/adm/wtmp")
  AC_MSG_RESULT(/usr/adm/wtmp)
elif test -f /etc/wtmp; then
  AC_DEFINE(SSH_WTMP, "/etc/wtmp")
  AC_MSG_RESULT(/etc/wtmp)
else
  AC_DEFINE(SSH_WTMP, "/var/adm/wtmp")
  AC_MSG_RESULT(not found)
fi

AC_MSG_CHECKING(location of lastlog)
if test -f /var/log/lastlog || test -d /var/log/lastlog; then
  AC_DEFINE(SSH_LASTLOG, "/var/log/lastlog")
  AC_DEFINE(HAVE_LASTLOG)
  LASTLOG=/var/log/lastlog
  AC_MSG_RESULT(/var/log/lastlog)
elif test -f /var/adm/lastlog || test -d /var/adm/lastlog; then
  AC_DEFINE(SSH_LASTLOG, "/var/adm/lastlog")
  AC_DEFINE(HAVE_LASTLOG)
  LASTLOG=/var/adm/lastlog
  AC_MSG_RESULT(/var/adm/lastlog)
elif test -f /usr/adm/lastlog || test -d /usr/adm/lastlog; then
  AC_DEFINE(SSH_LASTLOG, "/usr/adm/lastlog")
  AC_DEFINE(HAVE_LASTLOG)
  LASTLOG=/usr/adm/lastlog
  AC_MSG_RESULT(/usr/adm/lastlog)
elif test -f /etc/lastlog || test -d /etc/lastlog; then
  AC_DEFINE(SSH_LASTLOG, "/etc/lastlog")
  AC_DEFINE(HAVE_LASTLOG)
  LASTLOG=/etc/lastlog
  AC_MSG_RESULT(/etc/lastlog)
else
  AC_MSG_RESULT(not found)
  AC_DEFINE(SSH_LASTLOG, "/var/log/lastlog")
  LASTLOG=/var/log/lastlog
fi

AC_MSG_CHECKING(whether $LASTLOG is a directory)
if test -d $LASTLOG
then
  AC_MSG_RESULT(yes)
  AC_DEFINE(LASTLOG_IS_DIR)
else
  AC_MSG_RESULT(no)
fi

AC_MSG_CHECKING(whether to include the IDEA encryption algorithm)
AC_ARG_WITH(idea,
[  --with-idea             Use IDEA (not default).
  --without-idea          Don't use IDEA: avoids patent problems in commercial use],
[ case "$withval" in
  yes)
    AC_MSG_RESULT(yes)
    CONFOBJS="$CONFOBJS idea.o"
    AC_DEFINE(WITH_IDEA)
    ;;
  *)
    AC_MSG_RESULT(no)
    ;;
  esac ],
  AC_MSG_RESULT(no)
)

AC_MSG_CHECKING(whether to include the RC4 encryption algorithm)
AC_ARG_WITH(rc4,
[  --with-rc4          Include RC4 support.
  --without-rc4       Don't include RC4 support (default)],
[ case "$withval" in
  yes)
    AC_MSG_RESULT(yes)
    CONFOBJS="$CONFOBJS rc4.o"
    AC_DEFINE(WITH_RC4)
    ;;
  *)
    AC_MSG_RESULT(no)
    ;;
  esac ],
  AC_MSG_RESULT(no)
)

AC_MSG_CHECKING(whether to include the Blowfish encryption algorithm)
AC_ARG_WITH(blowfish,
[  --with-blowfish          Include Blowfish support (default).
  --without-blowfish       Don't include Blowfish support],
[ case "$withval" in
  no)
    ;;
  *)
    with_blowfish=yes
    ;;
  esac ],
  with_blowfish=yes
)

case "$with_blowfish" in
yes)
    AC_DEFINE(WITH_BLOWFISH)
    CONFOBJS="$CONFOBJS bf_skey.o bf_enc.o"
    AC_MSG_RESULT(yes)
    ;;
no)
    AC_MSG_RESULT(no)
    ;;
esac

AC_MSG_CHECKING(whether to use rsaref)
AC_ARG_WITH(rsaref,
[  --with-rsaref           Use RSAREF (try to avoid patent problems in U.S.)
  --without-rsaref        Use normal RSA routines (default). ],
[ case "$withval" in
  no)
       AC_MSG_RESULT(no)
       ;;
  *)
       AC_MSG_RESULT(yes)
       AC_DEFINE(RSAREF)
       RSAREFDEP="rsaref2/source/librsaref.a"
       LIBS="-lrsaref $LIBS"
       LDFLAGS="-Lrsaref2/source $LDFLAGS"
       ;;
  esac ],
  AC_MSG_RESULT(no)
)

AC_MSG_CHECKING(whether to use ssl)
AC_ARG_WITH(ssl,
[  --with-ssl           Use SSL (try to avoid patent problems in U.S.)
  --without-ssl         Use normal RSA routines (default). ],
[ case "$withval" in
  no)
       AC_MSG_RESULT(no)
       ;;
  *)
       AC_MSG_RESULT(yes)
       AC_DEFINE(DO_SSL)
       LIBS="-lcrypto $LIBS"
       ;;
  esac ],
  AC_MSG_RESULT(no)
)

AC_MSG_CHECKING(whether to use rsh)
AC_ARG_WITH(rsh, 
[  --with-rsh=PATH         Specify where to find rsh.
  --without-rsh           Do not use rsh under any conditions. ],
[ case "$withval" in
    no) 
        AC_MSG_RESULT(no)
	;;
    yes) 
	 AC_MSG_RESULT(yes)
	 AC_PATH_PROGS(RSH_PATH, remsh rsh)
         AC_DEFINE_UNQUOTED(RSH_PATH, "$RSH_PATH")
	;;
    *) 
       AC_MSG_RESULT($withval)
       AC_DEFINE_UNQUOTED(RSH_PATH, "$withval")
       ;;
  esac ],
  [ AC_MSG_RESULT(yes)
    AC_PATH_PROGS(RSH_PATH, remsh rsh)
    AC_DEFINE_UNQUOTED(RSH_PATH, "$RSH_PATH") ]
)

# Code to permit setting default path for users (alden@math.ohio-state.edu)
AC_MSG_CHECKING(default path)
AC_ARG_WITH(path,
[  --with-path=PATH        Default path passed to user shell by sshd.],
[ case "$withval" in
  no)
    AC_MSG_RESULT(use system default)
    ;;
  *)
    AC_MSG_RESULT($withval)
    AC_DEFINE_UNQUOTED(DEFAULT_PATH, "$withval")
    ;;
  esac ],
  AC_MSG_RESULT(use system default)
)

AC_MSG_CHECKING(etcdir)
AC_ARG_WITH(etcdir,
[  --with-etcdir=PATH      Directory containing ssh system files (default /etc).],
[ case "$withval" in
  no)
    AC_MSG_ERROR(Need ETCDIR.)
    ;;
  yes)
    ETCDIR="/etc"
    AC_MSG_RESULT(/etc)
    ;;
  *)
    ETCDIR="$withval"
    AC_MSG_RESULT($withval)
    ;;
  esac ],
  ETCDIR="/etc"
  AC_MSG_RESULT(/etc)
)

AC_MSG_CHECKING(whether to support SecurID)
AC_ARG_WITH(securid,
[  --with-securid[=PATH]   Enable support for Security Dynamics SecurID card.],
[ case "$withval" in
  no)
    AC_MSG_RESULT(no)
    ;;
  yes)
    AC_MSG_RESULT(yes)
    if test '!' -f /usr/ace/sdiclient.a; then
      AC_ERROR(SecurID sdiclient.a not found in /usr/ace: you must supply the path.)
    fi
    AC_MSG_RESULT(yes)
    AC_MSG_RESULT(Assuming SecurID headers and libraries are in /usr/ace.)
    AC_DEFINE(HAVE_SECURID)
    CFLAGS="$CFLAGS -I/usr/ace"
    LIBS="/usr/ace/sdiclient.a $LIBS"
    ;;
  *)
    AC_MSG_RESULT(yes)
    if test '!' -f $withval/sdiclient.a; then
      AC_ERROR(SecurID sdiclient.a not found in $withval: please supply the correct path.)
    fi
    AC_MSG_RESULT(Assuming SecurID headers and libraries are in $withval.)
    AC_DEFINE(HAVE_SECURID)
    CFLAGS="$CFLAGS -I$withval"
    LIBS="$withval/sdiclient.a $LIBS"
    ;;
  esac ],
  AC_MSG_RESULT(no)
)

AC_MSG_CHECKING(whether to include compression support)
AC_ARG_WITH(zlib,
[  --with-zlib            Use zlib (default).
  --without-zlib          Don't use zlib.],
[ case "$withval" in
  no)
    ;;
  *)
    with_zlib=yes
    ;;
  esac ],
  with_zlib=yes
)

case "$with_zlib" in
yes)
    AC_MSG_RESULT(yes)
    AC_CHECK_HEADERS(zlib.h)
    if test "$ac_cv_header_zlib_h" != yes; then
      echo "Can't find zlib.h, disable with --without-zlib"
      exit 1
    fi
    AC_CHECK_LIB(z, main)
    if test "$ac_cv_lib_z_main" != yes; then
      echo "Can't find library z (libz.a), disable with --without-zlib"
      exit 1
    fi
    CONFOBJS="$CONFOBJS compress.o"
    AC_DEFINE(WITH_ZLIB)
    ;;
no)
    AC_MSG_RESULT(no)
    ;;
esac

AC_MSG_CHECKING(whether to use Kerberos v4)
AC_ARG_WITH(krb4,
[  --with-krb4[=PATH]      Compile in Kerberos v4 support.],
[ case "$withval" in
  yes)
    ;;
  no)
    ;;
  *)
    ;;
  esac ],
[ with_krb4=default ]
)
# krb4 continued
case "$with_krb4" in
no)
  AC_MSG_RESULT(no)
  ;;
yes)
  AC_MSG_RESULT(yes)
  AC_CHECK_HEADERS(krb.h)
  if test "$ac_cv_header_krb_h" != yes; then
    echo "Can't find include file krb.h! Aborting!"
    exit 1
  fi
  AC_CHECK_LIB(krb, main)
  if test "$ac_cv_lib_krb_main" != yes; then
    echo "Can't find library krb (libkrb.a)! Aborting"
    exit 1
  fi
  AC_DEFINE(KRB4)
  KRB4_AUTH="auth-krb4.o"
  KRB4_ROOT=""
  KRB4_INCS=""
  KRB4_LIBS="-lkrb -ldes"
  AC_CHECK_LIB(resolv, dn_expand, KRB4_LIBS="$KRB4_LIBS -lresolv")
  ;;
default)
  AC_CHECK_HEADERS(krb.h)
  AC_CHECK_LIB(krb, main)
  if test "$ac_cv_header_krb_h" = yes -a "$ac_cv_lib_krb_main" = yes; then
    AC_MSG_RESULT(yes)
    AC_DEFINE(KRB4)
    KRB4_AUTH="auth-krb4.o"
    KRB4_ROOT=""
    KRB4_INCS=""
    KRB4_LIBS="-lkrb -ldes"
    AC_CHECK_LIB(resolv, dn_expand, KRB4_LIBS="$KRB4_LIBS -lresolv")
  else
    AC_MSG_RESULT(no)
  fi
  ;;
*)
  AC_MSG_RESULT(yes)
  AC_DEFINE(KRB4)
  KRB4_AUTH="auth-krb4.o"
  KRB4_ROOT="$with_krb4"
  KRB4_INCS="-I\$(KRB4_ROOT)/include"
  KRB4_LIBS="-L\$(KRB4_ROOT)/lib -lkrb -ldes"
  AC_CHECK_LIB(resolv, dn_expand, KRB4_LIBS="$KRB4_LIBS -lresolv")
  ;;
esac
AC_SUBST(KRB4_AUTH) dnl
AC_SUBST(KRB4_ROOT) dnl
AC_SUBST(KRB4_INCS) dnl
AC_SUBST(KRB4_LIBS) dnl

AC_MSG_CHECKING(whether to use AFS)
AC_ARG_WITH(afs,
[  --with-afs              Compile in AFS support (requires KTH krb4).],
if test "$with_afs" = no; then
      AC_MSG_RESULT(no)
    else
      AC_MSG_RESULT(yes)
  AC_DEFINE(AFS)
  AC_DEFINE(KERBEROS_TGT_PASSING)
  RADIX="radix.o"
  if test "$with_krb4" = no; then
    AC_MSG_RESULT(no)
    AC_MSG_WARN("AFS requires Kerberos v4 support.")
  else
    KRB4_LIBS="${KRB4_LIBS} -lkafs"
    if test -n "$os_aix"; then
      KRB4_LIBS="${KRB4_LIBS} -lld"
    fi
  fi
fi
)
AC_SUBST(RADIX)dnl

AC_MSG_CHECKING(whether to use libwrap)
AC_ARG_WITH(libwrap,
[  --with-libwrap[=PATH]   Compile in libwrap (tcp_wrappers) support.],
[ case "$withval" in
  no)
    AC_MSG_RESULT(no)
    ;;
  yes)
    AC_MSG_RESULT(yes)
    AC_DEFINE(LIBWRAP)
    LIBS="-lwrap $LIBS"
    AC_TRY_LINK([ int allow_severity; int deny_severity; ],
                [ hosts_access(); ],
		[],
		[ AC_MSG_ERROR(Could not find the libwrap.a library.  You must first install tcp_wrappers.) ])
    ;;
  *)
    AC_MSG_RESULT(yes)
    AC_DEFINE(LIBWRAP)
    LIBS="$withval $LIBS"
    AC_TRY_LINK([ int allow_severity; int deny_severity; ],
                [ hosts_access(); ],
		[],
		[ AC_MSG_ERROR(Could not find the $withval library.  You must first install tcp_wrappers.) ])
    ;;
  esac ],
  AC_MSG_RESULT(no)
)

AC_MSG_CHECKING(whether to support SOCKS)
AC_ARG_WITH(socks,
[  --with-socks[=PATH]     Compile with SOCKS firewall traversal support.],
[ case "$withval" in
  no)
    AC_MSG_RESULT(no)
    ;;
  *)
    AC_MSG_RESULT(yes)
    AC_DEFINE(SOCKS)
    AC_DEFINE(connect, Rconnect)
    AC_DEFINE(getsockname, Rgetsockname)
    AC_DEFINE(bind, Rbind)
    AC_DEFINE(accept, Raccept)
    AC_DEFINE(listen, Rlisten)
    AC_DEFINE(select, Rselect)
    if test "x$withval" = "xyes"; then
      withval="-lsocks"
    fi
    LIBS="$withval $LIBS"
    AC_TRY_LINK([],
                [ Rconnect(); ],
		[],
		[ AC_MSG_ERROR(Could not find the $withval library.  You must first install socks.) ])
    ;;
  esac ],
  AC_MSG_RESULT(no)
)

PIDDIR="/var/run"
AC_MSG_CHECKING(where to put sshd.pid)
if test '!' -d $PIDDIR; then
  PIDDIR="$ETCDIR"
fi
AC_MSG_RESULT($PIDDIR)

AC_ARG_PROGRAM

AC_SUBST(ETCDIR)
AC_SUBST(PIDDIR)
AC_SUBST(RSAREFDEP)
AC_SUBST(CONFOBJS)

AC_OUTPUT(Makefile sshd.8 ssh.1)