1 # Rules without side effects.
3 # Vanilla Jam compatibility
4 if ! $(INVOCATION_SUBDIR_SET) {
7 # FIsPrefix <a> : <b> ;
8 # Returns true, if list <a> is a prefix (a proper one or equal) of
9 # list <b>, an empty list otherwise.
12 while $(a) && $(a[1]) = $(b[1]) {
24 rule LocalClean { Clean $(1) : $(2) ; }
26 rule LocalDepends { Depends $(1) : $(2) ; }
28 } # vanilla Jam compatibility
32 # FFilter <list> : <excludes> ;
33 # Removes all occurrences of <excludes> in <list>.
36 local excludes = $(2) ;
42 for exclude in $(excludes) {
43 if $(item) = $(exclude) {
56 # FGetGrist <target> ;
58 # Returns the grist of a target, not including leading "<" and trailing ">".
60 local grist = $(1[1]:G) ;
65 return [ Match <(.*)> : $(grist) ] ;
68 rule FSplitString string : delimiterChar
73 local split = [ Match $(delimiterChar)*([^$(delimiterChar)]+)(.*)
75 result += $(split[1]) ;
76 string = $(split[2-]) ;
85 # Decomposes a path into its components.
86 local path = $(1:G=) ;
88 # $(path:D) for "/" is "/". Therefore the second condition.
89 while $(path:D) && $(path:D) != $(path)
91 # Note: $(path:B) returns "." for "..", but $(path:D=) is fine.
92 components = $(path:D=) $(components) ;
95 components = $(path) $(components) ;
96 return $(components) ;
100 rule FConditionsHold conditions : predicate
102 # FConditionsHold <conditions> : <predicate> ;
103 # Checks whether the conditions <conditions> are satisfied by the predicate
104 # rule <predicate> and returns a respective result (if so: "1", if not:
105 # empty list). The conditions are satisfied when <conditions> is not empty
107 # * none of the negative conditions it contains hold and
108 # * if <conditions> contains any positive conditions, at least one of those
110 # A positive condition is an element not starting with a "!". It holds when
111 # the predicate rule <predicate> returns true for the element.
112 # A negative condition is an element that starts with a "!". It holds when
113 # the predicate rule <predicate> returns true for the string resulting from
114 # removing the leading "!".
116 # <conditions> - The list of conditions.
117 # <predicate> - The predicate rule invoked to test the elements.
120 # For a predicate that holds for the elements of the set { a b c } the
121 # following conditions hold:
122 # { a }, { a d }, { !d }, { !d !e }, { a !d }, { b !e !f }
123 # The following conditions don't hold:
124 # { }, { d }, { d e }, { !a }, { !a b }, { !d e } { a b !c !d }
128 local positiveMatch ;
130 for condition in $(conditions) {
131 switch $(condition) {
135 condition = [ Match "!(.*)" : $(condition) ] ;
136 if [ $(predicate) $(condition) ] {
143 if [ $(predicate) $(condition) ] {
151 return $(positiveMatch) ;
153 return $(hasNegative) ;
157 rule SetPlatformCompatibilityFlagVariables
159 # SetPlatformCompatibilityFlagVariables <platform var> : <var prefix>
160 # : <platform kind> [ : other platforms ] ;
162 local platformVar = $(1) ;
163 local platform = $($(platformVar)) ;
164 local varPrefix = $(2) ;
165 local platformKind = $(3) ;
166 local otherPlatforms = $(4) ;
169 ECHO "Variable $(platformVar) not set. Please run ./configure or" ;
170 EXIT "specify it manually." ;
173 # special case: Haiku libbe.so built for testing under BeOS
174 if $(platform) = libbe_test {
175 platform = $(HOST_PLATFORM) ;
178 $(varPrefix)_PLATFORM_BEOS_COMPATIBLE = ;
179 $(varPrefix)_PLATFORM_BONE_COMPATIBLE = ;
180 $(varPrefix)_PLATFORM_DANO_COMPATIBLE = ;
181 $(varPrefix)_PLATFORM_HAIKU_COMPATIBLE = ;
187 $(varPrefix)_PLATFORM_BEOS_COMPATIBLE = true ;
192 $(varPrefix)_PLATFORM_BONE_COMPATIBLE = true ;
197 $(varPrefix)_PLATFORM_DANO_COMPATIBLE = true ;
202 $(varPrefix)_PLATFORM_HAIKU_COMPATIBLE = true ;
207 $(varPrefix)_PLATFORM_HAIKU_COMPATIBLE = true ;
211 # not compatible to anything
215 if ! ( $(platform) in $(otherPlatforms) ) {
216 Exit Unsupported $(platformKind) platform: $(platform) ;
221 # set lesser flags, e.g. "DANO" for "HAIKU" and "BEOS" for "BONE"
222 $(varPrefix)_PLATFORM_HAIKU_COMPATIBLE
223 ?= $($(varPrefix)_PLATFORM_HAIKU_COMPATIBLE) ;
224 $(varPrefix)_PLATFORM_DANO_COMPATIBLE
225 ?= $($(varPrefix)_PLATFORM_HAIKU_COMPATIBLE) ;
226 $(varPrefix)_PLATFORM_BONE_COMPATIBLE
227 ?= $($(varPrefix)_PLATFORM_DANO_COMPATIBLE) ;
228 $(varPrefix)_PLATFORM_BEOS_COMPATIBLE
229 ?= $($(varPrefix)_PLATFORM_BONE_COMPATIBLE) ;
231 # set the machine friendly flags
232 $(varPrefix)_PLATFORM_(haiku)_COMPATIBLE
233 ?= $($(varPrefix)_PLATFORM_HAIKU_COMPATIBLE) ;
234 $(varPrefix)_PLATFORM_(haiku_host)_COMPATIBLE
235 ?= $($(varPrefix)_PLATFORM_HAIKU_COMPATIBLE) ;
236 $(varPrefix)_PLATFORM_(dano)_COMPATIBLE
237 ?= $($(varPrefix)_PLATFORM_DANO_COMPATIBLE) ;
238 $(varPrefix)_PLATFORM_(bone)_COMPATIBLE
239 ?= $($(varPrefix)_PLATFORM_BONE_COMPATIBLE) ;
240 $(varPrefix)_PLATFORM_(r5)_COMPATIBLE
241 ?= $($(varPrefix)_PLATFORM_BEOS_COMPATIBLE) ;
243 $(varPrefix)_PLATFORM_(libbe_test)_COMPATIBLE
244 ?= $($(varPrefix)_PLATFORM_BEOS_COMPATIBLE) ;
247 rule FAnalyzeGCCVersion
249 # FAnalyzeGCCVersion <rawVersionVariable> ;
251 local varName = $(1) ;
252 local rawVersion = $($(varName)) ;
255 ECHO "Variable $(varName) not set. Please run ./configure or" ;
256 EXIT "specify it manually." ;
260 # split the raw version string at `.' and `-' characters
261 while $(rawVersion) {
262 local split = [ Match "([^.-]*)[.-](.*)" : $(rawVersion) ] ;
264 version += $(split[1]) ;
265 rawVersion = $(split[2]) ;
267 version += $(rawVersion) ;
275 rule SetIncludePropertiesVariables prefix : suffix
277 # SetIncludePropertiesVariables <prefix> : <suffix> ;
279 suffix = $(suffix:E=) ;
280 if $($(prefix)_GCC_VERSION$(suffix)[1]) < 4 {
281 $(prefix)_INCLUDES_SEPARATOR$(suffix) = -I- ;
282 $(prefix)_LOCAL_INCLUDES_OPTION$(suffix) = -I ;
283 $(prefix)_SYSTEM_INCLUDES_OPTION$(suffix) = -I ;
285 $(prefix)_INCLUDES_SEPARATOR$(suffix) = ;
286 $(prefix)_LOCAL_INCLUDES_OPTION$(suffix) = "-iquote " ;
287 $(prefix)_SYSTEM_INCLUDES_OPTION$(suffix) = "-I " ;
294 rule SetPlatformForTarget
296 # SetPlatformForTarget <target> : <platform> ;
298 PLATFORM on $(1) = $(2) ;
301 rule SetSubDirPlatform
303 # SetSubDirPlatform <platform> ;
308 rule SetSupportedPlatformsForTarget
310 # SetSupportedPlatformsForTarget <target> : <platforms> ;
312 SUPPORTED_PLATFORMS on $(1) = $(2) ;
315 rule SetSubDirSupportedPlatforms
317 # SetSubDirSupportedPlatforms <platforms> ;
319 SUPPORTED_PLATFORMS = $(1) ;
322 rule AddSubDirSupportedPlatforms
324 # AddSubDirSupportedPlatforms <platforms> ;
326 SUPPORTED_PLATFORMS += $(1) ;
329 rule SetSubDirSupportedPlatformsBeOSCompatible
331 # SetSubDirSupportedPlatformsBeOSCompatible ;
333 SUPPORTED_PLATFORMS = $(HAIKU_BEOS_COMPATIBLE_PLATFORMS) ;
336 rule IsPlatformSupportedForTarget
338 # IsPlatformSupportedForTarget <target> [ : <platform> ]
342 if $(PLATFORM) in $(SUPPORTED_PLATFORMS) {
352 # InheritPlatform <children> : <parent> ;
353 # PLATFORM and SUPPORTED_PLATFORMS are set on <children> to their value
356 local children = $(1) ;
357 local parent = $(2) ;
360 PLATFORM on $(children) = $(PLATFORM) ;
361 SUPPORTED_PLATFORMS on $(children) = $(SUPPORTED_PLATFORMS) ;
367 SUBDIRASFLAGS += $(<) ;