-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconfigure
executable file
·304 lines (275 loc) · 7.57 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
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
#!/bin/bash
# Copyright (c) 2013 - 2025, 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 GrumpyChat 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)
QT5=1
QT6=0
USEDEBUG=0
UNIT_TESTS=''
CMAKE_ARGS=''
_BUILD=0
_Q=0
PROFILER=''
QTPATH=''
BUILD=release
HAS_PREFIX=0
PREFIX=""
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 grumpy, parameters:"
echo "=========================================="
echo " --debug: build a debuggable grumpy"
echo " --disable-dependency-tracking: skip all package checks"
echo " --extension: will build all extensions as well"
echo " --unit-test: will build unit tests"
echo " --qtpath: path to Qt (for example C:\\Qt\\5.4\\mingw\\"
echo " --profiler: enable profiler"
echo " --qt5: use Qt5 (default)"
echo " --qt6: use Qt6"
echo " --prefix: specify prefix for installation path"
echo " --folder <folder>: change the default build folder"
echo " --no-colors: suppress colors"
echo " --version: show version"
echo
echo "Copyright (c) 2013 - 2025 Petr Bena. This script is licensed under the BSD license."
exit 0
fi
if [ "$_BUILD" = "1" ];then
BUILD="$var"
_BUILD=0
continue
fi
if [ "$_Q" = "1" ];then
_Q=0
QTPATH=$var
continue
fi
if [ "$HAS_PREFIX" = "1" ];then
HAS_PREFIX=0
PREFIX=$var
continue
fi
if [ "$var" = "--extension" ];then
modules=1
continue
fi
if [ "$var" = "--prefix" ];then
HAS_PREFIX=1
continue
fi
if [ "$var" = "--unit-test" ];then
UNIT_TESTS=' -DUNIT_TESTS=true'
continue
fi
if [ "$var" = "--qtpath" ];then
_Q=1
continue
fi
if [ "$var" = "--no-colors" ];then
RED=""
WARN=""
GREEN=""
NORMAL=""
fi
if [ "$var" = "--qt5" ];then
QT5=1
continue
fi
if [ "$var" = "--qt6" ];then
QT6=1
QT5=0
continue
fi
if [ "$var" = "--folder" ];then
_BUILD=1
continue
fi
if [ "$var" = "--debug" ];then
USEDEBUG=1
continue
fi
if [ "$var" = "--version" ];then
echo "Configure v 1.0"
exit 0
fi
if [ "$var" = "--disable-dependency-tracking" ];then
SKIPCHECKS=1
continue
fi
if [ "$var" = "--profiler" ];then
PROFILER=' -DGRUMPY_PROFILER=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
}
checkqt()
{
text "Checking if $1 or $2 is present... "
if [ "$SKIPCHECKS" -eq 1 ];then
echo "SKIP"
return 0
fi
if [ "`apt-cache policy $1 | grep -Ev '^\s*Installed: \(none\)' | grep -E '^\s*Installed: ' | wc -l`" -gt 0 ];then
ok
return 0
fi
if [ "`apt-cache policy $2 | grep -Ev '^\s*Installed: \(none\)' | grep -E '^\s*Installed: ' | wc -l`" -gt 0 ];then
ok
return 0
fi
fail
echo "$1 neither $2 is present, use --skip-checks to ignore this"
echo "or execute apt-get install $1 $2 as root"
exit 1
}
checkpkg()
{
text "Checking if $1 is present... "
if [ "$SKIPCHECKS" == "1" ];then
echo "SKIP"
return 0
fi
if [ "`apt-cache policy $1 | grep -Ev '^\s*Installed: \(none\)' | grep -E '^\s*Installed: ' | wc -l`" -gt 0 ];then
ok
return 0
fi
fail
echo "$1 is not present, use --skip-checks to ignore this"
echo "or execute apt-get install $1 as root"
exit 1
}
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/libirc/libirc" ];then
echo "The libirc directories are missing! Fixing by using a backup file..."
cd "src/libirc" || exit 1
unzip libirc.zip || exit 1
cd - || exit 1
fi
if [ "$QT6" -eq 1 ];then
CMAKE_ARGS="$CMAKE_ARGS -DQT6_BUILD=true"
else
if [ "$QT5" -eq 1 ];then
CMAKE_ARGS="$CMAKE_ARGS -DQT5_BUILD=true"
else
CMAKE_ARGS="$CMAKE_ARGS -DQT5_BUILD=false"
fi
fi
#text "Executing update.sh... "
#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
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 [ -d "$BUILD" ];then
echo $WARN"WARNING: build directory already exist make sure it's clean"$NORMAL
else
mkdir "$BUILD" || exit 1
fi
CMAKE_ARGS="$CMAKE_ARGS"$PROFILER
cd "$BUILD" || exit 1
echo "CMake args: $CMAKE_ARGS $UNIT_TESTS -Wno-dev"
cmake ../src $CMAKE_ARGS $UNIT_TESTS -Wno-dev || exit 1
echo "Everything is ready, you can build grumpy by entering "$BUILD" and typing"
echo "make"
# this isn't normally needed but ensure we return 0 here
exit 0