Building a VM image from a NonBSD-Host of a self compiled source

From: Raphael O. <raphael.ob_at_protonmail.com>
Date: Fri, 20 Jan 2023 10:41:35 UTC
Hello! (If this would have been more suitable for the freebsd-arm mailing list, I'm sorry)

I would like to dig into the world of FreeBSD, but unfortunately I'm bound to a Macbook M1 device.
So I will have to use virtual machines for using and working on FreeBSD.

First of all I tried if running the ARM64 port of FreeBSD inside a VM works on M1.
Using this https://gist.github.com/ctsrc/a1f57933a2cde9abc0f07be12889f97f it was only a matter of minute to get it running.

My next step was to build BSD from source, which turned out to be a little challenge but still solvable.
(https://wiki.freebsd.org/BuildingOnNonFreeBSD).

Now I have buildworld and buildkernel in a freebsd/obj but no clue how to actually create a VM image from that.
Is it even possible to create a image which I can just startup in qemu like the one I downloaded in the first gist?

I looked at multiple websites but the only promising ones was this https://adventurist.me/posts/0283

Since I replaced make with ./tools/build/make.py in the build process I tried replacing it here to, where it just said, that bmake isn't capable of doing vm-release/install or whatever.

Afterwards I found this slide (https://papers.freebsd.org/2019/COSCUP/lwhsu-getting-started.files/Getting%20started%20with%20FreeBSD%20development.pdf)
and on side 17 it is stated to use the makefile again and use installworld, distribution installkernel now instead of build*.

I ran` `
`env MAKEOBJDIRPREFIX=/Users/lockna/freebsd/obj time ../tools/build/make.py -j4 installworld TARGET=arm64 TARGET_ARCH=aarch64 DESTDIR=/Users/lockna/freebsd/destdir`
from within the src/release directory.
But essentially I get this error
`bmake[2]: "/Users/lockna/freebsd/src/Makefile.inc1" line 574: warning: "MAKEFLAGS= CPUTYPE=dummy /Users/lockna/freebsd/obj/bmake-install/bin/bmake -f /dev/null -m /Users/lockna/freebsd/src/share/mk MK_AUTO_OBJ=no -V CPUTYPE" exited on a signal bmake[2]: "/Users/lockna/freebsd/src/Makefile.inc1" line 577: CPUTYPE global should be set with ?=.`

I tried setting the CPUTYPE to native, aarch64, arm64 (as env variable) or setting it in the Makefile using `?=.`
When I set it using env variable it changed accordingly in the command output but when setting it in the Makefile which was used it still was dummy.

So I decided to ask here how someone would create a vm image from self compiled sources on a non bsd host.

Thanks in advance [:)]:D