The following now works completely (I think -- still building a
variant), allowing for the keeping tools objects in $TOOLDIR, and
allowing multiple variants to be built using BUILDID while all sharing
the same $TOOLDIR.
Careful invocation is needed of course, and one must also remember to
update the build of the tools on occasion as well. My wrapper script
helps do this, and also creates a shared RELEASEDIR for all variants.
Ideally some of the concepts from my wrapper might be added directly to
build.sh, but I'll not attempt that until these initial changes are
available.
For an example of two different variants (in this case the "inet6"
setting _enables_ MKINET6 in my mk.conf file):
$ diff *-obj/inet6/params *-obj/params
3c3
< BUILDID = 'inet6'
---
> BUILDID = (undefined)
6c6
< DESTDIR = '/Users/woods/build/woods/very.local/trunk-amd64-inet6-destdir'
---
> DESTDIR = '/Users/woods/build/woods/very.local/trunk-amd64-destdir'
23,24c23,24
< MAKEFLAGS = ' -d e -m /Volumes/work/woods/g-NetBSD-src/share/mk -X -j 24 -J 15,16 HOST_OSTYPE=Darwin-25.1.0-x86_64 MKOBJDIRS=yes NOPOSTINSTALL=1 _SRC_TOP_=/Volumes/work/woods/g-NetBSD-src _SRC_TOP_OBJ_=/Users/woods/build/woods/very.local/trunk-Darwin-25.1.0-i386-amd64-obj/inet6 _THISDIR_='
< MAKEOBJDIR = '/Users/woods/build/woods/very.local/trunk-Darwin-25.1.0-i386-amd64-obj/inet6'
---
> MAKEFLAGS = ' -d e -m /Volumes/work/woods/g-NetBSD-src/share/mk -X -j 24 -J 15,16 HOST_OSTYPE=Darwin-25.1.0-x86_64 MKOBJDIRS=yes NOPOSTINSTALL=1 _SRC_TOP_=/Volumes/work/woods/g-NetBSD-src _SRC_TOP_OBJ_=/Users/woods/build/woods/very.local/trunk-Darwin-25.1.0-i386-amd64-obj _THISDIR_='
> MAKEOBJDIR = '/Users/woods/build/woods/very.local/trunk-Darwin-25.1.0-i386-amd64-obj'
125c125
< RELEASEMACHINEDIR = 'amd64.inet6'
---
> RELEASEMACHINEDIR = 'amd64'
--
Greg A. Woods <gwoods%acm.org@localhost>
Kelowna, BC +1 250 762-7675 RoboHack <woods%robohack.ca@localhost>
Planix, Inc. <woods%planix.com@localhost> Avoncote Farms <woods%avoncote.ca@localhost>
diff --git a/build.sh b/build.sh
index c6ef6291fdb1..1467e3c88457 100755
--- a/build.sh
+++ b/build.sh
@@ -1072,6 +1072,9 @@ resolvepath()
local var="$1"
local val
eval val=\"\${${var}}\"
+ # remove any leading (and trailing) whitespace
+ val=${val##*[[:blank:]]}
+ val=${val%%*[[:blank:]]}
case "${val}" in
/)
;;
@@ -1091,7 +1094,7 @@ synopsis()
{
cat <<_usage_
-Usage: ${progname} [-EnoPRrUux] [-a ARCH] [-B BID] [-C EXTRAS]
+Usage: ${progname} [-EnoPRrtUux] [-a ARCH] [-B BID] [-C EXTRAS]
[-c COMPILER] [-D DEST] [-j NJOB] [-M MOBJ] [-m MACH]
[-N NOISY] [-O OOBJ] [-R RELEASE] [-S SEED] [-T TOOLS]
[-V VAR=[VALUE]] [-w WRAPPER] [-X X11SRC]
@@ -1175,7 +1178,7 @@ help()
-h Show this help message, and exit.
-j NJOB Run up to NJOB jobs in parallel; see make(1) -j.
-M MOBJ Set obj root directory to MOBJ; sets MAKEOBJDIRPREFIX=MOBJ,
- unsets MAKEOBJDIR.
+ unsets MAKEOBJDIR. "/BUILDID", if given, is appended.
-m MACH Set MACHINE=MACH. Some MACH values are actually
aliases that set MACHINE/MACHINE_ARCH pairs.
[Default: deduced from the host system if the host
@@ -1202,6 +1205,8 @@ help()
-T TOOLS Set TOOLDIR=TOOLS. If unset, and TOOLDIR is not set
in the environment, ${toolprefix}make will be (re)built
unconditionally.
+ -t Set MKTOOLS=no. A TOOLDIR must be provided, and tools must
+ be pre-built therein. USETOOLS must be set to "yes".
-U Set MKUNPRIVED=yes; build without requiring root privileges,
install from an unprivileged build with proper file
permissions.
@@ -1233,7 +1238,7 @@ usage()
parseoptions()
{
- opts=a:B:C:c:D:Ehj:M:m:N:nO:oPR:rS:T:UuV:w:X:xZ:
+ opts=a:B:C:c:D:Ehj:M:m:N:nO:oPR:rS:T:tUuV:w:X:xZ:
opt_a=false
opt_m=false
local did_show_info=false
@@ -1274,7 +1279,7 @@ parseoptions()
-B)
eval ${optargcmd}
- BUILDID=${OPTARG}
+ setmakeenv BUILDID "${OPTARG}"
;;
-C)
@@ -1363,7 +1368,7 @@ parseoptions()
;;
esac
unsetmakeenv MAKEOBJDIRPREFIX
- setmakeenv MAKEOBJDIR "\${.CURDIR:C,^$TOP,$OPTARG,}"
+ setmakeenv MAKEOBJDIR "\${.CURDIR:C,^${TOP},${OPTARG}${BUILDID:+/${BUILDID}},}"
;;
-o)
@@ -1398,6 +1403,10 @@ parseoptions()
export TOOLDIR
;;
+ -t)
+ setmakeenv MKTOOLS "no"
+ ;;
+
-U)
setmakeenv MKUNPRIVED yes
;;
@@ -1513,9 +1522,9 @@ parseoptions()
disk-image=*)
arg=${op#*=}
- op=disk_image
+ op=disk_image # XXX how/why can this have an '_', or a '-'????
[ -n "${arg}" ] ||
- bomb "Must supply a target name with '${op}=...'"
+ bomb "Must supply a target/kernel name with '${op}=...'"
;;
@@ -1600,8 +1609,16 @@ parseoptions()
# Set up default make(1) environment.
#
+ if [ -n "${BUILDID}" ]; then
+ if [ -n "${MAKEOBJDIRPREFIX}" -a -n "${TOP_objdir}" ]; then
+ # xxx this will dup MAKEOBJDIRPREFIX in $makeenv but
+ # unsetmakeenv doesn't remove var from $makeenv so it
+ # can't help here
+ setmakeenv MAKEOBJDIRPREFIX "${MAKEOBJDIRPREFIX}/${BUILDID}"
+ TOP_objdir="${MAKEOBJDIRPREFIX}/${TOP}"
+ fi
+ fi
makeenv="${makeenv} TOOLDIR MACHINE MACHINE_ARCH MAKEFLAGS"
- [ -z "${BUILDID}" ] || makeenv="${makeenv} BUILDID"
[ -z "${BUILDINFO}" ] || makeenv="${makeenv} BUILDINFO"
MAKEFLAGS="-de -m ${TOP}/share/mk ${MAKEFLAGS}"
MAKEFLAGS="${MAKEFLAGS} MKOBJDIRS=${MKOBJDIRS-yes}"
@@ -2012,7 +2029,7 @@ validatemakeparams()
# could be handled either way, but we choose to handle
# it similarly to MAKEOBJDIRPREFIX.
#
- if [ -n "${TOP_obj}" ]
+ if [ -n "${TOP_objdir}" ]
then
# It must have been set by the "-M" or "-O"
# command line options, so there's no need to
@@ -2020,16 +2037,16 @@ validatemakeparams()
:
elif [ -n "$MAKEOBJDIRPREFIX" ]
then
- TOP_obj="$(getmakevar MAKEOBJDIRPREFIX)${TOP}"
+ TOP_objdir="$(getmakevar MAKEOBJDIRPREFIX)${TOP}"
elif [ -n "$MAKEOBJDIR" ]
then
- TOP_obj="$(getmakevar MAKEOBJDIR)"
+ TOP_objdir="$(getmakevar MAKEOBJDIR)"
fi
- if [ -n "$TOP_obj" ]
+ if [ -n "$TOP_objdir" ]
then
- ${runcmd} mkdir -p "${TOP_obj}" ||
+ ${runcmd} mkdir -p "${TOP_objdir}" ||
bomb "Can't create top level object directory" \
- "${TOP_obj}"
+ "${TOP_objdir}"
else
${runcmd} "${make}" -m "${TOP}/share/mk" obj NOSUBDIR= ||
bomb "Can't create top level object directory" \
@@ -2057,16 +2074,20 @@ validatemakeparams()
newval="$(getmakevar $var)"
if ! $do_expertmode
then
+ # xxx this should be outside the for loop!?!?!?!
: ${_SRC_TOP_OBJ_:=$(getmakevar _SRC_TOP_OBJ_)}
case "$var" in
DESTDIR)
: ${newval:=${_SRC_TOP_OBJ_}/destdir.${MACHINE}}
- makeenv="${makeenv} DESTDIR"
;;
RELEASEDIR)
- : ${newval:=${_SRC_TOP_OBJ_}/releasedir}
- makeenv="${makeenv} RELEASEDIR"
+ if [ -n "${BUILDID}" ]; then
+ : ${newval:=$(echo ${_SRC_TOP_OBJ_} | sed "s|/${BUILDID}||")/releasedir}
+ else
+ : ${newval:=${_SRC_TOP_OBJ_}/releasedir}
+ fi
;;
+ # n.b.: TOOLDIR will have the correct value from getmakevar
esac
fi
if [ -n "$oldval" ] && [ "$oldval" != "$newval" ]
@@ -2076,10 +2097,15 @@ validatemakeparams()
fi
eval ${var}=\"\${newval}\"
eval export ${var}
+ makeenv="${makeenv} ${var}"
statusmsg2 "${var} path:" "${newval}"
+
+ # XXX could/should make these directories now too???
done
- # RELEASEMACHINEDIR is just a subdir name, e.g. "i386".
+ # RELEASEMACHINEDIR is just a subdir name, e.g. "i386", with ".$BUILDID"
+ # appended if BUILDID is set (see <bsd.own.mk>)
+ #
RELEASEMACHINEDIR=$(getmakevar RELEASEMACHINEDIR)
# Check validity of TOOLDIR and DESTDIR.
@@ -2169,7 +2195,7 @@ createmakewrapper()
done
fi
- # Recreate $TOOLDIR.
+ # (Re)create $TOOLDIR.
#
${runcmd} mkdir -p "${TOOLDIR}/bin" ||
bomb "mkdir of '${TOOLDIR}/bin' failed"
@@ -2343,6 +2369,10 @@ diskimage()
kernel="${kerneldir}/netbsd-${ARG}.gz"
[ -f "${kernel}" ] ||
bomb "The kernel ${kernel} must be built first"
+ #
+ # XXX this seems specific only to evbarm, evbmips, evbppc, and riscv; or
+ # at least those are the only architectures that have smp_* targets!
+ #
make_in_dir "${NETBSDSRCDIR}/etc" "smp_${1}"
}
@@ -2825,6 +2855,8 @@ setup_mkrepro()
bomb "Failed to get timestamp for vcs=$vcs in '$d'"
fi
+ # XXX this assumes all of ${dirs} were updated at nearly the same time!!!
+
#echo "latest $d $vcs $t"
if [ "$t" -gt "$MKREPRO_TIMESTAMP" ]
then
@@ -2838,6 +2870,7 @@ setup_mkrepro()
statusmsg2 "MKREPRO_TIMESTAMP" \
"$(repro_date "${MKREPRO_TIMESTAMP}")"
fi
+ # XXX why are these not in $makeenv???
export MKREPRO MKREPRO_TIMESTAMP NETBSD_REVISIONID
}
diff --git a/distrib/common/Makefile.bootcd b/distrib/common/Makefile.bootcd
index 519302c3a415..12b0be5d612b 100644
--- a/distrib/common/Makefile.bootcd
+++ b/distrib/common/Makefile.bootcd
@@ -48,7 +48,7 @@ CDRELEASE?= false
CDSOURCE?= false
CDDEV_POPULATE?=false
.if ${CDRELEASE} == false
-CDROMS_RELEASEDIR?= ${MACHINE}/installation/cdrom
+CDROMS_RELEASEDIR?= ${RELEASEMACHINEDIR}/installation/cdrom
.else
CDROMS_RELEASEDIR?= images
.endif
@@ -123,11 +123,11 @@ CHMOD?= chmod
ECHO?= echo
.if ${CDRELEASE} == false
-CDIMAGE= ${CDBASE}.iso
+CDIMAGE= ${CDBASE}.iso # xxx ${BUILDID:D-${BUILDID}} not needed as in RELEASEMACHINEDIR?
.elif ${CDBASE:M*dvd}
-CDIMAGE= NetBSD-${DISTRIBVER}-${CDBASE:S/dvd$//}-dvd.iso
+CDIMAGE= NetBSD-${DISTRIBVER}-${CDBASE:S/dvd$//}${BUILDID:D-${BUILDID}}-dvd.iso
.else
-CDIMAGE= NetBSD-${DISTRIBVER}-${CDBASE:S/cd$//}.iso
+CDIMAGE= NetBSD-${DISTRIBVER}-${CDBASE:S/cd$//}${BUILDID:D-${BUILDID}}.iso
.endif
WORKSPEC= fs.spec
@@ -200,7 +200,7 @@ PAX_v?= -v
PAX_v?=
.endif
-# Copy $RELEASEDIR/${MACHINE} in the CDROM dir
+# Copy $RELEASEDIR/${MACHINERELEASEDIR} in the CDROM dir
#
# XXX This could be done a lot easier if makefs(8) could
# XXX include more than one directory on the image - HF
diff --git a/distrib/common/bootimage/Makefile.bootimage b/distrib/common/bootimage/Makefile.bootimage
index c95fe0013b8a..8543cee0a6d8 100644
--- a/distrib/common/bootimage/Makefile.bootimage
+++ b/distrib/common/bootimage/Makefile.bootimage
@@ -247,7 +247,10 @@ SWAPDISK_UUID=`${TOOL_GPT} ${GPT_TIMESTAMP} ${WORKMBR} show -i 3 | ${TOOL_AWK} '
#
# definitions to create root fs
#
-SETS_DEFAULT= modules base etc comp games gpufw man misc rescue text
+SETS_DEFAULT= base etc comp games gpufw man misc rescue text
+.if ${MKKMOD} != "no"
+SETS_DEFAULT+= modules
+.endif
.if ${MKATF} != "no"
SETS_DEFAULT+= tests
.endif
diff --git a/distrib/common/bootimage/Makefile.installimage b/distrib/common/bootimage/Makefile.installimage
index a0bed1abf8e7..73c5b3afedfe 100644
--- a/distrib/common/bootimage/Makefile.installimage
+++ b/distrib/common/bootimage/Makefile.installimage
@@ -32,7 +32,11 @@ IMAGEMB= ${INSTIMAGEMB}
SWAPMB= 0 # no swap
KERN_SET?= kern-GENERIC
+.if ${MKKMOD} != "no"
SETS?= gpufw modules base etc
+.else
+SETS?= gpufw base etc
+.endif
FSTAB_IN?= ${NETBSDSRCDIR}/distrib/common/bootimage/fstab.install.in
@@ -54,14 +58,19 @@ IMGDIR_EXCLUDE+= -s ',./installation/installimage.*,,gp'
IMGDIR_EXCLUDE+= ${MD_IMGDIR_EXCLUDE}
.endif
-IMGBASE= ${INSTIMGBASE}
+# figure out the installed name so it can live with others
+.if !empty(BUILDID)
+IMGBASE= ${INSTIMGBASE:C/(-install)/-${BUILDID}\1/}
+.else
+IMGBASE= ${INSTIMGBASE}
+.endif
.include "${NETBSDSRCDIR}/distrib/common/bootimage/Makefile.bootimage"
# INSTIMG_RELEASEDIR specifies where to install ${INSTIMGBASE}.img.gz.
# This should be passed from etc/Makefile or etc/etc.${MACHINE}/Makefile.inc
# but also set default here for manual builds.
-INSTIMG_RELEASEDIR?= ${RELEASEMACHINEDIR}/installation/installimage
+INSTIMG_RELEASEDIR?= ${RELEASEDIR}/images
# should be defined elsewhere?
MKDIR?= mkdir -p
diff --git a/distrib/common/bootimage/Makefile.liveimage b/distrib/common/bootimage/Makefile.liveimage
index 14b8abc9040a..a8a71be05727 100644
--- a/distrib/common/bootimage/Makefile.liveimage
+++ b/distrib/common/bootimage/Makefile.liveimage
@@ -30,14 +30,19 @@ check_LIVEIMGBASE: .PHONY .NOTMAIN
IMAGEMB= ${LIVEIMAGEMB}
.endif
+# figure out the installed name so it can live with others
+.if !empty(BUILDID)
+IMGBASE= ${LIVEIMGBASE:C/(-install)/-${BUILDID}\1/}
+.else
IMGBASE= ${LIVEIMGBASE}
+.endif
.include "${NETBSDSRCDIR}/distrib/common/bootimage/Makefile.bootimage"
# LIVEIMG_RELEASEDIR specifies where to install ${LIVEIMGBASE}.img.gz.
# This should be passed from etc/Makefile or etc/etc.${MACHINE}/Makefile.inc
# but also set default here for manual builds.
-LIVEIMG_RELEASEDIR?= ${RELEASEMACHINEDIR}/installation/liveimage
+LIVEIMG_RELEASEDIR?= ${RELEASEDIR}/images
# should be defined elsewhere?
MKDIR?= mkdir -p
diff --git a/doc/BUILDING.mdoc b/doc/BUILDING.mdoc
index c422ea9d081a..ef45ba7f17ba 100644
--- a/doc/BUILDING.mdoc
+++ b/doc/BUILDING.mdoc
@@ -1304,6 +1304,14 @@ or
.Fl u
options (respectively) are given.
.
+.It Sy libs
+Build and install include files and libraries.
+This command will run
+.Dq make do-distrib-dirs ,
+.Dq make includes ,
+and then
+.Dq make do-lib .
+.
.It Sy install Ns = Ns Ar idir
Install the contents of
.Sy DESTDIR
@@ -1483,6 +1491,11 @@ This will also append the build identifier to the name of the
.Sy \*[toolprefix]make- Ns Sy MACHINE
wrapper script so that the resulting name is of the form
.Dq Sy \*[toolprefix]make- Ns Sy MACHINE Ns Sy -BUILDID .
+The build ID will also be appended to the internal
+.Sy RELEASEMACHINEDIR
+subdirectory name, as well as to the object directory name(s) (which is
+done by
+.In bsd.obj.mk ) .
.
.It Fl C Ar cdextras
Append
@@ -1590,6 +1603,18 @@ will place build-time files under
.Pa /usr/obj/usr/src/usr.bin ,
and so forth.
.Pp
+This might be useful if you want one shared main products directory but you
+build from multiple different source trees.
+However since it also, by default, places
+.Sy RELEASEDIR
+and
+.Sy TOOLDIR
+under
+.Pa /usr/obj/usr/src
+it can be cumbersome to deal with, so see
+.Fl O
+instead!
+.Pp
If a relative path is specified, it will be converted to an
absolute path before being used.
.Sy build.sh
diff --git a/etc/Makefile b/etc/Makefile
index 7cacec34e6a7..463b1284b05d 100644
--- a/etc/Makefile
+++ b/etc/Makefile
@@ -432,7 +432,7 @@ release snapshot: .PHONY .MAKE check_DESTDIR check_RELEASEDIR snap_md_post
# Note: At least mkisofs 2.0 should be used.
#
CDROM_NAME_ADD?=
-CDROM_IMAGE?=${RELEASEDIR}/images/NetBSD-${DISTRIBVER}-${MACHINE}.iso
+CDROM_IMAGE?=${RELEASEDIR}/images/NetBSD-${DISTRIBVER}-${MACHINE}${BUILDID:D-${BUILDID}}.iso
CDROM.dir= ${.OBJDIR}/cdrom.dir
CDROM.pathlist= ${.OBJDIR}/cdrom.pathlist
Attachment:
pgpMuiE7C4Ljl.pgp
Description: OpenPGP Digital Signature