xref: /haiku/Jamrules (revision 9d87b2c5f89ad51c34e67348112d15c163791da8)
1338b8dc3SIngo Weinhold# Haiku Jamrules
2979afc6fSAxel Dörfler
3633e29aeSAugustin Cavalier# Make sure we are on a sane version of Jam.
4633e29aeSAugustin Cavalierif ! [ Match "(.*)-haiku-(.*)" : $(JAMVERSION) ] {
5633e29aeSAugustin Cavalier	Exit "You can only build Haiku with Haiku's Jam, not Perforce Jam or"
6633e29aeSAugustin Cavalier		"some other variant (you are using $(JAMVERSION))." ;
7633e29aeSAugustin Cavalier}
8633e29aeSAugustin Cavalier
9633e29aeSAugustin Cavalier# Make sure we are on a recent Jambase.
10633e29aeSAugustin Cavalierif $(JAMBASEDATE) < 2018 {
11633e29aeSAugustin Cavalier	Exit "Your Jambase is too old ($(JAMBASEDATE)); please update it (likely"
12633e29aeSAugustin Cavalier		"by updating Jam itself.)" ;
13633e29aeSAugustin Cavalier}
14633e29aeSAugustin Cavalier
15c52d856eSAugustin Cavalier# Make sure HAIKU_TOP is a relative path (and prefer it to be the current or
16c52d856eSAugustin Cavalier# parent directory.)
173facc270SAugustin Cavalier#
183facc270SAugustin Cavalier# This is done so that invocations to the compiler and other tools, which
193facc270SAugustin Cavalier# under some circumstances inject the source's path into the generated file,
203facc270SAugustin Cavalier# are passed relative paths, making builds more reproducible.
21c52d856eSAugustin Cavalierif $(HAIKU_TOP) != "." && $(HAIKU_TOP) != ".."
22c52d856eSAugustin Cavalier		&& ! [ Match "\\.\\./(.*)" : $(HAIKU_TOP) ] {
23f7b5d8a1SAugustin Cavalier	Exit "The present path to the project root is '$(HAIKU_TOP)', but you"
24f7b5d8a1SAugustin Cavalier		"must be in the project root or a \"generated\" directory in order to"
25f7b5d8a1SAugustin Cavalier		"build Haiku."
26f7b5d8a1SAugustin Cavalier
27f7b5d8a1SAugustin Cavalier		"(If you are, and are still seeing this message, run "
28f7b5d8a1SAugustin Cavalier		"\"../configure --update\" to solve the issue.)" ;
2963cc5547SOliver Tappe}
3063cc5547SOliver Tappe
31338b8dc3SIngo Weinhold# Main directories used by the build.
32338b8dc3SIngo WeinholdHAIKU_OUTPUT_DIR					?= [ FDirName $(HAIKU_TOP) generated ] ;
33e6d5152fSOliver TappeHAIKU_BUILD_OUTPUT_DIR				?= [ FDirName $(HAIKU_OUTPUT_DIR) build ] ;
34e6d5152fSOliver TappeHAIKU_BUILD_DIR						?= [ FDirName $(HAIKU_TOP) build ] ;
35e6d5152fSOliver TappeHAIKU_BUILD_RULES_DIR				?= [ FDirName $(HAIKU_BUILD_DIR) jam ] ;
36e6d5152fSOliver TappeHAIKU_OBJECT_DIR					?= [ FDirName $(HAIKU_OUTPUT_DIR)
37413a591cSMatt Madia											objects ] ;
38e6d5152fSOliver TappeHAIKU_CATALOGS_OBJECT_DIR			?= [ FDirName $(HAIKU_OBJECT_DIR)
390a53d94bSMatt Madia											catalogs ] ;
40e6d5152fSOliver TappeHAIKU_COMMON_PLATFORM_OBJECT_DIR	?= [ FDirName $(HAIKU_OBJECT_DIR) common ] ;
41e6d5152fSOliver TappeHAIKU_DOWNLOAD_DIR					?= [ FDirName $(HAIKU_OUTPUT_DIR)
421467a878SAxel Dörfler											download ] ;
43e6d5152fSOliver TappeHAIKU_OPTIONAL_BUILD_PACKAGES_DIR	?= [ FDirName $(HAIKU_OUTPUT_DIR)
44ff81d306SIngo Weinhold											build_packages ] ;
454ff6d49fSIngo Weinhold
4668191643SAugustin Cavalier# Absolutely rooted versions of some of the main directories
4768191643SAugustin CavalierHAIKU_ABSOLUTE_TOP					?= [ FDirName $(PWD) $(HAIKU_TOP) ] ;
48f2b20de6SAugustin CavalierHAIKU_ABSOLUTE_OUTPUT_DIR			?= [ FDirName $(PWD) $(HAIKU_OUTPUT_DIR) ] ;
4968191643SAugustin Cavalier
504ff6d49fSIngo Weinhold# Cache files for header scanning and jamfile caching
514ff6d49fSIngo WeinholdHCACHEFILE = header_cache ;
524ff6d49fSIngo WeinholdJCACHEFILE = jamfile_cache ;
53338b8dc3SIngo WeinholdLOCATE on $(HCACHEFILE) $(JCACHEFILE) = $(HAIKU_BUILD_OUTPUT_DIR) ;
549eea4522SIngo Weinhold
55889903f9SIngo Weinhold# include BuildConfig
56889903f9SIngo Weinholdlocal buildConfig = [ GLOB $(HAIKU_BUILD_OUTPUT_DIR) : BuildConfig ] ;
57889903f9SIngo Weinholdif ! $(buildConfig) {
58889903f9SIngo Weinhold	ECHO "No `BuildConfig' found in $(HAIKU_BUILD_OUTPUT_DIR)!" ;
59889903f9SIngo Weinhold	EXIT "Run ./configure in the source tree's root directory first!" ;
60889903f9SIngo Weinhold}
61889903f9SIngo WeinholdLOCATE on BuildConfig = $(HAIKU_BUILD_OUTPUT_DIR) ;
62889903f9SIngo Weinholdinclude BuildConfig ;
63889903f9SIngo Weinhold
64b0944c78SIngo Weinhold# set HAIKU_PACKAGING_ARCH, the primary packaging architecture
65c0e8cc1aSIngo WeinholdHAIKU_PACKAGING_ARCH = $(HAIKU_PACKAGING_ARCHS[1]) ;
66c0e8cc1aSIngo Weinhold
67338b8dc3SIngo Weinhold# The build setup and rules are neatly organized in several files. Include
68338b8dc3SIngo Weinhold# them now. Start with the side-effect-less rules, since they are the most
69338b8dc3SIngo Weinhold# likely to be used in the top level context (i.e. not only in rules).
70338b8dc3SIngo Weinhold# At the end include BuildSetup that sets up global variables etc. The
71338b8dc3SIngo Weinhold# optional user-defined UserBuildConfig is included thereafter.
72338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) HelperRules ] ;
7325b12e83SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) MathRules ] ;
74b0944c78SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) ArchitectureRules ] ;
75338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) BeOSRules ] ;
76d31a50eeSIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) BuildFeatureRules ] ;
77b891b0acSOliver Tappeinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) LocaleRules ] ;
7837aefc9cSIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) CommandLineArguments ] ;
79338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) ConfigRules ] ;
80338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) FileRules ] ;
81338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) HeadersRules ] ;
82338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) KernelRules ] ;
8365ad1ba3SAlex Smithinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) BootRules ] ;
84338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) ImageRules ] ;
85e2c3dec9SMichael Lotzinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) CDRules ] ;
86338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) MainBuildRules ] ;
87338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) MiscRules ] ;
88338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) OverriddenJamRules ] ;
89338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) PackageRules ] ;
9098c6dfa4SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) RepositoryRules ] ;
91ed25955aSOliver Tappeinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) SystemLibraryRules ] ;
92338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) TestsRules ] ;
93338b8dc3SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) BuildSetup ] ;
94b9eec519SIngo Weinholdinclude [ FDirName $(HAIKU_BUILD_RULES_DIR) DefaultBuildProfiles ] ;
95b1e5b60cSAxel Dörfler
96*9d87b2c5SAdrien Destugues# Include the repositories for this architecture.
97*9d87b2c5SAdrien Destugueslocal repositoriesDirectory
98*9d87b2c5SAdrien Destugues	= [ FDirName $(HAIKU_BUILD_RULES_DIR) repositories ] ;
99*9d87b2c5SAdrien Destugueslocal repositories = HaikuPorts ;
100*9d87b2c5SAdrien Destuguesif $(HAIKU_BUILD_TYPE) = bootstrap {
101*9d87b2c5SAdrien Destugues	repositories = HaikuPortsCross ;
102*9d87b2c5SAdrien Destugues}
103*9d87b2c5SAdrien Destugues
104*9d87b2c5SAdrien Destugueslocal repository ;
105*9d87b2c5SAdrien Destuguesfor repository in $(repositories) {
106*9d87b2c5SAdrien Destugues	local repositoryDirectory
107*9d87b2c5SAdrien Destugues		= [ FDirName $(repositoriesDirectory) $(repository) ] ;
108*9d87b2c5SAdrien Destugues	local file = [ Glob $(repositoryDirectory) : $(HAIKU_PACKAGING_ARCH) ] ;
109*9d87b2c5SAdrien Destugues	if $(file) {
110*9d87b2c5SAdrien Destugues		HAIKU_REPOSITORY_JAMFILE = $(file) ;
111*9d87b2c5SAdrien Destugues		include $(file) ;
112*9d87b2c5SAdrien Destugues	}
113*9d87b2c5SAdrien Destugues}
114*9d87b2c5SAdrien Destugues
11530ed37c8SIngo Weinhold# Declare no-op user-overridable build rules.
11630ed37c8SIngo Weinholdrule UserBuildConfigRulePostBuildTargets	{ }
11730ed37c8SIngo Weinholdrule UserBuildConfigRulePreImage			{ }
11830ed37c8SIngo Weinholdrule UserBuildConfigRulePostImage			{ }
11930ed37c8SIngo Weinhold
120338b8dc3SIngo Weinhold# Include UserBuildConfig.
121a4a52ab2SIngo Weinholdif ! $(HAIKU_IGNORE_USER_BUILD_CONFIG) {
122338b8dc3SIngo Weinhold	local userBuildConfig
123338b8dc3SIngo Weinhold		= [ GLOB $(HAIKU_BUILD_RULES_DIR) : UserBuildConfig ] ;
124338b8dc3SIngo Weinhold	if $(userBuildConfig) {
125338b8dc3SIngo Weinhold		include $(userBuildConfig) ;
1268c17a26bSIngo Weinhold	}
127d5ec51caSMichael Lotz
128d5ec51caSMichael Lotz	# allow for a separate UserBuildConfig per output directory
129d5ec51caSMichael Lotz	local userBuildConfig
130d5ec51caSMichael Lotz		= [ GLOB $(HAIKU_OUTPUT_DIR) : UserBuildConfig ] ;
131d5ec51caSMichael Lotz	if $(userBuildConfig) {
132d5ec51caSMichael Lotz		include $(userBuildConfig) ;
133d5ec51caSMichael Lotz	}
1348c17a26bSIngo Weinhold}
1358c17a26bSIngo Weinhold
136b9eec519SIngo WeinholdDefineDefaultBuildProfiles ;
137a0a9d225SIngo Weinhold
138338b8dc3SIngo WeinholdPrepareConfigVariables ;
139