Changeset View
Changeset View
Standalone View
Standalone View
head/share/mk/meta.stage.mk
# $FreeBSD$ | # $FreeBSD$ | ||||
# $Id: meta.stage.mk,v 1.55 2017/10/27 01:17:09 sjg Exp $ | # $Id: meta.stage.mk,v 1.60 2020/08/19 17:51:53 sjg Exp $ | ||||
# | # | ||||
# @(#) Copyright (c) 2011-2017, Simon J. Gerraty | # @(#) Copyright (c) 2011-2017, Simon J. Gerraty | ||||
# | # | ||||
# This file is provided in the hope that it will | # This file is provided in the hope that it will | ||||
# be of use. There is absolutely NO WARRANTY. | # be of use. There is absolutely NO WARRANTY. | ||||
# Permission to copy, redistribute or otherwise | # Permission to copy, redistribute or otherwise | ||||
# use this file is hereby granted provided that | # use this file is hereby granted provided that | ||||
# the above copyright notice and this notice are | # the above copyright notice and this notice are | ||||
# left intact. | # left intact. | ||||
# | # | ||||
# Please send copies of changes and bug-fixes to: | # Please send copies of changes and bug-fixes to: | ||||
# sjg@crufty.net | # sjg@crufty.net | ||||
# | # | ||||
.ifndef NO_STAGING | .ifndef NO_STAGING | ||||
.if !target(__${.PARSEFILE}__) | .if !target(__${.PARSEFILE}__) | ||||
# the guard target is defined later | # the guard target is defined later | ||||
.-include <local.meta.stage.mk> | |||||
.if ${.MAKE.DEPENDFILE_PREFERENCE:U${.MAKE.DEPENDFILE}:M*.${MACHINE}} != "" | .if ${.MAKE.DEPENDFILE_PREFERENCE:U${.MAKE.DEPENDFILE}:M*.${MACHINE}} != "" | ||||
# this is generally safer anyway | # this is generally safer anyway | ||||
_dirdep ?= ${RELDIR}.${MACHINE} | _dirdep ?= ${RELDIR}.${TARGET_SPEC:U${MACHINE}} | ||||
.else | .else | ||||
_dirdep ?= ${RELDIR} | _dirdep ?= ${RELDIR} | ||||
.endif | .endif | ||||
CLEANFILES+= .dirdep | CLEANFILES+= .dirdep | ||||
# this allows us to trace dependencies back to their src dir | # this allows us to trace dependencies back to their src dir | ||||
.dirdep: .NOPATH | .dirdep: .NOPATH | ||||
Show All 30 Lines | LN_CP_SCRIPT = LnCp() { \ | ||||
rm -f $$2 2> /dev/null; \ | rm -f $$2 2> /dev/null; \ | ||||
{ [ -z "$$mode" ] && ${LN:Uln} $$1 $$2 2> /dev/null; } || \ | { [ -z "$$mode" ] && ${LN:Uln} $$1 $$2 2> /dev/null; } || \ | ||||
cp -p $$1 $$2; } | cp -p $$1 $$2; } | ||||
# a staging conflict should cause an error | # a staging conflict should cause an error | ||||
# a warning is handy when bootstapping different options. | # a warning is handy when bootstapping different options. | ||||
STAGE_CONFLICT?= ERROR | STAGE_CONFLICT?= ERROR | ||||
.if ${STAGE_CONFLICT:tl} == "error" | .if ${STAGE_CONFLICT:tl} == "error" | ||||
STAGE_CONFLICT_ACTION= exit 1; | STAGE_CONFLICT_ACTION= exit 1 | ||||
.else | .else | ||||
STAGE_CONFLICT_ACTION= | STAGE_CONFLICT_ACTION= | ||||
.endif | .endif | ||||
# it is an error for more than one src dir to try and stage | # it is an error for more than one src dir to try and stage | ||||
# the same file | # the same file | ||||
STAGE_DIRDEP_SCRIPT = ${LN_CP_SCRIPT}; StageDirdep() { \ | STAGE_DIRDEP_SCRIPT = ${LN_CP_SCRIPT}; StageDirdep() { \ | ||||
t=$$1; \ | t=$$1; \ | ||||
if [ -s $$t.dirdep ]; then \ | if [ -s $$t.dirdep ]; then \ | ||||
cmp -s .dirdep $$t.dirdep && return; \ | cmp -s .dirdep $$t.dirdep && return; \ | ||||
echo "${STAGE_CONFLICT}: $$t installed by `cat $$t.dirdep` not ${_dirdep}" >&2; \ | x=`cat $$t.dirdep`; \ | ||||
${STAGE_CONFLICT_ACTION} \ | case "${RELDIR}:${_dirdep}" in $${x%.*}:$${x}*) ;; \ | ||||
*) echo "${STAGE_CONFLICT}: $$t installed by $$x not ${_dirdep}" >&2; \ | |||||
${STAGE_CONFLICT_ACTION} ;; esac; \ | |||||
fi; \ | fi; \ | ||||
LnCp .dirdep $$t.dirdep || exit 1; } | LnCp .dirdep $$t.dirdep || exit 1; } | ||||
# common logic for staging files | # common logic for staging files | ||||
# this all relies on RELDIR being set to a subdir of SRCTOP | # this all relies on RELDIR being set to a subdir of SRCTOP | ||||
# we use ln(1) if we can, else cp(1) | # we use ln(1) if we can, else cp(1) | ||||
STAGE_FILE_SCRIPT = ${STAGE_DIRDEP_SCRIPT}; StageFiles() { \ | STAGE_FILE_SCRIPT = ${STAGE_DIRDEP_SCRIPT}; StageFiles() { \ | ||||
case "$$1" in "") return;; -m) mode=$$2; shift 2;; *) mode=;; esac; \ | case "$$1" in "") return;; -m) mode=$$2; shift 2;; *) mode=;; esac; \ | ||||
▲ Show 20 Lines • Show All 45 Lines • ▼ Show 20 Lines | _STAGE_AS_BASENAME_USE: .USE .dirdep ${.TARGET:T} | ||||
@${STAGE_AS_SCRIPT}; StageAs ${.TARGET:H:${STAGE_DIR_FILTER}} ${.TARGET:T} ${STAGE_AS_${.TARGET:T}:U${.TARGET:T}} | @${STAGE_AS_SCRIPT}; StageAs ${.TARGET:H:${STAGE_DIR_FILTER}} ${.TARGET:T} ${STAGE_AS_${.TARGET:T}:U${.TARGET:T}} | ||||
.endif # first time | .endif # first time | ||||
.if !empty(STAGE_INCSDIR) | .if !empty(STAGE_INCSDIR) | ||||
.if !empty(STAGE_INCS) | .if !empty(STAGE_INCS) | ||||
stage_incs: ${STAGE_INCS} | stage_incs: ${STAGE_INCS:N*\**} | ||||
.endif | .endif | ||||
.if target(stage_incs) || !empty(.ALLTARGETS:Mstage_includes) | .if target(stage_incs) || !empty(.ALLTARGETS:Mstage_includes) | ||||
STAGE_TARGETS += stage_incs | STAGE_TARGETS += stage_incs | ||||
STAGE_INCS ?= ${.ALLSRC:N.dirdep:Nstage_*} | STAGE_INCS ?= ${.ALLSRC:N.dirdep:Nstage_*} | ||||
stage_includes: stage_incs | stage_includes: stage_incs | ||||
stage_incs: .dirdep | stage_incs: .dirdep | ||||
@${STAGE_FILE_SCRIPT}; StageFiles ${STAGE_INCSDIR:${STAGE_DIR_FILTER}} ${STAGE_INCS} | @${STAGE_FILE_SCRIPT}; StageFiles ${STAGE_INCSDIR:${STAGE_DIR_FILTER}} ${STAGE_INCS} | ||||
@touch $@ | @touch $@ | ||||
.endif | .endif | ||||
.endif | .endif | ||||
.if !empty(STAGE_LIBDIR) | .if !empty(STAGE_LIBDIR) | ||||
.if !empty(STAGE_LIBS) | .if !empty(STAGE_LIBS) | ||||
stage_libs: ${STAGE_LIBS} | stage_libs: ${STAGE_LIBS:N*\**} | ||||
.endif | .endif | ||||
.if target(stage_libs) | .if target(stage_libs) | ||||
STAGE_TARGETS += stage_libs | STAGE_TARGETS += stage_libs | ||||
STAGE_LIBS ?= ${.ALLSRC:N.dirdep:Nstage_*} | STAGE_LIBS ?= ${.ALLSRC:N.dirdep:Nstage_*} | ||||
stage_libs: .dirdep | stage_libs: .dirdep | ||||
@${STAGE_FILE_SCRIPT}; StageFiles ${STAGE_LIBDIR:${STAGE_DIR_FILTER}} ${STAGE_LIBS} | @${STAGE_FILE_SCRIPT}; StageFiles ${STAGE_LIBDIR:${STAGE_DIR_FILTER}} ${STAGE_LIBS} | ||||
.if !defined(NO_SHLIB_LINKS) | .if !defined(NO_SHLIB_LINKS) | ||||
.if !empty(SHLIB_LINKS) | .if !empty(SHLIB_LINKS) | ||||
Show All 18 Lines | |||||
.endif | .endif | ||||
.if !empty(STAGE_SETS) | .if !empty(STAGE_SETS) | ||||
CLEANFILES += ${STAGE_SETS:@s@stage*$s@} | CLEANFILES += ${STAGE_SETS:@s@stage*$s@} | ||||
# some makefiles need to populate multiple directories | # some makefiles need to populate multiple directories | ||||
.for s in ${STAGE_SETS:O:u} | .for s in ${STAGE_SETS:O:u} | ||||
.if !empty(STAGE_FILES.$s) | .if !empty(STAGE_FILES.$s) | ||||
stage_files.$s: ${STAGE_FILES.$s} | stage_files.$s: ${STAGE_FILES.$s:N*\**} | ||||
.endif | .endif | ||||
.if target(stage_files.$s) || target(stage_files${s:S,^,.,:N._default}) | .if target(stage_files.$s) || target(stage_files${s:S,^,.,:N._default}) | ||||
STAGE_TARGETS += stage_files | STAGE_TARGETS += stage_files | ||||
STAGE_FILES.$s ?= ${.ALLSRC:N.dirdep:Nstage_*} | STAGE_FILES.$s ?= ${.ALLSRC:N.dirdep:Nstage_*} | ||||
.if !target(.stage_files.$s) | .if !target(.stage_files.$s) | ||||
.stage_files.$s: | .stage_files.$s: | ||||
.if $s != "_default" | .if $s != "_default" | ||||
stage_files: stage_files.$s | stage_files: stage_files.$s | ||||
stage_files.$s: .dirdep | stage_files.$s: .dirdep | ||||
.else | .else | ||||
STAGE_FILES ?= ${.ALLSRC:N.dirdep:Nstage_*} | STAGE_FILES ?= ${.ALLSRC:N.dirdep:Nstage_*} | ||||
stage_files: .dirdep | stage_files: .dirdep | ||||
.endif | .endif | ||||
@${STAGE_FILE_SCRIPT}; StageFiles ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_FILES.$s} | @${STAGE_FILE_SCRIPT}; StageFiles ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_FILES.$s:O} | ||||
@touch $@ | @touch $@ | ||||
.endif | .endif | ||||
.endif | .endif | ||||
.if !empty(STAGE_LINKS.$s) | .if !empty(STAGE_LINKS.$s) | ||||
stage_links.$s: | stage_links.$s: | ||||
.endif | .endif | ||||
.if target(stage_links.$s) || target(stage_links${s:S,^,.,:N._default}) | .if target(stage_links.$s) || target(stage_links${s:S,^,.,:N._default}) | ||||
Show All 40 Lines | |||||
# sometimes things need to be renamed as they are staged | # sometimes things need to be renamed as they are staged | ||||
# each ${file} will be staged as ${STAGE_AS_${file:T}} | # each ${file} will be staged as ${STAGE_AS_${file:T}} | ||||
# one could achieve the same with SYMLINKS | # one could achieve the same with SYMLINKS | ||||
# stage_as_and_symlink makes the original name a symlink to the new name | # stage_as_and_symlink makes the original name a symlink to the new name | ||||
# it is the same as using stage_as and stage_symlinks but ensures | # it is the same as using stage_as and stage_symlinks but ensures | ||||
# both operations happen together | # both operations happen together | ||||
.for s in ${STAGE_AS_SETS:O:u} | .for s in ${STAGE_AS_SETS:O:u} | ||||
.if !empty(STAGE_AS.$s) | .if !empty(STAGE_AS.$s) | ||||
stage_as.$s: ${STAGE_AS.$s} | stage_as.$s: ${STAGE_AS.$s:N*\**} | ||||
.endif | .endif | ||||
.if target(stage_as.$s) | .if target(stage_as.$s) | ||||
STAGE_TARGETS += stage_as | STAGE_TARGETS += stage_as | ||||
STAGE_AS.$s ?= ${.ALLSRC:N.dirdep:Nstage_*} | STAGE_AS.$s ?= ${.ALLSRC:N.dirdep:Nstage_*} | ||||
.if !target(.stage_as.$s) | .if !target(.stage_as.$s) | ||||
.stage_as.$s: | .stage_as.$s: | ||||
stage_as: stage_as.$s | stage_as: stage_as.$s | ||||
stage_as.$s: .dirdep | stage_as.$s: .dirdep | ||||
@${STAGE_AS_SCRIPT}; StageAs ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS.$s:@f@$f ${STAGE_AS_${f:tA}:U${STAGE_AS_${f:T}:U${f:T}}}@} | @${STAGE_AS_SCRIPT}; StageAs ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS.$s:O:@f@$f ${STAGE_AS_${f:tA}:U${STAGE_AS_${f:T}:U${f:T}}}@} | ||||
@touch $@ | @touch $@ | ||||
.endif | .endif | ||||
.endif | .endif | ||||
.if !empty(STAGE_AS_AND_SYMLINK.$s) | .if !empty(STAGE_AS_AND_SYMLINK.$s) | ||||
stage_as_and_symlink.$s: ${STAGE_AS_AND_SYMLINK.$s} | stage_as_and_symlink.$s: ${STAGE_AS_AND_SYMLINK.$s:N*\**} | ||||
.endif | .endif | ||||
.if target(stage_as_and_symlink.$s) | .if target(stage_as_and_symlink.$s) | ||||
STAGE_TARGETS += stage_as_and_symlink | STAGE_TARGETS += stage_as_and_symlink | ||||
STAGE_AS_AND_SYMLINK.$s ?= ${.ALLSRC:N.dirdep:Nstage_*} | STAGE_AS_AND_SYMLINK.$s ?= ${.ALLSRC:N.dirdep:Nstage_*} | ||||
.if !target(.stage_as_and_symlink.$s) | .if !target(.stage_as_and_symlink.$s) | ||||
.stage_as_and_symlink.$s: | .stage_as_and_symlink.$s: | ||||
stage_as_and_symlink: stage_as_and_symlink.$s | stage_as_and_symlink: stage_as_and_symlink.$s | ||||
stage_as_and_symlink.$s: .dirdep | stage_as_and_symlink.$s: .dirdep | ||||
@${STAGE_AS_SCRIPT}; StageAs ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS_AND_SYMLINK.$s:@f@$f ${STAGE_AS_${f:tA}:U${STAGE_AS_${f:T}:U${f:T}}}@} | @${STAGE_AS_SCRIPT}; StageAs ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS_AND_SYMLINK.$s:O:@f@$f ${STAGE_AS_${f:tA}:U${STAGE_AS_${f:T}:U${f:T}}}@} | ||||
@${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS_AND_SYMLINK.$s:@f@${STAGE_AS_${f:tA}:U${STAGE_AS_${f:T}:U${f:T}}} $f@} | @${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_AS_AND_SYMLINK.$s:O:@f@${STAGE_AS_${f:tA}:U${STAGE_AS_${f:T}:U${f:T}}} $f@} | ||||
@touch $@ | @touch $@ | ||||
.endif | .endif | ||||
.endif | .endif | ||||
.endfor | .endfor | ||||
.endif | .endif | ||||
CLEANFILES += ${STAGE_TARGETS} stage_incs stage_includes | CLEANFILES += ${STAGE_TARGETS} stage_incs stage_includes | ||||
▲ Show 20 Lines • Show All 64 Lines • Show Last 20 Lines |