1SubDir HAIKU_TOP ;
2
3# Prepare the optional build features before parsing the Jamfile tree.
4local architectureObject ;
5for architectureObject in [ MultiArchSubDirSetup ] {
6	on $(architectureObject) {
7		include [ FDirName $(HAIKU_BUILD_RULES_DIR) BuildFeatures ] ;
8
9		# Let the target platform depend on the external header directories such
10		# that those will be unpacked before anything is built for the target
11		# platform.
12		Depends $(TARGET_PLATFORM) : [
13			BuildFeatureAttribute gcc_syslibs_devel : c++-headers
14		] [
15			BuildFeatureAttribute gcc_syslibs_devel : gcc-headers
16		] ;
17	}
18}
19
20# Include required packages:
21# primary architecture
22AddHaikuImageSystemPackages [ FFilterByBuildFeatures
23	bash bc freetype libsolv zlib
24
25	!gcc2 @{ coreutils icu74 }@
26	gcc2 @{ coreutils_x86 icu icu74_x86@secondary_x86 }@
27	regular_image @{
28		bzip2 expat ffmpeg6 glu gutenprint8 gzip
29		lame less libedit libicns
30		mesa mesa_devel mesa_swpipe@!gcc2 mesa_swrast@gcc2
31		netcat
32		sed sharutils
33		unzip wget which zip
34
35		!gcc2 @{ diffutils findutils gawk grep tar tcpdump zstd }@
36		gcc2 @{
37			diffutils_x86@secondary_x86 findutils_x86@secondary_x86
38			mawk grep_x86@secondary_x86 tar_x86@secondary_x86
39			tcpdump_x86@secondary_x86
40		}@
41	}@
42] ;
43AddHaikuImageSourcePackages [ FFilterByBuildFeatures
44	bash bc
45
46	!gcc2 @{ coreutils }@
47	gcc2 @{ coreutils_x86 }@
48
49	regular_image @{
50		expat ffmpeg6 findutils grep gutenprint8 gzip
51		lame less libicns
52		sed sharutils
53		tar wget which
54		!gcc2 @{ gawk }@
55		gcc2 @{ mawk }@
56	}@
57] ;
58if $(HAIKU_PACKAGING_ARCHS[1]) != x86_gcc2 {
59	AddHaikuImageSystemPackages [ FFilterByBuildFeatures gcc_syslibs ] ;
60}
61
62if $(HAIKU_PACKAGING_ARCHS[2]) {
63	# secondary architectures
64	local architectureObject ;
65	for architectureObject
66			in [ MultiArchSubDirSetup $(HAIKU_PACKAGING_ARCHS[2-]) ] {
67		on $(architectureObject) {
68			AddHaikuImageSystemPackages [ FFilterByBuildFeatures
69				freetype icu libsolv zlib
70
71				regular_image @{
72					ffmpeg6 glu jasper jpeg libavif libicns libpng16 libwebp mesa
73				}@
74			] ;
75			if $(TARGET_PACKAGING_ARCH) != x86_gcc2 {
76				AddHaikuImageSystemPackages [ FFilterByBuildFeatures gcc_syslibs
77					mesa_swpipe ] ;
78			}
79		}
80	}
81}
82
83# If enabled, make sure that OpenSSL is added to the image.
84if [ FIsBuildFeatureEnabled openssl ] {
85	AddHaikuImageSystemPackages openssl ;
86}
87
88# add additionally requested packages
89AddHaikuImageSystemPackages $(HAIKU_IMAGE_ADDITIONAL_PACKAGES) ;
90
91# Optionally we allow not to include the "src" subdirectory.
92if $(HAIKU_DONT_INCLUDE_SRC) {
93	# Don't include "src", but at least include the stuff needed for the
94	# build.
95	SubInclude HAIKU_TOP src build ;
96	SubInclude HAIKU_TOP src tools ;
97} else {
98	SubInclude HAIKU_TOP src ;
99}
100if $(HAIKU_INCLUDE_3RDPARTY) {
101	SubInclude HAIKU_TOP 3rdparty ;
102}
103
104# Perform deferred SubIncludes.
105ExecuteDeferredSubIncludes ;
106
107# reset subdir
108SubDir HAIKU_TOP ;
109
110# Execute post-build-target user config rules.
111UserBuildConfigRulePostBuildTargets	;
112
113# specify the Haiku repository contents
114include [ FDirName $(HAIKU_BUILD_RULES_DIR) repositories Haiku ] ;
115
116# specify the actual Haiku image contents
117include [ FDirName $(HAIKU_BUILD_RULES_DIR) images HaikuImage ] ;
118
119# specify the additional image contents one for each boot type
120include [ FDirName $(HAIKU_BUILD_RULES_DIR) images NetBootArchive ] ;
121include [ FDirName $(HAIKU_BUILD_RULES_DIR) images FloppyBootImage ] ;
122include [ FDirName $(HAIKU_BUILD_RULES_DIR) images CDBootImage ] ;
123include [ FDirName $(HAIKU_BUILD_RULES_DIR) images HaikuCD ] ;
124include [ FDirName $(HAIKU_BUILD_RULES_DIR) images AnybootImage ] ;
125include [ FDirName $(HAIKU_BUILD_RULES_DIR) images MMCImage ] ;
126
127# Check whether all requested optional packages do actually exist.
128local package ;
129local packageError ;
130for package in $(HAIKU_ADDED_OPTIONAL_PACKAGES) {
131	if ! [ on $(package) return $(HAIKU_OPTIONAL_PACKAGE_EXISTS) ] {
132		Echo "ERROR: Requested optional package \"$(package)\" does not"
133			"exist." ;
134		packageError = 1 ;
135	}
136}
137if $(packageError) {
138	Exit ;
139}
140
141# Pseudo-target to build all targets that are localized.
142NotFile LocalizedTargets ;
143Depends LocalizedTargets : $(HAIKU_LOCALIZED_TARGETS) ;
144
145NotFile catalogs ;
146Depends catalogs : $(HAIKU_LOCALE_CATALOGS) ;
147
148NotFile catkeys ;
149Depends catkeys : $(HAIKU_LOCALE_OUTPUT_CATKEYS) ;
150