1# Rules without side effects. 2 3# Vanilla Jam compatibility 4if ! $(INVOCATION_SUBDIR_SET) { 5 rule FIsPrefix 6 { 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. 10 local a = $(1) ; 11 local b = $(2) ; 12 while $(a) && $(a[1]) = $(b[1]) { 13 a = $(a[2-]) ; 14 b = $(b[2-]) ; 15 } 16 17 if $(a) { 18 return ; 19 } else { 20 return true ; 21 } 22 } 23 24 rule LocalClean { Clean $(1) : $(2) ; } 25 26 rule LocalDepends { Depends $(1) : $(2) ; } 27 28} # vanilla Jam compatibility 29 30rule FFilter 31{ 32 # FFilter <list> : <excludes> ; 33 # Removes all occurrences of <excludes> in <list>. 34 35 local list = $(1) ; 36 local excludes = $(2) ; 37 local newList ; 38 local item ; 39 for item in $(list) { 40 local skip ; 41 local exclude ; 42 for exclude in $(excludes) { 43 if $(item) = $(exclude) { 44 skip = true ; 45 } 46 } 47 if ! $(skip) { 48 newList += $(item) ; 49 } 50 } 51 return $(newList) ; 52} 53 54rule FGetGrist 55{ 56 # FGetGrist <target> ; 57 # 58 # Returns the grist of a target, not including leading "<" and trailing ">". 59 60 local grist = $(1[1]:G) ; 61 if ! $(grist) { 62 return ; 63 } 64 65 return [ Match <(.*)> : $(grist) ] ; 66} 67 68rule FSplitPath 69{ 70 # SplitPath <path> ; 71 # Decomposes a path into its components. 72 local path = $(1:G=) ; 73 local components ; 74 # $(path:D) for "/" is "/". Therefore the second condition. 75 while $(path:D) && $(path:D) != $(path) 76 { 77 # Note: $(path:B) returns "." for "..", but $(path:D=) is fine. 78 components = $(path:D=) $(components) ; 79 path = $(path:D) ; 80 } 81 components = $(path) $(components) ; 82 return $(components) ; 83} 84 85rule FTimeZoneBinaries 86{ 87 local sources = $(1:G=timezone-source) ; 88 local locate = $(2) ; 89 local setRelativeTimezoneDir = $(3) ; 90 91 local gristedBinaries ; 92 93 local source ; 94 for source in $(sources) { 95 local binaries = [ on $(source) return $(TZ_OBJECTS) ] ; 96 97 local targetDir = [ FDirName $(TARGET_COMMON_DEBUG_OBJECT_DIR) 98 data etc timezones ] ; 99 100 local binary ; 101 for binary in $(binaries) { 102 local dir = $(binary:D) ; 103 if $(dir) { 104 binary = $(binary:BSG=timezone!$(dir)) ; 105 if $(locate) { 106 LOCATE on $(binary) = [ FDirName $(targetDir) $(dir) ] ; 107 } 108 } else { 109 binary = $(binary:BSG=timezone) ; 110 if $(locate) { 111 LOCATE on $(binary) = $(targetDir) ; 112 } 113 } 114 115 if $(setRelativeTimezoneDir) { 116 RELATIVE_TIMEZONE_DIR on $(binary) = $(dir) ; 117 } 118 119 gristedBinaries += $(binary) ; 120 } 121 } 122 123 return $(gristedBinaries) ; 124} 125 126 127rule SetPlatformCompatibilityFlagVariables 128{ 129 # SetPlatformCompatibilityFlagVariables <platform var> : <var prefix> 130 # : <platform kind> [ : other platforms ] ; 131 132 local platformVar = $(1) ; 133 local platform = $($(platformVar)) ; 134 local varPrefix = $(2) ; 135 local platformKind = $(3) ; 136 local otherPlatforms = $(4) ; 137 138 if ! $(platform) { 139 ECHO "Variable $(platformVar) not set. Please run ./configure or" ; 140 EXIT "specify it manually." ; 141 } 142 143 # special case: Haiku libbe.so built for testing under BeOS 144 if $(platform) = libbe_test { 145 platform = $(HOST_PLATFORM) ; 146 } 147 148 $(varPrefix)_PLATFORM_BEOS_COMPATIBLE = ; 149 $(varPrefix)_PLATFORM_BONE_COMPATIBLE = ; 150 $(varPrefix)_PLATFORM_DANO_COMPATIBLE = ; 151 $(varPrefix)_PLATFORM_HAIKU_COMPATIBLE = ; 152 153 switch $(platform) 154 { 155 case r5 : 156 { 157 $(varPrefix)_PLATFORM_BEOS_COMPATIBLE = true ; 158 } 159 160 case bone : 161 { 162 $(varPrefix)_PLATFORM_BONE_COMPATIBLE = true ; 163 } 164 165 case dano : 166 { 167 $(varPrefix)_PLATFORM_DANO_COMPATIBLE = true ; 168 } 169 170 case haiku_host : 171 { 172 $(varPrefix)_PLATFORM_HAIKU_COMPATIBLE = true ; 173 } 174 175 case haiku : 176 { 177 $(varPrefix)_PLATFORM_HAIKU_COMPATIBLE = true ; 178 } 179 180 case * : 181 { 182 if ! ( $(platform) in $(otherPlatforms) ) { 183 Exit Unsupported $(platformKind) platform: $(platform) ; 184 } 185 } 186 } 187 188 # set lesser flags, e.g. "DANO" for "HAIKU" and "BEOS" for "BONE" 189 $(varPrefix)_PLATFORM_HAIKU_COMPATIBLE 190 ?= $($(varPrefix)_PLATFORM_HAIKU_COMPATIBLE) ; 191 $(varPrefix)_PLATFORM_DANO_COMPATIBLE 192 ?= $($(varPrefix)_PLATFORM_HAIKU_COMPATIBLE) ; 193 $(varPrefix)_PLATFORM_BONE_COMPATIBLE 194 ?= $($(varPrefix)_PLATFORM_DANO_COMPATIBLE) ; 195 $(varPrefix)_PLATFORM_BEOS_COMPATIBLE 196 ?= $($(varPrefix)_PLATFORM_BONE_COMPATIBLE) ; 197 198 # set the machine friendly flags 199 $(varPrefix)_PLATFORM_(haiku)_COMPATIBLE 200 ?= $($(varPrefix)_PLATFORM_HAIKU_COMPATIBLE) ; 201 $(varPrefix)_PLATFORM_(haiku_host)_COMPATIBLE 202 ?= $($(varPrefix)_PLATFORM_HAIKU_COMPATIBLE) ; 203 $(varPrefix)_PLATFORM_(dano)_COMPATIBLE 204 ?= $($(varPrefix)_PLATFORM_DANO_COMPATIBLE) ; 205 $(varPrefix)_PLATFORM_(bone)_COMPATIBLE 206 ?= $($(varPrefix)_PLATFORM_BONE_COMPATIBLE) ; 207 $(varPrefix)_PLATFORM_(r5)_COMPATIBLE 208 ?= $($(varPrefix)_PLATFORM_BEOS_COMPATIBLE) ; 209 210 $(varPrefix)_PLATFORM_(libbe_test)_COMPATIBLE 211 ?= $($(varPrefix)_PLATFORM_BEOS_COMPATIBLE) ; 212} 213 214rule FAnalyzeGCCVersion 215{ 216 # FAnalyzeGCCVersion <rawVersionVariable> ; 217 # 218 local varName = $(1) ; 219 local rawVersion = $($(varName)) ; 220 221 if ! $(rawVersion) { 222 ECHO "Variable $(varName) not set. Please run ./configure or" ; 223 EXIT "specify it manually." ; 224 } 225 226 local version = ; 227 # split the raw version string at `.' and `-' characters 228 while $(rawVersion) { 229 local split = [ Match "([^.-]*)[.-](.*)" : $(rawVersion) ] ; 230 if $(split) { 231 version += $(split[1]) ; 232 rawVersion = $(split[2]) ; 233 } else { 234 version += $(rawVersion) ; 235 rawVersion = ; 236 } 237 } 238 239 return $(version) ; 240} 241 242rule SetIncludePropertiesVariables 243{ 244 # SetIncludePropertiesVariables <varPrefix> ; 245 # 246 local prefix = $(1) ; 247 if $($(prefix)_GCC_VERSION[1]) < 4 { 248 $(prefix)_INCLUDES_SEPARATOR = -I- ; 249 $(prefix)_LOCAL_INCLUDES_OPTION = -I ; 250 $(prefix)_SYSTEM_INCLUDES_OPTION = -I ; 251 } else { 252 $(prefix)_INCLUDES_SEPARATOR = ; 253 $(prefix)_LOCAL_INCLUDES_OPTION = "-iquote " ; 254 $(prefix)_SYSTEM_INCLUDES_OPTION = "-I " ; 255 } 256} 257 258 259#pragma mark - 260 261rule SetPlatformForTarget 262{ 263 # SetPlatformForTarget <target> : <platform> ; 264 265 PLATFORM on $(1) = $(2) ; 266} 267 268rule SetSubDirPlatform 269{ 270 # SetSubDirPlatform <platform> ; 271 272 PLATFORM = $(1) ; 273} 274 275rule SetSupportedPlatformsForTarget 276{ 277 # SetSupportedPlatformsForTarget <target> : <platforms> ; 278 279 SUPPORTED_PLATFORMS on $(1) = $(2) ; 280} 281 282rule SetSubDirSupportedPlatforms 283{ 284 # SetSubDirSupportedPlatforms <platforms> ; 285 286 SUPPORTED_PLATFORMS = $(1) ; 287} 288 289rule AddSubDirSupportedPlatforms 290{ 291 # AddSubDirSupportedPlatforms <platforms> ; 292 293 SUPPORTED_PLATFORMS += $(1) ; 294} 295 296rule SetSubDirSupportedPlatformsBeOSCompatible 297{ 298 # SetSubDirSupportedPlatformsBeOSCompatible ; 299 300 SUPPORTED_PLATFORMS = $(HAIKU_BEOS_COMPATIBLE_PLATFORMS) ; 301} 302 303rule IsPlatformSupportedForTarget 304{ 305 # IsPlatformSupportedForTarget <target> [ : <platform> ] 306 # 307 308 on $(1) { 309 if $(PLATFORM) in $(SUPPORTED_PLATFORMS) { 310 return true ; 311 } else { 312 return ; 313 } 314 } 315} 316 317rule InheritPlatform 318{ 319 # InheritPlatform <children> : <parent> ; 320 # PLATFORM and SUPPORTED_PLATFORMS are set on <children> to their value 321 # on <parent>. 322 # 323 local children = $(1) ; 324 local parent = $(2) ; 325 326 on $(parent) { 327 PLATFORM on $(children) = $(PLATFORM) ; 328 SUPPORTED_PLATFORMS on $(children) = $(SUPPORTED_PLATFORMS) ; 329 } 330} 331 332rule SubDirAsFlags 333{ 334 SUBDIRASFLAGS += $(<) ; 335} 336 337