2005-10-29 20:27:43 +04:00
|
|
|
rule SymLink
|
|
|
|
{
|
|
|
|
# SymLink <target> : <source> : <makeDefaultDependencies> ;
|
|
|
|
# Links <target> to <source>.
|
|
|
|
# <source> is the exact link contents. No binding is done.
|
|
|
|
# <makeDefaultDependencies> If true, <target> will be made a dependency
|
|
|
|
# of the `all' pseudo target, i.e. it will be made by default, and removed
|
|
|
|
# on `jam clean'.
|
|
|
|
|
|
|
|
local target = $(1) ;
|
|
|
|
local source = $(2) ;
|
|
|
|
local makeDefaultDependencies = $(3) ;
|
|
|
|
if ! $(makeDefaultDependencies) {
|
|
|
|
makeDefaultDependencies = true ;
|
|
|
|
}
|
|
|
|
LINKCONTENTS on $(target) = $(source) ;
|
|
|
|
SymLink1 $(target) ;
|
|
|
|
if $(makeDefaultDependencies) = true {
|
|
|
|
LocalDepends files : $(target) ;
|
|
|
|
LocalClean clean : $(target) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
actions SymLink1
|
|
|
|
{
|
|
|
|
$(RM) "$(1)" && $(LN) -s "$(LINKCONTENTS)" "$(1)"
|
|
|
|
}
|
|
|
|
|
|
|
|
rule RelSymLink
|
|
|
|
{
|
|
|
|
# RelSymLink <link> : <link target> : <makeDefaultDependencies> ;
|
|
|
|
# Creates a relative symbolic link from <link> to <link target>.
|
|
|
|
# <link> and <link target> can be usual targets. They may have a grist
|
|
|
|
# and don't need to have any dirname. Their LOCATE variables are used to
|
|
|
|
# find their locations.
|
|
|
|
# <makeDefaultDependencies> If true (which is the default), <link> will be
|
|
|
|
# made a dependency of the `files' pseudo target, i.e. it will be made by
|
|
|
|
# default, and removed on `jam clean'.
|
|
|
|
|
|
|
|
local target = $(1) ;
|
|
|
|
local source = $(2) ;
|
|
|
|
local makeDefaultDependencies = $(3) ;
|
|
|
|
local targetDir = [ on $(target) FDirName $(LOCATE[1]) $(target:D) ] ;
|
|
|
|
local sourceDir = [ on $(source) FDirName $(LOCATE[1]) $(source:D) ] ;
|
|
|
|
local sourcePath = $(source:G=) ;
|
|
|
|
sourcePath = $(sourcePath:D=$(sourceDir)) ;
|
|
|
|
local targetDirComponents = [ FSplitPath $(targetDir) ] ;
|
|
|
|
local sourceComponents = [ FSplitPath $(sourcePath) ] ;
|
|
|
|
|
|
|
|
SymLink $(target)
|
|
|
|
: [ FRelPath $(targetDirComponents) : $(sourceComponents) ]
|
|
|
|
: $(makeDefaultDependencies) ;
|
|
|
|
NOUPDATE $(target) ;
|
|
|
|
Depends $(target) : $(source) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
rule AbsSymLink
|
|
|
|
{
|
2008-10-18 13:23:42 +04:00
|
|
|
# AbsSymLink <link> : <link target> : <link dir>
|
2005-10-29 20:27:43 +04:00
|
|
|
# : <makeDefaultDependencies> ;
|
|
|
|
# Creates an absolute symbolic link from <link> to <link target>.
|
|
|
|
# <link> and <link target> must be usual targets. If <link dir> is
|
|
|
|
# given, then it is set as LOCATE directory on <link>.
|
|
|
|
# <makeDefaultDependencies> If true (which is the default), <link> will be
|
|
|
|
# made a dependency of the `files' pseudo target, i.e. it will be made by
|
|
|
|
# default, and removed on `jam clean'.
|
|
|
|
|
|
|
|
local makeDefaultDependencies = $(4) ;
|
|
|
|
if ! $(makeDefaultDependencies) {
|
|
|
|
makeDefaultDependencies = true ;
|
|
|
|
}
|
|
|
|
|
|
|
|
Depends $(1) : $(2) ;
|
|
|
|
if $(3) {
|
|
|
|
MakeLocate $(1) : $(3) ;
|
|
|
|
}
|
|
|
|
SEARCH on $(2) += $(SEARCH_SOURCE) ;
|
|
|
|
if $(makeDefaultDependencies) = true {
|
|
|
|
LocalDepends files : $(1) ;
|
|
|
|
LocalClean clean : $(1) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
actions AbsSymLink
|
|
|
|
{
|
|
|
|
target="$(2)"
|
|
|
|
case "$target" in
|
|
|
|
/*) ;;
|
|
|
|
*) target=`pwd`/"$target";;
|
|
|
|
esac
|
|
|
|
$(RM) "$(1)" && $(LN) -s "$target" "$(1)"
|
|
|
|
}
|
|
|
|
|
|
|
|
rule HaikuInstall
|
|
|
|
{
|
|
|
|
# Usage: HaikuInstall <[ install [ and uninstall ] pseudotarget ]>
|
|
|
|
# : <directory> : <sources to install>
|
|
|
|
# : [ <installgrist> ] : [ <install rule> ] ;
|
|
|
|
local install = $(1[1]) ;
|
|
|
|
install ?= install ;
|
|
|
|
local uninstall = $(1[2]) ;
|
|
|
|
uninstall ?= un$(install) ;
|
|
|
|
local dir = $(2) ;
|
|
|
|
local sources = $(3) ;
|
|
|
|
local installgrist = $(4) ;
|
|
|
|
installgrist ?= $(INSTALLGRIST) ;
|
|
|
|
local installRule = $(5) ;
|
|
|
|
installRule ?= Install ;
|
|
|
|
local targets = $(sources:G=$(installgrist)) ;
|
|
|
|
|
|
|
|
NotFile $(install) ;
|
|
|
|
NotFile $(uninstall) ;
|
|
|
|
Depends $(install) : $(targets) ;
|
|
|
|
Clean $(uninstall) : $(targets) ;
|
|
|
|
|
|
|
|
SEARCH on $(sources) += $(SEARCH_SOURCE) ;
|
|
|
|
MakeLocate $(targets) : $(dir) ;
|
|
|
|
|
|
|
|
local source ;
|
|
|
|
for source in $(sources) {
|
|
|
|
local target = $(source:G=$(installgrist)) ;
|
|
|
|
|
|
|
|
Depends $(target) : $(source) ;
|
|
|
|
$(installRule) $(target) : $(source) ;
|
|
|
|
|
|
|
|
if [ on $(target) return $(MODE) ] {
|
|
|
|
Chmod $(target) ;
|
|
|
|
}
|
|
|
|
|
2008-10-18 13:23:42 +04:00
|
|
|
if $(OWNER) && $(CHOWN) {
|
2005-10-29 20:27:43 +04:00
|
|
|
Chown $(target) ;
|
|
|
|
OWNER on $(target) = $(OWNER) ;
|
|
|
|
}
|
|
|
|
|
2008-10-18 13:23:42 +04:00
|
|
|
if $(GROUP) && $(CHGRP) {
|
2005-10-29 20:27:43 +04:00
|
|
|
Chgrp $(target) ;
|
|
|
|
GROUP on $(target) = $(GROUP) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rule InstallAbsSymLinkAdapter
|
|
|
|
{
|
|
|
|
# InstallAbsSymLinkAdapter <link> : <link target>
|
|
|
|
if ! [ on $(2) return $(TARGET) ] {
|
|
|
|
TARGET on $(2) = [ on $(2) return $(SEARCH) ] ;
|
|
|
|
}
|
|
|
|
AbsSymLink $(1) : $(2) : : false ;
|
|
|
|
}
|
|
|
|
|
|
|
|
rule HaikuInstallAbsSymLink
|
|
|
|
{
|
|
|
|
# Usage: HaikuInstallAbsSymLink <[ install [ and uninstall ] pseudotarget ]>
|
|
|
|
# : <directory> : <sources to install>
|
|
|
|
# : [ <installgrist> ] ;
|
|
|
|
HaikuInstall $(1) : $(2) : $(3) : $(4) : InstallAbsSymLinkAdapter ;
|
|
|
|
}
|
|
|
|
|
|
|
|
rule InstallRelSymLinkAdapter
|
|
|
|
{
|
|
|
|
# InstallRelSymLinkAdapter <link> : <link target>
|
|
|
|
if ! [ on $(2) return $(TARGET) ] {
|
|
|
|
TARGET on $(2) = [ on $(2) return $(SEARCH) ] ;
|
|
|
|
}
|
|
|
|
RelSymLink $(1) : $(2) : false ;
|
|
|
|
}
|
|
|
|
|
|
|
|
rule HaikuInstallRelSymLink
|
|
|
|
{
|
|
|
|
# Usage: HaikuInstallRelSymLink <[ install [ and uninstall ] pseudotarget ]>
|
|
|
|
# : <directory> : <sources to install>
|
|
|
|
# : [ <installgrist> ] ;
|
|
|
|
HaikuInstall $(1) : $(2) : $(3) : $(4) : InstallRelSymLinkAdapter ;
|
|
|
|
}
|
|
|
|
|
2008-10-18 13:23:42 +04:00
|
|
|
|
2005-10-29 20:27:43 +04:00
|
|
|
rule UnarchiveObjects
|
|
|
|
{
|
|
|
|
# UnarchiveObjects <target objects> : <static object>
|
|
|
|
|
|
|
|
MakeLocateArch $(1) ;
|
|
|
|
Depends $(1) : $(2) ;
|
|
|
|
SEARCH on $(2) = $(SEARCH_SOURCE) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
actions UnarchiveObjects
|
|
|
|
{
|
|
|
|
( cd $(1[1]:D) && $(TARGET_AR) $(TARGET_UNARFLAGS) "$(2)" $(1:BS) )
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2009-04-08 13:55:33 +04:00
|
|
|
rule UnzipArchive directory : entries : zipFile : grist
|
|
|
|
{
|
|
|
|
# UnzipArchive <directory> : <entries> : <zipFile> [ : <grist> ]
|
|
|
|
#
|
|
|
|
# Unzips the zip file target <zipFile> to directory <directory>. The rule
|
|
|
|
# can be called multiple times for different <entries> for the same
|
|
|
|
# <directory> and <zipFile> combo.
|
|
|
|
#
|
|
|
|
# <directory> - The directory into which to unzip the zip file. The
|
|
|
|
# directory is created is by this rule and it is the target
|
|
|
|
# that the unzip action is associated with.
|
|
|
|
# <entries> - The entries of the zip file one is interested in. The rule
|
|
|
|
# always unzips the complete zip file, from the given entries
|
|
|
|
# the rule creates targets (using <grist>) representing the
|
|
|
|
# unzipped entries. Those targets are returned by the rule.
|
|
|
|
# <zipFile> - The zip file target to unzip.
|
|
|
|
# <grist> - The grist used to create targets from <entries>. Defaults to
|
|
|
|
# "unzipped".
|
|
|
|
|
|
|
|
grist ?= unzipped ;
|
|
|
|
|
|
|
|
# Turn the entries into targets to build.
|
|
|
|
local targets ;
|
|
|
|
local entry ;
|
|
|
|
for entry in $(entries) {
|
|
|
|
local target = $(entry:G=$(grist)) ;
|
|
|
|
targets += $(target) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
LOCATE on $(targets) = $(directory) ;
|
|
|
|
Depends $(targets) : $(directory) ;
|
|
|
|
NoUpdate $(targets) ;
|
|
|
|
|
|
|
|
# one-time initialization for the main target (the directory)
|
|
|
|
if ! [ on $(directory) return $(INITIALIZED) ] {
|
2009-04-08 22:03:18 +04:00
|
|
|
# make sure the parent dir exists
|
|
|
|
local parentDir = $(directory:PG=dir) ;
|
|
|
|
Depends $(directory) : $(parentDir) ;
|
|
|
|
MkDir $(parentDir) ;
|
|
|
|
|
2009-04-08 13:55:33 +04:00
|
|
|
NoUpdate $(directory) ;
|
|
|
|
Depends $(directory) : $(zipFile) ;
|
|
|
|
UnzipArchive1 $(directory) : $(zipFile) ;
|
|
|
|
INITIALIZED on $(directory) = 1 ;
|
|
|
|
}
|
|
|
|
|
|
|
|
# Use a dummy rule so that it looks to jam like the targets are actually
|
|
|
|
# built from the directory target.
|
|
|
|
UnzipArchiveDummy $(targets) : $(directory) ;
|
|
|
|
|
|
|
|
return $(targets) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
actions UnzipArchive1
|
|
|
|
{
|
|
|
|
mkdir -p $(1[1])
|
|
|
|
unzip -q -u -o -d $(1[1]) $(2)
|
|
|
|
}
|
|
|
|
|
|
|
|
actions UnzipArchiveDummy
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
|
2005-10-29 20:27:43 +04:00
|
|
|
rule ObjectReference
|
|
|
|
{
|
|
|
|
# ObjectReference <reference object> : <source object>
|
|
|
|
# Makes <reference object> refer to the same file as <source object>.
|
|
|
|
# The filenames must of course be identical.
|
|
|
|
# <source object> must have already been LOCATEd.
|
|
|
|
|
|
|
|
local ref = $(1) ;
|
|
|
|
local source = $(2) ;
|
|
|
|
if $(ref) != $(source) {
|
|
|
|
Depends $(ref) : $(source) ;
|
|
|
|
LOCATE on $(ref) = [ on $(source) return $(LOCATE) ] ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
rule ObjectReferences
|
|
|
|
{
|
|
|
|
# ObjectReferences <source objects>
|
|
|
|
# Creates local references to <source objects>, i.e. identifiers with the
|
|
|
|
# current grist referring to the same files. <source objects> must have
|
|
|
|
# already been LOCATEd.
|
|
|
|
|
|
|
|
local source ;
|
|
|
|
for source in $(1) {
|
|
|
|
ObjectReference [ FGristFiles $(source) ] : $(source) ;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-02-06 19:51:29 +03:00
|
|
|
rule CopySetHaikuRevision target : source
|
|
|
|
{
|
|
|
|
# CopySetHaikuRevision <target> : <source>
|
|
|
|
#
|
|
|
|
# Copy <source> to <target>, writing the SVN revision of the working root
|
|
|
|
# directory into the haiku revision section of <target>.
|
|
|
|
#
|
|
|
|
# <target> - Output file target. Gristed and located target.
|
|
|
|
# <source> - ELF object to be copied. Gristed and located target.
|
|
|
|
|
|
|
|
# If existent, make the target depend on the .svn/entries file in the
|
|
|
|
# root directory, so it gets updated when the revision changes due to
|
|
|
|
# "svn up".
|
|
|
|
if [ Glob [ FDirName $(HAIKU_TOP) .svn ] : entries ] {
|
|
|
|
local svnEntries = <haiku-rootdir-svn>entries ;
|
|
|
|
SEARCH on $(svnEntries) = [ FDirName $(HAIKU_TOP) .svn ] ;
|
|
|
|
Depends $(target) : $(svnEntries) ;
|
2008-08-15 15:00:07 +04:00
|
|
|
} else if [ Glob [ FDirName $(HAIKU_TOP) .git ] : index ] {
|
|
|
|
local gitIndex = <haiku-rootdir-git>index ;
|
|
|
|
SEARCH on $(gitIndex) = [ FDirName $(HAIKU_TOP) .git ] ;
|
|
|
|
Depends $(target) : $(gitIndex) ;
|
2007-02-06 19:51:29 +03:00
|
|
|
}
|
|
|
|
|
2007-06-29 23:28:11 +04:00
|
|
|
HAIKU_INCLUDE_IN_IMAGE on $(target)
|
|
|
|
= [ on $(source) return $(HAIKU_INCLUDE_IN_IMAGE) ] ;
|
|
|
|
|
2007-02-06 19:51:29 +03:00
|
|
|
Depends $(target) : <build>copyattr <build>set_haiku_revision $(source) ;
|
|
|
|
CopySetHaikuRevision1 $(target)
|
|
|
|
: <build>copyattr <build>set_haiku_revision $(source) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
actions CopySetHaikuRevision1
|
|
|
|
{
|
|
|
|
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
|
2008-10-18 13:23:42 +04:00
|
|
|
revision=`LC_ALL=C LANG=C svn info $(HAIKU_TOP) 2> /dev/null |
|
2007-02-06 19:51:29 +03:00
|
|
|
grep Revision | awk '{printf $2}'`
|
2008-10-18 13:23:42 +04:00
|
|
|
if [ "$revision" = 0 -o "$revision" = "" ]; then
|
|
|
|
revision=`(cd $(HAIKU_TOP) && LC_ALL=C LANG=C git svn info)
|
|
|
|
2> /dev/null ||
|
|
|
|
(git log --max-count=1 --grep="git-svn-id:" 2> /dev/null |
|
|
|
|
grep git-svn-id: | cut -d '@' -f 2 |
|
|
|
|
awk '{printf $1}') 2> /dev/null`
|
|
|
|
fi
|
|
|
|
if [ "$revision" = "" ]; then
|
|
|
|
revision=0
|
|
|
|
fi
|
2007-02-06 19:51:29 +03:00
|
|
|
$(2[1]) --data $(2[3]) $(1) &&
|
|
|
|
$(2[2]) $(1) ${revision}
|
|
|
|
}
|
2007-06-12 07:54:07 +04:00
|
|
|
|
2007-07-15 04:04:27 +04:00
|
|
|
rule DataFileToSourceFile sourceFile : dataFile : dataVariable : sizeVariable
|
|
|
|
{
|
|
|
|
sourceFile = [ FGristFiles $(sourceFile) ] ;
|
|
|
|
MakeLocateCommonPlatform $(sourceFile) ;
|
|
|
|
|
|
|
|
sizeVariable ?= $(dataVariable)Size ;
|
|
|
|
|
|
|
|
DATA_VARIABLE on $(sourceFile) = $(dataVariable) ;
|
|
|
|
SIZE_VARIABLE on $(sourceFile) = $(sizeVariable) ;
|
|
|
|
|
|
|
|
Depends $(sourceFile) : <build>data_to_source $(dataFile) ;
|
|
|
|
DataFileToSourceFile1 $(sourceFile) : <build>data_to_source $(dataFile) ;
|
|
|
|
LocalClean clean : $(sourceFile) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
actions DataFileToSourceFile1
|
|
|
|
{
|
|
|
|
$(HOST_ADD_BUILD_COMPATIBILITY_LIB_DIR)
|
|
|
|
$(2[1]) $(DATA_VARIABLE) $(SIZE_VARIABLE) $(2[2]) $(1)
|
|
|
|
}
|
2007-09-05 07:08:38 +04:00
|
|
|
|
|
|
|
rule DownloadFile target : url
|
|
|
|
{
|
|
|
|
URL on $(target) = $(url) ;
|
|
|
|
|
|
|
|
DownloadFile1 $(target) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
actions DownloadFile1
|
|
|
|
{
|
|
|
|
wget -O $(1) $(URL)
|
|
|
|
}
|
2009-04-08 13:55:33 +04:00
|
|
|
|
|
|
|
rule DownloadOptionalPackage package : url
|
|
|
|
{
|
|
|
|
# download zip file
|
|
|
|
local zipFile = $(package:G=download).zip ;
|
|
|
|
|
|
|
|
# Request the download only once.
|
|
|
|
if [ on $(zipFile) return $(HAIKU_OPTIONAL_PACKAGE_DOWNLOAD) ] {
|
|
|
|
return $(zipFile) ;
|
|
|
|
}
|
|
|
|
|
|
|
|
HAIKU_OPTIONAL_PACKAGE_DOWNLOAD on $(zipFile) = 1 ;
|
|
|
|
|
|
|
|
MakeLocate $(zipFile) : $(HAIKU_DOWNLOAD_DIR) ;
|
|
|
|
DownloadFile $(zipFile) : $(url) ;
|
|
|
|
|
|
|
|
return $(zipFile) ;
|
|
|
|
}
|