]> git.ipfire.org Git - thirdparty/snort3.git/blob - configure_cmake.sh
Merge branch 'master' of /nfs/home/rucombs/Snort++ into codecs
[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 set -e
5 command="$0 $*"
6
7 # check for `cmake` command
8 type cmake > /dev/null 2>&1 || {
9 echo "\
10 This package requires CMake, please install it first, then you may
11 use this configure script to access CMake equivalent functionality.\
12 " >&2;
13 exit 1;
14 }
15
16 usage="\
17 Usage: $0 [OPTION]... [VAR=VALUE]...
18
19 Build Options:
20 --builddir=DIR place build files in directory [build]
21 --generator=GENERATOR CMake generator to use (see cmake --help)
22
23 Installation Directories:
24 --prefix=PREFIX installation directory [/usr/local/bro]
25 --conf-files-dir=PATH config files installation directory [PREFIX/etc]
26
27 Optional Features:
28 --disable-option-checking ignore unrecognized --enable/--with options
29 --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
30 --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
31 --enable-silent-rules less verbose build output (undo: \"make V=1\")
32 --disable-silent-rules verbose build output (undo: \"make V=0\")
33 --enable-shared[=PKGS] build shared libraries [default=yes]
34 --enable-static[=PKGS] build static libraries [default=yes]
35 --enable-fast-install[=PKGS]
36 optimize for fast installation [default=yes]
37 --enable-dependency-tracking
38 do not reject slow dependency extractors
39 --disable-dependency-tracking
40 speeds up one-time build
41 --disable-libtool-lock avoid locking (might break parallel builds)
42 --disable-static-inspectors do not include inspectors in binary
43 --disable-static-loggers do not include loggers in binary
44 --disable-static-ips-options do not include ips options in binary
45 --disable-static-search-engines do not include search engines in binary
46 --disable-static-codecs do not include codecs in binary
47 --enable-control-socket Enable the control socket (Linux only)
48 --enable-side-channel Enable the side channel (Linux only)
49 --enable-valgrind Only use if you are testing with valgrind.
50 --disable-ppm Disable packet/rule performance monitor
51 --enable-ppm-test Enable packet/rule performance monitor for readback
52 --disable-perfprofiling Disable preprocessor and rule performance profiling
53 --enable-linux-smp-stats Enable statistics reporting through proc
54 --enable-inline-init-failopen Enable Fail Open during initialization for Inline Mode (adds pthread support implicitly)
55 --disable-pthread Disable pthread support
56 --enable-debug-msgs Enable debug printing options (bugreports and developers only)
57 --enable-debug Enable debugging options (bugreports and developers only)
58 --enable-gdb Enable gdb debugging information
59 --enable-profile Enable profiling options (developers only)
60 --enable-sourcefire Enable Sourcefire specific build options, encompasing --enable-perfprofiling and --enable-ppm
61 --disable-corefiles Prevent Snort from generating core files
62 --enable-ha Enable high-availability state sharing
63 --enable-non-ether-decoders Enable non Ethernet decoders.
64 --enable-intel-soft-cpm Enable Intel Soft CPM support
65 --enable-unit-tests Build unit tests
66 --enable-large-pcap Enable support for pcaps larger than 2 GB
67 --disable-static-daq Link static DAQ modules.
68
69 Optional Packages:
70 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
71 --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
72 --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use
73 both]
74 --with-gnu-ld assume the C compiler uses GNU ld [default=no]
75 --with-sysroot=DIR Search for dependent libraries within DIR
76 (or the compiler's sysroot if not specified).
77 --with-pcap-includes=DIR libpcap include directory
78 --with-pcap-libraries=DIR libpcap library directory
79 --with-luajit-includes=DIR luajit include directory
80 --with-luajit-libraries=DIR luajit library directory
81 --with-pcre-includes=DIR libpcre include directory
82 --with-pcre-libraries=DIR libpcre library directory
83 --with-openssl-includes=DIR openssl include directory
84 --with-openssl-libraries=DIR openssl library directory
85 --with-dnet-includes=DIR libdnet include directory
86 --with-dnet-libraries=DIR libdnet library directory
87 --with-daq-includes=DIR DAQ include directory
88 --with-daq-libraries=DIR DAQ library directory
89 --with-intel-soft-cpm-includes=DIR Intel Soft CPM include directory
90 --with-intel-soft-cpm-libraries=DIR Intel Soft CPM library directory
91
92 Some influential environment variables:
93 CC C compiler command
94 CFLAGS C compiler flags
95 LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
96 nonstandard directory <lib dir>
97 LIBS libraries to pass to the linker, e.g. -l<library>
98 CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
99 you have headers in a nonstandard directory <include dir>
100 CPP C preprocessor
101 CXX C++ compiler command
102 CXXFLAGS C++ compiler flags
103 CXXCPP C++ preprocessor
104 SIGNAL_SNORT_RELOAD
105 set the SIGNAL_SNORT_RELOAD value
106 SIGNAL_SNORT_DUMP_STATS
107 set the SIGNAL_SNORT_DUMP_STATS value
108 SIGNAL_SNORT_ROTATE_STATS
109 set the SIGNAL_SNORT_ROTATE_STATS value
110 SIGNAL_SNORT_READ_ATTR_TBL
111 set the SIGNAL_SNORT_READ_ATTR_TBL value
112
113 Use these variables to override the choices made by \`configure' or to help
114 it to find libraries and programs with nonstandard names/locations.
115
116 Report bugs to the package provider.
117 "
118
119 sourcedir="$( cd "$( dirname "$0" )" && pwd )"
120
121 # Function to append a CMake cache entry definition to the
122 # CMakeCacheEntries variable
123 # $1 is the cache entry variable name
124 # $2 is the cache entry variable type
125 # $3 is the cache entry variable value
126 append_cache_entry () {
127 CMakeCacheEntries="$CMakeCacheEntries -D $1:$2=$3"
128 }
129
130 check_and_append_cache_entry() {
131 if [ -f $3 ]; then
132 append_cache_entry $1 $2 $3
133 else
134 echo ""
135 echo "the $1 variable, which is specified using a --with-* options,"
136 echo "requires an absolute path to the library. Could not stat the"
137 echo "the library:"
138 echo " $3"
139 echo ""
140 exit 1
141 fi
142 }
143
144 # set defaults
145 builddir=build
146 prefix=/usr/local/snort
147 CMakeCacheEntries=""
148 append_cache_entry CMAKE_INSTALL_PREFIX PATH $prefix
149
150
151 # parse arguments
152 while [ $# -ne 0 ]; do
153 case "$1" in
154 -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
155 *) optarg= ;;
156 esac
157
158 case "$1" in
159 --help|-h)
160 echo "${usage}" 1>&2
161 exit 1
162 ;;
163 --builddir=*)
164 builddir=$optarg
165 ;;
166 --generator=*)
167 CMakeGenerator="$optarg"
168 ;;
169 --prefix=*)
170 prefix=$optarg
171 append_cache_entry CMAKE_INSTALL_PREFIX PATH $optarg
172 ;;
173 --disable-static-codecs)
174 append_cache_entry STATIC_CODECS BOOL false
175 ;;
176 --enable-static-codecs)
177 append_cache_entry STATIC_CODECS BOOL true
178 ;;
179 --disable-static-inspectors)
180 append_cache_entry STATIC_INSPECTORS BOOL false
181 ;;
182 --enable-static-inspectors)
183 append_cache_entry STATIC_INSPECTORS BOOL true
184 ;;
185 --disable-static-loggers)
186 append_cache_entry STATIC_LOGGERS BOOL false
187 ;;
188 --enable-static-loggers)
189 append_cache_entry STATIC_LOGGERS BOOL true
190 ;;
191 --disable-static-ips-option)
192 append_cache_entry STATIC_IPS_OPTIONS BOOL false
193 ;;
194 --enable-static-ips-option)
195 append_cache_entry STATIC_IPS_OPTIONS BOOL true
196 ;;
197 --disable-static-search-engines)
198 append_cache_entry STATIC_SEARCH_ENGINES BOOL false
199 ;;
200 --enable-static-search-engines)
201 append_cache_entry STATIC_SEARCH_ENGINES BOOL true
202 ;;
203 --disable-control-socket)
204 append_cache_entry BUILD_CONTROL_SOCKET BOOL false
205 ;;
206 --enable-control-socket)
207 append_cache_entry BUILD_CONTROL_SOCKET BOOL true
208 ;;
209 --disable-side-channel)
210 append_cache_entry BUILD_SIDE_CHANNEL BOOL false
211 ;;
212 --enable-side-channel)
213 append_cache_entry BUILD_SIDE_CHANNEL BOOL true
214 ;;
215 --disable-static-daq)
216 append_cache_entry ENABLE_STATIC_DAQ BOOL false
217 ;;
218 --enable-static-daq)
219 append_cache_entry ENABLE_STATIC_DAQ BOOL true
220 ;;
221 --disable-valgrind)
222 append_cache_entry ENABLE_VALGRIND BOOL false
223 ;;
224 --enable-valgrind)
225 append_cache_entry ENABLE_VALGRIND BOOL true
226 ;;
227 --disable-ppm)
228 append_cache_entry ENABLE_PPM BOOL false
229 ;;
230 --enable-ppm)
231 append_cache_entry ENABLE_PPM BOOL true
232 ;;
233 --disable-ppm-test)
234 append_cache_entry ENABLE_PPM BOOL false
235 ;;
236 --enable-ppm-test)
237 append_cache_entry ENABLE_PPM BOOL true
238 ;;
239 --disable-perfprofiling)
240 append_cache_entry ENABLE_PERFPROFILING BOOL false
241 ;;
242 --enable-perfprofiling)
243 append_cache_entry ENABLE_PERFPROFILING BOOL true
244 ;;
245 --disable-linux-smp-stats)
246 append_cache_entry ENABLE_INLINE_INIT_FAILOPEN BOOL false
247 ;;
248 --enable-linux-smp-stats)
249 append_cache_entry ENABLE_INLINE_INIT_FAILOPEN BOOL true
250 ;;
251 --disable-pthread)
252 append_cache_entry ENABLE_PTHREAD BOOL false
253 ;;
254 --enable-pthread)
255 append_cache_entry ENABLE_PTHREAD BOOL true
256 ;;
257 --disable-debug_msgs)
258 append_cache_entry ENABLE_DEBUG_MSGS BOOL false
259 ;;
260 --enable-debug_msgs)
261 append_cache_entry ENABLE_DEBUG_MSGS BOOL true
262 ;;
263 --disable-gdb)
264 append_cache_entry ENABLE_GDB BOOL false
265 ;;
266 --enable-gdb)
267 append_cache_entry ENABLE_GDB BOOL true
268 ;;
269 --disable-profile)
270 append_cache_entry ENABLE_PROFILE BOOL false
271 ;;
272 --enable-profile)
273 append_cache_entry ENABLE_PROFILE BOOL true
274 ;;
275 --disable-sourcefire)
276 append_cache_entry ENABLE_SOURCEFIRE BOOL false
277 ;;
278 --enable-sourcefire)
279 append_cache_entry ENABLE_SOURCEFIRE BOOL true
280 ;;
281 --disable-debug)
282 append_cache_entry ENABLE_COREFILES BOOL false
283 ;;
284 --enable-debug)
285 append_cache_entry ENABLE_COREFILES BOOL true
286 ;;
287 --disable-ha)
288 append_cache_entry BUILD_HA BOOL false
289 ;;
290 --enable-ha)
291 append_cache_entry BUILD_HA BOOL true
292 ;;
293 --disable-large-pcap)
294 append_cache_entry ENABLE_LARGE_PCAP BOOL false
295 ;;
296 --enable-large-pcap)
297 append_cache_entry ENABLE_LARGE_PCAP BOOL true
298 ;;
299 --disable-intel-soft-cpm)
300 append_cache_entry HAVE_INTEL_SOFT_CPM BOOL false
301 ;;
302 --enable-intel-soft-cpm)
303 append_cache_entry HAVE_INTEL_SOFT_CPM BOOL true
304 ;;
305 --disable-side-channel)
306 append_cache_entry BUILD_SIDE_CHANNEL BOOL false
307 ;;
308 --enable-side-channel)
309 append_cache_entry BUILD_SIDE_CHANNEL BOOL true
310 ;;
311 --disable-unit-tests)
312 append_cache_entry BUILD_UNIT_TESTS BOOL false
313 ;;
314 --enable-unit-tests)
315 append_cache_entry BUILD_UNIT_TESTS BOOL true
316 ;;
317 --disable-html-docs)
318 append_cache_entry MAKE_HTML_DOC BOOL false
319 ;;
320 --enable-html-docs)
321 append_cache_entry MAKE_HTML_DOC BOOL true
322 ;;
323 --disable-pdf-docs)
324 append_cache_entry MAKE_PDF_DOC BOOL false
325 ;;
326 --enable-pdf-docs)
327 append_cache_entry MAKE_PDF_DOC BOOL true
328 ;;
329 --with-openssl-includes=*)
330 append_cache_entry OPENSSL_INCLUDE_DIR PATH $optarg
331 ;;
332 --with-openssl-libraries=*)
333 check_and_append_cache_entry OPENSSL_SSL_LIBRARY FILEPATH $optarg
334 ;;
335 --with-crypto-libraries=*)
336 check_and_append_cache_entry OPENSSL_CRYPTO_LIBRARY FILEPATH $optarg
337 ;;
338 --with-pcap-includes=*)
339 append_cache_entry PCAP_INCLUDE_DIR PATH $optarg
340 ;;
341 --with-pcap-libraries=*)
342 append_cache_entry PCAP_LIBRARIES_DIR PATH $optarg
343 ;;
344 --with-luajit-includes=*)
345 append_cache_entry LUAJIT_INCLUDE_DIR PATH $optarg
346 ;;
347 --with-luajit-libraries=*)
348 append_cache_entry LUAJIT_LIBRARIES_DIR PATH $optarg
349 ;;
350 --with-pcre-includes=*)
351 append_cache_entry PCRE_INCLUDE_DIR PATH $optarg
352 ;;
353 --with-pcre-libraries=*)
354 append_cache_entry PCRE_LIBRARIES_DIR PATH $optarg
355 ;;
356 --with-dnet-includes=*)
357 append_cache_entry DNET_INCLUDE_DIR PATH $optarg
358 ;;
359 --with-dnet-libraries=*)
360 append_cache_entry DNET_LIBRARIES_DIR PATH $optarg
361 ;;
362 --with-daq-includes=*)
363 append_cache_entry DAQ_INCLUDE_DIR PATH $optarg
364 ;;
365 --with-daq-libraries=*)
366 append_cache_entry DAQ_LIBRARIES_DIR PATH $optarg
367 ;;
368 # Currently unsupported
369 # --with-intel-soft-cpm-includes=*)
370 # append_cache_entry INTEL_SOFT_CPM_INCLUDE_DIR PATH $optarg
371 # ;;
372 # --with-intel-soft-cpm-libraries=*)
373 # append_cache_entry INTEL_SOFT_CPM_LIBRARIES_DIR PATH $optarg
374 # ;;
375 --with-flex=*)
376 append_cache_entry FLEX_EXECUTABLE PATH $optarg
377 ;;
378 --with-bison=*)
379 append_cache_entry BISON_EXECUTABLE PATH $optarg
380 ;;
381 SIGNAL_SNORT_RELOAD=*)
382 append_cache_entry SIGNAL_SNORT_RELOAD STRING $optarg
383 ;;
384 SIGNAL_SNORT_DUMP_STATS=*)
385 append_cache_entry SIGNAL_SNORT_DUMP_STATS STRING $optarg
386 ;;
387 SIGNAL_SNORT_ROTATE_STATS=*)
388 append_cache_entry SIGNAL_SNORT_ROTATE_STATS STRING $optarg
389 ;;
390 SIGNAL_SNORT_READ_ATTR_TBL=*)
391 append_cache_entry SIGNAL_SNORT_READ_ATTR_TBL STRING $optarg
392 ;;
393 *)
394 echo "Invalid option '$1'. Try $0 --help to see available options."
395 exit 1
396 ;;
397 esac
398 shift
399 done
400
401
402 if [ -d $builddir ]; then
403 # If build directory exists, check if it has a CMake cache
404 if [ -f $builddir/CMakeCache.txt ]; then
405 # If the CMake cache exists, delete it so that this configuration
406 # is not tainted by a previous one
407 rm -f $builddir/CMakeCache.txt
408 fi
409 else
410 # Create build directory
411 mkdir -p $builddir
412 fi
413
414 echo "Build Directory : $builddir"
415 echo "Source Directory: $sourcedir"
416 cd $builddir
417
418 if [ -n "$CMakeGenerator" ]; then
419 cmake -G "$CMakeGenerator" $CMakeCacheEntries $sourcedir
420 else
421 cmake $CMakeCacheEntries $sourcedir
422 fi
423
424 echo "# This is the command used to configure this build" > config.status
425 echo $command >> config.status
426 chmod u+x config.status