haiku/build/jam/PackageRules
Ingo Weinhold b0944c78b0 More work towards hybrid support
* All packaging architecture dependent variables do now have a
  respective suffix and are set up for each configured packaging
  architecture, save for the kernel and boot loader variables, which
  are still only set up for the primary architecture.
  For convenience TARGET_PACKAGING_ARCH, TARGET_ARCH, TARGET_LIBSUPC++,
  and TARGET_LIBSTDC++ are set to the respective values for the primary
  packaging architecture by default.
* Introduce a set of MultiArch* rules to help with building targets for
  multiple packaging architectures. Generally the respective targets are
  (additionally) gristed with the packaging architecture. For libraries
  the additional grist is usually omitted for the primary architecture
  (e.g. libroot.so and <x86>libroot.so for x86_gcc2/x86 hybrid), so that
  Jamfiles for targets built only for the primary architecture don't
  need to be changed.
* Add multi-arch build support for all targets needed for the stage 1
  cross devel package as well as for libbe (untested).
2013-08-01 08:54:06 +02:00

225 lines
6.6 KiB
Plaintext

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 PreprocessPackageInfo source : directory : architecture
{
source = $(source:G=package-info-source) ;
SEARCH on $(source) +=
[ FDirName $(HAIKU_PACKAGE_INFOS_DIR) $(architecture) ]
[ FDirName $(HAIKU_PACKAGE_INFOS_DIR) any ]
[ FDirName $(HAIKU_PACKAGE_INFOS_DIR) generic ]
;
local target = $(source:BSG=package-info)-package-info ;
local defines = HAIKU_PACKAGING_ARCH=$(architecture) ;
if $(HAIKU_BOOTSTRAP_BUILD) {
defines += HAIKU_BOOTSTRAP_BUILD ;
target = $(target)-bootstrap ;
}
MakeLocate $(target) : $(directory) ;
Depends $(target) : $(source) ;
CCDEFS on $(target) = [ FDefines $(defines) ] ;
PreprocessPackageInfo1 $(target) : $(source) ;
return $(target) ;
}
actions PreprocessPackageInfo1
{
$(HOST_CC) -E -w $(CCDEFS) - -o $(1) < $(2)
}
rule BuildHaikuPackage package : packageInfo
{
local architecture = $(HAIKU_PACKAGING_ARCH) ;
local grist = [ FHaikuPackageGrist $(package) ] ;
local tempDir
= [ FDirName $(HAIKU_PACKAGES_BUILD_DIR_$(architecture)) $(grist) ] ;
local scriptDir = [ FDirName $(tempDir) scripts ] ;
# build the package info and locate the package
packageInfo = [ PreprocessPackageInfo $(packageInfo) : $(tempDir)
: $(architecture) ] ;
MakeLocate $(package) : $(HAIKU_PACKAGES_DIR_$(architecture)) ;
Depends $(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_$(architecture)) ;
AddTargetVariableToScript $(script) : <build>addattr ;
AddTargetVariableToScript $(script) : <build>copyattr ;
AddTargetVariableToScript $(script) : <mimedb>mime_db : mimeDB ;
AddTargetVariableToScript $(script) : <build>mimeset ;
AddTargetVariableToScript $(script) : <build>package ;
AddTargetVariableToScript $(script) : <build>rc ;
AddTargetVariableToScript $(script) : <build>resattr ;
AddTargetVariableToScript $(script) : <build>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 ;