1 rule FHaikuPackageGrist package
3 local grist = [ Match "<(.*)>" : $(package:G) ] ;
4 return hpkg_$(grist:E="")-$(package:G=) ;
8 rule HaikuPackage package
10 local grist = [ FHaikuPackageGrist $(package) ] ;
12 HAIKU_CONTAINER_GRIST on $(package) = $(grist) ;
13 HAIKU_INCLUDE_IN_CONTAINER_VAR on $(package) = HAIKU_INCLUDE_IN_PACKAGES ;
14 HAIKU_INSTALL_TARGETS_VAR on $(package)
15 = $(grist)_HAIKU_PACKAGE_INSTALL_TARGETS ;
16 HAIKU_CONTAINER_SYSTEM_DIR_TOKENS on $(package) = ;
18 HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE = $(package) ;
20 if $(HAIKU_PACKAGES_UPDATE_ONLY) {
21 HAIKU_CONTAINER_UPDATE_ONLY on $(package) = 1 ;
22 HAIKU_CONTAINER_INHERIT_UPDATE_VARIABLE on $(package)
23 = HAIKU_INCLUDE_IN_IMAGE ;
24 } else if $(HAIKU_UPDATE_ALL_PACKAGES) {
25 HAIKU_INCLUDE_IN_IMAGE on $(package) = 1 ;
28 HAIKU_CONTAINER_ALWAYS_CREATE_DIRECTORIES on $(package) = 1 ;
30 # If HAIKU_DONT_REBUILD_PACKAGES is defined, don't rebuild an existing
32 if $(HAIKU_DONT_REBUILD_PACKAGES) {
33 local file = [ Glob $(HAIKU_PACKAGES_DIR_$(HAIKU_PACKAGING_ARCH))
36 HAIKU_DONT_REBUILD_PACKAGE on $(package) = 1 ;
42 rule PreprocessPackageInfo source : directory : architecture
43 : secondaryArchitecture
45 source = $(source:G=package-info-source) ;
46 SEARCH on $(source) +=
47 [ FDirName $(HAIKU_PACKAGE_INFOS_DIR) $(architecture) ]
48 [ FDirName $(HAIKU_PACKAGE_INFOS_DIR) any ]
49 [ FDirName $(HAIKU_PACKAGE_INFOS_DIR) generic ]
52 local target = $(source:BSG=package-info)-package-info ;
53 MakeLocate $(target) : $(directory) ;
55 PreprocessPackageOrRepositoryInfo $(target) : $(source) : $(architecture)
56 : $(secondaryArchitecture) : useCPP ;
58 # Update requires in the package info.
59 if $(HAIKU_BUILD_TYPE) != bootstrap {
60 local updateRequiresFiles =
61 <build>update_package_requires
62 [ on <repository>HaikuPorts return $(HAIKU_REPOSITORY_CACHE_FILE) ]
64 Depends $(target) : $(updateRequiresFiles) ;
65 UpdatePackageInfoRequires $(target) : $(updateRequiresFiles) ;
72 actions UpdatePackageInfoRequires
74 $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
75 "$(2[1])" "$(1)" "$(2[2])"
79 rule PreprocessPackageOrRepositoryInfo target : source : architecture
80 : secondaryArchitecture : flags
82 # PreprocessPackageOrRepositoryInfo <target> : <source> : <architecture>
83 # : [ <secondaryArchitecture> ] [ : <flags> ] ;
84 # Preprocesses the package or repository info template file <source> by
85 # performing several placeholder substitutions and optionally filtering it
86 # through the C preprocessor.
88 # <target> - The generated preprocessed file.
89 # <source> - The package or repository info template file.
90 # <architecture> - The primary packaging architecture.
91 # <secondaryArchitecture> - If given, the secondary packaging architecture
92 # the package targets. Otherwise the primary architecture is targeted.
94 # useCPP - Filter the source file through the C preprocessor after the
95 # placeholder substitutions have been performed.
97 local defines = HAIKU_PACKAGING_ARCH=$(architecture)
98 HAIKU_$(HAIKU_BUILD_TYPE:U)_BUILD ;
99 local sedReplacements = %HAIKU_PACKAGING_ARCH%,$(architecture) ;
100 if $(secondaryArchitecture) {
101 defines += HAIKU_SECONDARY_PACKAGING_ARCH=$(secondaryArchitecture) ;
103 += %HAIKU_SECONDARY_PACKAGING_ARCH%,$(secondaryArchitecture) ;
105 %HAIKU_SECONDARY_PACKAGING_ARCH_SUFFIX%,_$(secondaryArchitecture) ;
108 += %HAIKU_SECONDARY_PACKAGING_ARCH_SUFFIX%, ;
110 for feature in $(HAIKU_BUILD_FEATURES) {
111 local featureSplit = [ FSplitString $(feature) : ":" ] ;
112 defines += HAIKU_BUILD_FEATURE_$(featureSplit:UJ=_)_ENABLED ;
115 local revisionFile = [ DetermineEffectiveHaikuRevision ] ;
116 Depends $(target) : $(source) $(revisionFile) ;
118 if useCPP in $(flags) {
119 PREPROCESSOR on $(target)
120 = "|" $(HOST_CC) -E -w [ FDefines $(defines) ] - ;
122 PREPROCESSOR on $(target) = ;
125 HAIKU_SED_REPLACEMENTS on $(target) = "-e s,$(sedReplacements),g" ;
127 PreprocessPackageOrRepositoryInfo1 $(target) : $(source) $(revisionFile) ;
131 actions PreprocessPackageOrRepositoryInfo1
133 revision=`cat $(2[2])`
134 version=$(HAIKU_VERSION)_${revision}
135 sed $(HAIKU_SED_REPLACEMENTS) \
136 -e s,%HAIKU_VERSION%,${version}-1, \
137 -e s,%HAIKU_VERSION_NO_REVISION%,${version}, $(2[1]) \
138 $(PREPROCESSOR) > $(1)
142 rule BuildHaikuPackage package : packageInfo
144 local architecture = $(HAIKU_PACKAGING_ARCH) ;
145 local secondaryArchitecture ;
146 if $(TARGET_PACKAGING_ARCH) != $(architecture) {
147 secondaryArchitecture = $(TARGET_PACKAGING_ARCH) ;
150 MakeLocate $(package) : $(HAIKU_PACKAGES_DIR_$(architecture)) ;
152 # Don't rebuild an existing package, if requested.
153 if [ on $(package) return $(HAIKU_DONT_REBUILD_PACKAGE) ] {
154 NoUpdate $(package) ;
155 BuildHaikuPackageDummy $(package) ;
159 local grist = [ FHaikuPackageGrist $(package) ] ;
161 local tempDir = [ FDirName
162 $(HAIKU_PACKAGES_BUILD_DIR_$(architecture)) $(HAIKU_BUILD_TYPE) $(grist)
164 local scriptDir = [ FDirName $(tempDir) scripts ] ;
166 # build the package info and locate the package
167 packageInfo = [ PreprocessPackageInfo $(packageInfo) : $(tempDir)
168 : $(architecture) : $(secondaryArchitecture) ] ;
169 Depends $(package) : $(packageInfo) ;
171 # prepare the script that initializes the shell variables
172 local initVariablesScript = <$(grist)>haiku.package-init-vars ;
173 MakeLocate $(initVariablesScript) : $(scriptDir) ;
174 Always $(initVariablesScript) ;
176 local script = $(initVariablesScript) ;
177 AddVariableToScript $(script) : sourceDir : $(HAIKU_TOP) ;
178 AddVariableToScript $(script) : outputDir : $(HAIKU_OUTPUT_DIR) ;
179 AddVariableToScript $(script) : tmpDir : $(tempDir) ;
180 AddVariableToScript $(script) : addBuildCompatibilityLibDir
181 : $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) ;
182 AddVariableToScript $(script) : compressionLevel
183 : [ on $(package) return $(HAIKU_PACKAGE_COMPRESSION_LEVEL) ] ;
184 AddVariableToScript $(script) : updateOnly
185 : [ on $(package) return $(HAIKU_CONTAINER_UPDATE_ONLY) ] ;
186 AddVariableToScript $(script) : cc : $(TARGET_CC_$(architecture)) ;
187 AddTargetVariableToScript $(script) : <build>addattr ;
188 AddTargetVariableToScript $(script) : <build>copyattr ;
189 AddTargetVariableToScript $(script) : <mimedb>mime_db : mimeDB ;
190 AddTargetVariableToScript $(script) : <build>mimeset ;
191 AddTargetVariableToScript $(script) : <build>package ;
192 AddTargetVariableToScript $(script) : <build>rc ;
193 AddTargetVariableToScript $(script) : <build>resattr ;
194 AddTargetVariableToScript $(script) : <build>unzip ;
195 if $(HOST_RM_ATTRS_TARGET) {
196 AddTargetVariableToScript $(script) : $(HOST_RM_ATTRS_TARGET)
199 AddVariableToScript $(script) : rmAttrs : rm ;
202 # create the other scripts
203 local makeDirsScript = <$(grist)>haiku.package-make-dirs ;
204 local copyFilesScript = <$(grist)>haiku.package-copy-files ;
205 local extractFilesScript = <$(grist)>haiku.package-extract-files ;
207 MakeLocate $(makeDirsScript) $(copyFilesScript) $(extractFilesScript)
210 CreateContainerMakeDirectoriesScript $(package) : $(makeDirsScript) ;
211 CreateContainerCopyFilesScript $(package) : $(copyFilesScript) ;
212 CreateContainerExtractFilesScript $(package) : $(extractFilesScript) ;
214 local scripts = $(initVariablesScript) $(makeDirsScript)
215 $(copyFilesScript) $(extractFilesScript) ;
217 # call the build actions
218 local mainScript = build_haiku_package ;
219 SEARCH on $(mainScript) = [ FDirName $(HAIKU_TOP) build scripts ] ;
221 Depends $(package) : $(mainScript) $(scripts) ;
222 BuildHaikuPackage1 $(package) : $(mainScript) $(packageInfo) $(scripts) ;
226 actions BuildHaikuPackage1
228 $(2[1]) "$(1)" "$(2[2])" $(2[3-])
232 actions BuildHaikuPackageDummy
238 rule FDontRebuildCurrentPackage
240 on $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE)
241 return $(HAIKU_DONT_REBUILD_PACKAGE) ;
245 rule AddDirectoryToPackage directoryTokens : attributeFiles
247 if ! [ FDontRebuildCurrentPackage ] {
248 return [ AddDirectoryToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE)
249 : $(directoryTokens) : $(attributeFiles) ] ;
254 rule AddFilesToPackage directory : targets : destName
256 if ! [ FDontRebuildCurrentPackage ] {
257 AddFilesToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE)
258 : $(directory) : $(targets) : $(destName) ;
263 rule AddSymlinkToPackage directoryTokens : linkTarget : linkName
265 if ! [ FDontRebuildCurrentPackage ] {
266 linkTarget = $(linkTarget:J=/) ;
268 AddSymlinkToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE)
269 : $(directoryTokens) : $(linkTarget) : $(linkName) ;
274 rule CopyDirectoryToPackage directoryTokens : sourceDirectory
275 : targetDirectoryName : excludePatterns : flags
277 if ! [ FDontRebuildCurrentPackage ] {
278 CopyDirectoryToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE)
279 : $(directoryTokens) : $(sourceDirectory) : $(targetDirectoryName)
280 : $(excludePatterns) : $(flags) ;
285 rule AddHeaderDirectoryToPackage dirTokens : dirName : flags
287 if ! [ FDontRebuildCurrentPackage ] {
288 AddHeaderDirectoryToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE)
289 : $(dirTokens) : $(dirName) : $(flags) ;
294 rule AddWifiFirmwareToPackage driver : subDirToExtract : archive
297 if ! [ FDontRebuildCurrentPackage ] {
298 AddWifiFirmwareToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE)
299 : $(driver) : $(subDirToExtract) : $(archive) : $(extract) ;
304 rule ExtractArchiveToPackage dirTokens : archiveFile : flags : extractedSubDir
306 if ! [ FDontRebuildCurrentPackage ] {
307 ExtractArchiveToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE)
308 : $(dirTokens) : $(archiveFile) : $(flags) : $(extractedSubDir) ;
313 rule AddDriversToPackage relativeDirectoryTokens : targets
315 if ! [ FDontRebuildCurrentPackage ] {
316 AddDriversToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE)
317 : $(relativeDirectoryTokens) : $(targets) ;
322 rule AddNewDriversToPackage relativeDirectoryTokens : targets
324 if ! [ FDontRebuildCurrentPackage ] {
325 AddNewDriversToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE)
326 : $(relativeDirectoryTokens) : $(targets) ;
331 rule AddBootModuleSymlinksToPackage targets
333 if ! [ FDontRebuildCurrentPackage ] {
334 AddBootModuleSymlinksToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE)
340 rule AddLibrariesToPackage directory : libs
342 if ! [ FDontRebuildCurrentPackage ] {
343 AddLibrariesToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE)
344 : $(directory) : $(libs) ;
349 # default value for the package compression level
350 HAIKU_PACKAGE_COMPRESSION_LEVEL ?= 9 ;