From 1dbea5251dd038f90436e75cba25ceaf7a41b59a Mon Sep 17 00:00:00 2001 From: "Lance R. Vick" Date: Fri, 29 Jul 2022 12:32:45 -0700 Subject: [PATCH] restructure dirs for easier target additions --- Makefile | 22 ++++++++++++---------- {targets/local => config}/busybox.config | 0 config.env => config/global.env | 0 {targets => config}/local/linux.config | 0 {targets => config}/local/rootfs.list | 0 {scripts => src/scripts}/busybox_init | 0 toolchain/Makefile | 3 +-- 7 files changed, 13 insertions(+), 12 deletions(-) rename {targets/local => config}/busybox.config (100%) rename config.env => config/global.env (100%) rename {targets => config}/local/linux.config (100%) rename {targets => config}/local/rootfs.list (100%) rename {scripts => src/scripts}/busybox_init (100%) diff --git a/Makefile b/Makefile index f257f0b..4634fd6 100644 --- a/Makefile +++ b/Makefile @@ -4,14 +4,14 @@ KEY_DIR := keys SRC_DIR := src TARGET := local CACHE_DIR := cache -CONFIG_DIR := targets/$(TARGET) +CONFIG_DIR := config TOOLCHAIN_DIR := toolchain -SCRIPTS_DIR := scripts +SRC_DIR := src USER := $(shell id -g):$(shell id -g) CPUS := $(shell nproc) ARCH := x86_64 -include $(PWD)/config.env +include $(PWD)/config/global.env include $(PWD)/make/keys.mk include $(PWD)/make/fetch.mk include $(PWD)/toolchain/Makefile @@ -65,8 +65,8 @@ busybox-config: # Run linux config menu and save output .PHONY: linux-config linux-config: - rm $(CONFIG_DIR)/linux.config - make $(CONFIG_DIR)/linux.config + rm $(CONFIG_DIR)/$(TARGET)/linux.config + make $(CONFIG_DIR)/$(TARGET)/linux.config # This can likely be eliminated with path fixes in toolchain/Makefile $(OUT_DIR)/toolchain.tar: @@ -83,11 +83,11 @@ $(CONFIG_DIR)/busybox.config: cp .config /config/busybox.config; \ ") -$(CONFIG_DIR)/linux.config: +$(CONFIG_DIR)/$(TARGET)/linux.config: $(call toolchain,$(USER)," \ cd /cache/linux-$(LINUX_VERSION) && \ make menuconfig && \ - cp .config /config/linux.config; \ + cp .config /config/$(TARGET)/linux.config; \ ") $(OUT_DIR)/busybox: \ @@ -126,7 +126,7 @@ $(OUT_DIR)/rootfs.cpio: \ mkdir -p $(CACHE_DIR)/rootfs/bin ifeq ($(DEBUG), true) cp $(OUT_DIR)/sample_init $(CACHE_DIR)/rootfs/sample_init - cp $(SCRIPTS_DIR)/busybox_init $(CACHE_DIR)/rootfs/init + cp $(SRC_DIR)/scripts/busybox_init $(CACHE_DIR)/rootfs/init cp $(OUT_DIR)/busybox $(CACHE_DIR)/rootfs/bin/ else cp $(OUT_DIR)/sample_init $(CACHE_DIR)/rootfs/init @@ -136,7 +136,9 @@ endif find . -mindepth 1 -execdir touch -hcd "@0" "{}" + && \ find . -mindepth 1 -printf '%P\0' && \ cd /cache/linux-$(LINUX_VERSION) && \ - usr/gen_initramfs.sh -o /out/rootfs.cpio /config/rootfs.list && \ + usr/gen_initramfs.sh \ + -o /out/rootfs.cpio \ + /config/$(TARGET)/rootfs.list && \ cpio -itv < /out/rootfs.cpio && \ sha256sum /out/rootfs.cpio; \ ") @@ -145,7 +147,7 @@ $(OUT_DIR)/bzImage: \ $(OUT_DIR)/rootfs.cpio $(call toolchain,$(USER)," \ cd /cache/linux-$(LINUX_VERSION) && \ - cp /config/linux.config .config && \ + cp /config/$(TARGET)/linux.config .config && \ make olddefconfig && \ make -j$(CPUS) ARCH=$(ARCH) bzImage && \ cp arch/x86_64/boot/bzImage /out/ && \ diff --git a/targets/local/busybox.config b/config/busybox.config similarity index 100% rename from targets/local/busybox.config rename to config/busybox.config diff --git a/config.env b/config/global.env similarity index 100% rename from config.env rename to config/global.env diff --git a/targets/local/linux.config b/config/local/linux.config similarity index 100% rename from targets/local/linux.config rename to config/local/linux.config diff --git a/targets/local/rootfs.list b/config/local/rootfs.list similarity index 100% rename from targets/local/rootfs.list rename to config/local/rootfs.list diff --git a/scripts/busybox_init b/src/scripts/busybox_init similarity index 100% rename from scripts/busybox_init rename to src/scripts/busybox_init diff --git a/toolchain/Makefile b/toolchain/Makefile index 1802e1d..fadce58 100644 --- a/toolchain/Makefile +++ b/toolchain/Makefile @@ -20,11 +20,10 @@ define toolchain --user=$(1) \ --platform=linux/$(ARCH) \ --volume $(PWD)/$(CONFIG_DIR):/config \ - --volume $(PWD)/$(KEY_DIR):/keys \ --volume $(PWD)/$(CACHE_DIR):/cache \ + --volume $(PWD)/$(KEY_DIR):/keys \ --volume $(PWD)/$(OUT_DIR):/out \ --volume $(PWD)/$(SRC_DIR):/src \ - --volume $(PWD)/$(SCRIPTS_DIR):/scripts \ --env GNUPGHOME=/cache/.gnupg \ --env ARCH=$(ARCH) \ --env KBUILD_BUILD_USER=$(KBUILD_BUILD_USER) \