NetBSD-Users archive
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]
Re: kernel source : compile from a ubuntu (gnu/linux) system : possible?
On Wed, 27 May 2020 14:47:44 +0200
mayuresh%kathe.in@localhost <mayuresh%kathe.in@localhost> wrote:
> i've heard about the impressive portability of the netbsd system,
> especially it's kernel. i've also heard that it's possible to
> cross-compile the whole system for a different target 'isa'. so, i
> wondered if it's possible to compile the netbsd kernel (only) source
> from a gnu/linux system like ubuntu. i don't expect to "run" the
> kernel, just to modify the source (primarily working on updating from
> older 'c' to c99 and secondarily to identify and patch code issues
> with security) and compile to test whether everything goes through
> and then submit the patches. all this because netbsd won't support
> all of my hardware and also incapability to use virtualisation.
> thanks.
>
I normally build on Debian. All you need is to download NetBSD sources:
/home/myusername/netbsd_build/src
/home/myusername/netbsd_build/xsrc
Setup mk.conf, i.e. cat /home/myusername/netbsd_build/mk.sparc64.conf
CPUFLAGS+=-mcpu=ultrasparc
MKX11=yes
And just run the script below. NetBSD build.sh will first build
various tools like bmake and cross-compiler and then build your
code. You don't need to be root and can build as a normal user.
#!/bin/sh
# Build NetBSD from sources. Linux needs the following packages:
# apt-get install build-essential zlib1g-dev flex
MACHINE_ARCH=sparc64
MAKECONF=/home/myusername/netbsd_build/mk.$MACHINE_ARCH.conf; export MAKECONF
WORK_DIR=/home/myusername/netbsd_build
JOBS=8
echo "MACHINE_ARCH=$MACHINE_ARCH"
echo "WORK_DIR=$WORK_DIR"
echo "sleeping for 4 seconds..."
for i in 4 3 2 1 0
do
echo -n "$i "
sleep 1
done
echo " "
# Various build targets, uncomment as needed
# Build sets
#cd $WORK_DIR/src && sh ./build.sh -j $JOBS -U -u -m $MACHINE_ARCH \
# -x -X $WORK_DIR/xsrc \
# -O $WORK_DIR/obj.$MACHINE_ARCH -T $WORK_DIR/tools.$MACHINE_ARCH \
# distribution sets 2>&1 | tee $WORK_DIR/log.$MACHINE_ARCH
# Build complete release
#cd $WORK_DIR/src && sh ./build.sh -j $JOBS -U -u -m $MACHINE_ARCH \
# -x -X $WORK_DIR/xsrc \
# -O $WORK_DIR/obj.$MACHINE_ARCH -T $WORK_DIR/tools.$MACHINE_ARCH \
# release 2>&1 | tee $WORK_DIR/log.$MACHINE_ARCH
# Build only kernel (requires tools)
cd $WORK_DIR/src && sh ./build.sh -j $JOBS -U -u -m $MACHINE_ARCH \
-x -X $WORK_DIR/xsrc \
-O $WORK_DIR/obj.$MACHINE_ARCH -T $WORK_DIR/tools.$MACHINE_ARCH \
kernel=GENERIC 2>&1 | tee $WORK_DIR/log.$MACHINE_ARCH
Home |
Main Index |
Thread Index |
Old Index