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 03fdd5a6d2
commit c5da575520
5 changed files with 96 additions and 94 deletions

View File

@ -6,7 +6,6 @@ PREFIX ?= /usr/local
DESTDIR ?=
BUILDDIR ?= $(shell pwd)/build
override BUILDDIR := $(shell echo '$(BUILDDIR)' | sed 's/ /\\ /g')
BINDIR ?= $(BUILDDIR)/bin
export PATH := $(shell pwd)/toolchain/bin:$(PATH)
@ -58,7 +57,7 @@ all:
.PHONY: 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
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
mkdir -p $(BINDIR)
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/pxe && nasm bootsect.asm -Werror -fbin -DBUILDDIR=\'$(BUILDDIR)\' -o $(BINDIR)/limine-pxe.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/pxe && nasm bootsect.asm -Werror -fbin -DBUILDDIR="'$(BUILDDIR)'" -o $(BINDIR)/limine-pxe.bin
cp $(BUILDDIR)/stage23-bios/limine.sys $(BINDIR)/
touch $(BUILDDIR)/stage1
@ -92,15 +91,15 @@ limine-bios: stage23-bios decompressor
.PHONY: $(BINDIR)/limine-eltorito-efi.bin
$(BINDIR)/limine-eltorito-efi.bin:
mkdir -p $(BINDIR)
dd if=/dev/zero of="$@" bs=512 count=2880
( mformat -i "$@" -f 1440 :: && \
mmd -D s -i "$@" ::/EFI && \
mmd -D s -i "$@" ::/EFI/BOOT && \
dd if=/dev/zero of=$@ bs=512 count=2880
( mformat -i $@ -f 1440 :: && \
mmd -D s -i $@ ::/EFI && \
mmd -D s -i $@ ::/EFI/BOOT && \
( ( [ -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 ] && \
mcopy -D o -i "$@" $(BUILDDIR)/stage23-uefi32/BOOTIA32.EFI ::/EFI/BOOT ) || true ) \
) || rm -f "$@"
mcopy -D o -i $@ $(BUILDDIR)/stage23-uefi32/BOOTIA32.EFI ::/EFI/BOOT ) || true ) \
) || rm -f $@
.PHONY: limine-uefi
limine-uefi:
@ -157,35 +156,35 @@ stivale:
.PHONY: stage23-uefi
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
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
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
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
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
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
decompressor:
$(MAKE) -C decompressor all BUILDDIR=$(BUILDDIR)/decompressor
$(MAKE) -C decompressor all BUILDDIR="$(BUILDDIR)/decompressor"
.PHONY: decompressor-clean
decompressor-clean:
$(MAKE) -C decompressor clean BUILDDIR=$(BUILDDIR)/decompressor
$(MAKE) -C decompressor clean BUILDDIR="$(BUILDDIR)/decompressor"
.PHONY: test-clean
test-clean:
@ -197,7 +196,7 @@ toolchain:
MAKE="$(MAKE)" aux/make_toolchain.sh "`pwd`/toolchain" -j$(NCPUS)
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/
ovmf-x64:

View File

