From 3badc5ac30fcc0836a2604146788158b16b64f2d Mon Sep 17 00:00:00 2001 From: dzwdz Date: Sat, 23 Jul 2022 18:20:06 +0200 Subject: init: compile as an elf --- Makefile | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 72e7883..f1b6ce3 100644 --- a/Makefile +++ b/Makefile @@ -67,12 +67,19 @@ out/bootstrap: src/user_bootstrap/linker.ld $(call from_sources, src/user_bootst initrd/test.elf: out/test.elf @# dummy +initrd/init.elf: out/init.elf + @# dummy + out/test.elf: src/usertestelf.ld out/obj/usertestelf.c.o out/obj/user/lib/syscall.s.o $(call from_sources, src/shared/) @mkdir -p $(@D) @$(CC) $(LFLAGS) -Wl,-pie -Wl,-no-dynamic-linker -T $^ -o $@ +out/init.elf: src/user/linker.ld $(call from_sources, src/user/) $(call from_sources, src/shared/) + @mkdir -p $(@D) + @$(CC) $(LFLAGS) -Wl,-pie -Wl,-no-dynamic-linker -T $^ -o $@ + # TODO automatically resolve symlinks -out/initrd.tar: $(shell find initrd/) out/test.elf +out/initrd.tar: $(shell find initrd/) out/test.elf out/init.elf cd initrd; tar chf ../$@ * out/fs/boot/init: out/bootstrap out/initrd.tar @@ -95,6 +102,10 @@ out/obj/%.c.o: src/%.c @mkdir -p $(@D) @$(CC) $(CFLAGS) -c $^ -o $@ +out/obj/user/%.c.o: src/user/%.c + @mkdir -p $(@D) + @$(CC) $(CFLAGS) -fPIE -c $^ -o $@ + out/obj/usertestelf.c.o: src/usertestelf.c @mkdir -p $(@D) @$(CC) $(CFLAGS) -fPIE -c $^ -o $@ -- cgit v1.2.3