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