forked from snort3/snort3
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure_cmake.sh
executable file
·400 lines (381 loc) · 14.2 KB
/
configure_cmake.sh
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
#!/bin/sh
# Convenience wrapper for easily viewing/setting options that
# the project's CMake scripts will recognize
set -e
command="$0 $*"
# check for `cmake` command
type cmake > /dev/null 2>&1 || {
echo "\
This package requires CMake, please install it first, then you may
use this configure script to access CMake equivalent functionality.\
" >&2;
exit 1;
}
usage="\
Usage: $0 [OPTION]... [VAR=VALUE]...
--builddir= The build directory
--generator= run cmake --help for a list of generators
--prefix= Snort++ installation prefix
Optional Features:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--disable-static-ips-actions do not include ips actions in binary
--disable-static-inspectors do not include inspectors in binary
--disable-static-loggers do not include loggers in binary
--disable-static-ips-options do not include ips options in binary
--disable-static-search-engines do not include search engines in binary
--disable-static-codecs do not include codecs in binary
--enable-valgrind Only use if you are testing with valgrind.
--enable-ppm Enable packet/rule performance monitor
--enable-ppm-test Enable packet/rule performance monitor for readback
--enable-perfprofiling Enable preprocessor and rule performance profiling
--enable-linux-smp-stats Enable statistics reporting through proc
--enable-debug-msgs Enable debug printing options (bugreports and developers only)
--enable-debug Enable debugging options (bugreports and developers only)
--enable-gdb Enable gdb debugging information
--enable-profile Enable profiling options (developers only)
--disable-corefiles Prevent Snort from generating core files
--enable-intel-soft-cpm Enable Intel Soft CPM support
--enable-unit-tests Build unit tests
--enable-large-pcap Enable support for pcaps larger than 2 GB
--disable-static-daq Link static DAQ modules.
--enable-shell enable command line shell support
Optional Packages:
--with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
--without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
--with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use
both]
--with-gnu-ld assume the C compiler uses GNU ld [default=no]
--with-sysroot=DIR Search for dependent libraries within DIR
(or the compiler's sysroot if not specified).
--with-pcap-includes=DIR libpcap include directory
--with-pcap-libraries=DIR libpcap library directory
--with-luajit-includes=DIR luajit include directory
--with-luajit-libraries=DIR luajit library directory
--with-pcre-includes=DIR libpcre include directory
--with-pcre-libraries=DIR libpcre library directory
--with-openssl-includes=DIR openssl include directory
--with-openssl-library=LIB openssl library library - NOT THE DIRECTORY
--with-crypto-library=LIB openssl crypto library - NOT THE DIRECTORY
--with-dnet-includes=DIR libdnet include directory
--with-dnet-libraries=DIR libdnet library directory
--with-daq-includes=DIR DAQ include directory
--with-daq-libraries=DIR DAQ library directory
SIGNAL_SNORT_RELOAD=<value>
set the SIGNAL_SNORT_RELOAD value
SIGNAL_SNORT_DUMP_STATS<value>
set the SIGNAL_SNORT_DUMP_STATS value
SIGNAL_SNORT_ROTATE_STATS<value>
set the SIGNAL_SNORT_ROTATE_STATS value
SIGNAL_SNORT_READ_ATTR_TBL<value>
set the SIGNAL_SNORT_READ_ATTR_TBL value
"
sourcedir="$( cd "$( dirname "$0" )" && pwd )"
# Function to append a CMake cache entry definition to the
# CMakeCacheEntries variable
# $1 is the cache entry variable name
# $2 is the cache entry variable type
# $3 is the cache entry variable value
append_cache_entry () {
CMakeCacheEntries="$CMakeCacheEntries -D $1:$2=$3"
}
check_and_append_cache_entry() {
if [ -f $3 ]; then
append_cache_entry $1 $2 $3
else
echo ""
echo "the $1 variable, which is specified using a --with-* options,"
echo "requires an absolute path to the library. Could not stat the"
echo "the library:"
echo " $3"
echo ""
exit 1
fi
}
# set defaults
builddir=build
prefix=/usr/local/snort
CMakeCacheEntries=""
append_cache_entry CMAKE_INSTALL_PREFIX PATH $prefix
# parse arguments
while [ $# -ne 0 ]; do
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case "$1" in
--help|-h)
echo "${usage}" 1>&2
exit 1
;;
--builddir=*)
builddir=$optarg
;;
--generator=*)
CMakeGenerator="$optarg"
;;
--prefix=*)
prefix=$optarg
append_cache_entry CMAKE_INSTALL_PREFIX PATH $optarg
;;
--disable-static-codecs)
append_cache_entry STATIC_CODECS BOOL false
;;
--enable-static-codecs)
append_cache_entry STATIC_CODECS BOOL true
;;
--disable-static-inspectors)
append_cache_entry STATIC_INSPECTORS BOOL false
;;
--enable-static-inspectors)
append_cache_entry STATIC_INSPECTORS BOOL true
;;
--disable-static-loggers)
append_cache_entry STATIC_LOGGERS BOOL false
;;
--enable-static-loggers)
append_cache_entry STATIC_LOGGERS BOOL true
;;
--disable-static-ips-options)
append_cache_entry STATIC_IPS_OPTIONS BOOL false
;;
--enable-static-ips-actions)
append_cache_entry STATIC_IPS_ACTIONS BOOL true
;;
--disable-static-ips-actions)
append_cache_entry STATIC_IPS_ACTIONS BOOL false
;;
--enable-static-ips-options)
append_cache_entry STATIC_IPS_OPTIONS BOOL true
;;
--disable-static-search-engines)
append_cache_entry STATIC_SEARCH_ENGINES BOOL false
;;
--enable-static-search-engines)
append_cache_entry STATIC_SEARCH_ENGINES BOOL true
;;
--disable-control-socket)
append_cache_entry BUILD_CONTROL_SOCKET BOOL false
;;
--enable-control-socket)
append_cache_entry BUILD_CONTROL_SOCKET BOOL true
;;
--disable-side-channel)
append_cache_entry BUILD_SIDE_CHANNEL BOOL false
;;
--enable-side-channel)
append_cache_entry BUILD_SIDE_CHANNEL BOOL true
;;
--disable-static-daq)
append_cache_entry ENABLE_STATIC_DAQ BOOL false
;;
--enable-static-daq)
append_cache_entry ENABLE_STATIC_DAQ BOOL true
;;
--disable-valgrind)
append_cache_entry ENABLE_VALGRIND BOOL false
;;
--enable-valgrind)
append_cache_entry ENABLE_VALGRIND BOOL true
;;
--disable-ppm)
append_cache_entry ENABLE_PPM BOOL false
;;
--enable-ppm)
append_cache_entry ENABLE_PPM BOOL true
;;
--disable-ppm-test)
append_cache_entry ENABLE_PPM_TEST BOOL false
;;
--enable-ppm-test)
append_cache_entry ENABLE_PPM_TEST BOOL true
;;
--disable-perfprofiling)
append_cache_entry ENABLE_PERFPROFILING BOOL false
;;
--enable-perfprofiling)
append_cache_entry ENABLE_PERFPROFILING BOOL true
;;
--disable-linux-smp-stats)
append_cache_entry ENABLE_LINUX_SMP_STATS BOOL false
;;
--enable-linux-smp-stats)
append_cache_entry ENABLE_LINUX_SMP_STATS BOOL true
;;
--disable-pthread)
append_cache_entry ENABLE_PTHREAD BOOL false
;;
--enable-pthread)
append_cache_entry ENABLE_PTHREAD BOOL true
;;
--disable-debug-msgs)
append_cache_entry ENABLE_DEBUG_MSGS BOOL false
;;
--enable-debug-msgs)
append_cache_entry ENABLE_DEBUG_MSGS BOOL true
;;
--disable-gdb)
append_cache_entry ENABLE_GDB BOOL false
;;
--enable-gdb)
append_cache_entry ENABLE_GDB BOOL true
;;
--disable-profile)
append_cache_entry ENABLE_PROFILE BOOL false
;;
--enable-profile)
append_cache_entry ENABLE_PROFILE BOOL true
;;
--disable-debug)
append_cache_entry ENABLE_DEBUG BOOL false
;;
--enable-debug)
append_cache_entry ENABLE_DEBUG BOOL true
;;
--disable-ha)
append_cache_entry BUILD_HA BOOL false
;;
--enable-ha)
append_cache_entry BUILD_HA BOOL true
;;
--disable-corefiles)
append_cache_entry ENABLE_COREFILES BOOL false
;;
--enable-corefiles)
append_cache_entry ENABLE_COREFILES BOOL true
;;
--disable-large-pcap)
append_cache_entry ENABLE_LARGE_PCAP BOOL false
;;
--enable-large-pcap)
append_cache_entry ENABLE_LARGE_PCAP BOOL true
;;
--disable-intel-soft-cpm)
append_cache_entry ENABLE_INTEL_SOFT_CPM BOOL false
;;
--enable-intel-soft-cpm)
append_cache_entry ENABLE_INTEL_SOFT_CPM BOOL true
;;
--enable-shell)
append_cache_entry ENABLE_SHELL BOOL true
;;
--disable-shell)
append_cache_entry ENABLE_SHELL BOOL false
;;
--disable-side-channel)
append_cache_entry BUILD_SIDE_CHANNEL BOOL false
;;
--enable-side-channel)
append_cache_entry BUILD_SIDE_CHANNEL BOOL true
;;
--disable-unit-tests)
append_cache_entry BUILD_UNIT_TESTS BOOL false
;;
--enable-unit-tests)
append_cache_entry BUILD_UNIT_TESTS BOOL true
;;
--disable-html-docs)
append_cache_entry MAKE_HTML_DOC BOOL false
;;
--enable-html-docs)
append_cache_entry MAKE_HTML_DOC BOOL true
;;
--disable-pdf-docs)
append_cache_entry MAKE_PDF_DOC BOOL false
;;
--enable-pdf-docs)
append_cache_entry MAKE_PDF_DOC BOOL true
;;
--with-openssl-includes=*)
append_cache_entry OPENSSL_INCLUDE_DIR PATH $optarg
;;
--with-openssl-library=*)
check_and_append_cache_entry OPENSSL_SSL_LIBRARY FILEPATH $optarg
;;
--with-crypto-library=*)
check_and_append_cache_entry OPENSSL_CRYPTO_LIBRARY FILEPATH $optarg
;;
--with-pcap-includes=*)
append_cache_entry PCAP_INCLUDE_DIR PATH $optarg
;;
--with-pcap-libraries=*)
append_cache_entry PCAP_LIBRARIES_DIR PATH $optarg
;;
--with-luajit-includes=*)
append_cache_entry LUAJIT_INCLUDE_DIR PATH $optarg
;;
--with-luajit-libraries=*)
append_cache_entry LUAJIT_LIBRARIES_DIR PATH $optarg
;;
--with-pcre-includes=*)
append_cache_entry PCRE_INCLUDE_DIR PATH $optarg
;;
--with-pcre-libraries=*)
append_cache_entry PCRE_LIBRARIES_DIR PATH $optarg
;;
--with-dnet-includes=*)
append_cache_entry DNET_INCLUDE_DIR PATH $optarg
;;
--with-dnet-libraries=*)
append_cache_entry DNET_LIBRARIES_DIR PATH $optarg
;;
--with-daq-includes=*)
append_cache_entry DAQ_INCLUDE_DIR PATH $optarg
;;
--with-daq-libraries=*)
append_cache_entry DAQ_LIBRARIES_DIR PATH $optarg
;;
# Currently unsupported
# --with-intel-soft-cpm-includes=*)
# append_cache_entry INTEL_SOFT_CPM_INCLUDE_DIR PATH $optarg
# ;;
# --with-intel-soft-cpm-libraries=*)
# append_cache_entry INTEL_SOFT_CPM_LIBRARIES_DIR PATH $optarg
# ;;
--with-flex=*)
append_cache_entry FLEX_EXECUTABLE PATH $optarg
;;
--with-bison=*)
append_cache_entry BISON_EXECUTABLE PATH $optarg
;;
SIGNAL_SNORT_RELOAD=*)
append_cache_entry SIGNAL_SNORT_RELOAD STRING $optarg
;;
SIGNAL_SNORT_DUMP_STATS=*)
append_cache_entry SIGNAL_SNORT_DUMP_STATS STRING $optarg
;;
SIGNAL_SNORT_ROTATE_STATS=*)
append_cache_entry SIGNAL_SNORT_ROTATE_STATS STRING $optarg
;;
SIGNAL_SNORT_READ_ATTR_TBL=*)
append_cache_entry SIGNAL_SNORT_READ_ATTR_TBL STRING $optarg
;;
*)
echo "Invalid option '$1'. Try $0 --help to see available options."
exit 1
;;
esac
shift
done
if [ -d $builddir ]; then
# If build directory exists, check if it has a CMake cache
if [ -f $builddir/CMakeCache.txt ]; then
# If the CMake cache exists, delete it so that this configuration
# is not tainted by a previous one
rm -f $builddir/CMakeCache.txt
fi
else
# Create build directory
mkdir -p $builddir
fi
echo "Build Directory : $builddir"
echo "Source Directory: $sourcedir"
cd $builddir
if [ -n "$CMakeGenerator" ]; then
cmake -G "$CMakeGenerator" $CMakeCacheEntries $sourcedir
else
cmake $CMakeCacheEntries $sourcedir
fi
echo "# This is the command used to configure this build" > config.status
echo $command >> config.status
chmod u+x config.status