-
Notifications
You must be signed in to change notification settings - Fork 37
/
configure
executable file
·198 lines (172 loc) · 8.13 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
#!/bin/sh
#
# Copyright (c) 2020-2023 by the Zeek Project. See LICENSE for details.
#
# Convenience wrapper for easily viewing/setting options that
# the project's CMake scripts will recognize
#
# Adapted from Zeek's wrapper.
set -e
# Defaults
cmake_binary_packaging_mode="no"
cmake_bison_root=""
cmake_build_directory="build"
cmake_build_shared_libs="yes"
cmake_build_toolchain="yes"
cmake_build_type="Release"
cmake_c_compiler=""
cmake_cxx_compiler=""
cmake_flex_root=""
cmake_generator=""
cmake_install_prefix="/usr/local"
cmake_use_benchmark="no"
cmake_use_ccache="no"
cmake_use_gold="yes"
cmake_use_precompiled_headers="yes"
cmake_use_sanitizers=""
cmake_use_werror="no"
display_cmake=0
cmake_cache_entries=""
set -e
command="$0 $*"
cmake_exe="<no cmake>"
for i in cmake cmake3; do
if which $i >/dev/null; then
$i --version | grep -q "cmake.*version 3" && cmake_exe=$(which $i)
break
fi
done
which "${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:
--binary-package Toggle special logic for binary packaging
--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}]
--disable-gold On Linux, do not try to use the gold linker
--disable-precompiled-headers Disable use of precompiled headers for developer tests
--enable-benchmark Build benchmark [default: ${cmake_use_benchmark}]
--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-c-compiler=<path> Set C compiler to use
--with-cxx-compiler=<path> Set C++ compiler to use
--with-hilti-compiler-launcher=<cmd> Set compiler launcher to use during JIT, e.g., ccache.
--with-flex=<prefix> Set prefix of Flex installation
--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
Spicy. 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
--binary-package) cmake_binary_packaging_mode="yes";;
--build-dir=*|--builddir=*) cmake_build_directory="${optarg}";;
--build-static-libs) cmake_build_shared_libs="no";;
--build-toolchain=*) cmake_build_toolchain="${optarg}";;
--build-type=*) cmake_build_type="${optarg}";;
--disable-gold) cmake_use_gold="no";;
--disable-precompiled-headers) cmake_use_precompiled_headers="no";;
--enable-benchmark) cmake_use_benchmark="yes";;
--enable-ccache) cmake_use_ccache="yes";;
--enable-debug) cmake_build_type="Debug";;
--enable-sanitizer) cmake_use_sanitizers="address";;
--enable-sanitizer=*) cmake_use_sanitizers="${optarg}";;
--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-hilti-compiler-launcher=*) hilti_compiler_launcher="${optarg}";;
--with-flex=*) cmake_flex_root="${optarg}";;
--with-bison=*) cmake_bison_root="${optarg}";;
--without-bison=*) cmake_bison_root="";;
--without-flex=*) cmake_flex_root="";;
--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 BINARY_PACKAGING_MODE BOOL "${cmake_binary_packaging_mode}"
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 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 HILTI_COMPILER_LAUNCHER STRING "${hilti_compiler_launcher}"
append_cache_entry FLEX_ROOT PATH "${cmake_flex_root}"
append_cache_entry USE_BENCHMARK BOOL "${cmake_use_benchmark}"
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}"
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}"
fail=$(mktemp)
{ eval "${cmake}" 2>&1 || echo > "$fail"; } | tee config.log && [ ! -s "$fail" ]
rm "$fail"
echo "# This is the command used to configure this build" > config.status
echo "${command}" >> config.status
chmod u+x config.status