I have noticed what appears to be a serious hole in NetBSD documentation, so I thought that I would try to fill in as much as I can. Most of this is courtesy of rvp. My notes are incomplete, but they still appear to be the most systematic attempt at a howto on the subject. Please note that the reason my notes are incomplete, is I have run into trouble, so please feel free to contribute to this post to fill in the holes (and of course to my original thread as well), should you feel the urge. The one major caveat to the following notes, is that I have never compiled anything larger than ee (my favorite editor)...
Compiling on NetBSD
Add a separate user just for compiling:
(#) useradd -m -G wsrc -s /bin/sh -c "System Builder" -g =uid bld
Unpack source files:
(#) for f in /home/user/Downloads/*.tgz
do tar -C/ -xpf $f && echo $f.
done
Prepare the work directories:
(#) rm -rf /usr/obj /usr/tools
(#) install -d -m 775 -o root -g wsrc /usr/obj /usr/tools
Login from default user, to “bld” user:
$ su -l bld
Prepare CVS (only once is necessary). Note that "update -A" flag is used for -HEAD sources and omitted for -RELEASE/-STABLE :
$ cat > $HOME/.cvsrc <<\EoF
update -A -dP
rdiff -pu
diff -pu
cvs -q
EoF
Create new kernel configuration file:
$ cd /usr/src
$ cp sys/arch/amd64/conf/GENERIC sys/arch/amd64/conf/MYKERNEL
Edit and change the MYKERNEL configuration file as needed (search for AMDGPU ?}:
$ ee sys/arch/amd64/conf/MYKERNEL
Build tools once, then kernel. Remember to change “-j” (job) flag according to specific computer values. The values below refer to a computer CPU with 2 cores and 2 threads (plus 50 percent):
$ cd /usr/src
$ ./build.sh -j6 -N1 -M /usr/obj -T /usr/tools -U tools
$ ./build.sh -j6 -N1 -M /usr/obj -T /usr/tools -U kernel=MYKERNEL
I have run the following on my Huawei computer without lock up. dmesg reports that there are 11 CPUs and 6 cores:
$ cd /usr/src
$ ./build.sh -j20 -N1 -M /usr/obj -T /usr/tools -U tools
This should logically work as well, without a processor lock up...
$ ./build.sh -j20 -N1 -M /usr/obj -T /usr/tools -U -u kernel=MYKERNEL
Save GENERIC kernel (only once per computer):
(#) mv /netbsd /netbsd.GENERIC
Install new kernel:
(#) install -m 555 /usr/obj/usr/src/sys/arch/amd64/compile/MYKERNEL/netbsd /netbsd.new
Symlink “netbsd” to “netbsd.new” (once)
(#) cd /
(#) ln -sv netbsd.new netbsd
“To go back to the old kernel, simply point the symlink back to netbsd.GENERIC. (Be mindful of this when doing an upgrade.)
To do a clean kernel rebuild, first do rm -rf /usr/obj/*. Leave /usr/tools alone--unless the compiler sources have changed: check the cvs update output for this.” (rvp)