]> git.ipfire.org Git - thirdparty/snort3.git/blob - configure_cmake.sh
Merge branch 'codecs' of ssh://chivas64dev.cm.sourcefire.com/nfs/home/jrosenba/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 --builddir= The build directory
20 --generator= run cmake --help for a list of generators
21 --prefix= Snort++ installation prefix
22
23 Optional Features:
24 --disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
25 --enable-FEATURE[=ARG] include FEATURE [ARG=yes]
26 --disable-static-ips-actions do not include ips actions in binary
27 --disable-static-inspectors do not include inspectors in binary
28 --disable-static-loggers do not include loggers in binary
29 --disable-static-ips-options do not include ips options in binary
30 --disable-static-search-engines do not include search engines in binary
31 --disable-static-codecs do not include codecs in binary
32 --enable-valgrind Only use if you are testing with valgrind.
33 --enable-ppm Enable packet/rule performance monitor
34 --enable-ppm-test Enable packet/rule performance monitor for readback
35 --enable-perf-profiling Enable preprocessor and rule performance profiling
36 --enable-linux-smp-stats Enable statistics reporting through proc
37 --enable-debug-msgs Enable debug printing options (bugreports and developers only)
38 --enable-debug Enable debugging options (bugreports and developers only)
39 --enable-gdb Enable gdb debugging information
40 --enable-profile Enable profiling options (developers only)
41 --disable-corefiles Prevent Snort from generating core files
42 --enable-intel-soft-cpm Enable Intel Soft CPM support
43 --enable-unit-tests Build unit tests
44 --enable-large-pcap Enable support for pcaps larger than 2 GB
45 --disable-static-daq Link static DAQ modules.
46 --enable-shell enable command line shell support
47
48
49 Optional Packages:
50 --with-PACKAGE[=ARG] use PACKAGE [ARG=yes]
51 --without-PACKAGE do not use PACKAGE (same as --with-PACKAGE=no)
52 --with-pic[=PKGS] try to use only PIC/non-PIC objects [default=use
53 both]
54 --with-gnu-ld assume the C compiler uses GNU ld [default=no]
55 --with-sysroot=DIR Search for dependent libraries within DIR
56 (or the compiler's sysroot if not specified).
57 --with-pcap-includes=DIR libpcap include directory
58 --with-pcap-libraries=DIR libpcap library directory
59 --with-luajit-includes=DIR luajit include directory
60 --with-luajit-libraries=DIR luajit library directory
61 --with-pcre-includes=DIR libpcre include directory
62 --with-pcre-libraries=DIR libpcre library directory
63 --with-openssl-includes=DIR openssl include directory
64 --with-openssl-library=LIB openssl library library - NOT THE DIRECTORY
65 --with-crypto-library=LIB openssl crypto library - NOT THE DIRECTORY
66 --with-dnet-includes=DIR libdnet include directory
67 --with-dnet-libraries=DIR libdnet library directory
68 --with-daq-includes=DIR DAQ include directory
69 --with-daq-libraries=DIR DAQ library directory
70
71
72 SIGNAL_SNORT_RELOAD=<value>
73 set the SIGNAL_SNORT_RELOAD value
74 SIGNAL_SNORT_DUMP_STATS<value>
75 set the SIGNAL_SNORT_DUMP_STATS value
76 SIGNAL_SNORT_ROTATE_STATS<value>
77 set the SIGNAL_SNORT_ROTATE_STATS value
78 SIGNAL_SNORT_READ_ATTR_TBL<value>
79 set the SIGNAL_SNORT_READ_ATTR_TBL value
80 "
81
82 sourcedir="$( cd "$( dirname "$0" )" && pwd )"
83
84 # Function to append a CMake cache entry definition to the
85 # CMakeCacheEntries variable
86 # $1 is the cache entry variable name
87 # $2 is the cache entry variable type
88 # $3 is the cache entry variable value
89 append_cache_entry () {
90 CMakeCacheEntries="$CMakeCacheEntries -D $1:$2=$3"
91 }
92
93 check_and_append_cache_entry() {
94 if [ -f $3 ]; then
95 append_cache_entry $1 $2 $3
96 else
97 echo ""
98 echo "the $1 variable, which is specified using a --with-* options,"
99 echo "requires an absolute path to the library. Could not stat the"
100 echo "the library:"
101 echo " $3"
102 echo ""
103 exit 1
104 fi
105 }
106
107 # set defaults
108 builddir=build
109 prefix=/usr/local/snort
110 CMakeCacheEntries=""
111 append_cache_entry CMAKE_INSTALL_PREFIX PATH $prefix
112
113
114 # parse arguments
115 while [ $# -ne 0 ]; do
116 case "$1" in
117 -*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
118 *) optarg= ;;
119 esac
120
121 case "$1" in
122 --help|-h)
123 echo "${usage}" 1>&2
124 exit 1
125 ;;
126 --builddir=*)
127 builddir=$optarg
128 ;;
129 --generator=*)
130 CMakeGenerator="$optarg"
131 ;;
132 --prefix=*)
133 prefix=$optarg
134 append_cache_entry CMAKE_INSTALL_PREFIX PATH $optarg
135 ;;
136 --disable-static-codecs)
137 append_cache_entry STATIC_CODECS BOOL false
138 ;;
139 --enable-static-codecs)
140 append_cache_entry STATIC_CODECS BOOL true
141 ;;
142 --disable-static-inspectors)
143 append_cache_entry STATIC_INSPECTORS BOOL false
144 ;;
145 --enable-static-inspectors)
146 append_cache_entry STATIC_INSPECTORS BOOL true
147 ;;
148 --disable-static-loggers)
149 append_cache_entry STATIC_LOGGERS BOOL false
150 ;;
151 --enable-static-loggers)
152 append_cache_entry STATIC_LOGGERS BOOL true
153 ;;
154 --disable-static-ips-options)
155 append_cache_entry STATIC_IPS_OPTIONS BOOL false
156 ;;
157 --enable-static-ips-actions)
158 append_cache_entry STATIC_IPS_ACTIONS BOOL true
159 ;;
160 --disable-static-ips-actions)
161 append_cache_entry STATIC_IPS_ACTIONS BOOL false
162 ;;
163 --enable-static-ips-options)
164 append_cache_entry STATIC_IPS_OPTIONS BOOL true
165 ;;
166 --disable-static-search-engines)
167 append_cache_entry STATIC_SEARCH_ENGINES BOOL false
168 ;;
169 --enable-static-search-engines)
170 append_cache_entry STATIC_SEARCH_ENGINES BOOL true
171 ;;
172 --disable-control-socket)
173 append_cache_entry BUILD_CONTROL_SOCKET BOOL false
174 ;;
175 --enable-control-socket)
176 append_cache_entry BUILD_CONTROL_SOCKET BOOL true
177 ;;
178 --disable-side-channel)
179 append_cache_entry BUILD_SIDE_CHANNEL BOOL false
180 ;;
181 --enable-side-channel)
182 append_cache_entry BUILD_SIDE_CHANNEL BOOL true
183 ;;
184 --disable-static-daq)
185 append_cache_entry ENABLE_STATIC_DAQ BOOL false
186 ;;
187 --enable-static-daq)
188 append_cache_entry ENABLE_STATIC_DAQ BOOL true
189 ;;
190 --disable-valgrind)
191 append_cache_entry ENABLE_VALGRIND BOOL false
192 ;;
193 --enable-valgrind)
194 append_cache_entry ENABLE_VALGRIND BOOL true
195 ;;
196 --disable-ppm)
197 append_cache_entry ENABLE_PPM BOOL false
198 ;;
199 --enable-ppm)
200 append_cache_entry ENABLE_PPM BOOL true
201 ;;
202 --disable-ppm-test)
203 append_cache_entry ENABLE_PPM_TEST BOOL false
204 ;;
205 --enable-ppm-test)
206 append_cache_entry ENABLE_PPM_TEST BOOL true
207 ;;
208 --disable-perf-profiling)
209 append_cache_entry ENABLE_PERFPROFILING BOOL false
210 ;;
211 --enable-perf-profiling)
212 append_cache_entry ENABLE_PERFPROFILING BOOL true
213 ;;
214 --disable-linux-smp-stats)
215 append_cache_entry ENABLE_LINUX_SMP_STATS BOOL false
216 ;;
217 --enable-linux-smp-stats)
218 append_cache_entry ENABLE_LINUX_SMP_STATS BOOL true
219 ;;
220 --disable-pthread)
221 append_cache_entry ENABLE_PTHREAD BOOL false
222 ;;
223 --enable-pthread)
224 append_cache_entry ENABLE_PTHREAD BOOL true
225 ;;
226 --disable-debug-msgs)
227 append_cache_entry ENABLE_DEBUG_MSGS BOOL false
228 ;;
229 --enable-debug-msgs)
230 append_cache_entry ENABLE_DEBUG_MSGS BOOL true
231 ;;
232 --disable-gdb)
233 append_cache_entry ENABLE_GDB BOOL false
234 ;;
235 --enable-gdb)
236 append_cache_entry ENABLE_GDB BOOL true
237 ;;
238 --disable-profile)
239 append_cache_entry ENABLE_PROFILE BOOL false
240 ;;
241 --enable-profile)
242 append_cache_entry ENABLE_PROFILE BOOL true
243 ;;
244 --disable-debug)
245 append_cache_entry ENABLE_DEBUG BOOL false
246 ;;
247 --enable-debug)
248 append_cache_entry ENABLE_DEBUG BOOL true
249 ;;
250 --disable-ha)
251 append_cache_entry BUILD_HA BOOL false
252 ;;
253 --enable-ha)
254 append_cache_entry BUILD_HA BOOL true
255 ;;
256 --disable-corefiles)
257 append_cache_entry ENABLE_COREFILES BOOL false
258 ;;
259 --enable-corefiles)
260 append_cache_entry ENABLE_COREFILES BOOL true
261 ;;
262 --disable-large-pcap)
263 append_cache_entry ENABLE_LARGE_PCAP BOOL false
264 ;;
265 --enable-large-pcap)
266 append_cache_entry ENABLE_LARGE_PCAP BOOL true
267 ;;
268 --disable-intel-soft-cpm)
269 append_cache_entry ENABLE_INTEL_SOFT_CPM BOOL false
270 ;;
271 --enable-intel-soft-cpm)
272 append_cache_entry ENABLE_INTEL_SOFT_CPM BOOL true
273 ;;
274 --enable-shell)
275 append_cache_entry ENABLE_SHELL BOOL true
276 ;;
277 --disable-shell)
278 append_cache_entry ENABLE_SHELL BOOL false
279 ;;
280 --disable-side-channel)
281 append_cache_entry BUILD_SIDE_CHANNEL BOOL false
282 ;;
283 --enable-side-channel)
284 append_cache_entry BUILD_SIDE_CHANNEL BOOL true
285 ;;
286 --disable-unit-tests)
287 append_cache_entry BUILD_UNIT_TESTS BOOL false
288 ;;
289 --enable-unit-tests)
290 append_cache_entry BUILD_UNIT_TESTS BOOL true
291 ;;
292 --disable-html-docs)
293 append_cache_entry MAKE_HTML_DOC BOOL false
294 ;;
295 --enable-html-docs)
296 append_cache_entry MAKE_HTML_DOC BOOL true
297 ;;
298 --disable-pdf-docs)
299 append_cache_entry MAKE_PDF_DOC BOOL false
300 ;;
301 --enable-pdf-docs)
302 append_cache_entry MAKE_PDF_DOC BOOL true
303 ;;
304 --with-openssl-includes=*)
305 append_cache_entry OPENSSL_INCLUDE_DIR PATH $optarg
306 ;;
307 --with-openssl-library=*)
308 check_and_append_cache_entry OPENSSL_SSL_LIBRARY FILEPATH $optarg
309 ;;
310 --with-crypto-library=*)
311 check_and_append_cache_entry OPENSSL_CRYPTO_LIBRARY FILEPATH $optarg
312 ;;
313 --with-pcap-includes=*)
314 append_cache_entry PCAP_INCLUDE_DIR PATH $optarg
315 ;;
316 --with-pcap-libraries=*)
317 append_cache_entry PCAP_LIBRARIES_DIR PATH $optarg
318 ;;
319 --with-luajit-includes=*)
320 append_cache_entry LUAJIT_INCLUDE_DIR PATH $optarg
321 ;;
322 --with-luajit-libraries=*)
323 append_cache_entry LUAJIT_LIBRARIES_DIR PATH $optarg
324 ;;
325 --with-pcre-includes=*)
326 append_cache_entry PCRE_INCLUDE_DIR PATH $optarg
327 ;;
328 --with-pcre-libraries=*)
329 append_cache_entry PCRE_LIBRARIES_DIR PATH $optarg
330 ;;
331 --with-dnet-includes=*)
332 append_cache_entry DNET_INCLUDE_DIR PATH $optarg
333 ;;
334 --with-dnet-libraries=*)
335 append_cache_entry DNET_LIBRARIES_DIR PATH $optarg
336 ;;
337 --with-daq-includes=*)
338 append_cache_entry DAQ_INCLUDE_DIR PATH $optarg
339 ;;
340 --with-daq-libraries=*)
341 append_cache_entry DAQ_LIBRARIES_DIR PATH $optarg
342 ;;
343 # Currently unsupported
344 # --with-intel-soft-cpm-includes=*)
345 # append_cache_entry INTEL_SOFT_CPM_INCLUDE_DIR PATH $optarg
346 # ;;
347 # --with-intel-soft-cpm-libraries=*)
348 # append_cache_entry INTEL_SOFT_CPM_LIBRARIES_DIR PATH $optarg
349 # ;;
350 --with-flex=*)
351 append_cache_entry FLEX_EXECUTABLE PATH $optarg
352 ;;
353 --with-bison=*)
354 append_cache_entry BISON_EXECUTABLE PATH $optarg
355 ;;
356 SIGNAL_SNORT_RELOAD=*)
357 append_cache_entry SIGNAL_SNORT_RELOAD STRING $optarg
358 ;;
359 SIGNAL_SNORT_DUMP_STATS=*)
360 append_cache_entry SIGNAL_SNORT_DUMP_STATS STRING $optarg
361 ;;
362 SIGNAL_SNORT_ROTATE_STATS=*)
363 append_cache_entry SIGNAL_SNORT_ROTATE_STATS STRING $optarg
364 ;;
365 SIGNAL_SNORT_READ_ATTR_TBL=*)
366 append_cache_entry SIGNAL_SNORT_READ_ATTR_TBL STRING $optarg
367 ;;
368 *)
369 echo "Invalid option '$1'. Try $0 --help to see available options."
370 exit 1
371 ;;
372 esac
373 shift
374 done
375
376 if [ -d $builddir ]; then
377 # If build directory exists, check if it has a CMake cache
378 if [ -f $builddir/CMakeCache.txt ]; then
379 # If the CMake cache exists, delete it so that this configuration
380 # is not tainted by a previous one
381 rm -f $builddir/CMakeCache.txt
382 fi
383 else
384 # Create build directory
385 mkdir -p $builddir
386 fi
387
388 echo "Build Directory : $builddir"
389 echo "Source Directory: $sourcedir"
390 cd $builddir
391
392 if [ -n "$CMakeGenerator" ]; then
393 cmake -G "$CMakeGenerator" $CMakeCacheEntries $sourcedir
394 else
395 cmake $CMakeCacheEntries $sourcedir
396 fi
397
398 echo "# This is the command used to configure this build" > config.status
399 echo $command >> config.status
400 chmod u+x config.status