forked from notepadqq/notepadqq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
configure
executable file
·187 lines (155 loc) · 4.98 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
#!/bin/sh
# Don't set `-e'!
test -n "$QMAKE" || QMAKE="qtchooser -run-tool=qmake -qt=5"
test -n "$LRELEASE" || LRELEASE="qtchooser -run-tool=lrelease -qt=5"
test -n "$MAKE" || MAKE="make"
test -n "$CXX" || CXX="c++"
errorExit() {
echo $1
test x"$2" != x"1" || fail_on_missing="yes"
test $fail_on_missing != "yes" || exit 1
}
help() {
cat << EOF
Usage: ./configure [OPTION]... [VAR=VALUE]...
To assign environment variables (e.g. CFLAGS...), specify them as
VAR=VALUE. See below for descriptions of some of the useful variables.
Defaults for the options are specified in brackets.
-h, --help display this help and exit
--prefix PREFIX,
--prefix=PREFIX install files in PREFIX [/usr/local]
--fail-on-missing return exit 1 if non-optional components are missing
--lrelease COMMAND,
--lrelease=COMMAND specify lrelease command [$LRELEASE]
--qmake COMMAND,
--qmake=COMMAND specify qmake command [$QMAKE]
--qmake-args ARGS arguments to pass directly to qmake
Some influential environment variables:
MAKE make command
CXX C++ compiler
LDFLAGS linker flags, e.g. -L<lib dir> if you have libraries in a
nonstandard directory <lib dir>
CPPFLAGS (Objective) C/C++ preprocessor flags, e.g. -I<include dir> if
you have headers in a nonstandard directory <include dir>
CXXFLAGS C++ compiler flags
EOF
}
# check "toolname/description" "command" errorExit
# set errorExit to 1 for an error exit, otherwise leave it empty.
# examples:
# check "a Git client tool" git
# check c++ g++ 1
check() {
printf "checking for $1... "
t=$(basename $2)
which $t 2>/dev/null 1>/dev/null
test $(echo $?) -eq 0 && echo "$(which $t)" || errorExit "not found!" $3
}
fail_on_missing="no"
while [ "$#" -ge 1 ]; do
key="$1"
shift
case $key in
-h|--help)
help
exit 0
;;
--prefix=*) # --prefix=<something>
PREFIX="${key#*=}"
;;
--prefix) # --prefix <something>
PREFIX="$1"
shift
;;
--fail-on-missing)
fail_on_missing="yes"
;;
--lrelease=*)
LRELEASE="${key#*=}"
;;
--lrelease)
LRELEASE="$1"
shift
;;
--qmake=*)
QMAKE="${key#*=}"
;;
--qmake)
QMAKE="$1"
shift
;;
--qmake-args)
# Leave qmake args in $@
break
;;
*)
echo WARNING: Unknown option "$key"
;;
esac
done
# check for QT5 qmake
printf "checking for QT5 qmake... "
$QMAKE -help 2>/dev/null 1>/dev/null
test $? -eq 0 && echo "$QMAKE" || \
errorExit "not found!\n Try to run configure with \`--qmake /path/to/qmake-executable'." 1
# check for lrelease
printf "checking for lrelease... "
$LRELEASE -help 2>/dev/null 1>/dev/null
test $? -eq 0 && echo "$LRELEASE" || \
errorExit "not found!\n Try to run configure with \`--lrelease /path/to/lrelease-executable'." 1
check c++ "$CXX" 1
# check C++ compiler functionality
rm -f test test.cpp
cat << EOF > test.cpp
#include <iostream>
int main()
{
std::cout << "Hello World!" << std::endl;
return 0;
}
EOF
printf "checking whether c++ compiler builds test program... "
$CXX -o test test.cpp && echo "ok" || errorExit "error!" 1
printf "checking whether c++ compiler supports -std=c++0x... "
rm -f test
$CXX -std=c++0x -o test test.cpp && echo "ok" || errorExit "error!" 1
printf "checking whether compiled test program works... "
./test 2>/dev/null 1>/dev/null && echo "ok" || errorExit "error!" 1
rm -f test test.cpp
check make "$MAKE" 1
check git git
check pkg-config pkg-config
# check for libraries via pkg-config
libraries="Qt5Core Qt5Gui Qt5Network Qt5WebKit Qt5Widgets Qt5WebKitWidgets Qt5PrintSupport Qt5Svg"
which pkg-config 2>/dev/null 1>/dev/null
if [ $(echo $?) -eq 0 ] ; then
for l in $libraries ; do
printf "checking for ${l} library... "
pkg-config --libs $l 2>/dev/null 1>/dev/null
test $(echo $?) -eq 0 && pkg-config --libs $l || errorExit "not found!"
done
fi
# If we're in a git repo and git is installed, update the submodules.
# If ".git" is not found, assume that the complete source
# code is already available.
which git 2>/dev/null 1>/dev/null
if [ -d ".git" ] && [ $(echo $?) -eq 0 ]; then
git submodule init
git submodule update
fi
cmdir=src/editor/libs/codemirror
cmerror="error: CodeMirror submodule not available at \`$cmdir'! Make sure you downloaded the source code using git as specified in README.md."
# check if directory exists
test -d "$cmdir" || errorExit "$cmerror" 1
# check if directory is empty
test "$(ls -A $cmdir)" || errorExit "$cmerror" 1
if [ -f "Makefile" ]; then
make distclean 2>/dev/null 1>/dev/null || true
fi
printf "generate Makefile... "
$QMAKE PREFIX="$PREFIX" \
QMAKE_CXX="$CXX" \
QMAKE_CXXFLAGS="$CXXFLAGS $CPPFLAGS" \
QMAKE_LFLAGS="$LDFLAGS" \
LRELEASE="$LRELEASE" \
"$@" notepadqq.pro && echo "done" || errorExit "error!" 1