From e215f7741187553528b1c80e928b3cc77bf314fd Mon Sep 17 00:00:00 2001 From: mintsuki Date: Fri, 22 Oct 2021 20:08:11 +0200 Subject: [PATCH] build: De-symlink tinf --- Makefile | 3 ++- decompressor/Makefile | 17 +++++++++++++---- decompressor/main.c | 2 +- decompressor/tinf | 1 - stage23/Makefile | 39 ++++++++++++++++++++++++--------------- stage23/lib/uri.c | 2 +- stage23/protos/stivale.c | 2 +- stage23/protos/stivale2.c | 2 +- stage23/tinf | 1 - 9 files changed, 43 insertions(+), 26 deletions(-) delete mode 120000 decompressor/tinf delete mode 120000 stage23/tinf diff --git a/Makefile b/Makefile index 7d56ebe2..96d46160 100644 --- a/Makefile +++ b/Makefile @@ -57,6 +57,7 @@ bin/limine-install: .PHONY: clean clean: limine-bios-clean limine-uefi-clean limine-uefi32-clean $(MAKE) -C limine-install clean + rm -rf bin build .PHONY: install install: all @@ -122,7 +123,7 @@ limine-uefi32-clean: stage23-uefi32-clean .PHONY: distclean2 distclean2: clean test-clean - rm -rf bin build toolchain ovmf* gnu-efi + rm -rf toolchain ovmf* gnu-efi .PHONY: distclean distclean: distclean2 diff --git a/decompressor/Makefile b/decompressor/Makefile index bebfe471..51ba955f 100644 --- a/decompressor/Makefile +++ b/decompressor/Makefile @@ -45,7 +45,8 @@ INTERNAL_CFLAGS = \ -mno-sse \ -mno-sse2 \ -MMD \ - -I. + -I. \ + -I$(BUILDDIR)/tinf LDFLAGS ?= @@ -70,13 +71,21 @@ all: builddir: for i in $(OBJ); do mkdir -p `dirname $$i`; done -$(BUILDDIR)/decompressor.bin: $(OBJ) - $(TOOLCHAIN_LD) $(OBJ) $(LDFLAGS) $(INTERNAL_LDFLAGS) -o $(BUILDDIR)/decompressor.elf +$(BUILDDIR)/decompressor.bin: $(OBJ) $(BUILDDIR)/tinf/tinfgzip.o $(BUILDDIR)/tinf/tinflate.o + $(TOOLCHAIN_LD) $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -o $(BUILDDIR)/decompressor.elf $(TOOLCHAIN_OBJCOPY) -O binary $(BUILDDIR)/decompressor.elf $@ +$(BUILDDIR)/tinf-copied: ../tinf/* + rm -rf $(BUILDDIR)/tinf + cp -r ../tinf $(BUILDDIR)/ + touch $(BUILDDIR)/tinf-copied + +$(BUILDDIR)/tinf/tinfgzip.o $(BUILDDIR)/tinf/tinflate.o: $(BUILDDIR)/tinf-copied + $(TOOLCHAIN_CC) $(CFLAGS) -Os $(INTERNAL_CFLAGS) -c $(@:.o=.c) -o $@ + -include $(HEADER_DEPS) -$(BUILDDIR)/%.o: %.c +$(BUILDDIR)/%.o: %.c $(BUILDDIR)/tinf-copied $(TOOLCHAIN_CC) $(CFLAGS) -Os $(INTERNAL_CFLAGS) -c $< -o $@ $(BUILDDIR)/%.o: %.asm diff --git a/decompressor/main.c b/decompressor/main.c index c2770ae6..1efb2b6e 100644 --- a/decompressor/main.c +++ b/decompressor/main.c @@ -1,6 +1,6 @@ #include #include -#include +#include __attribute__((noreturn)) void entry(uint8_t *compressed_stage2, size_t stage2_size, uint8_t boot_drive, int pxe) { diff --git a/decompressor/tinf b/decompressor/tinf deleted file mode 120000 index fded5ef1..00000000 --- a/decompressor/tinf +++ /dev/null @@ -1 +0,0 @@ -../tinf/ \ No newline at end of file diff --git a/stage23/Makefile b/stage23/Makefile index 352de1e7..75af2a8a 100644 --- a/stage23/Makefile +++ b/stage23/Makefile @@ -79,7 +79,8 @@ INTERNAL_CFLAGS := \ -DCOM_OUTPUT=$(COM_OUTPUT) \ -DE9_OUTPUT=$(E9_OUTPUT) \ -I. \ - -I.. + -I../stivale \ + -I$(BUILDDIR)/tinf ifeq ($(TARGET), bios) INTERNAL_CFLAGS += \ @@ -113,8 +114,8 @@ ifeq ($(TARGET), uefi) -mtune=generic \ -mabi=sysv \ -DGNU_EFI_USE_MS_ABI \ - -I../gnu-efi/inc \ - -I../gnu-efi/inc/x86_64 \ + -I$(BUILDDIR)/gnu-efi/inc \ + -I$(BUILDDIR)/gnu-efi/inc/x86_64 \ -fpie \ -mno-red-zone endif @@ -128,8 +129,8 @@ ifeq ($(TARGET), uefi32) -mtune=generic \ -mabi=sysv \ -DGNU_EFI_USE_MS_ABI \ - -I../gnu-efi/inc \ - -I../gnu-efi/inc/ia32 \ + -I$(BUILDDIR)/gnu-efi/inc \ + -I$(BUILDDIR)/gnu-efi/inc/ia32 \ -fpie endif @@ -214,6 +215,14 @@ $(BUILDDIR)/font.o: font.bin cd "`dirname $<`" && \ $(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) "`basename $<`" $@ +$(BUILDDIR)/tinf-copied: ../tinf/* + rm -rf $(BUILDDIR)/tinf + cp -r ../tinf $(BUILDDIR)/ + touch $(BUILDDIR)/tinf-copied + +$(BUILDDIR)/tinf/tinfgzip.o $(BUILDDIR)/tinf/tinflate.o: $(BUILDDIR)/tinf-copied + $(TOOLCHAIN_CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $(@:.o=.c) -o $@ + ifeq ($(TARGET), bios) $(BUILDDIR)/stage2.bin.gz: $(BUILDDIR)/stage2.bin @@ -240,13 +249,13 @@ $(BUILDDIR)/limine_stage2only.elf: $(OBJ) ( echo "This error may mean that stage 2 was trying to use stage 3 symbols before loading stage 3" && \ false ) -$(BUILDDIR)/limine_nomap.elf: $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(BUILDDIR)/stage2.map.o +$(BUILDDIR)/limine_nomap.elf: $(OBJ) $(BUILDDIR)/tinf/tinfgzip.o $(BUILDDIR)/tinf/tinflate.o $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(BUILDDIR)/stage2.map.o $(TOOLCHAIN_LD) $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker_nomap.ld -o $@ -$(BUILDDIR)/limine.elf: $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(BUILDDIR)/stage2.map.o $(BUILDDIR)/full.map.o +$(BUILDDIR)/limine.elf: $(OBJ) $(BUILDDIR)/tinf/tinfgzip.o $(BUILDDIR)/tinf/tinflate.o $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(BUILDDIR)/stage2.map.o $(BUILDDIR)/full.map.o $(TOOLCHAIN_LD) $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker.ld -o $@ -$(BUILDDIR)/limine_dbg.elf: $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(BUILDDIR)/stage2.map.o $(BUILDDIR)/full.map.o +$(BUILDDIR)/limine_dbg.elf: $(OBJ) $(BUILDDIR)/tinf/tinfgzip.o $(BUILDDIR)/tinf/tinflate.o $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(BUILDDIR)/stage2.map.o $(BUILDDIR)/full.map.o $(TOOLCHAIN_LD) $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker_dbg.ld -o $@ endif @@ -271,12 +280,12 @@ $(BUILDDIR)/BOOTX64.EFI: $(BUILDDIR)/limine_efi.elf $(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-x86_64.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a: $(BUILDDIR)/gnu-efi $(MAKE) -C $(BUILDDIR)/gnu-efi/gnuefi CC="$(TOOLCHAIN_CC) -m64 -march=x86-64 -mtune=generic" AR="$(TOOLCHAIN_AR)" ARCH=x86_64 -$(BUILDDIR)/limine_efi_nomap.elf: $(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-x86_64.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o +$(BUILDDIR)/limine_efi_nomap.elf: $(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-x86_64.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a $(OBJ) $(BUILDDIR)/tinf/tinfgzip.o $(BUILDDIR)/tinf/tinflate.o $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(TOOLCHAIN_LD) \ -Tlinker_uefi_nomap.ld \ $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -o $@ -$(BUILDDIR)/limine_efi.elf: $(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-x86_64.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(BUILDDIR)/full.map.o +$(BUILDDIR)/limine_efi.elf: $(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-x86_64.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a $(OBJ) $(BUILDDIR)/tinf/tinfgzip.o $(BUILDDIR)/tinf/tinflate.o $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(BUILDDIR)/full.map.o $(TOOLCHAIN_LD) \ -Tlinker_uefi.ld \ $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -o $@ @@ -296,12 +305,12 @@ $(BUILDDIR)/BOOTIA32.EFI: $(BUILDDIR)/limine_efi.elf $(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-ia32.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a: $(BUILDDIR)/gnu-efi $(MAKE) -C $(BUILDDIR)/gnu-efi/gnuefi CC="$(TOOLCHAIN_CC) -m32 -march=i386 -mtune=generic" AR="$(TOOLCHAIN_AR)" ARCH=ia32 -$(BUILDDIR)/limine_efi_nomap.elf: $(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-ia32.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o +$(BUILDDIR)/limine_efi_nomap.elf: $(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-ia32.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a $(OBJ) $(BUILDDIR)/tinf/tinfgzip.o $(BUILDDIR)/tinf/tinflate.o $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(TOOLCHAIN_LD) \ -Tlinker_uefi32_nomap.ld \ $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -o $@ -$(BUILDDIR)/limine_efi.elf: $(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-ia32.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(BUILDDIR)/full.map.o +$(BUILDDIR)/limine_efi.elf: $(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-ia32.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a $(OBJ) $(BUILDDIR)/tinf/tinfgzip.o $(BUILDDIR)/tinf/tinflate.o $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(BUILDDIR)/full.map.o $(TOOLCHAIN_LD) \ -Tlinker_uefi32.ld \ $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -o $@ @@ -311,17 +320,17 @@ endif -include $(HEADER_DEPS) ifeq ($(TARGET), uefi) -$(BUILDDIR)/%.o: %.c $(BUILDDIR)/gnu-efi +$(BUILDDIR)/%.o: %.c $(BUILDDIR)/tinf-copied $(BUILDDIR)/gnu-efi $(TOOLCHAIN_CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@ endif ifeq ($(TARGET), uefi32) -$(BUILDDIR)/%.o: %.c $(BUILDDIR)/gnu-efi +$(BUILDDIR)/%.o: %.c $(BUILDDIR)/tinf-copied $(BUILDDIR)/gnu-efi $(TOOLCHAIN_CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@ endif ifeq ($(TARGET), bios) -$(BUILDDIR)/%.o: %.c +$(BUILDDIR)/%.o: %.c $(BUILDDIR)/tinf-copied $(TOOLCHAIN_CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@ endif diff --git a/stage23/lib/uri.c b/stage23/lib/uri.c index 4d9c2b33..da172831 100644 --- a/stage23/lib/uri.c +++ b/stage23/lib/uri.c @@ -8,7 +8,7 @@ #include #include #include -#include +#include // A URI takes the form of: resource://root/path // The following function splits up a URI into its componenets diff --git a/stage23/protos/stivale.c b/stage23/protos/stivale.c index 25aa23eb..a29ca68b 100644 --- a/stage23/protos/stivale.c +++ b/stage23/protos/stivale.c @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #define REPORTED_ADDR(PTR) \ diff --git a/stage23/protos/stivale2.c b/stage23/protos/stivale2.c index 197476c6..90675f56 100644 --- a/stage23/protos/stivale2.c +++ b/stage23/protos/stivale2.c @@ -21,7 +21,7 @@ #include #include #include -#include +#include #include #include #include diff --git a/stage23/tinf b/stage23/tinf deleted file mode 120000 index fded5ef1..00000000 --- a/stage23/tinf +++ /dev/null @@ -1 +0,0 @@ -../tinf/ \ No newline at end of file