-
Notifications
You must be signed in to change notification settings - Fork 3
/
clebs-lib.pri
434 lines (393 loc) · 14.6 KB
/
clebs-lib.pri
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
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
# Specify CLEBS if you need libraries or special build settings. Mark optional
# ones with a leading - (the directory will be compiled without it) and
# mandatory ones with a leading + (the project will fail completely).
# Specify CLEBS_INSTALL to add install commands to the make file.
# clebs/
# external: external libraries/programs, you can define whether configuration
# fails or a depending subdirectory is omitted from the build with
# -/+ as described above.
# internal: internal libraries, the .pri file needs to have the same name as
# the subdirectory in contrib or src/lib the contains the
# corresponding library.
# build: special build settings (dll, plugin, pch, etc.)
# Some macros ==================================================================
# clebsFixupSubdirs(): Configures directories of the project (dependencies,
# compile order, disabled). Compile order will be obeyed if the directory pro
# file has a CLEBS line that depends on libs in clebs/internal that have the
# same name as a directory in contrib or src/lib.
defineTest(clebsFixupSubdirs) {
clear(CLEBS_SUBDIRS)
clear(CLEBS_EXTERNALDEPS)
for(subdir, SUBDIRS) {
SUBDIRS -= $$subdir
subdir ~= s|/$||
pro = $$basename(subdir)
!exists("$${subdir}/$${pro}.pro"):next()
deps = $$fromfile("$$subdir/$${pro}.pro", "CLEBS")
libs = $$clebsInternalLibDependencies($$deps)
external = $$clebsExternalDependencies($$deps)
missingexternal = $$clebsMissingDependencies($$external)
CLEBS_EXTERNALDEPS *= $$external
contains(CLEBS_DISABLED, $$subdir) {
CLEBS_SUBDIRS += "$${subdir}_"
next()
}
!isEmpty(missingexternal) {
CLEBS_SUBDIRS += "$${subdir}+$${missingexternal}-"
next()
}
CLEBS_SUBDIRS += "$${subdir}"
name = $$replace(subdir, [/\\\\], _)
eval($${name}.subdir = $$subdir)
export($${name}.subdir)
for(dep, libs):eval($${name}.depends *= $$replace(dep, [/\\\\], _))
export($${name}.depends)
SUBDIRS *= $$name
}
CLEBS_SUBDIRS = $$clebsSort($$CLEBS_SUBDIRS)
export(SUBDIRS)
export(CLEBS_EXTERNALDEPS)
export(CLEBS_SUBDIRS)
}
# Returns the .pri file for a dependency
defineReplace(clebsDependencyFile) {
1 ~= s|^[-+]||
subdirs = clebs $$files(clebs/*)
for(subdir, subdirs):exists($${subdir}/$${1}.pri):return($${subdir}/$${1}.pri)
# only error out if the error occured in the top-level pro file (not included)
profile = $$_PRO_FILE_
!isEmpty(profile):error("Build configuration requested for unknown dependency $$1!")
# fail gracefully
return ""
}
# Tries to temporarily include the specified dependency include files and
# returns the missing ones (without +-)
defineReplace(clebsMissingDependencies) {
clear(missing)
for(dep, 1) {
contains(dep, "^[-].*"):next()
dep ~= s|^[-+]||
CLEBS = $$dep
file = $$clebsDependencyFile($$dep)
!isEmpty(file):include($$file)
!contains(CLEBS_DEPENDENCIES, $$dep):missing *= $$dep
}
return($$missing)
}
# Looks through the dependencies and returns the one that seem to refer to a lib
# in src/lib or contrib
defineReplace(clebsInternalLibDependencies) {
clear(libs)
for(dep, 1) {
dep ~= s|^[-+]||
exists(clebs/internal/$${dep}.pri) {
libdirs = src/lib contrib
clear(foundinclude)
for(libdir, libdirs) {
exists($${libdir}/$${dep}) {
foundinclude = true
libs *= $${libdir}/$${dep}
break()
}
}
isEmpty(foundinclude):error("Unable to find internal lib $$dep!")
}
}
return($$libs)
}
# Looks through the dependencies and returns the one that seem to refer to external libs
defineReplace(clebsExternalDependencies) {
clear(libs)
for(rawdep, 1) {
dep = $$rawdep
dep ~= s|^[-+]||
exists(clebs/external/$${dep}.pri):libs *= $${rawdep}
}
return($$libs)
}
# Looks through the dependencies and returns the ones with a - or without a +
# in front of it
defineReplace(clebsOptionalNormalDependencies) {
clear(result)
for(dep, 1) {
contains(dep, "[+].*"):next()
dep ~= s|^[-+]||
contains(1, "[+]$$dep"):next()
result += $$dep
}
return($$clebsSort($$result))
}
# Looks through the dependencies and returns the ones with a + in front of it
defineReplace(clebsMandatoryDependencies) {
clear(result)
for(dep, 1) {
!contains(dep, "[+].*"):next()
dep ~= s|^[-+]||
result += $$dep
}
return($$clebsSort($$result))
}
# Selection sort
defineReplace(clebsSort) {
clear(result)
list = $$1
for(ever) {
isEmpty(list):break()
smallest = $$first(list)
for(value, list):lessThan(value, $$smallest):smallest = $$value
result += $$smallest
list -= $$smallest
}
return($$result)
}
# clebsCheck(dependency): Used in clebs dependency include files to mark the
# block that determines whether a dependency is available. The block should add
# the dependency name to CLEBS_DEPENDENCIES if the dependency is available
defineTest(clebsCheck) {
contains(CLEBS, "[-+]?$$1")|contains(CLEBS_INSTALL, "[-+]?$$1"):return(true)
return(false)
}
# clebsInstall(dependency): Used in clebs dependency include files to mark the
# block that installs the library.
defineTest(clebsInstall) {
1 ~= s|^[-+]||
contains(CLEBS_INSTALL, "[-+]?$$1"):contains(CLEBS_DEPENDENCIES, "[-+]?$$1"):return(true)
return(false)
}
# clebsDependency(dependency): Used in clebs dependency include files to mark
# the block that does the setup for a dependency like adding include dirs and
# library dependencies. If the library in turn requires other additional
# libraries, add them to the CLEBS variable.
defineTest(clebsDependency) {
1 ~= s|^[-+]||
contains(CLEBS, "[-+]?$$1"):contains(CLEBS_DEPENDENCIES, "[-+]?$$1"):return(true)
return(false)
}
# clebsCheckQtVersion(major,minor,patch): Checks whether the current Qt version
# is larger than or equal to the given version consisting of major, minor and
# patch revision.
defineTest(clebsCheckQtVersion) {
version = $$[QT_VERSION]
major = $$section(version, '.', 0, 0)
minor = $$section(version, '.', 1, 1)
patch = $$section(version, '.', 2, 2)
greaterThan(major,$$1):return(true)
lessThan(major,$$1):return(false)
greaterThan(minor,$$2):return(true)
lessThan(minor,$$2):return(false)
greaterThan(patch,$$3):return(true)
lessThan(patch,$$3):return(false)
return(true)
}
defineTest(clebsCheckDependencies) {
clear(somethingmissing)
missing = $$clebsMissingDependencies($$1)
!isEmpty(missing):error("Please install the necessary (devel) packages for $$missing!")
}
defineTest(clebsPrintDependencies) {
!isEmpty(2) {
message("----------------------------------------------")
message("$$1 dependencies:")
message("----------------------------------------------")
for(dep, 2) {
found = "no"
missing = $$clebsMissingDependencies($$dep)
isEmpty(missing):found = "yes"
temp = "Looking for $$dep __________________________"
temp ~= s/(.{41}).*/\\1: $$found/
temp ~= s/_/ /
message($$temp)
}
}
}
defineTest(clebsPrintSubdirs) {
!isEmpty(1) {
message("----------------------------------------------")
message("Build overview:")
message("----------------------------------------------")
clear(oldpath)
clear(indent)
for(dir, 1) {
build = "yes"
contains(dir, ".*-$") {
missing = $$section(dir, '+', 1, 1)
missing ~= s/-$//
build = "no ($$missing)"
}
contains(dir, ".*_$"):build = "disabled"
dir ~= s/([-_]|\\+.*)$//
name = $$section(dir, '/', -1, -1)
path = $$section(dir, '/', 0, -2)
oldtemppath = $$oldpath
clear(oldpath)
clear(indent)
!isEmpty(path):for(ever) {
dirpart = $$section(path, '/', 0, 0)
olddirpart = $$section(oldtemppath, '/', 0, 0)
isEqual(dirpart, $$olddirpart) {
} else {
clebsPrintSubdir("$$indent$$dirpart/")
}
indent = "$${indent}__"
isEmpty(oldpath) {
oldpath = $$dirpart
} else {
oldpath = "$$oldpath/$$dirpart"
}
path = $$section(path, '/', 1, -1)
oldtemppath = $$section(oldtemppath, '/', 1, -1)
isEmpty(path):break()
}
clebsPrintSubdir("$$indent$$name", $$build)
}
}
}
defineTest(clebsPrintSubdir) {
dir = $$1
build = $$2
temp = "$$dir ______________________________________"
isEmpty(build) {
temp ~= s/(.{41}).*/\\1/
} else {
temp ~= s/(.{41}).*/\\1: $$build/
}
temp ~= s/_/ /
message($$temp)
}
# General settings =============================================================
# base dir as needed by the .pri files and localconfig.pri
BASEDIR = $$PWD
# Calculate the relative path to the .pro file, relative base dir
profile = $$_PRO_FILE_ # do not remove, _PRO_FILE_ needs to be copied
!isEmpty(profile):PRORELPATH = $$_PRO_FILE_PWD_
PRORELPATH ~= s|^/||
pwdparts = $$split(PWD, '/')
for(part, pwdparts):PRORELPATH = $$section(PRORELPATH, '/', 1)
RELBASEDIR = $$replace(PRORELPATH, "[^/]+", "..")
isEmpty(LOCALCONFIG):LOCALCONFIG = localconfig.pri
exists($$LOCALCONFIG):include($$LOCALCONFIG)
# Calculate the package name
mainprofiles = $$files($$BASEDIR/*.pro)
mainprofile = $$first(mainprofiles)
mainprofile = $$basename(mainprofile)
PACKAGE = $$section(mainprofile, '.', 0, 0)
CONFIG += stl warn_on exceptions thread rtti silent
CONFIG += debug
CONFIG -= release
CONFIG -= debug_and_release
!isEmpty(RELEASE) {
CONFIG += release
CONFIG -= debug
}
QT -= gui
DEFINES += QT_NO_CAST_FROM_ASCII QT_NO_CAST_TO_ASCII
android:DIRECTORY_PREFIX=android-
CONFIG(release, debug|release) {
DESTDIR = $$PWD/bin/$${DIRECTORY_PREFIX}release
OBJECTS_DIR = $$PWD/.build/$${DIRECTORY_PREFIX}release/$$PRORELPATH
} else {
DESTDIR = $$PWD/bin/$${DIRECTORY_PREFIX}debug
OBJECTS_DIR = $$PWD/.build/$${DIRECTORY_PREFIX}debug/$$PRORELPATH
}
MOC_DIR = $$OBJECTS_DIR/moc
UI_DIR = $$OBJECTS_DIR/ui
RCC_DIR = $$OBJECTS_DIR/rcc
android {
# Uses INSTALL_ROOT instead of PREFIX because target path is hardcoded
isEmpty(CONFDIR):CONFDIR = /etc
isEmpty(DATADIR):DATADIR = /assets
isEmpty(DOCDIR):DOCDIR = /assets
isEmpty(APPDIR):APPDIR = /assets
isEmpty(MANDIR):MANDIR = /assets
isEmpty(TRANSLATIONDIR):TRANSLATIONDIR = /assets
isEmpty(ICONDIR):ICONDIR = /assets/icons
isEmpty(BINDIR):BINDIR = /libs/armeabi
isEmpty(LIBDIR):LIBDIR = /libs/armeabi
isEmpty(INCLUDEDIR):INCLUDEDIR = /assets/include
isEmpty(PLUGINDIR):PLUGINDIR = /libs/armeabi
} else:unix {
isEmpty(PREFIX):PREFIX = /usr/local
isEmpty(CONFDIR):CONFDIR = /etc
isEmpty(DATADIR):DATADIR = $$PREFIX/share/$$PACKAGE
isEmpty(DOCDIR):DOCDIR = $$PREFIX/share/doc/$$PACKAGE
isEmpty(APPDIR):APPDIR = $$PREFIX/share/applications
isEmpty(MANDIR):MANDIR = $$PREFIX/share/man
isEmpty(TRANSLATIONDIR):TRANSLATIONDIR = $$PREFIX/share/locale
isEmpty(ICONDIR):ICONDIR = $$PREFIX/share/icons/hicolor
isEmpty(BINDIR):BINDIR = $$PREFIX/bin
isEmpty(LIBDIR):LIBDIR = $$PREFIX/lib
isEmpty(INCLUDEDIR):INCLUDEDIR = $$PREFIX/include/$$PACKAGE
isEmpty(PLUGINDIR):PLUGINDIR = $$PREFIX/lib/$$PACKAGE
} else:win32 {
isEmpty(PREFIX):PREFIX = $${DESTDIR}-installed
isEmpty(CONFDIR):CONFDIR = $$PREFIX/etc
isEmpty(DATADIR):DATADIR = $$PREFIX/share
isEmpty(DOCDIR):DOCDIR = $$PREFIX/doc
isEmpty(MANDIR):MANDIR = $$PREFIX/share
isEmpty(TRANSLATIONDIR):TRANSLATIONDIR = $$PREFIX/locale
isEmpty(ICONDIR):ICONDIR = $$PREFIX/icons
isEmpty(BINDIR):BINDIR = $$PREFIX/bin
isEmpty(LIBDIR):LIBDIR = $$PREFIX/bin
# the same as the executables so that SxS dlls also work for plugins
isEmpty(PLUGINDIR):PLUGINDIR = $$PREFIX/bin
}
# Programs may need internal libraries...
LIBS *= -L$$DESTDIR
# ...and these libraries may need more internal libraries
unix:QMAKE_LFLAGS *=-Wl,-rpath-link=$$DESTDIR
# For includes from .ui files on MinGW
INCLUDEPATH *= .
DEPENDPATH *= .
# Install to the binary directory per default
target.path = $$BINDIR
INSTALLS *= target
# mingw creates scripts if there are too many source files
win32-g++|win32-x-g++*:QMAKE_CLEAN *= object_script.*
unix {
CONFIG += link_pkgconfig
#QMAKE_CXXFLAGS_DEBUG *= -O2
# Code coverage tests with gcov
#QMAKE_CXXFLAGS_DEBUG *= -fprofile-arcs -ftest-coverage
#LIBS *= -lgcov
}
win32 {
CONFIG += embed_manifest_exe
# Creates a console window so we see debug messages
CONFIG(debug, debug|release):CONFIG += console
# STL iterators and fopen are unsafe
DEFINES *= _SCL_SECURE_NO_WARNINGS _CRT_SECURE_NO_WARNINGS
# Template warnings
!win32-g++: QMAKE_CXXFLAGS += /wd4661
# we want debugging symbol files (for visual studio)
!win32-g++: QMAKE_CXXFLAGS += /Zi
!win32-g++: QMAKE_LFLAGS += /INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF
}
# Fixup subdir compile order and dependencies. check dependencies =============
clebsFixupSubdirs()
!isEmpty(CLEBS_EXTERNALDEPS) {
CONFIG(release, debug|release) {
message("----------------------------------------------")
message("BUILDING IN RELEASE MODE")
}
clebsPrintDependencies("Required", $$clebsMandatoryDependencies($$CLEBS_EXTERNALDEPS))
clebsPrintDependencies("Optional", $$clebsOptionalNormalDependencies($$CLEBS_EXTERNALDEPS))
clebsCheckDependencies($$clebsMandatoryDependencies($$CLEBS_EXTERNALDEPS))
clebsPrintSubdirs($$CLEBS_SUBDIRS)
message("----------------------------------------------")
CONFIG(release, debug|release) {
message("BUILDING IN RELEASE MODE")
message("----------------------------------------------")
}
}
# Linking against libraries ====================================================
alldeps = $$CLEBS $$CLEBS_INSTALL
for(ever) {
isEmpty(alldeps):break()
dep = $$first(alldeps)
alldeps -= $$dep
contains(result, $$replace(dep, "^[-+]?", "[-+]?")):next()
result += $$dep
file = $$clebsDependencyFile($$dep)
!isEmpty(file):include($$file)
alldeps += $$CLEBS $$CLEBS_INSTALL
}