diff --git a/Makefile b/Makefile index 0e9b836b..d91d2ce0 100644 --- a/Makefile +++ b/Makefile @@ -7,14 +7,10 @@ SHELL := /usr/bin/env bash TOOLCHAIN = x86_64-elf TOOLCHAIN_CC = $(TOOLCHAIN)-gcc -TOOLCHAIN_AR = $(TOOLCHAIN)-ar ifeq ($(shell export "PATH=$(PATH)"; command -v $(TOOLCHAIN_CC) ; ), ) TOOLCHAIN_CC := gcc endif -ifeq ($(shell export "PATH=$(PATH)"; command -v $(TOOLCHAIN_AR) ; ), ) -TOOLCHAIN_AR := ar -endif ifneq ($(MAKECMDGOALS), toolchain) ifneq ($(shell export "PATH=$(PATH)"; $(TOOLCHAIN_CC) -dumpmachine | head -c 6), x86_64) @@ -132,8 +128,6 @@ toolchain: gnu-efi: git clone https://git.code.sf.net/p/gnu-efi/code --branch=3.0.13 --depth=1 $@ - $(MAKE) -C gnu-efi/gnuefi CC="$(TOOLCHAIN_CC) -m64 -march=x86-64" AR="$(TOOLCHAIN_AR)" - $(MAKE) -C gnu-efi/lib CC="$(TOOLCHAIN_CC) -m64 -march=x86-64" ARCH=x86_64 x86_64/efi_stub.o ovmf: mkdir -p ovmf diff --git a/stage23/Makefile b/stage23/Makefile index a3fbfc17..74c8dc78 100644 --- a/stage23/Makefile +++ b/stage23/Makefile @@ -17,6 +17,7 @@ TOOLCHAIN = x86_64-elf TOOLCHAIN_CC = $(TOOLCHAIN)-gcc TOOLCHAIN_LD = $(TOOLCHAIN)-ld +TOOLCHAIN_AR = $(TOOLCHAIN)-ar TOOLCHAIN_OBJCOPY = $(TOOLCHAIN)-objcopy TOOLCHAIN_OBJDUMP = $(TOOLCHAIN)-objdump TOOLCHAIN_READELF = $(TOOLCHAIN)-readelf @@ -27,6 +28,9 @@ endif ifeq ($(shell command -v $(TOOLCHAIN_LD) ; ), ) TOOLCHAIN_LD := ld endif +ifeq ($(shell command -v $(TOOLCHAIN_AR) ; ), ) +TOOLCHAIN_AR := ar +endif ifeq ($(shell command -v $(TOOLCHAIN_OBJCOPY) ; ), ) TOOLCHAIN_OBJCOPY := objcopy endif @@ -197,20 +201,20 @@ $(BUILDDIR)/full.map.o: $(BUILDDIR)/limine_efi_nomap.elf $(BUILDDIR)/BOOTX64.EFI: $(BUILDDIR)/limine_efi.elf $(TOOLCHAIN_OBJCOPY) -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel -j .rela -j .rel.* -j .rela.* -j .reloc -j .sbat --target efi-app-x86_64 --subsystem=10 $< $@ -$(BUILDDIR)/limine_efi_nomap.elf: $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o +../gnu-efi/gnuefi/crt0-efi-x86_64.o ../gnu-efi/gnuefi/libgnuefi.a: + $(MAKE) -C ../gnu-efi/gnuefi CC="$(TOOLCHAIN_CC) -m64 -march=x86-64" AR="$(TOOLCHAIN_AR)" ARCH=x86_64 + +../gnu-efi/lib/x86_64/efi_stub.o: + $(MAKE) -C ../gnu-efi/lib CC="$(TOOLCHAIN_CC) -m64 -march=x86-64" ARCH=x86_64 x86_64/efi_stub.o + +$(BUILDDIR)/limine_efi_nomap.elf: ../gnu-efi/gnuefi/crt0-efi-x86_64.o ../gnu-efi/gnuefi/libgnuefi.a ../gnu-efi/lib/x86_64/efi_stub.o $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(TOOLCHAIN_LD) \ -Tlinker_uefi_nomap.ld \ - ../gnu-efi/gnuefi/crt0-efi-x86_64.o \ - ../gnu-efi/gnuefi/libgnuefi.a \ - ../gnu-efi/lib/x86_64/efi_stub.o \ $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -o $@ -$(BUILDDIR)/limine_efi.elf: $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(BUILDDIR)/full.map.o +$(BUILDDIR)/limine_efi.elf: ../gnu-efi/gnuefi/crt0-efi-x86_64.o ../gnu-efi/gnuefi/libgnuefi.a ../gnu-efi/lib/x86_64/efi_stub.o $(OBJ) $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(BUILDDIR)/full.map.o $(TOOLCHAIN_LD) \ -Tlinker_uefi.ld \ - ../gnu-efi/gnuefi/crt0-efi-x86_64.o \ - ../gnu-efi/gnuefi/libgnuefi.a \ - ../gnu-efi/lib/x86_64/efi_stub.o \ $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -o $@ endif