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 = haiku ; 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 : 171 { 172 $(varPrefix)_PLATFORM_HAIKU_COMPATIBLE = true ; 173 } 174 175 case * : 176 { 177 if ! ( $(platform) in $(otherPlatforms) ) { 178 Exit Unsupported $(platformKind) platform: $(platform) ; 179 } 180 } 181 } 182 183 # set lesser flags, e.g. "DANO" for "HAIKU" and "BEOS" for "BONE" 184 $(varPrefix)_PLATFORM_DANO_COMPATIBLE 185 ?= $($(varPrefix)_PLATFORM_HAIKU_COMPATIBLE) ; 186 $(varPrefix)_PLATFORM_BONE_COMPATIBLE 187 ?= $($(varPrefix)_PLATFORM_DANO_COMPATIBLE) ; 188 $(varPrefix)_PLATFORM_BEOS_COMPATIBLE 189 ?= $($(varPrefix)_PLATFORM_BONE_COMPATIBLE) ; 190 191 # set the machine friendly flags 192 $(varPrefix)_PLATFORM_(haiku)_COMPATIBLE 193 ?= $($(varPrefix)_PLATFORM_HAIKU_COMPATIBLE) ; 194 $(varPrefix)_PLATFORM_(dano)_COMPATIBLE 195 ?= $($(varPrefix)_PLATFORM_DANO_COMPATIBLE) ; 196 $(varPrefix)_PLATFORM_(bone)_COMPATIBLE 197 ?= $($(varPrefix)_PLATFORM_BONE_COMPATIBLE) ; 198 $(varPrefix)_PLATFORM_(r5)_COMPATIBLE 199 ?= $($(varPrefix)_PLATFORM_BEOS_COMPATIBLE) ; 200 201 $(varPrefix)_PLATFORM_(libbe_test)_COMPATIBLE 202 ?= $($(varPrefix)_PLATFORM_BEOS_COMPATIBLE) ; 203} 204 205rule FAnalyzeGCCVersion 206{ 207 # FAnalyzeGCCVersion <rawVersionVariable> ; 208 # 209 local varName = $(1) ; 210 local rawVersion = $($(varName)) ; 211 212 if ! $(rawVersion) { 213 ECHO "Variable $(varName) not set. Please run ./configure or" ; 214 EXIT "specify it manually." ; 215 } 216 217 local version = ; 218 # split the raw version string at `.' and `-' characters 219 while $(rawVersion) { 220 local split = [ Match "([^.-]*)[.-](.*)" : $(rawVersion) ] ; 221 if $(split) { 222 version += $(split[1]) ; 223 rawVersion = $(split[2]) ; 224 } else { 225 version += $(rawVersion) ; 226 rawVersion = ; 227 } 228 } 229 230 return $(version) ; 231} 232 233rule SetIncludePropertiesVariables 234{ 235 # SetIncludePropertiesVariables <varPrefix> ; 236 # 237 local prefix = $(1) ; 238 if $($(prefix)_GCC_VERSION[1]) < 4 { 239 $(prefix)_INCLUDES_SEPARATOR = -I- ; 240 $(prefix)_LOCAL_INCLUDES_OPTION = -I ; 241 $(prefix)_SYSTEM_INCLUDES_OPTION = -I ; 242 } else { 243 $(prefix)_INCLUDES_SEPARATOR = ; 244 $(prefix)_LOCAL_INCLUDES_OPTION = "-iquote " ; 245 $(prefix)_SYSTEM_INCLUDES_OPTION = "-idirafter " ; 246 } 247} 248 249 250#pragma mark - 251 252rule SetPlatformForTarget 253{ 254 # SetPlatformForTarget <target> : <platform> ; 255 256 PLATFORM on $(1) = $(2) ; 257} 258 259rule SetSubDirPlatform 260{ 261 # SetSubDirPlatform <platform> ; 262 263 PLATFORM = $(1) ; 264} 265 266rule SetSupportedPlatformsForTarget 267{ 268 # SetSupportedPlatformsForTarget <target> : <platforms> ; 269 270 SUPPORTED_PLATFORMS on $(1) = $(2) ; 271} 272 273rule SetSubDirSupportedPlatforms 274{ 275 # SetSubDirSupportedPlatforms <platforms> ; 276 277 SUPPORTED_PLATFORMS = $(1) ; 278} 279 280rule AddSubDirSupportedPlatforms 281{ 282 # AddSubDirSupportedPlatforms <platforms> ; 283 284 SUPPORTED_PLATFORMS += $(1) ; 285} 286 287rule SetSubDirSupportedPlatformsBeOSCompatible 288{ 289 # SetSubDirSupportedPlatformsBeOSCompatible ; 290 291 SUPPORTED_PLATFORMS = $(HAIKU_BEOS_COMPATIBLE_PLATFORMS) ; 292} 293 294rule IsPlatformSupportedForTarget 295{ 296 # IsPlatformSupportedForTarget <target> [ : <platform> ] 297 # 298 299 on $(1) { 300 if $(PLATFORM) in $(SUPPORTED_PLATFORMS) { 301 return true ; 302 } else { 303 return ; 304 } 305 } 306} 307 308rule InheritPlatform 309{ 310 # InheritPlatform <children> : <parent> ; 311 # PLATFORM and SUPPORTED_PLATFORMS are set on <children> to their value 312 # on <parent>. 313 # 314 local children = $(1) ; 315 local parent = $(2) ; 316 317 on $(parent) { 318 PLATFORM on $(children) = $(PLATFORM) ; 319 SUPPORTED_PLATFORMS on $(children) = $(SUPPORTED_PLATFORMS) ; 320 } 321} 322