1# Copyright (c) 2008-2020, OARC, Inc.
2# Copyright (c) 2007-2008, Internet Systems Consortium, Inc.
3# Copyright (c) 2003-2007, The Measurement Factory, Inc.
4# All rights reserved.
5#
6# Redistribution and use in source and binary forms, with or without
7# modification, are permitted provided that the following conditions
8# are met:
9#
10# 1. Redistributions of source code must retain the above copyright
11#    notice, this list of conditions and the following disclaimer.
12#
13# 2. Redistributions in binary form must reproduce the above copyright
14#    notice, this list of conditions and the following disclaimer in
15#    the documentation and/or other materials provided with the
16#    distribution.
17#
18# 3. Neither the name of the copyright holder nor the names of its
19#    contributors may be used to endorse or promote products derived
20#    from this software without specific prior written permission.
21#
22# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
23# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
24# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
25# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
26# COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
27# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
28# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
29# LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
30# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
31# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
32# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
33# POSSIBILITY OF SUCH DAMAGE.
34
35AC_PREREQ(2.61)
36AC_INIT([DSC], [2.11.1], [dsc@dns-oarc.net], [dsc], [https://github.com/DNS-OARC/dsc/issues])
37AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects])
38AC_CONFIG_SRCDIR([src/md_array.c])
39AC_CONFIG_HEADER([src/config.h])
40
41# Checks for programs.
42AC_PROG_CC
43AM_PROG_CC_C_O
44AC_PROG_INSTALL
45PKG_PROG_PKG_CONFIG
46
47# Check --enable-warn-all
48AC_ARG_ENABLE([warn-all], [AS_HELP_STRING([--enable-warn-all], [Enable all compiler warnings])], [AX_CFLAGS_WARN_ALL()])
49
50# Check --with-extra-cflags
51AC_ARG_WITH([extra-cflags], [AS_HELP_STRING([--with-extra-cflags=CFLAGS], [Add extra CFLAGS])], [
52  AC_MSG_NOTICE([appending extra CFLAGS... $withval])
53  AS_VAR_APPEND(CFLAGS, [" $withval"])
54])
55
56# Check --with-extra-ldflags
57AC_ARG_WITH([extra-ldflags], [AS_HELP_STRING([--with-extra-ldflags=CFLAGS], [Add extra LDFLAGS])], [
58  AC_MSG_NOTICE([appending extra LDFLAGS... $withval])
59  AS_VAR_APPEND(LDFLAGS, [" $withval"])
60])
61
62# pcap thread
63AC_ARG_ENABLE(threads,
64  [AS_HELP_STRING([--enable-threads],
65    [enable the usage of threads (default disabled)])],
66  [AX_PCAP_THREAD],
67  [AX_PCAP_THREAD_PCAP])
68
69# dnstap
70use_dnstap=no
71AC_ARG_ENABLE([dnstap], [AS_HELP_STRING([--enable-dnstap], [DNSTAP input support])], [
72  AC_DEFINE([USE_DNSTAP], [1], [Define to 1 if DNSTAP support is built in.])
73  PKG_CHECK_MODULES([libdnswire], [libdnswire])
74  PKG_CHECK_MODULES([libuv], [libuv])
75  use_dnstap=yes
76])
77AM_CONDITIONAL([USE_DNSTAP], [test x$use_dnstap = xyes])
78
79# Check --enable-gcov
80AC_ARG_ENABLE([gcov], [AS_HELP_STRING([--enable-gcov], [Enable coverage testing])], [
81  coverage_cflags="--coverage -g -O0 -fno-inline -fno-inline-small-functions -fno-default-inline"
82  AC_MSG_NOTICE([enabling coverage testing... $coverage_cflags])
83  AS_VAR_APPEND(CFLAGS, [" $coverage_cflags"])
84])
85AM_CONDITIONAL([ENABLE_GCOV], [test "x$enable_gcov" != "xno"])
86AM_EXTRA_RECURSIVE_TARGETS([gcov])
87
88# Checks for libraries.
89AC_CHECK_LIB([resolv], [inet_aton])
90AC_CHECK_LIB([nsl], [gethostbyname])
91AC_CHECK_LIB([socket], [connect])
92AC_CHECK_LIB([GeoIP], [GeoIP_open])
93PKG_CHECK_MODULES([libmaxminddb], [libmaxminddb], [AC_DEFINE([HAVE_LIBMAXMINDDB], [1], [Define to 1 if you have libmaxminddb.])], [:])
94AC_CHECK_LIB([m], [log10])
95
96# Checks for header files.
97AC_HEADER_STDC
98AC_HEADER_SYS_WAIT
99AC_HEADER_TIME
100AC_CHECK_HEADERS([arpa/nameser_compat.h arpa/inet.h fcntl.h memory.h])
101AC_CHECK_HEADERS([netdb.h netinet/in.h stdint.h stdlib.h string.h])
102AC_CHECK_HEADERS([strings.h sys/mount.h sys/param.h sys/socket.h])
103AC_CHECK_HEADERS([sys/statfs.h sys/statvfs.h sys/time.h syslog.h])
104AC_CHECK_HEADERS([unistd.h netinet/ip_compat.h pcap/sll.h])
105AC_CHECK_HEADERS([GeoIP.h maxminddb.h])
106AC_CHECK_HEADERS([endian.h sys/endian.h machine/endian.h])
107
108# Checks for typedefs, structures, and compiler characteristics.
109AC_C_CONST
110AC_HEADER_STDBOOL
111AC_TYPE_INT8_T
112AC_TYPE_OFF_T
113AC_TYPE_PID_T
114AC_TYPE_SIZE_T
115AC_HEADER_TIME
116AC_STRUCT_TM
117AC_TYPE_UINT16_T
118AC_TYPE_UINT32_T
119AC_TYPE_UINT64_T
120AC_TYPE_UINT8_T
121
122# Checks for library functions.
123AC_FUNC_FORK
124AC_PROG_GCC_TRADITIONAL
125AC_FUNC_MALLOC
126AC_FUNC_MEMCMP
127AC_FUNC_REALLOC
128AC_FUNC_SELECT_ARGTYPES
129AC_FUNC_STAT
130AC_CHECK_FUNCS([dup2 gettimeofday memset regcomp select strcasecmp strchr])
131AC_CHECK_FUNCS([strdup strerror strrchr strspn strstr strtoull statvfs])
132
133# pid file
134AC_ARG_WITH(pid-file,
135  [AS_HELP_STRING([--with-pid-file=FILE], [write pid to FILE [/run/dsc.pid]])],
136  [],
137  [with_pid_file=/run/dsc.pid])
138
139AC_SUBST([DSC_PID_FILE], [$with_pid_file])
140
141# data dir
142AC_ARG_WITH(data-dir,
143  [AS_HELP_STRING([--with-data-dir=DIR], [use DIR for DSC data [LOCALSTATEDIR/lib/dsc]])],
144  [],
145  [with_data_dir=${localstatedir}/lib/dsc])
146
147AC_SUBST([DSC_DATA_DIR], [$with_data_dir])
148
149# Generate
150AC_CONFIG_FILES([
151  Makefile
152  src/Makefile
153  src/test/Makefile
154  cron/Makefile
155])
156AC_OUTPUT
157