Files
src/mk/install-mk
T
Simon J. Gerraty fe271bdb43 Import bmake-20260313
Intersting/relevant changes since bmake-20251111

ChangeLog since bmake-20251111

2026-03-12  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20260313
	Merge with NetBSD make, pick up
	o make: ensure .MAKE.SAVE_DOLLARS is initialized so makefiles like
	sys.vars.mk can test its value to know how to deal with macros
	that need to save '$' during ':='.

	* Makefile: default MAKE_SAVE_DOLLARS_DEFAULT to "no"
	for traditional behavior.

2026-03-10  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20260310
	Merge with NetBSD make, pick up
	o unit-tests ensure TEST_MAKE is absolute path
	and tests that make symlink for ${MAKE} can run in parallel.

2026-03-03  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20260303
	Merge with NetBSD make, pick up
	o job.c: MaybeSubMake: Look for expansion of ${.MAKE}
	and if necessary its basename, and only match if at start of line
	or preceded by space.

2026-02-28  Simon J Gerraty  <sjg@beast.crufty.net>

	* Makefile: mark ${PROG} and ${OBJS} as .META
	MaybeSubMake will otherwise mistake them for sub-makes

	* VERSION (_MAKE_VERSION): 20260301
	Merge with NetBSD make, pick up
	o job.c: MaybeSubMake: skip control chars [@+-] at start of line
	when checking for ${MAKE}

2026-02-22  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20260222
	o mk file update

2026-02-16  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20260216
	Merge with NetBSD make, pick up
	o minor cleanups

2026-02-10  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20260210
	Merge with NetBSD make, pick up
	o document that multiple variables can be set on command line.
	o move MaybeSubMake to job.c so it can be called on expanded
	commands for more accuracy and less overhead.
	o main.c: set .MAKE.VERSION as read-only.

	* unit-tests/opt-{chdir,where-am-i}.mk: use MAKEOBJDIRPREFIX=/
	to avoid tripping over an unreadable /usr/obj

2026-02-04  Simon J Gerraty  <sjg@beast.crufty.net>

	* unit-tests/varname-make_stack_trace.mk: for
	FreeBSD and similar set .MAKE.ALWAYS_PASS_JOB_QUEUE=no
	to ensure we get the expected errors.

	* VERSION (_MAKE_VERSION): 20260202
	Merge with NetBSD make, pick up
	o on error avoid duplicate stack trace to stderr

2026-01-11  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20260111
	Merge with NetBSD make, pick up
	o var.c: add explicit check for empty re as not all
	regex libs throw an error as expected, in this case.

2026-01-10  Simon J Gerraty  <sjg@beast.crufty.net>

	* VERSION (_MAKE_VERSION): 20260110
	Merge with NetBSD make, pick up
	o minor cleanups

mk/ChangeLog since bmake-20251111

2026-03-12  Simon J Gerraty  <sjg@beast.crufty.net>

	* install-mk (MK_VERSION): 20260313

	* sys.vars.mk: use .MAKE.VERSION
	M_type can simply use '$x'

2026-02-22  Simon J Gerraty  <sjg@beast.crufty.net>

	* install-mk (MK_VERSION): 20260222

	* dirdeps.mk, sys.mk: add dependent option
	UPDATE_DIRDEPS_CACHE/DIRDEPS_CACHE.
	It can be useful to use -DWITHOUT_UPDATE_DIRDEPS_CACHE to
	temporarily treat dynamic DIRDEPS_CACHE as static.

2026-01-10  Simon J Gerraty  <sjg@beast.crufty.net>

	* meta.autodep.mk (${_DEPENDFILE}): add .NOMETA

2026-01-08  Simon J Gerraty  <sjg@beast.crufty.net>

	* rust.mk: better accommodation for RUST_LIBS.
	Set RUST_{LIBS,PROGS}_CARGO_BUILD_OUTPUT_LIST to
	simplify staging.

2025-12-08  Simon J Gerraty  <sjg@beast.crufty.net>

	* install-mk (MK_VERSION): 20251207

	* sys.vars.mk: replace MAKE_POSIX_SHELL usage with isPOSIX_SHELL
	Using ${isPOSIX_SHELL:U:Nfalse} provides a boolean for make
	and ${isPOSIX_SHELL:Ufalse} does the same for target scripts.
	Both will be false if isPOSIX_SHELL is not set or set to false.

	This has the advantage that if only POSIX shells are expected
	sys.mk (or something it includes) can simply do isPOSIX_SHELL?=:
2026-04-06 11:25:05 -07:00

194 lines
4.0 KiB
Plaintext

