-
Notifications
You must be signed in to change notification settings - Fork 3
/
Jamrules
206 lines (180 loc) · 5.24 KB
/
Jamrules
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
PDCLIB ?= pdclib ;
ECHO "PDCLIB_TOP: " $(PDCLIB_TOP) ;
if ! $(PDCLIB_HAVE_PLATFORM) && ! $(PDCLIB_PLATFORM) {
if $(NT) {
PDCLIB_PLATFORM = "win32" ;
} else if $(UNIX) {
PDCLIB_PLATFORM = "posix" ;
} else {
ECHO PDCLIB_PLATFORM not set and platform not automatically detected ;
ECHO Set PDCLIB_PLATFORM to the platform to be built for ;
EXIT ;
}
PDCLIB_HAVE_PLATFORM = 1 ;
}
if $(PDCLIB_TOOLCHAIN) = "" {
local __ccparts = [ SPLIT $(CC) : "-" ] ;
if $(JAM_TOOLSET) = "MINGW" || "gcc" in $(__ccparts)
|| "clang" in $(__ccparts) {
# GCC / GCC-alike
PDCLIB_TOOLCHAIN = "gcc" ;
} else if $(JAM_TOOLSET) != "" {
PDCLIB_TOOLCHAIN = $(JAM_TOOLSET) ;
} else {
ECHO PDCLIB_TOOLCHAIN is unset and I can't glean what toolset is being ;
ECHO used from your environment. Please set it. ;
EXIT ;
}
}
if $(PDCLIB_TOOLCHAIN) = "gcc" {
# No -Wcast-align : spurious warnings when using char* to do pointer
# arithmetic
# No -Winline : when compiling with e.g. -Os causes spurious
# warnings that call is unlikely/code size would grow
# No -Wredundant-decls : some functions must be multiply defined
PDCLIB_WARNINGS ?=
-Wall -Wextra -pedantic -Wno-unused-parameter -Wshadow
-Wpointer-arith -Wwrite-strings -Wmissing-declarations -Wno-long-long
-Wuninitialized
;
PDCLIB_CCWARNINGS ?=
-Wnested-externs -Wstrict-prototypes -Wmissing-prototypes ;
PDCLIB_CCFLAGS =
-ffreestanding
#-nostdinc
-std=c11
-g
-ffunction-sections
-fdata-sections
-D_PDCLIB_BUILD
$(PDCLIB_WARNINGS) ;
PDCLIB_C++FLAGS =
-ffreestanding
#-nostdinc
-std=c++11
-g
-ffunction-sections
-fdata-sections
-D_PDCLIB_BUILD
$(PDCLIB_WARNINGS) ;
if $(OS) = "MACOSX" {
# ld64 does automatic repeated searches of archives
# and doesn't accept --start-group/--end-group
#actions Link bind NEEDLIBS
#{
# $(LINK) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) $(NEEDLIBS) $(LINKLIBS)
#}
} else {
PDCLIB_TEST_LINKFLAGS += -Wl,--gc-sections ;
actions Link bind NEEDLIBS
{
$(LINK) $(LINKFLAGS) -o $(<) $(UNDEFS) $(>) -Wl,--start-group $(NEEDLIBS) $(LINKLIBS) -Wl,--end-group
}
}
} else if $(PDCLIB_TOOLCHAIN) = "WATCOM" {
ECHO "Watcom!" ;
CCFLAGS = /zq /DWIN32 /zls ;
C++FLAGS = /zq /DWIN32 /zls ;
STDHDRS = $(WATCOM)\\h\\nt ;
PDCLIB_CCFLAGS = "-za99 -zl -s" ;
} else {
ECHO The value of PDCLIB_TOOLCHAIN is not recognized ;
ECHO Currently set to $(PDCLIB_TOOLCHAIN) ;
EXIT ;
}
if $(PDCLIB_PLATFORM) {
include [ FDirName $(PDCLIB_TOP) platform $(PDCLIB_PLATFORM) Config.jam ] ;
}
rule PDCLibHeaders {
SubDirHdrs $(PDCLIB_TOP) includes ;
SubDirHdrs $(PDCLIB_TOP) internals ;
SubDirHdrs $(PDCLIB_TOP) testing ;
for opt in $(PDCLIB_OPTIONS) {
SubDirHdrs $(PDCLIB_TOP) opt $(opt) ;
}
PDCLibTargetHeaders ;
}
rule PDCLibConfig {
SubDirCcFlags $(PDCLIB_CCFLAGS) ;
SubDirC++Flags $(PDCLIB_C++FLAGS) ;
PDCLibHeaders ;
PDCLibTargetConfig ;
}
# MinGW needs appropriate prodding to cretae executables
if $(TOOLSET) = MINGW {
PDCLIB_TEST_LINKFLAGS += -mconsole ;
PDCLIB_REGTEST_LINKFLAGS += -mconsole ;
}
# Tests
ALWAYS regtest test ;
rule Test {
DEPENDS $(<) : $(>) ;
ALWAYS $(<) ;
DEPENDS test : $(<) ;
}
rule RegTest {
DEPENDS $(<) : $(>) ;
ALWAYS $(<) ;
DEPENDS regtest : $(<) ;
}
actions Test {
$(>)
}
actions RegTest {
$(>)
}
# list all files in a directory, except ., ..
# [ ListDir base : dirname ]
rule ListDir {
# start with empty list
local _result = ;
# for each file in the directory
local _dirlist = [ GLOB [ FDirName $(1) $(2) ] : * ] ;
for _subdir in $(_dirlist) {
# if it is not . or ..
switch $(_subdir) {
case *\\. : _dummy = "" ; # is there some no-op statement?
case *\\.. : _dummy = "" ; # is there some no-op statement?
case * :
# add it to the list
_result += $(_subdir:D=$(2)) ;
}
}
# return resulting list
return $(_result) ;
}
# same as glob, but recurses into subdirs
rule RecursiveGlob {
# initially use the files in the current directory
local _dir = $(2) ;
local _path = [ FDirName $(1) $(2) ] ;
local _result = [ GLOB $(_path) : $(3) ] ;
_result = $(_result:D=$(_dir)) ;
# list all subdirectories (and files, but it doesn't hurt)
local _subdirlist = [ ListDir $(1) : $(2) ] ;
# for each subdir/file
for _subdir in $(_subdirlist) {
# recurse into it
_result += [ RecursiveGlob $(1) : $(_subdir) : $(3) ] ;
}
# return the resulting list
return $(_result) ;
}
# Fix to work on targets in subdirs
rule MakeLocate
{
# Note we grist the directory name with 'dir',
# so that directory path components and other
# targets don't conflict.
if $(>)
{
local _rev = [ FReverse $(>) ] ;
if $(_rev[1]) = "." {
_rev = $(_rev[2-]) ;
}
local _dir = [ FDirName [ FReverse $(_rev) ] $(<[0]:D) ] ;
LOCATE on $(<) = [ FDirName $(>) ] ;
Depends $(<) : $(_dir:G=dir) ;
MkDir $(_dir:G=dir) ;
}
}