Latest version from Crufty
This commit is contained in:
parent
fbc1b149eb
commit
6ff48435f9
Notes:
svn2git
2020-12-20 02:59:44 +00:00
svn path=/projects/bmake/; revision=242786
@ -1,4 +1,4 @@
|
||||
# $Id: meta.stage.mk,v 1.11 2011/05/05 15:01:05 sjg Exp $
|
||||
# $Id: meta.stage.mk,v 1.15 2012/10/14 02:50:38 sjg Exp $
|
||||
#
|
||||
# @(#) Copyright (c) 2011, Simon J. Gerraty
|
||||
#
|
||||
@ -35,23 +35,47 @@ _stage_file_basename = $${f\#\#*/}
|
||||
_stage_target_dirname = $${t%/*}
|
||||
.endif
|
||||
|
||||
_objroot ?= ${_OBJROOT:tA}
|
||||
# make sure this is global
|
||||
_STAGED_DIRS ?=
|
||||
.export _STAGED_DIRS
|
||||
# add each dir we stage to to _STAGED_DIRS
|
||||
# and make sure we have absolute paths so that bmake
|
||||
# will match against .MAKE.META.BAILIWICK
|
||||
STAGE_DIR_FILTER = tA:@d@$${_STAGED_DIRS::+=$$d}$$d@
|
||||
# convert _STAGED_DIRS into suitable filters
|
||||
GENDIRDEPS_FILTER += Nnot-empty-is-important \
|
||||
${_STAGED_DIRS:O:u:M${OBJTOP}*:S,${OBJTOP}/,N,} \
|
||||
${_STAGED_DIRS:O:u:N${OBJTOP}*:S,${_objroot},,:C,^([^/]+)/(.*),N\2.\1,:S,${HOST_TARGET},.host,}
|
||||
|
||||
# it is an error for more than one src dir to try and stage
|
||||
# the same file
|
||||
STAGE_DIRDEP_SCRIPT = StageDirdep() { \
|
||||
t=$$1; \
|
||||
if [ -s $$t.dirdep ]; then \
|
||||
cmp -s .dirdep $$t.dirdep && return; \
|
||||
echo "ERROR: $$t installed by `cat $$t.dirdep` not ${_dirdep}" >&2; \
|
||||
exit 1; \
|
||||
fi; \
|
||||
ln .dirdep $$t.dirdep 2> /dev/null || \
|
||||
cp .dirdep $$t.dirdep; }
|
||||
|
||||
# common logic for staging files
|
||||
# this all relies on RELDIR being set to a subdir of SRCTOP
|
||||
# we use ln(1) if we can, else cp(1)
|
||||
STAGE_FILE_SCRIPT = StageFiles() { \
|
||||
STAGE_FILE_SCRIPT = ${STAGE_DIRDEP_SCRIPT}; StageFiles() { \
|
||||
dest=$$1; shift; \
|
||||
mkdir -p $$dest; \
|
||||
[ -s .dirdep ] || echo '${_dirdep}' > .dirdep; \
|
||||
for f in "$$@"; do \
|
||||
case "$$f" in */*) t=$$dest/${_stage_file_basename};; *) t=$$dest/$$f;; esac; \
|
||||
rm -f $$t $$t.dirdep; \
|
||||
StageDirdep $$t; \
|
||||
rm -f $$t; \
|
||||
{ ln $$f $$t 2> /dev/null || \
|
||||
cp -p $$f $$t; } && \
|
||||
{ ln .dirdep $$t.dirdep 2> /dev/null || \
|
||||
cp .dirdep $$t.dirdep; }; \
|
||||
done; }
|
||||
cp -p $$f $$t; }; \
|
||||
done; :; }
|
||||
|
||||
STAGE_LINKS_SCRIPT = StageLinks() { \
|
||||
STAGE_LINKS_SCRIPT = ${STAGE_DIRDEP_SCRIPT}; StageLinks() { \
|
||||
case "$$1" in --) shift;; -*) lnf=$$1; shift;; esac; \
|
||||
dest=$$1; shift; \
|
||||
mkdir -p $$dest; \
|
||||
@ -61,13 +85,12 @@ STAGE_LINKS_SCRIPT = StageLinks() { \
|
||||
t=$$dest/$$1; \
|
||||
case "$$1" in */*) mkdir -p ${_stage_target_dirname};; esac; \
|
||||
shift; \
|
||||
rm -f $$t $$t.dirdep 2>/dev/null; \
|
||||
StageDirdep $$t; \
|
||||
rm -f $$t 2>/dev/null; \
|
||||
ln $$lnf $$l $$t; \
|
||||
{ ln .dirdep $$t.dirdep 2> /dev/null || \
|
||||
cp .dirdep $$t.dirdep; }; \
|
||||
done; :; }
|
||||
|
||||
STAGE_AS_SCRIPT = StageAs() { \
|
||||
STAGE_AS_SCRIPT = ${STAGE_DIRDEP_SCRIPT}; StageAs() { \
|
||||
dest=$$1; shift; \
|
||||
mkdir -p $$dest; \
|
||||
[ -s .dirdep ] || echo '${_dirdep}' > .dirdep; \
|
||||
@ -76,35 +99,38 @@ STAGE_AS_SCRIPT = StageAs() { \
|
||||
t=$$dest/$$1; \
|
||||
case "$$1" in */*) mkdir -p ${_stage_target_dirname};; esac; \
|
||||
shift; \
|
||||
rm -f $$t $$t.dirdep; \
|
||||
StageDirdep $$t; \
|
||||
rm -f $$t; \
|
||||
{ ln $$s $$t 2> /dev/null || \
|
||||
cp -p $$s $$t; } && \
|
||||
{ ln .dirdep $$t.dirdep 2> /dev/null || \
|
||||
cp .dirdep $$t.dirdep; }; \
|
||||
done; }
|
||||
cp -p $$s $$t; }; \
|
||||
done; :; }
|
||||
|
||||
# this is simple, a list of the "staged" files depends on this,
|
||||
_STAGE_BASENAME_USE: .USE ${.TARGET:T}
|
||||
@${STAGE_FILE_SCRIPT}; StageFiles ${.TARGET:H} ${.TARGET:T}
|
||||
@${STAGE_FILE_SCRIPT}; StageFiles ${.TARGET:H:${STAGE_DIR_FILTER}} ${.TARGET:T}
|
||||
|
||||
.if !empty(STAGE_INCSDIR)
|
||||
CLEANFILES += stage_incs
|
||||
|
||||
STAGE_INCS ?= ${.ALLSRC:N.dirdep}
|
||||
|
||||
stage_incs: .dirdep
|
||||
@${STAGE_FILE_SCRIPT}; StageFiles ${STAGE_INCSDIR} ${STAGE_INCS}
|
||||
@${STAGE_FILE_SCRIPT}; StageFiles ${STAGE_INCSDIR:${STAGE_DIR_FILTER}} ${STAGE_INCS}
|
||||
@touch $@
|
||||
.endif
|
||||
|
||||
.if !empty(STAGE_LIBDIR)
|
||||
CLEANFILES += stage_libs
|
||||
|
||||
STAGE_LIBS ?= ${.ALLSRC:N.dirdep}
|
||||
|
||||
stage_libs: .dirdep
|
||||
@${STAGE_FILE_SCRIPT}; StageFiles ${STAGE_LIBDIR} ${STAGE_LIBS}
|
||||
@${STAGE_FILE_SCRIPT}; StageFiles ${STAGE_LIBDIR:${STAGE_DIR_FILTER}} ${STAGE_LIBS}
|
||||
.if !empty(SHLIB_LINKS)
|
||||
@${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_LIBDIR} \
|
||||
@${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_LIBDIR:${STAGE_DIR_FILTER}} \
|
||||
${SHLIB_LINKS:@t@${STAGE_LIBS:T:M$t.*} $t@}
|
||||
.elif !empty(SHLIB_LINK) && !empty(SHLIB_NAME)
|
||||
@${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_LIBDIR} ${SHLIB_NAME} ${SHLIB_LINK} ${SYMLINKS:T}
|
||||
@${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_LIBDIR:${STAGE_DIR_FILTER}} ${SHLIB_NAME} ${SHLIB_LINK} ${SYMLINKS:T}
|
||||
.endif
|
||||
@touch $@
|
||||
.endif
|
||||
@ -121,6 +147,8 @@ STAGE_SYMLINKS ?= ${.ALLSRC:T:N.dirdep:Nstage_*}
|
||||
|
||||
.if !empty(STAGE_SETS)
|
||||
|
||||
CLEANFILES += ${STAGE_SETS:@s@stage*$s@}
|
||||
|
||||
# some makefiles need to populate multiple directories
|
||||
.for s in ${STAGE_SETS:O:u}
|
||||
STAGE_FILES.$s ?= ${.ALLSRC:N.dirdep}
|
||||
@ -132,7 +160,7 @@ stage_files.$s: .dirdep
|
||||
.else
|
||||
stage_files: .dirdep
|
||||
.endif
|
||||
@${STAGE_FILE_SCRIPT}; StageFiles ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}} ${STAGE_FILES.$s}
|
||||
@${STAGE_FILE_SCRIPT}; StageFiles ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_FILES.$s}
|
||||
@touch $@
|
||||
|
||||
.if $s != "_default"
|
||||
@ -141,7 +169,7 @@ stage_symlinks.$s: .dirdep
|
||||
.else
|
||||
stage_symlinks: .dirdep
|
||||
.endif
|
||||
@${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_SYMLINKS_DIR.$s:U${STAGE_DIR.$s}} ${STAGE_SYMLINKS.$s}
|
||||
@${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_SYMLINKS_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_SYMLINKS.$s}
|
||||
@touch $@
|
||||
|
||||
.endfor
|
||||
@ -149,6 +177,8 @@ stage_symlinks: .dirdep
|
||||
|
||||
.if !empty(STAGE_AS_SETS)
|
||||
|
||||
CLEANFILES += ${STAGE_AS_SETS:@s@stage*$s@}
|
||||
|
||||
# sometimes things need to be renamed as they are staged
|
||||
# each ${file} will be staged as ${STAGE_AS_${file:T}}
|
||||
# one could achieve the same with SYMLINKS
|
||||
@ -157,7 +187,7 @@ STAGE_AS.$s ?= ${.ALLSRC:N.dirdep}
|
||||
|
||||
stage_as: stage_as.$s
|
||||
stage_as.$s: .dirdep
|
||||
@${STAGE_AS_SCRIPT}; StageAs ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}} ${STAGE_AS.$s:@f@$f ${STAGE_AS_${f:T}:U${f:T}}@}
|
||||
@${STAGE_AS_SCRIPT}; StageAs ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS.$s:@f@$f ${STAGE_AS_${f:T}:U${f:T}}@}
|
||||
@touch $@
|
||||
|
||||
.endfor
|
||||
|
@ -34,5 +34,14 @@
|
||||
_e := ${.MAKE.DEPENDFILE_PREFERENCE:@m@${exists($m):?$m:}@}
|
||||
.if !empty(_e)
|
||||
.MAKE.DEPENDFILE := ${_e:[1]}
|
||||
.elif ${.MAKE.DEPENDFILE_PREFERENCE:M*${MACHINE}} != "" && ${.MAKE.DEPENDFILE_PREFERENCE:[1]:E} != ${MACHINE}
|
||||
# MACHINE specific depend files are supported, but *not* default.
|
||||
# If any already exist, we should follow suit.
|
||||
_aml = ${ALL_MACHINE_LIST:Uarm amd64 i386 powerpc:N${MACHINE}} ${MACHINE}
|
||||
# MACHINE must be the last entry in _aml ;-)
|
||||
_e := ${_aml:@MACHINE@${.MAKE.DEPENDFILE_PREFERENCE:@m@${exists($m):?$m:}@}@}
|
||||
.if !empty(_e)
|
||||
.MAKE.DEPENDFILE ?= ${.MAKE.DEPENDFILE_PREFERENCE:M*${MACHINE}:[1]}
|
||||
.endif
|
||||
.endif
|
||||
.MAKE.DEPENDFILE ?= ${.MAKE.DEPENDFILE_PREFERENCE:[1]}
|
||||
|
Loading…
Reference in New Issue
Block a user