rule FHaikuPackageGrist package { local grist = [ Match "<(.*)>" : $(package:G) ] ; return hpkg_$(grist:E="")-$(package:G=) ; } rule HaikuPackage package { local grist = [ FHaikuPackageGrist $(package) ] ; HAIKU_CONTAINER_GRIST on $(package) = $(grist) ; HAIKU_INCLUDE_IN_CONTAINER_VAR on $(package) = HAIKU_INCLUDE_IN_PACKAGES ; HAIKU_INSTALL_TARGETS_VAR on $(package) = $(grist)_HAIKU_PACKAGE_INSTALL_TARGETS ; HAIKU_CONTAINER_SYSTEM_DIR_TOKENS on $(package) = ; HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE = $(package) ; if $(HAIKU_PACKAGES_UPDATE_ONLY) { HAIKU_CONTAINER_UPDATE_ONLY on $(package) = 1 ; HAIKU_CONTAINER_INHERIT_UPDATE_VARIABLE on $(package) = HAIKU_INCLUDE_IN_IMAGE ; } else if $(HAIKU_UPDATE_ALL_PACKAGES) { HAIKU_INCLUDE_IN_IMAGE on $(package) = 1 ; } HAIKU_CONTAINER_ALWAYS_CREATE_DIRECTORIES on $(package) = 1 ; } rule BuildHaikuPackage package : packageInfo { packageInfo = $(packageInfo:G=package-info) ; local grist = [ FHaikuPackageGrist $(package) ] ; local tempDir = [ FDirName $(HAIKU_PACKAGES_BUILD_DIR) $(grist) ] ; local scriptDir = [ FDirName $(tempDir) scripts ] ; # locate the package and package info MakeLocate $(package) : $(HAIKU_PACKAGES_DIR) ; SEARCH on $(packageInfo) += [ FDirName $(HAIKU_PACKAGE_INFOS_DIR) $(HAIKU_PACKAGING_ARCH) ] [ FDirName $(HAIKU_PACKAGE_INFOS_DIR) any ] [ FDirName $(HAIKU_PACKAGE_INFOS_DIR) generic ] ; LocalDepends $(package) : $(packageInfo) ; # prepare the script that initializes the shell variables local initVariablesScript = <$(grist)>haiku.package-init-vars ; MakeLocate $(initVariablesScript) : $(scriptDir) ; Always $(initVariablesScript) ; local script = $(initVariablesScript) ; AddVariableToScript $(script) : sourceDir : $(HAIKU_TOP) ; AddVariableToScript $(script) : outputDir : $(HAIKU_OUTPUT_DIR) ; AddVariableToScript $(script) : tmpDir : $(tempDir) ; AddVariableToScript $(script) : addBuildCompatibilityLibDir : $(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR) ; AddVariableToScript $(script) : compressionLevel : [ on $(package) return $(HAIKU_PACKAGE_COMPRESSION_LEVEL) ] ; AddVariableToScript $(script) : updateOnly : [ on $(package) return $(HAIKU_CONTAINER_UPDATE_ONLY) ] ; AddVariableToScript $(script) : cc : $(TARGET_CC) ; AddVariableToScript $(script) : packagingArch : $(HAIKU_PACKAGING_ARCH) ; AddTargetVariableToScript $(script) : addattr ; AddTargetVariableToScript $(script) : copyattr ; AddTargetVariableToScript $(script) : mime_db : mimeDB ; AddTargetVariableToScript $(script) : mimeset ; AddTargetVariableToScript $(script) : package ; AddTargetVariableToScript $(script) : rc ; AddTargetVariableToScript $(script) : resattr ; AddTargetVariableToScript $(script) : unzip ; if $(HOST_RM_ATTRS_TARGET) { AddTargetVariableToScript $(script) : $(HOST_RM_ATTRS_TARGET) : rmAttrs ; } else { AddVariableToScript $(script) : rmAttrs : rm ; } # create the other scripts local makeDirsScript = <$(grist)>haiku.package-make-dirs ; local copyFilesScript = <$(grist)>haiku.package-copy-files ; local extractFilesScript = <$(grist)>haiku.package-extract-files ; MakeLocate $(makeDirsScript) $(copyFilesScript) $(extractFilesScript) : $(scriptDir) ; CreateContainerMakeDirectoriesScript $(package) : $(makeDirsScript) ; CreateContainerCopyFilesScript $(package) : $(copyFilesScript) ; CreateContainerExtractFilesScript $(package) : $(extractFilesScript) ; local scripts = $(initVariablesScript) $(makeDirsScript) $(copyFilesScript) $(extractFilesScript) ; # call the build actions local mainScript = build_haiku_package ; SEARCH on $(mainScript) = [ FDirName $(HAIKU_TOP) build scripts ] ; LocalDepends $(package) : $(mainScript) $(scripts) ; BuildHaikuPackage1 $(package) : $(mainScript) $(packageInfo) $(scripts) ; } actions BuildHaikuPackage1 { $(2[1]) "$(1)" "$(2[2])" $(2[3-]) } rule AddDirectoryToPackage directoryTokens : attributeFiles { return [ AddDirectoryToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE) : $(directoryTokens) : $(attributeFiles) ] ; } rule AddFilesToPackage directory : targets : destName { AddFilesToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE) : $(directory) : $(targets) : $(destName) ; } rule AddSymlinkToPackage directoryTokens : linkTarget : linkName { linkTarget = $(linkTarget:J=/) ; AddSymlinkToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE) : $(directoryTokens) : $(linkTarget) : $(linkName) ; } rule CopyDirectoryToPackage directoryTokens : sourceDirectory : targetDirectoryName : excludePatterns : flags { CopyDirectoryToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE) : $(directoryTokens) : $(sourceDirectory) : $(targetDirectoryName) : $(excludePatterns) : $(flags) ; } rule AddHeaderDirectoryToPackage dirTokens : dirName : flags { AddHeaderDirectoryToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE) : $(dirTokens) : $(dirName) : $(flags) ; } rule AddWifiFirmwareToPackage driver : subDirToExtract : archive : extract { AddWifiFirmwareToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE) : $(driver) : $(subDirToExtract) : $(archive) : $(extract) ; } rule ExtractArchiveToPackage dirTokens : archiveFile : flags : extractedSubDir { ExtractArchiveToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE) : $(dirTokens) : $(archiveFile) : $(flags) : $(extractedSubDir) ; } rule AddDriversToPackage relativeDirectoryTokens : targets { AddDriversToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE) : $(relativeDirectoryTokens) : $(targets) ; } rule AddNewDriversToPackage relativeDirectoryTokens : targets { AddNewDriversToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE) : $(relativeDirectoryTokens) : $(targets) ; } rule AddBootModuleSymlinksToPackage targets { AddBootModuleSymlinksToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE) : $(targets) ; } rule AddLibrariesToPackage directory : libs { AddLibrariesToContainer $(HAIKU_CURRENTLY_BUILT_HAIKU_PACKAGE) : $(directory) : $(libs) ; } # default value for the package compression level HAIKU_PACKAGE_COMPRESSION_LEVEL ?= 9 ;