forked from actor-framework/actor-framework
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·465 lines (422 loc) · 15.2 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
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
#!/bin/sh
# Convenience wrapper for easily viewing/setting options that
# the project's CMake scripts will recognize.
# check for `cmake` command
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;
}
command="$0 $*"
dirname_0=`dirname $0`
sourcedir=`cd $dirname_0 && pwd`
usage="\
Usage: $0 [OPTION]... [VAR=VALUE]...
Build Options:
--generator=GENERATOR set CMake generator (see cmake --help)
--build-type=TYPE set CMake build type [RelWithDebInfo]:
- Debug: debugging flags enabled
- MinSizeRel: minimal output size
- Release: optimizations on, debugging off
- RelWithDebInfo: release flags plus debugging
--build-dir=DIR place build files in directory [build]
--bin-dir=DIR executable directory [build/bin]
--lib-dir=DIR library directory [build/lib]
--with-clang=FILE path to clang++ executable
--with-gcc=FILE path to g++ executable
--with-qt-prefix=PATH prefix path for Qt5 cmake modules
--with-openssl=PATH path to OpenSSL library and headers
--dual-build build using both gcc and clang
--build-static build as static and shared library
--build-static-only build as static library only
--static-runtime build with static C++ runtime
--more-warnings enables most warnings
--no-compiler-check disable compiler version check
--no-auto-libc++ do not automatically enable libc++ for Clang
--no-exceptions do not catch exceptions in CAF
--force-no-exceptions build CAF with '-fno-exceptions'
--warnings-as-errors build with '-Werror'
--with-ccache use ccache to improve build performance
Additional Examples:
--with-qt-examples include Qt example(s)
--with-protobuf-examples include Google Protobuf example(s)
Installation Directories:
--prefix=PREFIX installation directory [/usr/local]
Remove Standard Features (even if all dependencies are available):
--no-memory-management build without memory management
--no-examples build without examples
--no-curl-examples build without libcurl examples
--no-unit-tests build without unit tests
--no-opencl build without OpenCL module
--no-openssl build without OpenSSL module
--no-benchmarks build without benchmarks
--no-tools build without CAF tools such as caf-run
--no-io build without I/O module
--no-python build without python binding
--no-summary do not print configuration before building
--core-only sets no-examples, no-opencl, no-openssl,
no-tools, no-python, and no-io
Debugging:
--with-runtime-checks build with requirement checks at runtime
--with-log-level=LVL build with debugging output, possible values:
- ERROR
- WARNING
- INFO
- DEBUG
- TRACE
--with-address-sanitizer build with address sanitizer if available
--with-asan alias for --with-address-sanitier
--enable-asan alias for --with-address-sanitier
--with-gcov build with gcov coverage enabled
Convenience options:
--dev-mode sets --build-type=debug, --no-examples,
--no-tools, --with-runtime-checks,
--log-level=trace, and --enable-asan
Influential Environment Variables (only on first invocation):
CXX C++ compiler command
CXXFLAGS C++ compiler flags
LDFLAGS Additional linker flags
CMAKE_GENERATOR Selects a custom generator
Python Build Options:
--with-python-config=FILE Use python-conf binary to determine includes and libs
iOS Build Options (should be used with XCode generator):
--sysroot=DIR set system root for Clang
- iphoneos: for iOS device
- iphonesimulator: for iOS simulator
--ios-min-ver=VERSION set the ios deployment target version
"
# Appends 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 ()
{
case "$3" in
*\ * )
# string contains whitespace
CMakeCacheEntries="$CMakeCacheEntries -D \"$1:$2=$3\""
;;
*)
# string contains whitespace
CMakeCacheEntries="$CMakeCacheEntries -D $1:$2=$3"
;;
esac
}
# Creates a build directory via CMake.
# $1 is the path to a compiler executable.
# $2 is the suffix of the build directory.
# $3 is the executable output path.
# $4 is the library output path.
# $5 is the CMake generator.
configure ()
{
CMakeCacheEntries=$CMakeDefaultCache
if [ -n "$1" ]; then
append_cache_entry CMAKE_CXX_COMPILER FILEPATH $1
fi
case "$builddir" in
/*)
#absolute path given
absolute_builddir="$builddir"
;;
*)
# relative path given; convert to absolute path
absolute_builddir="$PWD/$builddir"
;;
esac
if [ -n "$2" ]; then
workdir="$absolute_builddir-$2"
else
workdir="$absolute_builddir"
fi
workdirs="$workdirs $workdir"
if [ -n "$3" ]; then
append_cache_entry EXECUTABLE_OUTPUT_PATH PATH "$3"
else
append_cache_entry EXECUTABLE_OUTPUT_PATH PATH "$workdir/bin"
fi
if [ -n "$4" ]; then
append_cache_entry LIBRARY_OUTPUT_PATH PATH "$4"
else
append_cache_entry LIBRARY_OUTPUT_PATH PATH "$workdir/lib"
fi
if [ -d "$workdir" ]; then
# If a build directory exists, check if it has a CMake cache.
if [ -f "$workdir/CMakeCache.txt" ]; then
# If the CMake cache exists, delete it so that this configuration
# is not tainted by a previous one.
rm -f "$workdir/CMakeCache.txt"
fi
else
mkdir -p "$workdir"
fi
cd "$workdir"
if [ -n "$5" ]; then
cmake -G "$5" $CMakeCacheEntries "$sourcedir"
else
cmake $CMakeCacheEntries "$sourcedir"
fi
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\"\n" "$CC" >> config.status
fi
if [ -n "$CXX" ]; then
printf "CXX=\"%s\"\n" "$CXX" >> config.status
fi
if [ -n "$CXXFLAGS" ]; then
printf "CXXFLAGS=\"%s\"\n" "$CXXFLAGS" >> config.status
fi
if [ -n "$LDFLAGS" ]; then
printf "LDFLAGS=\"%s\"\n" "$LDFLAGS" >> config.status
fi
echo $command >> config.status
chmod u+x config.status
}
# Set defaults.
builddir="$sourcedir/build"
CMakeCacheEntries=""
append_cache_entry CMAKE_INSTALL_PREFIX PATH /usr/local
append_cache_entry CAF_ENABLE_RUNTIME_CHECKS BOOL false
# parse custom environment variable to initialize CMakeGenerator
if [ -n "$CMAKE_GENERATOR" ]; then
CMakeGenerator="$CMAKE_GENERATOR"
fi
# Parse 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
;;
--generator=*)
CMakeGenerator="$optarg"
;;
--prefix=*)
append_cache_entry CMAKE_INSTALL_PREFIX PATH "$optarg"
;;
--with-runtime-checks)
append_cache_entry CAF_ENABLE_RUNTIME_CHECKS BOOL yes
;;
--with-address-sanitizer)
append_cache_entry CAF_ENABLE_ADDRESS_SANITIZER BOOL yes
;;
--with-asan)
append_cache_entry CAF_ENABLE_ADDRESS_SANITIZER BOOL yes
;;
--enable-asan)
append_cache_entry CAF_ENABLE_ADDRESS_SANITIZER BOOL yes
;;
--with-gcov)
append_cache_entry CAF_ENABLE_GCOV BOOL yes
;;
--no-memory-management)
append_cache_entry CAF_NO_MEM_MANAGEMENT BOOL yes
;;
--more-warnings)
append_cache_entry CAF_MORE_WARNINGS BOOL yes
;;
--no-compiler-check)
append_cache_entry CAF_NO_COMPILER_CHECK BOOL yes
;;
--no-auto-libc++)
append_cache_entry CAF_NO_AUTO_LIBCPP BOOL yes
;;
--no-exceptions)
append_cache_entry CAF_NO_EXCEPTIONS BOOL yes
;;
--force-no-exceptions)
append_cache_entry CAF_NO_EXCEPTIONS BOOL yes
append_cache_entry CAF_FORCE_NO_EXCEPTIONS BOOL yes
;;
--warnings-as-errors)
append_cache_entry CAF_CXX_WARNINGS_AS_ERRORS BOOL yes
;;
--with-ccache)
append_cache_entry CAF_USE_CCACHE BOOL yes
;;
--sysroot=*)
append_cache_entry CAF_OSX_SYSROOT PATH "$optarg"
;;
--ios-min-ver=*)
append_cache_entry CMAKE_OSX_ARCHITECTURES STRING "\$(ARCHS_STANDARD_32_64_BIT)"
append_cache_entry CAF_IOS_DEPLOYMENT_TARGET STRING "$optarg"
;;
--with-log-level=*)
level=`echo "$optarg" | tr '[:lower:]' '[:upper:]'`
case $level in
ERROR)
append_cache_entry CAF_LOG_LEVEL STRING 0
;;
WARNING)
append_cache_entry CAF_LOG_LEVEL STRING 1
;;
INFO)
append_cache_entry CAF_LOG_LEVEL STRING 2
;;
DEBUG)
append_cache_entry CAF_LOG_LEVEL STRING 3
;;
TRACE)
append_cache_entry CAF_LOG_LEVEL STRING 4
;;
*)
echo "Invalid log level '$level'. Try '$0 --help' to see valid values."
exit 1
;;
esac
;;
--with-clang=*)
clang="$optarg"
;;
--with-gcc=*)
gcc="$optarg"
;;
--with-qt-prefix=*)
append_cache_entry CAF_QT_PREFIX_PATH STRING "$optarg"
;;
--with-openssl=*)
append_cache_entry OPENSSL_ROOT_DIR PATH "$optarg"
;;
--build-type=*)
append_cache_entry CMAKE_BUILD_TYPE STRING "$optarg"
;;
--build-dir=*)
builddir="$optarg"
;;
--bin-dir=*)
bindir="$optarg"
;;
--lib-dir=*)
libdir="$optarg"
;;
--dual-build)
dualbuild=1
;;
--no-examples)
append_cache_entry CAF_NO_EXAMPLES BOOL yes
;;
--with-qt-examples)
append_cache_entry CAF_BUILD_QT_EXAMPLES BOOL yes
;;
--with-protobuf-examples)
append_cache_entry CAF_BUILD_PROTOBUF_EXAMPLES BOOL yes
;;
--no-curl-examples)
append_cache_entry CAF_NO_CURL_EXAMPLES BOOL yes
;;
--no-unit-tests)
append_cache_entry CAF_NO_UNIT_TESTS BOOL yes
;;
--no-opencl)
append_cache_entry CAF_NO_OPENCL BOOL yes
;;
--no-openssl)
append_cache_entry CAF_NO_OPENSSL BOOL yes
;;
--build-static)
append_cache_entry CAF_BUILD_STATIC BOOL yes
;;
--build-static-only)
append_cache_entry CAF_BUILD_STATIC_ONLY BOOL yes
;;
--static-runtime)
append_cache_entry CAF_BUILD_STATIC_RUNTIME BOOL yes
;;
--with-python-config=*)
append_cache_entry CAF_PYTHON_CONFIG_BIN FILEPATH "$optarg"
;;
--no-benchmarks)
append_cache_entry CAF_NO_BENCHMARKS BOOL yes
;;
--no-tools)
append_cache_entry CAF_NO_TOOLS BOOL yes
;;
--no-io)
append_cache_entry CAF_NO_IO BOOL yes
;;
--no-python)
append_cache_entry CAF_NO_PYTHON BOOL yes
;;
--no-summary)
append_cache_entry CAF_NO_SUMMARY BOOL yes
;;
--core-only)
append_cache_entry CAF_NO_TOOLS BOOL yes
append_cache_entry CAF_NO_IO BOOL yes
append_cache_entry CAF_NO_PYTHON BOOL yes
append_cache_entry CAF_NO_EXAMPLES BOOL yes
append_cache_entry CAF_NO_OPENCL BOOL yes
append_cache_entry CAF_NO_OPENSSL BOOL yes
;;
--dev-mode)
append_cache_entry CMAKE_BUILD_TYPE STRING Debug
append_cache_entry CAF_NO_EXAMPLES BOOL yes
append_cache_entry CAF_NO_TOOLS BOOL yes
append_cache_entry CAF_LOG_LEVEL STRING 4
append_cache_entry CAF_ENABLE_RUNTIME_CHECKS BOOL yes
append_cache_entry CAF_ENABLE_ADDRESS_SANITIZER BOOL yes
;;
*)
echo "Invalid option '$1'. Try $0 --help to see available options."
exit 1
;;
esac
shift
done
# At this point we save the global CMake variables so that configure() can
# later use them.
CMakeDefaultCache=$CMakeCacheEntries
if [ -n "$dualbuild" ]; then
# Use what we got in $PATH if --with-clang or --with-gcc is not specified.
if [ -z "$clang" ]; then
clang=clang++
fi
if [ -z "$gcc" ]; then
gcc=g++
fi
for i in gcc clang; do
eval "compiler=\$$i"
configure $compiler $i "" "" $CMakeGenerator
done
else
# Prefer Clang to GCC.
if [ -n "$clang" ]; then
compiler=$clang
elif [ -n "$gcc" ]; then
compiler=$gcc
fi
configure "$compiler" "" "$bindir" "$libdir" "$CMakeGenerator"
fi
if [ -n "$CMakeGenerator" ] && [ "$CMakeGenerator" != "Unix" ]; then
# skip Makefile-specific code below when not using make
exit 0
fi
printf "DIRS := %s\n\n" "$workdirs" > $sourcedir/Makefile
makefile=`cat <<'EOT'
all:
@for i in $(DIRS); do $(MAKE) -C $$i $@ || exit; done
test:
@for i in $(DIRS); do $(MAKE) -C $$i $@ || exit; done
install:
@for i in $(DIRS); do $(MAKE) -C $$i $@ || exit; done
uninstall:
@for i in $(DIRS); do $(MAKE) -C $$i $@ || exit; done
clean:
@for i in $(DIRS); do $(MAKE) -C $$i $@; done
distclean:
rm -rf $(DIRS) Makefile
doc:
$(MAKE) -C $(firstword $(DIRS)) $@
.PHONY: all test install uninstall clean distclean doc
EOT
`
echo "$makefile" >> $sourcedir/Makefile