convert HAVE_GCC handling to modern GCC release numbering:
- HAVE_GCC=5 is now the default (vs. HAVE_GCC=53 we've been using for
GCC 5.4 and GCC 5.5.)
- remove some more GCC 4.8 code. we don't support GCC 4 here.
- adjust set lists to gcc=5 from gcc=53.
add some basic HAVE_GCC=6 handling (totally unused so far.)

Disgusting and evil hack to elide coverity options that break production
of coverity output when present [userland portion]
- --sysroot
- -fstack-protector
- -std=gnu99
- --nostdinc
- -fPIE
The critical one here being --sysroot because this means that we need to
use the actual system headers while building (or chroot/sandbox appropriately)

Import NVIDIA Tegra XUSB firmware for Tegra124 and Tegra210. Installation
of this firmware is controlled by the MKTEGRAFIRMWARE option, which
defaults to yes on evbarm and evbarm64 and no everywhere else.

Build PIC libs on MIPS and PPC64. While the normal calling convention is
position-independent, real PIC defaults to Global Dynamic as TLS model,
while non-PIC and PIE code can use more restrictive models like Initial
Exec. This is most visible with the thread_local destructor code now
using TLS in libc as it would be clobbered by any other shared library
with TLS due to static offset assignment by ld.

Remove MKCRYPTO option.
Originally, MKCRYPTO was introduced because the United States
classified cryptography as a munition and restricted its export. The
export controls were substantially relaxed fifteen years ago, and are
essentially irrelevant for software with published source code.
In the intervening time, nobody bothered to remove the option after
its motivation -- the US export restriction -- was eliminated. I'm
not aware of any other operating system that has a similar option; I
expect it is mainly out of apathy for churn that we still have it.
Today, cryptography is an essential part of modern computing -- you
can't use the internet responsibly without cryptography.
The position of the TNF board of directors is that TNF makes no
representation that MKCRYPTO=no satisfies any country's cryptography
regulations.
My personal position is that the availability of cryptography is a
basic human right; that any local laws restricting it to a privileged
few are fundamentally immoral; and that it is wrong for developers to
spend effort crippling cryptography to work around such laws.
As proposed on tech-crypto, tech-security, and tech-userlevel to no
objections:
https://mail-index.netbsd.org/tech-crypto/2017/05/06/msg000719.htmlhttps://mail-index.netbsd.org/tech-security/2017/05/06/msg000928.htmlhttps://mail-index.netbsd.org/tech-userlevel/2017/05/06/msg010547.html
P.S. Reviewing all the uses of MKCRYPTO in src revealed a lot of
*bad* crypto that was conditional on it, e.g. DES in telnet... That
should probably be removed too, but on the grounds that it is bad,
not on the grounds that it is (nominally) crypto.

provide a common softfloat fenv implemenation and use it for softfloat builds.
restore ABI compatibility with previous releases for ieeefp.h on sh3.
add namespace.h protection for all the fenv interfaces.
use MKSOFTFLOAT on sh3 instead of assuming softfloat.
standardize on comparing MKSOFTFLOAT with "no".
remove the arm-specific softfloat fenv code (which also had several bugs).
fix logic errors in the arm hardfloat feraiseexcept() and feupdateenv().

switch alpha to GDB 7.12. it works just as featureful as 7.7/7.10.
'step' and 'stepi' both fail, but 'next' and break points are ok,
so a sufficiently determined user can get somewhere..
someone should try to fix 'step'. it appears to loop forever inside
ld.elf_so for me in an atomic cas function.

