aboutsummaryrefslogtreecommitdiff
path: root/crypto/heimdal/configure.in
blob: f406c0304e862e31d9dd1fcb99d7f6a4d32ddafb (plain) (blame)
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
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
dnl Process this file with autoconf to produce a configure script.
AC_REVISION($Revision: 1.215 $)
AC_INIT(lib/krb5/send_to_kdc.c)
AM_CONFIG_HEADER(include/config.h)

AM_INIT_AUTOMAKE(heimdal,0.2m)

AC_PREFIX_DEFAULT(/usr/heimdal)

AC_CANONICAL_HOST
CANONICAL_HOST=$host
AC_SUBST(CANONICAL_HOST)

sunos=no
case "$host" in 
*-*-sunos4*)
	sunos=40
	;;
*-*-solaris2.7)
	sunos=57
	;;
*-*-solaris2*)
	sunos=50
	;;
esac
if test "$sunos" != no; then
	AC_DEFINE_UNQUOTED(SunOS, $sunos, 
		[Define to what version of SunOS you are running.])
fi

aix=no
case "$host" in 
*-*-aix3*)
	aix=3
	;;
*-*-aix4*)
	aix=4
	;;
esac

#test -z "$CFLAGS" && CFLAGS="-g"

dnl Checks for programs.
AC_PROG_CC

AC_CYGWIN
AC_OBJEXT
AC_EXEEXT

dnl AC_KRB_PROG_YACC
AC_PROG_YACC
AM_PROG_LEX
AC_PROG_RANLIB
AC_PROG_AWK
AC_KRB_PROG_LN_S

AC_MIPS_ABI
CC="$CC $abi"
libdir="$libdir$abilibdirext"

AC_C___ATTRIBUTE__

AM_DISABLE_SHARED
AM_PROG_LIBTOOL

AC_WFLAGS(-Wall -Wmissing-prototypes -Wpointer-arith -Wbad-function-cast -Wmissing-declarations -Wnested-externs)

berkeley_db=db
AC_ARG_WITH(berkeley-db,
[  --without-berkeley-db   if you don't want berkeley db],[
if test "$withval" = no; then
	berkeley_db=""
fi
])

