summaryrefslogtreecommitdiff
path: root/third_party/heimdal/configure.ac
blob: e8eea4e6d3ae1832759202dab0a832909a39ec3f (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
816
817
818
819
820
821
822
823
824
825
826
827
828
829
dnl Process this file with autoconf to produce a configure script.
AC_REVISION($Revision$)
AC_PREREQ(2.62)
test -z "$CFLAGS" && CFLAGS="-g"
AC_INIT([Heimdal],[7.99.1],[https://github.com/heimdal/heimdal/issues])
AC_CONFIG_SRCDIR([kuser/kinit.c])
AC_CONFIG_HEADERS(include/config.h)
AC_CONFIG_MACRO_DIR([cf])

AM_INIT_AUTOMAKE([foreign 1.11])
AM_MAINTAINER_MODE

LT_PREREQ([2.2])
LT_INIT([shared static win32-dll])


dnl Checks for programs.
AC_PROG_CC
AM_PROG_CC_C_O
AC_PROG_CPP
AM_PATH_PYTHON
AC_CHECK_PROG(CLANG_FORMAT, clang-format, [clang-format], [no])
test "$CLANG_FORMAT" = no && CLANG_FORMAT=true

m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])

AC_PREFIX_DEFAULT(/usr/heimdal)

test "$sysconfdir" = '${prefix}/etc' && sysconfdir='/etc'
test "$localstatedir" = '${prefix}/var' && localstatedir='/var/heimdal'

AC_CANONICAL_HOST
CANONICAL_HOST=$host
AC_SUBST(CANONICAL_HOST)

rk_SYS_LARGEFILE

rk_AIX
rk_IRIX
rk_SUNOS

dnl
dnl this is needed to run the configure tests against glibc
dnl
AC_DEFINE([_GNU_SOURCE], 1,
	[Define to enable extensions on glibc-based systems such as Linux.])

AC_OBJEXT
AC_EXEEXT

dnl
dnl this is needed when der-protos.h or der-private.h has to be generated
dnl
if ! test -f "$srcdir/lib/asn1/der-protos.h" ||
   ! test -f "$srcdir/lib/asn1/der-private.h"; then
    AC_KRB_PROG_PERL
    AC_KRB_PERL_MOD(Getopt::Std)
    AC_KRB_PERL_MOD(File::Compare)
    AC_KRB_PERL_MOD(JSON)
fi

AC_KRB_PROG_YACC
dnl AC_PROG_YACC
AM_PROG_LEX
AS_IF([$LEX --nounput -V > /dev/null 2>&1 && test $? -eq 0],
      [AC_SUBST([FLEXNOUNPUTARGS], ["--nounput"])],
      [AC_SUBST([FLEXNOUNPUTARGS], [""])])
dnl AC_PROG_RANLIB
AC_PROG_AWK
AC_KRB_PROG_LN_S

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

AC_C___ATTRIBUTE__

AM_CONDITIONAL(ENABLE_SHARED, test "$enable_shared" = "yes")
rk_VERSIONSCRIPT

dnl Code coverage
AC_ARG_ENABLE([gcov],
        AC_HELP_STRING([--enable-gcov], [enable gcov code coverage tool]))
AM_CONDITIONAL([ENABLE_GCOV], [test "x$enable_gcov" = xyes])


dnl
dnl Helper bits for cross compiling
dnl

AM_CONDITIONAL(CROSS_COMPILE, test "${cross_compiling}" = yes)

AC_ARG_WITH(cross-tools,
	AS_HELP_STRING([--with-cross-tools=dir], [use cross tools in dir]),
	[if test "$withval" = "yes"; then
		AC_MSG_ERROR([Need path to cross tools])
	fi
	with_cross_tools="${with_cross_tools}/"
	])

if test "${cross_compiling}" != yes ; then

   ASN1_COMPILE="\$(top_builddir)/lib/asn1/asn1_compile\$(EXEEXT)"
   SLC="\$(top_builddir)/lib/sl/slc"

   ASN1_COMPILE_DEP="\$(ASN1_COMPILE)"
   SLC_DEP="\$(SLC)"
else
   ASN1_COMPILE="${with_cross_tools}asn1_compile"
   SLC="${with_cross_tools}slc"

   ASN1_COMPILE_DEP=
   SLC_DEP=

   ac_cv_prog_COMPILE_ET=${with_cross_tools}compile_et

fi

AX_CHECK_COMPILE_FLAG([-Wno-error=enum-conversion],
                      [WFLAGS_ENUM_CONV=-Wno-error=enum-conversion],
                      [WFLAGS_ENUM_CONV=], [-Werror])
AX_CHECK_COMPILE_FLAG([-Wno-unused-but-set-variable],
                      [WFLAGS_UNUSED_BUT_SET_VAR=-Wno-unused-but-set-variable],
                      [WFLAGS_UNUSED_BUT_SET_VAR=], [-Werror])

AC_SUBST([WFLAGS_ENUM_CONV])
AC_SUBST([ASN1_COMPILE])
AC_SUBST([ASN1_COMPILE_DEP])
AC_SUBST([SLC])
AC_SUBST([SLC_DEP])

dnl ---

AC_DEFINE(HEIM_WEAK_CRYPTO, 1, [Define if you want support for weak crypto])

rk_TEST_PACKAGE(openldap,
[#include <lber.h>
#include <ldap.h>],
[-lldap -llber],,,OPENLDAP)
AM_CONDITIONAL(OPENLDAP, test "$with_openldap" != "no")

AC_ARG_ENABLE(hdb-openldap-module, 
	AS_HELP_STRING([--enable-hdb-openldap-module],
		[if you want support to build openldap hdb as shared object]))
if test "$enable_hdb_openldap_module" = yes -a "$with_openldap" = yes; then
    AC_DEFINE(OPENLDAP_MODULE, 1, [Define if you want support for hdb ldap module])
fi
AM_CONDITIONAL(OPENLDAP_MODULE, test "$enable_hdb_openldap_module" = yes -a "$with_openldap" = yes)

AC_ARG_ENABLE(asn1-templating, 
	AS_HELP_STRING([--disable-asn1-templating],
		[if you want disable to use of the ASN.1 templating compiler]))
AM_CONDITIONAL(ASN1_TEMPLATING, test "x$enable_asn1_templating" != xno)

dnl
dnl Optional modules, pk-init, digest, kx509
dnl

AC_ARG_ENABLE(pk-init, 
	AS_HELP_STRING([--disable-pk-init],
		[if you want disable to PK-INIT support]))
if test "$enable_pk_init" != no ;then
	AC_DEFINE([PKINIT], 1, [Define to enable PKINIT.])
fi
AM_CONDITIONAL(PKINIT, test "$enable_pk_init" != no)

AC_ARG_ENABLE(digest, 
	AS_HELP_STRING([--disable-digest],
		[if you want disable to DIGEST support]))
if test "$enable_digest" != no ;then
	AC_DEFINE([DIGEST], 1, [Define to enable DIGEST.])
fi

AC_ARG_ENABLE(kx509, 
	AS_HELP_STRING([--disable-kx509],
		[if you want disable to kx509 support]))
if test "$enable_kx509" != no ;then
	AC_DEFINE([KX509], 1, [Define to enable kx509.])
fi

dnl Need to test if pkg-config exists
PKG_PROG_PKG_CONFIG

dnl libcap-ng
AC_ARG_WITH([capng],
  AC_HELP_STRING([--with-capng], [use libcap-ng to drop KDC privileges @<:@default=check@:>@]),
  [],
  [with_capng=check])
if test "$with_capng" != "no"; then
  PKG_CHECK_MODULES([CAPNG], [libcap-ng >= 0.4.0],
		    [with_capng=yes],[with_capng=no])
fi
if test "$with_capng" = "yes"; then
  AC_DEFINE_UNQUOTED([HAVE_CAPNG], 1, [whether capng is available for privilege reduction])
fi
AM_CONDITIONAL([HAVE_CAPNG], [test "$with_capng" != "no"])
AC_SUBST([CAPNG_CFLAGS])
AC_SUBST([CAPNG_LIBS])

dnl libmicrohttpd
AC_ARG_WITH([microhttpd],
  AC_HELP_STRING([--with-microhttpd], [use microhttpd to serve KDC REST API @<:@default=check@:>@]),
  [],
  [with_microhttpd=check])
if test "$with_microhttpd" != "no"; then
  PKG_CHECK_MODULES([MICROHTTPD], [libmicrohttpd >= 0.9.37],
		    [with_microhttpd=yes],[with_microhttpd=no])
fi
if test "$with_microhttpd" = "yes"; then
  AC_DEFINE_UNQUOTED([HAVE_MICROHTTPD], 1, [whether libmicrohttpd is available for KDC REST API])
fi
AM_CONDITIONAL([HAVE_MICROHTTPD], [test "$with_microhttpd" != "no"])
AC_SUBST([MICROHTTPD_CFLAGS])
AC_SUBST([MICROHTTPD_LIBS])

dnl libcjwt
AC_ARG_WITH([cjwt],
  AC_HELP_STRING([--with-cjwt], [(Experimental) use cjwt to validate JWT tokens @<:@default=check@:>@]),
  [],
  [with_cjwt=check])
if test "$with_cjwt" != "no"; then
  PKG_CHECK_MODULES([CJWT], [libcjwt >= 1.0.0],
		    [with_cjwt=yes],[with_cjwt=no])
fi
if test "$with_cjwt" = "yes"; then
  AC_DEFINE_UNQUOTED([HAVE_CJWT], 1, [whether libcjwt is available for KDC REST API])
fi
AM_CONDITIONAL([HAVE_CJWT], [test "$with_cjwt" != "no"])
AC_SUBST([CJWT_CFLAGS])
AC_SUBST([CJWT_LIBS])

dnl libcjson
AC_ARG_WITH([cjson],
  AC_HELP_STRING([--with-cjson], [(Experimental) use cJSON to extract private claims from JWT tokens @<:@default=check@:>@]),
  [],
  [with_cjson=check])
if test "$with_cjson" != "no"; then
  PKG_CHECK_MODULES([CJSON], [libcjson >= 1.0.0],
		    [with_cjson=yes],[with_cjson=no])
fi
if test "$with_cjson" = "yes"; then
  AC_DEFINE_UNQUOTED([HAVE_CJSON], 1, [whether libcjson is available for KDC REST API])
fi
AM_CONDITIONAL([HAVE_CJSON], [test "$with_cjson" != "no"])
AC_SUBST([CJSON_CFLAGS])
AC_SUBST([CJSON_LIBS])

dnl mitkrb5
AC_ARG_WITH([mitkrb5],
  AC_HELP_STRING([--with-mitkrb5], [Path to MIT Kerberos for interop testing @<:@default=check@:>@]),
  [],
  [with_mikrb5=check])
AM_CONDITIONAL([MITKRB5], [test "$with_mitkrb5" != "no"])

dnl Check for sqlite
rk_TEST_PACKAGE(sqlite3,
[#include <sqlite3.h>
#ifndef SQLITE_OPEN_CREATE
#error "old version"
#endif],
[-lsqlite3],,,SQLITE3)

if test "X$with_sqlite3" != Xyes ; then
   INCLUDE_sqlite3="-I\$(top_srcdir)/lib/sqlite"
   LIB_sqlite3="\$(top_builddir)/lib/sqlite/libheimsqlite.la"
fi
AM_CONDITIONAL(SQLITE3,  test "X$with_sqlite3" = Xyes)

AC_DEFINE(HAVE_SQLITE3, 1, [Define if you want support for sqlite in Heimdal.])

AC_ARG_ENABLE(sqlite-cache, 
	AS_HELP_STRING([--disable-sqlite-cache],[if you want support for cache in sqlite]))
if test "$enable_sqlite_cache" != no; then
    AC_DEFINE(HAVE_SCC, 1, [Define if you want support for cache in sqlite.])
fi
AM_CONDITIONAL(have_scc, test "$enable_sqlite_cache" != no)


dnl check for libintl
rk_TEST_PACKAGE(libintl,
[#include <libintl.h>],
[-lintl],,,LIBINTL)

dnl path where the hdb directory is stored
AC_ARG_WITH([hdbdir], 
	[AS_HELP_STRING([--with-hdbdir],[Default location for KDC database @<:@default=/var/heimdal@:>@])],
	[],
	[with_hdbdir=/var/heimdal])
DIR_hdbdir="$with_hdbdir"
AC_SUBST([DIR_hdbdir])


AM_CONDITIONAL(KRB5, true)
AM_CONDITIONAL(do_roken_rename, true)

AC_DEFINE(SUPPORT_INETD, 1, [Enable use of inetd style startup.])dnl


AC_DEFINE(KRB5, 1, [Enable Kerberos 5 support in applications.])dnl
AC_SUBST(LIB_kdb)dnl

KRB_CRYPTO

KRB_PTHREADS

AC_ARG_ENABLE(dce, 
	AS_HELP_STRING([--enable-dce],[if you want support for DCE/DFS PAG's]))
if test "$enable_dce" = yes; then
    AC_DEFINE(DCE, 1, [Define if you want support for DCE/DFS PAG's.])
fi
AM_CONDITIONAL(DCE, test "$enable_dce" = yes)

## XXX quite horrible:
if test -f /etc/ibmcxx.cfg; then
	dpagaix_ldadd=`sed -n '/^xlc_r4/,/^$/p' /etc/ibmcxx.cfg | sed -n -e '/libraries/{;s/^[[^=]]*=\(.*\)/\1/;s/,/ /gp;}'`
	dpagaix_cflags=`sed -n '/^xlc_r4/,/^$/p' /etc/ibmcxx.cfg | sed -n -e '/options/{;s/^[[^=]]*=\(.*\)/\1/;s/-q[^,]*//;s/,/ /gp;}'`
	dpagaix_ldflags=
else
	dpagaix_cflags="-D_THREAD_SAFE -D_AIX_PTHREADS_D7 -D_AIX32_THREADS=1 -D_AES_SOURCE -D_AIX41 -I/usr/include/dce"
	dpagaix_ldadd="-L/usr/lib/threads -ldcelibc_r -ldcepthreads -lpthreads_compat lpthreads -lc_r"
	dpagaix_ldflags="-Wl,-bI:dfspag.exp"
fi
AC_SUBST(dpagaix_cflags)
AC_SUBST(dpagaix_ldadd)
AC_SUBST(dpagaix_ldflags)

AC_ARG_ENABLE([afs-support],
	AS_HELP_STRING([--disable-afs-support],[if you don't want support for AFS]))
if test "$enable_afs_support" = no; then
	AC_DEFINE(NO_AFS, 1, [Define if you don't wan't support for AFS.])
	NO_AFS="1"
fi
AC_SUBST(NO_AFS)dnl
AM_CONDITIONAL(NO_AFS, test "$enable_afs_support" = no)

rk_DB

dnl AC_ROKEN(10,[/usr/heimdal /usr/athena],[lib/roken],[$(top_builddir)/lib/roken/libroken.la],[-I$(top_builddir)/lib/roken -I$(top_srcdir)/lib/roken])

rk_ROKEN(lib/roken)
LIBADD_roken="$LIB_roken"
AC_SUBST(LIBADD_roken)dnl
LIB_roken="\$(top_builddir)/lib/vers/libvers.la $LIB_roken"

rk_OTP

rk_LIBDISPATCH

AC_CHECK_OSFC2

AC_ARG_ENABLE(mmap,
	AS_HELP_STRING([--disable-mmap],[disable use of mmap]))
if test "$enable_mmap" = "no"; then
	AC_DEFINE(NO_MMAP, 1, [Define if you don't want to use mmap.])
fi

AC_ARG_ENABLE(afs-string-to-key,
	AS_HELP_STRING([--disable-afs-string-to-key],
	[disable use of weak AFS string-to-key functions]),
	[], [enable_afs_string_to_key=yes])

if test "$enable_afs_string_to_key" = "yes"; then
	AC_DEFINE(ENABLE_AFS_STRING_TO_KEY, 1, [Define if want to use the weak AFS string to key functions.])
	ENABLE_AFS_STRING_TO_KEY=1
fi
AC_SUBST(ENABLE_AFS_STRING_TO_KEY)dnl


rk_CHECK_MAN

rk_TEST_PACKAGE(readline,
[#include <stdio.h>
#if defined(HAVE_READLINE_READLINE_H)
#include <readline/readline.h>
#elif defined(HAVE_READLINE_H)
#include <readline.h>
#endif
],-lreadline,,, READLINE,, [readline.h readline/readline.h])

rk_TEST_PACKAGE(libedit,
[#include <stdio.h>
#if defined(HAVE_READLINE_READLINE_H)
#include <readline/readline.h>
#elif defined(HAVE_READLINE_H)
#include <readline.h>
#elif defined(HAVE_EDITLINE_READLINE_H)
#include <editline/readline.h>
#endif
],-ledit,,, READLINE,, [readline.h readline/readline.h editline/readline.h])

AC_CONFIG_SUBDIRS([lib/libedit])

KRB_C_BIGENDIAN
AC_C_INLINE

dnl AM_C_PROTOTYPES

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

dnl Checks for header files.
AC_HEADER_STDC

AC_CHECK_HEADERS([\
	CommonCrypto/CommonDigest.h		\
	CommonCrypto/CommonCryptor.h		\
	arpa/telnet.h				\
	bind/bitypes.h				\
	bsdsetjmp.h				\
	curses.h				\
	dlfcn.h					\
	execinfo.h				\
	fnmatch.h				\
	inttypes.h				\
	io.h					\
	keyutils.h				\
	libutil.h				\
	limits.h				\
	maillock.h				\
	netgroup.h				\
	netinet/in6_machtypes.h			\
	netinet/tcp.h				\
	pthread.h				\
	pty.h					\
	sac.h					\
	sgtty.h					\
	siad.h					\
	signal.h				\
	strings.h				\
	stropts.h				\
	stdatomic.h				\
	sys/bitypes.h				\
	sys/category.h				\
	sys/file.h				\
	sys/filio.h				\
	sys/ioccom.h				\
	sys/mman.h				\
	sys/param.h				\
	sys/pty.h				\
	sys/ptyio.h				\
	sys/select.h				\
	sys/socket.h				\
	sys/str_tty.h				\
	sys/stream.h				\
	sys/stropts.h				\
	sys/syscall.h				\
	sys/termio.h				\
	sys/timeb.h				\
	sys/times.h				\
	sys/types.h				\
	sys/un.h				\
	locale.h				\
	termcap.h				\
	termio.h				\
	termios.h				\
	time.h					\
	tmpdir.h				\
	udb.h					\
	util.h					\
])

dnl On Solaris 8 there's a compilation warning for term.h because
dnl it doesn't define `bool'.
AC_CHECK_HEADERS(term.h, , , -)

dnl aix have asl.h (A/IX screen library) that we don't want
AC_CHECK_HEADERS(asl.h, , , [
#include <asl.h>
#ifndef ASL_STRING_EMERG
#error ASL_STRING_EMERG missing
#endif])

AC_CHECK_HEADERS(net/if.h, , , [AC_INCLUDES_DEFAULT
#if HAVE_SYS_SOCKET_H
#include <sys/socket.h>
#endif])

AC_CHECK_HEADERS(sys/ptyvar.h, , , [AC_INCLUDES_DEFAULT
#if HAVE_SYS_TTY_H
#include <sys/tty.h>
#endif])

AC_CHECK_HEADERS(sys/strtty.h, , , [AC_INCLUDES_DEFAULT
#if HAVE_TERMIOS_H
#include <termios.h>
#endif
#if HAVE_SYS_STREAM_H
#include <sys/stream.h>
#endif])

AC_CHECK_HEADERS(sys/ucred.h, , , [AC_INCLUDES_DEFAULT
#if HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#if HAVE_SYS_PARAM_H
#include <sys/param.h>
#endif])

AC_CHECK_HEADERS(security/pam_modules.h, , , [AC_INCLUDES_DEFAULT
#include <security/pam_appl.h>
])

dnl export symbols
rk_WIN32_EXPORT(BUILD_KRB5_LIB, KRB5_LIB)
rk_WIN32_EXPORT(BUILD_ROKEN_LIB, ROKEN_LIB)
rk_WIN32_EXPORT(BUILD_GSSAPI_LIB, GSSAPI_LIB)
rk_WIN32_EXPORT(BUILD_KDC_LIB, KDC_LIB)

dnl Deal with switch fallthrough warnings
AH_TOP([
#if defined(DISPATCH_FALLTHROUGH)
# define HEIM_FALLTHROUGH DISPATCH_FALLTHROUGH
#else
# if defined(__GNUC__)
#  if __GNUC__ >= 7
#   define HEIM_FALLTHROUGH __attribute__((fallthrough))
#  else
#   define HEIM_FALLTHROUGH do {} while (0) /* fallthrough */
#  endif
# else
#  define HEIM_FALLTHROUGH do {} while (0) /* fallthrough */
# endif
#endif
])

dnl Checks for libraries.

AC_FIND_FUNC_NO_LIBS(openpty, util,[
#ifdef HAVE_UTIL_H
#include <util.h>
#endif
],[0,0,0,0,0])

AC_FIND_FUNC_NO_LIBS(tgetent, termcap ncurses curses tinfo,[
#ifdef HAVE_TERMCAP_H
#include <termcap.h>
#endif
#ifdef HAVE_CURSES_H
#include <curses.h>
#endif
],[0,0])

dnl Checks for library functions.

AC_CHECK_FUNCS([				\
	_scrsize				\
	arc4random				\
	backtrace				\
	fcntl					\
	fork					\
	fseeko					\
	ftello					\
	getpeereid				\
	getpeerucred				\
	getresgid				\
	getresuid				\
	grantpt					\
	ptsname_r				\
	rand					\
	setitimer				\
	setregid				\
	setresgid				\
	setresuid				\
	setreuid				\
	setsid					\
	sigaction				\
	unlockpt				\
	waitpid					\
])

AC_MSG_CHECKING([checking for __sync_add_and_fetch])
AC_LINK_IFELSE([AC_LANG_PROGRAM([[#include <sys/types.h>]],
	[[unsigned int foo, bar; bar = __sync_add_and_fetch(&foo, 1);]])],
	[ac_rk_have___sync_add_and_fetch=yes], [ac_rk_have___sync_add_and_fetch=no])
if test "$ac_rk_have___sync_add_and_fetch" = "yes" ; then
	AC_DEFINE_UNQUOTED(HAVE___SYNC_ADD_AND_FETCH, 1, [have __sync_add_and_fetch])
fi
AC_MSG_RESULT($ac_rk_have___sync_add_and_fetch)

AC_FUNC_MMAP

rk_DLADDR

AC_CHECK_GETPWNAM_R_POSIX
AC_CHECK_GETPWUID_R_POSIX

dnl detect doors on solaris
if test "$enable_pthread_support" != no; then
   saved_LIBS="$LIBS"
   LIBS="$LIBS $PTHREADS_LIBS"
   AC_FIND_FUNC_NO_LIBS(door_create, door)
   LIBS="$saved_LIBS"
fi

AC_ARG_ENABLE(kcm,
	AS_HELP_STRING([--enable-kcm],[enable Kerberos Credentials Manager]),
,[enable_kcm=yes])

if test "$enable_kcm" = yes ; then
   if test  "$ac_cv_header_sys_un_h" != yes -a "$ac_cv_funclib_door_create" != yes ; then
  	enable_kcm=no
   fi
fi
if test "$enable_kcm" = yes; then
       AC_DEFINE(HAVE_KCM, 1,
               [Define if you want to use the Kerberos Credentials Manager.])
fi
AM_CONDITIONAL(KCM, test "$enable_kcm" = yes)

dnl detect keyring on Linux
if test "$ac_cv_header_keyutils_h" = yes; then
    AC_CHECK_SIZEOF([key_serial_t],,[
	#ifdef HAVE_INTTYPES_H
	#include <inttypes.h>
	#endif
	#ifdef HAVE_SYS_TYPES_H
	#include <sys/types.h>
	#endif
	#include <keyutils.h>
    ])
fi

AC_FIND_FUNC_NO_LIBS(add_key, keyutils)
if test -n "$LIB_add_key"; then
    saved_LIBS="$LIBS"
    LIBS="$LIBS $LIB_add_key"
    AC_CHECK_FUNCS(keyctl_get_persistent)
    LIBS="$saved_LIBS"
fi
AM_CONDITIONAL(HAVE_KEYUTILS, test "$ac_cv_func_keyctl_get_persistent" = yes)

AC_CHECK_SIZEOF([time_t])

AX_CHECK_SIGN([time_t],
  [ AC_DEFINE(TIME_T_SIGNED, 1, [Define if time_t is signed]) ],
  [ AC_DEFINE(TIME_T_UNSIGNED, 1, [Define if time_t is unsigned]) ], [
#ifdef HAVE_TIME_H
#include <time.h>
#endif
])


AC_CHECK_TYPES([int8_t, int16_t, int32_t, int64_t, 
	u_int8_t, u_int16_t, u_int32_t, u_int64_t,
	uint8_t, uint16_t, uint32_t, uint64_t],,,[
#ifdef HAVE_INTTYPES_H
#include <inttypes.h>
#endif
#ifdef HAVE_SYS_TYPES_H
#include <sys/types.h>
#endif
#ifdef HAVE_SYS_BITYPES_H
#include <sys/bitypes.h>
#endif
#ifdef HAVE_BIND_BITYPES_H
#include <bind/bitypes.h>
#endif
#ifdef HAVE_NETINET_IN6_MACHTYPES_H
#include <netinet/in6_machtypes.h>
#endif
])

rk_FRAMEWORK_SECURITY
rk_FRAMEWORK_COREFOUNDATION

KRB_READLINE

rk_TELNET

dnl Some operating systems already have com_err and compile_et
CHECK_COMPILE_ET

rk_AUTH_MODULES([sia afskauthlib])

rk_DESTDIRS

rk_WFLAGS([-Wall -Wmissing-prototypes -Wpointer-arith -Wbad-function-cast -Wmissing-declarations -Wnested-externs])


AH_BOTTOM([#ifdef __APPLE__
#include <AvailabilityMacros.h>
#endif])

AH_BOTTOM([#ifdef ROKEN_RENAME
#include "roken_rename.h"
#endif])

AC_ARG_ENABLE(heimdal-documentation,
	AS_HELP_STRING([--disable-heimdal-documentation],
		[if you want disable to heimdal documentation]))
AM_CONDITIONAL(HEIMDAL_DOCUMENTATION, test "$enable_heimdal_documentation" != no)

AC_CONFIG_FILES(Makefile 		\
	etc/Makefile			\
	include/Makefile		\
	include/gssapi/Makefile		\
	include/hcrypto/Makefile	\
	include/kadm5/Makefile		\
	lib/Makefile			\
	lib/base/Makefile			\
	lib/asn1/Makefile		\
	lib/com_err/Makefile		\
	lib/hcrypto/Makefile		\
	lib/hx509/Makefile		\
	lib/gssapi/Makefile		\
	lib/ntlm/Makefile		\
	lib/hdb/Makefile		\
	lib/ipc/Makefile		\
	lib/kadm5/Makefile		\
	lib/kafs/Makefile		\
	lib/kdfs/Makefile		\
	lib/krb5/Makefile		\
	lib/otp/Makefile		\
	lib/roken/Makefile		\
	lib/sl/Makefile			\
	lib/sqlite/Makefile		\
	lib/vers/Makefile		\
	lib/wind/Makefile		\
	lib/gss_preauth/Makefile	\
	po/Makefile			\
	kuser/Makefile			\
	kpasswd/Makefile		\
	kadmin/Makefile			\
	admin/Makefile			\
	kcm/Makefile			\
	kdc/Makefile			\
	appl/Makefile			\
	appl/afsutil/Makefile		\
	appl/dbutils/Makefile		\
	appl/gssmask/Makefile		\
	appl/otp/Makefile		\
	appl/test/Makefile		\
	appl/kf/Makefile		\
	appl/dceutils/Makefile		\
	tests/Makefile			\
	tests/bin/Makefile		\
	tests/can/Makefile		\
	tests/db/Makefile		\
	tests/kdc/Makefile		\
	tests/ldap/Makefile		\
	tests/gss/Makefile		\
	tests/java/Makefile		\
	tests/plugin/Makefile		\
	packages/Makefile		\
	packages/mac/Makefile		\
	doc/Makefile			\
	tools/Makefile			\
)

AC_OUTPUT

dnl
dnl This is the release version name-number[beta]
dnl

if test -d "$srcdir/.git"; then
    cat > include/newversion.h.in <<EOF
#ifndef VERSION_HIDDEN
#define VERSION_HIDDEN
#endif
VERSION_HIDDEN const char *heimdal_long_version = "@([#])\$Version: $PACKAGE_STRING by @USER@ on @HOST@ @BRANCH@ @TAG@ ($host) @COMMIT@ @DATE@ \$";
VERSION_HIDDEN const char *heimdal_version = "AC_PACKAGE_STRING";
EOF
else
    cat > include/newversion.h.in <<EOF
#ifndef VERSION_HIDDEN
#define VERSION_HIDDEN
#endif
VERSION_HIDDEN const char *heimdal_long_version = "@([#])\$Version: $PACKAGE_STRING by @USER@ on @HOST@ ($host) @DATE@ \$";
VERSION_HIDDEN const char *heimdal_version = "AC_PACKAGE_STRING";
EOF
fi

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"
        if test -n "$SOURCE_DATE_EPOCH"; then
            Date=`
                  # BSD, OS X
                  date -u -r "$SOURCE_DATE_EPOCH" "+%Y-%m-%dT%H:%M:%SZ" 2>/dev/null ||
                  # Linux
                  date -u -d "@${SOURCE_DATE_EPOCH}" 2>/dev/null ||
                  # Illumos -- sorry, no -r/-d here
                  date -u ||
                  date`
        else
            Date=`date -u "+%Y-%m-%dT%H:%M:%SZ"`
        fi
        if test -n "$SOURCE_HOST"; then
            Host=$SOURCE_HOST
        else
            Host=`uname -n`
        fi
        if test -n "$SOURCE_USER"; then
            User=$SOURCE_USER
        else
            User=${USER:-${LOGNAME:-`id -nu`}}
        fi
        if test -d "$srcdir/.git"; then
            GitCommit=`cd $srcdir && git rev-parse HEAD`
            GitBranch=`cd $srcdir && git rev-parse --abbrev-ref HEAD`
            if test "x$GitBranch" = master; then
                GitDesc=`cd $srcdir && git describe --all --dirty`
            else
                GitDesc=`cd $srcdir && \
			 git describe --tags --match 'heimdal-*' --dirty`
            fi
        else
            GitCommit='<commit-unknown>'
            GitBranch='<branch-unknown>'
            GitDesc='<tag-unknown>'
        fi
	mv -f include/newversion.h.in include/version.h.in
	sed -e "s/@HOST@/$Host/" \
            -e "s;@USER@;$User;" \
            -e "s;@DATE@;$Date;" \
            -e "s;@BRANCH@;$GitBranch;" \
            -e "s;@TAG@;$GitDesc;" \
            -e "s;@COMMIT@;$GitCommit;" \
            include/version.h.in > include/version.h
fi