From 4afedd00a2a819da2a9756b39b6e461a66950a39 Mon Sep 17 00:00:00 2001 From: "Lance R. Vick" Date: Wed, 27 Jul 2022 17:27:16 -0700 Subject: [PATCH] disable debug by default, and favor sample 'hello world' init binary --- Makefile | 17 ++++++++++++++++- src/sample/init.c | 9 +++++++++ toolchain/Makefile | 1 + 3 files changed, 26 insertions(+), 1 deletion(-) create mode 100644 src/sample/init.c diff --git a/Makefile b/Makefile index 410c2cc..f257f0b 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,7 @@ -DEBUG := true +DEBUG := false OUT_DIR := out KEY_DIR := keys +SRC_DIR := src TARGET := local CACHE_DIR := cache CONFIG_DIR := targets/$(TARGET) @@ -100,6 +101,14 @@ $(OUT_DIR)/busybox: \ cp busybox /out/; \ ") +$(OUT_DIR)/sample_init: + $(call toolchain,$(USER)," \ + gcc \ + -static \ + -static-libgcc /src/sample/init.c \ + -o /out/sample_init; \ + ") + $(CACHE_DIR)/linux-$(LINUX_VERSION)/usr/gen_init_cpio: \ $(CACHE_DIR)/linux-$(LINUX_VERSION) \ $(CACHE_DIR)/linux-$(LINUX_VERSION) \ @@ -112,10 +121,16 @@ $(CACHE_DIR)/linux-$(LINUX_VERSION)/usr/gen_init_cpio: \ $(OUT_DIR)/rootfs.cpio: \ $(OUT_DIR)/busybox \ + $(OUT_DIR)/sample_init \ $(CACHE_DIR)/linux-$(LINUX_VERSION)/usr/gen_init_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 $(OUT_DIR)/busybox $(CACHE_DIR)/rootfs/bin/ +else + cp $(OUT_DIR)/sample_init $(CACHE_DIR)/rootfs/init +endif $(call toolchain,$(USER)," \ cd /cache/rootfs && \ find . -mindepth 1 -execdir touch -hcd "@0" "{}" + && \ diff --git a/src/sample/init.c b/src/sample/init.c new file mode 100644 index 0000000..23e4a10 --- /dev/null +++ b/src/sample/init.c @@ -0,0 +1,9 @@ +#include +#include + +int main(int argc, char **argv) { + (void) argc; + (void) argv; + puts("Appliance Linux Sample Init"); + sleep(0xFFFFFFFF); +} diff --git a/toolchain/Makefile b/toolchain/Makefile index 8cf371b..1802e1d 100644 --- a/toolchain/Makefile +++ b/toolchain/Makefile @@ -23,6 +23,7 @@ define toolchain --volume $(PWD)/$(KEY_DIR):/keys \ --volume $(PWD)/$(CACHE_DIR):/cache \ --volume $(PWD)/$(OUT_DIR):/out \ + --volume $(PWD)/$(SRC_DIR):/src \ --volume $(PWD)/$(SCRIPTS_DIR):/scripts \ --env GNUPGHOME=/cache/.gnupg \ --env ARCH=$(ARCH) \