-
Notifications
You must be signed in to change notification settings - Fork 6
/
configure
executable file
·183 lines (159 loc) · 7.38 KB
/
configure
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
#! /bin/sh
#
# Convenience wrapper for easily viewing/setting options that
# the project's CMake scripts will recognize.
#
# Adapted from Zeek's wrapper.
# Defaults
cmake_build_directory="build"
cmake_build_type="RelWithDebInfo"
cmake_c_compiler=""
cmake_cxx_compiler=""
cmake_generator=""
cmake_install_prefix="/usr/local"
cmake_use_broker="no"
cmake_use_ccache="no"
cmake_use_doctest="yes"
cmake_use_sanitizers=""
cmake_use_werror="no"
cmake_use_static_linking="no"
cmake_openssl_root=""
cmake_osx_architectures=""
cmake_osx_deployment_target=""
display_cmake=0
cache_entries=""
if [ "$(uname -s)" = "Linux" ]; then
# Pick clang by default on Linux if available.
cmake_c_compiler="$(command -v clang 2>/dev/null)"
cmake_cxx_compiler="$(command -v clang++ 2>/dev/null)"
fi
set -e
command="$0 $*"
cmake_exe="<no cmake>"
for i in cmake cmake3; do
if command -v $i >/dev/null; then
$i --version | grep -q "cmake.*version 3" && cmake_exe=$(command -v $i)
break
fi
done
type ${cmake_exe} > /dev/null 2>&1 || {
echo "\
This package requires CMake, please install it first, then you may
use this configure script to access CMake equivalent functionality.\
" >&2;
exit 1;
}
usage="\
Usage: $0 [OPTION]... [VAR=VALUE]...
Build Options:
--build-dir=DIR Place build files in directory [default: ${cmake_build_directory}]
--build-type=TYPE Set build type (Debug,Release,RelWithDebInfo) [default: ${cmake_build_type}]
--disable-tests Do not include unit tests into build.
--enable-broker Build in legacy Broker support for connecting to Zeek 4.x [default: ${cmake_use_broker}]
--enable-ccache Build using the compiler cache cache if in PATH [default: ${cmake_use_ccache}]
--enable-debug Compile debug version (same as --build-type=Debug) [default: off]
--enable-osx-universal Build universal x86/arm64 binary on macOS (will need universal deps too)
--enable-sanitizer[=<names>] Enable sanitizer(s), default if not further specified is \"address\"
--enable-static Link agent binary staticallly (where supported by platform)
--enable-werror Treat compiler warnings as errors [default: ${cmake_use_werror}]
--generator=<generator> CMake generator to use (see cmake --help)
--prefix=PATH Installation prefix [default: ${cmake_install_prefix}]
--with-c-compiler=<path> Set C compiler to use [default: ${cmake_c_compiler:-determined by CMake}]
--with-cxx-compiler=<path> Set C++ compiler to use [default: ${cmake_cxx_compiler:-determined by CMake}]
--with-openssl=DIR Path to OpenSSL installation root
--osx-deployment-target=VERSION Minimum macOS version to deploy on
--display-cmake Don't create build configuration, just output final CMake invocation
"
source_dir="$(cd "$(dirname "$0")" && pwd)"
if [ ! -e "$source_dir/3rdparty/doctest/CMakeLists.txt" ] && [ -d "$source_dir/.git" ]; then
echo "\
You seem to be missing the content of the 3rdparty/doctest directory.
This typically means that you performed a non-recursive git clone of
Spict. To check out the required subdirectories, please execute:
( cd $source_dir && git submodule update --recursive --init )
" >&2;
exit 1;
fi
# Function to append a CMake cache entry definition to the
# cmake_cache_entries variable.
# $1 is the cache entry variable name
# $2 is the cache entry variable type
# $3 is the cache entry variable value
append_cache_entry () {
if [ "$3" != "" ]; then
cmake_cache_entries="${cmake_cache_entries} -D $1:$2=$3"
fi
}
# parse arguments
while [ $# -ne 0 ]; do
case "$1" in
-*=*) optarg=`echo "$1" | sed 's/[-_a-zA-Z0-9]*=//'` ;;
*) optarg= ;;
esac
case "$1" in
--build-dir=*) cmake_build_directory="${optarg}";;
--build-type=*) cmake_build_type="${optarg}";;
--disable-tests) cmake_use_doctest="no";;
--enable-broker) cmake_use_broker="yes";;
--enable-ccache) cmake_use_ccache="yes";;
--enable-debug) cmake_build_type="Debug";;
--enable-osx-universal) cmake_osx_architectures="'arm64;x86_64'";;
--enable-sanitizer) cmake_use_sanitizers="address";;
--enable-sanitizer=*) cmake_use_sanitizers="${optarg}";;
--enable-static) cmake_use_static_linking="yes";;
--enable-werror) cmake_use_werror="yes";;
--generator=*) cmake_generator="${optarg}";;
--prefix=*) cmake_install_prefix="${optarg}";;
--with-c-compiler=*) cmake_c_compiler="${optarg}";;
--with-cxx-compiler=*)
cmake_cxx_compiler="${optarg}"
if [ -z "${cmake_c_compiler}" ]; then
try_c_compiler=$(echo "${cmake_cxx_compiler}" | sed 's/++//g')
which "${try_c_compiler}" >/dev/null && cmake_c_compiler="${try_c_compiler}"
fi
;;
--with-openssl=*) cmake_openssl_root="${optarg}";;
--osx-deployment-target=*) cmake_osx_deployment_target="${optarg}";;
--display-cmake) display_cmake=1;;
--help|-h) echo "${usage}" 1>&2 && exit 1;;
*) echo "Invalid option '$1'. Try $0 --help to see available options." && exit 1;;
esac
shift
done
# Set CMake cache options.
append_cache_entry CMAKE_BUILD_TYPE STRING "${cmake_build_type}"
append_cache_entry CMAKE_C_COMPILER PATH "${cmake_c_compiler}"
append_cache_entry CMAKE_CXX_COMPILER PATH "${cmake_cxx_compiler}"
append_cache_entry CMAKE_INSTALL_PREFIX PATH "${cmake_install_prefix}"
append_cache_entry CMAKE_OSX_ARCHITECTURES STRING "${cmake_osx_architectures}"
append_cache_entry CMAKE_OSX_DEPLOYMENT_TARGET STRING "${cmake_osx_deployment_target}"
append_cache_entry USE_BROKER BOOL "${cmake_use_broker}"
append_cache_entry USE_CCACHE BOOL "${cmake_use_ccache}"
append_cache_entry USE_SANITIZERS STRING "${cmake_use_sanitizers}"
append_cache_entry USE_WERROR BOOL "${cmake_use_werror}"
append_cache_entry USE_DOCTEST BOOL "${cmake_use_doctest}"
append_cache_entry USE_STATIC_LINKING BOOL "${cmake_use_static_linking}"
append_cache_entry OPENSSL_ROOT_DIR PATH "${cmake_openssl_root}"
if [ -n "${cmake_generator}" ]; then
cmake="${cmake_exe} -G '${cmake_generator}' ${cmake_cache_entries} ${source_dir}"
else
cmake="${cmake_exe} ${cmake_cache_entries} ${source_dir}"
fi
if [ "${display_cmake}" = 1 ]; then
echo "${cmake}"
exit 0
fi
if [ ! -d ${cmake_build_directory} ]; then
# Create build directory
mkdir -p ${cmake_build_directory}
else
# If build directory already exists, remove any pre-existing
# CMake cache so that this configuration is not tainted by a
# previous one
rm -f ${cmake_build_directory}/CMakeCache.txt
fi
cd ${cmake_build_directory}
eval ${cmake} 2>&1 | tee config.log
echo "# This is the command used to configure this build" > config.status
echo ${command} >> config.status
chmod u+x config.status