1# Haiku Jamrules
2
3# Make sure we have an absolute HAIKU_TOP
4if $(HAIKU_TOP) = "." {
5	HAIKU_TOP = $(PWD) ;
6}
7
8# Main directories used by the build.
9HAIKU_OUTPUT_DIR					?= [ FDirName $(HAIKU_TOP) generated ] ;
10HAIKU_BUILD_OUTPUT_DIR				?= [ FDirName $(HAIKU_OUTPUT_DIR) build ] ;
11HAIKU_BUILD_DIR						?= [ FDirName $(HAIKU_TOP) build ] ;
12HAIKU_BUILD_RULES_DIR				?= [ FDirName $(HAIKU_BUILD_DIR) jam ] ;
13HAIKU_OBJECT_DIR					?= [ FDirName $(HAIKU_OUTPUT_DIR)
14											objects ] ;
15HAIKU_CATALOGS_OBJECT_DIR			?= [ FDirName $(HAIKU_OBJECT_DIR)
16											catalogs ] ;
17HAIKU_COMMON_PLATFORM_OBJECT_DIR	?= [ FDirName $(HAIKU_OBJECT_DIR) common ] ;
18HAIKU_DOWNLOAD_DIR					?= [ FDirName $(HAIKU_OUTPUT_DIR)
19											download ] ;
20HAIKU_OPTIONAL_BUILD_PACKAGES_DIR	?= [ FDirName $(HAIKU_OUTPUT_DIR)
21											build_packages ] ;
22
23# Cache files for header scanning and jamfile caching
24HCACHEFILE = header_cache ;
25JCACHEFILE = jamfile_cache ;
26LOCATE on $(HCACHEFILE) $(JCACHEFILE) = $(HAIKU_BUILD_OUTPUT_DIR) ;
27
28# include BuildConfig
29local buildConfig = [ GLOB $(HAIKU_BUILD_OUTPUT_DIR) : BuildConfig ] ;
30if ! $(buildConfig) {
31	ECHO "No `BuildConfig' found in $(HAIKU_BUILD_OUTPUT_DIR)!" ;
32	EXIT "Run ./configure in the source tree's root directory first!" ;
33}
34LOCATE on BuildConfig = $(HAIKU_BUILD_OUTPUT_DIR) ;
35include BuildConfig ;
36
37# set HAIKU_PACKAGING_ARCH, the primary packaging architecture
38HAIKU_PACKAGING_ARCH = $(HAIKU_PACKAGING_ARCHS[1]) ;
39
40# The build setup and rules are neatly organized in several files. Include
41# them now. Start with the side-effect-less rules, since they are the most
42# likely to be used in the top level context (i.e. not only in rules).
43# At the end include BuildSetup that sets up global variables etc. The
44# optional user-defined UserBuildConfig is included thereafter.
45include [ FDirName $(HAIKU_BUILD_RULES_DIR) HelperRules ] ;
46include [ FDirName $(HAIKU_BUILD_RULES_DIR) MathRules ] ;
47include [ FDirName $(HAIKU_BUILD_RULES_DIR) ArchitectureRules ] ;
48include [ FDirName $(HAIKU_BUILD_RULES_DIR) BeOSRules ] ;
49include [ FDirName $(HAIKU_BUILD_RULES_DIR) BuildFeatureRules ] ;
50include [ FDirName $(HAIKU_BUILD_RULES_DIR) LocaleRules ] ;
51include [ FDirName $(HAIKU_BUILD_RULES_DIR) CommandLineArguments ] ;
52include [ FDirName $(HAIKU_BUILD_RULES_DIR) ConfigRules ] ;
53include [ FDirName $(HAIKU_BUILD_RULES_DIR) FileRules ] ;
54include [ FDirName $(HAIKU_BUILD_RULES_DIR) HeadersRules ] ;
55include [ FDirName $(HAIKU_BUILD_RULES_DIR) KernelRules ] ;
56include [ FDirName $(HAIKU_BUILD_RULES_DIR) BootRules ] ;
57include [ FDirName $(HAIKU_BUILD_RULES_DIR) ImageRules ] ;
58include [ FDirName $(HAIKU_BUILD_RULES_DIR) CDRules ] ;
59include [ FDirName $(HAIKU_BUILD_RULES_DIR) MainBuildRules ] ;
60include [ FDirName $(HAIKU_BUILD_RULES_DIR) MiscRules ] ;
61include [ FDirName $(HAIKU_BUILD_RULES_DIR) OverriddenJamRules ] ;
62include [ FDirName $(HAIKU_BUILD_RULES_DIR) PackageRules ] ;
63include [ FDirName $(HAIKU_BUILD_RULES_DIR) RepositoryRules ] ;
64include [ FDirName $(HAIKU_BUILD_RULES_DIR) SystemLibraryRules ] ;
65include [ FDirName $(HAIKU_BUILD_RULES_DIR) TestsRules ] ;
66include [ FDirName $(HAIKU_BUILD_RULES_DIR) BuildSetup ] ;
67include [ FDirName $(HAIKU_BUILD_RULES_DIR) DefaultBuildProfiles ] ;
68
69# Include the repositories for this architecture.
70local repositoriesDirectory
71	= [ FDirName $(HAIKU_BUILD_RULES_DIR) repositories ] ;
72local repositories = HaikuPorts ;
73if $(HAIKU_BUILD_TYPE) = bootstrap {
74	repositories = HaikuPortsCross ;
75}
76
77local repository ;
78for repository in $(repositories) {
79	local repositoryDirectory
80		= [ FDirName $(repositoriesDirectory) $(repository) ] ;
81	local file = [ Glob $(repositoryDirectory) : $(HAIKU_PACKAGING_ARCH) ] ;
82	if $(file) {
83		HAIKU_REPOSITORY_JAMFILE = $(file) ;
84		include $(file) ;
85	}
86}
87
88# Declare no-op user-overridable build rules.
89rule UserBuildConfigRulePostBuildTargets	{ }
90rule UserBuildConfigRulePreImage			{ }
91rule UserBuildConfigRulePostImage			{ }
92
93# Include UserBuildConfig.
94if ! $(HAIKU_IGNORE_USER_BUILD_CONFIG) {
95	local userBuildConfig
96		= [ GLOB $(HAIKU_BUILD_RULES_DIR) : UserBuildConfig ] ;
97	if $(userBuildConfig) {
98		include $(userBuildConfig) ;
99	}
100
101	# allow for a separate UserBuildConfig per output directory
102	local userBuildConfig
103		= [ GLOB $(HAIKU_OUTPUT_DIR) : UserBuildConfig ] ;
104	if $(userBuildConfig) {
105		include $(userBuildConfig) ;
106	}
107}
108
109DefineDefaultBuildProfiles ;
110
111PrepareConfigVariables ;
112