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