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

118 lines
5.8 KiB
XML

<!-- License: CNCL 1.0 (Could Not Care Less), see LICENSE at the top of the tree. -->
<chapter id="cross">
<title>Cross-Building and the Source Tree</title>
<para>Makronix is built on NetBSD and on other systems. The same tree,
the same packages and the same release come out; the difference is the
toolchain that <command>build.sh</command> builds first. This chapter is
for the person who works on that build, not for the person who installs
the result.</para>
<sect1 id="cross-detect">
<title>What the build detects</title>
<para><filename>tools/userland.sh</filename> looks at
<command>uname -s</command>. On NetBSD it builds natively with the
host's pkgsrc and installs into the host's <filename>/usr/pkg</filename>;
on anything else it cross-builds with the toolchain and the sysroot in
<filename>build/obj</filename>. The packages are the same either way;
<filename>tools/pkgsrc-cross.mk.conf</filename> is the only
configuration that is specific to the cross case, and
<filename>pkgsrc/</filename> is not patched.</para>
<para>The build's paths come from <filename>MAKRONIX_TOP</filename>.
On a development machine that is the repository root; on an installed
system with the source set it is <filename>/usr/src</filename>.</para>
</sect1>
<sect1 id="cross-workarounds">
<title>The cross workarounds, and why they exist</title>
<para>Four settings in <filename>tools/pkgsrc-cross.mk.conf</filename>
were each added after a measured failure. They are documented in
<filename>docs/CROSS.md</filename> in the source set; in short:</para>
<itemizedlist>
<listitem><para><application>fonts/Xft2</application> runs a C++
probe it does not declare. The cross configuration adds
<literal>USE_LANGUAGES+= c c++</literal>, which gives it a real
compiler instead of pkgsrc's fail wrapper.</para></listitem>
<listitem><para><application>fonts/Xft2</application> calls
<function>FT_GlyphSlot_Embolden</function> without the header that
declares it after FreeType moved it. The build adds
<literal>-include freetype/ftsynth.h</literal>. This is a GCC-14
strictness issue, not a cross issue; the native build may need it
too.</para></listitem>
<listitem><para><application>pkgtools/x11-links</application> probes
<filename>/usr</filename> for X headers. In a cross build that is the
host's X, not the target's; the configuration points it at
<filename>${CROSS_DESTDIR}/usr/X11R7</filename>.</para></listitem>
<listitem><para>X's configure passes absolute
<filename>/usr/X11R7/include</filename> and
<filename>/usr/X11R7/lib</filename>, which do not resolve inside the
sysroot. The build adds the sysroot-relative GCC form
<literal>-I=/usr/X11R7/include</literal> and
<literal>-L=/usr/X11R7/lib</literal>.</para></listitem>
</itemizedlist>
<para>Each setting has a removal criterion in
<filename>docs/CROSS.md</filename>: when the package builds without it
in both modes, it goes. A workaround that outlives its cause is a bug
with a comment.</para>
</sect1>
<sect1 id="cross-forks">
<title>Forks and imported trees</title>
<para>What Makronix changes is a fork in <filename>ext/</filename>; what
it does not change is imported and left alone. The NetBSD tree is
<filename>src/</filename> with its base commit in
<filename>src/BASE</filename>; the X tree is <filename>xsrc/</filename>
with <filename>xsrc/BASE</filename>; upstream for reading is
<filename>refs/netbsd</filename> and <filename>refs/linux</filename>.
The import of a fork is one commit of the upstream archive, and every
change after it is a visible diff.</para>
<para>MCDE is the largest fork. Its build for the host is
<command>make mcde-host</command>; its Linux build is
<command>make mcde-linux</command>. The host build is what produces
<command>dtdocbook2infolib</command> and <command>dtinfo</command> for
the documentation and for testing without a target machine; the cross
build for the release is part of <command>make userland</command>.</para>
</sect1>
<sect1 id="cross-rules">
<title>The rules that keep it buildable</title>
<itemizedlist>
<listitem><para>A package that builds only on one host is broken. Fix
the recipe, the configuration in <filename>tools/</filename>, or the
source in <filename>ext/</filename>; do not build it in a virtual
machine.</para></listitem>
<listitem><para><filename>pkgsrc/</filename> and <filename>refs/</filename>
are not edited. A change is a moved pin, recorded in
<filename>PINS</filename>, or a package of our own.</para></listitem>
<listitem><para><filename>tools/</filename> is POSIX shell: no bash,
no Python, no transient units. A tool that only runs on the author's
machine is not a tool.</para></listitem>
<listitem><para>The set list is generated, not written:
<filename>tools/makronix-set.sh</filename> reads the installed tree
back and writes <filename>src/distrib/sets/lists/makronix/mi</filename>.
A file that is installed but not in the list fails
<command>checkflist</command>.</para></listitem>
</itemizedlist>
</sect1>
<sect1 id="cross-platforms">
<title>Other platforms</title>
<para><command>make release ARCH=macppc</command> and the other
architectures use the same tree with a different target. A platform is
supported when its installation has been run to a login prompt; the
measured state is in <filename>docs/PLATFORMS.md</filename>. Cross
building makes the compiler for that platform; it does not test the
firmware, the drivers or the desktop on it. That is what the hardware
is for.</para>
</sect1>
</chapter>