-
Notifications
You must be signed in to change notification settings - Fork 17
/
configure.ac
268 lines (239 loc) · 8.16 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
dnl Copyright 2011 Nick Mathewson, George Kadianakis
dnl Copyright 2011, 2012 SRI International
dnl See LICENSE for other credits and copying information
dnl
AC_PREREQ([2.61])dnl Possibly earlier will do, but this is what I have
AC_INIT([stegotorus], [0.0])
AC_CONFIG_SRCDIR([src/main.cc])
AC_CONFIG_AUX_DIR([config-aux])
AC_LANG([C++])
AM_INIT_AUTOMAKE([foreign nostdinc silent-rules subdir-objects])
dnl this makes for cross compilation joy.
AC_CANONICAL_BUILD
AM_MAINTAINER_MODE([enable])
AC_ARG_WITH(stegtracesdir,
[AS_HELP_STRING([--with-stegtracesdir],[Location of Stegotorus Traces @<:@default=./traces/@:>@])],
[],
with_stegtracesdir=./traces/)
AC_MSG_RESULT($with_stegtracesdir)
steg_traces_dir=-DSTEG_TRACES_DIR=\\\"$with_stegtracesdir\\\"
dnl This script deliberately does not check for a bunch of things
dnl that 'autoscan' thinks we ought to check for. Here is the list,
dnl with a rationale for each:
dnl
dnl Defined by C89, therefore unnecessary to check for nowadays:
dnl
dnl AC_CHECK_FUNCS([memset strcasecmp strchr strerror strrchr strstr strtoul])
dnl AC_CHECK_HEADERS([limits.h stddef.h stdlib.h string.h])
dnl AC_CHECK_TYPES([ptrdiff_t])
dnl AC_TYPE_SIZE_T
dnl
dnl Dealt with by our 'xmalloc' and 'xrealloc' wrappers:
dnl
dnl AC_FUNC_MALLOC
dnl AC_FUNC_REALLOC
dnl
dnl Defined by C++ since cfront, therefore unnecessary to check for
dnl in a C++ program:
dnl
dnl AC_C_INLINE
dnl AC_HEADER_STDBOOL # 'bool', 'true', and 'false', not the header
dnl
dnl Defined by Unix98, therefore adequately handled by #ifdef _WIN32
dnl (FIXME: Windows has not been tested in some time and is likely to
dnl be broken):
dnl
dnl AC_CHECK_HEADERS([fcntl.h unistd.h arpa/inet.h netinet/in.h
dnl sys/types.h sys/stat.h sys/un.h sys/wait.h])
dnl AC_CHECK_FUNCS([gettimeofday])
dnl AC_FUNC_FORK
dnl AC_TYPE_PID_T
dnl
dnl libevent handles for us (FIXME: we probably shouldn't rely on this):
dnl
dnl AC_CHECK_HEADERS([stdint.h])
dnl AC_CHECK_FUNCS([socket])
dnl AC_TYPE_SSIZE_T
dnl AC_TYPE_UINT8_T
dnl AC_TYPE_UINT16_T
dnl AC_TYPE_UINT32_T
dnl AC_TYPE_UINT64_T
dnl
dnl The fallback is inappropriate for our use case (it would copy
dnl several enormous files), it is only required for 'make check'
dnl in an out-of-tree build, and it's slated to go away RSN anyway:
dnl
dnl AC_PROG_LN_S
### Compiler and language features ###
AC_PROG_CC
AC_PROG_CXX
AC_PROG_CXXCPP
# Make a conditional for whether we're on Windows or not, so we can
# select the right version of certain files.
AC_CACHE_CHECK([for Windows], ac_cv_system_windows,
[AC_PREPROC_IFELSE([AC_LANG_SOURCE([[
/* _WIN32 is defined for both Win32 and Win64 */
#ifndef _WIN32
#error "this is not Windows"
#endif
]])],
[ac_cv_system_windows=yes],
[ac_cv_system_windows=no])])
AM_CONDITIONAL(WINDOWS, test $ac_cv_system_windows = yes)
AX_SYS_EXTENSIONS
AC_SYS_LARGEFILE
AX_CXXFLAGS_STDCXX_11([ext])
AX_CXX_DELETE_METHOD
AX_CXX_STATIC_ASSERT
### Programs ###
AX_PROG_RANLIB
PKG_PROG_PKG_CONFIG
# We need python 2.7 for TestLoader.discover().
# The unit tests presently only work on POSIX systems,
# and are flaky enough that we let them be configured off.
AC_ARG_ENABLE(integration-tests,
[AS_HELP_STRING([--disable-integration-tests],
[Disable tests of the complete program])],
[], [enable_integration_tests=yes])
if test x$enable_integration_tests != xyes; then
AC_MSG_WARN([Integration tests disabled by configure option.])
PYOS=none
else
AM_PATH_PYTHON([2.7],, [:])
if test "$PYTHON" = ":"; then
AC_MSG_WARN([Python interpreter not found; integration tests disabled.])
PYOS=none
else
PYOS=`$PYTHON -c 'import os; print os.name'`
if test "$PYOS" != "posix"; then
AC_MSG_WARN([Not a POSIX platform; integration tests disabled.])
fi
fi
fi
AM_CONDITIONAL([INTEGRATION_TESTS], [test "$PYOS" = "posix"])
### Libraries ###
# Presently no need for libssl, only libcrypto.
# We require version 1.0.1 for GCM support.
PKG_CHECK_MODULES([libcrypto], [libcrypto >= 1.0.1])
# libevent 2.0 radically changed the API
PKG_CHECK_MODULES([libevent], [libevent >= 2.0])
# 2.2 seems as good a place as any to start (there are ubuntu packages for this)
PKG_CHECK_MODULES([libjansson], [jansson >= 2.2])
# there's no good reason not to require the latest zlib, which is
# from 2009
PKG_CHECK_MODULES([libz], [zlib >= 1.2.3.4])
#
PKG_CHECK_MODULES([libjel], [jel >= 1.0])
#
# ntohl and a bunch of related functions require a special library on Windows.
# It is possible that libevent or libcrypto has hooked us up already.
# This can't be done with AC_SEARCH_LIBS -- see m4/winsock.m4 for gory details.
AX_LIB_WINSOCK2
# We might need to explicitly link -lm for floor().
AC_SEARCH_LIBS([floor], [m], [], [
AC_MSG_ERROR([unable to find 'floor'])
])
LIBS="$libevent_LIBS $libcrypto_LIBS $libz_LIBS $libjansson_LIBS $libjel_LIBS"
LIBS="$LIBS $ws32_LIBS"
LIBS="$LIBS $ac_cv_env_LIBS_value"
lib_LIBS="$LIBS"
lib_CPPFLAGS="$libjel_CFLAGS $libevent_CFLAGS $libcrypto_CFLAGS $libz_CFLAGS $libjansson_CFLAGS $steg_traces_dir"
LIBS=
AC_SUBST(lib_LIBS)
AC_SUBST(lib_CPPFLAGS)
# pgen_pcap needs libpcap.
pcap_LIBS=
HAVE_PCAP=no
AC_SEARCH_LIBS([pcap_open_offline], [pcap],
[AC_CACHE_CHECK([whether libpcap is usable], ac_cv_libpcap_usable,
[AC_LINK_IFELSE([AC_LANG_PROGRAM(
[[#include <pcap/pcap.h>]],
[[char f;
pcap_t *p = pcap_open_offline("",&f);]])],
[ac_cv_libpcap_usable=yes], [ac_cv_libpcap_usable=no])])
if test $ac_cv_libpcap_usable = yes; then
HAVE_PCAP=yes
pcap_LIBS="$LIBS"
fi],
[])
LIBS=
AC_SUBST(pcap_LIBS)
AM_CONDITIONAL(HAVE_PCAP, test $HAVE_PCAP = yes)
### System features ###
AC_CHECK_HEADERS([execinfo.h paths.h],,,[/**/])
AC_CHECK_FUNCS([closefrom execvpe strcasestr])
### TR1 detection as per http://gcc.gnu.org/onlinedocs/libstdc++/manual/backwards.html
# AC_HEADER_TR1_UNORDERED_MAP
AC_DEFUN([AC_HEADER_TR1_UNORDERED_MAP], [
AC_CACHE_CHECK(for tr1/unordered_map,
ac_cv_cxx_tr1_unordered_map,
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE([#include <tr1/unordered_map>], [using std::tr1::unordered_map;],
ac_cv_cxx_tr1_unordered_map=yes, ac_cv_cxx_tr1_unordered_map=no)
AC_LANG_RESTORE
])
if test "$ac_cv_cxx_tr1_unordered_map" = yes; then
AC_DEFINE(HAVE_TR1_UNORDERED_MAP,,[Define if tr1/unordered_map is present. ])
fi
])
# AC_HEADER_TR1_UNORDERED_SET
AC_DEFUN([AC_HEADER_TR1_UNORDERED_SET], [
AC_CACHE_CHECK(for tr1/unordered_set,
ac_cv_cxx_tr1_unordered_set,
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE([#include <tr1/unordered_set>], [using std::tr1::unordered_set;],
ac_cv_cxx_tr1_unordered_set=yes, ac_cv_cxx_tr1_unordered_set=no)
AC_LANG_RESTORE
])
if test "$ac_cv_cxx_tr1_unordered_set" = yes; then
AC_DEFINE(HAVE_TR1_UNORDERED_SET,,[Define if tr1/unordered_set is present. ])
fi
])
AC_HEADER_TR1_UNORDERED_MAP
AC_HEADER_TR1_UNORDERED_SET
# AC_HEADER_UNORDERED_MAP
AC_DEFUN([AC_HEADER_UNORDERED_MAP], [
AC_CACHE_CHECK(for unordered_map,
ac_cv_cxx_unordered_map,
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE([#include <unordered_map>], [using std::unordered_map;],
ac_cv_cxx_unordered_map=yes, ac_cv_cxx_unordered_map=no)
AC_LANG_RESTORE
])
if test "$ac_cv_cxx_unordered_map" = yes; then
AC_DEFINE(HAVE_UNORDERED_MAP,,[Define if unordered_map is present. ])
fi
])
# AC_HEADER_UNORDERED_SET
AC_DEFUN([AC_HEADER_UNORDERED_SET], [
AC_CACHE_CHECK(for unordered_set,
ac_cv_cxx_unordered_set,
[AC_LANG_SAVE
AC_LANG_CPLUSPLUS
AC_TRY_COMPILE([#include <unordered_set>], [using std::unordered_set;],
ac_cv_cxx_unordered_set=yes, ac_cv_cxx_unordered_set=no)
AC_LANG_RESTORE
])
if test "$ac_cv_cxx_unordered_set" = yes; then
AC_DEFINE(HAVE_UNORDERED_SET,,[Define if unordered_set is present. ])
fi
])
AC_HEADER_UNORDERED_MAP
AC_HEADER_UNORDERED_SET
if test "$ac_cv_cxx_tr1_unordered_set" = yes; then
AC_MSG_NOTICE([Using TR1 unordered_set/map])
else
if test "$ac_cv_cxx_unordered_set" = yes; then
AC_MSG_NOTICE([Using C99 unordered_set/map])
else
AC_MSG_ERROR([Neither TR1 or C99 unordered_set/map has been found])
fi
fi
### Output ###
AC_CONFIG_FILES([Makefile])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_COMMANDS_PRE([DEFS=])dnl Suppress pointless -DHAVE_CONFIG_H.
AC_OUTPUT