AC_TEST_PACKAGE_NEW(krb4,[#include <krb.h>],-lkrb,-ldes,/usr/athena)

LIB_kdb=
if test "$with_krb4" != "no"; then
	save_CFLAGS="$CFLAGS"
	CFLAGS="$CFLAGS $INCLUDE_krb4"
	save_LIBS="$LIBS"
	LIBS="$LIB_krb4 -ldes $LIBS"
	EXTRA_LIB45=lib45.a
	AC_SUBST(EXTRA_LIB45)
	AC_CACHE_CHECK(for four valued krb_put_int, ac_cv_func_krb_put_int_four,
		[AC_TRY_COMPILE([#include <krb.h>],[
		char tmp[4];
		krb_put_int(17, tmp, 4, sizeof(tmp));],
		ac_cv_func_krb_put_int_four=yes,
		ac_cv_func_krb_put_int_four=no)
	])
	if test "$ac_cv_func_krb_put_int_four" = yes; then
		AC_DEFINE(HAVE_FOUR_VALUED_KRB_PUT_INT, 1,
			[define if krb_put_int takes four arguments.])
	fi
	AC_CACHE_CHECK(for KRB_VERIFY_SECURE, ac_cv_func_krb_verify_secure,
		[AC_TRY_COMPILE([#include <krb.h>],[
		int x = KRB_VERIFY_SECURE],
		ac_cv_func_krb_verify_secure=yes,
		ac_cv_func_krb_verify_secure=no)
	])
	if test "$ac_cv_func_krb_verify_secure" != yes; then
		AC_DEFINE(KRB_VERIFY_SECURE, 1,
			[Define to one if your krb.h doesn't])
		AC_DEFINE(KRB_VERIFY_SECURE_FAIL, 2,
			[Define to two if your krb.h doesn't])
	fi
	AC_CACHE_CHECK(for KRB_VERIFY_NOT_SECURE,
		ac_cv_func_krb_verify_not_secure,
		[AC_TRY_COMPILE([#include <krb.h>],[
		int x = KRB_VERIFY_NOT_SECURE],
		ac_cv_func_krb_verify_not_secure=yes,
		ac_cv_func_krb_verify_not_secure=no)
	])
	if test "$ac_cv_func_krb_verify_not_secure" != yes; then
		AC_DEFINE(KRB_VERIFY_NOT_SECURE, 0,
			[Define to zero if your krb.h doesn't])
	fi
	AC_FIND_FUNC(krb_enable_debug)
	AC_FIND_FUNC(krb_disable_debug)
	AC_FIND_FUNC(krb_get_our_ip_for_realm)
	LIBS="$save_LIBS"
	CFLAGS="$save_CFLAGS"
	LIB_kdb="-lkdb -lkrb"
	if test "$krb4_libdir"; then
		LIB_krb4="-rpath $krb4_libdir $LIB_krb4"
		LIB_kdb="-rpath $krb4_libdir -L$krb4_libdir $LIB_kdb"
	fi
fi
AM_CONDITIONAL(KRB4, test "$with_krb4" != "no")
AM_CONDITIONAL(KRB5, true)
AC_DEFINE(KRB5, 1, [Enable Kerberos 5 support in applications.])dnl
AC_SUBST(LIB_kdb)dnl
AM_CONDITIONAL(AIX, test "$aix" != no)dnl
AM_CONDITIONAL(AIX4, test "$aix" = 4)
aix_dynamic_afs=yes
AM_CONDITIONAL(AIX_DYNAMIC_AFS, test "$aix_dynamic_afs" = yes)dnl

AC_FIND_FUNC_NO_LIBS(dlopen, dl)

if test "$aix" != no; then
	if test "$aix_dynamic_afs" = yes; then
		if test "$ac_cv_funclib_dlopen" = yes; then
			AIX_EXTRA_KAFS=
		elif test "$ac_cv_funclib_dlopen" != no; then
			AIX_EXTRA_KAFS="$ac_cv_funclib_dlopen"
		else
			AIX_EXTRA_KAFS=-lld
		fi
	else
		AIX_EXTRA_KAFS=
	fi
fi

AM_CONDITIONAL(HAVE_DLOPEN, test "$ac_cv_funclib_dlopen" != no)dnl
AC_SUBST(AFS_EXTRA_LD)dnl
AC_SUBST(AIX_EXTRA_KAFS)dnl

AC_ARG_ENABLE(kaserver,
[  --enable-kaserver	  if you want the KDC to try to emulate a kaserver])
if test "$enable_kaserver" = yes; then
	AC_DEFINE(KASERVER, 1,
		[Define if you want to use the KDC as a kaserver.])
	if test "$with_krb4" = "no"; then
		AC_MSG_ERROR(kaserver requires krb4)
		exit 1
	fi
fi

AC_ARG_ENABLE(kaserver-db,
[  --enable-kaserver-db	  if you want support for reading kaserver databases in hprop])
if test "$enable_kaserver_db" = yes; then
	AC_DEFINE(KASERVER_DB, 1,
		[Define if you want support in hprop for reading kaserver databases])
	if test "$with_krb4" = "no"; then
		AC_MSG_ERROR(kaserver-db requires krb4)
		exit 1
	fi
fi

otp=yes
AC_ARG_ENABLE(otp,
[  --disable-otp          if you don't want OTP support],
[
if test "$enableval" = "no"; then
	otp=no
fi
])
if test "$otp" = "yes"; then
	AC_DEFINE(OTP, 1, [Define if you want OTP support in applications.])
	LIB_otp='$(top_builddir)/lib/otp/libotp.la'
fi
AC_SUBST(LIB_otp)
AM_CONDITIONAL(OTP, test "$otp" = yes)dnl

AC_CHECK_OSFC2

AC_CHECK_MAN

AC_TEST_PACKAGE_NEW(readline,
[#include <stdio.h>
 #include <readline.h>],-lreadline)

AC_TEST_PACKAGE_NEW(hesiod,[#include <hesiod.h>],-lhesiod)

KRB_C_BIGENDIAN
AC_C_INLINE

KRB_CHECK_X

if test "$no_x" = "yes" ; then
	MAKE_X_PROGS_BIN_PROGS=""
	MAKE_X_PROGS_BIN_SCRPTS=""
	MAKE_X_PROGS_LIBEXEC_PROGS=""
else
	MAKE_X_PROGS_BIN_PROGS='$(X_PROGS_BIN_PROGS)'
	MAKE_X_PROGS_BIN_SCRPTS='$(X_PROGS_BIN_SCRPTS)'
	MAKE_X_PROGS_LIBEXEC_PROGS='$(X_PROGS_LIBEXEC_PROGS)'
fi
AC_SUBST(MAKE_X_PROGS_BIN_PROGS)dnl
AC_SUBST(MAKE_X_PROGS_BIN_SCRPTS)dnl
AC_SUBST(MAKE_X_PROGS_LIBEXEC_PROGS)dnl

AC_CHECK_XAU

dnl AM_C_PROTOTYPES

dnl Checks for typedefs, structures, and compiler characteristics.
AC_C_CONST
AC_TYPE_OFF_T
AC_TYPE_SIZE_T
AC_CHECK_TYPE_EXTRA(ssize_t, int, [#include <unistd.h>])
AC_TYPE_PID_T
AC_TYPE_UID_T
AC_CHECK_TYPE_EXTRA(mode_t, unsigned short, [])
AC_CHECK_TYPE_EXTRA(sig_atomic_t, int, [#include <signal.h>])
AC_HEADER_TIME
AC_STRUCT_TM

dnl Checks for header files.
AC_HEADER_STDC

if test "$berkeley_db"; then
  AC_CHECK_HEADERS([				\
	db.h					\
	db_185.h				\
  ])
fi

AC_CHECK_HEADERS([\
	arpa/ftp.h				\
	arpa/inet.h				\
	arpa/nameser.h				\
	arpa/telnet.h				\
	bind/bitypes.h				\
	bsdsetjmp.h				\
	crypt.h					\
	curses.h				\
	dbm.h					\
	dirent.h				\
	dlfcn.h					\
	err.h					\
	errno.h					\
	fcntl.h					\
	fnmatch.h				\
	grp.h					\
	inttypes.h				\
	io.h					\
	limits.h				\
	maillock.h				\
	ndbm.h					\
	net/if.h				\
	netdb.h					\
	netinet/in.h				\
	netinet/in6.h				\
	netinet/in6_machtypes.h			\
	netinet/in6_var.h			\
	netinet/in_systm.h			\
	netinet6/in6.h				\
	netinfo/ni.h				\
	paths.h					\
	pthread.h				\
	pty.h					\
	pwd.h					\
	resolv.h				\
	rpcsvc/dbm.h				\
	sac.h					\
	security/pam_modules.h			\
	sgtty.h					\
	shadow.h				\
	siad.h					\
	signal.h				\
	stropts.h				\
	sys/bitypes.h				\
	sys/category.h				\
	sys/file.h				\
	sys/filio.h				\
	sys/ioccom.h				\
	sys/ioctl.h				\
	sys/param.h				\
	sys/proc.h				\
	sys/pty.h				\
	sys/ptyio.h				\
	sys/ptyvar.h				\
	sys/resource.h				\
	sys/select.h				\
	sys/socket.h				\
	sys/sockio.h				\
	sys/stat.h				\
	sys/str_tty.h				\
	sys/stream.h				\
	sys/stropts.h				\
	sys/strtty.h				\
	sys/syscall.h				\
	sys/sysctl.h				\
	sys/termio.h				\
	sys/time.h				\
	sys/timeb.h				\
	sys/times.h				\
	sys/tty.h				\
	sys/types.h				\
	sys/uio.h				\
	sys/un.h				\
	sys/utsname.h				\
	sys/wait.h				\
	syslog.h				\
	term.h					\
	termio.h				\
	termios.h				\
	time.h					\
	tmpdir.h				\
	udb.h					\
	unistd.h				\
	util.h					\
	utmp.h					\
	utmpx.h					\
])

CHECK_NETINET_IP_AND_TCP


AC_ARG_ENABLE(netinfo,
[  --enable-netinfo      enable netinfo for configuration lookup])

if test "$ac_cv_header_netinfo_ni_h" = yes -a "$enable_netinfo" = yes; then
       AC_DEFINE(HAVE_NETINFO, 1,
               [Define if you want to use Netinfo instead of krb5.conf.])
fi

AM_CONDITIONAL(have_err_h, test "$ac_cv_header_err_h" = yes)
AM_CONDITIONAL(have_fnmatch_h, test "$ac_cv_header_fnmatch_h" = yes)

AC_KRB_IPV6

dnl Checks for libraries.

AC_FIND_FUNC(socket, socket)
AC_FIND_FUNC(gethostbyname, nsl)
AC_FIND_FUNC(syslog, syslog)

AC_FIND_FUNC_NO_LIBS(logwtmp, util)
AC_FIND_FUNC_NO_LIBS(tgetent, termcap ncurses curses)
AC_FIND_FUNC(gethostbyname2, inet6 ip6)

AC_FIND_FUNC(res_search, resolv,
[
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
#include <arpa/nameser.h>
#endif
#ifdef HAVE_RESOLV_H
#include <resolv.h>
#endif
],
[0,0,0,0,0])

AC_FIND_FUNC(dn_expand, resolv,
[
#include <stdio.h>
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_NAMESER_H
#include <arpa/nameser.h>
#endif
#ifdef HAVE_RESOLV_H
#include <resolv.h>
#endif
],
[0,0,0,0,0])

dnl Checks for library functions.

AC_BROKEN_SNPRINTF
AC_BROKEN_VSNPRINTF

AC_BROKEN_GLOB

if test "$ac_cv_func_glob_working" != yes; then
	LIBOBJS="$LIBOBJS glob.o"
fi
AM_CONDITIONAL(have_glob_h, test "$ac_cv_func_glob_working" = yes)

dnl these should happen after tests for *snprintf

AC_FIND_FUNC_NO_LIBS(dbopen, $berkeley_db)
AC_FIND_FUNC_NO_LIBS(dbm_firstkey, $berkeley_db gdbm ndbm)

DBLIB="$LIB_dbopen"
if test "$LIB_dbopen" != "$LIB_dbm_firstkey"; then
	DBLIB="$DBLIB $LIB_dbm_firstkey"
fi
AC_SUBST(DBLIB)dnl

AC_CHECK_FUNCS(_getpty _scrsize asnprintf asprintf cgetent fcntl)
AC_CHECK_FUNCS(getmsg getrlimit getspnam gettimeofday getuid)
AC_CHECK_FUNCS(grantpt mktime ptsname rand random setproctitle)
AC_CHECK_FUNCS(revoke select setitimer setpcred setpgid)
AC_CHECK_FUNCS(setregid setresgid setresuid setreuid setutent)
AC_CHECK_FUNCS(setsid sigaction strstr)
AC_CHECK_FUNCS(sysconf sysctl timegm ttyname ttyslot umask uname)
AC_CHECK_FUNCS(unlockpt vasnprintf vasprintf vhangup)
AC_CHECK_FUNCS(yp_get_default_domain)

if test "$ac_cv_func_cgetent" = no; then
	LIBOBJS="$LIBOBJS getcap.o"
fi

AC_FUNC_GETLOGIN

KRB_CAPABILITIES

AC_CHECK_GETPWNAM_R_POSIX

AC_FIND_FUNC_NO_LIBS(getsockopt,,
[#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif],
[0,0,0,0,0])
AC_FIND_FUNC_NO_LIBS(setsockopt,,
[#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif],
[0,0,0,0,0])

dnl Cray stuff
AC_CHECK_FUNCS(getudbnam setlim)

AC_TYPE_SIGNAL
if test "$ac_cv_type_signal" = "void" ; then
	AC_DEFINE(VOID_RETSIGTYPE, 1, [Define if signal handlers return void.])
fi
AC_SUBST(VOID_RETSIGTYPE)

AC_FIND_IF_NOT_BROKEN(hstrerror, resolv,
[#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif],
17)
if test "$ac_cv_func_hstrerror" = yes; then
AC_NEED_PROTO([
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif],
hstrerror)
fi

dnl sigh, wish this could be done in a loop
if test "$ac_cv_func_asprintf" = yes; then
AC_NEED_PROTO([
#include <stdio.h>
#include <string.h>],
asprintf)dnl
fi
if test "$ac_cv_func_vasprintf" = yes; then
AC_NEED_PROTO([
#include <stdio.h>
#include <string.h>],
vasprintf)dnl
fi
if test "$ac_cv_func_asnprintf" = yes; then
AC_NEED_PROTO([
#include <stdio.h>
#include <string.h>],
asnprintf)dnl
fi
if test "$ac_cv_func_vasnprintf" = yes; then
AC_NEED_PROTO([
#include <stdio.h>
#include <string.h>],
vasnprintf)dnl
fi

AC_BROKEN(chown copyhostent daemon err errx fchown flock fnmatch)
AC_BROKEN(freeaddrinfo freehostent gai_strerror getaddrinfo)
AC_BROKEN(getcwd getdtablesize gethostname getipnodebyaddr getipnodebyname)
AC_BROKEN(geteuid getgid getegid)
AC_BROKEN(getnameinfo getopt getusershell)
AC_BROKEN(inet_aton inet_ntop inet_pton initgroups innetgr iruserok lstat)
AC_BROKEN(memmove)
AC_BROKEN(mkstemp putenv rcmd readv recvmsg sendmsg setegid setenv seteuid)
AC_BROKEN(strcasecmp strncasecmp strdup strerror strftime)
AC_BROKEN(strlcat strlcpy strlwr)
AC_BROKEN(strndup strnlen strptime strsep strtok_r strupr)
AC_BROKEN(swab unsetenv verr verrx vsyslog)
AC_BROKEN(vwarn vwarnx warn warnx writev)

AC_NEED_PROTO([#include <stdlib.h>], setenv)
AC_NEED_PROTO([#include <stdlib.h>], unsetenv)
AC_NEED_PROTO([#include <unistd.h>], gethostname)
AC_NEED_PROTO([#include <unistd.h>], mkstemp)
AC_NEED_PROTO([#include <unistd.h>], getusershell)

AC_NEED_PROTO([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif],
inet_aton)

AC_FIND_FUNC_NO_LIBS(crypt, crypt)dnl

dnl
dnl libroken references crypt and dbopen
dnl

LIB_roken='$(top_builddir)/lib/roken/libroken.la $(LIB_crypt) $(LIB_dbopen)'
AC_SUBST(LIB_roken)dnl

AC_CACHE_CHECK(if realloc if broken, ac_cv_func_realloc_broken, [
ac_cv_func_realloc_broken=no
AC_TRY_RUN([
#include <stddef.h>
#include <stdlib.h>

int main()
{
	return realloc(NULL, 17) == NULL;
}
],:, ac_cv_func_realloc_broken=yes, :)
])
if test "$ac_cv_func_realloc_broken" = yes ; then
	AC_DEFINE(BROKEN_REALLOC, 1, [Define if realloc(NULL) doesn't work.])
fi

dnl AC_KRB_FUNC_GETCWD_BROKEN

dnl
dnl Checks for prototypes and declarations
dnl

AC_PROTO_COMPAT([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
],
gethostbyname, struct hostent *gethostbyname(const char *))

AC_PROTO_COMPAT([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
],
gethostbyaddr, struct hostent *gethostbyaddr(const void *, size_t, int))

AC_PROTO_COMPAT([
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif
#ifdef HAVE_NETINET_IN_H
#include <netinet/in.h>
#endif
#ifdef HAVE_ARPA_INET_H
#include <arpa/inet.h>
#endif
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif
],
getservbyname, struct servent *getservbyname(const char *, const char *))

AC_PROTO_COMPAT([
#ifdef HAVE_SYSLOG_H
#include <syslog.h>
#endif
],
openlog, void openlog(const char *, int, int))

AC_NEED_PROTO([
#ifdef HAVE_CRYPT_H
#include <crypt.h>
#endif
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif
],
crypt)

AC_NEED_PROTO([
#include <string.h>
],
strtok_r)

AC_NEED_PROTO([
#include <string.h>
],
strsep)

AC_CHECK_VAR([#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif],
h_errno)

AC_CHECK_VAR([#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif],
h_errlist)

AC_CHECK_VAR([#ifdef HAVE_NETDB_H
#include <netdb.h>
#endif],
h_nerr)

AC_CHECK_VAR([#ifdef HAVE_ERR_H
#include <err.h>
#endif],[__progname])

AC_CHECK_DECLARATION([#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif], optarg)
AC_CHECK_DECLARATION([#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif], optind)
AC_CHECK_DECLARATION([#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif], opterr)
AC_CHECK_DECLARATION([#include <stdlib.h>
#ifdef HAVE_UNISTD_H
#include <unistd.h>
#endif], optopt)

AC_CHECK_DECLARATION([#include <stdlib.h>], environ)

dnl
dnl Check for fields in struct utmp
dnl

AC_HAVE_STRUCT_FIELD(struct utmp, ut_addr, [#include <utmp.h>])
AC_HAVE_STRUCT_FIELD(struct utmp, ut_host, [#include <utmp.h>])
AC_HAVE_STRUCT_FIELD(struct utmp, ut_id, [#include <utmp.h>])
AC_HAVE_STRUCT_FIELD(struct utmp, ut_pid, [#include <utmp.h>])
AC_HAVE_STRUCT_FIELD(struct utmp, ut_type, [#include <utmp.h>])
AC_HAVE_STRUCT_FIELD(struct utmp, ut_user, [#include <utmp.h>])
AC_HAVE_STRUCT_FIELD(struct utmpx, ut_exit, [#include <utmpx.h>])
AC_HAVE_STRUCT_FIELD(struct utmpx, ut_syslen, [#include <utmpx.h>])

dnl
dnl Check for fields in struct tm
dnl

AC_HAVE_STRUCT_FIELD(struct tm, tm_gmtoff, [#include <time.h>])
AC_HAVE_STRUCT_FIELD(struct tm, tm_zone, [#include <time.h>])

dnl
dnl or do we have a variable `timezone' ?
dnl

AC_CHECK_VAR(
[#include <time.h>],
timezone)

AC_HAVE_TYPE([sa_family_t],[#include <sys/socket.h>])

AC_HAVE_TYPE([socklen_t],[#include <sys/socket.h>])

AC_HAVE_TYPE([struct sockaddr], [#include <sys/socket.h>])

AC_HAVE_TYPE([struct sockaddr_storage], [#include <sys/socket.h>])

AC_HAVE_TYPE([struct addrinfo], [#include <netdb.h>])

dnl
dnl Check for struct winsize
dnl

AC_KRB_STRUCT_WINSIZE

dnl
dnl Check for struct spwd
dnl

AC_KRB_STRUCT_SPWD

dnl
dnl Check for sa_len in struct sockaddr
dnl

AC_HAVE_STRUCT_FIELD(struct sockaddr, sa_len, [#include <sys/types.h>
#include <sys/socket.h>])


AC_GROK_TYPES(int8_t int16_t int32_t int64_t)
AC_GROK_TYPES(u_int8_t u_int16_t u_int32_t u_int64_t)

dnl
dnl Tests for editline
dnl

dnl el_init

AC_FIND_FUNC_NO_LIBS(el_init, edit, [], [], [$LIB_tgetent])
if test "$ac_cv_func_el_init" = yes ; then
	AC_CACHE_CHECK(for four argument el_init, ac_cv_func_el_init_four,[
		AC_TRY_COMPILE([#include <stdio.h>
			#include <histedit.h>],
			[el_init("", NULL, NULL, NULL);],
			ac_cv_func_el_init_four=yes,
			ac_cv_func_el_init_four=no)])
	if test "$ac_cv_func_el_init_four" = yes; then
		AC_DEFINE(HAVE_FOUR_VALUED_EL_INIT, 1, [Define if el_init takes four arguments.])
	fi
fi

dnl readline

ac_foo=no
if test "$with_readline" = yes; then
	:
elif test "$ac_cv_func_readline" = yes; then
	:
elif test "$ac_cv_func_el_init" = yes; then
	ac_foo=yes
	LIB_readline="\$(top_builddir)/lib/editline/libel_compat.a $LIB_el_init"
else
	LIB_readline='$(top_builddir)/lib/editline/libeditline.a'
fi
AM_CONDITIONAL(el_compat, test "$ac_foo" = yes)
if test "$readline_libdir"; then
	LIB_readline="-rpath $readline_libdir $LIB_readline"
fi
LIB_readline="$LIB_readline \$(LIB_tgetent)"
AC_DEFINE(HAVE_READLINE, 1, 
	[Define if you have a readline compatible library.])dnl

dnl telnet muck --------------------------------------------------

AC_DEFINE(AUTHENTICATION, 1, 
	[Define if you want authentication support in telnet.])dnl
AC_DEFINE(ENCRYPTION, 1,
	[Define if you want encryption support in telnet.])dnl
AC_DEFINE(DES_ENCRYPTION, 1,
	[Define if you want to use DES encryption in telnet.])dnl
AC_DEFINE(DIAGNOSTICS, 1,
	[Define this to enable diagnostics in telnet.])dnl
AC_DEFINE(OLD_ENVIRON, 1,
	[Define this to enable old environment option in telnet.])dnl
if false; then
AC_DEFINE(ENV_HACK, 1,
	[Define this if you want support for broken ENV_{VAR,VAL} telnets.])
fi

# Simple test for streamspty, based on the existance of getmsg(), alas
# this breaks on SunOS4 which have streams but BSD-like ptys
#
# And also something wierd has happend with dec-osf1, fallback to bsd-ptys

AC_MSG_CHECKING(for streamspty)
case "$host" in
*-*-aix3*|*-*-sunos4*|*-*-osf*|*-*-hpux10*)
	krb_cv_sys_streamspty=no
	;;
*)
	krb_cv_sys_streamspty="$ac_cv_func_getmsg"
	;;
esac
if test "$krb_cv_sys_streamspty" = yes; then
	AC_DEFINE(STREAMSPTY, 1, [Define if you have streams ptys.])
fi
dnl AC_SUBST(STREAMSPTY)
AC_MSG_RESULT($krb_cv_sys_streamspty)

AC_AUTH_MODULES

dnl This is done by AC_OUTPUT but we need the result here.

test "x$prefix" = xNONE && prefix=$ac_default_prefix
test "x$exec_prefix" = xNONE && exec_prefix='${prefix}'

for i in bin lib libexec sbin; do
	i=${i}dir
	foo=`echo $i | tr 'xindiscernible' 'XINDISCERNIBLE'`
	x="\$${i}"
	eval y="$x"
	while test "x$y" != "x$x"; do
		x="$y"
		eval y="$x"
	done
	AC_DEFINE_UNQUOTED($foo,"$x")
done

if false; then
	# hack to shut up automake
	LIBOBJS="$LIBOBJS make-print-version.o"
fi
LTLIBOBJS=`echo "$LIBOBJS" | sed 's/\.o/\.lo/g'`
AC_SUBST(LTLIBOBJS)
AC_OUTPUT(Makefile 			\
	include/Makefile		\
	include/kadm5/Makefile		\
	lib/Makefile			\
	lib/45/Makefile			\
	lib/auth/Makefile		\
	lib/auth/afskauthlib/Makefile	\
	lib/auth/pam/Makefile		\
	lib/auth/sia/Makefile		\
	lib/asn1/Makefile		\
	lib/com_err/Makefile		\
	lib/des/Makefile		\
	lib/editline/Makefile		\
	lib/gssapi/Makefile		\
	lib/hdb/Makefile		\
	lib/kadm5/Makefile		\
	lib/kafs/Makefile		\
	lib/krb5/Makefile		\
	lib/otp/Makefile		\
	lib/roken/Makefile		\
	lib/sl/Makefile			\
	kuser/Makefile			\
	kpasswd/Makefile		\
	kadmin/Makefile			\
	admin/Makefile			\
	kdc/Makefile			\
	appl/Makefile			\
	appl/afsutil/Makefile		\
	appl/ftp/Makefile		\
	appl/ftp/common/Makefile	\
	appl/ftp/ftp/Makefile		\
	appl/ftp/ftpd/Makefile		\
	appl/kauth/Makefile		\
	appl/kx/Makefile		\
	appl/login/Makefile		\
	appl/otp/Makefile		\
	appl/popper/Makefile		\
	appl/push/Makefile		\
	appl/rsh/Makefile		\
	appl/su/Makefile		\
	appl/xnlock/Makefile		\
	appl/telnet/Makefile		\
	appl/telnet/libtelnet/Makefile	\
	appl/telnet/telnet/Makefile	\
	appl/telnet/telnetd/Makefile	\
	appl/test/Makefile		\
	appl/kf/Makefile		\
	doc/Makefile			\
)

dnl
dnl This is the release version name-number[beta]
dnl
HEIMDALVERSION="$PACKAGE-$VERSION"

cat > include/newversion.h.in <<EOF
char *heimdal_long_version = "@(#)\$Version: $HEIMDALVERSION by @USER@ on @HOST@ ($host) @DATE@ \$";
char *heimdal_version = "$HEIMDALVERSION";
EOF

if test -f include/version.h && cmp -s include/newversion.h.in include/version.h.in; then
	echo "include/version.h is unchanged"
	rm -f include/newversion.h.in
else
 	echo "creating include/version.h"
 	User=${USER-${LOGNAME}}
 	Host=`(hostname || uname -n || echo unknown) 2>/dev/null | sed 1q`
 	Date=`date`
	mv -f include/newversion.h.in include/version.h.in
	sed -e "s/@USER@/$User/" -e "s/@HOST@/$Host/" -e "s/@DATE@/$Date/" include/version.h.in > include/version.h
fi