forked from tenzir/tenzir
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·221 lines (203 loc) · 5.98 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
218
219
220
221
#!/bin/sh
# Convenience wrapper for easily viewing/setting options that
# the project's CMake scripts will recognize
type cmake > /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;
}
# Save some values for later before parsing the command line.
if [ -n "$*" ]; then
args=$(printf " \"%s\"" $*)
fi
command="$0$args"
sourcedir="$(cd "$(dirname "$0")" && pwd)"
usage="\
Usage: $0 [OPTION]... [VAR=VALUE]...
Installation directories:
--prefix=PREFIX installation directory [/usr/local]
Build options:
--generator=GENERATOR CMake generator to use (see cmake --help)
--build-type=DIR CMake build type [RelWithDebInfo]
--build-dir=DIR directory where to perform build [build]
--show-time-report show where the compiler spends its time
--no-auto-libc++ do not automatically use libc++ with Clang
Debugging:
--log-level=LEVEL maximum compile-time log level [debug]
--disable-assertions disable assertions
--enable-asan enable AddressSanitizer
--enable-gcov enable GCOV
Optional features:
--enable-tcmalloc link against tcmalloc (requires gperftools)
Required packages in non-standard locations:
--with-caf=PATH path to CAF install root or build directory
Optional packages in non-standard locations:
--with-snappy=PATH path to Snappy install root
--with-pcap=PATH path to libpcap install root
--with-perftools=PATH path to gperftools install root
--with-doxygen=PATH path to Doxygen install root
"
# Function to append a CMake cache entry definition to the
# CMakeCacheEntries 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() {
CMakeCacheEntries="$CMakeCacheEntries -D \"$1:$2=$3\""
}
levelize() {
case "$1" in
quiet)
echo -1
;;
error)
echo 0
;;
warning)
echo 1
;;
info)
echo 2
;;
debug)
echo 3
;;
trace)
echo 4
;;
*)
echo "invalid log level specification, use:"
echo " quiet|error|warning|info|debug|trace"
exit 1;
esac
}
# Set defaults
builddir=build
CMakeCacheEntries=""
append_cache_entry CMAKE_INSTALL_PREFIX PATH /usr/local
append_cache_entry CMAKE_BUILD_TYPE STRING RelWithDebInfo
append_cache_entry VAST_ENABLE_ASSERTIONS BOOL true
append_cache_entry VAST_LOG_LEVEL INTEGER $(levelize debug)
append_cache_entry VAST_USE_TCMALLOC BOOL false
# Parse command line arguments.
while [ $# -ne 0 ]; do
case "$1" in
-*=*)
optarg="$(echo "$1" | sed 's/[-_a-zA-Z0-9]*=//')"
;;
*)
optarg=
;;
esac
case "$1" in
--help|-h)
echo "${usage}" 1>&2
exit 1
;;
--prefix=*)
append_cache_entry VAST_PREFIX PATH "$optarg"
append_cache_entry CMAKE_INSTALL_PREFIX PATH "$optarg"
;;
--generator=*)
CMakeGenerator="$optarg"
;;
--build-dir=*)
builddir="$optarg"
;;
--build-type=*)
append_cache_entry CMAKE_BUILD_TYPE STRING "$optarg"
;;
--show-time-report)
append_cache_entry SHOW_TIME_REPORT BOOL true
;;
--no-auto-libc++)
append_cache_entry NO_AUTO_LIBCPP BOOL yes
;;
--log-level=*)
append_cache_entry VAST_LOG_LEVEL INTEGER $(levelize $optarg)
;;
--disable-assertions)
append_cache_entry VAST_ENABLE_ASSERTIONS BOOL false
;;
--enable-asan)
append_cache_entry ENABLE_ADDRESS_SANITIZER BOOL true
;;
--enable-gcov)
append_cache_entry ENABLE_GCOV BOOL true
;;
--enable-tcmalloc)
append_cache_entry VAST_USE_TCMALLOC BOOL true
;;
--with-caf=*)
append_cache_entry CAF_ROOT_DIR PATH "$optarg"
;;
--with-snappy=*)
append_cache_entry SNAPPY_ROOT_DIR PATH "$optarg"
;;
--with-pcap=*)
append_cache_entry PCAP_ROOT_DIR PATH "$optarg"
;;
--with-perftools=*)
append_cache_entry Gperftools_ROOT_DIR PATH "$optarg"
;;
--with-doxygen=*)
append_cache_entry Doxygen_ROOT_DIR PATH "$optarg"
;;
*)
echo "Invalid option '$1'. Try $0 --help to see available options."
exit 1
;;
esac
shift
done
if [ -d "$builddir" ]; then
# If build directory exists, check if it has a CMake cache
if [ -f "$builddir/CMakeCache.txt" ]; then
# If the CMake cache exists, delete it so that this configuration
# is not tainted by a previous one
rm -f "$builddir/CMakeCache.txt"
fi
else
mkdir -p "$builddir"
fi
cd "$builddir"
# In order to support spaces in paths, we use eval to re-evaluate the command
# line before passing it to CMake.
cmake=cmake
if [ -n "$CMakeGenerator" ]; then
cmake="$cmake -G \"$CMakeGenerator\""
fi
cmake="$cmake $CMakeCacheEntries \"$sourcedir\""
eval $cmake
printf "#!/bin/sh\n\n" > config.status
printf "# Switch to the source of this build directory.\n" >> config.status
printf "cd \"$sourcedir\"\n\n" >> config.status
printf "# Invoke the command to configure this build.\n" >> config.status
if [ -n "$CC" ]; then
printf 'CC="%s" ' "$CC" >> config.status
fi
if [ -n "$CXX" ]; then
printf 'CXX="%s" ' "$CXX" >> config.status
fi
if [ -n "$CXXFLAGS" ]; then
printf 'CXXFLAGS="%s" ' "$CXXFLAGS" >> config.status
fi
printf "$command\n" $@ >> config.status
chmod u+x config.status
makefile="$sourcedir/Makefile"
if [ -f "$makefile" ]; then
if ! head -n 1 "$makefile" | cut -d ' ' -f 2- | grep -q "\"$builddir\""; then
sed -i.orig "s/\(DIRS=.*\)/\1 \"$builddir\"/" "$makefile"
rm "$makefile.orig"
echo "-- added \"$builddir\" to top-level Makefile" 1>&2
fi
else
printf "DIRS= \"%s\" \n\n" "$builddir" > "$makefile"
if [ "$(uname -s)" = "FreeBSD" ]; then
printf ".include \".Makefile.BSD\"" >> "$makefile"
else
printf "include .Makefile.GNU" >> "$makefile"
fi
fi