-
Notifications
You must be signed in to change notification settings - Fork 1
/
configure.ac
345 lines (314 loc) · 11.6 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
# -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.
AC_PREREQ([2.63])
AC_INIT([p0f], [3.03c], [[email protected]])
AC_CONFIG_SRCDIR([readfp.h])
AC_CONFIG_HEADERS([config.h])
AC_CONFIG_MACRO_DIR([m4])
# Must come before AM_INIT_AUTOMAKE.
AC_CONFIG_AUX_DIR([build-aux])
AC_CANONICAL_HOST
AM_INIT_AUTOMAKE([1.11 color-tests -Wall -Werror foreign])
#
AC_COPYRIGHT([Copyright (C) 2012 by Michal Zalewski <[email protected]>])
# Checks for programs.
AC_PROG_CC
gl_EARLY
AC_PROG_INSTALL
AC_PROG_MAKE_SET
# Checks for libraries.
AC_MSG_CHECKING([checking for pcap library])
LIB_SOCKET_NSL
have_pcap=no
AC_PATH_TOOL(PCAP_CONFIG, pcap-config)
AS_IF([test -n "$PCAP_CONFIG"],
[
pcap_cflags=`"$PCAP_CONFIG" --cflags`
pcap_ldflags=`"$PCAP_CONFIG" --libs`
p0f_CFLAGS_ADD([$pcap_cflags], [P0F_CFLAGS])
p0f_LDFLAGS_ADD([$pcap_ldflags], [P0F_LDFLAGS])
AC_CHECK_HEADERS([pcap.h], [],
[])
AC_CHECK_HEADERS([pcap-bpf.h], [],
[])
],
[
###############################################################
# We don't have pcap-config; find out any additional link flags
# we need. (If we have pcap-config, we assume it tells us what
# we need.)
###############################################################
case "$host_os" in
aix*)
############################################################
# If libpcap is DLPI-based, we have to use /lib/pse.exp if
# present, as we use the STREAMS routines.
#
# (XXX - true only if we're linking with a static libpcap?)
############################################################
#
pseexe="/lib/pse.exp"
AC_MSG_CHECKING(for $pseexe)
if test -f $pseexe ; then
AC_MSG_RESULT(yes)
pcap_ldflags="-I:$pseexe"
p0f_LDFLAGS_ADD([$pcap_ldflags], [P0F_LDFLAGS])
fi
#
# If libpcap is BPF-based, we need "-lodm" and "-lcfg", as
# we use them to load the BPF module.
#
# (XXX - true only if we're linking with a static libpcap?)
#
pcap_ldflags="-lodm -lcfg"
p0f_LDFLAGS_ADD([$pcap_ldflags], [P0F_LDFLAGS])
AC_CHECK_HEADERS([pcap.h], [],
[])
AC_CHECK_HEADERS([pcap-bpf.h], [], [])
;;
*)
AC_SEARCH_LIBS([pcap_findalldevs], [pcap],
[have_pcap=yes])
AS_IF([test "x${have_pcap}" = xno],
[ AC_SEARCH_LIBS([pcap_findalldevs], [wpcap],
[have_pcap=yes])
AS_IF([test "x${have_pcap}" = xyes],
[
AC_CHECK_HEADERS([pcap.h], [],
[have_pcap=no])
AC_CHECK_HEADERS([pcap-bpf.h], [],
[have_pcap=no])
AS_IF([test "x${have_pcap}" = xno],
[AC_MSG_ERROR([pcap library don't found])]
)
],
[AC_MSG_ERROR([pcap library don't found])]
)
]
)
;;
esac
]
)
#
# Check for gnulib flock replacement
#
gl_FUNC_FLOCK
if test $HAVE_FLOCK = 0; then
AC_LIBOBJ([flock])
gl_PREREQ_FLOCK
fi
gl_HEADER_SYS_FILE_MODULE_INDICATOR([flock])
# build and distribuite the optional p0f tools
AC_ARG_ENABLE([build-p0f-tools],
[AS_HELP_STRING([--enable-build-p0f-tools],
[build with the auxiliary p0f tools(@<:@default=no@:>@)])],
[case $enableval in
yes|no) ;;
*) AC_MSG_ERROR([bad value $enableval for build-p0f-tools option]) ;;
esac
build_p0f_tools=$enableval],
[build_p0f_tools=no]
)
AM_CONDITIONAL([BUILD_P0F_TOOLS],[test "$build_p0f_tools" = "yes"])
AC_ARG_ENABLE([gcc-debug],
[AS_HELP_STRING([--enable-gcc-debug],
[turn on GCC and p0f debugging options (for developers)@<:@default=no@:>@])],
[case $enableval in
yes|no) ;;
*) AC_MSG_ERROR([bad value $enableval for gcc-debug option]) ;;
esac
p0f_gcc_debug=$enableval],
[p0f_gcc_debug=no]
)
AS_IF([test "x$p0f_gcc_debug" = xyes],
[
p0f_CFLAGS_ADD([-g], [P0F_CFLAGS])
p0f_CFLAGS_ADD([-ggdb], [P0F_CFLAGS])
p0f_CFLAGS_ADD([-DDEBUG_BUILD=1], [P0F_CFLAGS])
])
# Turn gcc warning
AC_ARG_ENABLE([gcc-warnings],
[AS_HELP_STRING([--enable-gcc-warnings],
[turn on GCC warnings (for developers)@<:@default=no@:>@])],
[case $enableval in
yes|no) ;;
*) AC_MSG_ERROR([bad value $enableval for gcc-warnings option]) ;;
esac
p0f_gcc_warnings=$enableval],
[p0f_gcc_warnings=no]
)
AS_IF([test "x$p0f_gcc_warnings" = xyes],
[ # Add/Delete as needed
MAX_STACK_SIZE=32768
p0f_CFLAGS_ADD([-Wall], [P0F_CFLAGS])
p0f_CFLAGS_ADD([-pedantic], [P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wextra], [P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wformat-y2k], [P0F_CFLAGS])
p0f_CFLAGS_ADD([-fdiagnostics-show-option],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-funit-at-a-time],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-fstrict-aliasing],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wstrict-overflow],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-fstrict-overflow],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wpointer-arith],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wundef],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wformat-security],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Winit-self],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wmissing-include-dirs],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wunused],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wunknown-pragmas],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wstrict-aliasing],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wshadow],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wbad-function-cast],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wcast-align],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wwrite-strings],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wlogical-op],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Waggregate-return],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wstrict-prototypes],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wold-style-definition],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wmissing-prototypes],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wmissing-declarations],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wmissing-noreturn],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wmissing-format-attribute],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wredundant-decls],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wnested-externs],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Winline],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Winvalid-pch],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wvolatile-register-var],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wdisabled-optimization],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wbuiltin-macro-redefined],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wmudflap],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wpacked-bitfield-compat],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wsync-nand],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wattributes],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wcoverage-mismatch],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wmultichar],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wcpp],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wdeprecated-declarations],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wdiv-by-zero],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wdouble-promotion],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wendif-labels],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wformat-contains-nul],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wformat-extra-args],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wformat-zero-length],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wformat=2],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wmultichar],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wnormalized=nfc],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Woverflow],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wpointer-to-int-cast],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wpragmas],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wsuggest-attribute=const],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wsuggest-attribute=noreturn],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wsuggest-attribute=pure],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wtrampolines],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wno-missing-field-initializers],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wno-sign-compare],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wjump-misses-init],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wno-format-nonliteral],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wframe-larger-than=$MAX_STACK_SIZE],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-fstack-protector-all],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-fasynchronous-unwind-tables],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-fdiagnostics-show-option],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-funit-at-a-time],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-fipa-pure-const],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wno-aggregate-return],[P0F_CFLAGS])
p0f_CFLAGS_ADD([-Wno-redundant-decls],[P0F_CFLAGS])
])
# build p0f with mudflap instrumentation (GCC only)
p0f_gcc_mudflap=no
AC_ARG_ENABLE([mudflap],
[AS_HELP_STRING([--enable-mudflap],
[build P0F with mudflap instrumentation (@<:@default=no@:>@) (with GCC only) (EXPERIMENTAL)])],
[case $enableval in
yes|no) ;;
*) AC_MSG_ERROR([bad value $enableval for mudflap option]) ;;
esac
p0f_gcc_mudflap=$enableval],
[ p0f_gcc_mudflap=no ])
AS_IF([ test x"$p0f_gcc_mudflap" = x"yes" ],
[
AS_IF([test "x$GCC" != x],
[
old_CFLAGS="$CFLAGS"
CFLAGS="$CFLAGS -fmudflap"
old_LDFLAGS="$LDFLAGS"
LDFLAGS="$LDFLAGS -lmudflap"
AC_LINK_IFELSE([AC_LANG_PROGRAM([[]], [[]])],[p0f_gcc_mudflap=yes],[p0f_gcc_mudflap=fail])
CFLAGS="$old_CFLAGS"
LDFLAGS="$old_LDFLAGS"
AS_IF([ test "$p0f_gcc_mudflap" = fail ],
[
AC_MSG_WARN([--enable-mudflap requires a compiler which understands this option.])
],
[
p0f_CFLAGS_ADD([-fmudflap], [P0F_CFLAGS])
p0f_LDFLAGS_ADD([-lmudflap], [P0F_LDFLAGS])
# XXX: memory leak ?
#MUDFLAP_OPTIONS="-mode-check -abbreviate -viol-abort -check-initialization -print-leaks"
MUDFLAP_OPTIONS="-mode-check -abbreviate -check-initialization"
AC_SUBST([MUDFLAP_OPTIONS])
])
],
[ AC_MSG_WARN([--enable-mudflap requires GCC])]
)
])
# build p0f instrumented for -fPIE (GCC only)
AC_ARG_ENABLE([build-pie],
[AS_HELP_STRING([--enable-build-pie],
[build p0f as Position Independent Executable (PIE) (@<:@default=yes@:>@ with GCC only)])],
[case $enableval in
yes|no) ;;
*) AC_MSG_ERROR([bad value $enableval for build-pie option]) ;;
esac
p0f_gcc_pie=$enableval],
[p0f_gcc_pie=yes]
)
AS_IF([test "x$p0f_gcc_pie" = xyes],
[
AS_IF([test "x$GCC" != x],
[ p0f_CFLAGS_ADD([-fpie], [P0F_CFLAGS])
p0f_LDFLAGS_ADD([-pie], [P0F_LDFLAGS])
],
[ AC_MSG_WARN([--enable-build-pie requires GCC])]
)
])
# build p0f instrumented for extra optimization/security (GCC only)
# general (as in the original build.sh with some enhancement)
# -fno-delete-null-pointer as the kernel does http://patchwork.kernel.org/patch/36060/
# add relro
# GNU GCC (usually "gcc")
AS_IF([test "x$GCC" != x],
[ for c in -fno-delete-null-pointer-checks -D_FORTIFY_SOURCE=2 -fstack-protector -fexceptions -fstack-protector-all -Wno-format
do
p0f_CFLAGS_ADD([$c], [P0F_CFLAGS])
done
p0f_LDFLAGS_ADD([-Wl,-z,relro], [P0F_LDFLAGS])
# add -O3 if not debug
AS_IF([test "x$p0f_gcc_debug" != xyes],
[
p0f_CFLAGS_ADD([-03], [P0F_CFLAGS])
])
])
# Finally put an AC_SUBST for all the CFLAGS and LDFLAGS above
AC_SUBST([POPT_LDFLAGS])
AC_SUBST([P0F_CFLAGS])
# Checks for header files.
AC_CHECK_HEADERS([arpa/inet.h fcntl.h getopt.h limits.h locale.h netdb.h sys/file.h netinet/in.h stdint.h stdlib.h string.h sys/socket.h pcap/bpf.h net/bpf.h sys/time.h unistd.h])
# for gnulib
gl_INIT
# Checks for typedefs, structures, and compiler characteristics.
AC_C_INLINE
AC_TYPE_INT16_T
AC_TYPE_INT32_T
AC_TYPE_INT64_T
AC_TYPE_INT8_T
AC_TYPE_UINT16_T
AC_TYPE_UINT32_T
AC_TYPE_UINT64_T
AC_TYPE_UINT8_T
# Checks for library functions.
AC_CHECK_FUNCS([fork malloc mktime realloc dup2 memmove memset setlocale socket strcasecmp strchr strncasecmp strstr tzset])
AC_CONFIG_FILES([Makefile
tools/Makefile
lib/Makefile])
AC_OUTPUT