forked from trusteddomainproject/OpenDKIM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
2691 lines (2399 loc) · 66 KB
/
configure.ac
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
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
#
# Copyright (c) 2009-2015, The Trusted Domain Project. All rights reserved.
#
#
# Setup
#
AC_PREREQ(2.61)
#
# Package version
#
m4_define([VERSION_RELEASE], 2)
m4_define([VERSION_MAJOR_REV], 10)
m4_define([VERSION_MINOR_REV], 3)
m4_define([VERSION_PATCH], 0)
#
# Library version
# - bump "current" and reset "revision" with API changes
# - bump "revision" with internal source code changes
#
m4_define([LIBVERSION_CURRENT], 10)
m4_define([LIBVERSION_REVISION], 3)
m4_define([LIBVERSION_AGE], 0)
#
# Autotools setup
#
AC_INIT([OpenDKIM],
[VERSION_RELEASE.VERSION_MAJOR_REV.VERSION_MINOR_REV],
AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE(
1.11.1
dnl Automake version before 1.13 (when the serial-tests option was
dnl still the default) still defined the badly obsolete macro
dnl 'AM_PROG_INSTALL'.
m4_ifndef([AM_PROG_INSTALL], [serial-tests])
)
AC_CONFIG_HEADERS([build-config.h])
AC_CONFIG_MACRO_DIR([m4])
#
# Hexadecimal version, for use in generating dkim.h
#
HEX_VERSION=$(printf %08x $(( ((VERSION_RELEASE << 8 | VERSION_MAJOR_REV) << 8 | VERSION_MINOR_REV) << 8| VERSION_PATCH )))
AC_SUBST([HEX_VERSION])
#
# library version, passed to libtool
#
LIBOPENDKIM_VERSION_INFO=$(printf %d:%d:%d LIBVERSION_CURRENT LIBVERSION_REVISION LIBVERSION_AGE)
AC_SUBST([LIBOPENDKIM_VERSION_INFO])
#
# Checks for programs
#
AC_PROG_CC
AC_PROG_CC_C99
AM_PROG_CC_C_O
AC_PROG_LIBTOOL
PKG_PROG_PKG_CONFIG
#
# Check for how to compile threaded stuff
#
AX_PTHREAD
#
# save outer values
#
outer_CFLAGS="$CFLAGS"
outer_CPPFLAGS="$CPPFLAGS"
outer_LDFLAGS="$LDFLAGS"
outer_LIBS="$LIBS"
#
# Checks for libraries
#
saved_LIBS="$LIBS"
LIBS=""
AC_SEARCH_LIBS(inet_addr, nsl)
LIBNSL_LIBS="$LIBS"
LIBS="$saved_LIBS"
AC_SUBST([LIBNSL_LIBS])
saved_LIBS="$LIBS"
LIBS=""
AC_SEARCH_LIBS(dlopen, dl)
LIBDL_LIBS="$LIBS"
LIBS="$saved_LIBS"
AC_SUBST([LIBDL_LIBS])
AC_SEARCH_LIBS(socket, socket)
AC_SEARCH_LIBS(inet_aton, resolv)
AC_SEARCH_LIBS(inet_pton, resolv,
AC_DEFINE(HAVE_INET_PTON, 1,
[Define to 1 if you have the `inet_pton()' function.]))
AC_SEARCH_LIBS(inet_ntop, resolv nsl,
AC_DEFINE(HAVE_INET_NTOP, 1,
[Define to 1 if you have the `inet_ntop()' function.]))
AC_SEARCH_LIBS(getaddrinfo, resolv,
AC_DEFINE(HAVE_GETADDRINFO, 1,
[Define to 1 if you have the `getaddrinfo()' function.]))
AC_SEARCH_LIBS(res_ninit, resolv,
AC_DEFINE(HAVE_RES_NINIT, 1,
[Define to 1 if you have the `res_ninit()' function.]))
AC_SEARCH_LIBS(res_setservers, resolv bind,
AC_DEFINE(HAVE_RES_SETSERVERS, 1,
[Define to 1 if you have the `res_setservers()' function.]))
AC_SEARCH_LIBS(getopt_long, iberty,
AC_DEFINE(HAVE_GETOPT_LONG, 1,
[Define to 1 if you have the `getopt_long()' function.]))
AC_HEADER_RESOLV
#
# Check for types
#
AC_CHECK_TYPES([useconds_t])
#
# See if libopendkim will need -lresolv
#
dnscheck='
#include "confdefs.h"
#include <sys/types.h>
#include <netinet/in.h>
#include <arpa/nameser.h>
#include <resolv.h>
int main() {
res_mkquery (0, 0, 0, 0, 0, 0, 0, 0, 0);
dn_expand (0, 0, 0, 0, 0);
dn_skipname (0, 0);
dn_comp (0, 0, 0, 0, 0);
return 0;
}'
AC_MSG_CHECKING([whether the resolver works without -lresolv])
LIBRESOLV=
AC_LINK_IFELSE([AC_LANG_SOURCE([
$dnscheck
])] , [
AC_MSG_RESULT(yes)
] , [
AC_MSG_RESULT(no)
AC_MSG_CHECKING([whether the resolver works with -lresolv])
saved_LIBS="$LIBS"
LIBS="$outer_LIBS -lresolv"
AC_LINK_IFELSE([AC_LANG_SOURCE([
$dnscheck
])] , [
AC_MSG_RESULT(yes)
LIBRESOLV=-lresolv
] , [
AC_MSG_RESULT(no)
AC_MSG_ERROR([need workable resolver library])
])
LIBS="$saved_LIBS"
])
AC_SUBST([LIBRESOLV])
#
# Checks for header files
#
AC_CHECK_HEADERS([arpa/inet.h fcntl.h limits.h iso/limits_iso.h netdb.h netinet/in.h paths.h stdlib.h string.h sys/file.h sys/param.h sys/socket.h sys/time.h syslog.h unistd.h stdint.h])
#
# Checks for typedefs, structures, and compiler characteristics.
#
AC_HEADER_STDBOOL
AC_TYPE_UID_T
AC_TYPE_MODE_T
AC_TYPE_OFF_T
AC_TYPE_PID_T
AC_TYPE_SIZE_T
AC_TYPE_SSIZE_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
#
# Checks for library functions.
#
AC_FUNC_FORK
AC_FUNC_GETGROUPS
AC_FUNC_MALLOC
AC_FUNC_MKTIME
AC_FUNC_REALLOC
AC_CHECK_FUNCS([dup2 endpwent getcwd gethostname gethostbyname getaddrinfo gethostbyname2 gettimeofday isascii memchr memmove memset regcomp select socket strcasecmp strchr strdup strerror strncasecmp strrchr strstr strtol strtoul strtoull realpath strsep])
bsdstrl_h_found="no"
strl_found="no"
libstrl_found="no"
strl_h_found="no"
AC_CHECK_HEADERS([bsd/string.h], [bsdstrl_h_found="yes"])
AC_CHECK_FUNCS([strlcat strlcpy], [strl_found="yes"],
[
saved_LIBS="$LIBS"
LIBS="$outer_LIBS"
AC_SEARCH_LIBS([strlcat],
[bsd strl],
[libstrl_found="yes"],
[strl_found="no"])
AC_SEARCH_LIBS([strlcpy],
[bsd strl],
[libstrl_found="yes"],
[strl_found="no"])
STRL_LIBS="$LIBS"
LIBS="$saved_LIBS"
])
if test x"$libstrl_found" = x"yes"
then
LIBS="$LIBS $STRL_LIBS"
fi
# we need something above to have worked
if test x"$strl_found" != x"yes" -a x"$libstrl_found" != x"yes"
then
AC_MSG_ERROR(no strlcpy/strlcat found)
fi
AC_CHECK_HEADERS([strl.h], [strl_h_found="yes"])
if test x"$strl_h_found" != x"yes"
then
strldirs="/usr/local/include /usr/include"
for d in $strldirs
do
AC_MSG_CHECKING([for strl.h in $d/strl])
if test -f $d/strl/strl.h
then
unset ac_cv_header_strl_h
saved_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$CPPFLAGS -I$d/strl"
AC_CHECK_HEADERS([strl.h], [strl_h_found="yes"])
CPPFLAGS="$saved_CPPFLAGS"
fi
if test x"$strl_h_found" = x"yes"
then
CPPFLAGS="$CPPFLAGS -I$d/strl"
break
fi
done
fi
# we need to include <strl.h> if an installed strl.h was found and no
# bsd/string.h was found
if test x"$strl_h_found" = x"yes" -a x"$bsdstrl_h_found" = x"no"
then
AC_DEFINE([USE_STRL_H], 1,
[Define to 1 if you need to include <strl.h> to get the `strlcat()' and `strlcpy()' functions.])
fi
if test x"$bsdstrl_h_found" = x"yes"
then
AC_DEFINE([USE_BSD_H], 1,
[Define to 1 if you need to include <bsd/string.h> to get the `strlcat()' and `strlcpy()' functions.])
fi
#
# Checks for structure members
#
AC_CHECK_MEMBER([struct sockaddr_un.sun_len],
AC_DEFINE([HAVE_SUN_LEN],
[1],
[Define if sockaddr_un has a sun_len member]),
[],
[[#include <sys/un.h>]])
AC_CHECK_MEMBER([struct sockaddr_in.sin_len],
AC_DEFINE([HAVE_SIN_LEN],
[1],
[Define if sockaddr_in has a sin_len member]),
[],
[[#include <netinet/in.h>]])
AC_CHECK_MEMBER([struct sockaddr_in6.sin6_len],
AC_DEFINE([HAVE_SIN6_LEN],
[1],
[Define if sockaddr_in6 has a sin6_len member]),
[],
[[#include <netinet/in.h>]])
#
# Library feature string and macros
#
LIBOPENDKIM_FEATURE_STRING="libopendkim $PACKAGE_VERSION:"
AC_DEFUN([TR_UP], [m4_translit([AS_TR_SH([$1])], [a-z], [A-Z])])
AC_DEFUN([FEATURE],
[notincluded="(Not enabled for this installation.)"
AC_ARG_ENABLE($1, AS_HELP_STRING(--enable-$1, $2),
AS_IF([test "x$enable_]$1[" = "xyes"],
[
AC_SUBST(TR_UP($1)[_MANNOTICE], "")
AC_DEFINE(TR_UP($1), 1, [enable $1 feature])
],
[
AC_SUBST(TR_UP($1)[_MANNOTICE], $notincluded)
]),
AC_SUBST(TR_UP($1)[_MANNOTICE], $notincluded))
])
AC_DEFUN([LIB_FEATURE],
[FEATURE($1, $2)
AS_IF([test "x$enable_]$1[" = "xyes"],
[
LIBOPENDKIM_FEATURE_STRING="$LIBOPENDKIM_FEATURE_STRING $1"
])
])
AC_DEFUN([FFR_FEATURE],
[experimentalnotincluded="(Experimental feature not enabled for this installation.)"
AC_ARG_ENABLE($1, AS_HELP_STRING(--enable-$1, $2),
AS_IF([test "x$enable_]$1[" = "xyes"],
[
AC_DEFINE([_FFR_]TR_UP($1), 1,
[enable $1 feature])
AC_SUBST(TR_UP($1)[_MANNOTICE],
"(Note: Feature is experimental.)")
],
[
AC_SUBST(TR_UP($1)[_MANNOTICE],
$experimentalnotincluded)
]),
AC_SUBST(TR_UP($1)[_MANNOTICE],
$experimentalnotincluded))
])
AC_DEFUN([LIB_FFR_FEATURE],
[FFR_FEATURE($1, $2)
AS_IF([test "x$enable_]$1[" = "xyes"],
[
LIBOPENDKIM_FEATURE_STRING="$LIBOPENDKIM_FEATURE_STRING $1"
])
])
#
# opendkim
#
FEATURE([popauth], [enable POP-before-SMTP support])
FEATURE([poll], [use poll() instead of select()])
FFR_FEATURE([atps], [experimental Authorized Third Party Signers checks])
LIB_FFR_FEATURE([atps], [experimental Authorized Third Party Signers checks])
AM_CONDITIONAL([ATPS], [test x"$enable_atps" = x"yes"])
FFR_FEATURE([db_handle_pools], [experimental database handle pools])
FFR_FEATURE([diffheaders], [compare signed and verified headers when possible])
LIB_FFR_FEATURE([diffheaders],
[compare signed and verified headers when possible])
FFR_FEATURE([identity_header], [special header to set identity])
FFR_FEATURE([ldap_caching], [LDAP query piggybacking and caching])
FFR_FEATURE([postgresql_reconnect_hack],
[hack to overcome PostgreSQL connection error detection bug])
FFR_FEATURE([rate_limit], [support for DKIM-based rate limiting])
FFR_FEATURE([replace_rules], [support for string substitution when signing])
AM_CONDITIONAL([REPLACE_RULES], [test x"$enable_replace_rules" = x"yes"])
FFR_FEATURE([reprrd],
[support for experimental reputation checks using RRD])
AM_CONDITIONAL([REPRRD], [test x"$enable_reprrd" = x"yes"])
AC_CHECK_PROG([hasrrdtool], [rrdtool], [yes])
if test x"$enable_reprrd" = x"yes" -a x"$hasrrdtool" != x"yes"
then
AC_MSG_ERROR([--enable-reprrd requires rrdtool binary, not found])
fi
FFR_FEATURE([reputation],
[support for experimental reputation checks])
if test x"$enable_reputation" = x"yes"
then
AC_SEARCH_LIBS([ceil], [m])
fi
AM_CONDITIONAL([REPUTE], [test x"$enable_reputation" = x"yes"])
FFR_FEATURE([resign],
[support for one-step re-signing])
FFR_FEATURE([sender_macro], [macro to determine sender])
FFR_FEATURE([socketdb], [arbitrary socket data sets])
FFR_FEATURE([stats], [stats recording and reporting])
AM_CONDITIONAL([STATS], [test x"$enable_stats" = x"yes"])
FFR_FEATURE([statsext], [extended stats recording and reporting])
FFR_FEATURE([rbl], [Realtime Blacklist query support])
AM_CONDITIONAL([RBL], [test x"$enable_rbl" = x"yes"])
FFR_FEATURE([vbr], [Vouch-By-Reference support])
AM_CONDITIONAL([VBR], [test x"$enable_vbr" = x"yes"])
if test x"$enable_statsext" = x"yes" -a x"$enable_stats" != x"yes"
then
AC_MSG_ERROR([--enable-statsext requires --enable-stats])
fi
FFR_FEATURE([default_sender], [default sender address])
# sendmail command
AC_PATH_PROG([SENDMAIL_PATH], [sendmail], [/usr/sbin/sendmail],
[/sbin:/usr/sbin:/usr/local/bin:/usr/local/sbin:/usr/lib:$PATH])
AC_DEFINE_UNQUOTED([SENDMAIL_PATH], "$ac_cv_path_SENDMAIL_PATH",
[The path the the sendmail executable for report sending])
AC_SUBST([SENDMAIL_PATH])
#
# use rpath at load time?
#
AC_ARG_ENABLE(
[rpath],
AS_HELP_STRING([--enable-rpath],
[include library load paths in binaries]),
,
enable_rpath="yes")
AM_CONDITIONAL([RPATH], [test x"$enable_rpath" = x"yes"])
if test x"$enable_rpath" != x"yes"
then
AC_MSG_RESULT([Suppressing -rpath use by libtool])
hardcode_libdir_flag_spec=" -D__LIBTOOL_NO_RPATH__ "
chmod 0755 libtool
fi
#
# test coverage/profiling stuff
#
AC_ARG_ENABLE([codecoverage],
AS_HELP_STRING([--enable-codecoverage],
[include code coverage/profiling code]))
if test x"$enable_codecoverage" = x"yes"
then
# gcc can do all of them; Solaris cc can only do gprof
AC_CHECK_PROG([hasgcc], [gcc], [yes])
AC_CHECK_PROG([hascc], [cc], [yes])
if test x"$hasgcc" != x"yes" -a x"$hascc" = x"yes"
then
if test x`cc -V 2>&1 | grep -c "Sun C"` = x"1"
then
hassuncc="yes"
fi
fi
# figure out which profiling system to use
AC_CHECK_PROG([hasgprof], [gprof], [yes])
AC_ARG_WITH(gprof,
AS_HELP_STRING(--with-gprof, profiling with gprof),
hasgprof="$withval")
if test x"$hasgcc" = x"yes"
then
AC_CHECK_PROG([hasgcov], [gcov], [yes])
AC_ARG_WITH(gcov,
AS_HELP_STRING(--with-gcov, profiling with gcov),
hasgcov="$withval")
AC_CHECK_PROG([haslcov], [lcov], [yes])
AC_ARG_WITH(lcov,
AS_HELP_STRING(--with-lcov, profiling with lcov),
haslcov="$withval")
fi
# bail if none
if test x"$hasgprof" != x"yes" -a \
x"$hasgcov" != x"yes" -a \
x"$haslcov" != x"yes"
then
AC_MSG_ERROR([no supported test coverage packages found])
fi
# see if there's a libgcov (OpenBSD doesn't have one)
if test x"$hasgcov" = x"yes" -a x"$haslcov" != x"yes"
then
saved_LIBS="$LIBS"
LIBS="$outer_LIBS"
AC_SEARCH_LIBS([__gcov_init], [gcov])
GCOV_LIBS="$LIBS"
LIBS="$saved_LIBS"
fi
COV_CFLAGS=""
COV_LDFLAGS=""
COV_LIBADD=""
# sun profiling
if test x"$hasgprof" = x"yes" -a \
x"$hasgcov" != x"yes" -a \
x"$hassuncc" = x"yes"
then
COV_CFLAGS="-g -xpg"
COV_LDFLAGS="-g -xpg"
# non-sun profiling
elif test x"$hasgprof" = x"yes" -a \
x"$hasgcov" != x"yes" -a \
x"$hassuncc" != x"yes"
then
COV_CFLAGS="-g -pg"
COV_LDFLAGS="-g -pg"
# gcov profiling
elif test x"$hasgcov" = x"yes"
then
COV_CFLAGS="-g -fprofile-arcs -ftest-coverage"
COV_LIBADD="$GCOV_LIBS"
fi
AC_SUBST(COV_CFLAGS)
AC_SUBST(COV_LDFLAGS)
AC_SUBST(COV_LIBADD)
fi
# see if profiling-enabled binaries generate profile output with the
# standard name "gmon.out" or "<file>.gmon"
gprof_gmon_out="unknown"
if test x"$hasgprof" = x"yes"
then
gprofcheck='
int main() {
long x;
x = random();
}'
AC_MSG_CHECKING([names of profiling output files])
saved_CFLAGS="$CFLAGS"
saved_LDFLAGS="$LDFLAGS"
CFLAGS="$CFLAGS $COV_CFLAGS"
LDFLAGS="$LDFLAGS $COV_LDFLAGS"
AC_RUN_IFELSE([AC_LANG_SOURCE([$gprofcheck])],
[ if test -f "gmon.out"
then
gprof_gmon_out="yes"
rm -f gmon.out
AC_MSG_RESULT(gmon.out)
else
gprof_gmon_out="no"
rm -f *.gmon
AC_MSG_RESULT([<binary>.gmon])
fi
],
[AC_MSG_RESULT(unknown)])
CFLAGS="$saved_CFLAGS"
LDFLAGS="$saved_LDFLAGS"
fi
AM_CONDITIONAL(LCOV, test x"$haslcov" = x"yes" -a x"$hasgcov" = x"yes")
AM_CONDITIONAL(GCOV, test x"$hasgcov" = x"yes")
AM_CONDITIONAL(GCOV_ONLY, test x"$hasgcov" = x"yes" -a x"$haslcov" != x"yes")
AM_CONDITIONAL(GPROF, test x"$hasgprof" = x"yes" -a x"$hasgcov" != x"yes")
AM_CONDITIONAL(GPROF_FILENAMES, test x"$gprof_gmon_out" = x"no")
#
# opendkim
#
AC_ARG_ENABLE([filter],
AS_HELP_STRING([--disable-filter],
[do not compile the opendkim filter]),
[enable_filter=$enableval],
[enable_filter=yes])
AM_CONDITIONAL([BUILD_FILTER], [test x"$enable_filter" != x"no"])
#
# libopendkim
#
LIB_FEATURE([query_cache], [local key caching])
#
# Conditional stuff
#
AC_ARG_ENABLE([allsymbols],
AS_HELP_STRING([--enable-allsymbols],
[export internal-use symbols for better test coverage]))
AM_CONDITIONAL(ALL_SYMBOLS, [test x"$enable_allsymbols" = x"yes"])
# the AM_CONDITIONAL and AC_DEFINE for USE_ARLIB are farther below,
# after the Darwin checks
AC_ARG_ENABLE([debug],
AS_HELP_STRING([--enable-debug],
[produce debugging binaries and libraries]),
AS_IF([test "x$enable_debug" = x"yes"],
[
LIBOPENDKIM_FEATURE_STRING="$LIBOPENDKIM_FEATURE_STRING debug"
[[CFLAGS=`echo $CFLAGS | sed 's/ -O[1-9s]*//g'`]]
])
)
AM_CONDITIONAL([DEBUG], [test x"$enable_debug" = x"yes"])
#
# gnutls
#
AC_ARG_WITH([gnutls],
AS_HELP_STRING([--with-gnutls],
[location of GnuTLS includes and library]),
[gtpath="$withval"], [gtpath="no"])
gnutls_found="no"
if test \( x"$gtpath" = x"auto" -o x"$gtpath" = x"yes" \) -a x"$PKG_CONFIG" != x""
then
PKG_CHECK_MODULES([GNUTLS], [gnutls >= 2.11.7],
[gnutls_found="pkg-config"],
[gnutls_found="auto"
AC_MSG_WARN([pkg-config for GnuTLS not found, trying manual search...])
])
elif test x"$gtpath" != x"no"
then
AC_MSG_NOTICE([checking for GnuTLS library and includes in $gtpath])
saved_CFLAGS="$CFLAGS"
saved_CPPFLAGS="$CPPFLAGS"
saved_LDFLAGS="$LDFLAGS"
saved_LIBS="$LIBS"
LIBS="$outer_LIBS -lgnutls $saved_LIBS"
CPPFLAGS="-I$gtpath/include $saved_CPPFLAGS"
CFLAGS="$saved_CFLAGS"
LDFLAGS="-L$gtpath/lib $saved_LDFLAGS"
AC_CHECK_HEADERS([gnutls/gnutls.h], ,
AC_MSG_ERROR([required GnuTLS header not found]))
AC_SEARCH_LIBS([gnutls_global_init], [gnutls], ,
AC_MSG_ERROR([libgnutls not found]),
[-lnettle -lgmp -ldl])
LIBCRYPTO_CPPFLAGS="-I$gtpath/include"
LIBCRYPTO_LIBDIRS="-L$gtpath/lib"
LIBCRYPTO_LIBS="-lgnutls"
CFLAGS="$saved_CFLAGS"
CPPFLAGS="$saved_CPPFLAGS"
LDFLAGS="$saved_LDFLAGS"
LIBS="$saved_LIBS"
gnutls_found="yes"
fi
if test x"$gnutls_found" = x"pkg-config"
then
LIBCRYPTO_CPPFLAGS="$GNUTLS_CFLAGS"
LIBCRYPTO_LDFLAGS=""
LIBCRYPTO_LIBS="$GNUTLS_LIBS"
gnutls_found="yes"
fi
if test x"$gtpath" = x"yes" -a x"$gnutls_found" = x"auto"
then
gcdirs="/usr/local /usr"
for d in $gcdirs
do
AC_MSG_NOTICE([checking for GnuTLS library and includes in $d])
saved_CFLAGS="$CFLAGS"
saved_CPPFLAGS="$CPPFLAGS"
saved_LDFLAGS="$LDFLAGS"
saved_LIBS="$LIBS"
LIBS="$outer_LIBS -lgnutls $saved_LIBS"
CPPFLAGS="-I$d/include $saved_CPPFLAGS"
CFLAGS="$saved_CFLAGS"
LDFLAGS="$outer_LDFLAGS -L$d/lib $saved_LDFLAGS"
gnutls_h_found="no"
gnutls_lib_found="no"
AC_CHECK_HEADERS([gnutls/gnutls.h], gnutls_h_found="yes")
AC_SEARCH_LIBS([gnutls_global_init], [gnutls],
gnutls_lib_found="yes", , [-lnettle -lgmp])
CFLAGS="$saved_CFLAGS"
CPPFLAGS="$saved_CPPFLAGS"
LDFLAGS="$saved_LDFLAGS"
LIBS="$saved_LIBS"
if test x"$gnutls_h_found" = x"yes" -a \
x"$gnutls_lib_found" = x"yes"
then
LIBCRYPTO_CPPFLAGS="-I$d/include"
LIBCRYPTO_LIBDIRS="-L$d/lib"
LIBCRYPTO_LIBS="-lgnutls"
gnutls_found="yes"
AC_MSG_NOTICE(libgnutls found in $d)
break
else
AC_MSG_NOTICE(not found in $d)
fi
done
if test x"$gnutls_found" != x"yes"
then
AC_MSG_ERROR([GnuTLS not found])
fi
fi
if test x"$gnutls_found" = x"yes"
then
AC_DEFINE(USE_GNUTLS, 1,
[Define to 1 to use libgnutls instead of OpenSSL.])
saved_CPPFLAGS="$CPPFLAGS"
CPPFLAGS="$LIBCRYPTO_CPPFLAGS $saved_CPPFLAGS"
versioncheck='
#include <gnutls/gnutls.h>
#if GNUTLS_VERSION_NUMBER < 0x020b07
# error GnuTLS 2.11.7 or later required
#endif
int main()
{
return 0;
}'
AC_MSG_CHECKING([your GnuTLS version])
AC_LINK_IFELSE([AC_LANG_SOURCE([$versioncheck])],
AC_MSG_RESULT(ok),
AC_MSG_FAILURE([GnuTLS must be at least version 2.11.7]))
sha256check='
#include <gnutls/gnutls.h>
int main()
{
int x = GNUTLS_DIG_SHA256;
}'
AC_MSG_CHECKING([whether your GnuTLS supports SHA256])
AC_LINK_IFELSE([AC_LANG_SOURCE([$sha256check])],
AC_MSG_RESULT(yes)
AC_DEFINE([HAVE_SHA256], 1,
[Define to 1 if your crypto library has SHA256 support]),
AC_MSG_WARN([SHA256 is required for DKIM but is not
supported with your version of GnuTLS]))
CPPFLAGS="$saved_CPPFLAGS"
fi
AM_CONDITIONAL([USE_GNUTLS], [test x"$gnutls_found" = x"yes"])
#
# OpenSSL
#
AC_ARG_WITH([openssl],
AS_HELP_STRING([--with-openssl],
[location of OpenSSL includes and library]),
[sslpath="$withval"], [sslpath="auto"])
openssl_found="no"
if test x"$gnutls_found" = x"yes"
then
sslpath="skip"
openssl_found="skip"
fi
if test \( "$sslpath" = "auto" -o x"$sslpath" = x"yes" \) -a x"$PKG_CONFIG" != x""
then
PKG_CHECK_MODULES([LIBCRYPTO], [openssl >= 0.9.7],
[openssl_found="yes"],
[openssl_found="no"
AC_MSG_WARN([pkg-config for openssl not found, trying manual search...])
])
elif test "$sslpath" != "auto" -a x"$sslpath" != x"yes"
then
AC_MSG_CHECKING([for OpenSSL includes])
if test -f $sslpath/include/openssl/opensslv.h
then
LIBCRYPTO_CPPFLAGS="-I$sslpath/include"
LIBCRYPTO_CFLAGS=""
LIBCRYPTO_LIBDIRS="-L$sslpath/lib"
LIBCRYPTO_LIBS="-lssl -lcrypto"
openssl_found=yes
AC_MSG_RESULT([$sslpath])
else
AC_MSG_RESULT([no])
fi
fi
if test x"$openssl_found" = x"no"
then
AC_MSG_CHECKING([for OpenSSL library and includes])
ssldirs="/usr/local/ssl /usr/local /usr/sfw /opt/local /usr"
if test "$sslpath" = "auto" -o "$sslpath" = "yes"
then
for d in $ssldirs
do
if test -f $d/include/openssl/opensslv.h
then
sslpath=$d
openssl_found=yes
break
fi
done
fi
case "$sslpath" in
no)
AC_MSG_ERROR([OpenSSL is required])
;;
auto)
AC_MSG_ERROR([OpenSSL not found])
;;
*/*)
AC_MSG_RESULT([$sslpath])
;;
*)
AC_MSG_ERROR([OpenSSL not found])
;;
esac
LIBCRYPTO_CPPFLAGS="-I$sslpath/include"
LIBCRYPTO_CFLAGS=""
LIBCRYPTO_LIBDIRS="-L$sslpath/lib"
LIBCRYPTO_LIBS="-lssl -lcrypto"
fi
if test x"$openssl_found" = x"yes"
then
saved_CFLAGS="$CFLAGS"
saved_CPPFLAGS="$CPPFLAGS"
saved_LDFLAGS="$LDFLAGS"
saved_LIBS="$LIBS"
LIBS="$outer_LIBS $LIBCRYPTO_LIBS $saved_LIBS"
CPPFLAGS="$LIBCRYPTO_CPPFLAGS $saved_CPPFLAGS"
CFLAGS="$LIBCRYPTO_CFLAGS $saved_CFLAGS"
LDFLAGS="$outer_LDFLAGS $LIBCRYPTO_LIBDIRS $saved_LDFLAGS"
AC_CHECK_HEADERS([openssl/bio.h openssl/conf.h openssl/crypto.h openssl/err.h openssl/evp.h openssl/md5.h openssl/opensslv.h openssl/pem.h openssl/rsa.h openssl/sha.h openssl/ssl.h], ,
AC_MSG_ERROR([required OpenSSL header not found]))
# -ldl is needed to assist with compilation of static openssl libraries.
# It appears to need dl for opening engine plugins. It fails at load
# time It also fails to build on FreeBSD if enabled by default.
AC_SEARCH_LIBS([ERR_peek_error], [crypto], ,
AC_MSG_ERROR([libcrypto not found]))
AC_SEARCH_LIBS([SSL_library_init], [ssl], ,
[
if test x"$enable_shared" = x"yes"
then
AC_MSG_ERROR([Cannot build shared opendkim
against static openssl libraries.
Configure with --disable-shared
to get this working or obtain a
shared libssl library for
opendkim to use.])
fi
# avoid caching issue - last result of SSL_library_init
# shouldn't be cached for this next check
unset ac_cv_search_SSL_library_init
LIBCRYPTO_LIBS="$LIBCRYPTO_LIBS -ldl"
AC_SEARCH_LIBS([SSL_library_init], [ssl], ,
AC_MSG_ERROR([libssl not found]), [-ldl])
]
)
AC_CHECK_DECL([SHA256_DIGEST_LENGTH],
AC_DEFINE([HAVE_SHA256], 1,
[Define to 1 if your crypto library has SHA256 support]),
AC_MSG_WARN([SHA256 is required for DKIM but is not
supported with your version of OpenSSL]),
[
#include <sys/types.h>
#include <openssl/sha.h>])
CFLAGS="$saved_CFLAGS"
CPPFLAGS="$saved_CPPFLAGS"
LDFLAGS="$saved_LDFLAGS"
LIBS="$saved_LIBS"
fi
AC_SUBST(LIBCRYPTO_CFLAGS)
AC_SUBST(LIBCRYPTO_CPPFLAGS)
AC_SUBST(LIBCRYPTO_LIBDIRS)
AC_SUBST(LIBCRYPTO_LIBS)
#
# libmilter
#
AC_MSG_CHECKING([for milter library and includes])
AC_ARG_WITH([milter],
AS_HELP_STRING([--with-milter],
[location of milter includes and library]),
[milterpath="$withval"], [milterpath="auto"])
if test x"$enable_filter" = x"no"
then
milterpath="no"
fi
if test "$milterpath" = "auto" -o "$milterpath" = "yes"
then
milterdirs="/usr/local /opt/local /usr"
for d in $milterdirs
do
if test -f $d/include/libmilter/mfapi.h
then
milterpath=$d
break
fi
done
fi
case "$milterpath" in
no)
if test x"$enable_filter" = x"yes"
then
AC_MSG_ERROR([milter is required])
fi
AC_MSG_RESULT(disabled)
;;
auto)
AC_MSG_ERROR([milter not found])
;;
*/*)
if ! test -f $milterpath/include/libmilter/mfapi.h
then
AC_MSG_ERROR([milter includes not found at $milterpath])
fi
AC_MSG_RESULT([$milterpath])
;;
*)
AC_MSG_ERROR([milter not found])
;;
esac
LIBMILTER_INCDIRS=""
LIBMILTER_LIBDIRS=""
LIBMILTER_LIBS=""
if test x"$milterpath" != x"no"
then
LIBMILTER_INCDIRS="-I$milterpath/include"
saved_CC="$CC"
saved_CFLAGS="$CFLAGS"
saved_CPPFLAGS="$CPPFLAGS"
saved_LDFLAGS="$LDFLAGS"
saved_LIBS="$LIBS"
CC="$PTHREAD_CC"
LIBS="$outer_LIBS $PTHREAD_LIBS $saved_LIBS"
CPPFLAGS="$LIBMILTER_INCDIRS $saved_CPPFLAGS"
CFLAGS="$PTHREAD_CFLAGS $saved_CFLAGS"
LDFLAGS="$outer_LDFLAGS $PTHREAD_CFLAGS $saved_LDFLAGS"
breakloop="no"
for d in lib lib64 lib/libmilter
do
unset ac_cv_search_smfi_register
LDFLAGS="$outer_LDFLAGS $PTHREAD_CFLAGS -L$milterpath/$d $saved_LDFLAGS"
AC_SEARCH_LIBS([smfi_register], [milter],
[
LIBMILTER_LIBDIRS="-L$milterpath/$d"
LIBMILTER_LIBS="-lmilter"
breakloop="yes"
])
AC_CHECK_FUNC([smfi_insheader],
AC_DEFINE([HAVE_SMFI_INSHEADER], 1,
[Define if libmilter has smfi_insheader()]))
AC_CHECK_FUNC([smfi_opensocket],
AC_DEFINE([HAVE_SMFI_OPENSOCKET], 1,
[Define if libmilter has smfi_opensocket()]))
AC_CHECK_FUNC([smfi_progress],
AC_DEFINE([HAVE_SMFI_PROGRESS], 1,
[Define if libmilter has smfi_progress()]))
AC_CHECK_FUNC([smfi_setsymlist],
AC_DEFINE([HAVE_SMFI_SETSYMLIST], 1,
[Define if libmilter has smfi_setsymlist()]))