:
# NAME:
# install-mk - install mk files
#
# SYNOPSIS:
# install-mk [options] [var=val] [dest]
#
# DESCRIPTION:
# This tool installs mk files in a semi-intelligent manner into
# "dest".
#
# Options:
#
# -n just say what we want to do, but don't touch anything.
#
# -f use -f when copying sys,mk.
#
# -v be verbose
#
# -q be quiet
#
# -m "mode"
# Use "mode" for installed files (444).
#
# -o "owner"
# Use "owner" for installed files.
#
# -g "group"
# Use "group" for installed files.
#
# -U "umask"
# Use "umask" so directories are created with suitable
# mode (default is 022).
#
# var=val
# Set "var" to "val". See below.
#
# All our *.mk files are copied to "dest" with appropriate
# ownership and permissions.
#
# By default if a sys.mk can be found in a standard location
# (that bmake will find) then no sys.mk will be put in "dest".
#
# SKIP_SYS_MK:
# If set, we will avoid installing our 'sys.mk'
# This is probably a bad idea.
#
# SKIP_BSD_MK:
# If set, we will skip making bsd.*.mk links to *.mk
#
# sys.mk:
#
# By default (and provided we are not installing to the system
# mk dir - '/usr/share/mk') we install our own 'sys.mk' which
# includes a sys specific file, or a generic one.
#
#
# AUTHOR:
# Simon J. Gerraty <sjg@crufty.net>
# RCSid:
# $Id: install-mk,v 1.274 2026/03/13 05:13:00 sjg Exp $
#
# @(#) Copyright (c) 1994-2025 Simon J. Gerraty
#
# SPDX-License-Identifier: BSD-2-Clause
#
# Please send copies of changes and bug-fixes to:
# sjg@crufty.net
#
MK_VERSION=20260313
OWNER=
GROUP=
MODE=444
BINMODE=555
ECHO=:
SKIP=
cp_f=-f
umask 022
while :
do
case "$1" in
*=*) eval "$1"; shift;;
+f) cp_f=; shift;;
-f) cp_f=-f; shift;;
-m) MODE=$2; shift 2;;
-o) OWNER=$2; shift 2;;
-g) GROUP=$2; shift 2;;
-v) ECHO=echo; shift;;
-q) ECHO=:; shift;;
-n) ECHO=echo SKIP=:; shift;;
-U) umask $2; shift;;
--) shift; break;;
*) break;;
esac
done
case $# in
0) echo "$0 [options] <destination> [<os>]"
echo "eg."
echo "$0 -o bin -g bin -m 444 /usr/local/share/mk"
exit 1
;;
esac
dest=$1
os=${2:-`uname`}
osrel=${3:-`uname -r`}
Do() {
$ECHO "$@"
$SKIP "$@"
}
Error() {
echo "ERROR: $@" >&2
exit 1
}
Warning() {
echo "WARNING: $@" >&2
}
[ "$FORCE_SYS_MK" ] && Warning "ignoring: FORCE_{BSD,SYS}_MK (no longer supported)"
SYS_MK_DIR=${SYS_MK_DIR:-/usr/share/mk}
SYS_MK=${SYS_MK:-$SYS_MK_DIR/sys.mk}
realpath() {
[ -d $1 ] && cd $1 && 'pwd' && return
echo $1
}
# some Linux systems have deprecated egrep in favor of grep -E
case "`echo bmake | egrep 'a' 2>&1`" in
*"grep -E"*) egrep='grep -E';;
*) egrep=egrep;;
esac
if [ -s $SYS_MK -a -d $dest ]; then
# if this is a BSD system we don't want to touch $SYS_MK
dest=`realpath $dest`
sys_mk_dir=`realpath $SYS_MK_DIR`
if [ $dest = $sys_mk_dir ]; then
case "$os" in
*BSD*) SKIP_SYS_MK=:
SKIP_BSD_MK=:
;;
*) # could be fake?
if [ ! -d $dest/sys -a ! -s $dest/Generic.sys.mk ]; then
SKIP_SYS_MK=: # play safe
SKIP_BSD_MK=:
fi
;;
esac
fi
fi
[ -d $dest/sys ] || Do mkdir -p $dest/sys
[ -d $dest/sys ] || Do mkdir $dest/sys || exit 1
[ -z "$SKIP" ] && dest=`realpath $dest`
cd `dirname $0`
mksrc=`'pwd'`
if [ $mksrc = $dest ]; then
SKIP_MKFILES=:
else
# we do not install the examples
mk_files=`grep '^[a-z].*\.mk' FILES | $egrep -v '(examples/|^sys\.mk|sys/)'`
mk_scripts=`$egrep '^[a-z].*[.-](sh|py)' FILES | $egrep -v '/'`
sys_mk_files=`grep 'sys/.*\.mk' FILES`
SKIP_MKFILES=
[ -z "$SKIP_SYS_MK" ] && mk_files="sys.mk $mk_files"
fi
$SKIP_MKFILES Do cp $cp_f $mk_files $dest
$SKIP_MKFILES Do cp $cp_f $sys_mk_files $dest/sys
$SKIP_MKFILES Do cp $cp_f $mk_scripts $dest
$SKIP cd $dest
$SKIP_MKFILES Do chmod $MODE $mk_files $sys_mk_files
$SKIP_MKFILES Do chmod $BINMODE $mk_scripts
[ "$GROUP" ] && $SKIP_MKFILES Do chgrp $GROUP $mk_files $sys_mk_files
[ "$OWNER" ] && $SKIP_MKFILES Do chown $OWNER $mk_files $sys_mk_files
# if this is a BSD system the bsd.*.mk should exist and be used.
if [ -z "$SKIP_BSD_MK" ]; then
for f in dep doc files inc init lib links man nls obj own prog subdir
do
b=bsd.$f.mk
[ -s $b ] || Do ln -s $f.mk $b
done
fi
exit 0