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