@ -66,6 +66,9 @@ release.
*These steps are not necessary if cloning a binary release. If so, skip to*
*"Installing Limine binaries".*
**Note that the build system does not support building from a directory whose**
**full path contains spaces.**
### Building the toolchain
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
BUILDDIR =
override BUILDDIR := $(shell echo '$(BUILDDIR)' | sed 's/ /\\ /g')
ifeq ($(BUILDDIR), )
$(error BUILDDIR not specified)
@ -70,11 +69,11 @@ all:
$(MAKE) $(BUILDDIR)/decompressor.bin
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
$(TOOLCHAIN_LD) $(OBJ) $(BUILDDIR)/tinf/tinfgzip.o $(BUILDDIR)/tinf/tinflate.o $(LDFLAGS) $(INTERNAL_LDFLAGS) -o $(BUILDDIR)/decompressor.elf
$(TOOLCHAIN_OBJCOPY) -O binary $(BUILDDIR)/decompressor.elf "$@"
$(TOOLCHAIN_LD) $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -o $(BUILDDIR)/decompressor.elf
$(TOOLCHAIN_OBJCOPY) -O binary $(BUILDDIR)/decompressor.elf $@
$(BUILDDIR)/tinf-copied: ../tinf/*
rm -rf $(BUILDDIR)/tinf
@ -82,15 +81,15 @@ $(BUILDDIR)/tinf-copied: ../tinf/*
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 "$@"
$(TOOLCHAIN_CC) $(CFLAGS) -Os $(INTERNAL_CFLAGS) -c $(@:.o=.c) -o $@
-include $(HEADER_DEPS)
$(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
nasm "$<" -f elf32 -o "$@"
nasm $< -f elf32 -o $@
clean:
rm -rf $(BUILDDIR)

View File

@ -10,8 +10,7 @@ CFLAGS = -O2 -pipe -Wall -Wextra
.PHONY: all install clean
all:
$(CC) $(CFLAGS) -std=c11 -DLIMINE_HDD_BIN='"$(LIMINE_HDD_BIN)"' limine-install.c inc.S -o "$(BUILDDIR)/limine-install"
all: $(BUILDDIR)/limine-install
install: all
install -d "$(DESTDIR)$(PREFIX)/bin"
@ -27,3 +26,6 @@ install: all
clean:
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 =
BUILDDIR =
override BUILDDIR := $(shell echo '$(BUILDDIR)' | sed 's/ /\\ /g')
ifeq ($(BUILDDIR), )
$(error BUILDDIR not specified)
@ -199,18 +198,18 @@ all:
endif
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
nasm "$<" -f bin -o "$@"
nasm $< -f bin -o $@
$(BUILDDIR)/sys/smp_trampoline.o: $(BUILDDIR)/sys/smp_trampoline.bin
cd "`dirname "$<"`" && \
$(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) "`basename "$<"`" "$@"
cd "`dirname $<`" && \
$(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) "`basename $<`" $@
$(BUILDDIR)/font.o: font.bin
cd "`dirname "$<"`" && \
$(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) "`basename "$<"`" "$@"
cd "`dirname $<`" && \
$(TOOLCHAIN_OBJCOPY) -B i8086 -I binary -O $(OBJCOPY_ARCH) "`basename $<`" $@
$(BUILDDIR)/tinf-copied: ../tinf/*
rm -rf $(BUILDDIR)/tinf
@ -218,70 +217,70 @@ $(BUILDDIR)/tinf-copied: ../tinf/*
touch $(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)
$(BUILDDIR)/stage2.bin.gz: $(BUILDDIR)/stage2.bin
gzip -n -9 < "$<" > "$@"
gzip -n -9 < $< > $@
$(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
GENSYMS="`pwd`/gensyms.sh" && \
cd "`dirname "$<"`" && \
"$$GENSYMS" $(TOOLCHAIN_OBJDUMP) "$<" stage2 32
cd "`dirname $<`" && \
"$$GENSYMS" $(TOOLCHAIN_OBJDUMP) $< stage2 32
$(BUILDDIR)/full.map.o: $(BUILDDIR)/limine_nomap.elf
GENSYMS="`pwd`/gensyms.sh" && \
cd "`dirname "$<"`" && \
"$$GENSYMS" $(TOOLCHAIN_OBJDUMP) "$<" full 32
cd "`dirname $<`" && \
"$$GENSYMS" $(TOOLCHAIN_OBJDUMP) $< full 32
$(BUILDDIR)/limine.sys: $(BUILDDIR)/limine.elf
$(TOOLCHAIN_OBJCOPY) -O binary "$<" "$@"
$(TOOLCHAIN_OBJCOPY) -O binary $< $@
$(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" && \
false )
$(TOOLCHAIN_OBJCOPY) -O binary --only-section=.note.gnu.build-id "$@" $(BUILDDIR)/build-id.s2.bin
cd $(BUILDDIR) && \
$(TOOLCHAIN_OBJCOPY) -O binary --only-section=.note.gnu.build-id $@ $(BUILDDIR)/build-id.s2.bin
cd "$(BUILDDIR)" && \
$(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
cd $(BUILDDIR) && \
$(TOOLCHAIN_OBJCOPY) -O binary --only-section=.note.gnu.build-id $@ $(BUILDDIR)/build-id.s3.bin
cd "$(BUILDDIR)" && \
$(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
$(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_OBJCOPY) -O binary --only-section=.note.gnu.build-id "$@" $(BUILDDIR)/build-id.s2.bin
cd $(BUILDDIR) && \
$(TOOLCHAIN_LD) $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker_nomap.ld -o $@
$(TOOLCHAIN_OBJCOPY) -O binary --only-section=.note.gnu.build-id $@ $(BUILDDIR)/build-id.s2.bin
cd "$(BUILDDIR)" && \
$(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
cd $(BUILDDIR) && \
$(TOOLCHAIN_OBJCOPY) -O binary --only-section=.note.gnu.build-id $@ $(BUILDDIR)/build-id.s3.bin
cd "$(BUILDDIR)" && \
$(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
$(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_OBJCOPY) -O binary --only-section=.note.gnu.build-id "$@" $(BUILDDIR)/build-id.s2.bin
cd $(BUILDDIR) && \
$(TOOLCHAIN_LD) $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker.ld -o $@
$(TOOLCHAIN_OBJCOPY) -O binary --only-section=.note.gnu.build-id $@ $(BUILDDIR)/build-id.s2.bin
cd "$(BUILDDIR)" && \
$(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
cd $(BUILDDIR) && \
$(TOOLCHAIN_OBJCOPY) -O binary --only-section=.note.gnu.build-id $@ $(BUILDDIR)/build-id.s3.bin
cd "$(BUILDDIR)" && \
$(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
$(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_OBJCOPY) -O binary --only-section=.note.gnu.build-id "$@" $(BUILDDIR)/build-id.s2.bin
cd $(BUILDDIR) && \
$(TOOLCHAIN_LD) $^ $(LDFLAGS) $(INTERNAL_LDFLAGS) -Tlinker_dbg.ld -o $@
$(TOOLCHAIN_OBJCOPY) -O binary --only-section=.note.gnu.build-id $@ $(BUILDDIR)/build-id.s2.bin
cd "$(BUILDDIR)" && \
$(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
cd $(BUILDDIR) && \
$(TOOLCHAIN_OBJCOPY) -O binary --only-section=.note.gnu.build-id $@ $(BUILDDIR)/build-id.s3.bin
cd "$(BUILDDIR)" && \
$(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
@ -289,18 +288,18 @@ $(BUILDDIR)/gnu-efi:
cp -r ../gnu-efi $(BUILDDIR)/
# gnu-efi's build system is broken and fails to actually detect clang.
# This is a workaround.
sed 's/-maccumulate-outgoing-args//g' < $(BUILDDIR)/gnu-efi/Make.defaults > sed.tmp
mv sed.tmp $(BUILDDIR)/gnu-efi/Make.defaults
sed 's/-maccumulate-outgoing-args//g' < "$(BUILDDIR)/gnu-efi/Make.defaults" > sed.tmp
mv sed.tmp "$(BUILDDIR)/gnu-efi/Make.defaults"
ifeq ($(TARGET), uefi)
$(BUILDDIR)/full.map.o: $(BUILDDIR)/limine_efi_nomap.elf
GENSYMS="`pwd`/gensyms.sh" && \
cd "`dirname "$<"`" && \
"$$GENSYMS" $(TOOLCHAIN_OBJDUMP) "$<" full 64
cd "`dirname $<`" && \
"$$GENSYMS" $(TOOLCHAIN_OBJDUMP) $< full 64
$(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
$(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
$(TOOLCHAIN_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
$(TOOLCHAIN_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
@ -321,11 +320,11 @@ ifeq ($(TARGET), uefi32)
$(BUILDDIR)/full.map.o: $(BUILDDIR)/limine_efi_nomap.elf
GENSYMS="`pwd`/gensyms.sh" && \
cd "`dirname "$<"`" && \
"$$GENSYMS" $(TOOLCHAIN_OBJDUMP) "$<" full 32
cd "`dirname $<`" && \
"$$GENSYMS" $(TOOLCHAIN_OBJDUMP) $< full 32
$(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
$(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
$(TOOLCHAIN_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
$(TOOLCHAIN_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
@ -346,57 +345,57 @@ endif
ifeq ($(TARGET), uefi)
$(BUILDDIR)/%.o: %.c $(BUILDDIR)/tinf-copied $(BUILDDIR)/gnu-efi
$(TOOLCHAIN_CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c "$<" -o "$@"
$(TOOLCHAIN_CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@
endif
ifeq ($(TARGET), uefi32)
$(BUILDDIR)/%.o: %.c $(BUILDDIR)/tinf-copied $(BUILDDIR)/gnu-efi
$(TOOLCHAIN_CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c "$<" -o "$@"
$(TOOLCHAIN_CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@
endif
ifeq ($(TARGET), bios)
$(BUILDDIR)/%.o: %.c $(BUILDDIR)/tinf-copied
$(TOOLCHAIN_CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c "$<" -o "$@"
$(TOOLCHAIN_CC) $(CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@
endif
-include $(HEADER_DEPS)
ifeq ($(TARGET), bios)
$(BUILDDIR)/%.s2.o: %.s2.c
$(TOOLCHAIN_CC) $(S2CFLAGS) $(INTERNAL_CFLAGS) -c "$<" -o "$@"
$(TOOLCHAIN_CC) $(S2CFLAGS) $(INTERNAL_CFLAGS) -c $< -o $@
endif
-include $(HEADER_DEPS)
ifeq ($(TARGET), uefi)
$(BUILDDIR)/%.32.o: %.32.c $(BUILDDIR)/gnu-efi
$(TOOLCHAIN_CC) $(CFLAGS) $(INTERNAL_CFLAGS32) -c "$<" -o "$@".32
$(TOOLCHAIN_OBJCOPY) -I elf32-i386 -O elf64-x86-64 "$@".32 "$@"
rm "$@".32
$(TOOLCHAIN_CC) $(CFLAGS) $(INTERNAL_CFLAGS32) -c $< -o $@.32
$(TOOLCHAIN_OBJCOPY) -I elf32-i386 -O elf64-x86-64 $@.32 $@
rm $@.32
endif
ifeq ($(TARGET), bios)
$(BUILDDIR)/%.o: %.asm32
nasm "$<" -F dwarf -g -Werror -f elf32 -o "$@"
nasm $< -F dwarf -g -Werror -f elf32 -o $@
$(BUILDDIR)/%.o: %.asmb
nasm "$<" -F dwarf -g -Werror -f elf32 -o "$@"
nasm $< -F dwarf -g -Werror -f elf32 -o $@
endif
ifeq ($(TARGET), uefi)
$(BUILDDIR)/%.o: %.asm64
nasm "$<" -F dwarf -g -Werror -f elf64 -o "$@"
nasm $< -F dwarf -g -Werror -f elf64 -o $@
$(BUILDDIR)/%.o: %.asm64u
nasm "$<" -F dwarf -g -Werror -f elf64 -o "$@"
nasm $< -F dwarf -g -Werror -f elf64 -o $@
endif
ifeq ($(TARGET), uefi32)
$(BUILDDIR)/%.o: %.asm32
nasm "$<" -F dwarf -g -Werror -f elf32 -o "$@"
nasm $< -F dwarf -g -Werror -f elf32 -o $@
$(BUILDDIR)/%.o: %.asm32u
nasm "$<" -F dwarf -g -Werror -f elf32 -o "$@"
nasm $< -F dwarf -g -Werror -f elf32 -o $@
endif
clean: