Skip to content

Commit a40d734

Browse files
committed
Export SB_OBJROOT for later reference
The build varies MAKEOBJDIRPREFIX at times which can make it difficult to track the original OBJROOT. This is easier when we get the original from env as SB_OBJROOT. If SB_OBJROOT did not come from env, set and export it the first time we set OBJROOT. This allows SB_OBJROOT to be used in .MAKE.META.IGNORE* variables to tweak what should be considered as making a target out-of-date. Update auto.obj.mk to latest from contrib/bmake - handles relative objdirs more simply and reliably. Also update jobs.mk and stage-install.sh Reviewed by: stevek Differential Revision: https://reviews.freebsd.org/D50313
1 parent 08bc009 commit a40d734

File tree

4 files changed

+79
-24
lines changed

4 files changed

+79
-24
lines changed

share/mk/auto.obj.mk

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
# SPDX-License-Identifier: BSD-2-Clause
22
#
3-
# $Id: auto.obj.mk,v 1.17 2024/02/17 17:26:57 sjg Exp $
3+
# $Id: auto.obj.mk,v 1.20 2025/05/17 15:29:55 sjg Exp $
44
#
5-
# @(#) Copyright (c) 2004, Simon J. Gerraty
5+
# @(#) Copyright (c) 2004-2025, Simon J. Gerraty
66
#
77
# This file is provided in the hope that it will
88
# be of use. There is absolutely NO WARRANTY.
@@ -50,7 +50,12 @@ __objdir?= ${.CURDIR}
5050
__objdir?= ${MAKEOBJDIRPREFIX}${.CURDIR}
5151
.endif
5252
__objdir?= ${MAKEOBJDIR:Uobj}
53-
__objdir:= ${__objdir}
53+
# relative dirs can cause trouble below
54+
# keep it simple and convert to absolute path now if needed
55+
.if ${__objdir:M/*} == ""
56+
# avoid ugly ${.CURDIR}/./obj etc.
57+
__objdir:= ${.CURDIR}/${__objdir:S,^./,,}
58+
.endif
5459
.if ${.OBJDIR:tA} != ${__objdir:tA}
5560
# We need to chdir, make the directory if needed
5661
.if !exists(${__objdir}/) && \
@@ -65,11 +70,9 @@ __objdir_made != echo ${__objdir}/; umask ${OBJDIR_UMASK:U002}; \
6570
.if ${.OBJDIR:tA} != ${__objdir:tA}
6671
# we did not get what we want - do we care?
6772
.if ${__objdir_made:Uno:M${__objdir}/*} != ""
68-
# watch out for __objdir being relative path
69-
.if !(${__objdir:M/*} == "" && ${.OBJDIR:tA} == ${${.CURDIR}/${__objdir}:L:tA})
73+
# we attempted to make ${__objdir} and failed
7074
.error could not use ${__objdir}: .OBJDIR=${.OBJDIR}
7175
.endif
72-
.endif
7376
# apparently we can live with it
7477
# make sure we know what we have
7578
.OBJDIR: ${.CURDIR}

share/mk/jobs.mk

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,8 @@
1-
# $Id: jobs.mk,v 1.14 2023/09/11 16:52:44 sjg Exp $
1+
# SPDX-License-Identifier: BSD-2-Clause
22
#
3-
# @(#) Copyright (c) 2012-2023, Simon J. Gerraty
3+
# $Id: jobs.mk,v 1.19 2025/02/03 21:18:44 sjg Exp $
4+
#
5+
# @(#) Copyright (c) 2012-2025, Simon J. Gerraty
46
#
57
# This file is provided in the hope that it will
68
# be of use. There is absolutely NO WARRANTY.
@@ -66,7 +68,7 @@ NEWLOG_SH := ${(type newlog.sh) 2> /dev/null:L:sh:M/*}
6668
.endif
6769
.endif
6870
.if !empty(NEWLOG_SH) && exists(${NEWLOG_SH})
69-
NEWLOG := sh ${NEWLOG_SH}
71+
NEWLOG := ${.SHELL:Ush} ${NEWLOG_SH}
7072
JOB_NEWLOG_ARGS ?= -S -n ${JOB_LOG_GENS}
7173
.else
7274
NEWLOG = :
@@ -78,7 +80,8 @@ JOB_MAX = ${.MAKE.JOBS}
7880
# This should be derrived from number of cpu's
7981
.if ${.MAKE.JOBS.C:Uno} == "yes"
8082
# 1.2 - 1.5 times nCPU works well on most machines that support -jC
81-
JOB_MAX_C ?= 1.33C
83+
# if the factor is floating point, the C suffix isn't needed
84+
JOB_MAX_C ?= 1.33
8285
JOB_MAX ?= ${JOB_MAX_C}
8386
.endif
8487
JOB_MAX ?= 8

share/mk/src.sys.obj.mk

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,12 @@ OBJROOT:= ${OBJROOT:H:tA}/${OBJROOT:T}
7373
.endif
7474
# Must export since OBJDIR will dynamically be based on it
7575
.export OBJROOT SRCTOP
76+
# if we didn't get SB_OBJROOT from env,
77+
# it is handy to set it now, so we can remember it
78+
.if empty(SB_OBJROOT)
79+
SB_OBJROOT:= ${OBJROOT}
80+
.export SB_OBJROOT
81+
.endif
7682
.endif
7783

7884
.if ${MK_DIRDEPS_BUILD} == "no"

share/mk/stage-install.sh

Lines changed: 57 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -28,22 +28,28 @@
2828
# "file".dirdep placed in "dest" or "dest".dirdep if it happed
2929
# to be a file rather than a directory.
3030
#
31+
# Before we run install(1), we check if "dest" needs to be a
32+
# directory (more than one file in "args") and create it
33+
# if necessary.
34+
#
3135
# SEE ALSO:
3236
# meta.stage.mk
33-
#
37+
#
3438

3539
# RCSid:
36-
# $Id: stage-install.sh,v 1.5 2013/04/19 16:32:24 sjg Exp $
40+
# $Id: stage-install.sh,v 1.11 2024/02/17 17:26:57 sjg Exp $
3741
#
38-
# @(#) Copyright (c) 2013, Simon J. Gerraty
42+
# SPDX-License-Identifier: BSD-2-Clause
43+
#
44+
# @(#) Copyright (c) 2013-2020, Simon J. Gerraty
3945
#
4046
# This file is provided in the hope that it will
4147
# be of use. There is absolutely NO WARRANTY.
4248
# Permission to copy, redistribute or otherwise
43-
# use this file is hereby granted provided that
49+
# use this file is hereby granted provided that
4450
# the above copyright notice and this notice are
45-
# left intact.
46-
#
51+
# left intact.
52+
#
4753
# Please send copies of changes and bug-fixes to:
4854
# sjg@crufty.net
4955
#
@@ -59,6 +65,45 @@ do
5965
esac
6066
done
6167

68+
# get last entry from "$@" without side effects
69+
last_entry() {
70+
while [ $# -gt 8 ]
71+
do
72+
shift 8
73+
done
74+
eval last=\$$#
75+
echo $last
76+
}
77+
78+
# mkdir $dest if needed (more than one file)
79+
mkdir_if_needed() {
80+
(
81+
lf=
82+
while [ $# -gt 8 ]
83+
do
84+
shift 4
85+
done
86+
for f in "$@"
87+
do
88+
[ -f $f ] || continue
89+
[ $f = $dest ] && continue
90+
if [ -n "$lf" ]; then
91+
# dest must be a directory
92+
mkdir -p $dest
93+
break
94+
fi
95+
lf=$f
96+
done
97+
)
98+
}
99+
100+
args="$@"
101+
dest=`last_entry "$@"`
102+
case " $args " in
103+
*" -d "*) ;;
104+
*) [ -e $dest ] || mkdir_if_needed "$@";;
105+
esac
106+
62107
# if .dirdep doesn't exist, just run install and be done
63108
_DIRDEP=${_DIRDEP:-$OBJDIR/.dirdep}
64109
[ -s $_DIRDEP ] && EXEC= || EXEC=exec
@@ -74,18 +119,16 @@ StageDirdep() {
74119
t=$1
75120
if [ -s $t.dirdep ]; then
76121
cmp -s $_DIRDEP $t.dirdep && return
77-
echo "ERROR: $t installed by `cat $t.dirdep` not `cat $_DIRDEP`" >&2
78-
exit 1
122+
case "${STAGE_CONFLICT:-error}" in
123+
[Ee]*) STAGE_CONFLICT=ERROR action=exit;;
124+
*) STAGE_CONFLICT=WARNING action=: ;;
125+
esac
126+
echo "$STAGE_CONFLICT: $t installed by `cat $t.dirdep` not `cat $_DIRDEP`" >&2
127+
$action 1
79128
fi
80129
LnCp $_DIRDEP $t.dirdep || exit 1
81130
}
82131

83-
args="$@"
84-
while [ $# -gt 8 ]
85-
do
86-
shift 8
87-
done
88-
eval dest=\$$#
89132
if [ -f $dest ]; then
90133
# a file, there can be only one .dirdep needed
91134
StageDirdep $dest

0 commit comments

Comments
 (0)