1338b8dc3SIngo Weinhold# Haiku Jamrules 2979afc6fSAxel Dörfler 3c52d856eSAugustin Cavalier# Make sure HAIKU_TOP is a relative path (and prefer it to be the current or 4c52d856eSAugustin Cavalier# parent directory.) 53facc270SAugustin Cavalier# 63facc270SAugustin Cavalier# This is done so that invocations to the compiler and other tools, which 73facc270SAugustin Cavalier# under some circumstances inject the source's path into the generated file, 83facc270SAugustin Cavalier# are passed relative paths, making builds more reproducible. 9c52d856eSAugustin Cavalierif $(HAIKU_TOP) != "." && $(HAIKU_TOP) != ".." 10c52d856eSAugustin Cavalier && ! [ Match "\\.\\./(.*)" : $(HAIKU_TOP) ] { 11f7b5d8a1SAugustin Cavalier Exit "The present path to the project root is '$(HAIKU_TOP)', but you" 12f7b5d8a1SAugustin Cavalier "must be in the project root or a \"generated\" directory in order to" 13f7b5d8a1SAugustin Cavalier "build Haiku." 14f7b5d8a1SAugustin Cavalier 15f7b5d8a1SAugustin Cavalier "(If you are, and are still seeing this message, run " 16f7b5d8a1SAugustin Cavalier "\"../configure --update\" to solve the issue.)" ; 1763cc5547SOliver Tappe} 1863cc5547SOliver Tappe 19338b8dc3SIngo Weinhold# Main directories used by the build. 20338b8dc3SIngo WeinholdHAIKU_OUTPUT_DIR ?= [ FDirName $(HAIKU_TOP) generated ] ; 21e6d5152fSOliver TappeHAIKU_BUILD_OUTPUT_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) build ] ; 22e6d5152fSOliver TappeHAIKU_BUILD_DIR ?= [ FDirName $(HAIKU_TOP) build ] ; 23e6d5152fSOliver TappeHAIKU_BUILD_RULES_DIR ?= [ FDirName $(HAIKU_BUILD_DIR) jam ] ; 24e6d5152fSOliver TappeHAIKU_OBJECT_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) 25413a591cSMatt Madia objects ] ; 26e6d5152fSOliver TappeHAIKU_CATALOGS_OBJECT_DIR ?= [ FDirName $(HAIKU_OBJECT_DIR) 270a53d94bSMatt Madia catalogs ] ; 28e6d5152fSOliver TappeHAIKU_COMMON_PLATFORM_OBJECT_DIR ?= [ FDirName $(HAIKU_OBJECT_DIR) common ] ; 29e6d5152fSOliver TappeHAIKU_DOWNLOAD_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) 301467a878SAxel Dörfler download ] ; 31e6d5152fSOliver TappeHAIKU_OPTIONAL_BUILD_PACKAGES_DIR ?= [ FDirName $(HAIKU_OUTPUT_DIR) 32ff81d306SIngo Weinhold build_packages ] ; 334ff6d49fSIngo Weinhold 34*68191643SAugustin Cavalier# Absolutely rooted versions of some of the main directories 35*68191643SAugustin CavalierHAIKU_ABSOLUTE_TOP ?= [ FDirName $(PWD) $(HAIKU_TOP) ] ; 36*68191643SAugustin CavalierHAIKU_ABSOLUTE_OUTPUT_DIR ?= [ FDirName $(HAIKU_ABSOLUTE_TOP) generated ] ; 37*68191643SAugustin Cavalier 384ff6d49fSIngo Weinhold# Cache files for header scanning and jamfile caching 394ff6d49fSIngo WeinholdHCACHEFILE = header_cache ; 404ff6d49fSIngo WeinholdJCACHEFILE = jamfile_cache ; 41338b8dc3SIngo WeinholdLOCATE on $(HCACHEFILE) $(JCACHEFILE) = $(HAIKU_BUILD_OUTPUT_DIR) ; 429eea4522SIngo Weinhold 43889903f9SIngo Weinhold# include BuildConfig 44889903f9SIngo Weinholdlocal buildConfig = [ GLOB $(HAIKU_BUILD_OUTPUT_DIR) : BuildConfig ] ; 45889903f9SIngo Weinholdif ! $(buildConfig) { 46889903f9SIngo Weinhold ECHO "No `BuildConfig' found in $(HAIKU_BUILD_OUTPUT_DIR)!" ; 47889903f9SIngo Weinhold EXIT "Run ./configure in the source tree's root directory first!" ; 48889903f9SIngo Weinhold} 49889903f9SIngo WeinholdLOCATE on BuildConfig = $(HAIKU_BUILD_OUTPUT_DIR) ; 50889903f9SIngo Weinholdinclude BuildConfig ; 51889903f9SIngo Weinhold 52b0944c78SIngo Weinhold# set HAIKU_PACKAGING_ARCH, the primary packaging architecture 53c0e8cc1aSIngo WeinholdHAIKU_PACKAGING_ARCH = $(HAIKU_PACKAGING_ARCHS[1]) ; 54c0e8cc1aSIngo Weinhold 55338b8dc3SIngo Weinhold# The build setup and rules are neatly organized in several files. Include 56338b8dc3SIngo Weinhold# them now. Start with the side-effect-less rules, since they are the most 57338b8dc3SIngo Weinhold# likely to be used in the top level context (i.e. not only in rules). 58338b8dc3SIngo Weinhold# At the end include BuildSetup that sets up global variables etc. The 59338b8dc3SIngo Weinhold# optional user-defined UserBuildConfig is included thereafter. 60338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) HelperRules ] ; 6125b12e83SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) MathRules ] ; 62b0944c78SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) ArchitectureRules ] ; 63338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) BeOSRules ] ; 64d31a50eeSIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) BuildFeatureRules ] ; 65b891b0acSOliver Tappeinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) LocaleRules ] ; 6637aefc9cSIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) CommandLineArguments ] ; 67338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) ConfigRules ] ; 68338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) FileRules ] ; 69338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) HeadersRules ] ; 70338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) KernelRules ] ; 7165ad1ba3SAlex Smithinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) BootRules ] ; 72338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) ImageRules ] ; 73e2c3dec9SMichael Lotzinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) CDRules ] ; 74338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) MainBuildRules ] ; 75338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) MiscRules ] ; 76338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) OverriddenJamRules ] ; 77338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) PackageRules ] ; 7898c6dfa4SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) RepositoryRules ] ; 79ed25955aSOliver Tappeinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) SystemLibraryRules ] ; 80338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) TestsRules ] ; 81338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) BuildSetup ] ; 82b9eec519SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) DefaultBuildProfiles ] ; 83b1e5b60cSAxel Dörfler 8498c6dfa4SIngo Weinhold# Include the repositories for this architecture. 8598c6dfa4SIngo Weinholdlocal repositoriesDirectory 8698c6dfa4SIngo Weinhold = [ FDirName $(HAIKU_BUILD_RULES_DIR) repositories ] ; 87e173a1ecSIngo Weinholdlocal repositories = HaikuPorts ; 88a8c098a3SOliver Tappeif $(HAIKU_BUILD_TYPE) = bootstrap { 89e173a1ecSIngo Weinhold repositories = HaikuPortsCross ; 90e173a1ecSIngo Weinhold} 91e173a1ecSIngo Weinhold 9298c6dfa4SIngo Weinholdlocal repository ; 93e173a1ecSIngo Weinholdfor repository in $(repositories) { 9498c6dfa4SIngo Weinhold local repositoryDirectory 9598c6dfa4SIngo Weinhold = [ FDirName $(repositoriesDirectory) $(repository) ] ; 9698c6dfa4SIngo Weinhold local file = [ Glob $(repositoryDirectory) : $(HAIKU_PACKAGING_ARCH) ] ; 9798c6dfa4SIngo Weinhold if $(file) { 98d72ce066SIngo Weinhold HAIKU_REPOSITORY_JAMFILE = $(file) ; 9998c6dfa4SIngo Weinhold include $(file) ; 10098c6dfa4SIngo Weinhold } 10198c6dfa4SIngo Weinhold} 10298c6dfa4SIngo Weinhold 10330ed37c8SIngo Weinhold# Declare no-op user-overridable build rules. 10430ed37c8SIngo Weinholdrule UserBuildConfigRulePostBuildTargets { } 10530ed37c8SIngo Weinholdrule UserBuildConfigRulePreImage { } 10630ed37c8SIngo Weinholdrule UserBuildConfigRulePostImage { } 10730ed37c8SIngo Weinhold 108338b8dc3SIngo Weinhold# Include UserBuildConfig. 109a4a52ab2SIngo Weinholdif ! $(HAIKU_IGNORE_USER_BUILD_CONFIG) { 110338b8dc3SIngo Weinhold local userBuildConfig 111338b8dc3SIngo Weinhold = [ GLOB $(HAIKU_BUILD_RULES_DIR) : UserBuildConfig ] ; 112338b8dc3SIngo Weinhold if $(userBuildConfig) { 113338b8dc3SIngo Weinhold include $(userBuildConfig) ; 1148c17a26bSIngo Weinhold } 115d5ec51caSMichael Lotz 116d5ec51caSMichael Lotz # allow for a separate UserBuildConfig per output directory 117d5ec51caSMichael Lotz local userBuildConfig 118d5ec51caSMichael Lotz = [ GLOB $(HAIKU_OUTPUT_DIR) : UserBuildConfig ] ; 119d5ec51caSMichael Lotz if $(userBuildConfig) { 120d5ec51caSMichael Lotz include $(userBuildConfig) ; 121d5ec51caSMichael Lotz } 1228c17a26bSIngo Weinhold} 1238c17a26bSIngo Weinhold 124b9eec519SIngo WeinholdDefineDefaultBuildProfiles ; 125a0a9d225SIngo Weinhold 126338b8dc3SIngo WeinholdPrepareConfigVariables ; 127