Basic
- Don't try "unprivileged" build from start.
- First do cross-dirs/cross-tools/cross-distrib as root (sudo).
- Then change owner/mode of obj directories. This will make development easier.
- Always use cross build (for development).
- Otherwise you'll overwrite your /usr/include during build.
- Cross build can't make release on OpenBSD, unfortunately (because of gnu/, where Makefile.bsd-wrapper is used). So cross build is only for development.
Common definition
% target=amd64
% topdir=${HOME}/Workspace/openbsd/HEAD
% srcdir=${topdir}/src
% destdir=${topdir}/dest.${target}
% objdir=${topdir}/obj.${target}
% toolsdir=${topdir}/tools.${target}
% cd ${srcdir}
% eval export $( make -f Makefile.cross TARGET=${target} CROSSDIR=${destdir} cross-env )
First build (setup)
- Set TARGET and CROSSDIR.
- TARGET is the target machine (e.g. amd64, i386, octeon, ...).
- CROSSDIR is the destination directory used in cross build.
- Default CROSSDIR written in Makefile.cross is misguiding!
- First build is done as root, then chown/chmod.
% cd ${srcdir}
% sudo make -f Makefile.cross TARGET=${target} CROSSDIR=${destdir} cross-dirs
% sudo make -f Makefile.cross TARGET=${target} CROSSDIR=${destdir} cross-tools
% sudo make -f Makefile.cross TARGET=${target} CROSSDIR=${destdir} cross-distrib
% ln -sf ${destdir}/usr/obj ${objdir}
% ln -sf ${destdir}/usr/${target}-* ${toolsdir}
% sudo chown -R XXX.YYY ${objdir}/*
% sudo chmod -R ZZZ ${objdir}/*
Full rebuild
XXX
Partial update build (development)
- Just `make' works.
- If not, you forget setting environments (see eval $( make ... cross-env ) above).
- Build done as user (no sudo needed).
- Install done as root.
- Note sudo `-E' to preserve cross environments.
% ( cd bin/ls && make )
% ( cd bin/ls && sudo -E make install )
Kernel build
% kconf=GENERIC.MP
% kobjdir=${objdir}/sys/arch/${target}/compile/${kconf}
% config -b ${kobjdir} -s sys sys/arch/${target}/conf/${kconf}
% ( cd ${kobjdir} && make )
NFS root
- XXX Copy files from ${destdir}?
- XXX Why `make release' doesn't work for cross?
- Because foreign builds, called from Makefile.bsd-wrapper, have no idea how to deal with cross build environments.
Note (to self)
- Makefile.cross is confusing.
- cross-gcc is to build cross gcc, while cross-bin is to build bin for target.
- cross-gcc should be renamed to cross-tools-gcc.
- BSDSRCDIR
- make(1) doesn't know BSDSRCDIR environment.
Thank you very much!
Searched a long time for a description. I also asked in the OpenBSD mailing list.
But nobody told me, how to do this.
I would like to try to port OpenBSD on my Digilent Zybo Z7 ARM/FPGA development board.