Files
lotherk ec3c1b496d guide: the source tree is /usr/src, not /usr/msrc and /usr/xsrc
The source set is one tree since 2026-11-15 (tasksd t0071):
/usr/src/src, /usr/src/xsrc, /usr/src/pkgsrc, with the tools and the
documentation at the top.  The chapters still sent the reader to /usr/msrc
and /usr/xsrc (building, tour, cross, help, updating, dtinfo and the
glossary's "msrc" entry); they now name /usr/src and its subdirectories.

Rebuilt with docs/guide/build.sh all, check and install: 27 manual pages,
61 PDF pages (build/logs/guide-2026-11-16.log).  A grep for usr/msrc and
usr/xsrc over src/share/doc/makronix, src/share/man/man7 and www/guide.html
finds nothing.
2026-11-16 07:22:42 +00:00

148 lines
6.7 KiB
XML

<!-- License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree. -->
<chapter id="building">
<title>Building Makronix</title>
<para>Makronix builds itself from its own sources. The installation
medium can carry those sources, so a machine can be rebuilt without a
network; a development machine does the same with more room and more
patience. This chapter is the map: the source layout, the one entry point,
and what each target produces.</para>
<sect1 id="building-layout">
<title>The source tree</title>
<variablelist>
<varlistentry>
<term><filename>src/</filename></term>
<listitem><para>Makronix's NetBSD tree: the kernel, the userland, the
build system and the installer. It is edited directly; there is no
patch layer between it and the system. Upstream NetBSD is in
<filename>refs/netbsd/src</filename>, for reading.</para></listitem>
</varlistentry>
<varlistentry>
<term><filename>xsrc/</filename></term>
<listitem><para>The X tree, imported the same way. X is part of the
base system: the server, the drivers, the fonts and the clients are
built into the X sets.</para></listitem>
</varlistentry>
<varlistentry>
<term><filename>pkgsrc/</filename></term>
<listitem><para>The pkgsrc checkout, pinned. It is not edited; a
change is a moved pin or a package in <filename>ext/</filename> or
the local <filename>wip</filename>.</para></listitem>
</varlistentry>
<varlistentry>
<term><filename>ext/</filename></term>
<listitem><para>The third-party trees Makronix ships and changes:
MCDE, its Motif build, afpfs-ng and glibc. Each has its own recipe
and its own <filename>IMPORT</filename> note.</para></listitem>
</varlistentry>
<varlistentry>
<term><filename>tools/</filename></term>
<listitem><para>Makronix's own POSIX shell tools: the build stamp,
the package list reader, the set generator, the test harnesses and
the MCDE helpers.</para></listitem>
</varlistentry>
<varlistentry>
<term><filename>docs/</filename> and <filename>www/</filename></term>
<listitem><para>The contracts and the guide, and the web site. The
guide's source is <filename>docs/guide/book.xml</filename>.</para></listitem>
</varlistentry>
</variablelist>
</sect1>
<sect1 id="building-entry">
<title>One entry point</title>
<para>Everything is built from the top-level <filename>Makefile</filename>.
The interface is deliberately small:</para>
<screen>$ make # the distribution (no medium)
$ make release ARCH=amd64 # through to a finished release
$ make iso # the installation CD/DVD image
$ make usb # the bootable USB image
$ make userland # the pkgsrc packages and the makronix set
$ make sourcesets # the source sets for the medium
$ make test # the tool tests, then the installation tests
$ make install # install over a running Makronix</screen>
<para><command>make release</command> builds the sets and the kernels;
<command>make iso</command> packages what the release built; it refuses
to run if a source changed since, because the medium would not match its
sets. <command>make usb</command> needs the source sets under
<filename>source/sets</filename>; <command>make sourcesets</command>
writes them.</para>
<para><command>ARCH</command> is the name a person types: amd64, i386,
macppc, evbarm. On a NetBSD host without <command>ARCH</command>, the
host decides; on a cross host it is amd64 unless named. <command>JOBS</command>
sets the parallelism.</para>
</sect1>
<sect1 id="building-cross">
<title>Cross and native are one build</title>
<para>The build detects whether the host is NetBSD or not. A NetBSD
host builds natively with its own toolchain; a Linux or another host
cross-builds the same tree with the toolchain that
<command>build.sh</command> builds first. A package that builds only on
one of the two is a defect in the recipe, not a reason to use a virtual
machine.</para>
<para>The pkgsrc packages are built for the target with the same
toolchain; <filename>tools/pkgsrc-cross.mk.conf</filename> is the whole
configuration, and <filename>pkgsrc/</filename> itself is not patched.
The workarounds in that file are measured; <xref linkend="cross"/>
explains them and when they can go.</para>
</sect1>
<sect1 id="building-output">
<title>Where the results land</title>
<para>The build writes to <filename>build/obj</filename>: the object
tree, <filename>destdir.</filename><replaceable>arch</replaceable> and
the release directory <filename>releasedir</filename>. The logs are in
<filename>build/logs</filename>. A medium is in
<filename>releasedir/images</filename>; the sets are in
<filename>releasedir/</filename><replaceable>arch</replaceable><filename>/binary/sets</filename>.</para>
<para>The gate is <command>checkflist</command>, run the way NetBSD runs
it: the set lists and what the build actually installed must agree.
Extra or missing files fail the build. A build is done when
<command>checkflist</command> reports neither.</para>
</sect1>
<sect1 id="building-device">
<title>Building on the installed system</title>
<para>The source set installs the whole tree to
<filename>/usr/src</filename> — the
<application>NetBSD</application> sources under
<filename>/usr/src/src</filename>, X under
<filename>/usr/src/xsrc</filename>, pkgsrc under
<filename>/usr/src/pkgsrc</filename>. Build from
<filename>/usr/src</filename> as a user in the wsrc group:</para>
<screen>$ cd /usr/src
$ export MAKRONIX_TOP=/usr/src
$ make release ARCH=amd64</screen>
<para>A full self-build needs room for the object tree and the
distfiles and takes hours on a laptop; the first build is the slow one.
The source set is not the development history: it carries the files a
rebuild needs, and <filename>PINS</filename> names the revisions they
came from.</para>
</sect1>
<sect1 id="building-tests">
<title>Tests</title>
<para><command>make test</command> runs the tests of the tools first,
then the installation tests: a machine is installed from the medium in
QEMU and must reach a login prompt and shut down cleanly. The MCDE
tests run before the release tests, from a native build of the host.
A test that has never failed has not been tested; the harnesses are in
<filename>tools/</filename> and each can be run alone.</para>
</sect1>
</chapter>