forked from zeek/zeek-agent-v2
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·154 lines (132 loc) · 5.81 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
#! /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_generator=""
cmake_install_prefix="/usr/local"
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=""
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-type=TYPE Set build type (Debug,Release,RelWithDebInfo) [default: ${cmake_build_type}]
--disable-tests Do not include unit tests into build.
--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-openssl=DIR Path to OpenSSL installation root
--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-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-openssl=*) cmake_openssl_root="${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_INSTALL_PREFIX PATH "${cmake_install_prefix}"
append_cache_entry CMAKE_OSX_ARCHITECTURES STRING "${cmake_osx_architectures}"
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