Revert "build: Support spaces in build directory"

This reverts commit d815c3d732.
This commit is contained in:
mintsuki 2021-11-26 14:51:01 +01:00
parent 5da7b1fcdc
commit 89f6d7ddeb
5 changed files with 96 additions and 94 deletions

View File

@ -6,7 +6,6 @@ PREFIX ?= /usr/local
DESTDIR ?= DESTDIR ?=
BUILDDIR ?= $(shell pwd)/build BUILDDIR ?= $(shell pwd)/build
override BUILDDIR := $(shell echo '$(BUILDDIR)' | sed 's/ /\\ /g')
BINDIR ?= $(BUILDDIR)/bin BINDIR ?= $(BUILDDIR)/bin
export PATH := $(shell pwd)/toolchain/bin:$(PATH) export PATH := $(shell pwd)/toolchain/bin:$(PATH)
@ -58,7 +57,7 @@ all:
.PHONY: limine-install .PHONY: limine-install
limine-install: limine-install:
$(MAKE) -C limine-install LIMINE_HDD_BIN=$(BINDIR)/limine-hdd.bin BUILDDIR=$(BINDIR) $(MAKE) -C limine-install LIMINE_HDD_BIN="$(BINDIR)/limine-hdd.bin" BUILDDIR="$(BINDIR)"
.PHONY: clean .PHONY: clean
clean: limine-bios-clean limine-uefi-clean limine-uefi32-clean clean: limine-bios-clean limine-uefi-clean limine-uefi32-clean
@ -79,9 +78,9 @@ install: all
$(BUILDDIR)/stage1: $(STAGE1_FILES) $(BUILDDIR)/decompressor/decompressor.bin $(BUILDDIR)/stage23-bios/stage2.bin.gz $(BUILDDIR)/stage1: $(STAGE1_FILES) $(BUILDDIR)/decompressor/decompressor.bin $(BUILDDIR)/stage23-bios/stage2.bin.gz
mkdir -p $(BINDIR) mkdir -p $(BINDIR)
cd stage1/hdd && nasm bootsect.asm -Werror -fbin -DBUILDDIR=\'$(BUILDDIR)\' -o $(BINDIR)/limine-hdd.bin cd stage1/hdd && nasm bootsect.asm -Werror -fbin -DBUILDDIR="'$(BUILDDIR)'" -o $(BINDIR)/limine-hdd.bin
cd stage1/cd && nasm bootsect.asm -Werror -fbin -DBUILDDIR=\'$(BUILDDIR)\' -o $(BINDIR)/limine-cd.bin cd stage1/cd && nasm bootsect.asm -Werror -fbin -DBUILDDIR="'$(BUILDDIR)'" -o $(BINDIR)/limine-cd.bin
cd stage1/pxe && nasm bootsect.asm -Werror -fbin -DBUILDDIR=\'$(BUILDDIR)\' -o $(BINDIR)/limine-pxe.bin cd stage1/pxe && nasm bootsect.asm -Werror -fbin -DBUILDDIR="'$(BUILDDIR)'" -o $(BINDIR)/limine-pxe.bin
cp $(BUILDDIR)/stage23-bios/limine.sys $(BINDIR)/ cp $(BUILDDIR)/stage23-bios/limine.sys $(BINDIR)/
touch $(BUILDDIR)/stage1 touch $(BUILDDIR)/stage1
@ -92,15 +91,15 @@ limine-bios: stage23-bios decompressor
.PHONY: $(BINDIR)/limine-eltorito-efi.bin .PHONY: $(BINDIR)/limine-eltorito-efi.bin
$(BINDIR)/limine-eltorito-efi.bin: $(BINDIR)/limine-eltorito-efi.bin:
mkdir -p $(BINDIR) mkdir -p $(BINDIR)
dd if=/dev/zero of="$@" bs=512 count=2880 dd if=/dev/zero of=$@ bs=512 count=2880
( mformat -i "$@" -f 1440 :: && \ ( mformat -i $@ -f 1440 :: && \
mmd -D s -i "$@" ::/EFI && \ mmd -D s -i $@ ::/EFI && \
mmd -D s -i "$@" ::/EFI/BOOT && \ mmd -D s -i $@ ::/EFI/BOOT && \
( ( [ -f $(BUILDDIR)/stage23-uefi/BOOTX64.EFI ] && \ ( ( [ -f $(BUILDDIR)/stage23-uefi/BOOTX64.EFI ] && \
mcopy -D o -i "$@" $(BUILDDIR)/stage23-uefi/BOOTX64.EFI ::/EFI/BOOT ) || true ) && \ mcopy -D o -i $@ $(BUILDDIR)/stage23-uefi/BOOTX64.EFI ::/EFI/BOOT ) || true ) && \
( ( [ -f $(BUILDDIR)/stage23-uefi32/BOOTIA32.EFI ] && \ ( ( [ -f $(BUILDDIR)/stage23-uefi32/BOOTIA32.EFI ] && \
mcopy -D o -i "$@" $(BUILDDIR)/stage23-uefi32/BOOTIA32.EFI ::/EFI/BOOT ) || true ) \ mcopy -D o -i $@ $(BUILDDIR)/stage23-uefi32/BOOTIA32.EFI ::/EFI/BOOT ) || true ) \
) || rm -f "$@" ) || rm -f $@
.PHONY: limine-uefi .PHONY: limine-uefi
limine-uefi: limine-uefi:
@ -157,35 +156,35 @@ stivale:
.PHONY: stage23-uefi .PHONY: stage23-uefi
stage23-uefi: stivale stage23-uefi: stivale
$(MAKE) -C stage23 all TARGET=uefi BUILDDIR=$(BUILDDIR)/stage23-uefi $(MAKE) -C stage23 all TARGET=uefi BUILDDIR="$(BUILDDIR)/stage23-uefi"
.PHONY: stage23-uefi-clean .PHONY: stage23-uefi-clean
stage23-uefi-clean: stage23-uefi-clean:
$(MAKE) -C stage23 clean TARGET=uefi BUILDDIR=$(BUILDDIR)/stage23-uefi $(MAKE) -C stage23 clean TARGET=uefi BUILDDIR="$(BUILDDIR)/stage23-uefi"
.PHONY: stage23-uefi32 .PHONY: stage23-uefi32
stage23-uefi32: stivale stage23-uefi32: stivale
$(MAKE) -C stage23 all TARGET=uefi32 BUILDDIR=$(BUILDDIR)/stage23-uefi32 $(MAKE) -C stage23 all TARGET=uefi32 BUILDDIR="$(BUILDDIR)/stage23-uefi32"
.PHONY: stage23-uefi32-clean .PHONY: stage23-uefi32-clean
stage23-uefi32-clean: stage23-uefi32-clean:
$(MAKE) -C stage23 clean TARGET=uefi32 BUILDDIR=$(BUILDDIR)/stage23-uefi32 $(MAKE) -C stage23 clean TARGET=uefi32 BUILDDIR="$(BUILDDIR)/stage23-uefi32"
.PHONY: stage23-bios .PHONY: stage23-bios
stage23-bios: stivale stage23-bios: stivale
$(MAKE) -C stage23 all TARGET=bios BUILDDIR=$(BUILDDIR)/stage23-bios $(MAKE) -C stage23 all TARGET=bios BUILDDIR="$(BUILDDIR)/stage23-bios"
.PHONY: stage23-bios-clean .PHONY: stage23-bios-clean
stage23-bios-clean: stage23-bios-clean:
$(MAKE) -C stage23 clean TARGET=bios BUILDDIR=$(BUILDDIR)/stage23-bios $(MAKE) -C stage23 clean TARGET=bios BUILDDIR="$(BUILDDIR)/stage23-bios"
.PHONY: decompressor .PHONY: decompressor
decompressor: decompressor:
$(MAKE) -C decompressor all BUILDDIR=$(BUILDDIR)/decompressor $(MAKE) -C decompressor all BUILDDIR="$(BUILDDIR)/decompressor"
.PHONY: decompressor-clean .PHONY: decompressor-clean
decompressor-clean: decompressor-clean:
$(MAKE) -C decompressor clean BUILDDIR=$(BUILDDIR)/decompressor $(MAKE) -C decompressor clean BUILDDIR="$(BUILDDIR)/decompressor"
.PHONY: test-clean .PHONY: test-clean
test-clean: test-clean:
@ -197,7 +196,7 @@ toolchain:
MAKE="$(MAKE)" aux/make_toolchain.sh "`pwd`/toolchain" -j$(NCPUS) MAKE="$(MAKE)" aux/make_toolchain.sh "`pwd`/toolchain" -j$(NCPUS)
gnu-efi: gnu-efi:
git clone https://github.com/limine-bootloader/gnu-efi.git --branch=3.0.14 --depth=1 "$@" git clone https://github.com/limine-bootloader/gnu-efi.git --branch=3.0.14 --depth=1 $@
cp aux/elf/* gnu-efi/inc/ cp aux/elf/* gnu-efi/inc/
ovmf-x64: ovmf-x64:

View File

@ -66,6 +66,9 @@ release.
*These steps are not necessary if cloning a binary release. If so, skip to* *These steps are not necessary if cloning a binary release. If so, skip to*
*"Installing Limine binaries".* *"Installing Limine binaries".*
**Note that the build system does not support building from a directory whose**
**full path contains spaces.**
### Building the toolchain ### Building the toolchain
This step can take a long time, but it will ensure that the toolchain will work This step can take a long time, but it will ensure that the toolchain will work

View File

@ -3,7 +3,6 @@ This makefile requires GNU Make.
endif endif
BUILDDIR = BUILDDIR =
override BUILDDIR := $(shell echo '$(BUILDDIR)' | sed 's/ /\\ /g')
ifeq ($(BUILDDIR), ) ifeq ($(BUILDDIR), )
$(error BUILDDIR not specified) $(error BUILDDIR not specified)
@ -70,11 +69,11 @@ all:
$(MAKE) $(BUILDDIR)/decompressor.bin $(MAKE) $(BUILDDIR)/decompressor.bin
builddir: builddir:
for i in $(OBJ); do mkdir -p "`dirname "$$i"`"; done for i in $(OBJ); do mkdir -p `dirname $$i`; done
$(BUILDDIR)/decompressor.bin: $(OBJ) $(BUILDDIR)/tinf/tinfgzip.o $(BUILDDIR)/tinf/tinflate.o $(BUILDDIR)/decompressor.bin: $(OBJ) $(BUILDDIR)/tinf/tinfgzip.o $(BUILDDIR)/tinf/tinflate.o
$(TOOLCHAIN_LD) $(OBJ) $(BUILDDIR)/tinf/tinfgzip.o $(BUILDDIR)/tinf/tinflate.o $(LDFLAGS) $(INTERNAL_LDFLAGS) -o $(BUILDDIR)/decompressor.elf $(TOOLCHAIN_LD) $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -o $(BUILDDIR)/decompressor.elf
$(TOOLCHAIN_OBJCOPY) -O binary $(BUILDDIR)/decompressor.elf "$@" $(TOOLCHAIN_OBJCOPY) -O binary $(BUILDDIR)/decompressor.elf $@
$(BUILDDIR)/tinf-copied: ../tinf/* $(BUILDDIR)/tinf-copied: ../tinf/*
rm -rf $(BUILDDIR)/tinf rm -rf $(BUILDDIR)/tinf
@ -82,15 +81,15 @@ $(BUILDDIR)/tinf-copied: ../tinf/*
touch $(BUILDDIR)/tinf-copied touch $(BUILDDIR)/tinf-copied
$(BUILDDIR)/tinf/tinfgzip.o $(BUILDDIR)/tinf/tinflate.o: $(BUILDDIR)/tinf-copied $(BUILDDIR)/tinf/tinfgzip.o $(BUILDDIR)/tinf/tinflate.o: $(BUILDDIR)/tinf-copied
$(TOOLCHAIN_CC) $(CFLAGS) -Os $(INTERNAL_CFLAGS) -c "$(@:.o=.c)" -o "$@" $(TOOLCHAIN_CC) $(CFLAGS) -Os $(INTERNAL_CFLAGS) -c $(@:.o=.c) -o $@
-include $(HEADER_DEPS) -include $(HEADER_DEPS)
$(BUILDDIR)/%.o: %.c $(BUILDDIR)/tinf-copied $(BUILDDIR)/%.o: %.c $(BUILDDIR)/tinf-copied
$(TOOLCHAIN_CC) $(CFLAGS) -Os $(INTERNAL_CFLAGS) -c "$<" -o "$@" $(TOOLCHAIN_CC) $(CFLAGS) -Os $(INTERNAL_CFLAGS) -c $< -o $@
$(BUILDDIR)/%.o: %.asm $(BUILDDIR)/%.o: %.asm
nasm "$<" -f elf32 -o "$@" nasm $< -f elf32 -o $@
clean: clean:
rm -rf $(BUILDDIR) rm -rf $(BUILDDIR)

View File

@ -10,8 +10,7 @@ CFLAGS = -O2 -pipe -Wall -Wextra
.PHONY: all install clean .PHONY: all install clean
all: all: $(BUILDDIR)/limine-install
$(CC) $(CFLAGS) -std=c11 -DLIMINE_HDD_BIN='"$(LIMINE_HDD_BIN)"' limine-install.c inc.S -o "$(BUILDDIR)/limine-install"
install: all install: all
install -d "$(DESTDIR)$(PREFIX)/bin" install -d "$(DESTDIR)$(PREFIX)/bin"
@ -27,3 +26,6 @@ install: all
clean: clean:
rm -f "$(BUILDDIR)/limine-install" "$(BUILDDIR)/limine-install.exe" rm -f "$(BUILDDIR)/limine-install" "$(BUILDDIR)/limine-install.exe"
$(BUILDDIR)/limine-install: limine-install.c inc.S $(LIMINE_HDD_BIN)
$(CC) $(CFLAGS) -std=c11 -DLIMINE_HDD_BIN='"$(LIMINE_HDD_BIN)"' limine-install.c inc.S -o "$@"

View File

@ -4,7 +4,6 @@ endif
TARGET = TARGET =
BUILDDIR = BUILDDIR =
override BUILDDIR := $(shell echo '$(BUILDDIR)' | sed 's/ /\\ /g')
ifeq ($(BUILDDIR), ) ifeq ($(BUILDDIR), )
$(error BUILDDIR not specified) $(error BUILDDIR not specified)
@ -199,18 +198,18 @@ all:
endif endif
builddir: builddir:
for i in $(OBJ); do mkdir -p "`dirname "$$i"`"; done for i in $(OBJ); do mkdir -p `dirname $$i`; done
$(BUILDDIR)/sys/smp_trampoline.bin: sys/smp_trampoline.real $(BUILDDIR)/sys/smp_trampoline.bin: sys/smp_trampoline.real
nasm "$<" -f bin -o "$@" nasm $< -f bin -o $@
$(BUILDDIR)/sys/smp_trampoline.o: $(BUILDDIR)/sys/smp_trampoline.bin $(BUILDDIR)/sys/smp_trampoline.o: $(BUILDDIR)/sys/smp_trampoline.bin
cd "`dirname "$<"`" && \ cd "`dirname $<`" && \
$(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) "`basename "$<"`" "$@" $(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) "`basename $<`" $@
$(BUILDDIR)/font.o: font.bin $(BUILDDIR)/font.o: font.bin
cd "`dirname "$<"`" && \ cd "`dirname $<`" && \
$(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) "`basename "$<"`" "$@" $(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) "`basename $<`" $@
$(BUILDDIR)/tinf-copied: ../tinf/* $(BUILDDIR)/tinf-copied: ../tinf/*
rm -rf $(BUILDDIR)/tinf rm -rf $(BUILDDIR)/tinf
@ -218,70 +217,70 @@ $(BUILDDIR)/tinf-copied: ../tinf/*
touch $(BUILDDIR)/tinf-copied touch $(BUILDDIR)/tinf-copied
$(BUILDDIR)/tinf/tinfgzip.o $(BUILDDIR)/tinf/tinflate.o: $(BUILDDIR)/tinf-copied $(BUILDDIR)/tinf/tinfgzip.o $(BUILDDIR)/tinf/tinflate.o: $(BUILDDIR)/tinf-copied
$(TOOLCHAIN_CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c "$(@:.o=.c)" -o "$@" $(TOOLCHAIN_CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $(@:.o=.c) -o $@
ifeq ($(TARGET), bios) ifeq ($(TARGET), bios)
$(BUILDDIR)/stage2.bin.gz: $(BUILDDIR)/stage2.bin $(BUILDDIR)/stage2.bin.gz: $(BUILDDIR)/stage2.bin
gzip -n -9 < "$<" > "$@" gzip -n -9 < $< > $@
$(BUILDDIR)/stage2.bin: $(BUILDDIR)/limine.sys $(BUILDDIR)/stage2.bin: $(BUILDDIR)/limine.sys
dd if="$<" bs=$$(( 0x$$($(TOOLCHAIN_READELF) -S $(BUILDDIR)/limine.elf | grep .stage3.text | sed 's/^.*] //' | awk '{print $$3}' | sed 's/^0*//') - 0x8000 )) count=1 of="$@" dd if=$< bs=$$(( 0x$$($(TOOLCHAIN_READELF) -S $(BUILDDIR)/limine.elf | grep .stage3.text | sed 's/^.*] //' | awk '{print $$3}' | sed 's/^0*//') - 0x8000 )) count=1 of=$@
$(BUILDDIR)/stage2.map.o: $(BUILDDIR)/limine_stage2only.elf $(BUILDDIR)/stage2.map.o: $(BUILDDIR)/limine_stage2only.elf
GENSYMS="`pwd`/gensyms.sh" && \ GENSYMS="`pwd`/gensyms.sh" && \
cd "`dirname "$<"`" && \ cd "`dirname $<`" && \
"$$GENSYMS" $(TOOLCHAIN_OBJDUMP) "$<" stage2 32 "$$GENSYMS" $(TOOLCHAIN_OBJDUMP) $< stage2 32
$(BUILDDIR)/full.map.o: $(BUILDDIR)/limine_nomap.elf $(BUILDDIR)/full.map.o: $(BUILDDIR)/limine_nomap.elf
GENSYMS="`pwd`/gensyms.sh" && \ GENSYMS="`pwd`/gensyms.sh" && \
cd "`dirname "$<"`" && \ cd "`dirname $<`" && \
"$$GENSYMS" $(TOOLCHAIN_OBJDUMP) "$<" full 32 "$$GENSYMS" $(TOOLCHAIN_OBJDUMP) $< full 32
$(BUILDDIR)/limine.sys: $(BUILDDIR)/limine.elf $(BUILDDIR)/limine.sys: $(BUILDDIR)/limine.elf
$(TOOLCHAIN_OBJCOPY) -O binary "$<" "$@" $(TOOLCHAIN_OBJCOPY) -O binary $< $@
$(BUILDDIR)/limine_stage2only.elf: $(OBJ) $(BUILDDIR)/limine_stage2only.elf: $(OBJ)
$(TOOLCHAIN_LD) $(OBJ) $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker_stage2only.ld -o "$@" || \ $(TOOLCHAIN_LD) $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker_stage2only.ld -o $@ || \
( echo "This error may mean that stage 2 was trying to use stage 3 symbols before loading stage 3" && \ ( echo "This error may mean that stage 2 was trying to use stage 3 symbols before loading stage 3" && \
false ) false )
$(TOOLCHAIN_OBJCOPY) -O binary --only-section=.note.gnu.build-id "$@" $(BUILDDIR)/build-id.s2.bin $(TOOLCHAIN_OBJCOPY) -O binary --only-section=.note.gnu.build-id $@ $(BUILDDIR)/build-id.s2.bin
cd $(BUILDDIR) && \ cd "$(BUILDDIR)" && \
$(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) build-id.s2.bin build-id.s2.o $(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) build-id.s2.bin build-id.s2.o
$(TOOLCHAIN_OBJCOPY) -O binary --only-section=.note.gnu.build-id "$@" $(BUILDDIR)/build-id.s3.bin $(TOOLCHAIN_OBJCOPY) -O binary --only-section=.note.gnu.build-id $@ $(BUILDDIR)/build-id.s3.bin
cd $(BUILDDIR) && \ cd "$(BUILDDIR)" && \
$(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) build-id.s3.bin build-id.s3.o $(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) build-id.s3.bin build-id.s3.o
$(TOOLCHAIN_LD) $(BUILDDIR)/build-id.s2.o $(BUILDDIR)/build-id.s3.o $(OBJ) $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker_stage2only.ld -o "$@" $(TOOLCHAIN_LD) $(BUILDDIR)/build-id.s2.o $(BUILDDIR)/build-id.s3.o $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker_stage2only.ld -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 $(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) $(OBJ) $(BUILDDIR)/tinf/tinfgzip.o $(BUILDDIR)/tinf/tinflate.o $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(BUILDDIR)/stage2.map.o $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker_nomap.ld -o "$@" $(TOOLCHAIN_LD) $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker_nomap.ld -o $@
$(TOOLCHAIN_OBJCOPY) -O binary --only-section=.note.gnu.build-id "$@" $(BUILDDIR)/build-id.s2.bin $(TOOLCHAIN_OBJCOPY) -O binary --only-section=.note.gnu.build-id $@ $(BUILDDIR)/build-id.s2.bin
cd $(BUILDDIR) && \ cd "$(BUILDDIR)" && \
$(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) build-id.s2.bin build-id.s2.o $(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) build-id.s2.bin build-id.s2.o
$(TOOLCHAIN_OBJCOPY) -O binary --only-section=.note.gnu.build-id "$@" $(BUILDDIR)/build-id.s3.bin $(TOOLCHAIN_OBJCOPY) -O binary --only-section=.note.gnu.build-id $@ $(BUILDDIR)/build-id.s3.bin
cd $(BUILDDIR) && \ cd "$(BUILDDIR)" && \
$(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) build-id.s3.bin build-id.s3.o $(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) build-id.s3.bin build-id.s3.o
$(TOOLCHAIN_LD) $(BUILDDIR)/build-id.s2.o $(BUILDDIR)/build-id.s3.o $(OBJ) $(BUILDDIR)/tinf/tinfgzip.o $(BUILDDIR)/tinf/tinflate.o $(BUILDDIR)/font.o $(BUILDDIR)/sys/smp_trampoline.o $(BUILDDIR)/stage2.map.o $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker_nomap.ld -o "$@" $(TOOLCHAIN_LD) $(BUILDDIR)/build-id.s2.o $(BUILDDIR)/build-id.s3.o $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker_nomap.ld -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 $(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) $(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 $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker.ld -o "$@" $(TOOLCHAIN_LD) $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker.ld -o $@
$(TOOLCHAIN_OBJCOPY) -O binary --only-section=.note.gnu.build-id "$@" $(BUILDDIR)/build-id.s2.bin $(TOOLCHAIN_OBJCOPY) -O binary --only-section=.note.gnu.build-id $@ $(BUILDDIR)/build-id.s2.bin
cd $(BUILDDIR) && \ cd "$(BUILDDIR)" && \
$(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) build-id.s2.bin build-id.s2.o $(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) build-id.s2.bin build-id.s2.o
$(TOOLCHAIN_OBJCOPY) -O binary --only-section=.note.gnu.build-id "$@" $(BUILDDIR)/build-id.s3.bin $(TOOLCHAIN_OBJCOPY) -O binary --only-section=.note.gnu.build-id $@ $(BUILDDIR)/build-id.s3.bin
cd $(BUILDDIR) && \ cd "$(BUILDDIR)" && \
$(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) build-id.s3.bin build-id.s3.o $(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) build-id.s3.bin build-id.s3.o
$(TOOLCHAIN_LD) $(BUILDDIR)/build-id.s2.o $(BUILDDIR)/build-id.s3.o $(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 $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker.ld -o "$@" $(TOOLCHAIN_LD) $(BUILDDIR)/build-id.s2.o $(BUILDDIR)/build-id.s3.o $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker.ld -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 $(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) $(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 $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker_dbg.ld -o "$@" $(TOOLCHAIN_LD) $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker_dbg.ld -o $@
$(TOOLCHAIN_OBJCOPY) -O binary --only-section=.note.gnu.build-id "$@" $(BUILDDIR)/build-id.s2.bin $(TOOLCHAIN_OBJCOPY) -O binary --only-section=.note.gnu.build-id $@ $(BUILDDIR)/build-id.s2.bin
cd $(BUILDDIR) && \ cd "$(BUILDDIR)" && \
$(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) build-id.s2.bin build-id.s2.o $(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) build-id.s2.bin build-id.s2.o
$(TOOLCHAIN_OBJCOPY) -O binary --only-section=.note.gnu.build-id "$@" $(BUILDDIR)/build-id.s3.bin $(TOOLCHAIN_OBJCOPY) -O binary --only-section=.note.gnu.build-id $@ $(BUILDDIR)/build-id.s3.bin
cd $(BUILDDIR) && \ cd "$(BUILDDIR)" && \
$(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) build-id.s3.bin build-id.s3.o $(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) build-id.s3.bin build-id.s3.o
$(TOOLCHAIN_LD) $(BUILDDIR)/build-id.s2.o $(BUILDDIR)/build-id.s3.o $(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 $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker_dbg.ld -o "$@" $(TOOLCHAIN_LD) $(BUILDDIR)/build-id.s2.o $(BUILDDIR)/build-id.s3.o $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker_dbg.ld -o $@
endif endif
@ -289,18 +288,18 @@ $(BUILDDIR)/gnu-efi:
cp -r ../gnu-efi $(BUILDDIR)/ cp -r ../gnu-efi $(BUILDDIR)/
# gnu-efi's build system is broken and fails to actually detect clang. # gnu-efi's build system is broken and fails to actually detect clang.
# This is a workaround. # This is a workaround.
sed 's/-maccumulate-outgoing-args//g' < $(BUILDDIR)/gnu-efi/Make.defaults > sed.tmp sed 's/-maccumulate-outgoing-args//g' < "$(BUILDDIR)/gnu-efi/Make.defaults" > sed.tmp
mv sed.tmp $(BUILDDIR)/gnu-efi/Make.defaults mv sed.tmp "$(BUILDDIR)/gnu-efi/Make.defaults"
ifeq ($(TARGET), uefi) ifeq ($(TARGET), uefi)
$(BUILDDIR)/full.map.o: $(BUILDDIR)/limine_efi_nomap.elf $(BUILDDIR)/full.map.o: $(BUILDDIR)/limine_efi_nomap.elf
GENSYMS="`pwd`/gensyms.sh" && \ GENSYMS="`pwd`/gensyms.sh" && \
cd "`dirname "$<"`" && \ cd "`dirname $<`" && \
"$$GENSYMS" $(TOOLCHAIN_OBJDUMP) "$<" full 64 "$$GENSYMS" $(TOOLCHAIN_OBJDUMP) $< full 64
$(BUILDDIR)/BOOTX64.EFI: $(BUILDDIR)/limine_efi.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 "$<" "$@" $(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)/gnu-efi/gnuefi/crt0-efi-x86_64.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a: $(BUILDDIR)/gnu-efi $(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 $(MAKE) -C $(BUILDDIR)/gnu-efi/gnuefi CC="$(TOOLCHAIN_CC) -m64 -march=x86-64 -mtune=generic" AR="$(TOOLCHAIN_AR)" ARCH=x86_64
@ -308,12 +307,12 @@ $(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-x86_64.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuef
$(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 $(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) \ $(TOOLCHAIN_LD) \
-Tlinker_uefi_nomap.ld \ -Tlinker_uefi_nomap.ld \
$(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 $(LDFLAGS) $(INTERNAL_LDFLAGS) -o "$@" $^ $(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)/tinf/tinfgzip.o $(BUILDDIR)/tinf/tinflate.o $(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) \ $(TOOLCHAIN_LD) \
-Tlinker_uefi.ld \ -Tlinker_uefi.ld \
$(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 $(LDFLAGS) $(INTERNAL_LDFLAGS) -o "$@" $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -o $@
endif endif
@ -321,11 +320,11 @@ ifeq ($(TARGET), uefi32)
$(BUILDDIR)/full.map.o: $(BUILDDIR)/limine_efi_nomap.elf $(BUILDDIR)/full.map.o: $(BUILDDIR)/limine_efi_nomap.elf
GENSYMS="`pwd`/gensyms.sh" && \ GENSYMS="`pwd`/gensyms.sh" && \
cd "`dirname "$<"`" && \ cd "`dirname $<`" && \
"$$GENSYMS" $(TOOLCHAIN_OBJDUMP) "$<" full 32 "$$GENSYMS" $(TOOLCHAIN_OBJDUMP) $< full 32
$(BUILDDIR)/BOOTIA32.EFI: $(BUILDDIR)/limine_efi.elf $(BUILDDIR)/BOOTIA32.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-ia32 --subsystem=10 "$<" "$@" $(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-ia32 --subsystem=10 $< $@
$(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-ia32.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.a: $(BUILDDIR)/gnu-efi $(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=i686 -mtune=generic" AR="$(TOOLCHAIN_AR)" ARCH=ia32 $(MAKE) -C $(BUILDDIR)/gnu-efi/gnuefi CC="$(TOOLCHAIN_CC) -m32 -march=i686 -mtune=generic" AR="$(TOOLCHAIN_AR)" ARCH=ia32
@ -333,12 +332,12 @@ $(BUILDDIR)/gnu-efi/gnuefi/crt0-efi-ia32.o $(BUILDDIR)/gnu-efi/gnuefi/libgnuefi.
$(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 $(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) \ $(TOOLCHAIN_LD) \
-Tlinker_uefi32_nomap.ld \ -Tlinker_uefi32_nomap.ld \
$(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 $(LDFLAGS) $(INTERNAL_LDFLAGS) -o "$@" $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -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 $(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) \ $(TOOLCHAIN_LD) \
-Tlinker_uefi32.ld \ -Tlinker_uefi32.ld \
$(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 $(LDFLAGS) $(INTERNAL_LDFLAGS) -o "$@" $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -o $@
endif endif
@ -346,57 +345,57 @@ endif
ifeq ($(TARGET), uefi) ifeq ($(TARGET), uefi)
$(BUILDDIR)/%.o: %.c $(BUILDDIR)/tinf-copied $(BUILDDIR)/gnu-efi $(BUILDDIR)/%.o: %.c $(BUILDDIR)/tinf-copied $(BUILDDIR)/gnu-efi
$(TOOLCHAIN_CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c "$<" -o "$@" $(TOOLCHAIN_CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@
endif endif
ifeq ($(TARGET), uefi32) ifeq ($(TARGET), uefi32)
$(BUILDDIR)/%.o: %.c $(BUILDDIR)/tinf-copied $(BUILDDIR)/gnu-efi $(BUILDDIR)/%.o: %.c $(BUILDDIR)/tinf-copied $(BUILDDIR)/gnu-efi
$(TOOLCHAIN_CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c "$<" -o "$@" $(TOOLCHAIN_CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@
endif endif
ifeq ($(TARGET), bios) ifeq ($(TARGET), bios)
$(BUILDDIR)/%.o: %.c $(BUILDDIR)/tinf-copied $(BUILDDIR)/%.o: %.c $(BUILDDIR)/tinf-copied
$(TOOLCHAIN_CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c "$<" -o "$@" $(TOOLCHAIN_CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@
endif endif
-include $(HEADER_DEPS) -include $(HEADER_DEPS)
ifeq ($(TARGET), bios) ifeq ($(TARGET), bios)
$(BUILDDIR)/%.s2.o: %.s2.c $(BUILDDIR)/%.s2.o: %.s2.c
$(TOOLCHAIN_CC) $(S2CFLAGS) $(INTERNAL_CFLAGS) -c "$<" -o "$@" $(TOOLCHAIN_CC) $(S2CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@
endif endif
-include $(HEADER_DEPS) -include $(HEADER_DEPS)
ifeq ($(TARGET), uefi) ifeq ($(TARGET), uefi)
$(BUILDDIR)/%.32.o: %.32.c $(BUILDDIR)/gnu-efi $(BUILDDIR)/%.32.o: %.32.c $(BUILDDIR)/gnu-efi
$(TOOLCHAIN_CC) $(CFLAGS) $(INTERNAL_CFLAGS32) -c "$<" -o "$@".32 $(TOOLCHAIN_CC) $(CFLAGS) $(INTERNAL_CFLAGS32) -c $< -o $@.32
$(TOOLCHAIN_OBJCOPY) -I elf32-i386 -O elf64-x86-64 "$@".32 "$@" $(TOOLCHAIN_OBJCOPY) -I elf32-i386 -O elf64-x86-64 $@.32 $@
rm "$@".32 rm $@.32
endif endif
ifeq ($(TARGET), bios) ifeq ($(TARGET), bios)
$(BUILDDIR)/%.o: %.asm32 $(BUILDDIR)/%.o: %.asm32
nasm "$<" -F dwarf -g -Werror -f elf32 -o "$@" nasm $< -F dwarf -g -Werror -f elf32 -o $@
$(BUILDDIR)/%.o: %.asmb $(BUILDDIR)/%.o: %.asmb
nasm "$<" -F dwarf -g -Werror -f elf32 -o "$@" nasm $< -F dwarf -g -Werror -f elf32 -o $@
endif endif
ifeq ($(TARGET), uefi) ifeq ($(TARGET), uefi)
$(BUILDDIR)/%.o: %.asm64 $(BUILDDIR)/%.o: %.asm64
nasm "$<" -F dwarf -g -Werror -f elf64 -o "$@" nasm $< -F dwarf -g -Werror -f elf64 -o $@
$(BUILDDIR)/%.o: %.asm64u $(BUILDDIR)/%.o: %.asm64u
nasm "$<" -F dwarf -g -Werror -f elf64 -o "$@" nasm $< -F dwarf -g -Werror -f elf64 -o $@
endif endif
ifeq ($(TARGET), uefi32) ifeq ($(TARGET), uefi32)
$(BUILDDIR)/%.o: %.asm32 $(BUILDDIR)/%.o: %.asm32
nasm "$<" -F dwarf -g -Werror -f elf32 -o "$@" nasm $< -F dwarf -g -Werror -f elf32 -o $@
$(BUILDDIR)/%.o: %.asm32u $(BUILDDIR)/%.o: %.asm32u
nasm "$<" -F dwarf -g -Werror -f elf32 -o "$@" nasm $< -F dwarf -g -Werror -f elf32 -o $@
endif endif
clean: clean: