forked from trusteddomainproject/OpenDMARC
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure.ac
548 lines (488 loc) · 14.4 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
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
#
# Copyright (c) 2012-2017, 2018, 2021, The Trusted Domain Project.
# All rights reserved.
# SPF support:
# Define --with-spf to include either internal OR libspf2 support. For libspf2
# support, also define these:
# --with-spf2-include=path
# --with-spf2-lib=path
#
# Setup
#
AC_CONFIG_AUX_DIR([build-aux])
AC_PREREQ(2.61)
#
# Package version
#
m4_define([VERSION_RELEASE], 1)
m4_define([VERSION_MAJOR_REV], 4)
m4_define([VERSION_MINOR_REV], 2)
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], 2)
m4_define([LIBVERSION_REVISION], 3)
m4_define([LIBVERSION_AGE], 0)
#
# Autotools setup
#
AC_INIT([OpenDMARC],
[VERSION_RELEASE.VERSION_MAJOR_REV.VERSION_MINOR_REV],
AC_CONFIG_AUX_DIR(build-aux)
AC_CONFIG_AUX_DIR([build-aux])
AC_CANONICAL_TARGET
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([.])
AC_CONFIG_HEADERS(build-config.h)
AC_CONFIG_MACRO_DIR([m4])
AC_HEADER_RESOLV
AC_CHECK_TYPES([ns_type], [], [], [[
#ifdef HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#ifdef HAVE_NETINET_IN_H
# include <netinet/in.h> /* inet_ functions / structs */
#endif
#ifdef HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h> /* DNS HEADER struct */
#endif
#ifdef HAVE_NETDB_H
# include <netdb.h>
#endif
#include <resolv.h>
]])
#
# Hexadecimal version, for use in generating dmarc.h
#
HEX_VERSION=$(printf %08x $(( ((VERSION_RELEASE << 8 | VERSION_MAJOR_REV) << 8 | VERSION_MINOR_REV) << 8 | VERSION_PATCH )))
AC_SUBST([HEX_VERSION])
#
# version string for GitHub assets
# https://github.com/trusteddomainproject/OpenDMARC/archive/rel-opendmarc-1-4-0.tar.gz
# https://github.com/trusteddomainproject/OpenDMARC/archive/rel-opendmarc-1-4-0-Beta1.tar.gz
# Beta tag is passed to RPM by downstream packagers and expanded there.
#
GITHUB_VERSION=$(printf %d-%d-%d VERSION_RELEASE VERSION_MAJOR_REV VERSION_MINOR_REV)
AC_SUBST([GITHUB_VERSION])
#
# library version, passed to libtool
#
LIBOPENDMARC_VERSION_INFO=$(printf %d:%d:%d LIBVERSION_CURRENT LIBVERSION_REVISION LIBVERSION_AGE)
AC_SUBST([LIBOPENDMARC_VERSION_INFO])
#
# Checks for programs
#
AC_PROG_CC
AM_PROG_CC_C_O
LT_INIT
PKG_PROG_PKG_CONFIG
AC_ARG_WITH([installdir],
AS_HELP_STRING([--with-installdir=/path], [(default =/usr/local)]),
LIBDMARC_BASE=$withval, LIBDMARC_BASE=/usr/local/)
AC_SUBST(LIBDMARC_DIR, $LIBDMARC_BASE)
#
# Check for how to compile threaded stuff
#
AX_PTHREAD
AC_CHECK_HEADERS(stdio.h)
AC_CHECK_HEADERS(syslog.h)
AC_CHECK_HEADERS(sysexits.h)
AC_CHECK_HEADERS(poll.h)
AC_CHECK_HEADERS(time.h)
AC_CHECK_HEADERS(netdb.h)
AC_CHECK_HEADERS(errno.h)
AC_CHECK_HEADERS(ctype.h)
AC_CHECK_HEADERS(fcntl.h)
AC_CHECK_HEADERS(string.h)
AC_CHECK_HEADERS(sys/param.h)
AC_CHECK_HEADERS(sys/socket.h)
AC_CHECK_HEADERS(sys/types.h)
AC_CHECK_HEADERS(sys/types.h)
AC_CHECK_HEADERS(arpa/inet.h sys/socket.h netdb.h sys/ioctl.h)
AC_CHECK_HEADERS(iso/limits_iso.h)
AC_CHECK_HEADERS([netinet/in.h], [], [],
[#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
])
AC_CHECK_HEADERS([arpa/nameser.h], [], [],
[#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
])
AC_CHECK_HEADERS([resolv.h], [], [],
[#if HAVE_SYS_TYPES_H
# include <sys/types.h>
#endif
#if HAVE_NETINET_IN_H
# include <netinet/in.h>
#endif
#if HAVE_ARPA_NAMESER_H
# include <arpa/nameser.h>
#endif
])
AC_CHECK_LIB(socket, connect)
AC_CHECK_LIB(resolv, hstrerror, , , [-lnsl -lsocket])
AC_CHECK_LIB(resolv, inet_aton, , , [-lnsl -lsocket])
# You might find res_ninit() in system libraries or in libresolv or not
# at all. The way AC_LANG_CALL finds out is it declares res_ninit() so
# it can call it, then it sees if linking fails because of unresolved
# symbols. Great, except glibc doesn't export res_ninit() -- it exports
# __res_ninit() -- res_ninit() is a macro in resolv.h. So unless we
# include resolv.h, we won't find res_ninit(), but when we do include
# it, it conflicts with AC_LANG_CALL's redeclaration. Hmm. I guess the
# only thing for it is to include resolv.h, don't redeclare res_ninit(),
# and use the proper type signature when calling it.
m4_rename([AC_LANG_CALL], [saved_AC_LANG_CALL])
m4_define([AC_LANG_CALL], [AC_LANG_PROGRAM([#include <resolv.h>],
[return res_ninit(NULL);])])
AC_SEARCH_LIBS(res_ninit, resolv,
AC_DEFINE(HAVE_RES_NINIT, 1,
[Define to 1 if you have the `res_ninit()' function.]))
# Same as above, but for res_ndestroy.
m4_define([AC_LANG_CALL], [AC_LANG_PROGRAM([#include <resolv.h>],
[res_ndestroy(NULL);])])
AC_SEARCH_LIBS(res_ndestroy, resolv,
AC_DEFINE(HAVE_RES_NDESTROY, 1,
[Define to 1 if you have the `res_ndestroy()' function.]))
m4_rename_force([saved_AC_LANG_CALL], [AC_LANG_CALL])
AC_CHECK_LIB(idn, idn_free)
AC_CHECK_LIB(rt, nanosleep)
AC_SEARCH_LIBS(inet_addr, nsl)
AC_SEARCH_LIBS(freehostent, 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,
AC_DEFINE(HAVE_INET_NTOP, 1,
[Define to 1 if you have the `inet_ntop()' function.]))
AC_SEARCH_LIBS(getipnodebyname, resolv,
AC_DEFINE(HAVE_GETADDRINFO, 1,
[Define to 1 if you have the `getipnodebyname()' function.]))
AC_HEADER_RESOLV
AC_C_BIGENDIAN
AC_STRUCT_TM
AC_C_CONST
AC_TYPE_SIZE_T
AC_CHECK_SIZEOF(long)
AC_CHECK_SIZEOF(int)
AC_CHECK_SIZEOF(short)
AC_CHECK_SIZEOF(char)
AC_CHECK_SIZEOF(size_t)
AC_CHECK_SIZEOF(long long)
AC_CHECK_SIZEOF(unsigned long long)
AC_CHECK_SIZEOF(void *)
AC_FUNC_MALLOC
AC_FUNC_REALLOC
AC_SEARCH_LIBS(strlcat, bsd strl,
AC_DEFINE(HAVE_STRLCAT, 1,
[Define to 1 if you have the `strlcat()' function.]))
AC_SEARCH_LIBS(strlcpy, bsd strl,
AC_DEFINE(HAVE_STRLCPY, 1,
[Define to 1 if you have the `strlcpy()' function.]))
AC_CHECK_FUNCS(basename)
AC_CHECK_FUNCS(syslog)
AC_CHECK_FUNCS(cuserid)
AC_CHECK_FUNCS(memset bzero, break)
AC_CHECK_FUNCS(memcpy bcopy, break)
AC_CHECK_FUNCS(strerror)
AC_CHECK_FUNCS(strchr)
AC_CHECK_FUNCS(strrchr)
AC_CHECK_FUNCS(strdup)
AC_CHECK_FUNCS(strpbrk)
AC_CHECK_FUNCS(inet_ntoa)
AC_CHECK_FUNCS(strcasecmp)
AC_CHECK_FUNCS(strncasecmp)
AC_CHECK_HEADERS(signal.h)
AC_CHECK_HEADERS(regex.h)
bsdstrl_h_found="no"
strl_h_found="no"
AC_CHECK_HEADERS([bsd/string.h], [bsdstrl_h_found="yes"])
AC_CHECK_HEADERS([strl.h], [strl_h_found="yes"])
# 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
# Use opendmarc strl if neither a system strl nor libbsd are found
if test x"$strl_h_found" = x"no" -a x"$bsdstrl_h_found" = x"no"
then
AC_DEFINE([USE_DMARCSTRL_H], 1,
[Define to 1 if you need to include <opendmarc_strl.h> to get the `strlcat()' and `strlcpy()' functions.])
fi
AC_PROG_LN_S
AC_CHECK_PROG(miltertest, miltertest, "yes", "no")
AC_SUBST(ac_aux_dir)
#
# See if we 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=-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])
#
# --with-sql-backend -- configures some defaults for DB access
#
AC_ARG_WITH([sql-backend],
AS_HELP_STRING([--with-sql-backend],
[selection of SQL backend in use]),
[SQL_BACKEND="$withval"], [SQL_BACKEND="mysql"])
if test x"$SQL_BACKEND" = x"yes"
then
SQL_BACKEND="mysql"
fi
AC_SUBST(SQL_BACKEND)
AC_DEFINE_UNQUOTED(SQL_BACKEND, "$SQL_BACKEND", [default SQL back-end])
AC_ARG_WITH([spf],
AS_HELP_STRING([--with-spf], [enable SPF checking]),
AC_DEFINE(WITH_SPF, 1, [Define to 1 if you want SPF support.]),
[])
AC_ARG_WITH([spf2-include],
AS_HELP_STRING([--with-spf2-include], [path to libspf2 includes]),
SPF2_INCLUDE="$withval",
[])
AC_ARG_WITH([spf2-lib],
AS_HELP_STRING([--with-spf2-lib], [path to libspf2 libraries]),
SPF2_LIB="$withval",
[])
use_spf="no"
if test "x$SPF2_INCLUDE" != "x" -a "x$SPF2_LIB" != "x"
then
use_spf="yes"
if test -f ${SPF2_INCLUDE}/spf.h
then
AC_DEFINE(HAVE_SPF2_H, 1,
[Define to 1 if you have libspf2's `spf.h'])
spf2_include="-I $SPF2_INCLUDE"
saved_CFLAGS="$CFLAGS"
saved_LDFLAGS="$LDFLAGS"
CFLAGS="$spf2_include $saved_CFLAGS"
LDFLAGS="$saved_LDFLAGS -L${SPF2_LIB}"
fi
AC_SEARCH_LIBS(SPF_record_new, spf2)
AC_SEARCH_LIBS(SPF_server_new, spf2)
fi
AM_CONDITIONAL([TEST_SPF], [test x"$with_spf" = x"yes"])
#
# opendmarc
#
AC_ARG_ENABLE([filter],
AS_HELP_STRING([--disable-filter],
[do not compile the opendmarc filter]),
[enable_filter=$enableval],
[enable_filter=yes])
AM_CONDITIONAL([BUILD_FILTER], [test x"$enable_filter" != x"no"])
AC_ARG_ENABLE([live-tests],
AS_HELP_STRING([--enable-live-tests],
[enable live unit tests]),
[enable_live_tests=$enableval],
[enable_live_tests=no])
AM_CONDITIONAL([LIVE_TESTS], [test x"$enable_live_tests" = x"yes"])
AC_ARG_ENABLE([filter-tests],
AS_HELP_STRING([--enable-filter-tests],
[enable Lua-based filter unit tests]),
[enable_filter_tests=$enableval],
[enable_filter_tests=no])
AM_CONDITIONAL([FILTER_TESTS], [test x"$enable_filter_tests" = x"yes"])
if test x"$enable_filter_tests" = x"yes" -a x"$miltertest" != x"yes"
then
AC_MSG_ERROR([miltertest is required for filter tests])
fi
AC_CHECK_HEADERS(math.h, [], [AC_MSG_FAILURE([missing header '$ac_header'])])
AC_SEARCH_LIBS([floor], [m])
AC_CHECK_FUNCS([floor], [], [AC_MSG_FAILURE([missing function '$ac_func'])])
#
# 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="$PTHREAD_LIBS $saved_LIBS"
CPPFLAGS="$LIBMILTER_INCDIRS $saved_CPPFLAGS"
CFLAGS="$PTHREAD_CFLAGS $saved_CFLAGS"
LDFLAGS="$PTHREAD_CFLAGS $saved_LDFLAGS"
breakloop="no"
for d in lib lib/libmilter
do
unset ac_cv_search_smfi_register
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()]))
AC_CHECK_FUNC([smfi_version],
AC_DEFINE([HAVE_SMFI_VERSION], 1,
[Define if libmilter has smfi_version()]))
if test x"$breakloop" = x"yes"
then
break
fi
done
if test x"$LIBMILTER_LIBDIRS" = x""
then
AC_MSG_WARN([libmilter not found])
fi
CC="$saved_CC"
CPPFLAGS="$saved_CPPFLAGS"
CFLAGS="$saved_CFLAGS"
LDFLAGS="$saved_LDFLAGS"
LIBS="$saved_LIBS"
fi
AC_SUBST(LIBMILTER_INCDIRS)
AC_SUBST(LIBMILTER_LIBDIRS)
AC_SUBST(LIBMILTER_LIBS)
#
# Final substitutions
#
CPPFLAGS="$CPPFLAGS -DCONFIG_BASE=\\\"$sysconfdir\\\""
test "x$prefix" = xNONE && prefix=$ac_default_prefix
SYSCONFDIR=`eval echo "$sysconfdir"`
AC_SUBST([SYSCONFDIR])
#
# Generate files
#
AC_CONFIG_FILES([ Makefile
contrib/Makefile
contrib/init/Makefile
contrib/init/generic/Makefile
contrib/init/redhat/Makefile
contrib/init/redhat/opendmarc
contrib/rddmarc/Makefile
contrib/service/Makefile
contrib/service/opendmarc.service
contrib/spec/Makefile
contrib/spec/opendmarc.spec
db/Makefile
libopendmarc/Makefile
libopendmarc/tests/Makefile
libopendmarc/tests/testfiles/Makefile
libopendmarc/docs/Makefile
opendmarc/Makefile
opendmarc/opendmarc.conf.5
opendmarc/opendmarc.8
opendmarc/opendmarc-check.8
opendmarc/tests/Makefile
reports/Makefile
reports/opendmarc-expire
reports/opendmarc-expire.8
reports/opendmarc-import
reports/opendmarc-import.8
reports/opendmarc-importstats.8
reports/opendmarc-params
reports/opendmarc-params.8
reports/opendmarc-reports
reports/opendmarc-reports.8
])
AC_OUTPUT()
# @end1