-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathJamrules
More file actions
534 lines (430 loc) · 11.9 KB
/
Jamrules
File metadata and controls
534 lines (430 loc) · 11.9 KB
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
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
#
# Copyright (c) 2005-2015 edelib authors
#
# This library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Lesser General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
#
# This library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Lesser General Public License for more details.
#
# You should have received a copy of the GNU Lesser General Public License
# along with this library. If not, see <http://www.gnu.org/licenses/>.
JAMCONFIG ?= $(TOP)/Jamconfig ;
include $(JAMCONFIG) ;
if ! $(JAMCONFIG_READ) {
Exit "Can't find Jamconfig. Did you run 'configure' first ?" ;
}
if $(SHARED) = 1 {
SUFOBJ_SHARED = ".lo" ;
SUFLIB_SHARED = ".so" ;
SUFLA_SHARED = ".la" ;
}
# only for haiku jam
JCACHEFILE = $(TOP)/.jamcache ;
HCACHEFILE = $(TOP)/.jamhcache ;
# jam by default set 711 for executable files which is
# too restrictive disabling shell scripts to be excuted.
# Here I'm changing it to default used
EXEMODE = 755 ;
# these variables should be here (not in Jamconfig) since RMDIR
# is already defined as 'rm -f' in Jambase, and calling 'jam distclean'
# will revert it's value when we remove Jamconfig
RMDIR = "rm -R" ;
COPYDIR = "cp -R" ;
LINKCMD = "ln -s" ;
MKDIR = "mkdir -p" ;
# variables used by jam directly
# OPTIM is cleared so it don't collide with FLAGS
OPTIM = ;
CCFLAGS = $(CFLAGS) -I$(TOP) -DE_LOG_DOMAIN="\\\"edelib\\\"" ;
C++FLAGS = $(CXXFLAGS) -I$(TOP) -DE_LOG_DOMAIN="\\\"edelib\\\"" ;
LINKFLAGS = $(LDFLAGS) ;
LINKLIBS = $(LIBS) ;
# directories used to place final library and
# by tests to construct correct paths
EDELIB_INCLUDEDIR = edelib ;
EDELIB_LIBDIR = lib ;
# library names
EDELIB = edelib ;
EDELIB_NAME = libedelib ;
EDELIB_GUI = edelib_gui ;
EDELIB_GUI_NAME = libedelib_gui ;
EDELIB_DBUS = edelib_dbus ;
EDELIB_DBUS_NAME = libedelib_dbus ;
# directory name for installed documentation
EDELIB_DOCDIR = "$(EDELIB)-$(EDELIB_VERSION)" ;
# Haiku jam have builtin LocalClean and LocalDepends
if ! $(INVOCATION_SUBDIR_SET) {
rule LocalClean { Clean $(1) : $(2) ; }
rule LocalDepends { Depends $(1) : $(2) ; }
}
# same as FDirName, but targeted to files
rule FFileName
{
return [ FDirName $(<) ] ;
}
# Cleandir cleandir : <directory> ;
# Removes directory in 'Clean clean' fashion
actions piecemeal together existing Cleandir
{
$(RMDIR) $(>)
}
# SymLink <link> : <source> ;
# Creates symbolic link <link> pointing at <source>.
rule SymLink
{
if ! $(LINKCMD) {
Echo "LINKCMD wasn't defined, $(<) will not be created" ;
return ;
}
LocalDepends $(<) : $(>) ;
SEARCH on $(<) = $(SEARCH_SOURCE) ;
SymLink1 $(<) : $(>) ;
Clean clean : $(<) ;
}
# LinkAgainst <target> : <libraries> ;
# The sam as jam's LinkLibraries, but will not mark those libraries
# for building. <libraries> should be in form '-lfoo'
rule LinkAgainst
{
#LINKLIBS on $(1) = -pg [ on $(1) return $(LINKLIBS) ] $(2) ;
LINKLIBS on $(1) = [ on $(1) return $(LINKLIBS) ] $(2) ;
}
# MakeLibrary <library> : <source> ;
# Create <library> and place it in $(EDELIB_LIBDIR). Library name should
# be in from 'libexample', without extension
rule MakeLibrary
{
local path = [ FFileName $(TOP) $(EDELIB_LIBDIR) $(1) ] ;
if $(SHARED) = 1 {
SharedLibrary $(path) : $(2) ;
} else {
Library $(path) : $(2) ;
}
if $(3) != "noinstall" {
if $(SHARED) = 1 {
InstallSharedLibrary $(libdir) : $(path) ;
} else {
InstallStaticLibrary $(libdir) : $(path) ;
}
}
}
rule LibraryObjectCcFlags
{
if $(SHARED) = 1 {
CCFLAGS on [ FGristFiles $(<:S=$(SUFOBJ_SHARED)) ] += $(>) ;
} else {
ObjectCcFlags $(<) : $(>) ;
}
}
rule LibraryObjectC++Flags
{
if $(SHARED) = 1 {
C++FLAGS on [ FGristFiles $(<:S=$(SUFOBJ_SHARED)) ] += $(>) ;
} else {
ObjectC++Flags $(<) : $(>) ;
}
}
# SharedLibrary <library> : <source> ;
# Creates shared library with libtool
rule SharedLibrary
{
if ! $(UNIX) {
Exit "Don't know how to build shared libraries on this platform" ;
}
SharedLibraryFromObjects $(<) : $(>:S=$(SUFOBJ_SHARED)) ;
SharedObjects $(>) ;
}
rule SharedLibraryFromObjects
{
local _i _l _l_so _l_la _s ;
# Add grist to file names
_s = [ FGristFiles $(>) ] ;
_l = $(<:S=$(SUFLIB_SHARED).$(EDELIB_VERSION)) ;
# for sonames; it accept only libname.so
_l_so = $(<:S=$(SUFLIB_SHARED)) ;
_l_so = $(_l_so:BSR=) ;
# libname.la file
_l_la = $(_l_so:S=$(SUFLA_SHARED)) ;
# library depends on its member objects
if $(KEEPOBJS) {
LocalDepends obj : $(_s) ;
} else {
LocalDepends lib : $(_l) ;
}
# Set LOCATE for the library and its contents. The bound
# value shows up as $(NEEDLIBS) on the Link actions.
# For compatibility, we only do this if the library doesn't
# already have a path.
if ! $(_l:D) {
MakeLocate $(_l) : $(LOCATE_TARGET) ;
}
# we never scan shared libraries for member objects
LocalDepends $(_l) : $(_s) ;
# clean library
LocalClean clean : $(_l) ;
if $(OS) = "SOLARIS" {
# solaris have other options for soname creation
LINKFLAGS on $(_l) = -h $(_l_so) -G [ on $(_l) return $(LINKFLAGS) ] ;
} else {
# let linker knows we are making shared library by adding -shared and -Wl,-soname libname.so flags
LINKFLAGS on $(_l) = -shared [ on $(_l) return $(LINKFLAGS) ] ;
}
# make it
Link $(_l) : $(_s) ;
# make a link
SymLink $(_l_so) : $(_l) ;
# let link be created in directory where libname.so.X.X.X exists
MakeLocate $(_l_so) : $(_l:D) ;
LocalDepends lib : $(_l_so) ;
# generate libname.la file
DLNAME1 on $(_l_la) = $(_l_so) ;
DLNAME2 on $(_l_la) = $(_l:BSR=) ;
GenLa $(_l_la) ;
LocalClean clean : $(_l_la) ;
LocalClean clean : $(_l_so) ;
# let libname.la be created in directory where libname.so.X.X.X exists
MakeLocate $(_l_la) : $(_l:D) ;
LocalDepends lib : $(_l_la) ;
}
rule SharedObjects
{
# temporary replace SUFOBJ since Objects rule use it
local SUFOBJ = $(SUFOBJ_SHARED) ;
ObjectCcFlags $(<) : -fPIC ;
ObjectC++Flags $(<) : -fPIC ;
# call the normal Objects rule
Objects $(<) ;
}
# MakeTest <bin> : <source> : <optional-addon-libs> : <option>
rule MakeTest
{
local lpath ;
lpath = [ FDirName $(TOP)/$(EDELIB_LIBDIR) ] ;
Main $(1) : $(2) ;
if $(SHARED) = 1 {
if $(OS) = "SOLARIS" {
# network libraries are in libxnet
LinkAgainst $(1) : -lxnet ;
}
}
if $(4) = "use-dbus" && $(DBUS_CFLAGS) {
if $(SHARED) = 1 {
LinkAgainst $(1) : -L$(lpath) -l$(EDELIB_DBUS) -l$(EDELIB_GUI) -l$(EDELIB) $(DBUS_LIBS) ;
} else {
LinkAgainst $(1) : -L$(lpath) -l$(EDELIB_DBUS) -l$(EDELIB_GUI) -l$(EDELIB) ;
}
} else {
LinkAgainst $(1) : -L$(lpath) -l$(EDELIB_GUI) -l$(EDELIB) ;
}
if $(3) {
LinkAgainst $(1) : $(3) ;
}
LinkAgainst $(1) : $(STDLIB) $(DMALLOC_LIBC) $(DMALLOC_LIBCXX) ;
}
# MakeInstallPrivate <location-dir> : <targets> : <opt-file-mode> : <opt-chown> : <opt-chgrp> : <opt-name> ;
rule MakeInstallPrivate
{
local i t s ;
local dir = $(1) ;
MkDir $(dir) ;
# This was pain-in-the-ass to set up (bad docs)
# but this is the shortest possible explaination of it:
# files must be gristed (or foo/foo will not be build) and _after_
# that apply SEARCH on it, consulting SUBDIR. Otherwise
# known targets will be compiled, but unknown (icons etc.) will not
# be recognized as installable entity.
s = [ FGristFiles $(2) ] ;
SEARCH on $(s) = $(SUBDIR) ;
for i in $(s) {
# so we can install it as desired name
if $(6) {
t = $(6:BSR=$(dir):G=installed) ;
} else {
t = $(i:BSR=$(dir):G=installed) ;
}
#t = $(i:BSR=$(dir):G=installed) ;
LocalDepends $(t) : $(i) ;
LocalDepends $(t) : $(dir) ;
LocalDepends install : $(t) ;
LocalClean uninstall : $(t) ;
Install1 $(t) : $(i) ;
if $(3) {
MODE on $(t) = $(3) ;
Chmod $(t) ;
}
if $(4) {
OWNER on $(t) = $(4) ;
Chown $(t) ;
}
if $(5) {
GROUP on $(t) = $(5) ;
Chgrp $(t) ;
}
}
}
# InstallStaticLibrary <location-dir> : <library> ;
rule InstallStaticLibrary
{
MakeInstallPrivate $(<) : $(>:S=$(SUFLIB)) : $(FILEMODE) ;
}
# InstallSharedLibrary <location-dir> : <library> ;
rule InstallSharedLibrary
{
local i t s sh o ;
local dir = $(1) ;
MkDir $(dir) ;
s = [ FGristFiles $(2:S=$(SUFLIB_SHARED).$(EDELIB_VERSION)) ] ;
sh = [ FGristFiles $(2:S=$(SUFLIB_SHARED)) ] ;
SEARCH on $(s) = $(SUBDIR) ;
for i in $(s) {
t = $(i:BSR=$(dir):G=installed) ;
LocalDepends $(t) : $(i) ;
LocalDepends $(t) : $(dir) ;
LocalDepends install : $(t) ;
UninstallSharedLibrary1 uninstall : $(t) ;
InstallSharedLibrary1 $(t) : $(i) ;
}
# install .la file
MakeInstallPrivate $(dir) : $(2:S=$(SUFLA_SHARED)) ;
# install .so by making symbolic link; first remove all those directory parts
# from variables (including grist)
#o = $(s:G=) ;
#o = $(o:D=) ;
#sh = $(sh:D=) ;
## mark it as not file since it is just a name (e.g. ln -s foo.so.2 <target>)
#NotFile $(o) ;
#SymLink $(sh) : $(o) ;
## tell jam to put it in installation folder
#MakeLocate $(sh) : $(dir) ;
#LocalDepends install : $(sh) ;
#UninstallSharedLibrary1 uninstall : $(sh) ;
}
actions InstallSharedLibrary1
{
$(CP) "$(>)" "$(<)" ;
}
actions piecemeal together existing UninstallSharedLibrary1
{
$(RM) "$(>)" ;
}
# InstallProgram <location-dir> : <program> ;
# EXEMODE is not used (jam set it to 711)
rule InstallProgram
{
MakeInstallPrivate $(<) : $(>) ;
}
# InstallDocumentation <location-dir> : <file> ;
rule InstallDocumentation
{
MakeInstallPrivate $(<) : $(>) : $(FILEMODE) ;
}
# InstallFile <location-dir> : <file> ;
rule InstallFile
{
MakeInstallPrivate $(<) : $(>) : $(FILEMODE) ;
}
# InstallFileAs <location-dir> : <file> : <file-as> ;
rule InstallFileAs
{
MakeInstallPrivate $(1) : $(2) : $(FILEMODE) : : : $(3) ;
}
# InstallDirectory <location-dir> : <directory> ;
rule InstallDirectory
{
local dir = $(1) ;
MkDir $(dir) ;
s = [ FGristFiles $(2) ] ;
SEARCH on $(s) = $(SUBDIR) ;
for i in $(s) {
t = $(i:BSR=$(dir):G=installed) ;
LocalDepends $(t) : $(i) ;
LocalDepends $(t) : $(dir) ;
LocalDepends install : $(t) ;
Cleandir uninstall : $(t) ;
CP on $(t) = $(COPYDIR) ;
Install1 $(t) : $(i) ;
}
}
actions Install1
{
$(CP) "$(>)" "$(<)"
}
actions SymLink1
{
$(RM) "$(<)" && $(LINKCMD) "$(>:D=)" "$(<)"
}
# .la files are generated by libtool and we emulate that too
# NOTE: jam will discard comments that should be written to the file
# so instead plain '#' is used '@@#' and later is replaced with sed
actions GenLa
{
today=`date`
cat > "$(<).tmp" <<EOF
@@# $(<:D=) - a libtool library file
@@# Generated by 'EDE jam build' on: $today
@@# The name that we can dlopen(3).
dlname='$(DLNAME1)'
@@# Names of this library.
library_names='$(DLNAME2) $(DLNAME1)'
@@# The name of the static archive.
old_library=''
@@# Libraries that this one depends upon.
dependency_libs=''
@@# Is this already installed library.
installed=yes
@@# Files to dlopen/dlpreopen.
dlopen=''
dlpreopen=''
@@# Directory that this library needs to be installed in:
libdir='$(libdir)'
EOF
cat "$(<).tmp" | $(SED) 's/^@@#/#/g' > "$(<)"
$(RM) "$(<).tmp"
}
NotFile install ;
# Allow 'jam tests' to be executed no matter was edelib compiled
# as shared library or not. Depending on that, we select appropriate rule.
actions quietly RunTests
{
cd tests; ./run-all.sh
}
actions quietly RunTestsShared
{
export LD_LIBRARY_PATH="$LD_LIBRARY_PATH:`pwd`/lib"
cd test; ./run-all.sh
}
if $(SHARED) {
RunTestsShared tests ;
} else {
RunTests tests ;
}
NotFile tests ;
Always tests ;
# a generated junk
LocalClean distclean :
$(TOP)/configure
$(TOP)/aclocal.m4
$(TOP)/Jamconfig
$(TOP)/edelib-config
$(TOP)/edelib.pc
$(TOP)/edelib-dbus.pc
$(TOP)/edelib-gui.pc
$(TOP)/edelib-gui-no-images.pc
$(TOP)/config.log
$(TOP)/config.status
$(TOP)/doc/Doxyfile
$(TOP)/edelib/edelib-config.h
$(TOP)/config.h.in
$(TOP)/config.h
$(TOP)/edelib/Version.h
$(TOP)/po/update-messages.sh
$(TOP)/sslib/init_ss.h
$(TOP)/sslib/theme_ss.h
$(JCACHEFILE)
$(HCACHEFILE) ;
Cleandir distclean : $(TOP)/autom4te.cache ;