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