2022-06-24 09:02:51 +00:00
|
|
|
NAME := qos
|
2022-07-09 00:37:00 +00:00
|
|
|
DEBUG := true
|
2022-06-24 09:02:51 +00:00
|
|
|
OUT_DIR := out
|
|
|
|
KEY_DIR := keys
|
|
|
|
TARGET := local
|
|
|
|
CACHE_DIR := cache
|
|
|
|
CONFIG_DIR := targets/$(TARGET)
|
2022-07-09 00:37:00 +00:00
|
|
|
SCRIPTS_DIR := scripts
|
2022-06-24 09:02:51 +00:00
|
|
|
CPUS := $(shell nproc)
|
2022-07-09 00:37:00 +00:00
|
|
|
ARCH := x86_64
|
2022-06-24 09:02:51 +00:00
|
|
|
|
|
|
|
include $(PWD)/config.env
|
|
|
|
include $(PWD)/make/keys.mk
|
|
|
|
include $(PWD)/make/fetch.mk
|
|
|
|
include $(PWD)/make/extract.mk
|
|
|
|
include $(PWD)/make/toolchain.mk
|
|
|
|
|
|
|
|
.DEFAULT_GOAL := default
|
|
|
|
default: $(OUT_DIR)/bzImage
|
|
|
|
|
|
|
|
$(CONFIG_DIR)/busybox.config:
|
|
|
|
$(toolchain) " \
|
|
|
|
cd /cache/busybox-$(BUSYBOX_VERSION) && \
|
2022-07-09 00:37:00 +00:00
|
|
|
KCONFIG_NOTIMESTAMP=1 make menuconfig && \
|
2022-06-24 09:02:51 +00:00
|
|
|
cp .config /config/busybox.config; \
|
|
|
|
"
|
|
|
|
|
|
|
|
$(CONFIG_DIR)/linux.config:
|
|
|
|
$(toolchain) " \
|
|
|
|
cd /cache/linux-$(LINUX_VERSION) && \
|
|
|
|
make menuconfig && \
|
|
|
|
cp .config /config/linux.config; \
|
|
|
|
"
|
2022-07-09 00:37:00 +00:00
|
|
|
|
|
|
|
$(OUT_DIR)/rootfs.cpio: $(OUT_DIR)/busybox
|
|
|
|
mkdir -p $(CACHE_DIR)/rootfs/bin
|
|
|
|
ifdef DEBUG
|
|
|
|
cp $(OUT_DIR)/busybox $(CACHE_DIR)/rootfs/bin;
|
|
|
|
cp $(SCRIPTS_DIR)/busybox_init $(CACHE_DIR)/rootfs/init;
|
|
|
|
chmod +x $(CACHE_DIR)/rootfs/init;
|
|
|
|
endif
|
|
|
|
$(toolchain) " \
|
|
|
|
cd /cache/rootfs \
|
|
|
|
&& find . \
|
|
|
|
| cpio -o -H newc \
|
|
|
|
| gzip -f - > /out/rootfs.cpio \
|
|
|
|
"
|
|
|
|
|
|
|
|
# Currently broken determinism attempt
|
|
|
|
# $(toolchain) " \
|
|
|
|
# cd /cache/rootfs \
|
|
|
|
# && mkdir -p dev \
|
|
|
|
# && fakeroot mknod -m 0622 dev/console c 5 1 \
|
|
|
|
# && find . -mindepth 1 -execdir touch -hcd "@0" "{}" + \
|
|
|
|
# && find . -mindepth 1 -printf '%P\0' \
|
|
|
|
# | sort -z \
|
|
|
|
# | LANG=C bsdtar --uid 0 --gid 0 --null -cnf - -T - \
|
|
|
|
# | LANG=C bsdtar --null -cf - --format=newc @- \
|
|
|
|
# " > $@
|
|
|
|
|
|
|
|
|
2022-06-24 09:02:51 +00:00
|
|
|
$(OUT_DIR)/busybox: extract
|
|
|
|
$(toolchain) " \
|
|
|
|
cd /cache/busybox-$(BUSYBOX_VERSION) && \
|
|
|
|
cp /config/busybox.config .config && \
|
|
|
|
make -j$(CPUS) busybox && \
|
|
|
|
cp busybox /out/; \
|
|
|
|
"
|
|
|
|
|
2022-07-09 00:37:00 +00:00
|
|
|
$(OUT_DIR)/bzImage: extract $(OUT_DIR)/rootfs.cpio
|
2022-06-24 09:02:51 +00:00
|
|
|
$(toolchain) " \
|
|
|
|
cd /cache/linux-$(LINUX_VERSION) && \
|
|
|
|
cp /config/linux.config .config && \
|
2022-07-09 00:37:00 +00:00
|
|
|
make olddefconfig && \
|
|
|
|
make -j$(CPUS) ARCH=$(ARCH) bzImage && \
|
2022-06-24 09:02:51 +00:00
|
|
|
cp arch/x86_64/boot/bzImage /out/; \
|
|
|
|
"
|
2022-07-09 00:37:00 +00:00
|
|
|
|
|
|
|
.PHONY: run
|
|
|
|
run:
|
|
|
|
qemu-system-x86_64 \
|
|
|
|
-m 512M \
|
|
|
|
-nographic \
|
|
|
|
-initrd $(OUT_DIR)/rootfs.cpio \
|
|
|
|
-kernel $(OUT_DIR)/bzImage
|