--- /dev/null
+# -*- GNUMakefile -*-
+# Requirements:
+# /bin/bash as SHELL
+
+export SHELL = /bin/bash
+
+ifndef PARALLEL
+ifndef NOPARALLEL
+PARALLEL := -j$(shell echo $$((`nproc` + 2)))
+endif
+endif
+
+KERNEL_TREE ?= ${CURDIR}/linux
+SYSROOT ?= ${CURDIR}/initramfs
+
+${SYSROOT}:
+ mkdir -p $@
+
+${SYSROOT}/.mount-stamp: | ${SYSROOT}
+ touch $@
+
+${SYSROOT_x86_64}:
+ mkdir -p $@
+
+${SYSROOT_x86_64}/.mount-stamp: | ${SYSROOT_x86_64}
+ touch $@
+
+.PHONY: world
+
+all: world
+
+world: \
+ .build-linux \
+ .initramfs \
+ build-image/initramfs.cpio.xz \
+ .guse
+
+# --- qemu
+
+build-qemu:
+ mkdir -p $@
+
+build-qemu/Makefile: | build-qemu
+ (cd build-qemu && \
+ PKG_CONFIG_PATH="${CURDIR}/tmp/lib64/pkgconfig/" \
+ ../qemu/configure \
+ --target-list="x86_64-softmmu,arm-softmmu" \
+ --disable-rdma \
+ --enable-fuse \
+ --enable-debug \
+ --cc=clang --cxx=clang++ \
+ $(TSAN) \
+ $(CFLAGS))
+
+build-qemu/qemu-system-arm build-qemu/qemu-system-x86_64 build-qemu/qemu-bridge-helper&: qemu | build-qemu/Makefile
+ make -C build-qemu ${PARALLEL} -s
+
+build-qemu/qemu-bundle/usr/local/etc/qemu:
+ mkdir -p $@
+
+build-qemu/qemu-bundle/usr/local/etc/qemu/bridge.conf: etc/qemu/bridge.conf build-qemu/qemu-bundle/usr/local/etc/qemu
+ cp etc/qemu/bridge.conf $@
+
+.bridge-helper: build-qemu/qemu-bridge-helper build-qemu/qemu-bundle/usr/local/etc/qemu/bridge.conf
+ sudo setcap cap_net_admin+ep build-qemu/qemu-bridge-helper
+
+.PHONY: .build-qemu .bridge-helper
+
+.build-qemu: build-qemu/qemu-system-arm
+
+.build-qemu-asan: CFLAGS += --extra-cflags="-fsanitize=address -fsanitize=leak"
+.build-qemu-asan: .build-qemu
+
+.build-qemu-tsan: CFLAGS += --extra-cflags="-fsanitize-blacklist=${CURDIR}/qemu/tests/tsan/blacklist.tsan"
+.build-qemu-tsan: TSAN += --enable-tsan
+.build-qemu-tsan: .build-qemu
+
+clean::
+ -make -C build-qemu clean
+
+distclean::
+ -rm -rf build-qemu
+
+
+# --- kernel
+
+build-linux/arch/x86/configs:
+ mkdir -p $@
+
+build-linux/arch/x86/configs/linux-qemu_x86_64_defconfig: configs/linux-qemu_x86_64_defconfig | build-linux/arch/x86/configs
+ cp $< $@
+
+build-linux/.config: build-linux/arch/x86/configs/linux-qemu_x86_64_defconfig
+ make -C ${KERNEL_TREE} O=${CURDIR}/build-linux linux-qemu_x86_64_defconfig -s
+
+build-linux/defconfig: build-linux/.config
+ make -C build-linux savedefconfig
+
+build-linux/arch/x86_64/boot/bzImage: linux build-linux/.config
+ make ${PARALLEL} -C build-linux V=1 -s
+ make -C build-linux scripts_gdb
+
+${SYSROOT}/lib/modules: build-linux/arch/x86_64/boot/bzImage linux build-linux
+ make ${PARALLEL} -s -C build-linux INSTALL_MOD_PATH=${SYSROOT} INSTALL_MOD_STRIP=1 modules_install
+
+${CURDIR}/overlay/qemu/merged/lib/modules:: build-linux/arch/x86_64/boot/bzImage linux build-linux
+ make ${PARALLEL} -s -C build-linux INSTALL_MOD_PATH=${CURDIR}/overlay/qemu/merged/ modules_install
+
+.PHONY: .build-linux .install-modules
+
+.build-linux: build-linux/arch/x86_64/boot/bzImage
+
+.install-modules:: ${SYSROOT}/lib/modules ${CURDIR}/overlay/qemu/merged/lib/modules
+
+distclean::
+ -rm -rf build-linux
+
+# --- guse
+
+guse/guse.ko: build-linux/arch/x86_64/boot/bzImage
+ make -C guse KDIR=${CURDIR}/build-linux
+
+# ${CURDIR}/lib/modules/6.14.0-rc3+/updates/guse.ko
+
+.PHONY: .install-guse
+
+.install-guse: guse/guse.ko
+ make -C guse KDIR=${CURDIR}/build-linux INSTALL_MOD_PATH=${SYSROOT} modules_install
+ make -C guse KDIR=${CURDIR}/build-linux INSTALL_MOD_PATH=${CURDIR}/overlay/qemu/merged/ modules_install
+
+.install-modules:: .install-guse
+
+# --- libfuse
+
+libfuse/build:
+ mkdir -p libfuse/build
+
+libfuse/build/build.ninja: libfuse/build
+ (cd libfuse/build \
+ && meson setup .. \
+ && meson configure --prefix=${CURDIR}/tmp -Ddefault_library=static)
+
+libfuse/build/example/guse: libfuse | libfuse/build/build.ninja
+ (cd libfuse/build && ninja)
+
+${CURDIR}/overlay/qemu/merged/root/guse: libfuse/build/example/guse
+ cp $< $@
+
+.install-example: ${CURDIR}/overlay/qemu/merged/root/guse
+
+# --- buildroot aspeed
+
+.PHONY: .build-buildroot-aspeed
+
+buildroot_aspeed: | buildroot
+ mkdir -p $@
+
+buildroot_aspeed/.config: configs/aspeed/buildroot_defconfig | buildroot
+ make -C buildroot O=../buildroot_aspeed aspeed_ast2600evb_defconfig
+
+buildroot_aspeed/images/rootfs.tar: buildroot buildroot_aspeed/.config
+ make -C buildroot_aspeed ${PARALLEL} -s
+
+.build-buildroot-aspeed: buildroot_aspeed/images/rootfs.tar
+
+clean::
+ -rm -rf buildroot_aspeed/images/rootfs.tar
+
+# --- buildroot x86_64
+
+.PHONY: .build-buildroot-x86-64
+
+buildroot/configs/x86_64_guse_defconfig: configs/x86_64/buildroot_defconfig
+ cp $< $@
+
+buildroot_x86_64:
+ mkdir -p $@
+
+buildroot_x86_64/.config: buildroot/configs/x86_64_guse_defconfig | buildroot_x86_64
+ make -C buildroot O=../buildroot_x86_64 x86_64_guse_defconfig
+
+buildroot_x86_64/images/rootfs.tar: buildroot_x86_64 buildroot_x86_64/.config build-linux/defconfig
+ make -C buildroot_x86_64 ${PARALLEL} -s
+
+.build-buildroot-x86-64: buildroot_x86_64/images/rootfs.tar
+
+clean::
+ -rm -rf buildroot_x86_64/images/rootfs.tar
+
+# --- initramfs
+
+.PHONY: .initramfs
+
+${SYSROOT}/init: scripts/init | ${SYSROOT}
+ install -m 755 $< $@
+
+${SYSROOT}/loginroot: scripts/loginroot | ${SYSROOT}
+ install -m 755 $< $@
+
+${SYSROOT}/lib/modules: build-linux/arch/x86_64/boot/bzImage linux build-linux
+ make ${PARALLEL} -s -C build-linux INSTALL_MOD_PATH=${SYSROOT} INSTALL_MOD_STRIP=1 modules_install
+
+.initramfs: buildroot_x86_64/images/rootfs.tar | ${SYSROOT}/init ${SYSROOT}/loginroot ${SYSROOT}/lib/modules ${SYSROOT}/.mount-stamp
+ tar xf $< -C ${SYSROOT}
+ cp etc/inittab ${SYSROOT}/etc/
+ cp -r scripts/root ${SYSROOT}
+
+# --- initrd image
+
+.PHONY: build-image-clean
+
+build-image:
+ mkdir -p $@
+
+build-image-clean: ${SYSROOT} | build-image .initramfs
+ rm -rf build-image/rootfs
+ mkdir build-image/rootfs
+ (cd ${SYSROOT} && tar cf - . ) | (cd build-image/rootfs; tar xf - )
+ rm -rf build-image/rootfs/usr/{include,share/doc,share/info}
+ rm -rf build-image/rootfs/var/db/*
+ rm -rf build-image/rootfs/var/lib/*
+ rm -rf build-image/rootfs/var/log/*
+ rm -rf build-image/rootfs/var/run/*
+ rm -rf build-image/rootfs/usr/share/man
+ rm -rf build-image/rootfs/usr/local/share/man
+ rm -rf build-image/rootfs/usr/share/pkgconfig build-image/rootfs/usr/lib/pkgconfig
+ rm -rf build-image/rootfs/usr/share/locale/{el,ko,sl,be,eo,bs,nb,pt,tr,ro,uk,it,hu,sv,id,kk,es,zh_CN,da,de,vi,pt_BR,nl,en_GB,ia,sq,sr,af,ru,pl,cs,tl,dz,sk,ja,nn,he,fr,zh_TW,km,gl,fi,eu,ga,lt,hr,bg,rw,ca,et,ne}
+ rm -rf build-image/rootfs/etc/ssl/man
+ find build-image/rootfs \( -name "*.a" -o -name "*.la" -o -name "*.o" \) -exec rm -rf {} \;
+ rm -f build-image/rootfs/usr/bin/{strings,strip,ranlib,readelf,objdump,objcopy,nm,ld.gold,ld.bfd,ld}
+ rm -f build-image/rootfs/usr/bin/{gdb,gdbserver,gprof,flex++,flex,c++filt,as,ar,addr2line}
+ rm -f build-image/rootfs/usr/bin/{strace,strace-graph,strace-log-merge}
+ rm -f build-image/rootfs/bin/udevadm
+ rm -f build-image/rootfs/sbin/{udevd,udevadm}
+ rm -rf build-image/rootfs/etc/udev
+ rm -rf build-image/rootfs/lib/udev
+ find build-image/rootfs -path build-image/rootfs/lib/modules -prune -o -type f -print | while read f; do file $$f | grep -q 'ELF 32-bit MSB' && { ${TARGET_CROSS_PREFIX}-strip -s -p $$f || true; } || true; done
+
+build-image/initramfs.cpio.xz: build-image-clean
+ (cd build-image/rootfs && find . -print0 | cpio --null -ov --format=newc | xz -C crc32 > ../initramfs.cpio.xz)
+
+clean::
+ -rm -rf build-image/initramfs.cpio.xz
+
+distclean::
+ -rm -rf ${SYSROOT}
+
+# --- overlay
+
+.PHONY: .overlayfs
+
+overlay/qemu/merged:
+ mkdir -p $@
+
+overlay/qemu/upper:
+ mkdir -p $@
+
+overlay/qemu/work:
+ mkdir -p $@
+
+.overlayfs: \
+ overlay/qemu/merged \
+ overlay/qemu/upper \
+ overlay/qemu/work
--- /dev/null
+# /etc/inittab
+#
+# Copyright (C) 2001 Erik Andersen <andersen@codepoet.org>
+#
+# Note: BusyBox init doesn't support runlevels. The runlevels field is
+# completely ignored by BusyBox init. If you want runlevels, use
+# sysvinit.
+#
+# Format for each entry: <id>:<runlevels>:<action>:<process>
+#
+# id == tty to run on, or empty for /dev/console
+# runlevels == ignored
+# action == one of sysinit, respawn, askfirst, wait, and once
+# process == program to run
+
+# Startup the system
+::sysinit:/bin/mount -t proc proc /proc
+::sysinit:/bin/mount -o remount,rw /
+::sysinit:/bin/mkdir -p /dev/pts /dev/shm
+::sysinit:/bin/mount -a
+::sysinit:/bin/mkdir -p /run/lock/subsys
+::sysinit:/sbin/swapon -a
+null::sysinit:/bin/ln -sf /proc/self/fd /dev/fd
+null::sysinit:/bin/ln -sf /proc/self/fd/0 /dev/stdin
+null::sysinit:/bin/ln -sf /proc/self/fd/1 /dev/stdout
+null::sysinit:/bin/ln -sf /proc/self/fd/2 /dev/stderr
+::sysinit:/bin/hostname -F /etc/hostname
+# now run any rc scripts
+::sysinit:/etc/init.d/rcS
+
+# Put a getty on the serial port
+::respawn:/sbin/getty -n -L -l /loginroot 115200 ttyS0 vt100
+#console::respawn:/sbin/getty -L -l /loginroot console 0 vt100 # GENERIC_SERIAL
+
+# Stuff to do for the 3-finger salute
+#::ctrlaltdel:/sbin/reboot
+
+# Stuff to do before rebooting
+::shutdown:/etc/init.d/rcK
+::shutdown:/sbin/swapoff -a
+::shutdown:/bin/umount -a -r