diff options
author | dzwdz | 2022-07-24 17:10:10 +0200 |
---|---|---|
committer | dzwdz | 2022-07-24 17:10:10 +0200 |
commit | 6cbeb4e42667bb4fd2f8abe6818865e700690d34 (patch) | |
tree | 2b69e254ba1bda609f1591a6d76107cce4234020 | |
parent | 373afdda5759198b2d5123abb578e3c649103493 (diff) |
make/user: generate the initrd.tar in a "smarter" way
-rw-r--r-- | Makefile | 27 | ||||
l--------- | initrd/init.elf | 1 | ||||
l--------- | initrd/testelf.elf | 1 |
3 files changed, 13 insertions, 16 deletions
@@ -64,23 +64,22 @@ out/bootstrap: src/user_bootstrap/linker.ld $(call from_sources, src/user_bootst @mkdir -p $(@D) @$(CC) $(LFLAGS) -T $^ -o $@ -initrd/testelf.elf: out/testelf.elf - @# dummy - -initrd/init.elf: out/init.elf - @# dummy - -out/testelf.elf: src/user/linker.ld $(call from_sources, src/user/app/testelf/) $(call from_sources, src/user/lib/) $(call from_sources, src/shared/) - @mkdir -p $(@D) - @$(CC) $(LFLAGS) -Wl,-pie -Wl,-no-dynamic-linker -T $^ -o $@ +define userbin_template = +out/initrd/$(1).elf: src/user/linker.ld $(call from_sources, src/user/app/$(1)/) $(call from_sources, src/user/lib/) $(call from_sources, src/shared/) + @mkdir -p $$(@D) + @$(CC) $(LFLAGS) -Wl,-pie -Wl,-no-dynamic-linker -T $$^ -o $$@ +endef +USERBINS := $(shell ls src/user/app) +$(foreach bin,$(USERBINS),$(eval $(call userbin_template,$(bin)))) -out/init.elf: src/user/linker.ld $(call from_sources, src/user/app/init/) $(call from_sources, src/user/lib/) $(call from_sources, src/shared/) +out/initrd/%: initrd/% @mkdir -p $(@D) - @$(CC) $(LFLAGS) -Wl,-pie -Wl,-no-dynamic-linker -T $^ -o $@ + @cp $< $@ -# TODO automatically resolve symlinks -out/initrd.tar: $(shell find initrd/) out/testelf.elf out/init.elf - cd initrd; tar chf ../$@ * +out/initrd.tar: $(patsubst %,out/%,$(shell find initrd/ -type f)) \ + $(patsubst %,out/initrd/%.elf,$(USERBINS)) + echo $^ + cd out/initrd; tar chf ../initrd.tar * out/fs/boot/init: out/bootstrap out/initrd.tar @mkdir -p $(@D) diff --git a/initrd/init.elf b/initrd/init.elf deleted file mode 120000 index 21a467a..0000000 --- a/initrd/init.elf +++ /dev/null @@ -1 +0,0 @@ -../out/init.elf
\ No newline at end of file diff --git a/initrd/testelf.elf b/initrd/testelf.elf deleted file mode 120000 index 8f2f99c..0000000 --- a/initrd/testelf.elf +++ /dev/null @@ -1 +0,0 @@ -../out/testelf.elf
\ No newline at end of file |