-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure
executable file
·199 lines (170 loc) · 6.02 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
#!/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
--extra-flags=STRING additional compiler flags
--build-dir=DIR place build files in directory [build]
--bin-dir=DIR executable directory [build/bin]
--lib-dir=DIR library directory [build/lib]
--no-compiler-check disable compiler version check
--no-auto-libc++ do not automatically enable libc++ for Clang
Required packages in non-standard locations:
--with-caf=PATH path to CAF install root or build directory
Installation Directories:
--prefix=PREFIX installation directory [/usr/local]
Debugging:
--enable-asan build with address sanitizer
Influential Environment Variables (only on first invocation):
CXX C++ compiler command
CXXFLAGS C++ compiler flags (overrides defaults)
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
}
# -- set defaults --------------------------------------------------------------
builddir="$sourcedir/build"
CMakeCacheEntries=""
append_cache_entry CMAKE_INSTALL_PREFIX PATH /usr/local
# -- parse custom environment variables ----------------------------------------
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"
;;
--enable-asan)
append_cache_entry ENABLE_ADDRESS_SANITIZER BOOL yes
;;
--no-compiler-check)
append_cache_entry NO_COMPILER_CHECK BOOL yes
;;
--no-auto-libc++)
append_cache_entry NO_AUTO_LIBCPP BOOL yes
;;
--with-caf=*)
append_cache_entry CAF_ROOT_DIR PATH "$optarg"
;;
--build-type=*)
append_cache_entry CMAKE_BUILD_TYPE STRING "$optarg"
;;
--extra-flags=*)
append_cache_entry EXTRA_FLAGS STRING "$optarg"
;;
--build-dir=*)
builddir="$optarg"
;;
--bin-dir=*)
append_cache_entry EXECUTABLE_OUTPUT_PATH PATH "$optarg"
;;
--lib-dir=*)
append_cache_entry LIBRARY_OUTPUT_PATH PATH "$optarg"
;;
*)
echo "Invalid option '$1'. Try $0 --help to see available options."
exit 1
;;
esac
shift
done
# -- CMake setup ---------------------------------------------------------------
CMakeDefaultCache=$CMakeCacheEntries
CMakeCacheEntries=$CMakeDefaultCache
# Set $workdir to the absolute path of $builddir.
case "$builddir" in
/*)
# Absolute path given
workdir="$builddir"
;;
*)
# Relative path given, convert to absolute path.
workdir="$PWD/$builddir"
;;
esac
# Make sure the build directory exists but has no CMakeCache.txt in it.
if [ -d "$workdir" ]; then
if [ -f "$workdir/CMakeCache.txt" ]; then
rm -f "$workdir/CMakeCache.txt"
fi
else
mkdir -p "$workdir"
fi
cd "$workdir"
if [ -n "$CMakeGenerator" ]; then
cmake -G "$CMakeGenerator" $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