Switch alpha and sparc64 back to gcc 4.8 and old binutils for now - too much
fallout from gcc 5.3 and no quick solution, it needs more work.
Binutils 2.26 does not play well with old gcc and causes random fallout
when building pkgs (e.g. /usr/pkg/lib/libgthread-2.0.so.0:
Trying to call undefined weak symbol `__deregister_frame_info' when
build gstremeer0.10)

remove the xfree86 reachover makefiles and the vast majority of
the support in the rest of the source tree.
X11 sets could use some cleaning up perhaps (just deletion, as
we've never really marked the old X11R6 as obsolete for native
xorg using platforms so far either.)

two changes to radeon drm firmware:
- only install it by default on x86, set new MKRADEONFIRMWARE variable
- install in /libdata, so that separate /usr systems work
(this still doesn't solve PR#49811, which possibly could be handled by
having them being a kernel module loaded by /boot.)

Build ZFS by default only for amd64, not i386.
If we build i386 for 486 (i.e. no 64bit atomic ops) and as a substitute
for the modern hardware that the code was designed to run on use solid
workarounds like external/cddl/osnet/lib/libzpool/atomic.c, there's not
much point in anything.

add build framework to choose between xf86-video-ati 6.x (UMS/KMS)
and 7.x (KMS only), and switch x86 to the latest (KMS only) version.
(if someone can make x86 install both radeon_drv.so.[67] and leave
the default symlink to .7, that would be nice. renaming it so that
it's easier to choose via xorg.conf is a little more tricky..)

Use HAVE_LLVM, not MKLLVM, in tests related to the active compiler.
Fixes problems in a build with MKLLVM=yes HAVE_LLVM=no,
where this error interacted with settings in
src/external/gpl3/gcc/lib/libgcc/Makefile.inc to cause
some object files to be omitted from the libgcc_s library.

Add the infrastructure for MODULAR support for Xen kernels. At
the moment, this can only load very simple modules due to missing
symbols. It is being add at this time to make pullups to the
netbsd-7 branch easier. It is not enabled by default in any kernels.

Add MKGROFFHTMLDOC and make it default to no. It seems that sometimes
when generating html groff runs netpbm behind your back. Needless to
say we don't have netpbm in base, so this fails on a clean install; so
for now disable generating html for /usr/share/doc by default.
Workaround for PR 48970.
It seems that all available document preparation toolchains are made
of fail.

Rework /usr/share/doc.
Update the <bsd.doc.mk> infrastructure, and update the docs to match
the new infrastructure.
- Build and install text, ps, pdf, and/or html, not roff sources.
- Don't wire the chapter numbers into the build system, or use them in
the installed pathnames. This didn't matter much when the docs were a
museum, but now that we're theoretically going to start maintaining
them again, we're going to add and remove documents periodically and
having the chapter numbers baked in creates a lot of thrashing for no
purpose.
- Specify the document name explicitly, rather than implicitly in a
path. Use this name (instead of other random strings) as the name
of the installed files.
- Specify the document section, which is the subdirectory of
/usr/share/doc to install into.
- Allow multiple subdocuments. (That is, multiple documents in one
output directory.)
- Enumerate the .png files groff emits along with html so they can be
installed.
- Remove assorted hand-rolled rules for running roff and roff widgetry
and add enough variable settings to make these unnecessary. This
includes support for
- explicit use of soelim
- refer
- tbl
- pic
- eqn
- Forcibly apply at least minimal amounts of sanity to certain
autogenerated roff files.
- Don't exclude USD.doc, SMM.doc, and PSD.doc directories from the
build, as they now actually do stuff.
Note: currently we can't generate pdf. This turns out to be a
nontrivial problem with no immediate solution forthcoming. So for now,
as a workaround, install compressed .ps as the printable form.

Elide broken exists tests for TOOL_CTFCONVERT and TOOL_CTFMERGE.
Either you set MKCTF=yes and they should exist, or you set MKCTF=no
and it doesn't matter. If MKCTF=yes and they don't exist, something
is broken, and this should fail noisily, not silently.

Add MKCTF
This variable separates CTF stuffs from MKDTRACE; we can build DTrace
solely without building and using them. This allows us to use DTrace
even if CTF stuffs have problems (actually they have now).
This variable would be merged into MKDTRACE eventually, once CTF stuffs
work correctly again.

- Add a new bsd.host.mk that contains all the HOST_ variables extracted from
bsd.sys.mk and bsd.own.mk
- Add protection requiring that:
1. bsd.sys.mk is not include from other Makefiles directly
2. bsd.own.mk must be included before bsd.sys.mk since it
sets variables that bsd.sys.mk uses as conditionals.
This is step 1 of removing all variable settings from bsd.sys.mk and
leaving behind only rules. This way, the structure of a standard Makefile
is:
variable overrides
optionally include bsd.own.mk
optionally include bsd.endian.mk
variable settings that use variables defined in bsd.own.mk
include a one or more rule .mk files (such as bsd.prog.mk etc)

add MKDEPCXX, that is used for C++ files depend creation. also
add some missing ${COPTS.${.IMPSRC:T}} and ${CPUFLAGS.${.IMPSRC:T}}
to the dependancy rules.
this makes it possible to have C++ files .d files created with the
C++ compiler, and with the normal options for this file, which
means that we can build libstdc++-v3 from gcc 4.8.

Update LLVM/Clang snapshot to r189662. This includes many improvements
to the new SLP vectorizer, fast codegen support for PPC and using
terminfo for the color sequences. In addition, add (optional) build
infrastructure for lld to allow easier testing. This is controlled by
MKLLD.

rename (new) xorg_drivers to xorg_server -- platforms that build the
actual Xorg server (aka "xfree86 server").
move the list of these platforms from xorg-server/Makefile.common to
bsd.own.mk, so that we can access it easily in distrib.
this should fix most of the current build failures.

Make disklabel a MI tool. It will use MACHINE/MACHINE_ARCH to determine
the disklabel params as well as allowing command-line options of -M <machine>
and -B {le,be} to specify MACHINE and byteorder to be used.

Add the MKKYUA knob.
MKKYUA defaults to no and will remain as such until the import is complete
and validated.
This knob does not currently have any effects on the build as nothing relies
on it yet. Upcoming imports and changes in this area will all be guarded by
this flag.

include <bsd.sys.mk>
This is a mess. HAS_SSP (which should really be HAVE_SSP), is defined
in bsd.sys.mk. So things that need it, include the file directly. The
trouble comes because bsd.sys.mk, needs stuff that bsd.own.mk defines,
so including first does not work. Anyway most other files include bsd.sys.mk
directly, so user Makefiles should just not do that, and just include
<bsd.own.mk> to get all the defines they need.

Make the test for infinite recursion in PRINTOBJDIR more specific,
and make the error case more easily recognisable.
Now "make -V '${PRINTOBJDIR}'" works instead of misinterpreting the "-V"
as infinite recursion.

Add elftosb tools to evbarm userland and toolchain.
Elftosb is used to create a digitaly signed "secure boot" file.
This sb file can be booted by the first stage boot loader found in
Freescale i.MX23 and i.MX28 application processors.
Copyright (c) 2004-2010 Freescale Semiconductor, Inc.

Add _NETBSD_VERSION_DEPENDS in bsd.own.mk. Targets that need
to be re-generated when the NetBSD version numberchanges,
or when any build-related variables change, may depend on
${_NETBSD_VERSION_DEPENDS}.

Import the new apropos/whatis.
This code has been developed by Abhinav Upadhyay as part of Google's Summer
of Code 2011. It uses libmandoc to parse man pages and builds a Full
Text Index in a SQLite database. The combination of indexing the full
manual page, filtering out stop words and ranking individual matches
based on the section gives a much improved user experience.
The old makewhatis and friends are kept under MKMAKEMANDB=no for now.

Add OBJCOPY_ELF2AOUT_FLAGS for some arm ports to create a.out binaries
using objcopy(1) for old firmware, shared among src/distrib and
src/sys/arch/${MACHIHNE}/conf/Makefile.${MACHINE}.inc.
Discussed with mrg@ and matt@ on source-changes-d@.

After making sure USE_PIGZGZIP is defined, add a TOOL_GZIP which will be
gzip or ${TOOL_PIGZ}. Use of gzip can be replaced with ${TOOL_GZIP} and
automatically get to use pigz if USE_PIGZGZIP is defined as "yes". This
avoid having to special case each of gzip.

Add LLVM and clang build system. It is enabled by MKLLVM=yes.
Upstream sources can be fetched by running "make checkout" in
src/external/bsd/llvm, they will be properly imported once the
integration and missing features are sorted out.

Add support for the Extensible MIPS ("eMIPS") platform. The
NetBSD/emips port runs on Xilinx and Beecube FPGA systems and the
Giano system simulator.
eMIPS is a platform developed at Microsoft Research for researching
reconfigurable computing. eMIPS allows dynamic loading and scheduling
of application-specific circuits for the purpose of accelerating
computations based on the current workload.
NetBSD eMIPS support for NetBSD 4.x was written at Microsoft Research
by Alessandro Forin and Neil Pittman. Microsoft Corporation has
donated full copyright to The NetBSD Foundation.
Platform support for eMIPS is the first part of Microsoft's
contribution. The second part includes the hardware accelerator
framework and will be proposed on tech-kern soon.

Add libc glue for libtre.
tre will be compiled without approx and wchar/mulibyte support to
only match the minimum requirement to replace our spencer regex.
This needs a lot of testing.
Only enabled when USE_LIBTRE is set to `yes'.

add new option to build/use tools/pigz for compressing sets. for now
USE_PIGZGZIP defaults to "no". (it depends upon local <pthread.h> and -lz.)
you can set it to "yes" on most modern platforms just fine.

remove almost all the ability to build netbsd with an a.out target.
we're ELF now, and there are many missing checks against OBJECT_FMT.
if we ever consider switching, the we can figure out what new ones
we need but for now it's just clutter.
this doesn't remove any of the support for exec_aout or any actually
required-for-boot a.out support, only the ability to build a netbsd
release in a.out format. ie, most of this code has been dead for
over a decade.
i've tested builds on vax, amd64, i386, mac68k, macppc, sparc, atari,
amiga, shark, cats, dreamcast, landisk, mmeye and x68k. this covers
the 5 MACHINE_ARCH's affected, and all the other arch code touched.
it also includes some actual run-time testing of sparc, i386 and
shark, and i performed binary comparison upon amiga and x68k as well.
some minor details relevant:
- move shlib.[ch] from ld.aout_so into ldconfig proper, and cut them
down to only the parts ldconfig needs
- remove various unused source files
- switch amiga bootblocks to using elf2bb.h instead of aout2bb.h

- note that if MKINET6 is "no", MK11 must also be "no". we don't support
building X11 without inet6 support. the support to maintain patches to
generated files and other files is too great. PR#42856
- add TOOL_PIGZ, which defaults to the (not yet default) built tools/pigz.

- always install pigz. hooary!
- kill MKPIGZ.
- add MKPIGZGZIP. if it is "no", then only install pigz as pigz. if it is
not "no", don't install mrgzip, install pigz as gzip.
in all cases, the z* scripts.
i don't like the name MKPIGZGZIP so if anyone has a better name, feel free
to replace it. i don't care enough since killing the ugly name is just
more incentive to get pigz doing .bz2, .Z and .z.

Install mdocml's default CSS as /usr/share/man/style.css. Switch HTML
man pages to use mandoc unconditional as it gives reasonable output for
all man pages, not only a subset of mdoc(7). Use the newly installed
style.css for formatting and produce hyperlinks for .Xr.

Move the test for evbppc out of sets.subr and into bsd.own.mk, to
decide whether to make kernel modules: set MKKMOD to no for evbppc.
Use this in etc/Makefile to decide whether to do the "modules"
obsolete sets. Move the ./var/db/obsolete/modules entry from the
"mi" to the "module.mi" file set.
Fixes the build for evbppc.
Discussed with uebayasi@

${GENCMD} is used to generate only one output from file generation commands
which potentially have multiple output files, which confuses make(1).
This wrapper copies all involved files into /tmp, execute the command, and
copy the wanted file back to ${.OBJDIR}. If this is expensive, consider to
rewrite the generation command to output files individually.
XXX bsd.own.mk is too bloated.

Add "MKZFS" to either "_MKVARS.yes" or "_MKVARS.no" depending on the
default of this platform. This fixed the build for NetBSD/amd64
and NetBSD/i386.
Yes, this horrible. There should be a better way to handle these
settings in general.

Support "extsrc", externally added programs and libraries. Users can write
their own reach-overs, cross-build, install, and get set files just like base
and X11 / X.org. (These sets are not included as TNF releases.)

Link the xf86-input-ws X.Org input driver to the build and add it to the lists
that also have the wsmouse driver.
xf86-input-ws adds support for touchpanels in X11 that report absolute position
data through wscons(4), e.g. the extended ums(4) driver. xf86-input-ws was
written by Matthieu Herrb for OpenBSD.
Please remember to also update xsrc before the next system build.

Rename MKBFD to MKBINUTILS and support HAVE_BINUTILS for set lists. This
makes {MK,HAVE_}BINUTILS consistent with {MK,HAVE_}{GCC,GDB}.
Allow MKBFD to defines MKBINUTILS as a backwards compatibility hook.
Update the sets lists and add conditionals for lib{bfd,opcodes}.

Use "i486" as GNU_ARCH for i386 so that the toolchain and libraries
can use instructions which were not available on the original i386
(eg cmpxchg). Due to some strangeness in gcc's i386 support this needs
an extra --with-arch=i486 configure argument for gcc to have the desired
effect, see my post "i386 vs i486, some inconsistencies" to tech-toolchain
some weeks ago.
I'm not happy to break compatibility, but since (a) kernel support
for i386 was removed and (b) i387 code was put into libm this is
just another coffin nail.
The gain is besides consistency and more efficient code that intel
atomar intrinsics can now be used by gcc. (which would need runtime
library support otherwise)

In build.sh and bsd.own.mk, if uname -p fails, or prints "unknown", or
prints something that does not look like an identifier, then use uname
-m instead. (Cygwin prints "unknown", and OpenBSD prints a long string
containing several spaces; this code should handle both.)

Merge the haad-dm branch to -current. This branch adds LVM functionality to
the base NetBSD system. It uses Linux LVM2 tools and our BSD licensed
device-mapper driver.
The device-mapper driver can be used to create virtual block devices which
maps virtual blocks to real with target mapping called target. Currently
these targets are available a linear, zero, error and a snapshot (this is
work in progress and doesn't work yet).
The lvm2tools adds lvm and dmsetup binary to based system, where the lvm
tool is used to manage and administer whole LVM and the dmestup is used to
communicate iwith device-mapper kernel driver. With these tools also
a libdevmapper library is instaled to the base system.
Building of tools and driver is currently disable and can be enabled with
MKLVM=yes in mk.conf. I will add sets lists and rc.d script soon.
Oked by agc@ and cube@.

Add support for new MAKEVERBOSE levels 3 and 4. The complete list is now:
0 Minimal output ("quiet")
1 Describe what is occurring
2 Describe what is occurring and echo the actual command
3 Ignore the effect of the "@" prefix in make commands
4 Trace shell commands using the shell's -x flag
The default remains MAKEVERBOSE=2.

- retire MKXORG from public use
- introduce X11FLAVOUR to choose src/x11 vs src/external/mit/xorg
for the X11 to build if MKX11=yes is set. it takes the values
of either Xorg or XFree86.
- default to Xorg on alpha, i386, macppc, shark, sparc and sparc64
- remove MKXORG_WITH_XSRC_XSERVER, unused and never useful

Always define TOOL_* variables in bsd.own.mk, not in bsd.sys.mk.
Previously, they were defined in bsd.own.mk if USETOOLS=yes, but in
bsd.sys.mk if USETOOLS!=yes. This caused makefiles that did this:
.include <bsd.own.mk>
FOO != ${TOOL_BAR} args...
to work in the USETOOLS=yes case but not in the USETOOLS!=yes case.

Set HOST_SH?=/bin/sh unconditionally. Previously, it was conditionally
set to /usr/bin/bash if HOST_CYGWIN was defined, but now build.sh
tries to set HOST_SH appropriately.
Remove the HOST_CYGWIN variable, which was not used for any other purpose.
Document that HOST_SH should be an absolute path.
THis was proposed in tech-toolchain.

In bsd.sys.mk and bsd.own.mk, sort lists of TOOL_* variables.
In bsd.README, document all TOOL_* variables that are set in bsd.sys.mk.
There are several TOOL_* variables that are set in bsd.own.mk, but not
set in bsd.sys.mk and not documented in bsd.README.

Build strfile both as a host tool and as an installed program:
* in games/fortune/strfile/Makefile, build strfile as a
regular program instead of as a host tool;
* add tools/strfile directory to build strfile as a host tool;
* in tools/Makefile, add strfile to SUBDIR list;
* in BSD.*.mk, define TOOL_STRFILE variable;
* in games/fortune/datfiles/Makefile, use TOOL_STRFILE when creating
databases at build time;
* in distrib/sets/lists/games/mi, mention usr/games/strfile.

Add MKSTRIPIDENT to remove the RCS IDs from binary programs and shared
libraries for space-constraint systems. The description is based on the
feedback of hubertf@, the logic on input from lukem@
This obsoletes the removal of LIBC_SCCS and SYSLIBC_SCCS for libc builds.

begin to add support for cross-built Xorg:
- add MKXORG
- default to DRI-on for Xorg
- add paths for 192 Xorg packages that will exist in
xsrc/external/mit/<package>/dist
- add some more X11FLAGS.* variables if MKXORG.
this is somewhat based on the xorg work rtr@ did a couple of years ago.
XXX: seriously need to fix the XORG_RELEASE value, it is still set to
XXX: 6.8.1 from when rtr was working on this.

Rename MKPRIVATELIB to LIBISPRIVATE, to make it clearer that this is
a variable that is used by in-tree Makefiles to control behaviour.
(MKsomevar variables are generally intended to be controlled by the end-user)

Change USE_SKEY default to "no"; we have had USE_PAM=yes as the default
for a long time, and there's no point having custom S/Key support in the
applications given that pam_skey.so is now in /etc/pam.d/*

Make it easier to find various MK* and USE_* variable definitions
by expanding their names in the for loops.
Inspired by a recent commit, which made sense to me based on the
number of times I've had to redo a search without the leading MK|USE_
within this file just to find the default...

Adjust the loop that handles NOMAN and friends so grepping for NOMAN
actually finds it. Also note that it only works if set before
bsd.own.mk is included.
Otherwise, grep NOMAN /usr/share/mk/*.mk comes up empty, and since
naively setting it may not work, one can easily draw wrong
conclusions.

Change the name of the host disklabel to nbdisklabel-${MAKEWRAPPERMACHINE},
where ${MAKEWRAPPERMACHINE} is the suffix XXX on the target's make
wrapper, nbmake-XXX.
Fixes toolchain/30673, "single arch host disklabel isn't enough".

If MAKEOBJDIRPREFIX or MAKEOBJDIR is defined, then we rely on make to
set .OBJDIR so 'make -V .OBJDIR' doesn't need to read any makefiles.
Given how much cud-chewing make does in order to read a line, this
speeds things up significantly (the operation in hand).

If we only want .OBJDIR printed, there is no point parsing the default
make rules, nor reading Makefile.
It is rather a shame we can't stop .depend being parsed as well.
Quite possibly one could argue that nothing in .depend should affect the
output of 'make -V xxxx'.

Mark all the .PHONY targets as .NOTMAIN in one go - instead of individually.
Add .WAITs after beforeinstall and before afterinstall.
Remove the bogus dependency lines that someone must have added with the
vague hope they would cause the build to happen in the right order!
Since we have 'realinstall: proginstall scriptsinstall' stopping
'realinstall' running never has stopped 'proginstall' running.
Fixing this probably fixes a variety of problems, including, but not
restricted to 'install' in src/sys/arch/atari/stand/bootxx
(NB this particular file is untested due to other local changes)

- clean up some comments to reality.
- retire LIBDCK, LIBG2C and (long broken) USE_LIBSTDCXX
- in bsd.hostprog.mk's LIBSTDCPP -> LIBSTDCC
- add LIBSUPCXX
- don't default USE_LIBSTDCXX or USE_GCC4 since they are
not used in the tree any where
- same with USE_XF86_4; retire it
- remove _SUPCXX handling in bsd.prog.mk
inspired by PR#26714.

Now that we have real build system support for syspkgs, remove someone's
half-implemented idea of building `syspkgs' (really a few giant blobs of the
same granularity of the old sets) using install(1).

Add definitions for the new "host tools " disklabel and fdisk.
Define TOOL_DISKLABEL and TOOL_FDISK. Also introduce HOST_INSTALL_DIR
and HOST_INSTALL_SYMLINK. These re-usable definitions help me to
install headers for disklabel and fdisk into ${TOOLDIR}/include/nbinclude/.

Add MKIPFILTER; if set to no, don't build and install the ipf(4) programs,
headers and LKM.
Add MKPF; if set to no, don't build and install the pf(4) programs,
headers, LKM and spamd.
Both options default to yes, so nothing changed in the default build.
Reviewed by lukem.

Don't build libpam and associated bits if the target platform doesn't
support shared libraries (sun2 and evbsh5 at it would seem), or if the
user has specified MKPIC=no. Also introduce a new tag to the set lists
("pam"), so that the non-shlib ports can once again complete a release
build.
Discussed with christos and lukem.

Revert most of previous, and move the LIB<libname>?= assignments
back to bsd.prog.mk from bsd.own.mk.
pkgsrc uses <bsd.own.mk>, and setting LIB<libname> in it causes
problems with various package builds.
This should fix PR #26542 submitted by Jim Bernard.
(I'll be implementing the DPADD for shared libraries in a different
manner that generally won't depend upon ${LIB<libname>}.)

Change STRIPFLAG from "-s" to ""; we now don't strip binaries with install(1).
The benefits of having the symbol table available by default (easier
debugging of core dumps, etc) outweigh the minor (3%) increase in
the size of the distribution, and end-users can always strip(1) their
systems if they're concerned about that 3% of disk space.

And the monkey flicks the switch ...
Enable the in-tree toolchain on sh5, at least for the time being so I
can evaluate the situation.
There are still numerous problems with gcc3's sh5 support, not least
of which is the fact that a native gcc3 doesn't work at all. As a
cross-compiler, it works reasonably well. Certainly enough to build
userland and kernel code.
Binutils also has problems dealing with shared libraries on sh5, so
we're back to static userland for now.

In the various _MKTARGET macros, prepend "${.OBJDIR:T}/" to the ${.TARGET},
to provide more context about the operation. Especially useful for crunched
binaries and kernel builds. Idea suggested by David Laight <dsl@>

Improve how build.sh -N and MAKEVERBOSE interoperate;
rather than adding '-s' to make's command line in the makewrapper,
use the .SILENT target based on MAKEVERBOSE's value.
This means that you can do:
./build.sh -N 1 makewrapper
$TOOLDIR/bin/nbmake-$MACHINE
# runs at MAKEVERBOSE==1, with command lines suppressed
$TOOLDIR/bin/nbmake-$MACHINE MAKEVERBOSE=2
# runs at MAKEVERBOSE==2 for this invocation, with command lines shown

introduce an additional switch to enable building GCC3 instead of GCC2:
HAVE_GCC3. if this is set, we also set USE_TOOLS_TOOLCHAIN=no. change
the definition of the former to be restricted to whether tools/toolchain
is used or not.

Change defined(CXX_SUPCXX) to MKCXXSUPCXX != "no".
Clarify that command-line overrides of the MKxxx variables should be
done via the environment rather than make(1) command-line variable
assignment, since the latter doesn't actually work as intended.

introduce a new $CPPFLAG_ISYSTEMXX that is used to reference c++ system
includes. for GCC3, set this to -I instead of -isystem.
XXX this should really be either not required or a -isystem-cxx, but for
now this is required to build libstdc++-v3, which otherwise complains
heavily about STL headers not being C code(!)

Add MKUNPRIVED; if not no has the same semantics as if UNPRIVED was defined.
Replace defined(UNPRIVED) tests with ${MKUNPRIVED} != "no"
Add MKUPDATE; if not no has the same semantics as if UPDATE was defined.
Replace defined(UPDATE) tests with ${MKUPDATE} != "no"
Improve documentation for these and other make flags.

Add MKMANZ; if not set to "no", compress the manual pages at installation time.
This replaces the previous .if defined (MANZ) behaviour, although the latter
will set MKMANZ=yes for compatibility purposes.
Don't bother with -P-bou in TOOL_ROFF_HTML; it doesn't appear to be
necessary with groff 1.19.
Fix NOHTML implementation to be consistent with other NOxxx / MKxxx
variables, and expose the user-tweakable MKHTML.

Change the default TOOLDIR from
top-of-obj/tools/tools.OS-VERSION-STRING
to
top-of-obj/tooldir.OS-VERSION-STRING
It's more consistent with the build.sh defaults for DESTDIR and
RELEASEDIR, and it's easier on "mr lazy completion fingers".

Provide the MKPICLIB value in bsd.own.mk, rather than bsd.lib.mk. It
is sometimes necessary for non-library Makefiles to determine if _pic
libraries are being built.
Problem pointed out by Havard Eidnes.

Rework METALOG manipulation:
- add '-D ${DESTDIR}' to INSTPRIV, so install(8) removes the leading
${DESTDIR} from the metalogged path
- provide ${METADB.add} variable (for "${CAT} -l >> ${METALOG}"), to make
it easier to replace manual metalog manipulation in the future.
- with manual metalog additions, don't add the leading ${DESTDIR} in the path
- in maketars, use "mtree -C ..." instead of
"mtree -D ... | sed -e 's,\(.*\) \(\..*\),\2 \1,";
Benefits:
- maketars "Parsing METALOG" step speeds up from 29 seconds to 1.2 seconds
on a P3-600.
(This also benefits "make installworld" at the top level.)
- ${DESTDIR}/METALOG is easier to read without the leading "${DESTDIR}"
on all the pathnames, and it's smaller as well.

Only set INSTPRIV?= if "inside" a NetBSD src tree (i.e, ${_SRC_TOP_} != "").
Fixes a problem found by Andrew Brown where programs outside of the NetBSD
src that use the /usr/share/mk framework (such as pkgsrc/pkgtools/digest)
couldn't be installed if /usr/src/etc wasn't present.

Add "-N ${NETBSDSRCDIR}/etc" to ${INSTPRIV}, so that non-host ${INSTALL_*}
rules use that directory to lookup users & groups as opposed to the
host system's passwd(5) and group(5) databases.
This is a change of behaviour which should make the build system more
robust when new users & groups are added to the NetBSD source.
The only users who may be adversely affected are those (small number,
if any) that renumber the uids & gids away from the "standard" NetBSD
ones; in this case said users should maintain local mods to
${NETBSDSRCDIR}/etc/{master.passwd,group} ...

Only use the MKDYNAMICROOT semantics (i.e. -rpath=/lib,/usr/lib and
-dynamic-linker=/libexec/ld.elf_so) if the BINDIR of the program being
built is /bin or /sbin.
The reason we do this is because now all programs *except* those in
/bin and /sbin (i.e. the "special cases") match the default the compiler
uses, which is what is used for things in e.g. xsrc, pkgsrc, and other
random 3rd party programs.
This is done by decoupling where a shlib is installed from how it
is located. Two new variables, SHLIBINSTALLDIR and SHLINKINSTALLDIR,
contain the former information, and key off MKDYNAMICROOT only. SHLIBDIR
and SHLINKDIR contain the latter, and key off MKDYNAMICROOT and BINDIR.
The SHLIBINSTALLDIR, SHLIBDIR, _LIBSODIR, SHLINKINSTALLDIR, and
SHLINKDIR parameters are moved to a new <bsd.shlib.mk>; see bsd.README
for usage details.

Only use the MKDYNAMICROOT semantics (i.e. -rpath=/lib,/usr/lib and
-dynamic-linker=/libexec/ld.elf_so) if the BINDIR of the program being
built is /bin or /sbin.
The reason we do this is because now all programs *except* those in
/bin and /sbin (i.e. the "special cases") match the default the compiler
uses, which is what is used for things in e.g. xsrc, pkgsrc, and other
random 3rd party programs.

Enable MKDYNAMICROOT=yes by default.
This means that:
+ /bin and /sbin (and the few programs in /usr/* which were statically
linked) are now dynamically linked.
+ The shared libraries that are needed by the /bin and /sbin programs
are now installed into /lib (with compatability symlinks from
/usr/lib). These are:
c crypt edit ipsec kvm m m387 termcap termlib util z
+ The shared linker is now in /libexec/ld.elf_so, and
/usr/libexec/ld.elf_so is a symlink to the former.
If you want the prior behaviour of "some applications statically linked,
the rest dynamically linked", set MKDYNAMICROOT=no in your mk.conf(5).
If you have a philosophical objection to dynamic libraries, continue
to set LDSTATIC=-static in your mk.conf(5), and please don't waste any
more time in trying to convince us why dynamic libraries are 3v1l.

* Eliminate the USE_NEW_TOOLCHAIN variable. Instead, split it into
two variables:
TOOLCHAIN_MISSING -- set to "yes" on platforms for which there is
no working in-tree toolchain (hppa, ns32k, sh5, x86_64).
EXTERNAL_TOOLCHAIN -- if defined by the user, points to the root of
an external toolchain (e.g. /usr/local/gnu). This enables the cross-build
framework even for TOOLCHAIN_MISSING platforms.
If TOOLCHAIN_MISSING is set to "yes", MKGDB, MKBFD, and MKGCC are all
unconditionally set to "no", since the bits are not there to build.
If EXTERNAL_TOOLCHAIN is set, MKGCC is unconditionally set to "no",
since the external toolchain's compiler is not in-sync with the
in-tree compiler support components (e.g. libgcc).
* Set MACHINE_CPU much earlier in bsd.own.mk, so that more tests in
that file can use it.

Implement MKDYNAMICROOT, which currently defaults to "no", but will
be changed in the future to "yes".
If MKDYNAMICROOT == "no", there is no change from existing behaviour
of a static /bin and /sbin (and a few programs in elsewhere).
If MKDYNAMICROOT == "yes", the following changes occur:
in <bsd.own.mk>:
SHLIBDIR?= /lib
SHLINKDIR?= /lib
in various Makefiles, the following entry is DISABLED.
LDSTATIC?=-static
This results in all programs (except those "standalone" programs built
in sys/arch/*/stand) are linked dynamically, the shared linker is moved
from /usr/libexec to /lib (with a compat symlink), and the shared
libraries used by /bin and /sbin programs are moved from /usr/lib to
/lib (with compat symlinks).

Some changes to facilitate fixing the toolchain issue on ns32k:
* Don't make OBJECT_FMT dependent on USE_NEW_TOOLCHAIN. All ports
except ns32k are ELF, so set it appropriately. Allow it to be
overridden in the ns32k case.
* If ns32k && USE_NEW_TOOLCHAIN, don't build shared libraries, because
external toolchains don't support them for our a.out.
* If ns32k && OBJECT_FMT == ELF, the GNU platform is "netbsdelf".
* If ns32k && USE_NEW_TOOLCHAIN, don't attempt to build the in-tree
binutils 2.11.2, gdb 5.0, or gcc 2.95.3.
This allows us to do USE_NEW_TOOLCHAIN cross-builds to ns32k using
an external toolchain.

Move the METALOG from ${_SRC_TOP_OBJ_} to ${DESTDIR}.
There were too many synchronisation problems with using the former;
including situations such as a "make clean" performed between two
installs to the same DESTDIR would result in a truncated METALOG and
the resultant sets would be missing stuff such as include files that
don't get reinstalled if they haven't changed, even with !UPDATE.

Implement NETBSDSRCDIR, which is the top level of the NetBSD source tree.
Defaults to the directory determined by the _SRC_TOP_ logic (if != ""),
and the BSDSRCDIR.
NETBSDSRCDIR has been provided for use by the various NetBSD source
Makefiles to find the top of the NetBSD source tree, and isn't
affected by the inheritance properties of _SRC_TOP_, nor does it
have the magic BSDOBJDIR baggage that BSDSRCDIR is stuck with.

Revert part of previous; don't set _SRC_TOP_ to BSDSRCDIR if it can't be
determined, since BSDSRCDIR's default of /usr/src might not exist and the
calculation of _SRC_TOP_OBJ_ would then generate a warning :-(.
_SRC_TOP_ can now == "" if make(1) (or a parent make(1)) was started
outside of the NetBSD source tree.
Now, if _SRC_TOP_ != "", BSDSRCDIR defaults to ${_SRC_TOP_} and
BSDOBJDIR defaults to the objdir of ${BSDSRCDIR}.
Failsafe defaults for BSDSRCDIR (/usr/src) and BSDOBJDIR (/usr/obj)
are provided later in the file.
This should result in a usable BSDSRCDIR default (i.e, _SRC_TOP_ if
running from within the source tree), with safe fallbacks as appropriate
(/usr/src, as always), meaning that BSDSRCDIR should be able to be used
instead of _SRC_TOP_ in the source tree, although I need to carefully
test this. *aaaiiiieeee!!!*. (Now I understand some of Todd's pain :)

Overhaul how _SRC_TOP_ is determined, ensuring that it will be set to
${BSDSRCDIR} if make(1) is running outside of the NetBSD source tree.
This should solve various issues, including building xsrc which uses
${BSDSRCDIR}/distrib/sets/maketars.

Split the notion of building Hesiod, Kerberos, S/key, and YP
infrastructure and using that infrastructure in programs.
* MKHESIOD, MKKERBEROS, MKSKEY, and MKYP control building
of the infratsructure (libraries, support programs, etc.)
* USE_HESIOD, USE_KERBEROS, USE_SKEY, and USE_YP control
building of support for using the corresponding API
in various libraries/programs that can use it.
As discussed on tech-toolchain.

- ensure that check_DESTDIR and check_RELEASEDIR are always available,
even if USETOOLS==no.
- wrap setting of DESTDIR?= with own USETOOLS==yes check.
should fix a problem noted on current-users with USETOOLS=no

Roll in fixes to permit cross-compiling from non-NetBSD hosts. This
round has been tested on Solaris/x86 and Linux hosts.
* Add host tools cap_mkdb, ctags, m4, uudecode.
* Protect __RCSID() and __COPYRIGHT() better.
* Reduce the number of places that need to include "config.h", to keep
sources closer to their "vanilla" versions.
* Add more compat #defines and autoconf-checked functions.

Add more tolerant script-based implementation of mkdep for host tool
compiles. Based loosely on mkdep.old.compiler (so CSRG license copied),
but now uses just one rewrite (awk) process per cpp invocation and
determines the proper way to run cpp and awk via a "configure" script.
Use HOST_MKDEP in bsd.hostlib/hostprog.mk (defaulting to the old override
value of MKDEP), and give it a TOOLDIR equivalent in bsd.own.mk.

x86_64 doesn't use the "new toolchain" but it doesn't really use the
old one either. The "new toolchain" environment is closer to what we
want, however, for using the external toolchain currently required for
x86_64, so set USE_NEW_TOOLCHAIN for x86_64.

* Add user-controlled mk.conf variables
- SHLIBDIR Location to install shared libraries if ${USE_SHLIBDIR}
is "yes". Defaults to "/usr/lib".
- USE_SHLIBDIR If "yes", install shared libraries in ${SHLIBDIR}
instead of ${LIBDIR}. Defaults to "no".
Sets ${_LIBSODIR} to the appropriate value.
This may be set by individual Makefiles as well.
- SHLINKDIR Location of shared linker. Defaults to "/usr/libexec".
If != "/usr/libexec", change the dynamic-linker
encoded in shared programs
* Set USE_SHLIBDIR for libraries used by /bin and /sbin:
libc libcrypt libcrypto libedit libipsec libkvm libm libmi387
libtermcap libutil libz
* If ${_LIBSODIR} != ${LIBDIR}, add symlinks from ${LIBDIR}/${LIB}.so*
to ${_LIBSODIR}/${LIB}.so* for compatibility.
* Always install /sbin/init statically (for now)
The net effect of these changes depends on how the variables are set:
1.) If nothing is set or changed, there is no change from the
current behaviour:
- Static /bin, /sbin, and bits of /usr/*
- Dynamic rest
- Shared linker is /usr/libexec/ld*so
2.) If the following make variables are set:
LDSTATIC=
SHLINKDIR=/lib
SHLIBDIR=/lib
Then the behaviour becomes:
- Dynamic tools
- .so libraries used by /bin and /sbin are installed to /lib,
with symlinks from /usr/lib/lib*so to -> /lib/lib*so
where appropriate
- Shared linker is /lib/ld*so
3.) As per 2.), but add the following variable:
USE_SHLIBDIR=yes
This forces all .so's to be instaleld in /lib (with compat
symlinks), not just those tagged by their Makefiles to be.
Again, compat symlinks are installed