MegaGlest/mk/linux/mk/jam/subdir.jam

94 lines
2.4 KiB
Plaintext

#============================================================================
# Work around problems the SubDir rule of Jambase
# (until jampeople accept my patches :-/ )
#============================================================================
LOCATE_OBJECTS ?= $(top_builddir)/build/$(target) ;
LOCATE_TARGETS ?= $(top_builddir) ;
LOCATE_DOCS ?= $(top_builddir)/build ;
SUBDIRRULES += FixSubDirPath ;
MKDIR ?= mkdir ;
MKDIRS ?= "$(MKDIR) -p" ;
rule FixSubDirPath
{
LOCATE_SOURCE = [ ConcatDirs $(LOCATE_OBJECTS) $(SUBDIR_TOKENS) ] ;
LOCATE_TARGET = [ ConcatDirs $(LOCATE_OBJECTS) $(SUBDIR_TOKENS) ] ;
# We need to package the Jamfile (a bit hacky here...)
Package Jamfile ;
}
# fix bug in Jambase where SubInclude in the middle of a jam file made it break
rule SubInclude
{
if ! $($(<[1]))
{
Exit SubInclude $(<[1]) without prior SubDir $(<[1]) ;
}
local save_SUBDIR_TOKENS = $(SUBDIR_TOKENS) ;
SubDir $(<) ;
include $(JAMFILE:D=$(SUBDIR)) ;
SubDir $(<[1]) $(save_SUBDIR_TOKENS) ;
}
# this MakeLocate rule differs from the Jambase one in that it also works with
# files being in subdirectories
rule MakeLocate
{
# MakeLocate targets : directory ;
# Sets special variable LOCATE on targets, and arranges
# with MkDir to create target directory.
# Note we grist the directory name with 'dir',
# so that directory path components and other
# targets don't conflict.
if $(>) && $(>) != "" && $(>) != "."
{
local i ;
for i in $(<) {
LOCATE on $(i) = $(>) ;
local targetfile = $(i:R=$(>)) ;
Depends $(i) : $(targetfile:DG=dir) ;
MkDir $(targetfile:DG=dir) ;
}
}
}
# The default MkDir rule in Jambase has problems when paths contains a sequence
# of multiple slashes (ie. bla////fup). We solve these problems and greatly
# simply this rule by using the "mkdir -p" or mkdirs command.
rule MkDir
{
# MkDir directory ;
# Make a directory and all its parent directories.
# Ignore timestamps on directories: we only care if they
# exist.
NoUpdate $(<) ;
# don't create the dir multiple times
if ! $($(<)-mkdir)
{
$(<)-mkdir = true ;
MkDir1 $(<) ;
}
}
actions MkDir1
{
$(MKDIRS) "$(<)"
}