-
Notifications
You must be signed in to change notification settings - Fork 77
/
Copy pathconfigure
executable file
·211 lines (177 loc) · 5.77 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
#!/bin/sh
set -u
CLANG_VER=4.0
SRCDIR=$(cd "$(dirname "$0")" && pwd)
usage() {
cat <<EOF
Usage: $0 [options]
Configures CxxCodeBrowser and runs qmake to generate makefiles.
Installation directories:
--prefix=PREFIX Base path for build/install. Default: /usr/local
Dependency options:
--with-clang-dir=CLANG_DIR
Root of Clang $CLANG_VER installation. This path
should identify a Clang installation directory
containing bin, lib, and include directories. It
should not refer to a Clang build directory.
--with-qmake=QMAKE [optional]
Configure the qmake binary to use. By default,
the configure script searches the PATH for qmake.
--with-qmake-spec=QMAKESPEC [optional]
Forcibly set the -spec passed to qmake.
EOF
}
CLANG_DIR=
PREFIX=
QMAKE=
QMAKESPEC=
QMAKE_FLAGS=
while [ $# -gt 0 ]; do
ARG=$1
case $ARG in
--prefix|--with-clang-dir|--with-qmake|--with-qmake-spec)
shift
ARG=$ARG=$1
esac
case $ARG in
--prefix=*) PREFIX=${ARG#*=}; shift;;
--with-clang-dir=*) CLANG_DIR=${ARG#*=}; shift;;
--with-qmake=*) QMAKE=${ARG#*=}; shift;;
--with-qmake-spec=*) QMAKESPEC=${ARG#*=}; shift;;
-h|--help) usage; exit 0;;
*) echo "$0: error: Unrecognized argument $ARG"; exit 1;;
esac
done
require_absolute_path() {
local PATH_NAME=$1
local PATH_VALUE=$2
if [ "${PATH_VALUE#/}" = "$PATH_VALUE" ]; then
echo "$0: error: $PATH_NAME path must be absolute."
exit 1
fi
}
PREFIX=${PREFIX:-/usr/local}
require_absolute_path --prefix "$PREFIX"
################################################################################
# Find a Clang library installation.
find_clang() {
local CANDIDATE=$1
echo " - trying $CANDIDATE..."
if [ ! -d "$CANDIDATE" ]; then
echo " - failed $CANDIDATE... does not exist"
return
fi
for ITEM in \
include/clang/AST/ASTContext.h \
lib/libclangTooling.a \
lib/libLLVMCore.a \
; do
ITEM_PATH=$CANDIDATE/$ITEM
if [ ! -f "$ITEM_PATH" ]; then
echo " - failed $CANDIDATE... $ITEM_PATH does NOT exist"
return
fi
echo " - trying $CANDIDATE... $ITEM_PATH exists"
done
echo " - found $CANDIDATE"
CLANG_DIR=$CANDIDATE
}
if [ "$CLANG_DIR" = "" ]; then
if [ -f "/etc/arch-release" ]; then
# ArchLinux has a different layout for clang
TMP_CLANG_DIR=/usr
elif [ "$(uname)" = "Linux" ]; then
TMP_CLANG_DIR=/usr/lib/llvm-$CLANG_VER
fi
echo "Searching for Clang $CLANG_VER..."
find_clang $TMP_CLANG_DIR
fi
if [ "$CLANG_DIR" = "" ]; then
if [ "$(uname)" = "Linux" ]; then
echo "$0: error: Could not find Clang $CLANG_VER. Either install it or specify"
echo "--with-clang-dir. Installation options:"
echo " - Debian/Ubuntu: sudo apt-get install libclang-${CLANG_VER}-dev llvm-${CLANG_VER}-dev"
echo " - Prebuilt binaries are available at llvm.org for some systems."
echo " - Compile LLVM from source."
else
echo "$0: error: A Clang $CLANG_VER directory must be specified using --with-clang-dir."
fi
exit 1
fi
require_absolute_path --with-clang-dir "$CLANG_DIR"
################################################################################
# Find qmake.
if [ -n "$QMAKE" -a \( ! -f "$QMAKE" -o ! -x "$QMAKE" \) ]; then
echo "$0: error: $QMAKE does not exist or is not an executable file."
exit 1
fi
if [ -z "$QMAKE" ]; then
echo "Looking for qmake..."
echo "- which qmake-qt4"
which qmake-qt4 > /dev/null
if [ $? -eq 0 ]; then
QMAKE=$(which qmake-qt4)
echo "- found $QMAKE"
else
echo "- found nothing"
echo "- which qmake"
which qmake > /dev/null
if [ $? -eq 0 ]; then
QMAKE=$(which qmake)
echo "- found $QMAKE"
else
echo "- found nothing"
echo "- error: Could not find qmake"
exit 1
fi
fi
else
echo "Using configured qmake... $QMAKE"
fi
################################################################################
# The default mkspec for Qt4 qmake on OS X generates an Xcode project file.
# Qt5 seems to work.
if [ "$(uname)" = "Darwin" -a "$QMAKESPEC" = "" ]; then
if "$QMAKE" -v 2>&1 | grep '^Using Qt version 4\.' > /dev/null; then
# enable-cxx11.pri will configure libc++ and the deployment target.
QMAKESPEC=unsupported/macx-clang
echo "The default OS X qmake spec is not suitable. Setting it to $QMAKESPEC."
fi
fi
if [ -n "$QMAKESPEC" ]; then
QMAKE_FLAGS="$QMAKE_FLAGS -spec $QMAKESPEC"
fi
################################################################################
# Test C++11 support using qmake.
run_test()
{
echo "- running: $@"
"$@" >cxx11-compat-test.log 2>&1
}
# Test that the qmake configuration is working and has sufficient C++11 support.
echo "Testing C++11 support using $QMAKE..."
run_test "$SRCDIR/cxx11-compat-test/run-test.sh" "$QMAKE" $QMAKE_FLAGS
if [ $? -ne 0 ]; then
echo "- Command failed. Output of $PWD/cxx11-compat-test.log:"
while read LINE; do
echo " $LINE"
done < cxx11-compat-test.log
exit 1
fi
echo "- test passed"
################################################################################
# Invoke qmake.
run_qmake()
{
echo "running: $@"
"$@"
}
run_qmake "$QMAKE" -r "$SRCDIR/CxxCodeBrowser.pro" $QMAKE_FLAGS \
PREFIX="$PREFIX" CLANG_DIR="$CLANG_DIR"
if [ $? -ne 0 ]; then
echo qmake failed
exit 1
fi
echo ""
echo "SUCCESS: Run make [-j JOBS], then [sudo] make install to build."
echo ""