2015-06-13 19:20:56 +00:00
|
|
|
# $FreeBSD$
|
2020-11-24 21:45:38 +00:00
|
|
|
# $Id: meta.stage.mk,v 1.60 2020/08/19 17:51:53 sjg Exp $
|
2012-08-22 19:25:57 +00:00
|
|
|
#
|
2017-03-06 23:13:25 +00:00
|
|
|
# @(#) Copyright (c) 2011-2017, Simon J. Gerraty
|
2012-08-22 19:25:57 +00:00
|
|
|
#
|
|
|
|
# This file is provided in the hope that it will
|
|
|
|
# be of use. There is absolutely NO WARRANTY.
|
|
|
|
# Permission to copy, redistribute or otherwise
|
2020-11-24 21:45:38 +00:00
|
|
|
# use this file is hereby granted provided that
|
2012-08-22 19:25:57 +00:00
|
|
|
# the above copyright notice and this notice are
|
2020-11-24 21:45:38 +00:00
|
|
|
# left intact.
|
|
|
|
#
|
2012-08-22 19:25:57 +00:00
|
|
|
# Please send copies of changes and bug-fixes to:
|
|
|
|
# sjg@crufty.net
|
|
|
|
#
|
|
|
|
|
2018-08-02 21:33:45 +00:00
|
|
|
.ifndef NO_STAGING
|
|
|
|
|
2012-08-22 19:25:57 +00:00
|
|
|
.if !target(__${.PARSEFILE}__)
|
2017-03-06 23:13:25 +00:00
|
|
|
# the guard target is defined later
|
2012-08-22 19:25:57 +00:00
|
|
|
|
2020-11-24 21:45:38 +00:00
|
|
|
.-include <local.meta.stage.mk>
|
|
|
|
|
2012-08-22 19:25:57 +00:00
|
|
|
.if ${.MAKE.DEPENDFILE_PREFERENCE:U${.MAKE.DEPENDFILE}:M*.${MACHINE}} != ""
|
|
|
|
# this is generally safer anyway
|
2020-11-24 21:45:38 +00:00
|
|
|
_dirdep ?= ${RELDIR}.${TARGET_SPEC:U${MACHINE}}
|
2012-08-22 19:25:57 +00:00
|
|
|
.else
|
2018-08-02 21:33:45 +00:00
|
|
|
_dirdep ?= ${RELDIR}
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
|
|
|
|
2015-10-07 00:24:27 +00:00
|
|
|
CLEANFILES+= .dirdep
|
|
|
|
|
2012-08-22 19:25:57 +00:00
|
|
|
# this allows us to trace dependencies back to their src dir
|
2016-03-11 00:37:02 +00:00
|
|
|
.dirdep: .NOPATH
|
2012-08-22 19:25:57 +00:00
|
|
|
@echo '${_dirdep}' > $@
|
|
|
|
|
|
|
|
.if defined(NO_POSIX_SHELL) || ${type printf:L:sh:Mbuiltin} == ""
|
|
|
|
_stage_file_basename = `basename $$f`
|
|
|
|
_stage_target_dirname = `dirname $$t`
|
|
|
|
.else
|
|
|
|
_stage_file_basename = $${f\#\#*/}
|
|
|
|
_stage_target_dirname = $${t%/*}
|
|
|
|
.endif
|
|
|
|
|
2013-10-13 00:17:24 +00:00
|
|
|
_OBJROOT ?= ${OBJROOT:U${OBJTOP:H}}
|
|
|
|
.if ${_OBJROOT:M*/} != ""
|
|
|
|
_objroot ?= ${_OBJROOT:tA}/
|
|
|
|
.else
|
2012-11-08 21:15:57 +00:00
|
|
|
_objroot ?= ${_OBJROOT:tA}
|
2013-10-13 00:17:24 +00:00
|
|
|
.endif
|
|
|
|
|
2012-11-08 21:15:57 +00:00
|
|
|
# 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,} \
|
2014-11-20 22:42:40 +00:00
|
|
|
${_STAGED_DIRS:O:u:M${_objroot}*:N${OBJTOP}*:S,${_objroot},,:C,^([^/]+)/(.*),N\2.\1,:S,${HOST_TARGET},.host,}
|
2012-11-08 21:15:57 +00:00
|
|
|
|
2013-04-14 01:21:20 +00:00
|
|
|
LN_CP_SCRIPT = LnCp() { \
|
|
|
|
rm -f $$2 2> /dev/null; \
|
2016-12-23 02:57:00 +00:00
|
|
|
{ [ -z "$$mode" ] && ${LN:Uln} $$1 $$2 2> /dev/null; } || \
|
2013-04-14 01:21:20 +00:00
|
|
|
cp -p $$1 $$2; }
|
|
|
|
|
2015-06-16 23:06:43 +00:00
|
|
|
# a staging conflict should cause an error
|
|
|
|
# a warning is handy when bootstapping different options.
|
|
|
|
STAGE_CONFLICT?= ERROR
|
|
|
|
.if ${STAGE_CONFLICT:tl} == "error"
|
2020-11-24 21:45:38 +00:00
|
|
|
STAGE_CONFLICT_ACTION= exit 1
|
2015-06-16 23:06:43 +00:00
|
|
|
.else
|
|
|
|
STAGE_CONFLICT_ACTION=
|
|
|
|
.endif
|
|
|
|
|
2012-11-08 21:15:57 +00:00
|
|
|
# it is an error for more than one src dir to try and stage
|
|
|
|
# the same file
|
2013-04-14 01:21:20 +00:00
|
|
|
STAGE_DIRDEP_SCRIPT = ${LN_CP_SCRIPT}; StageDirdep() { \
|
2012-11-08 21:15:57 +00:00
|
|
|
t=$$1; \
|
|
|
|
if [ -s $$t.dirdep ]; then \
|
|
|
|
cmp -s .dirdep $$t.dirdep && return; \
|
2020-11-24 21:45:38 +00:00
|
|
|
x=`cat $$t.dirdep`; \
|
|
|
|
case "${RELDIR}:${_dirdep}" in $${x%.*}:$${x}*) ;; \
|
|
|
|
*) echo "${STAGE_CONFLICT}: $$t installed by $$x not ${_dirdep}" >&2; \
|
|
|
|
${STAGE_CONFLICT_ACTION} ;; esac; \
|
2012-11-08 21:15:57 +00:00
|
|
|
fi; \
|
2013-04-14 01:21:20 +00:00
|
|
|
LnCp .dirdep $$t.dirdep || exit 1; }
|
2012-11-08 21:15:57 +00:00
|
|
|
|
2012-08-22 19:25:57 +00:00
|
|
|
# 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)
|
2012-11-08 21:15:57 +00:00
|
|
|
STAGE_FILE_SCRIPT = ${STAGE_DIRDEP_SCRIPT}; StageFiles() { \
|
2013-03-08 00:05:34 +00:00
|
|
|
case "$$1" in "") return;; -m) mode=$$2; shift 2;; *) mode=;; esac; \
|
2012-08-22 19:25:57 +00:00
|
|
|
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; \
|
2012-11-08 21:15:57 +00:00
|
|
|
StageDirdep $$t; \
|
2013-04-14 01:21:20 +00:00
|
|
|
LnCp $$f $$t || exit 1; \
|
2013-02-26 05:44:12 +00:00
|
|
|
[ -z "$$mode" ] || chmod $$mode $$t; \
|
2012-11-08 21:15:57 +00:00
|
|
|
done; :; }
|
2012-08-22 19:25:57 +00:00
|
|
|
|
2012-11-08 21:15:57 +00:00
|
|
|
STAGE_LINKS_SCRIPT = ${STAGE_DIRDEP_SCRIPT}; StageLinks() { \
|
2013-03-08 00:05:34 +00:00
|
|
|
case "$$1" in "") return;; --) shift;; -*) ldest= lnf=$$1; shift;; /*) ldest=$$1/;; esac; \
|
2012-08-22 19:25:57 +00:00
|
|
|
dest=$$1; shift; \
|
|
|
|
mkdir -p $$dest; \
|
|
|
|
[ -s .dirdep ] || echo '${_dirdep}' > .dirdep; \
|
|
|
|
while test $$\# -ge 2; do \
|
2013-01-29 00:10:05 +00:00
|
|
|
l=$$ldest$$1; shift; \
|
2012-08-22 19:25:57 +00:00
|
|
|
t=$$dest/$$1; \
|
|
|
|
case "$$1" in */*) mkdir -p ${_stage_target_dirname};; esac; \
|
|
|
|
shift; \
|
2012-11-08 21:15:57 +00:00
|
|
|
StageDirdep $$t; \
|
|
|
|
rm -f $$t 2>/dev/null; \
|
2013-03-08 00:05:34 +00:00
|
|
|
ln $$lnf $$l $$t || exit 1; \
|
2012-08-22 19:25:57 +00:00
|
|
|
done; :; }
|
|
|
|
|
2012-11-08 21:15:57 +00:00
|
|
|
STAGE_AS_SCRIPT = ${STAGE_DIRDEP_SCRIPT}; StageAs() { \
|
2013-03-08 00:05:34 +00:00
|
|
|
case "$$1" in "") return;; -m) mode=$$2; shift 2;; *) mode=;; esac; \
|
2012-08-22 19:25:57 +00:00
|
|
|
dest=$$1; shift; \
|
|
|
|
mkdir -p $$dest; \
|
|
|
|
[ -s .dirdep ] || echo '${_dirdep}' > .dirdep; \
|
|
|
|
while test $$\# -ge 2; do \
|
|
|
|
s=$$1; shift; \
|
|
|
|
t=$$dest/$$1; \
|
|
|
|
case "$$1" in */*) mkdir -p ${_stage_target_dirname};; esac; \
|
|
|
|
shift; \
|
2012-11-08 21:15:57 +00:00
|
|
|
StageDirdep $$t; \
|
2013-04-14 01:21:20 +00:00
|
|
|
LnCp $$s $$t || exit 1; \
|
2013-02-26 05:44:12 +00:00
|
|
|
[ -z "$$mode" ] || chmod $$mode $$t; \
|
2012-11-08 21:15:57 +00:00
|
|
|
done; :; }
|
2012-08-22 19:25:57 +00:00
|
|
|
|
|
|
|
# this is simple, a list of the "staged" files depends on this,
|
2017-03-06 23:13:25 +00:00
|
|
|
_STAGE_BASENAME_USE: .USE .dirdep ${.TARGET:T}
|
2012-11-08 21:15:57 +00:00
|
|
|
@${STAGE_FILE_SCRIPT}; StageFiles ${.TARGET:H:${STAGE_DIR_FILTER}} ${.TARGET:T}
|
2012-08-22 19:25:57 +00:00
|
|
|
|
2017-03-06 23:13:25 +00:00
|
|
|
_STAGE_AS_BASENAME_USE: .USE .dirdep ${.TARGET:T}
|
2014-11-20 22:42:40 +00:00
|
|
|
@${STAGE_AS_SCRIPT}; StageAs ${.TARGET:H:${STAGE_DIR_FILTER}} ${.TARGET:T} ${STAGE_AS_${.TARGET:T}:U${.TARGET:T}}
|
|
|
|
|
2012-08-22 19:25:57 +00:00
|
|
|
|
2018-08-02 21:33:45 +00:00
|
|
|
.endif # first time
|
|
|
|
|
|
|
|
|
|
|
|
.if !empty(STAGE_INCSDIR)
|
|
|
|
.if !empty(STAGE_INCS)
|
2020-11-24 21:45:38 +00:00
|
|
|
stage_incs: ${STAGE_INCS:N*\**}
|
2018-08-02 21:33:45 +00:00
|
|
|
.endif
|
|
|
|
.if target(stage_incs) || !empty(.ALLTARGETS:Mstage_includes)
|
|
|
|
STAGE_TARGETS += stage_incs
|
|
|
|
STAGE_INCS ?= ${.ALLSRC:N.dirdep:Nstage_*}
|
2014-05-16 14:47:18 +00:00
|
|
|
stage_includes: stage_incs
|
2012-08-22 19:25:57 +00:00
|
|
|
stage_incs: .dirdep
|
2012-11-08 21:15:57 +00:00
|
|
|
@${STAGE_FILE_SCRIPT}; StageFiles ${STAGE_INCSDIR:${STAGE_DIR_FILTER}} ${STAGE_INCS}
|
2012-08-22 19:25:57 +00:00
|
|
|
@touch $@
|
|
|
|
|
2018-08-02 21:33:45 +00:00
|
|
|
.endif
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !empty(STAGE_LIBDIR)
|
|
|
|
.if !empty(STAGE_LIBS)
|
2020-11-24 21:45:38 +00:00
|
|
|
stage_libs: ${STAGE_LIBS:N*\**}
|
2018-08-02 21:33:45 +00:00
|
|
|
.endif
|
|
|
|
.if target(stage_libs)
|
|
|
|
STAGE_TARGETS += stage_libs
|
|
|
|
STAGE_LIBS ?= ${.ALLSRC:N.dirdep:Nstage_*}
|
2012-08-22 19:25:57 +00:00
|
|
|
stage_libs: .dirdep
|
2012-11-08 21:15:57 +00:00
|
|
|
@${STAGE_FILE_SCRIPT}; StageFiles ${STAGE_LIBDIR:${STAGE_DIR_FILTER}} ${STAGE_LIBS}
|
2014-05-10 00:26:40 +00:00
|
|
|
.if !defined(NO_SHLIB_LINKS)
|
2012-08-22 19:25:57 +00:00
|
|
|
.if !empty(SHLIB_LINKS)
|
2012-11-08 21:15:57 +00:00
|
|
|
@${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_LIBDIR:${STAGE_DIR_FILTER}} \
|
2012-08-22 19:25:57 +00:00
|
|
|
${SHLIB_LINKS:@t@${STAGE_LIBS:T:M$t.*} $t@}
|
|
|
|
.elif !empty(SHLIB_LINK) && !empty(SHLIB_NAME)
|
2015-11-13 22:27:24 +00:00
|
|
|
@${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_LIBDIR:${STAGE_DIR_FILTER}} ${SHLIB_NAME} ${SHLIB_LINK}
|
2014-05-10 00:26:40 +00:00
|
|
|
.endif
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
|
|
|
@touch $@
|
2017-03-06 23:13:25 +00:00
|
|
|
.endif
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !empty(STAGE_DIR)
|
|
|
|
STAGE_SETS += _default
|
|
|
|
STAGE_DIR._default = ${STAGE_DIR}
|
2013-01-29 00:10:05 +00:00
|
|
|
STAGE_LINKS_DIR._default = ${STAGE_LINKS_DIR:U${STAGE_OBJTOP}}
|
|
|
|
STAGE_SYMLINKS_DIR._default = ${STAGE_SYMLINKS_DIR:U${STAGE_OBJTOP}}
|
2012-08-22 19:25:57 +00:00
|
|
|
STAGE_FILES._default = ${STAGE_FILES}
|
2013-01-29 00:10:05 +00:00
|
|
|
STAGE_LINKS._default = ${STAGE_LINKS}
|
2012-08-22 19:25:57 +00:00
|
|
|
STAGE_SYMLINKS._default = ${STAGE_SYMLINKS}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !empty(STAGE_SETS)
|
2012-11-08 21:15:57 +00:00
|
|
|
CLEANFILES += ${STAGE_SETS:@s@stage*$s@}
|
|
|
|
|
2012-08-22 19:25:57 +00:00
|
|
|
# some makefiles need to populate multiple directories
|
|
|
|
.for s in ${STAGE_SETS:O:u}
|
2018-08-02 21:33:45 +00:00
|
|
|
.if !empty(STAGE_FILES.$s)
|
2020-11-24 21:45:38 +00:00
|
|
|
stage_files.$s: ${STAGE_FILES.$s:N*\**}
|
2018-08-02 21:33:45 +00:00
|
|
|
.endif
|
|
|
|
.if target(stage_files.$s) || target(stage_files${s:S,^,.,:N._default})
|
2013-03-08 22:02:08 +00:00
|
|
|
STAGE_TARGETS += stage_files
|
2018-08-02 21:33:45 +00:00
|
|
|
STAGE_FILES.$s ?= ${.ALLSRC:N.dirdep:Nstage_*}
|
2017-03-06 23:13:25 +00:00
|
|
|
.if !target(.stage_files.$s)
|
|
|
|
.stage_files.$s:
|
2012-08-22 19:25:57 +00:00
|
|
|
.if $s != "_default"
|
|
|
|
stage_files: stage_files.$s
|
|
|
|
stage_files.$s: .dirdep
|
|
|
|
.else
|
2018-08-02 21:33:45 +00:00
|
|
|
STAGE_FILES ?= ${.ALLSRC:N.dirdep:Nstage_*}
|
2012-08-22 19:25:57 +00:00
|
|
|
stage_files: .dirdep
|
|
|
|
.endif
|
2020-11-24 21:45:38 +00:00
|
|
|
@${STAGE_FILE_SCRIPT}; StageFiles ${FLAGS.$@} ${STAGE_FILES_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_FILES.$s:O}
|
2013-01-29 00:10:05 +00:00
|
|
|
@touch $@
|
2017-03-06 23:13:25 +00:00
|
|
|
.endif
|
2018-08-02 21:33:45 +00:00
|
|
|
.endif
|
2013-01-29 00:10:05 +00:00
|
|
|
|
2018-08-02 21:33:45 +00:00
|
|
|
.if !empty(STAGE_LINKS.$s)
|
|
|
|
stage_links.$s:
|
|
|
|
.endif
|
|
|
|
.if target(stage_links.$s) || target(stage_links${s:S,^,.,:N._default})
|
|
|
|
STAGE_LINKS_DIR.$s ?= ${STAGE_OBJTOP}
|
2013-03-08 22:02:08 +00:00
|
|
|
STAGE_TARGETS += stage_links
|
2017-03-06 23:13:25 +00:00
|
|
|
.if !target(.stage_links.$s)
|
|
|
|
.stage_links.$s:
|
2013-01-29 00:10:05 +00:00
|
|
|
.if $s != "_default"
|
|
|
|
stage_links: stage_links.$s
|
|
|
|
stage_links.$s: .dirdep
|
|
|
|
.else
|
|
|
|
stage_links: .dirdep
|
|
|
|
.endif
|
|
|
|
@${STAGE_LINKS_SCRIPT}; StageLinks ${STAGE_LINKS_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_LINKS.$s}
|
2012-08-22 19:25:57 +00:00
|
|
|
@touch $@
|
2017-03-06 23:13:25 +00:00
|
|
|
.endif
|
2018-08-02 21:33:45 +00:00
|
|
|
.endif
|
2012-08-22 19:25:57 +00:00
|
|
|
|
2018-08-02 21:33:45 +00:00
|
|
|
.if !empty(STAGE_SYMLINKS.$s)
|
|
|
|
stage_symlinks.$s:
|
|
|
|
.endif
|
|
|
|
.if target(stage_symlinks.$s) || target(stage_symlinks${s:S,^,.,:N._default})
|
|
|
|
STAGE_SYMLINKS_DIR.$s ?= ${STAGE_OBJTOP}
|
2013-03-08 22:02:08 +00:00
|
|
|
STAGE_TARGETS += stage_symlinks
|
2017-03-06 23:13:25 +00:00
|
|
|
.if !target(.stage_symlinks.$s)
|
|
|
|
.stage_symlinks.$s:
|
2012-08-22 19:25:57 +00:00
|
|
|
.if $s != "_default"
|
|
|
|
stage_symlinks: stage_symlinks.$s
|
|
|
|
stage_symlinks.$s: .dirdep
|
|
|
|
.else
|
|
|
|
stage_symlinks: .dirdep
|
|
|
|
.endif
|
2012-11-08 21:15:57 +00:00
|
|
|
@${STAGE_LINKS_SCRIPT}; StageLinks -s ${STAGE_SYMLINKS_DIR.$s:U${STAGE_DIR.$s}:${STAGE_DIR_FILTER}} ${STAGE_SYMLINKS.$s}
|
2012-08-22 19:25:57 +00:00
|
|
|
@touch $@
|
2017-03-06 23:13:25 +00:00
|
|
|
.endif
|
2018-08-02 21:33:45 +00:00
|
|
|
.endif
|
2012-08-22 19:25:57 +00:00
|
|
|
|
|
|
|
.endfor
|
|
|
|
.endif
|
|
|
|
|
|
|
|
.if !empty(STAGE_AS_SETS)
|
2012-11-08 21:15:57 +00:00
|
|
|
CLEANFILES += ${STAGE_AS_SETS:@s@stage*$s@}
|
|
|
|
|
2012-08-22 19:25:57 +00:00
|
|
|
# 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
|
2016-12-23 02:57:00 +00:00
|
|
|
# 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
|
|
|
|
# both operations happen together
|
2012-08-22 19:25:57 +00:00
|
|
|
.for s in ${STAGE_AS_SETS:O:u}
|
2018-08-02 21:33:45 +00:00
|
|
|
.if !empty(STAGE_AS.$s)
|
2020-11-24 21:45:38 +00:00
|
|
|
stage_as.$s: ${STAGE_AS.$s:N*\**}
|
2018-08-02 21:33:45 +00:00
|
|
|
.endif
|
|
|
|
.if target(stage_as.$s)
|
|
|
|
STAGE_TARGETS += stage_as
|
2015-10-07 00:24:27 +00:00
|
|
|
STAGE_AS.$s ?= ${.ALLSRC:N.dirdep:Nstage_*}
|
2017-03-06 23:13:25 +00:00
|
|
|
.if !target(.stage_as.$s)
|
|
|
|
.stage_as.$s:
|
2012-08-22 19:25:57 +00:00
|
|
|
stage_as: stage_as.$s
|
|
|
|
stage_as.$s: .dirdep
|
2020-11-24 21:45:38 +00:00
|
|
|
@${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}}}@}
|
2012-08-22 19:25:57 +00:00
|
|
|
@touch $@
|
2017-03-06 23:13:25 +00:00
|
|
|
.endif
|
2018-08-02 21:33:45 +00:00
|
|
|
.endif
|
2012-08-22 19:25:57 +00:00
|
|
|
|
2018-08-02 21:33:45 +00:00
|
|
|
.if !empty(STAGE_AS_AND_SYMLINK.$s)
|
2020-11-24 21:45:38 +00:00
|
|
|
stage_as_and_symlink.$s: ${STAGE_AS_AND_SYMLINK.$s:N*\**}
|
2018-08-02 21:33:45 +00:00
|
|
|
.endif
|
|
|
|
.if target(stage_as_and_symlink.$s)
|
|
|
|
STAGE_TARGETS += stage_as_and_symlink
|
|
|
|
STAGE_AS_AND_SYMLINK.$s ?= ${.ALLSRC:N.dirdep:Nstage_*}
|
2017-03-06 23:13:25 +00:00
|
|
|
.if !target(.stage_as_and_symlink.$s)
|
|
|
|
.stage_as_and_symlink.$s:
|
2016-12-23 02:57:00 +00:00
|
|
|
stage_as_and_symlink: stage_as_and_symlink.$s
|
|
|
|
stage_as_and_symlink.$s: .dirdep
|
2020-11-24 21:45:38 +00:00
|
|
|
@${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:O:@f@${STAGE_AS_${f:tA}:U${STAGE_AS_${f:T}:U${f:T}}} $f@}
|
2016-12-23 02:57:00 +00:00
|
|
|
@touch $@
|
2017-03-06 23:13:25 +00:00
|
|
|
.endif
|
2018-08-02 21:33:45 +00:00
|
|
|
.endif
|
2016-12-23 02:57:00 +00:00
|
|
|
|
2012-08-22 19:25:57 +00:00
|
|
|
.endfor
|
|
|
|
.endif
|
|
|
|
|
2014-05-16 14:47:18 +00:00
|
|
|
CLEANFILES += ${STAGE_TARGETS} stage_incs stage_includes
|
2013-03-08 22:02:08 +00:00
|
|
|
|
2017-03-06 23:13:25 +00:00
|
|
|
# this lot also only makes sense the first time...
|
|
|
|
.if !target(__${.PARSEFILE}__)
|
|
|
|
__${.PARSEFILE}__:
|
|
|
|
|
2013-03-08 22:02:08 +00:00
|
|
|
# stage_*links usually needs to follow any others.
|
2015-10-07 00:24:27 +00:00
|
|
|
# for non-jobs mode the order here matters
|
|
|
|
staging: ${STAGE_TARGETS:N*_links} ${STAGE_TARGETS:M*_links}
|
|
|
|
|
2016-03-11 00:37:02 +00:00
|
|
|
.if ${.MAKE.JOBS:U0} > 0 && ${STAGE_TARGETS:U:M*_links} != ""
|
2015-10-07 00:24:27 +00:00
|
|
|
# the above isn't sufficient
|
|
|
|
.for t in ${STAGE_TARGETS:N*links:O:u}
|
|
|
|
.ORDER: $t stage_links
|
2013-03-08 22:02:08 +00:00
|
|
|
.endfor
|
2015-10-02 06:24:09 +00:00
|
|
|
.endif
|
2013-03-08 22:02:08 +00:00
|
|
|
|
|
|
|
# generally we want staging to wait until everything else is done
|
|
|
|
STAGING_WAIT ?= .WAIT
|
|
|
|
|
2015-05-26 21:03:41 +00:00
|
|
|
.if ${.MAKE.LEVEL} > 0
|
2013-03-08 22:02:08 +00:00
|
|
|
all: ${STAGING_WAIT} staging
|
2015-05-26 21:03:41 +00:00
|
|
|
.endif
|
2013-03-08 00:23:42 +00:00
|
|
|
|
2013-04-19 18:45:03 +00:00
|
|
|
.if exists(${.PARSEDIR}/stage-install.sh) && !defined(STAGE_INSTALL)
|
|
|
|
# this will run install(1) and then followup with .dirdep files.
|
|
|
|
STAGE_INSTALL := sh ${.PARSEDIR:tA}/stage-install.sh INSTALL="${INSTALL}" OBJDIR=${.OBJDIR:tA}
|
|
|
|
.endif
|
|
|
|
|
|
|
|
# if ${INSTALL} gets run during 'all' assume it is for staging?
|
|
|
|
.if ${.TARGETS:Nall} == "" && defined(STAGE_INSTALL)
|
|
|
|
INSTALL := ${STAGE_INSTALL}
|
|
|
|
.if target(beforeinstall)
|
|
|
|
beforeinstall: .dirdep
|
|
|
|
.endif
|
|
|
|
.endif
|
2014-11-20 22:42:40 +00:00
|
|
|
.NOPATH: ${STAGE_FILES}
|
|
|
|
|
|
|
|
.if !empty(STAGE_TARGETS)
|
2018-08-02 21:33:45 +00:00
|
|
|
# for backwards compat make sure they exist
|
|
|
|
${STAGE_TARGETS}:
|
|
|
|
|
2016-06-05 21:21:41 +00:00
|
|
|
.NOPATH: ${CLEANFILES}
|
|
|
|
|
2014-11-20 22:42:40 +00:00
|
|
|
MK_STALE_STAGED?= no
|
|
|
|
.if ${MK_STALE_STAGED} == "yes"
|
|
|
|
all: stale_staged
|
|
|
|
# get a list of paths that we have just staged
|
|
|
|
# get a list of paths that we have previously staged to those same dirs
|
|
|
|
# anything in the 2nd list but not the first is stale - remove it.
|
|
|
|
stale_staged: staging .NOMETA
|
|
|
|
@egrep '^[WL] .*${STAGE_OBJTOP}' /dev/null ${.MAKE.META.FILES:M*stage_*} | \
|
|
|
|
sed "/\.dirdep/d;s,.* '*\(${STAGE_OBJTOP}/[^ '][^ ']*\).*,\1," | \
|
|
|
|
sort > ${.TARGET}.staged1
|
|
|
|
@grep -l '${_dirdep}' /dev/null ${_STAGED_DIRS:M${STAGE_OBJTOP}*:O:u:@d@$d/*.dirdep@} | \
|
|
|
|
sed 's,\.dirdep,,' | sort > ${.TARGET}.staged2
|
|
|
|
@comm -13 ${.TARGET}.staged1 ${.TARGET}.staged2 > ${.TARGET}.stale
|
|
|
|
@test ! -s ${.TARGET}.stale || { \
|
|
|
|
echo "Removing stale staged files..."; \
|
|
|
|
sed 's,.*,& &.dirdep,' ${.TARGET}.stale | xargs rm -f; }
|
2013-04-19 18:45:03 +00:00
|
|
|
|
2012-08-22 19:25:57 +00:00
|
|
|
.endif
|
2014-11-20 22:42:40 +00:00
|
|
|
.endif
|
|
|
|
.endif
|
2018-08-02 21:33:45 +00:00
|
|
|
.endif
|