forked from zeek/spicy
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·217 lines (193 loc) · 9.65 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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
#! /bin/sh
#
# Convenience wrapper for easily viewing/setting options that
# the project's CMake scripts will recognize
#
# Adapted from Zeek's wrapper.
# Defaults
cmake_bison_root=""
cmake_build_directory="build"
cmake_build_shared_libs="yes"
cmake_build_toolchain="yes"
cmake_build_type="RelWithDebInfo"
cmake_build_zeek_plugin="yes"
cmake_c_compiler=""
cmake_clang_resource_dir=""
cmake_clang_root=""
cmake_cxx_compiler=""
cmake_flex_root=""
cmake_generator=""
cmake_hilti_have_jit="yes"
cmake_install_prefix="/usr/local"
cmake_llvm_root=""
cmake_use_ccache="no"
cmake_use_gold="yes"
cmake_use_precompiled_headers="yes"
cmake_use_sanitizers=""
cmake_use_werror="false"
cmake_zeek_have_jit="yes"
cmake_zeek_root_dir="/usr/local/zeek"
cmake_zeek_install_plugin="yes"
display_cmake=0
cache_entries=""
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-static-libs Build static libraries instead [default: shared]
--build-toolchain={yes,no} Build the Spicy compiler toolchain [default: ${cmake_build_toolchain}]
--build-type=TYPE Set build type (Debug,Release,RelWithDebInfo) [default: ${cmake_build_type}]
--build-zeek-plugin={yes,no} Build the the Spicy plugin for Zeek [default: ${cmake_build_zeek_plugin}]
--disable-jit Do not compile in support for JIT compilation
--disable-jit-for-zeek Do not compile support for JIT compilation into Zeek plugin
--disable-gold On Linux, do not try to use the gold linker
--disable-precompiled-headers Disable use of precompiled headers for developer tests
--disable-zeek-plugin-install Do not copy Zeek plugin into Zeek plugin path on install
--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-sanitizer[=<names>] Enable sanitizer(s), default if not further specified is \"address\"
--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-bison=<prefix> Set prefix of Bison installation
--with-clang-root=<prefix> Set prefix of Clang installation
--with-c-compiler=<path> Set C compiler to use
--with-cxx-compiler=<path> Set C++ compiler to use
--with-flex=<prefix> Set prefix of Flex installation
--with-clang-resource-dir=<path> Set resource directory to use with clang during JIT
--with-llvm-root=<prefix> Set prefix of LLVM installation
--with-zeek=PATH Path to Zeek installation [default: ${cmake_zeek_root_dir}]
--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=*|--builddir=*) cmake_build_directory="${optarg}";;
--build-static-libs) cmake_build_shared_libs="false";;
--build-toolchain=*) cmake_build_toolchain="${optarg}";;
--build-type=*) cmake_build_type="${optarg}";;
--build-zeek-plugin=*) cmake_build_zeek_plugin="${optarg}";;
--disable-gold) cmake_use_gold="no";;
--disable-jit) cmake_hilti_have_jit="no";;
--disable-jit-for-zeek) cmake_zeek_have_jit="no";;
--disable-precompiled-headers) cmake_use_precompiled_headers="no";;
--disable-zeek-plugin-install) cmake_zeek_install_plugin="no";;
--enable-ccache) cmake_use_ccache="yes";;
--enable-debug) cmake_build_type="Debug";;
--enable-sanitizer) cmake_use_sanitizers="address";;
--enable-sanitizer=*) cmake_use_sanitizers="${optargs}";;
--enable-werror) cmake_use_werror="yes";;
--generator=*) cmake_generator="${optarg}";;
--prefix=*) cmake_install_prefix="${optarg}";;
--with-clang-root=*) cmake_clang_root="${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')
command -v "${try_c_compiler}" >/dev/null && cmake_c_compiler="${try_c_compiler}"
fi
;;
--with-clang-resource-dir=*) cmake_clang_resource_dir="${optarg}";;
--with-flex=*) cmake_flex_root="${optarg}";;
--with-bison=*) cmake_bison_root="${optarg}";;
--with-llvm-root=*) cmake_llvm_root="${optarg}";;
--with-zeek=*) cmake_zeek_root_dir="${optarg}";;
--without-bison=*) cmake_bison_root="";;
--without-clang-root=*) cmake_clang_root=""; cmake_hilti_have_jit="no";;
--without-flex=*) cmake_flex_root="";;
--without-llvm-root=*) cmake_llvm_root=""; cmake_hilti_have_jit="no";;
--without-zeek) cmake_zeek_root_dir="";;
--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 BISON_ROOT PATH "${cmake_bison_root}"
append_cache_entry BUILD_SHARED_LIBS BOOL "${cmake_build_shared_libs}"
append_cache_entry BUILD_TOOLCHAIN BOOL "${cmake_build_toolchain}"
append_cache_entry BUILD_ZEEK_PLUGIN BOOL "${cmake_build_zeek_plugin}"
append_cache_entry CLANG_ROOT PATH "${cmake_clang_root}"
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 CLANG_RESOURCE_DIR PATH "${cmake_clang_resource_dir}"
append_cache_entry CMAKE_INSTALL_PREFIX PATH "${cmake_install_prefix}"
append_cache_entry FLEX_ROOT PATH "${cmake_flex_root}"
append_cache_entry HILTI_HAVE_JIT BOOL "${cmake_hilti_have_jit}"
append_cache_entry ZEEK_HAVE_JIT BOOL "${cmake_zeek_have_jit}"
append_cache_entry ZEEK_INSTALL_PLUGIN BOOL "${cmake_zeek_install_plugin}"
append_cache_entry LLVM_ROOT PATH "${cmake_llvm_root}"
append_cache_entry USE_CCACHE BOOL "${cmake_use_ccache}"
append_cache_entry USE_GOLD BOOL "${cmake_use_gold}"
append_cache_entry USE_SANITIZERS STRING "${cmake_use_sanitizers}"
append_cache_entry HILTI_DEV_PRECOMPILE_HEADERS BOOL "${cmake_use_precompiled_headers}"
append_cache_entry USE_WERROR BOOL "${cmake_use_werror}"
append_cache_entry ZEEK_ROOT_DIR PATH "${cmake_zeek_root_dir}"
append_cache_entry CPACK_BINARY_STGZ BOOL "OFF"
append_cache_entry CPACK_BINARY_TGZ BOOL "ON"
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