forked from rprichard/CxxCodeBrowser
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathconfigure
executable file
·164 lines (138 loc) · 4.87 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
#!/bin/sh
CLANG_VER=3.2
SRCDIR=$(cd "$(dirname "$0")" && pwd)
usage() {
cat <<EOF
Usage: $0 [options]
Configures SourceWeb 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.
EOF
}
QMAKE=
while [ $# -gt 0 ]; do
ARG=$1
case $ARG in
--prefix|--with-clang-dir|--with-qmake)
shift
ARG=$ARG=$1
esac
case $ARG in
--prefix=*) PREFIX=${ARG#*=}; shift;;
--with-clang-dir=*) CLANG_DIR=${ARG#*=}; shift;;
--with-qmake=*) QMAKE=${ARG#*=}; shift;;
-h|--help) usage; exit 0;;
*) echo "$0: error: Unrecognized argument $ARG"; exit 1;;
esac
done
PREFIX=${PREFIX:-/usr/local}
if [ "$CLANG_DIR" = "" ]; then
echo "$0: error: A Clang $CLANG_VER directory must be specified using --with-clang-dir."
exit 1
fi
if [ "${CLANG_DIR#/}" = "$CLANG_DIR" ]; then
echo "$0: error: --with-clang-dir path must be absolute."
exit 1
fi
if [ "${PREFIX#/}" = "$PREFIX" ]; then
echo "$0: error: --prefix path must be absolute."
exit 1
fi
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
################################################################################
# Find qmake.
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
QMAKE_FLAGS=""
################################################################################
# On Linux, build the project using the same Clang compiler used to index code.
# Many current Linux distributions lack a C++11 toolchain, so reusing the
# indexing compiler is convenient.
if [ "$(uname)" = "Linux" ]; then
# Ideally, we would also change the spec file to unsupported/linux-clang
# on Linux, but that spec file does not exist in Qt 4.6, which many current
# distributions still use.
QMAKE_FLAGS="$QMAKE_FLAGS QMAKE_CC=$CLANG_DIR/bin/clang"
QMAKE_FLAGS="$QMAKE_FLAGS QMAKE_CXX=$CLANG_DIR/bin/clang++"
QMAKE_FLAGS="$QMAKE_FLAGS QMAKE_LINK=$CLANG_DIR/bin/clang++"
fi
################################################################################
# The default mkspec for Qt4 qmake on OS X generates an Xcode project file.
# The default for Qt5 generates a Makefile, but it uses libstdc++ and sets the
# deployment target to 10.6. Select an appropriate spec file unless the user
# overrides it using QMAKESPEC.
if [ "$(uname)" = "Darwin" -a "$QMAKESPEC" = "" ]; then
echo "The default qmake spec is not suitable. Overriding it."
if "$QMAKE" -v 2>&1 | grep '^Using Qt version 4\.' > /dev/null; then
# enable-cxx11.pri will configure libc++ and the deployment target.
QMAKE_FLAGS="$QMAKE_FLAGS -spec unsupported/macx-clang"
else
# Assume qmake is from Qt5, which has a spec selecting Clang and
# libc++, which is needed for C++11 support.
QMAKE_FLAGS="$QMAKE_FLAGS -spec macx-clang-libc++"
fi
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/sourceweb.pro" $QMAKE_FLAGS \
PREFIX="$PREFIX" CLANG_DIR="$CLANG_DIR"
if [ $? -ne 0 ]; then
echo qmake failed
exit 1
fi