1# FIncludes <dirs> ; 2# 3# Overridden to support a second argument, the option to be used. 4# 5rule FIncludes 6{ 7 return $(2:E="--bad-include-option ")$(1) ; 8} 9 10 11# FSysIncludes <dirs> ; 12# 13# Counterpart of FIncludes for system include search paths. 14# 15rule FSysIncludes 16{ 17 return $(2:E="--bad-include-option ")$(1) ; 18} 19 20 21rule SubDirSysHdrs 22{ 23 # SubDirSysHdrs <dirs> ; 24 # 25 # Adds directories to the system include search paths for the current 26 # subdirectory. Counterpart of SubDirHdrs which adds non-system include 27 # search paths. 28 # 29 # <dirs>: The directories to be added to the current subdir's system 30 # include search paths. 31 # 32 SUBDIRSYSHDRS += [ FDirName $(1) ] ; 33} 34 35 36rule ObjectSysHdrs 37{ 38 # ObjectSysHdrs <sources or objects> : <headers> : <gristed objects> 39 # 40 # Adds directories to the system include search paths for the given 41 # sources or objects. Counterpart of ObjectHdrs which adds non-system 42 # include search paths. 43 # 44 # NOTE: With this incarnation of the Haiku build system this rule doesn't 45 # need to be invoked *after* the rule that generates the objects anymore. 46 # Actually it is even encouraged to do that *before*. Same for ObjectHdrs. 47 # 48 # <sources or objects>: The targets for which to add system include 49 # search paths. 50 # <dirs>: The directories to be added to the given objects' system 51 # include search paths. 52 # 53 54 local objects = [ FGristFiles $(1:S=$(SUFOBJ)) ] $(3) ; 55 local headers = $(2) ; 56 57 local file ; 58 for file in $(objects) { 59 on $(file) { 60 local sysHeaders = $(SYSHDRS) $(headers) ; 61 SYSHDRS on $(file) = $(sysHeaders) ; 62 63 # reformat ASHDRS and CCHDRS 64 local fileHeaders ; 65 66 if $(PLATFORM) = host { 67 fileHeaders = 68 [ FIncludes $(HDRS) : $(HOST_LOCAL_INCLUDES_OPTION) ] 69 $(HOST_INCLUDES_SEPARATOR) 70 [ FSysIncludes $(sysHeaders) 71 : $(HOST_SYSTEM_INCLUDES_OPTION) ] ; 72 } else { 73 local architecture = $(TARGET_PACKAGING_ARCH) ; 74 fileHeaders = 75 [ FIncludes $(HDRS) 76 : $(TARGET_LOCAL_INCLUDES_OPTION_$(architecture)) ] 77 $(TARGET_INCLUDES_SEPARATOR_$(architecture)) 78 [ FSysIncludes $(sysHeaders) 79 : $(TARGET_SYSTEM_INCLUDES_OPTION_$(architecture)) ] ; 80 } 81 82 ASHDRS on $(file) = $(fileHeaders) ; 83 CCHDRS on $(file) = $(fileHeaders) ; 84 } 85 } 86} 87 88 89rule SourceHdrs 90{ 91 # SourceHdrs <sources> : <headers> [ : <gristed objects> ] ; 92 # 93 # Is a wrapper for ObjectHdrs, that passes <sources> and <headers> or, 94 # if supplied <objects> and <headers>, and also adjusts HDRSEARCH (not 95 # done by ObjectHdrs). 96 97 local sources = [ FGristFiles $(1) ] ; 98 local headers = $(2) ; 99 local objects = $(3) ; 100 101 ObjectHdrs $(sources) : $(headers) : $(objects) ; 102 103 # Also add the header search dirs to HDRSEARCH. Note, that these dirs 104 # will be listed after the STDHDRS (if any), but that's better than not 105 # being listed at all. 106 HDRSEARCH on $(sources) += $(headers) ; 107} 108 109 110rule SourceSysHdrs 111{ 112 # SourceSysHdrs <sources> : <headers> [ : <gristed objects> ] ; 113 # 114 # Is a wrapper for ObjectSysHdrs, that passes <sources> and <headers> or, 115 # if supplied <objects> and <headers>, and also adjusts HDRSEARCH (not 116 # done by ObjectSysHdrs). 117 118 local sources = [ FGristFiles $(1) ] ; 119 local headers = $(2) ; 120 local objects = $(3) ; 121 122 ObjectSysHdrs $(sources) : $(headers) : $(objects) ; 123 124 # Also add the header search dirs to HDRSEARCH. Note, that these dirs 125 # will be listed after the STDHDRS (if any), but that's better than not 126 # being listed at all. 127 HDRSEARCH on $(sources) += $(headers) ; 128} 129 130 131rule PublicHeaders 132{ 133 # PublicHeaders <group list> 134 # 135 # Returns the directory names for the public header dirs identified by 136 # <group list>. 137 138 local list = $(1) ; 139 local dirs ; 140 local i ; 141 for i in $(list) { 142 dirs += [ FDirName $(HAIKU_TOP) headers os $(i) ] ; 143 } 144 return $(dirs) ; 145} 146 147 148rule PrivateHeaders 149{ 150 # PrivateHeaders <group list> 151 # 152 # Returns the directory names for the private header dirs identified by 153 # <group list>. 154 155 local list = $(1) ; 156 local dirs ; 157 local i ; 158 for i in $(list) { 159 dirs += [ FDirName $(HAIKU_TOP) headers private $(i) ] ; 160 } 161 return $(dirs) ; 162} 163 164 165rule PrivateBuildHeaders 166{ 167 # PrivateBuildHeaders <group list> 168 # 169 # Returns the directory names for the private build header dirs identified 170 # by <group list>. 171 172 local list = $(1) ; 173 local dirs ; 174 local i ; 175 for i in $(list) { 176 dirs += [ FDirName $(HAIKU_TOP) headers build private $(i) ] ; 177 } 178 return $(dirs) ; 179} 180 181 182rule LibraryHeaders 183{ 184 # LibraryHeaders <group list> 185 # 186 # Returns the directory names for the library header dirs identified by 187 # <group list>. 188 189 local list = $(1) ; 190 local dirs ; 191 local i ; 192 for i in $(list) { 193 dirs += [ FDirName $(HAIKU_TOP) headers libs $(i) ] ; 194 } 195 return $(dirs) ; 196} 197 198 199rule ArchHeaders 200{ 201 # usage: ArchHeaders <arch> ; 202 # 203 # <arch> specifies the architecture (e.g. x86). 204 205 return [ FDirName $(HAIKU_TOP) headers private kernel arch $(1) ] ; 206} 207 208 209rule UseHeaders 210{ 211 # UseHeaders <headers> [ : <system> ] ; 212 # 213 # Adds the C header dirs <headers> to the header search 214 # dirs of the subdirectory. 215 # If <system> is "true", the dirs are added as system otherwise local 216 # search dirs. 217 # NOTE: This rule must be invoked *before* the rule that builds the objects. 218 219 local header ; 220 if $(2) = true { 221 for header in $(1) { 222 SubDirSysHdrs $(header) ; 223 } 224 } else { 225 for header in $(1) { 226 SubDirHdrs $(header) ; 227 } 228 } 229} 230 231 232rule UsePublicHeaders 233{ 234 # UsePublicHeaders <group list> ; 235 # 236 # Adds the public C header dirs given by <group list> to the header search 237 # dirs of the subdirectory. 238 # NOTE: This rule must be invoked *before* the rule that builds the 239 # objects. 240 241 UseHeaders [ PublicHeaders $(1) ] : true ; 242} 243 244 245rule UsePublicObjectHeaders 246{ 247 # UsePublicObjectHeaders <sources> : <group list> [ : <objects> ] ; 248 # 249 # Adds the public C header dirs given by <group list> to the header search 250 # dirs of either the object targets of <sources> or if supplied to 251 # <objects>. Also adjusts HDRSEARCH of <sources>. 252 253 SourceSysHdrs $(1) : [ PublicHeaders $(2) ] : $(3) ; 254} 255 256 257rule UsePrivateHeaders 258{ 259 # UsePrivateHeaders <group list> [ : <system> ] ; 260 # 261 # Adds the private C header dirs given by <group list> to the header search 262 # dirs of the subdirectory. 263 # <system> specifies whether to add the dirs as system or local header 264 # search dirs. Defaults to "true". 265 # NOTE: This rule must be invoked *before* the rule that builds the objects. 266 267 local system = $(2) ; 268 system ?= true ; 269 270 UseHeaders [ PrivateHeaders $(1) ] : $(system) ; 271} 272 273 274rule UsePrivateObjectHeaders 275{ 276 # UsePrivateObjectHeaders <sources> : <group list> [ : <objects> 277 # [ : <system> ] ] ; 278 # 279 # Adds the private C header dirs given by <group list> to the header search 280 # dirs of either the object targets of <sources> or if supplied to 281 # <objects>. Also adjusts HDRSEARCH of <sources>. 282 # <system> specifies whether to add the dirs as system or local header 283 # search dirs. Defaults to "true". 284 285 local system = $(4) ; 286 system ?= true ; 287 288 if $(system) = true { 289 SourceSysHdrs $(1) : [ PrivateHeaders $(2) ] : $(3) ; 290 } else { 291 SourceHdrs $(1) : [ PrivateHeaders $(2) ] : $(3) ; 292 } 293} 294 295 296rule UsePrivateBuildHeaders 297{ 298 # UsePrivateBuildHeaders <group list> [ : <system> ] ; 299 # 300 # Adds the private build C header dirs given by <group list> to the header 301 # search dirs of the subdirectory. 302 # <system> specifies whether to add the dirs as system or local header 303 # search dirs. Defaults to "true". 304 # NOTE: This rule must be invoked *before* the rule that builds the objects. 305 306 local system = $(2) ; 307 system ?= true ; 308 309 UseHeaders [ PrivateBuildHeaders $(1) ] : $(system) ; 310} 311 312 313rule UseCppUnitHeaders 314{ 315 SubDirSysHdrs [ FDirName $(HAIKU_TOP) headers tools cppunit ] ; 316} 317 318 319rule UseCppUnitObjectHeaders 320{ 321 # UseCppUnitObjectHeaders <sources> [ : <objects> ] ; 322 SourceSysHdrs $(1) : [ FDirName $(HAIKU_TOP) headers tools cppunit ] 323 : $(2) ; 324} 325 326 327rule UseArchHeaders 328{ 329 # usage: UseArchHeaders <arch> ; 330 # 331 # <arch> specifies the architecture (e.g. x86). 332 # NOTE: This rule must be invoked *before* the rule that builds the objects. 333 334 local headers = [ ArchHeaders $(1) ] ; 335 336 UseHeaders $(headers) : true ; 337} 338 339 340rule UseArchObjectHeaders 341{ 342 # usage: UseArchObjectHeaders <sources> : <arch> : [ <objects> ] ; 343 # 344 # <arch> specifies the architecture (e.g. x86). 345 # <sources_or_objects> Source or object files. 346 347 local sources = $(1) ; 348 local headers = [ ArchHeaders $(2) ] ; 349 local objects = $(3) ; 350 local targets ; 351 if $(objects) { 352 targets = $(objects) ; 353 } else { 354 targets = [ FGristFiles $(sources:S=$(SUFOBJ)) ] ; 355 } 356 357 SourceSysHdrs $(sources) : $(headers) : $(objects) ; 358} 359 360 361rule UsePosixObjectHeaders 362{ 363 # UsePosixObjectHeaders <sources> [ : <objects> ] ; 364 # 365 # Adds the POSIX header dir to the header search 366 # dirs of either the object targets of <sources> or if supplied to 367 # <objects>. Also adjusts HDRSEARCH of <sources>. 368 369 SourceSysHdrs $(1) : [ FDirName $(HAIKU_TOP) headers posix ] : $(2) ; 370} 371 372 373rule UseLibraryHeaders 374{ 375 # UseLibraryHeaders <group list> ; 376 # 377 # Adds the library header dirs given by <group list> to the header search 378 # dirs of the subdirectory. 379 # NOTE: This rule must be invoked *before* the rule that builds the objects. 380 381 UseHeaders [ LibraryHeaders $(1) ] : true ; 382} 383 384 385rule UseLegacyHeaders 386{ 387 # usage: UseLegacyHeaders <group list> ; 388 # 389 # NOTE: This rule must be invoked *before* the rule that builds the objects. 390 391 UseHeaders [ FDirName $(HAIKU_TOP) headers legacy $(1) ] : true ; 392} 393 394 395rule UseLegacyObjectHeaders 396{ 397 # UseLegacyObjectHeaders <sources> [ : <objects> ] ; 398 # 399 # Adds the legacy header dir to the header search 400 # dirs of either the object targets of <sources> or if supplied to 401 # <objects>. Also adjusts HDRSEARCH of <sources>. 402 403 SourceSysHdrs $(1) : [ FDirName $(HAIKU_TOP) headers legacy ] : $(2) ; 404} 405 406 407rule UsePrivateKernelHeaders 408{ 409 UseHeaders $(TARGET_PRIVATE_KERNEL_HEADERS) : true ; 410} 411 412 413rule UsePrivateSystemHeaders 414{ 415 UseHeaders $(TARGET_PRIVATE_SYSTEM_HEADERS_$(TARGET_PACKAGING_ARCH)) 416 : true ; 417} 418 419 420rule UseBuildFeatureHeaders feature : attribute 421{ 422 # UseBuildFeatureHeaders <feature> : [ <attribute> ] ; 423 # A shorthand for 424 # UseHeaders [ BuildFeatureAttribute <feature> : <attribute> ] : true ; 425 # Moreover the default value for <attribute> is "headers", which usually 426 # allows the rule to be called with the feature name as the only parameter. 427 428 local headers = [ BuildFeatureAttribute $(feature) : $(attribute:E=headers) 429 : path ] ; 430 UseHeaders $(headers) : true ; 431} 432 433 434rule FStandardOSHeaders 435{ 436 local osIncludes = add-ons add-ons/file_system add-ons/graphics 437 add-ons/input_server add-ons/registrar 438 add-ons/screen_saver 439 add-ons/tracker app device drivers game interface 440 kernel locale media mail midi midi2 net storage 441 support translation ; 442 443 return [ FDirName $(HAIKU_TOP) headers os ] 444 [ PublicHeaders $(osIncludes) ] ; 445} 446 447 448rule FStandardHeaders architecture 449{ 450 local osIncludes = add-ons add-ons/file_system add-ons/graphics 451 add-ons/input_server add-ons/registrar 452 add-ons/screen_saver 453 add-ons/tracker app device drivers game interface 454 kernel locale media mail midi midi2 net storage 455 support translation ; 456 457 local headers = ; 458 459 if $(HAIKU_CC_IS_CLANG_$(architecture)) = 1 { 460 headers += [ FDirName $(HAIKU_OUTPUT_DIR) clang_headers ] ; 461 } 462 463 # The c++ headers. 464 headers += [ C++HeaderDirectories $(architecture) ] ; 465 466 # The gcc headers. 467 headers += [ GccHeaderDirectories $(architecture) ] ; 468 469 # Use headers directory, to allow to do things like include <posix/string.h> 470 headers += [ FDirName $(HAIKU_TOP) headers ] ; 471 472 # Use posix headers directory 473 headers += [ FDirName $(HAIKU_TOP) headers posix ] ; 474 475 # Use glibc headers 476 headers += [ FDirName $(HAIKU_TOP) headers glibc ] ; 477 478 # Use public OS header directories 479 headers += [ FDirName $(HAIKU_TOP) headers os ] ; 480 headers += [ PublicHeaders $(osIncludes) ] ; 481 482 # Use the root of the private headers -- not so nice, but simplifies things. 483 headers += [ PrivateHeaders $(DOT) ] ; 484 485 return $(headers) ; 486} 487 488 489# SUBDIRSYSHDRS shall be reset automatically for each subdir 490SUBDIRRESET += SYSHDRS ; 491