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 <> 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:


Setup mk.conf, i.e. cat /home/myusername/netbsd_build/mk.sparc64.conf

And just run the script below. NetBSD 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.


# Build NetBSD from sources. Linux needs the following packages:
# apt-get install build-essential zlib1g-dev flex

MAKECONF=/home/myusername/netbsd_build/mk.$MACHINE_ARCH.conf; export MAKECONF

echo "sleeping for 4 seconds..."
for i in 4 3 2 1 0
        echo -n "$i "
        sleep 1
echo " "

# Various build targets, uncomment as needed

# Build sets
#cd $WORK_DIR/src && sh ./ -j $JOBS -U -u -m $MACHINE_ARCH \
#       -x -X $WORK_DIR/xsrc \
#       distribution sets 2>&1 | tee $WORK_DIR/log.$MACHINE_ARCH

# Build complete release
#cd $WORK_DIR/src && sh ./ -j $JOBS -U -u -m $MACHINE_ARCH \
#       -x -X $WORK_DIR/xsrc \
#       release 2>&1 | tee $WORK_DIR/log.$MACHINE_ARCH

# Build only kernel (requires tools)
cd $WORK_DIR/src && sh ./ -j $JOBS -U -u -m $MACHINE_ARCH \
        -x -X $WORK_DIR/xsrc \
        kernel=GENERIC 2>&1 | tee $WORK_DIR/log.$MACHINE_ARCH

Home | Main Index | Thread Index | Old Index