-
Notifications
You must be signed in to change notification settings - Fork 87
/
configure
executable file
·269 lines (246 loc) · 6.99 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
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
#!/usr/bin/env bash
# Copyright (c) 2013 - 2014, Petr Bena
# All rights reserved.
# Redistribution and use in source and binary forms, with
# or without modification, are permitted provided that
# the following conditions are met:
# 1. Redistributions of source code must retain
# the above copyright notice, this list
# of conditions and the following disclaimer.
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in
# the documentation and/or other materials provided with the distribution.
# 3. Neither the name of Huggle nor the names of its contributors may be used
# to endorse or promote products derived from this software without specific
# prior written permission.
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS
# OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
# MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
# THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT
# OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
# EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
SKIPCHECKS=0
modules=0
RED=$(tput setaf 1)
WARN=$(tput setaf 3)
GREEN=$(tput setaf 2)
NORMAL=$(tput sgr0)
CMAKE_ARGS=''
_BUILD=0
_Q=0
QTPATH=''
WEBENG=0
QTVERSION=5
USEDEBUG=0
HAS_PREFIX=0
PREFIX=""
BUILD='release'
BUILD_CHANGED=0
if [ x"$*" != x ];then
echo "Options used: $*"
fi
# first we parse all arguments we got
for var in $@
do
if [ "$var" = "--help" ] || [ "$var" = "-h" ];then
echo "Configure script for huggle, parameters:"
echo "=========================================="
echo " --debug: build a debuggable huggle"
echo " --disable-dependency-tracking: skip all package checks"
echo " --extension: will build all extensions as well"
echo " --qt6: use qt6 instead of qt5"
echo " --qtpath: path to Qt (for example C:\\Qt\\5.4\\mingw\\"
echo " --folder <folder>: change the default build folder"
echo " --no-audio: don't build huggle with audio engine"
echo " --no-colors: suppress colors"
echo " --prefix: specify prefix for installation path"
echo " --enable-profiler: compile built-in profiler"
echo " --tests: unit tests"
echo " --web-engine: use web engine instead of web kit"
echo " --version: show version"
echo
echo "Copyright (c) 2013 - 2018 Petr Bena and Huggle team. This script is licensed under the BSD license."
exit 0
fi
if [ "$HAS_PREFIX" = "1" ];then
HAS_PREFIX=0
PREFIX=$var
continue
fi
if [ "$_BUILD" = "1" ];then
BUILD="$var"
BUILD_CHANGED=1
_BUILD=0
continue
fi
if [ "$_Q" = "1" ];then
_Q=0
QTPATH=$var
continue
fi
if [ "$var" = "--no-audio" ];then
CMAKE_ARGS="$CMAKE_ARGS -DAUDIO=false"
continue
fi
if [ "$var" = "--extension" ];then
modules=1
continue
fi
if [ "$var" = "--prefix" ];then
HAS_PREFIX=1
continue
fi
if [ "$var" = "--qtpath" ];then
_Q=1
continue
fi
if [ "$var" = "--no-colors" ];then
RED=""
WARN=""
GREEN=""
NORMAL=""
fi
if [ "$var" = "--folder" ];then
_BUILD=1
continue
fi
if [ "$var" = "--version" ];then
echo "Huggle configure v 1.2"
exit 0
fi
if [ "$var" = "--web-engine" ];then
WEBENG=1
CMAKE_ARGS="$CMAKE_ARGS -DWEB_ENGINE=true"
continue
fi
if [ "$var" = "--enable-profiler" ];then
CMAKE_ARGS="$CMAKE_ARGS -DHUGGLE_PROFILING=true"
continue
fi
if [ "$var" = "--disable-dependency-tracking" ];then
SKIPCHECKS=1
continue
fi
if [ "$var" = "--debug" ];then
USEDEBUG=1
continue
fi
if [ "$var" = "--tests" ];then
CMAKE_ARGS="$CMAKE_ARGS -DHUGGLE_TEST=true"
continue
fi
if [ "$var" = "--qt6" ];then
QTVERSION=6
WEBENG=1
CMAKE_ARGS="$CMAKE_ARGS -DQT6_BUILD=true -DWEB_ENGINE=true"
continue
fi
done
ok()
{
printf '%s%s%s\n' "$GREEN" "[OK]" "$NORMAL"
}
fail()
{
printf '%s%s%s\n' "$RED" "[FAIL]" "$NORMAL"
}
warn()
{
printf '%s%s%s\n' "$WARN" "WARNING!" "$NORMAL"
}
text()
{
MSG="$1"
let COL=$(tput cols)-20-${#MSG}+${#GREEN}+${#NORMAL}
printf '%s%*s' "$MSG" $COL
}
checkhf()
{
text "Check for headers of $1..."
if [ "$SKIPCHECKS" -eq 1 ];then
echo "SKIP"
return 0
fi
if [ -f "$2" ];then
ok
return 0
else
fail
echo "Unable to find headers for $1 ($2)"
echo "try installing dev files for $1"
exit 1
fi
}
if [ "$USEDEBUG" -eq 1 ];then
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=Debug"
if [ "$BUILD_CHANGED" = "0" ];then
BUILD='debug'
fi
else
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_BUILD_TYPE=Release"
fi
echo "Checking all required packages..."
text "Checking for cmake... "
if [ "`which cmake`" = "" ];then
fail
echo "cmake can't be found"
exit 1
fi
ok
if [ -d ".git" ];then
echo "This is a git repository, updating modules..."
git submodule init
git submodule update
fi
if [ ! -d "src/3rd/libirc/libirc" ];then
echo "The libirc directories are missing! Fixing by using a backup file..."
cd "src/3rd" || exit 1
unzip libirc.zip || exit 1
cd - || exit 1
fi
if [ ! -d "src/3rd/yaml-cpp/src" ];then
echo "The yaml-cpp directory is missing! Fixing by using a backup file..."
cd "src/3rd" || exit 1
unzip yaml-cpp.zip || exit 1
cd - || exit 1
fi
text "Executing update.sh... "
cd src/huggle_core || exit 1
if [ ! -f update.sh ];then
fail
echo "update.sh is missing!"
exit 1
fi
sh update.sh || exit 1;ok
text "Checking if version.txt exist... "
if [ ! -f version.txt ];then
fail
echo "Error! unable to create a version file!"
exit 1
fi
ok
cd ../..
if [ x"$PREFIX" != "x" ];then
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_INSTALL_PREFIX:PATH=$PREFIX"
fi
if [ x"$QTPATH" != "x" ];then
CMAKE_ARGS="$CMAKE_ARGS -DCMAKE_PREFIX_PATH:PATH=$QTPATH"
fi
if [ $modules -gt 0 ];then
CMAKE_ARGS="$CMAKE_ARGS -DHUGGLE_EXT=TRUE"
fi
if [ -d "$BUILD" ];then
echo $WARN"WARNING: build directory $BUILD already exist, make sure it's clean"$NORMAL
else
mkdir "$BUILD" || exit 1
fi
cd "$BUILD" || exit 1
echo "$*" > configure_args
cmake ../src $CMAKE_ARGS -Wno-dev || exit 1
echo "Everything is ready, you can build huggle by entering "$BUILD" and typing"
echo "make"
# this isn't normally needed but ensure we return 0 here
exit 0