]> git.ipfire.org Git - thirdparty/snort3.git/blob - configure_cmake.sh
Merge pull request #1424 in SNORT/snort3 from ~CWAXMAN/snort3:cmake_generator to...
[thirdparty/snort3.git] / configure_cmake.sh
1 #!/bin/sh
2 # Convenience wrapper for easily viewing/setting options that
3 # the project's CMake scripts will recognize
4
5 set -e
6 command="$0 $*"
7
8 # check for `cmake` command
9 type cmake > /dev/null 2>&1 || {
10 echo "\
11 This package requires CMake, please install it first, then you may
12 use this configure script to access CMake equivalent functionality.\
13 " >&2;
14 exit 1;
15 }
16
17 usage="\
18 Usage: $0 [OPTION]... [VAR=VALUE]...
19
20 --builddir= The build directory
21 --generator= run cmake --help for a list of generators
22 --prefix= Snort++ installation prefix
23
24 Optional Features:
25 --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
26 --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
27 --enable-code-coverage Whether to enable code coverage support
28 --enable-hardened-build Detect and use compile-time hardening options
29 --enable-pie Attempt to produce a position-independent executable
30 --disable-safec do not use libsafec bounds checking even if available
31 --disable-static-ips-actions
32 do not include ips actions in binary
33 --disable-static-inspectors
34 do not include inspectors in binary
35 --disable-static-loggers
36 do not include loggers in binary
37 --disable-static-ips-options
38 do not include ips options in binary
39 --disable-static-search-engines
40 do not include search engines in binary
41 --disable-static-codecs do not include codecs in binary
42 --enable-shell enable command line shell support
43 --enable-large-pcap enable support for pcaps larger than 2 GB
44 --enable-stdlog use file descriptor 3 instead of stdout for alerts
45 --enable-tsc-clock use timestamp counter register clock (x86 only)
46 --enable-debug-msgs enable debug printing options (bugreports and
47 developers only)
48 --enable-debug enable debugging options (bugreports and developers
49 only)
50 --disable-gdb disable gdb debugging information
51 --enable-gprof-profile enable gprof profiling options (developers only)
52 --disable-snort-profiler
53 disable snort performance profiling (cpu and memory) (developers only)
54 --enable-deep-profiling
55 enabled detailed snort performance profiling (developers only)
56 --disable-memory-manager
57 disable snort memory manager (developers only)
58 --disable-corefiles prevent Snort from generating core files
59 --enable-address-sanitizer
60 enable address sanitizer support
61 --enable-thread-sanitizer
62 enable thread sanitizer support
63 --enable-ub-sanitizer
64 enable undefined behavior sanitizer support
65 --enable-tcmalloc
66 enable using tcmalloc for dynamic memory management
67 --enable-appid-third-party
68 enable third party appid
69 --enable-unit-tests build unit tests
70 --enable-piglet build piglet test harness
71 --disable-static-daq link static DAQ modules
72 --disable-html-docs don't create the HTML documentation
73 --disable-pdf-docs don't create the PDF documentation
74 --disable-text-docs don't create the TEXT documentation
75 --disable-docs don't create documentation
76
77 Optional Packages:
78 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
79 --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
80 --with-pcap-includes=DIR
81 libpcap include directory
82 --with-pcap-libraries=DIR
83 libpcap library directory
84 --with-luajit-includes=DIR
85 luajit include directory
86 --with-luajit-libraries=DIR
87 luajit library directory
88 --with-pcre-includes=DIR
89 libpcre include directory
90 --with-pcre-libraries=DIR
91 libpcre library directory
92 --with-dnet-includes=DIR
93 libdnet include directory
94 --with-dnet-libraries=DIR
95 libdnet library directory
96 --with-daq-includes=DIR DAQ include directory
97 --with-daq-libraries=DIR
98 DAQ library directory
99 --with-openssl=DIR openssl installation root directory
100 --with-hyperscan-includes=DIR
101 libhs include directory
102 --with-hyperscan-libraries=DIR
103 libhs library directory
104 --with-flatbuffers-includes=DIR
105 flatbuffers include directory
106 --with-flatbuffers-libraries=DIR
107 flatbuffers library directory
108 --with-uuid-includes=DIR
109 libuuid include directory
110 --with-uuid-libraries=DIR
111 libuuid library directory
112
113 Some influential environment variables:
114 SIGNAL_SNORT_RELOAD=<value>
115 set the SIGNAL_SNORT_RELOAD value
116 SIGNAL_SNORT_DUMP_STATS<value>
117 set the SIGNAL_SNORT_DUMP_STATS value
118 SIGNAL_SNORT_ROTATE_STATS<value>
119 set the SIGNAL_SNORT_ROTATE_STATS value
120 SIGNAL_SNORT_READ_ATTR_TBL<value>
121 set the SIGNAL_SNORT_READ_ATTR_TBL value
122 "
123
124 sourcedir="$( cd "$( dirname "$0" )" && pwd )"
125
126 # Function to append a CMake cache entry definition to the
127 # CMakeCacheEntries variable
128 # $1 is the cache entry variable name
129 # $2 is the cache entry variable type
130 # $3 is the cache entry variable value
131 append_cache_entry () {
132 CMakeCacheEntries="$CMakeCacheEntries -D $1:$2=$3"
133 }
134
135 # set defaults
136 builddir=build
137 prefix=/usr/local/snort
138 CMakeCacheEntries=""
139 append_cache_entry CMAKE_INSTALL_PREFIX PATH $prefix
140
141
142 # parse arguments
143 while [ $# -ne 0 ]; do
144 case "$1" in
145 -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
146 *) optarg= ;;
147 esac
148
149 case "$1" in
150 --help|-h)
151 echo "${usage}" 1>&2
152 exit 1
153 ;;
154 --builddir=*)
155 builddir=$optarg
156 ;;
157 --define=*)
158 CMakeCacheEntries="$CMakeCacheEntries -D$optarg"
159 ;;
160 --generator=*)
161 CMakeGenerator="$optarg"
162 ;;
163 --prefix=*)
164 prefix=$optarg
165 append_cache_entry CMAKE_INSTALL_PREFIX PATH $optarg
166 ;;
167 --enable-code-coverage)
168 append_cache_entry ENABLE_CODE_COVERAGE BOOL true
169 ;;
170 --disable-code-coverage)
171 append_cache_entry ENABLE_CODE_COVERAGE BOOL false
172 ;;
173 --enable-hardened-build)
174 append_cache_entry ENABLE_HARDENED_BUILD BOOL true
175 ;;
176 --disable-hardened-build)
177 append_cache_entry ENABLE_HARDENED_BUILD BOOL false
178 ;;
179 --enable-pie)
180 append_cache_entry ENABLE_PIE BOOL true
181 ;;
182 --disable-pie)
183 append_cache_entry ENABLE_PIE BOOL false
184 ;;
185 --disable-safec)
186 append_cache_entry ENABLE_SAFEC BOOL false
187 ;;
188 --enable-safec)
189 append_cache_entry ENABLE_SAFEC BOOL true
190 ;;
191 --disable-static-ips-actions)
192 append_cache_entry STATIC_IPS_ACTIONS BOOL false
193 ;;
194 --enable-static-ips-actions)
195 append_cache_entry STATIC_IPS_ACTIONS BOOL true
196 ;;
197 --disable-static-inspectors)
198 append_cache_entry STATIC_INSPECTORS BOOL false
199 ;;
200 --enable-static-inspectors)
201 append_cache_entry STATIC_INSPECTORS BOOL true
202 ;;
203 --disable-static-loggers)
204 append_cache_entry STATIC_LOGGERS BOOL false
205 ;;
206 --enable-static-loggers)
207 append_cache_entry STATIC_LOGGERS BOOL true
208 ;;
209 --disable-static-ips-options)
210 append_cache_entry STATIC_IPS_OPTIONS BOOL false
211 ;;
212 --enable-static-ips-options)
213 append_cache_entry STATIC_IPS_OPTIONS BOOL true
214 ;;
215 --disable-static-search-engines)
216 append_cache_entry STATIC_SEARCH_ENGINES BOOL false
217 ;;
218 --enable-static-search-engines)
219 append_cache_entry STATIC_SEARCH_ENGINES BOOL true
220 ;;
221 --disable-static-codecs)
222 append_cache_entry STATIC_CODECS BOOL false
223 ;;
224 --enable-static-codecs)
225 append_cache_entry STATIC_CODECS BOOL true
226 ;;
227 --enable-shell)
228 append_cache_entry ENABLE_SHELL BOOL true
229 ;;
230 --disable-shell)
231 append_cache_entry ENABLE_SHELL BOOL false
232 ;;
233 --enable-large-pcap)
234 append_cache_entry ENABLE_LARGE_PCAP BOOL true
235 ;;
236 --enable-stdlog)
237 append_cache_entry ENABLE_STDLOG BOOL true
238 ;;
239 --enable-tsc-clock)
240 append_cache_entry ENABLE_TSC_CLOCK BOOL true
241 ;;
242 --disable-snort-profiler)
243 append_cache_entry DISABLE_SNORT_PROFILER BOOL true
244 ;;
245 --enable-deep-profiling)
246 append_cache_entry ENABLE_DEEP_PROFILING BOOL true
247 ;;
248 --disable-memory-manager)
249 append_cache_entry DISABLE_MEMORY_MANAGER BOOL true
250 ;;
251 --disable-large-pcap)
252 append_cache_entry ENABLE_LARGE_PCAP BOOL false
253 ;;
254 --enable-debug-msgs)
255 append_cache_entry ENABLE_DEBUG_MSGS BOOL true
256 ;;
257 --disable-debug-msgs)
258 append_cache_entry ENABLE_DEBUG_MSGS BOOL false
259 ;;
260 --enable-debug)
261 append_cache_entry ENABLE_DEBUG BOOL true
262 ;;
263 --disable-debug)
264 append_cache_entry ENABLE_DEBUG BOOL false
265 ;;
266 --enable-gdb)
267 append_cache_entry ENABLE_GDB BOOL true
268 ;;
269 --disable-gdb)
270 append_cache_entry ENABLE_GDB BOOL false
271 ;;
272 --enable-gprof-profile)
273 append_cache_entry ENABLE_PROFILE BOOL true
274 ;;
275 --disable-gprof-profile)
276 append_cache_entry ENABLE_PROFILE BOOL false
277 ;;
278 --disable-corefiles)
279 append_cache_entry ENABLE_COREFILES BOOL false
280 ;;
281 --enable-corefiles)
282 append_cache_entry ENABLE_COREFILES BOOL true
283 ;;
284 --enable-address-sanitizer)
285 append_cache_entry ENABLE_ADDRESS_SANITIZER BOOL true
286 ;;
287 --disable-address-sanitizer)
288 append_cache_entry ENABLE_ADDRESS_SANITIZER BOOL false
289 ;;
290 --enable-thread-sanitizer)
291 append_cache_entry ENABLE_THREAD_SANITIZER BOOL true
292 ;;
293 --disable-thread-sanitizer)
294 append_cache_entry ENABLE_THREAD_SANITIZER BOOL false
295 ;;
296 --enable-ub-sanitizer)
297 append_cache_entry ENABLE_UB_SANITIZER BOOL true
298 ;;
299 --disable-ub-sanitizer)
300 append_cache_entry ENABLE_UB_SANITIZER BOOL false
301 ;;
302 --enable-tcmalloc)
303 append_cache_entry ENABLE_TCMALLOC BOOL true
304 ;;
305 --disable-tcmalloc)
306 append_cache_entry ENABLE_TCMALLOC BOOL false
307 ;;
308 --enable-appid-third-party)
309 append_cache_entry ENABLE_APPID_THIRD_PARTY BOOL true
310 ;;
311 --enable-unit-tests)
312 append_cache_entry ENABLE_UNIT_TESTS BOOL true
313 ;;
314 --disable-unit-tests)
315 append_cache_entry ENABLE_UNIT_TESTS BOOL false
316 ;;
317 --enable-piglet)
318 append_cache_entry ENABLE_PIGLET BOOL true
319 ;;
320 --disable-piglet)
321 append_cache_entry ENABLE_PIGLET BOOL false
322 ;;
323 --disable-static-daq)
324 append_cache_entry ENABLE_STATIC_DAQ BOOL false
325 ;;
326 --enable-static-daq)
327 append_cache_entry ENABLE_STATIC_DAQ BOOL true
328 ;;
329 --disable-html-docs)
330 append_cache_entry MAKE_HTML_DOC BOOL false
331 ;;
332 --enable-html-docs)
333 append_cache_entry MAKE_HTML_DOC BOOL true
334 ;;
335 --disable-pdf-docs)
336 append_cache_entry MAKE_PDF_DOC BOOL false
337 ;;
338 --enable-pdf-docs)
339 append_cache_entry MAKE_PDF_DOC BOOL true
340 ;;
341 --disable-text-docs)
342 append_cache_entry MAKE_TEXT_DOC BOOL false
343 ;;
344 --enable-text-docs)
345 append_cache_entry MAKE_TEXT_DOC BOOL true
346 ;;
347 --disable-docs)
348 append_cache_entry MAKE_DOC BOOL false
349 ;;
350 --enable-docs)
351 append_cache_entry MAKE_DOC BOOL true
352 ;;
353 --with-pcap-includes=*)
354 append_cache_entry PCAP_INCLUDE_DIR_HINT PATH $optarg
355 ;;
356 --with-pcap-libraries=*)
357 append_cache_entry PCAP_LIBRARIES_DIR_HINT PATH $optarg
358 ;;
359 --with-luajit-includes=*)
360 append_cache_entry LUAJIT_INCLUDE_DIR_HINT PATH $optarg
361 ;;
362 --with-luajit-libraries=*)
363 append_cache_entry LUAJIT_LIBRARIES_DIR_HINT PATH $optarg
364 ;;
365 --with-pcre-includes=*)
366 append_cache_entry PCRE_INCLUDE_DIR_HINT PATH $optarg
367 ;;
368 --with-pcre-libraries=*)
369 append_cache_entry PCRE_LIBRARIES_DIR_HINT PATH $optarg
370 ;;
371 --with-dnet-includes=*)
372 append_cache_entry DNET_INCLUDE_DIR_HINT PATH $optarg
373 ;;
374 --with-dnet-libraries=*)
375 append_cache_entry DNET_LIBRARIES_DIR_HINT PATH $optarg
376 ;;
377 --with-daq-includes=*)
378 append_cache_entry DAQ_INCLUDE_DIR_HINT PATH $optarg
379 ;;
380 --with-daq-libraries=*)
381 append_cache_entry DAQ_LIBRARIES_DIR_HINT PATH $optarg
382 ;;
383 --with-openssl=*)
384 append_cache_entry OPENSSL_ROOT_DIR PATH $optarg
385 ;;
386 --with-hyperscan-includes=*)
387 append_cache_entry HS_INCLUDE_DIR PATH $optarg
388 ;;
389 --with-hyperscan-libraries=*)
390 append_cache_entry HS_LIBRARIES_DIR PATH $optarg
391 ;;
392 --with-flatbuffers-includes=*)
393 append_cache_entry FLATBUFFERS_INCLUDE_DIR_HINT PATH $optarg
394 ;;
395 --with-flatbuffers-libraries=*)
396 append_cache_entry FLATBUFFERS_LIBRARIES_DIR_HINT PATH $optarg
397 ;;
398 --with-uuid-includes=*)
399 append_cache_entry UUID_INCLUDE_DIR_HINT PATH $optarg
400 ;;
401 --with-uuid-libraries=*)
402 append_cache_entry UUID_LIBRARIES_DIR_HINT PATH $optarg
403 ;;
404 SIGNAL_SNORT_RELOAD=*)
405 append_cache_entry SIGNAL_SNORT_RELOAD STRING $optarg
406 ;;
407 SIGNAL_SNORT_DUMP_STATS=*)
408 append_cache_entry SIGNAL_SNORT_DUMP_STATS STRING $optarg
409 ;;
410 SIGNAL_SNORT_ROTATE_STATS=*)
411 append_cache_entry SIGNAL_SNORT_ROTATE_STATS STRING $optarg
412 ;;
413 SIGNAL_SNORT_READ_ATTR_TBL=*)
414 append_cache_entry SIGNAL_SNORT_READ_ATTR_TBL STRING $optarg
415 ;;
416 *)
417 echo "Invalid option '$1'. Try $0 --help to see available options."
418 exit 1
419 ;;
420 esac
421 shift
422 done
423
424 if [ -d $builddir ]; then
425 # If build directory exists, check if it has a CMake cache
426 if [ -f $builddir/CMakeCache.txt ]; then
427 # If the CMake cache exists, delete it so that this configuration
428 # is not tainted by a previous one
429 rm -f $builddir/CMakeCache.txt
430 fi
431 else
432 # Create build directory
433 mkdir -p $builddir
434 fi
435
436 echo "Build Directory : $builddir"
437 echo "Source Directory: $sourcedir"
438 cd $builddir
439
440 [ "$CMakeGenerator" ] && gen="-G $CMakeGenerator"
441
442 cmake "$gen" \
443 -DCMAKE_CXX_FLAGS:STRING="$CXXFLAGS $CPPFLAGS" \
444 -DCMAKE_C_FLAGS:STRING="$CFLAGS $CPPFLAGS" \
445 -DCMAKE_EXPORT_COMPILE_COMMANDS=ON \
446 $CMakeCacheEntries $sourcedir
447
448 echo "# This is the command used to configure this build" > config.status
449 echo $command >> config.status
450 chmod u+x config.status
451