xref: /haiku/Jamrules (revision 5b189b0e1e2f51f367bfcb126b2f00a3702f352d)
1# Haiku Jamrules
2
3# Make sure we are on a sane version of Jam.
4if ! [ Match "(.*)-haiku-(.*)" : $(JAMVERSION) ] {
5	Exit "You can only build Haiku with Haiku's Jam, not Perforce Jam or"
6		"some other variant (you are using $(JAMVERSION))." ;
7}
8
9# Make sure we are on a recent Jambase.
10if $(JAMBASEDATE) < 2018 {
11	Exit "Your Jambase is too old ($(JAMBASEDATE)); please update it (likely"
12		"by updating Jam itself.)" ;
13}
14
15# Make sure HAIKU_TOP is a relative path (and prefer it to be the current or
16# parent directory.)
17#
18# This is done so that invocations to the compiler and other tools, which
19# under some circumstances inject the source's path into the generated file,
20# are passed relative paths, making builds more reproducible.
21if $(HAIKU_TOP) != "." && $(HAIKU_TOP) != ".."
22		&& ! [ Match "\\.\\./(.*)" : $(HAIKU_TOP) ] {
23	Exit "The present path to the project root is '$(HAIKU_TOP)', but you"
24		"must be in the project root or a \"generated\" directory in order to"
25		"build Haiku."
26
27		"(If you are, and are still seeing this message, run "
28		"\"../configure --update\" to solve the issue.)" ;
29}
30
31# Main directories used by the build.
32HAIKU_OUTPUT_DIR					?= [ FDirName $(HAIKU_TOP) generated ] ;
33HAIKU_BUILD_OUTPUT_DIR				?= [ FDirName $(HAIKU_OUTPUT_DIR) build ] ;
34HAIKU_BUILD_DIR						?= [ FDirName $(HAIKU_TOP) build ] ;
35HAIKU_BUILD_RULES_DIR				?= [ FDirName $(HAIKU_BUILD_DIR) jam ] ;
36HAIKU_OBJECT_DIR					?= [ FDirName $(HAIKU_OUTPUT_DIR)
37											objects ] ;
38HAIKU_CATALOGS_OBJECT_DIR			?= [ FDirName $(HAIKU_OBJECT_DIR)
39											catalogs ] ;
40HAIKU_COMMON_PLATFORM_OBJECT_DIR	?= [ FDirName $(HAIKU_OBJECT_DIR) common ] ;
41HAIKU_DOWNLOAD_DIR					?= [ FDirName $(HAIKU_OUTPUT_DIR)
42											download ] ;
43HAIKU_OPTIONAL_BUILD_PACKAGES_DIR	?= [ FDirName $(HAIKU_OUTPUT_DIR)
44											build_packages ] ;
45
46# Absolutely rooted versions of some of the main directories
47HAIKU_ABSOLUTE_TOP					?= [ FDirName $(PWD) $(HAIKU_TOP) ] ;
48HAIKU_ABSOLUTE_OUTPUT_DIR			?= [ FDirName $(PWD) $(HAIKU_OUTPUT_DIR) ] ;
49
50# Cache files for header scanning and jamfile caching
51HCACHEFILE = header_cache ;
52JCACHEFILE = jamfile_cache ;
53LOCATE on $(HCACHEFILE) $(JCACHEFILE) = $(HAIKU_BUILD_OUTPUT_DIR) ;
54
55# include BuildConfig
56local buildConfig = [ GLOB $(HAIKU_BUILD_OUTPUT_DIR) : BuildConfig ] ;
57if ! $(buildConfig) {
58	ECHO "No `BuildConfig' found in $(HAIKU_BUILD_OUTPUT_DIR)!" ;
59	EXIT "Run ./configure in the source tree's root directory first!" ;
60}
61LOCATE on BuildConfig = $(HAIKU_BUILD_OUTPUT_DIR) ;
62include BuildConfig ;
63
64# set HAIKU_PACKAGING_ARCH, the primary packaging architecture
65HAIKU_PACKAGING_ARCH = $(HAIKU_PACKAGING_ARCHS[1]) ;
66
67# The build setup and rules are neatly organized in several files. Include
68# them now. Start with the side-effect-less rules, since they are the most
69# likely to be used in the top level context (i.e. not only in rules).
70# At the end include BuildSetup that sets up global variables etc. The
71# optional user-defined UserBuildConfig is included thereafter.
72include [ FDirName $(HAIKU_BUILD_RULES_DIR) HelperRules ] ;
73include [ FDirName $(HAIKU_BUILD_RULES_DIR) MathRules ] ;
74include [ FDirName $(HAIKU_BUILD_RULES_DIR) ArchitectureRules ] ;
75include [ FDirName $(HAIKU_BUILD_RULES_DIR) BeOSRules ] ;
76include [ FDirName $(HAIKU_BUILD_RULES_DIR) BuildFeatureRules ] ;
77include [ FDirName $(HAIKU_BUILD_RULES_DIR) LocaleRules ] ;
78include [ FDirName $(HAIKU_BUILD_RULES_DIR) CommandLineArguments ] ;
79include [ FDirName $(HAIKU_BUILD_RULES_DIR) ConfigRules ] ;
80include [ FDirName $(HAIKU_BUILD_RULES_DIR) FileRules ] ;
81include [ FDirName $(HAIKU_BUILD_RULES_DIR) HeadersRules ] ;
82include [ FDirName $(HAIKU_BUILD_RULES_DIR) KernelRules ] ;
83include [ FDirName $(HAIKU_BUILD_RULES_DIR) BootRules ] ;
84include [ FDirName $(HAIKU_BUILD_RULES_DIR) ImageRules ] ;
85include [ FDirName $(HAIKU_BUILD_RULES_DIR) CDRules ] ;
86include [ FDirName $(HAIKU_BUILD_RULES_DIR) MainBuildRules ] ;
87include [ FDirName $(HAIKU_BUILD_RULES_DIR) MiscRules ] ;
88include [ FDirName $(HAIKU_BUILD_RULES_DIR) OverriddenJamRules ] ;
89include [ FDirName $(HAIKU_BUILD_RULES_DIR) PackageRules ] ;
90include [ FDirName $(HAIKU_BUILD_RULES_DIR) RepositoryRules ] ;
91include [ FDirName $(HAIKU_BUILD_RULES_DIR) SystemLibraryRules ] ;
92include [ FDirName $(HAIKU_BUILD_RULES_DIR) TestsRules ] ;
93include [ FDirName $(HAIKU_BUILD_RULES_DIR) BuildSetup ] ;
94include [ FDirName $(HAIKU_BUILD_RULES_DIR) DefaultBuildProfiles ] ;
95
96# Declare no-op user-overridable build rules.
97rule UserBuildConfigRulePostBuildTargets	{ }
98rule UserBuildConfigRulePreImage			{ }
99rule UserBuildConfigRulePostImage			{ }
100
101# Include UserBuildConfig.
102if ! $(HAIKU_IGNORE_USER_BUILD_CONFIG) {
103	local userBuildConfig
104		= [ GLOB $(HAIKU_BUILD_RULES_DIR) : UserBuildConfig ] ;
105	if $(userBuildConfig) {
106		include $(userBuildConfig) ;
107	}
108
109	# allow for a separate UserBuildConfig per output directory
110	local userBuildConfig
111		= [ GLOB $(HAIKU_OUTPUT_DIR) : UserBuildConfig ] ;
112	if $(userBuildConfig) {
113		include $(userBuildConfig) ;
114	}
115}
116
117# Include the repositories for this architecture.
118local repositoriesDirectory
119	= [ FDirName $(HAIKU_BUILD_RULES_DIR) repositories ] ;
120local repositories = HaikuPorts ;
121if $(HAIKU_BUILD_TYPE) = bootstrap {
122	repositories = HaikuPortsCross ;
123}
124
125local repository ;
126for repository in $(repositories) {
127	local repositoryDirectory
128		= [ FDirName $(repositoriesDirectory) $(repository) ] ;
129	local file = [ Glob $(repositoryDirectory) : $(HAIKU_PACKAGING_ARCH) ] ;
130	if $(file) {
131		HAIKU_REPOSITORY_JAMFILE = $(file) ;
132		include $(file) ;
133	}
134}
135
136DefineDefaultBuildProfiles ;
137
138PrepareConfigVariables ;
139