-
Notifications
You must be signed in to change notification settings - Fork 15
/
configure
executable file
·215 lines (191 loc) · 5.96 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
#!/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:
--prefix=DIR CMake install directory
--build-dir=DIR CMake build directory
--build-type=STRING CMake build type
--with-javac=FILE path to Java compiler
--with-java=FILE path to Java Runtime
--with-scalac=FILE path to Scala compiler
--with-erlc=FILE path to Erlang compiler
--with-charmc=FILE path to Charm++ compiler
--with-salsa=FILE path to SALSA Lite jar
--with-caf=DIR path to CAF installation
Influential Environment Variables (only on first invocation):
CXX C++ compiler command
CXXFLAGS C++ compiler flags
DEFAULT_CMAKE_GENERATOR Selects a custom generator
"
# 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 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 [ -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 "$4" ]; then
cmake -G "$4" $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
echo $command >> config.status
chmod u+x config.status
}
# Set defaults.
builddir="$sourcedir/build"
CMakeCacheEntries=""
# parse custom environment variable to initialize CMakeGenerator
if [ -n "$DEFAULT_CMAKE_GENERATOR" ]; then
CMakeGenerator="$DEFAULT_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
;;
--prefix=*)
append_cache_entry CMAKE_INSTALL_PREFIX PATH "$optarg"
;;
--build-dir=*)
builddir="$optarg"
;;
--build-type=*)
append_cache_entry CMAKE_BUILD_TYPE STRING "$optarg"
;;
--generator=*)
CMakeGenerator="$optarg"
;;
--with-clang=*)
clang=$optarg
;;
--with-gcc=*)
gcc=$optarg
;;
--with-javac=*)
append_cache_entry CAF_JAVA_COMPILER FILEPATH "$optarg"
;;
--with-java=*)
append_cache_entry CAF_JAVA_BIN FILEPATH "$optarg"
;;
--with-scalac=*)
append_cache_entry CAF_SCALA_COMPILER FILEPATH "$optarg"
;;
--with-erlc=*)
append_cache_entry CAF_ERLANG_COMPILER FILEPATH "$optarg"
;;
--with-charmc=*)
append_cache_entry CAF_CHARM_COMPILER FILEPATH "$optarg"
;;
--with-salsa=*)
append_cache_entry CAF_SALSA_JAR FILEPATH "$optarg"
;;
--with-caf=*)
append_cache_entry CAF_ROOT FILEPATH "$optarg"
;;
--caf-tag=*)
tag="$optarg"
append_cache_entry CAF_TAG STRING "$tag"
;;
*)
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
# Prefer Clang to GCC.
if [ -n "$clang" ]; then
compiler=$clang
elif [ -n "$gcc" ]; then
compiler=$gcc
fi
configure "$compiler" "" "$bindir" "$CMakeGenerator"