build: Updates for newer freestanding-toolchain

This commit is contained in:
mintsuki 2023-03-14 17:20:46 +01:00
parent 674f490f7b
commit 9009404a11
10 changed files with 158 additions and 172 deletions

View File

@ -19,10 +19,10 @@ jobs:
run: git config --global --add safe.directory "$GITHUB_WORKSPACE" run: git config --global --add safe.directory "$GITHUB_WORKSPACE"
- name: Build the bootloader (LLVM) - name: Build the bootloader (LLVM)
run: ./bootstrap && ./configure CROSS_TOOLCHAIN=llvm --enable-werror --enable-all && make all && make maintainer-clean run: ./bootstrap && ./configure FREESTANDING_TOOLCHAIN=llvm --enable-werror --enable-all && make all && make maintainer-clean
- name: Build the bootloader (GCC, x86) - name: Build the bootloader (GNU, x86)
run: ./bootstrap && ./configure CROSS_CC=gcc CROSS_LD=ld CROSS_OBJCOPY=objcopy CROSS_OBJDUMP=objdump CROSS_READELF=readelf --enable-werror --enable-bios --enable-uefi-ia32 --enable-uefi-x86_64 && make all && make maintainer-clean run: ./bootstrap && ./configure FREESTANDING_TOOLCHAIN=gnu --enable-werror --enable-bios --enable-uefi-ia32 --enable-uefi-x86_64 && make all && make maintainer-clean
- name: Build the bootloader (GCC, aarch64) - name: Build the bootloader (GNU, aarch64)
run: ./bootstrap && ./configure CROSS_TOOLCHAIN=aarch64-linux-gnu --enable-werror --enable-uefi-aarch64 && make all && make maintainer-clean run: ./bootstrap && ./configure FREESTANDING_TOOLCHAIN=aarch64-linux-gnu --enable-werror --enable-uefi-aarch64 && make all && make maintainer-clean

View File

@ -36,7 +36,7 @@ jobs:
run: mkdir -p build run: mkdir -p build
- name: Configure - name: Configure
run: cd build && ../configure --enable-all CROSS_TOOLCHAIN=llvm run: cd build && ../configure --enable-all FREESTANDING_TOOLCHAIN=llvm
- name: Build the bootloader - name: Build the bootloader
run: make -C build run: make -C build

2
.gitignore vendored
View File

@ -1,6 +1,6 @@
/bin /bin
/build /build
/cross-files /toolchain-files
/limine-efi /limine-efi
/freestanding-headers /freestanding-headers
/libgcc-binaries /libgcc-binaries

View File

@ -76,12 +76,12 @@ export LDFLAGS
LIBS ?= @LIBS@ LIBS ?= @LIBS@
export LIBS export LIBS
CROSS_CFLAGS ?= @CROSS_CFLAGS@ FREESTANDING_CFLAGS ?= @FREESTANDING_CFLAGS@
export CROSS_CFLAGS export FREESTANDING_CFLAGS
CROSS_CPPFLAGS ?= @CROSS_CPPFLAGS@ FREESTANDING_CPPFLAGS ?= @FREESTANDING_CPPFLAGS@
export CROSS_CPPFLAGS export FREESTANDING_CPPFLAGS
CROSS_LDFLAGS ?= @CROSS_LDFLAGS@ FREESTANDING_LDFLAGS ?= @FREESTANDING_LDFLAGS@
export CROSS_LDFLAGS export FREESTANDING_LDFLAGS
override LIMINE_VERSION := @PACKAGE_VERSION@ override LIMINE_VERSION := @PACKAGE_VERSION@
@ -317,7 +317,7 @@ dist:
.PHONY: distclean .PHONY: distclean
distclean: clean distclean: clean
rm -rf ovmf* config.log config.status GNUmakefile config.h cross-files man/man1/limine-version.1 man/man1/limine-deploy.1 man/man1/limine-enroll-config.1 rm -rf ovmf* config.log config.status GNUmakefile config.h toolchain-files man/man1/limine-version.1 man/man1/limine-deploy.1 man/man1/limine-enroll-config.1
.PHONY: maintainer-clean .PHONY: maintainer-clean
maintainer-clean: distclean maintainer-clean: distclean
@ -326,7 +326,7 @@ maintainer-clean: distclean
.PHONY: common-uefi-x86-64 .PHONY: common-uefi-x86-64
common-uefi-x86-64: common-uefi-x86-64:
$(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/common' all \ $(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/common' all \
CROSS_FILE='$(call SHESCAPE,$(BUILDDIR))/cross-files/uefi-x86_64-toolchain.mk' \ TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-x86_64-toolchain.mk' \
TARGET=uefi-x86-64 \ TARGET=uefi-x86-64 \
BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/common-uefi-x86-64' BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/common-uefi-x86-64'
@ -337,7 +337,7 @@ common-uefi-x86-64-clean:
.PHONY: common-uefi-aarch64 .PHONY: common-uefi-aarch64
common-uefi-aarch64: common-uefi-aarch64:
$(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/common' all \ $(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/common' all \
CROSS_FILE='$(call SHESCAPE,$(BUILDDIR))/cross-files/uefi-aarch64-toolchain.mk' \ TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-aarch64-toolchain.mk' \
TARGET=uefi-aarch64 \ TARGET=uefi-aarch64 \
BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/common-uefi-aarch64' BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/common-uefi-aarch64'
@ -348,7 +348,7 @@ common-uefi-aarch64-clean:
.PHONY: common-uefi-ia32 .PHONY: common-uefi-ia32
common-uefi-ia32: common-uefi-ia32:
$(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/common' all \ $(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/common' all \
CROSS_FILE='$(call SHESCAPE,$(BUILDDIR))/cross-files/uefi-i686-toolchain.mk' \ TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-i686-toolchain.mk' \
TARGET=uefi-ia32 \ TARGET=uefi-ia32 \
BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/common-uefi-ia32' BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/common-uefi-ia32'
@ -359,7 +359,7 @@ common-uefi-ia32-clean:
.PHONY: common-bios .PHONY: common-bios
common-bios: common-bios:
$(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/common' all \ $(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/common' all \
CROSS_FILE='$(call SHESCAPE,$(BUILDDIR))/cross-files/bios-i686-toolchain.mk' \ TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/bios-i686-toolchain.mk' \
TARGET=bios \ TARGET=bios \
BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/common-bios' BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/common-bios'
@ -370,7 +370,7 @@ common-bios-clean:
.PHONY: decompressor .PHONY: decompressor
decompressor: decompressor:
$(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/decompressor' all \ $(MAKE) -C '$(call SHESCAPE,$(SRCDIR))/decompressor' all \
CROSS_FILE='$(call SHESCAPE,$(BUILDDIR))/cross-files/bios-i686-toolchain.mk' \ TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/bios-i686-toolchain.mk' \
BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/decompressor-build' BUILDDIR='$(call SHESCAPE,$(BUILDDIR))/decompressor-build'
.PHONY: decompressor-clean .PHONY: decompressor-clean
@ -413,7 +413,7 @@ ext2-test:
$(MAKE) test.hdd $(MAKE) test.hdd
$(MAKE) limine-bios $(MAKE) limine-bios
$(MAKE) limine-deploy $(MAKE) limine-deploy
$(MAKE) -C test CROSS_FILE='$(call SHESCAPE,$(BUILDDIR))/cross-files/uefi-x86_64-toolchain.mk' $(MAKE) -C test TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-x86_64-toolchain.mk'
rm -rf test_image/ rm -rf test_image/
mkdir test_image mkdir test_image
sudo losetup -Pf --show test.hdd > loopback_dev sudo losetup -Pf --show test.hdd > loopback_dev
@ -436,7 +436,7 @@ fat12-test:
$(MAKE) test.hdd $(MAKE) test.hdd
$(MAKE) limine-bios $(MAKE) limine-bios
$(MAKE) limine-deploy $(MAKE) limine-deploy
$(MAKE) -C test CROSS_FILE='$(call SHESCAPE,$(BUILDDIR))/cross-files/uefi-x86_64-toolchain.mk' $(MAKE) -C test TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-x86_64-toolchain.mk'
rm -rf test_image/ rm -rf test_image/
mkdir test_image mkdir test_image
sudo losetup -Pf --show test.hdd > loopback_dev sudo losetup -Pf --show test.hdd > loopback_dev
@ -459,7 +459,7 @@ fat16-test:
$(MAKE) test.hdd $(MAKE) test.hdd
$(MAKE) limine-bios $(MAKE) limine-bios
$(MAKE) limine-deploy $(MAKE) limine-deploy
$(MAKE) -C test CROSS_FILE='$(call SHESCAPE,$(BUILDDIR))/cross-files/uefi-x86_64-toolchain.mk' $(MAKE) -C test TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-x86_64-toolchain.mk'
rm -rf test_image/ rm -rf test_image/
mkdir test_image mkdir test_image
sudo losetup -Pf --show test.hdd > loopback_dev sudo losetup -Pf --show test.hdd > loopback_dev
@ -483,7 +483,7 @@ legacy-fat16-test:
fdisk -l mbrtest.hdd fdisk -l mbrtest.hdd
$(MAKE) limine-bios $(MAKE) limine-bios
$(MAKE) limine-deploy $(MAKE) limine-deploy
$(MAKE) -C test CROSS_FILE='$(call SHESCAPE,$(BUILDDIR))/cross-files/uefi-x86_64-toolchain.mk' $(MAKE) -C test TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-x86_64-toolchain.mk'
rm -rf test_image/ rm -rf test_image/
mkdir test_image mkdir test_image
sudo losetup -Pf --show mbrtest.hdd > loopback_dev sudo losetup -Pf --show mbrtest.hdd > loopback_dev
@ -506,7 +506,7 @@ fat32-test:
$(MAKE) test.hdd $(MAKE) test.hdd
$(MAKE) limine-bios $(MAKE) limine-bios
$(MAKE) limine-deploy $(MAKE) limine-deploy
$(MAKE) -C test CROSS_FILE='$(call SHESCAPE,$(BUILDDIR))/cross-files/uefi-x86_64-toolchain.mk' $(MAKE) -C test TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-x86_64-toolchain.mk'
rm -rf test_image/ rm -rf test_image/
mkdir test_image mkdir test_image
sudo losetup -Pf --show test.hdd > loopback_dev sudo losetup -Pf --show test.hdd > loopback_dev
@ -528,7 +528,7 @@ iso9660-test:
$(MAKE) test-clean $(MAKE) test-clean
$(MAKE) test.hdd $(MAKE) test.hdd
$(MAKE) limine-bios $(MAKE) limine-bios
$(MAKE) -C test CROSS_FILE='$(call SHESCAPE,$(BUILDDIR))/cross-files/uefi-x86_64-toolchain.mk' $(MAKE) -C test TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-x86_64-toolchain.mk'
rm -rf test_image/ rm -rf test_image/
$(MKDIR_P) test_image/boot $(MKDIR_P) test_image/boot
sudo cp -rv $(BINDIR)/* test_image/boot/ sudo cp -rv $(BINDIR)/* test_image/boot/
@ -542,7 +542,7 @@ full-hybrid-test:
$(MAKE) ovmf-ia32 $(MAKE) ovmf-ia32
$(MAKE) test-clean $(MAKE) test-clean
$(MAKE) all $(MAKE) all
$(MAKE) -C test CROSS_FILE='$(call SHESCAPE,$(BUILDDIR))/cross-files/uefi-x86_64-toolchain.mk' $(MAKE) -C test TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-x86_64-toolchain.mk'
rm -rf test_image/ rm -rf test_image/
$(MKDIR_P) test_image/boot $(MKDIR_P) test_image/boot
sudo cp -rv $(BINDIR)/* test_image/boot/ sudo cp -rv $(BINDIR)/* test_image/boot/
@ -560,7 +560,7 @@ full-hybrid-test:
pxe-test: pxe-test:
$(MAKE) test-clean $(MAKE) test-clean
$(MAKE) limine-bios $(MAKE) limine-bios
$(MAKE) -C test CROSS_FILE='$(call SHESCAPE,$(BUILDDIR))/cross-files/uefi-x86_64-toolchain.mk' $(MAKE) -C test TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-x86_64-toolchain.mk'
rm -rf test_image/ rm -rf test_image/
$(MKDIR_P) test_image/boot $(MKDIR_P) test_image/boot
sudo cp -rv $(BINDIR)/* test_image/boot/ sudo cp -rv $(BINDIR)/* test_image/boot/
@ -573,7 +573,7 @@ uefi-x86-64-test:
$(MAKE) test-clean $(MAKE) test-clean
$(MAKE) test.hdd $(MAKE) test.hdd
$(MAKE) limine-uefi-x86-64 $(MAKE) limine-uefi-x86-64
$(MAKE) -C test CROSS_FILE='$(call SHESCAPE,$(BUILDDIR))/cross-files/uefi-x86_64-toolchain.mk' $(MAKE) -C test TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-x86_64-toolchain.mk'
rm -rf test_image/ rm -rf test_image/
mkdir test_image mkdir test_image
sudo losetup -Pf --show test.hdd > loopback_dev sudo losetup -Pf --show test.hdd > loopback_dev
@ -597,7 +597,7 @@ uefi-aa64-test:
$(MAKE) test-clean $(MAKE) test-clean
$(MAKE) test.hdd $(MAKE) test.hdd
$(MAKE) limine-uefi-aarch64 $(MAKE) limine-uefi-aarch64
$(MAKE) -C test CROSS_FILE='$(call SHESCAPE,$(BUILDDIR))/cross-files/uefi-aarch64-toolchain.mk' $(MAKE) -C test TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-aarch64-toolchain.mk'
rm -rf test_image/ rm -rf test_image/
mkdir test_image mkdir test_image
sudo losetup -Pf --show test.hdd > loopback_dev sudo losetup -Pf --show test.hdd > loopback_dev
@ -621,7 +621,7 @@ uefi-ia32-test:
$(MAKE) test-clean $(MAKE) test-clean
$(MAKE) test.hdd $(MAKE) test.hdd
$(MAKE) limine-uefi-ia32 $(MAKE) limine-uefi-ia32
$(MAKE) -C test CROSS_FILE='$(call SHESCAPE,$(BUILDDIR))/cross-files/uefi-x86_64-toolchain.mk' $(MAKE) -C test TOOLCHAIN_FILE='$(call SHESCAPE,$(BUILDDIR))/toolchain-files/uefi-x86_64-toolchain.mk'
rm -rf test_image/ rm -rf test_image/
mkdir test_image mkdir test_image
sudo losetup -Pf --show test.hdd > loopback_dev sudo losetup -Pf --show test.hdd > loopback_dev

View File

@ -95,8 +95,6 @@ these, run `./configure --help`.
**`./configure` by default does not build any Limine port. Make sure to read the** **`./configure` by default does not build any Limine port. Make sure to read the**
**output of `./configure --help` and enable any or all ports!** **output of `./configure --help` and enable any or all ports!**
To build using the LLVM toolchain, pass `CROSS_TOOLCHAIN=llvm` to `./configure`.
Limine supports both in-tree and out-of-tree builds. Simply run the `configure` Limine supports both in-tree and out-of-tree builds. Simply run the `configure`
script from the directory you wish to execute the build in. The following `make` script from the directory you wish to execute the build in. The following `make`
commands are supposed to be ran inside the build directory. commands are supposed to be ran inside the build directory.

View File

@ -1,6 +1,6 @@
override MAKEFLAGS += -rR override MAKEFLAGS += -rR
include $(CROSS_FILE) include $(TOOLCHAIN_FILE)
TARGET ?= TARGET ?=
BUILDDIR ?= BUILDDIR ?=
@ -34,9 +34,9 @@ E9_OUTPUT ?= false
override S2CFLAGS := -Os override S2CFLAGS := -Os
override BASE_CFLAGS := $(CROSS_CFLAGS) override BASE_CFLAGS := $(FREESTANDING_CFLAGS)
override CROSS_CFLAGS += \ override FREESTANDING_CFLAGS += \
-g \ -g \
-std=gnu11 \ -std=gnu11 \
-nostdinc \ -nostdinc \
@ -49,31 +49,31 @@ override CROSS_CFLAGS += \
-Wshadow \ -Wshadow \
-Wvla -Wvla
override CROSS_CPPFLAGS := \ override FREESTANDING_CPPFLAGS := \
-I../freestanding-headers \ -I../freestanding-headers \
-I'$(call SHESCAPE,$(BUILDDIR))/..' \ -I'$(call SHESCAPE,$(BUILDDIR))/..' \
-I. \ -I. \
-I.. \ -I.. \
$(CROSS_CPPFLAGS) \ $(FREESTANDING_CPPFLAGS) \
-DCOM_OUTPUT=$(COM_OUTPUT) \ -DCOM_OUTPUT=$(COM_OUTPUT) \
-DE9_OUTPUT=$(E9_OUTPUT) \ -DE9_OUTPUT=$(E9_OUTPUT) \
-MMD -MMD
ifeq ($(TARGET),bios) ifeq ($(TARGET),bios)
override CROSS_CFLAGS += \ override FREESTANDING_CFLAGS += \
-fno-pie \ -fno-pie \
-fno-pic \ -fno-pic \
-m32 \ -m32 \
-march=i686 \ -march=i686 \
-mabi=sysv \ -mabi=sysv \
-mno-80387 -mno-80387
override CROSS_CPPFLAGS := \ override FREESTANDING_CPPFLAGS := \
$(CROSS_CPPFLAGS) \ $(FREESTANDING_CPPFLAGS) \
-DBIOS -DBIOS
endif endif
ifeq ($(TARGET),uefi-x86-64) ifeq ($(TARGET),uefi-x86-64)
override CROSS_CFLAGS += \ override FREESTANDING_CFLAGS += \
-fpie \ -fpie \
-m64 \ -m64 \
-march=x86-64 \ -march=x86-64 \
@ -83,56 +83,56 @@ ifeq ($(TARGET),uefi-x86-64)
-mno-sse \ -mno-sse \
-mno-sse2 \ -mno-sse2 \
-mno-red-zone -mno-red-zone
override CROSS_CPPFLAGS := \ override FREESTANDING_CPPFLAGS := \
-I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc' \ -I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc' \
-I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc/x86_64' \ -I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc/x86_64' \
$(CROSS_CPPFLAGS) \ $(FREESTANDING_CPPFLAGS) \
-DUEFI \ -DUEFI \
-DGNU_EFI_USE_MS_ABI -DGNU_EFI_USE_MS_ABI
endif endif
ifeq ($(TARGET),uefi-ia32) ifeq ($(TARGET),uefi-ia32)
override CROSS_CFLAGS += \ override FREESTANDING_CFLAGS += \
-fpie \ -fpie \
-m32 \ -m32 \
-march=i686 \ -march=i686 \
-mabi=sysv \ -mabi=sysv \
-mno-80387 -mno-80387
override CROSS_CPPFLAGS := \ override FREESTANDING_CPPFLAGS := \
-I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc' \ -I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc' \
-I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc/ia32' \ -I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc/ia32' \
$(CROSS_CPPFLAGS) \ $(FREESTANDING_CPPFLAGS) \
-DUEFI -DUEFI
endif endif
ifeq ($(TARGET),uefi-aarch64) ifeq ($(TARGET),uefi-aarch64)
override CROSS_CFLAGS += \ override FREESTANDING_CFLAGS += \
-fpie \ -fpie \
-mgeneral-regs-only -mgeneral-regs-only
override CROSS_CPPFLAGS := \ override FREESTANDING_CPPFLAGS := \
-I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc' \ -I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc' \
-I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc/aarch64' \ -I'$(call SHESCAPE,$(BUILDDIR))/limine-efi/inc/aarch64' \
$(CROSS_CPPFLAGS) \ $(FREESTANDING_CPPFLAGS) \
-DUEFI -DUEFI
endif endif
override CROSS_LDFLAGS += \ override FREESTANDING_LDFLAGS += \
-nostdlib \ -nostdlib \
-z max-page-size=0x1000 -z max-page-size=0x1000
ifeq ($(TARGET),bios) ifeq ($(TARGET),bios)
override CROSS_LDFLAGS += \ override FREESTANDING_LDFLAGS += \
-m elf_i386 \ -m elf_i386 \
-static \ -static \
--build-id=sha1 --build-id=sha1
ifeq ($(CROSS_LD_HAS_NO_PIE),yes) ifeq ($(FREESTANDING_LD_HAS_NO_PIE),yes)
override CROSS_LDFLAGS += -no-pie override FREESTANDING_LDFLAGS += -no-pie
endif endif
endif endif
ifeq ($(TARGET),uefi-x86-64) ifeq ($(TARGET),uefi-x86-64)
override CROSS_LDFLAGS += \ override FREESTANDING_LDFLAGS += \
-m elf_x86_64 \ -m elf_x86_64 \
-static \ -static \
-pie \ -pie \
@ -141,7 +141,7 @@ ifeq ($(TARGET),uefi-x86-64)
endif endif
ifeq ($(TARGET),uefi-ia32) ifeq ($(TARGET),uefi-ia32)
override CROSS_LDFLAGS += \ override FREESTANDING_LDFLAGS += \
-m elf_i386 \ -m elf_i386 \
-static \ -static \
-pie \ -pie \
@ -150,7 +150,7 @@ ifeq ($(TARGET),uefi-ia32)
endif endif
ifeq ($(TARGET),uefi-aarch64) ifeq ($(TARGET),uefi-aarch64)
override CROSS_LDFLAGS += \ override FREESTANDING_LDFLAGS += \
-m aarch64elf \ -m aarch64elf \
-static \ -static \
-pie \ -pie \
@ -208,77 +208,77 @@ $(call MKESCAPE,$(BUILDDIR))/stage2.bin.gz: $(call MKESCAPE,$(BUILDDIR))/stage2.
gzip -n -9 < '$(call SHESCAPE,$<)' > '$(call SHESCAPE,$@)' gzip -n -9 < '$(call SHESCAPE,$<)' > '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/stage2.bin: $(call MKESCAPE,$(BUILDDIR))/limine.sys $(call MKESCAPE,$(BUILDDIR))/stage2.bin: $(call MKESCAPE,$(BUILDDIR))/limine.sys
dd if='$(call SHESCAPE,$<)' bs=$$(( 0x$$("$(CROSS_READELF)" -S '$(call SHESCAPE,$(BUILDDIR))/limine.elf' | $(GREP) '\.text\.stage3' | $(SED) 's/^.*] //' | $(AWK) '{print $$3}' | $(SED) 's/^0*//') - 0xf000 )) count=1 of='$(call SHESCAPE,$@)' 2>/dev/null dd if='$(call SHESCAPE,$<)' bs=$$(( 0x$$("$(FREESTANDING_READELF)" -S '$(call SHESCAPE,$(BUILDDIR))/limine.elf' | $(GREP) '\.text\.stage3' | $(SED) 's/^.*] //' | $(AWK) '{print $$3}' | $(SED) 's/^0*//') - 0xf000 )) count=1 of='$(call SHESCAPE,$@)' 2>/dev/null
$(call MKESCAPE,$(BUILDDIR))/stage2.map.o: $(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf $(call MKESCAPE,$(BUILDDIR))/stage2.map.o: $(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf
cd '$(call SHESCAPE,$(BUILDDIR))' && \ cd '$(call SHESCAPE,$(BUILDDIR))' && \
'$(call SHESCAPE,$(SRCDIR))/gensyms.sh' '$(call SHESCAPE,$<)' stage2 32 '\.text\.stage2' '$(call SHESCAPE,$(SRCDIR))/gensyms.sh' '$(call SHESCAPE,$<)' stage2 32 '\.text\.stage2'
$(CROSS_CC) $(CROSS_CFLAGS) $(CROSS_CPPFLAGS) -c '$(call SHESCAPE,$(BUILDDIR))/stage2.map.S' -o '$(call SHESCAPE,$@)' $(FREESTANDING_CC) $(FREESTANDING_CFLAGS) $(FREESTANDING_CPPFLAGS) -c '$(call SHESCAPE,$(BUILDDIR))/stage2.map.S' -o '$(call SHESCAPE,$@)'
rm -f '$(call SHESCAPE,$(BUILDDIR))/stage2.map.S' '$(call SHESCAPE,$(BUILDDIR))/stage2.map.d' rm -f '$(call SHESCAPE,$(BUILDDIR))/stage2.map.S' '$(call SHESCAPE,$(BUILDDIR))/stage2.map.d'
$(call MKESCAPE,$(BUILDDIR))/full.map.o: $(call MKESCAPE,$(BUILDDIR))/limine_nos3map.elf $(call MKESCAPE,$(BUILDDIR))/full.map.o: $(call MKESCAPE,$(BUILDDIR))/limine_nos3map.elf
cd '$(call SHESCAPE,$(BUILDDIR))' && \ cd '$(call SHESCAPE,$(BUILDDIR))' && \
'$(call SHESCAPE,$(SRCDIR))/gensyms.sh' '$(call SHESCAPE,$<)' full 32 '\.text' '$(call SHESCAPE,$(SRCDIR))/gensyms.sh' '$(call SHESCAPE,$<)' full 32 '\.text'
$(CROSS_CC) $(CROSS_CFLAGS) $(CROSS_CPPFLAGS) -c '$(call SHESCAPE,$(BUILDDIR))/full.map.S' -o '$(call SHESCAPE,$@)' $(FREESTANDING_CC) $(FREESTANDING_CFLAGS) $(FREESTANDING_CPPFLAGS) -c '$(call SHESCAPE,$(BUILDDIR))/full.map.S' -o '$(call SHESCAPE,$@)'
rm -f '$(call SHESCAPE,$(BUILDDIR))/full.map.S' '$(call SHESCAPE,$(BUILDDIR))/full.map.d' rm -f '$(call SHESCAPE,$(BUILDDIR))/full.map.S' '$(call SHESCAPE,$(BUILDDIR))/full.map.d'
$(call MKESCAPE,$(BUILDDIR))/limine.sys: $(call MKESCAPE,$(BUILDDIR))/limine_stage2only.elf $(call MKESCAPE,$(BUILDDIR))/limine.elf $(call MKESCAPE,$(BUILDDIR))/limine.sys: $(call MKESCAPE,$(BUILDDIR))/limine_stage2only.elf $(call MKESCAPE,$(BUILDDIR))/limine.elf
$(CROSS_OBJCOPY) -O binary '$(call SHESCAPE,$(BUILDDIR))/limine.elf' '$(call SHESCAPE,$@)' $(FREESTANDING_OBJCOPY) -O binary '$(call SHESCAPE,$(BUILDDIR))/limine.elf' '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/linker_stage2only.ld: linker_bios.ld.in $(call MKESCAPE,$(BUILDDIR))/linker_stage2only.ld: linker_bios.ld.in
$(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))' $(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))'
$(CROSS_CC) -x c -E -P -undef -DLINKER_STAGE2ONLY linker_bios.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker_stage2only.ld' $(FREESTANDING_CC) -x c -E -P -undef -DLINKER_STAGE2ONLY linker_bios.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker_stage2only.ld'
$(call MKESCAPE,$(BUILDDIR))/limine_stage2only.elf: $(OBJ_S2) ../libgcc-binaries/libgcc-i686.a $(call MKESCAPE,$(BUILDDIR))/limine_stage2only.elf: $(OBJ_S2) ../libgcc-binaries/libgcc-i686.a
$(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker_stage2only.ld' $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker_stage2only.ld'
$(CROSS_LD) '$(call OBJESCAPE,$^)' $(CROSS_LDFLAGS) -T'$(call SHESCAPE,$(BUILDDIR))/linker_stage2only.ld' -o '$(call SHESCAPE,$@)' || \ $(FREESTANDING_LD) '$(call OBJESCAPE,$^)' $(FREESTANDING_LDFLAGS) -T'$(call SHESCAPE,$(BUILDDIR))/linker_stage2only.ld' -o '$(call SHESCAPE,$@)' || \
( 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 )
$(call MKESCAPE,$(BUILDDIR))/linker_nos2map.ld: linker_bios.ld.in $(call MKESCAPE,$(BUILDDIR))/linker_nos2map.ld: linker_bios.ld.in
$(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))' $(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))'
$(CROSS_CC) -x c -E -P -undef -DLINKER_NOMAP -DLINKER_NOS2MAP linker_bios.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker_nos2map.ld' $(FREESTANDING_CC) -x c -E -P -undef -DLINKER_NOMAP -DLINKER_NOS2MAP linker_bios.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker_nos2map.ld'
$(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf: $(OBJ) ../libgcc-binaries/libgcc-i686.a $(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf: $(OBJ) ../libgcc-binaries/libgcc-i686.a
$(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker_nos2map.ld' $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker_nos2map.ld'
$(CROSS_LD) '$(call OBJESCAPE,$^)' $(CROSS_LDFLAGS) -T'$(call SHESCAPE,$(BUILDDIR))/linker_nos2map.ld' -o '$(call SHESCAPE,$@)' $(FREESTANDING_LD) '$(call OBJESCAPE,$^)' $(FREESTANDING_LDFLAGS) -T'$(call SHESCAPE,$(BUILDDIR))/linker_nos2map.ld' -o '$(call SHESCAPE,$@)'
$(CROSS_OBJCOPY) -O binary --only-section=.note.gnu.build-id '$(call SHESCAPE,$@)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s2.bin' $(FREESTANDING_OBJCOPY) -O binary --only-section=.note.gnu.build-id '$(call SHESCAPE,$@)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s2.bin'
cd '$(call SHESCAPE,$(BUILDDIR))' && \ cd '$(call SHESCAPE,$(BUILDDIR))' && \
$(CROSS_OBJCOPY) -I binary $(OBJCOPY2ELF_FLAGS) build-id.s2.bin build-id.s2.o $(FREESTANDING_OBJCOPY) -I binary $(OBJCOPY2ELF_FLAGS) build-id.s2.bin build-id.s2.o
$(CROSS_OBJCOPY) -O binary --only-section=.note.gnu.build-id '$(call SHESCAPE,$@)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s3.bin' $(FREESTANDING_OBJCOPY) -O binary --only-section=.note.gnu.build-id '$(call SHESCAPE,$@)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s3.bin'
cd '$(call SHESCAPE,$(BUILDDIR))' && \ cd '$(call SHESCAPE,$(BUILDDIR))' && \
$(CROSS_OBJCOPY) -I binary $(OBJCOPY2ELF_FLAGS) build-id.s3.bin build-id.s3.o $(FREESTANDING_OBJCOPY) -I binary $(OBJCOPY2ELF_FLAGS) build-id.s3.bin build-id.s3.o
$(CROSS_LD) '$(call OBJESCAPE,$^)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s2.o' '$(call SHESCAPE,$(BUILDDIR))/build-id.s3.o' $(CROSS_LDFLAGS) -T'$(call SHESCAPE,$(BUILDDIR))/linker_nos2map.ld' -o '$(call SHESCAPE,$@)' $(FREESTANDING_LD) '$(call OBJESCAPE,$^)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s2.o' '$(call SHESCAPE,$(BUILDDIR))/build-id.s3.o' $(FREESTANDING_LDFLAGS) -T'$(call SHESCAPE,$(BUILDDIR))/linker_nos2map.ld' -o '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/linker_nomap.ld: linker_bios.ld.in $(call MKESCAPE,$(BUILDDIR))/linker_nomap.ld: linker_bios.ld.in
$(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))' $(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))'
$(CROSS_CC) -x c -E -P -undef -DLINKER_NOMAP linker_bios.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' $(FREESTANDING_CC) -x c -E -P -undef -DLINKER_NOMAP linker_bios.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld'
$(call MKESCAPE,$(BUILDDIR))/limine_nos3map.elf: $(OBJ) ../libgcc-binaries/libgcc-i686.a $(call MKESCAPE,$(BUILDDIR))/stage2.map.o $(call MKESCAPE,$(BUILDDIR))/limine_nos3map.elf: $(OBJ) ../libgcc-binaries/libgcc-i686.a $(call MKESCAPE,$(BUILDDIR))/stage2.map.o
$(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld'
$(CROSS_LD) '$(call OBJESCAPE,$^)' $(CROSS_LDFLAGS) -T'$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' -o '$(call SHESCAPE,$@)' $(FREESTANDING_LD) '$(call OBJESCAPE,$^)' $(FREESTANDING_LDFLAGS) -T'$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' -o '$(call SHESCAPE,$@)'
$(CROSS_OBJCOPY) -O binary --only-section=.note.gnu.build-id '$(call SHESCAPE,$@)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s2.bin' $(FREESTANDING_OBJCOPY) -O binary --only-section=.note.gnu.build-id '$(call SHESCAPE,$@)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s2.bin'
cd '$(call SHESCAPE,$(BUILDDIR))' && \ cd '$(call SHESCAPE,$(BUILDDIR))' && \
$(CROSS_OBJCOPY) -I binary $(OBJCOPY2ELF_FLAGS) build-id.s2.bin build-id.s2.o $(FREESTANDING_OBJCOPY) -I binary $(OBJCOPY2ELF_FLAGS) build-id.s2.bin build-id.s2.o
$(CROSS_OBJCOPY) -O binary --only-section=.note.gnu.build-id '$(call SHESCAPE,$@)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s3.bin' $(FREESTANDING_OBJCOPY) -O binary --only-section=.note.gnu.build-id '$(call SHESCAPE,$@)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s3.bin'
cd '$(call SHESCAPE,$(BUILDDIR))' && \ cd '$(call SHESCAPE,$(BUILDDIR))' && \
$(CROSS_OBJCOPY) -I binary $(OBJCOPY2ELF_FLAGS) build-id.s3.bin build-id.s3.o $(FREESTANDING_OBJCOPY) -I binary $(OBJCOPY2ELF_FLAGS) build-id.s3.bin build-id.s3.o
$(CROSS_LD) '$(call OBJESCAPE,$^)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s2.o' '$(call SHESCAPE,$(BUILDDIR))/build-id.s3.o' $(CROSS_LDFLAGS) -T'$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' -o '$(call SHESCAPE,$@)' $(FREESTANDING_LD) '$(call OBJESCAPE,$^)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s2.o' '$(call SHESCAPE,$(BUILDDIR))/build-id.s3.o' $(FREESTANDING_LDFLAGS) -T'$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' -o '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/linker.ld: linker_bios.ld.in $(call MKESCAPE,$(BUILDDIR))/linker.ld: linker_bios.ld.in
$(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))' $(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))'
$(CROSS_CC) -x c -E -P -undef linker_bios.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker.ld' $(FREESTANDING_CC) -x c -E -P -undef linker_bios.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker.ld'
$(call MKESCAPE,$(BUILDDIR))/limine.elf: $(OBJ) ../libgcc-binaries/libgcc-i686.a $(call MKESCAPE,$(BUILDDIR))/stage2.map.o $(call MKESCAPE,$(BUILDDIR))/full.map.o $(call MKESCAPE,$(BUILDDIR))/limine.elf: $(OBJ) ../libgcc-binaries/libgcc-i686.a $(call MKESCAPE,$(BUILDDIR))/stage2.map.o $(call MKESCAPE,$(BUILDDIR))/full.map.o
$(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker.ld' $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker.ld'
$(CROSS_LD) '$(call OBJESCAPE,$^)' $(CROSS_LDFLAGS) -T'$(call SHESCAPE,$(BUILDDIR))/linker.ld' -o '$(call SHESCAPE,$@)' $(FREESTANDING_LD) '$(call OBJESCAPE,$^)' $(FREESTANDING_LDFLAGS) -T'$(call SHESCAPE,$(BUILDDIR))/linker.ld' -o '$(call SHESCAPE,$@)'
$(CROSS_OBJCOPY) -O binary --only-section=.note.gnu.build-id '$(call SHESCAPE,$@)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s2.bin' $(FREESTANDING_OBJCOPY) -O binary --only-section=.note.gnu.build-id '$(call SHESCAPE,$@)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s2.bin'
cd '$(call SHESCAPE,$(BUILDDIR))' && \ cd '$(call SHESCAPE,$(BUILDDIR))' && \
$(CROSS_OBJCOPY) -I binary $(OBJCOPY2ELF_FLAGS) build-id.s2.bin build-id.s2.o $(FREESTANDING_OBJCOPY) -I binary $(OBJCOPY2ELF_FLAGS) build-id.s2.bin build-id.s2.o
$(CROSS_OBJCOPY) -O binary --only-section=.note.gnu.build-id '$(call SHESCAPE,$@)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s3.bin' $(FREESTANDING_OBJCOPY) -O binary --only-section=.note.gnu.build-id '$(call SHESCAPE,$@)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s3.bin'
cd '$(call SHESCAPE,$(BUILDDIR))' && \ cd '$(call SHESCAPE,$(BUILDDIR))' && \
$(CROSS_OBJCOPY) -I binary $(OBJCOPY2ELF_FLAGS) build-id.s3.bin build-id.s3.o $(FREESTANDING_OBJCOPY) -I binary $(OBJCOPY2ELF_FLAGS) build-id.s3.bin build-id.s3.o
$(CROSS_LD) '$(call OBJESCAPE,$^)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s2.o' '$(call SHESCAPE,$(BUILDDIR))/build-id.s3.o' $(CROSS_LDFLAGS) -T'$(call SHESCAPE,$(BUILDDIR))/linker.ld' -o '$(call SHESCAPE,$@)' $(FREESTANDING_LD) '$(call OBJESCAPE,$^)' '$(call SHESCAPE,$(BUILDDIR))/build-id.s2.o' '$(call SHESCAPE,$(BUILDDIR))/build-id.s3.o' $(FREESTANDING_LDFLAGS) -T'$(call SHESCAPE,$(BUILDDIR))/linker.ld' -o '$(call SHESCAPE,$@)'
endif endif
@ -291,39 +291,39 @@ ifeq ($(TARGET),uefi-x86-64)
$(call MKESCAPE,$(BUILDDIR))/full.map.o: $(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf $(call MKESCAPE,$(BUILDDIR))/full.map.o: $(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf
cd '$(call SHESCAPE,$(BUILDDIR))' && \ cd '$(call SHESCAPE,$(BUILDDIR))' && \
'$(call SHESCAPE,$(SRCDIR))/gensyms.sh' '$(call SHESCAPE,$<)' full 64 '\.text' '$(call SHESCAPE,$(SRCDIR))/gensyms.sh' '$(call SHESCAPE,$<)' full 64 '\.text'
$(CROSS_CC) $(CROSS_CFLAGS) $(CROSS_CPPFLAGS) -c '$(call SHESCAPE,$(BUILDDIR))/full.map.S' -o '$(call SHESCAPE,$@)' $(FREESTANDING_CC) $(FREESTANDING_CFLAGS) $(FREESTANDING_CPPFLAGS) -c '$(call SHESCAPE,$(BUILDDIR))/full.map.S' -o '$(call SHESCAPE,$@)'
rm -f '$(call SHESCAPE,$(BUILDDIR))/full.map.S' '$(call SHESCAPE,$(BUILDDIR))/full.map.d' rm -f '$(call SHESCAPE,$(BUILDDIR))/full.map.S' '$(call SHESCAPE,$(BUILDDIR))/full.map.d'
$(call MKESCAPE,$(BUILDDIR))/BOOTX64.EFI: $(call MKESCAPE,$(BUILDDIR))/limine.elf $(call MKESCAPE,$(BUILDDIR))/BOOTX64.EFI: $(call MKESCAPE,$(BUILDDIR))/limine.elf
$(CROSS_OBJCOPY) -O binary '$(call SHESCAPE,$<)' '$(call SHESCAPE,$@)' $(FREESTANDING_OBJCOPY) -O binary '$(call SHESCAPE,$<)' '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-x86_64.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_x86_64.o: $(call MKESCAPE,$(BUILDDIR))/limine-efi $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-x86_64.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_x86_64.o: $(call MKESCAPE,$(BUILDDIR))/limine-efi
unset CPPFLAGS; \ unset CPPFLAGS; \
$(MAKE) -C '$(call SHESCAPE,$(BUILDDIR))/limine-efi/gnuefi' \ $(MAKE) -C '$(call SHESCAPE,$(BUILDDIR))/limine-efi/gnuefi' \
CC="$(CROSS_CC)" \ CC="$(FREESTANDING_CC)" \
CFLAGS="$(BASE_CFLAGS)" \ CFLAGS="$(BASE_CFLAGS)" \
CPPFLAGS='-nostdinc -I$(call SHESCAPE,$(SRCDIR))/../freestanding-headers' \ CPPFLAGS='-nostdinc -I$(call SHESCAPE,$(SRCDIR))/../freestanding-headers' \
ARCH=x86_64 ARCH=x86_64
$(call MKESCAPE,$(BUILDDIR))/linker_nomap.ld: linker_uefi_x86_64.ld.in $(call MKESCAPE,$(BUILDDIR))/linker_nomap.ld: linker_uefi_x86_64.ld.in
$(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))' $(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))'
$(CROSS_CC) -x c -E -P -undef -DLINKER_NOMAP linker_uefi_x86_64.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' $(FREESTANDING_CC) -x c -E -P -undef -DLINKER_NOMAP linker_uefi_x86_64.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld'
$(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf: $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-x86_64.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_x86_64.o $(OBJ) ../libgcc-binaries/libgcc-x86_64-no-red-zone.a $(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf: $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-x86_64.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_x86_64.o $(OBJ) ../libgcc-binaries/libgcc-x86_64-no-red-zone.a
$(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld'
$(CROSS_LD) \ $(FREESTANDING_LD) \
-T'$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' \ -T'$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' \
'$(call OBJESCAPE,$^)' $(CROSS_LDFLAGS) -o '$(call SHESCAPE,$@)' '$(call OBJESCAPE,$^)' $(FREESTANDING_LDFLAGS) -o '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/linker.ld: linker_uefi_x86_64.ld.in $(call MKESCAPE,$(BUILDDIR))/linker.ld: linker_uefi_x86_64.ld.in
$(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))' $(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))'
$(CROSS_CC) -x c -E -P -undef linker_uefi_x86_64.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker.ld' $(FREESTANDING_CC) -x c -E -P -undef linker_uefi_x86_64.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker.ld'
$(call MKESCAPE,$(BUILDDIR))/limine.elf: $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-x86_64.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_x86_64.o $(OBJ) ../libgcc-binaries/libgcc-x86_64-no-red-zone.a $(call MKESCAPE,$(BUILDDIR))/full.map.o $(call MKESCAPE,$(BUILDDIR))/limine.elf: $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-x86_64.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_x86_64.o $(OBJ) ../libgcc-binaries/libgcc-x86_64-no-red-zone.a $(call MKESCAPE,$(BUILDDIR))/full.map.o
$(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker.ld' $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker.ld'
$(CROSS_LD) \ $(FREESTANDING_LD) \
-T'$(call SHESCAPE,$(BUILDDIR))/linker.ld' \ -T'$(call SHESCAPE,$(BUILDDIR))/linker.ld' \
'$(call OBJESCAPE,$^)' $(CROSS_LDFLAGS) -o '$(call SHESCAPE,$@)' '$(call OBJESCAPE,$^)' $(FREESTANDING_LDFLAGS) -o '$(call SHESCAPE,$@)'
endif endif
@ -332,39 +332,39 @@ ifeq ($(TARGET),uefi-aarch64)
$(call MKESCAPE,$(BUILDDIR))/full.map.o: $(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf $(call MKESCAPE,$(BUILDDIR))/full.map.o: $(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf
cd '$(call SHESCAPE,$(BUILDDIR))' && \ cd '$(call SHESCAPE,$(BUILDDIR))' && \
'$(call SHESCAPE,$(SRCDIR))/gensyms.sh' '$(call SHESCAPE,$<)' full 64 '\.text' '$(call SHESCAPE,$(SRCDIR))/gensyms.sh' '$(call SHESCAPE,$<)' full 64 '\.text'
$(CROSS_CC) $(CROSS_CFLAGS) $(CROSS_CPPFLAGS) -c '$(call SHESCAPE,$(BUILDDIR))/full.map.S' -o '$(call SHESCAPE,$@)' $(FREESTANDING_CC) $(FREESTANDING_CFLAGS) $(FREESTANDING_CPPFLAGS) -c '$(call SHESCAPE,$(BUILDDIR))/full.map.S' -o '$(call SHESCAPE,$@)'
rm -f '$(call SHESCAPE,$(BUILDDIR))/full.map.S' '$(call SHESCAPE,$(BUILDDIR))/full.map.d' rm -f '$(call SHESCAPE,$(BUILDDIR))/full.map.S' '$(call SHESCAPE,$(BUILDDIR))/full.map.d'
$(call MKESCAPE,$(BUILDDIR))/BOOTAA64.EFI: $(call MKESCAPE,$(BUILDDIR))/limine.elf $(call MKESCAPE,$(BUILDDIR))/BOOTAA64.EFI: $(call MKESCAPE,$(BUILDDIR))/limine.elf
$(CROSS_OBJCOPY) -O binary '$(call SHESCAPE,$<)' '$(call SHESCAPE,$@)' $(FREESTANDING_OBJCOPY) -O binary '$(call SHESCAPE,$<)' '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-aarch64.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_aarch64.o: $(call MKESCAPE,$(BUILDDIR))/limine-efi $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-aarch64.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_aarch64.o: $(call MKESCAPE,$(BUILDDIR))/limine-efi
unset CPPFLAGS; \ unset CPPFLAGS; \
$(MAKE) -C '$(call SHESCAPE,$(BUILDDIR))/limine-efi/gnuefi' \ $(MAKE) -C '$(call SHESCAPE,$(BUILDDIR))/limine-efi/gnuefi' \
CC="$(CROSS_CC)" \ CC="$(FREESTANDING_CC)" \
CFLAGS="$(BASE_CFLAGS)" \ CFLAGS="$(BASE_CFLAGS)" \
CPPFLAGS='-nostdinc -I$(call SHESCAPE,$(SRCDIR))/../freestanding-headers' \ CPPFLAGS='-nostdinc -I$(call SHESCAPE,$(SRCDIR))/../freestanding-headers' \
ARCH=aarch64 ARCH=aarch64
$(call MKESCAPE,$(BUILDDIR))/linker_nomap.ld: linker_uefi_aarch64.ld.in $(call MKESCAPE,$(BUILDDIR))/linker_nomap.ld: linker_uefi_aarch64.ld.in
$(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))' $(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))'
$(CROSS_CC) -x c -E -P -undef -DLINKER_NOMAP linker_uefi_aarch64.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' $(FREESTANDING_CC) -x c -E -P -undef -DLINKER_NOMAP linker_uefi_aarch64.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld'
$(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf: $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-aarch64.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_aarch64.o $(OBJ) ../libgcc-binaries/libgcc-aarch64.a $(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf: $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-aarch64.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_aarch64.o $(OBJ) ../libgcc-binaries/libgcc-aarch64.a
$(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld'
$(CROSS_LD) \ $(FREESTANDING_LD) \
-T'$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' \ -T'$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' \
'$(call OBJESCAPE,$^)' $(CROSS_LDFLAGS) -o '$(call SHESCAPE,$@)' '$(call OBJESCAPE,$^)' $(FREESTANDING_LDFLAGS) -o '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/linker.ld: linker_uefi_aarch64.ld.in $(call MKESCAPE,$(BUILDDIR))/linker.ld: linker_uefi_aarch64.ld.in
$(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))' $(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))'
$(CROSS_CC) -x c -E -P -undef linker_uefi_aarch64.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker.ld' $(FREESTANDING_CC) -x c -E -P -undef linker_uefi_aarch64.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker.ld'
$(call MKESCAPE,$(BUILDDIR))/limine.elf: $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-aarch64.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_aarch64.o $(OBJ) ../libgcc-binaries/libgcc-aarch64.a $(call MKESCAPE,$(BUILDDIR))/full.map.o $(call MKESCAPE,$(BUILDDIR))/limine.elf: $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-aarch64.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_aarch64.o $(OBJ) ../libgcc-binaries/libgcc-aarch64.a $(call MKESCAPE,$(BUILDDIR))/full.map.o
$(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker.ld' $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker.ld'
$(CROSS_LD) \ $(FREESTANDING_LD) \
-T'$(call SHESCAPE,$(BUILDDIR))/linker.ld' \ -T'$(call SHESCAPE,$(BUILDDIR))/linker.ld' \
'$(call OBJESCAPE,$^)' $(CROSS_LDFLAGS) -o '$(call SHESCAPE,$@)' '$(call OBJESCAPE,$^)' $(FREESTANDING_LDFLAGS) -o '$(call SHESCAPE,$@)'
endif endif
ifeq ($(TARGET),uefi-ia32) ifeq ($(TARGET),uefi-ia32)
@ -372,39 +372,39 @@ ifeq ($(TARGET),uefi-ia32)
$(call MKESCAPE,$(BUILDDIR))/full.map.o: $(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf $(call MKESCAPE,$(BUILDDIR))/full.map.o: $(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf
cd '$(call SHESCAPE,$(BUILDDIR))' && \ cd '$(call SHESCAPE,$(BUILDDIR))' && \
'$(call SHESCAPE,$(SRCDIR))/gensyms.sh' '$(call SHESCAPE,$<)' full 32 '\.text' '$(call SHESCAPE,$(SRCDIR))/gensyms.sh' '$(call SHESCAPE,$<)' full 32 '\.text'
$(CROSS_CC) $(CROSS_CFLAGS) $(CROSS_CPPFLAGS) -c '$(call SHESCAPE,$(BUILDDIR))/full.map.S' -o '$(call SHESCAPE,$@)' $(FREESTANDING_CC) $(FREESTANDING_CFLAGS) $(FREESTANDING_CPPFLAGS) -c '$(call SHESCAPE,$(BUILDDIR))/full.map.S' -o '$(call SHESCAPE,$@)'
rm -f '$(call SHESCAPE,$(BUILDDIR))/full.map.S' '$(call SHESCAPE,$(BUILDDIR))/full.map.d' rm -f '$(call SHESCAPE,$(BUILDDIR))/full.map.S' '$(call SHESCAPE,$(BUILDDIR))/full.map.d'
$(call MKESCAPE,$(BUILDDIR))/BOOTIA32.EFI: $(call MKESCAPE,$(BUILDDIR))/limine.elf $(call MKESCAPE,$(BUILDDIR))/BOOTIA32.EFI: $(call MKESCAPE,$(BUILDDIR))/limine.elf
$(CROSS_OBJCOPY) -O binary '$(call SHESCAPE,$<)' '$(call SHESCAPE,$@)' $(FREESTANDING_OBJCOPY) -O binary '$(call SHESCAPE,$<)' '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-ia32.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_ia32.o: $(call MKESCAPE,$(BUILDDIR))/limine-efi $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-ia32.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_ia32.o: $(call MKESCAPE,$(BUILDDIR))/limine-efi
unset CPPFLAGS; \ unset CPPFLAGS; \
$(MAKE) -C '$(call SHESCAPE,$(BUILDDIR))/limine-efi/gnuefi' \ $(MAKE) -C '$(call SHESCAPE,$(BUILDDIR))/limine-efi/gnuefi' \
CC="$(CROSS_CC)" \ CC="$(FREESTANDING_CC)" \
CFLAGS="$(BASE_CFLAGS)" \ CFLAGS="$(BASE_CFLAGS)" \
CPPFLAGS='-nostdinc -I$(call SHESCAPE,$(SRCDIR))/../freestanding-headers' \ CPPFLAGS='-nostdinc -I$(call SHESCAPE,$(SRCDIR))/../freestanding-headers' \
ARCH=ia32 ARCH=ia32
$(call MKESCAPE,$(BUILDDIR))/linker_nomap.ld: linker_uefi_ia32.ld.in $(call MKESCAPE,$(BUILDDIR))/linker_nomap.ld: linker_uefi_ia32.ld.in
$(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))' $(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))'
$(CROSS_CC) -x c -E -P -undef -DLINKER_NOMAP linker_uefi_ia32.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' $(FREESTANDING_CC) -x c -E -P -undef -DLINKER_NOMAP linker_uefi_ia32.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld'
$(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf: $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-ia32.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_ia32.o $(OBJ) ../libgcc-binaries/libgcc-i686.a $(call MKESCAPE,$(BUILDDIR))/limine_nomap.elf: $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-ia32.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_ia32.o $(OBJ) ../libgcc-binaries/libgcc-i686.a
$(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld'
$(CROSS_LD) \ $(FREESTANDING_LD) \
-T'$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' \ -T'$(call SHESCAPE,$(BUILDDIR))/linker_nomap.ld' \
'$(call OBJESCAPE,$^)' $(CROSS_LDFLAGS) -o '$(call SHESCAPE,$@)' '$(call OBJESCAPE,$^)' $(FREESTANDING_LDFLAGS) -o '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/linker.ld: linker_uefi_ia32.ld.in $(call MKESCAPE,$(BUILDDIR))/linker.ld: linker_uefi_ia32.ld.in
$(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))' $(MKDIR_P) '$(call SHESCAPE,$(BUILDDIR))'
$(CROSS_CC) -x c -E -P -undef linker_uefi_ia32.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker.ld' $(FREESTANDING_CC) -x c -E -P -undef linker_uefi_ia32.ld.in -o '$(call SHESCAPE,$(BUILDDIR))/linker.ld'
$(call MKESCAPE,$(BUILDDIR))/limine.elf: $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-ia32.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_ia32.o $(OBJ) ../libgcc-binaries/libgcc-i686.a $(call MKESCAPE,$(BUILDDIR))/full.map.o $(call MKESCAPE,$(BUILDDIR))/limine.elf: $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/crt0-efi-ia32.o $(call MKESCAPE,$(BUILDDIR))/limine-efi/gnuefi/reloc_ia32.o $(OBJ) ../libgcc-binaries/libgcc-i686.a $(call MKESCAPE,$(BUILDDIR))/full.map.o
$(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker.ld' $(MAKE) '$(call SHESCAPE,$(BUILDDIR))/linker.ld'
$(CROSS_LD) \ $(FREESTANDING_LD) \
-T'$(call SHESCAPE,$(BUILDDIR))/linker.ld' \ -T'$(call SHESCAPE,$(BUILDDIR))/linker.ld' \
'$(call OBJESCAPE,$^)' $(CROSS_LDFLAGS) -o '$(call SHESCAPE,$@)' '$(call OBJESCAPE,$^)' $(FREESTANDING_LDFLAGS) -o '$(call SHESCAPE,$@)'
endif endif
@ -413,25 +413,25 @@ endif
ifeq ($(TARGET),uefi-x86-64) ifeq ($(TARGET),uefi-x86-64)
$(call MKESCAPE,$(BUILDDIR))/%.o: %.c $(call MKESCAPE,$(BUILDDIR))/limine-efi $(call MKESCAPE,$(BUILDDIR))/%.o: %.c $(call MKESCAPE,$(BUILDDIR))/limine-efi
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
$(CROSS_CC) $(CROSS_CFLAGS) $(CROSS_CPPFLAGS) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)' $(FREESTANDING_CC) $(FREESTANDING_CFLAGS) $(FREESTANDING_CPPFLAGS) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)'
endif endif
ifeq ($(TARGET),uefi-aarch64) ifeq ($(TARGET),uefi-aarch64)
$(call MKESCAPE,$(BUILDDIR))/%.o: %.c $(call MKESCAPE,$(BUILDDIR))/limine-efi $(call MKESCAPE,$(BUILDDIR))/%.o: %.c $(call MKESCAPE,$(BUILDDIR))/limine-efi
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
$(CROSS_CC) $(CROSS_CFLAGS) $(CROSS_CPPFLAGS) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)' $(FREESTANDING_CC) $(FREESTANDING_CFLAGS) $(FREESTANDING_CPPFLAGS) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)'
endif endif
ifeq ($(TARGET),uefi-ia32) ifeq ($(TARGET),uefi-ia32)
$(call MKESCAPE,$(BUILDDIR))/%.o: %.c $(call MKESCAPE,$(BUILDDIR))/limine-efi $(call MKESCAPE,$(BUILDDIR))/%.o: %.c $(call MKESCAPE,$(BUILDDIR))/limine-efi
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
$(CROSS_CC) $(CROSS_CFLAGS) $(CROSS_CPPFLAGS) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)' $(FREESTANDING_CC) $(FREESTANDING_CFLAGS) $(FREESTANDING_CPPFLAGS) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)'
endif endif
ifeq ($(TARGET),bios) ifeq ($(TARGET),bios)
$(call MKESCAPE,$(BUILDDIR))/%.o: %.c $(call MKESCAPE,$(BUILDDIR))/%.o: %.c
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
$(CROSS_CC) $(CROSS_CFLAGS) $(CROSS_CPPFLAGS) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)' $(FREESTANDING_CC) $(FREESTANDING_CFLAGS) $(FREESTANDING_CPPFLAGS) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)'
endif endif
-include $(HEADER_DEPS) -include $(HEADER_DEPS)
@ -439,7 +439,7 @@ endif
ifeq ($(TARGET),bios) ifeq ($(TARGET),bios)
$(call MKESCAPE,$(BUILDDIR))/%.s2.o: %.s2.c $(call MKESCAPE,$(BUILDDIR))/%.s2.o: %.s2.c
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
$(CROSS_CC) $(CROSS_CFLAGS) $(S2CFLAGS) $(CROSS_CPPFLAGS) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)' $(FREESTANDING_CC) $(FREESTANDING_CFLAGS) $(S2CFLAGS) $(FREESTANDING_CPPFLAGS) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)'
endif endif
-include $(HEADER_DEPS) -include $(HEADER_DEPS)
@ -475,11 +475,11 @@ endif
ifeq ($(TARGET),uefi-aarch64) ifeq ($(TARGET),uefi-aarch64)
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_aarch64 $(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_aarch64
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
$(CROSS_CC) $(CROSS_CFLAGS) $(CROSS_CPPFLAGS) -x assembler-with-cpp -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)' $(FREESTANDING_CC) $(FREESTANDING_CFLAGS) $(FREESTANDING_CPPFLAGS) -x assembler-with-cpp -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_uefi_aarch64 $(call MKESCAPE,$(BUILDDIR))/%.o: %.asm_uefi_aarch64
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
$(CROSS_CC) $(CROSS_CFLAGS) $(CROSS_CPPFLAGS) -x assembler-with-cpp -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)' $(FREESTANDING_CC) $(FREESTANDING_CFLAGS) $(FREESTANDING_CPPFLAGS) -x assembler-with-cpp -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)'
endif endif
ifeq ($(TARGET),uefi-ia32) ifeq ($(TARGET),uefi-ia32)

View File

@ -28,7 +28,7 @@ TMP4="$(mktemp)"
trap "rm -f '$TMP1' '$TMP2' '$TMP3' '$TMP4'; trap - EXIT; exit" EXIT INT TERM QUIT HUP trap "rm -f '$TMP1' '$TMP2' '$TMP3' '$TMP4'; trap - EXIT; exit" EXIT INT TERM QUIT HUP
"$CROSS_OBJDUMP" -t "$1" | ( "$SED" '/[[:<:]]d[[:>:]]/d' 2>/dev/null || "$SED" '/\bd\b/d' ) | sort > "$TMP1" "$FREESTANDING_OBJDUMP" -t "$1" | ( "$SED" '/[[:<:]]d[[:>:]]/d' 2>/dev/null || "$SED" '/\bd\b/d' ) | sort > "$TMP1"
"$GREP" "$4" < "$TMP1" | cut -d' ' -f1 > "$TMP2" "$GREP" "$4" < "$TMP1" | cut -d' ' -f1 > "$TMP2"
"$GREP" "$4" < "$TMP1" | "$AWK" 'NF{ print $NF }' > "$TMP3" "$GREP" "$4" < "$TMP1" | "$AWK" 'NF{ print $NF }' > "$TMP3"

View File

@ -54,12 +54,12 @@ if ! test "x$NATIVE_STRIP_FOUND" = "xyes"; then
fi fi
AC_SUBST([NATIVE_STRIP]) AC_SUBST([NATIVE_STRIP])
rm -rf "$BUILDDIR/cross-files" rm -rf "$BUILDDIR/toolchain-files"
BUILD_ALL="no" BUILD_ALL="no"
AC_ARG_ENABLE([all], AC_ARG_ENABLE([all],
[AS_HELP_STRING([--enable-all], [enable ALL ports])], [AS_HELP_STRING([--enable-all], [enable ALL ports and targets])],
[BUILD_ALL="$enableval"]) [BUILD_ALL="$enableval"])
BUILD_CD="$BUILD_ALL" BUILD_CD="$BUILD_ALL"
@ -98,11 +98,8 @@ fi
if test "x$BUILD_BIOS" = "xno"; then if test "x$BUILD_BIOS" = "xno"; then
BUILD_BIOS="" BUILD_BIOS=""
else else
( $MKDIR_P "$BUILDDIR/toolchain-files"
$MKDIR_P "$BUILDDIR/cross-files" CC="$CC" ARCHITECTURE=i686 WANT_FREESTANDING_CC=yes WANT_FREESTANDING_LD=yes WANT_FREESTANDING_OBJCOPY=yes WANT_FREESTANDING_OBJDUMP=yes WANT_FREESTANDING_READELF=yes "$SRCDIR/freestanding-toolchain" >"$BUILDDIR/toolchain-files/bios-i686-toolchain.mk"
cd "$BUILDDIR/cross-files"
CC="$CC" ARCHITECTURE=i686 WANT_CROSS_CC=yes WANT_CROSS_LD=yes WANT_CROSS_OBJCOPY=yes WANT_CROSS_OBJDUMP=yes WANT_CROSS_READELF=yes "$SRCDIR/freestanding-toolchain" >"$BUILDDIR/cross-files/bios-i686-toolchain.mk"
) || exit 1
BUILD_BIOS="limine-bios" BUILD_BIOS="limine-bios"
NEED_NASM=yes NEED_NASM=yes
NEED_GZIP=yes NEED_GZIP=yes
@ -120,11 +117,8 @@ AC_ARG_ENABLE([uefi-ia32],
if test "x$BUILD_UEFI_IA32" = "xno"; then if test "x$BUILD_UEFI_IA32" = "xno"; then
BUILD_UEFI_IA32="" BUILD_UEFI_IA32=""
else else
( $MKDIR_P "$BUILDDIR/toolchain-files"
$MKDIR_P "$BUILDDIR/cross-files" CC="$CC" ARCHITECTURE=i686 WANT_FREESTANDING_CC=yes WANT_FREESTANDING_LD=yes WANT_FREESTANDING_OBJCOPY=yes WANT_FREESTANDING_OBJDUMP=yes "$SRCDIR/freestanding-toolchain" >"$BUILDDIR/toolchain-files/uefi-i686-toolchain.mk"
cd "$BUILDDIR/cross-files"
CC="$CC" ARCHITECTURE=i686 WANT_CROSS_CC=yes WANT_CROSS_LD=yes WANT_CROSS_OBJCOPY=yes WANT_CROSS_OBJDUMP=yes "$SRCDIR/freestanding-toolchain" >"$BUILDDIR/cross-files/uefi-i686-toolchain.mk"
) || exit 1
BUILD_UEFI_IA32="limine-uefi-ia32" BUILD_UEFI_IA32="limine-uefi-ia32"
NEED_NASM=yes NEED_NASM=yes
fi fi
@ -140,11 +134,8 @@ AC_ARG_ENABLE([uefi-x86-64],
if test "x$BUILD_UEFI_X86_64" = "xno"; then if test "x$BUILD_UEFI_X86_64" = "xno"; then
BUILD_UEFI_X86_64="" BUILD_UEFI_X86_64=""
else else
( $MKDIR_P "$BUILDDIR/toolchain-files"
$MKDIR_P "$BUILDDIR/cross-files" CC="$CC" ARCHITECTURE=x86_64 WANT_FREESTANDING_CC=yes WANT_FREESTANDING_LD=yes WANT_FREESTANDING_OBJCOPY=yes WANT_FREESTANDING_OBJDUMP=yes "$SRCDIR/freestanding-toolchain" >"$BUILDDIR/toolchain-files/uefi-x86_64-toolchain.mk"
cd "$BUILDDIR/cross-files"
CC="$CC" ARCHITECTURE=x86_64 WANT_CROSS_CC=yes WANT_CROSS_LD=yes WANT_CROSS_OBJCOPY=yes WANT_CROSS_OBJDUMP=yes "$SRCDIR/freestanding-toolchain" >"$BUILDDIR/cross-files/uefi-x86_64-toolchain.mk"
) || exit 1
BUILD_UEFI_X86_64="limine-uefi-x86-64" BUILD_UEFI_X86_64="limine-uefi-x86-64"
NEED_NASM=yes NEED_NASM=yes
fi fi
@ -160,11 +151,8 @@ AC_ARG_ENABLE([uefi-aarch64],
if test "x$BUILD_UEFI_AARCH64" = "xno"; then if test "x$BUILD_UEFI_AARCH64" = "xno"; then
BUILD_UEFI_AARCH64="" BUILD_UEFI_AARCH64=""
else else
( mkdir -p "$BUILDDIR/toolchain-files"
mkdir -p "$BUILDDIR/cross-files" CC="$CC" ARCHITECTURE=aarch64 WANT_FREESTANDING_CC=yes WANT_FREESTANDING_LD=yes WANT_FREESTANDING_OBJCOPY=yes WANT_FREESTANDING_OBJDUMP=yes "$SRCDIR/freestanding-toolchain" >"$BUILDDIR/toolchain-files/uefi-aarch64-toolchain.mk"
cd "$BUILDDIR/cross-files"
CC="$CC" ARCHITECTURE=aarch64 WANT_CROSS_CC=yes WANT_CROSS_LD=yes WANT_CROSS_OBJCOPY=yes WANT_CROSS_OBJDUMP=yes "$SRCDIR/freestanding-toolchain" >"$BUILDDIR/cross-files/uefi-aarch64-toolchain.mk"
) || exit 1
BUILD_UEFI_AARCH64="limine-uefi-aarch64" BUILD_UEFI_AARCH64="limine-uefi-aarch64"
fi fi
@ -203,27 +191,27 @@ if test "x$NEED_GZIP" = "xyes"; then
fi fi
fi fi
AC_ARG_VAR([CROSS_TOOLCHAIN], [alternative toolchain prefix for Limine (or 'llvm')]) AC_ARG_VAR([FREESTANDING_TOOLCHAIN], [alternative toolchain prefix for Limine (or 'llvm', or 'gnu')])
AC_ARG_VAR([CROSS_CC], [C compiler command for Limine]) AC_ARG_VAR([FREESTANDING_CC], [C compiler command for Limine])
AC_ARG_VAR([CROSS_LD], [linker command for Limine]) AC_ARG_VAR([FREESTANDING_LD], [linker command for Limine])
AC_ARG_VAR([CROSS_OBJCOPY], [objcopy command for Limine]) AC_ARG_VAR([FREESTANDING_OBJCOPY], [objcopy command for Limine])
AC_ARG_VAR([CROSS_OBJDUMP], [objdump command for Limine]) AC_ARG_VAR([FREESTANDING_OBJDUMP], [objdump command for Limine])
AC_ARG_VAR([CROSS_READELF], [readelf command for Limine]) AC_ARG_VAR([FREESTANDING_READELF], [readelf command for Limine])
m4_define([DEFAULT_CROSS_CFLAGS], [-g -O2 -pipe -Wall -Wextra]) m4_define([DEFAULT_FREESTANDING_CFLAGS], [-g -O2 -pipe -Wall -Wextra])
AC_ARG_VAR([CROSS_CFLAGS], [C flags for Limine @<:@default: ]DEFAULT_CROSS_CFLAGS[@:>@]) AC_ARG_VAR([FREESTANDING_CFLAGS], [C flags for Limine @<:@default: ]DEFAULT_FREESTANDING_CFLAGS[@:>@])
test "x$CROSS_CFLAGS" = "x" && CROSS_CFLAGS="DEFAULT_CROSS_CFLAGS" test "x$FREESTANDING_CFLAGS" = "x" && FREESTANDING_CFLAGS="DEFAULT_FREESTANDING_CFLAGS"
if test "$werror_state" = "yes"; then if test "$werror_state" = "yes"; then
CROSS_CFLAGS="$CROSS_CFLAGS -Werror" FREESTANDING_CFLAGS="$FREESTANDING_CFLAGS -Werror"
fi fi
m4_define([DEFAULT_CROSS_CPPFLAGS], []) m4_define([DEFAULT_FREESTANDING_CPPFLAGS], [])
AC_ARG_VAR([CROSS_CPPFLAGS], [C preprocessor flags for Limine @<:@default: ]DEFAULT_CROSS_CPPFLAGS[@:>@]) AC_ARG_VAR([FREESTANDING_CPPFLAGS], [C preprocessor flags for Limine @<:@default: ]DEFAULT_FREESTANDING_CPPFLAGS[@:>@])
test "x$CROSS_CPPFLAGS" = "x" && CROSS_CPPFLAGS="DEFAULT_CROSS_CPPFLAGS" test "x$FREESTANDING_CPPFLAGS" = "x" && FREESTANDING_CPPFLAGS="DEFAULT_FREESTANDING_CPPFLAGS"
m4_define([DEFAULT_CROSS_LDFLAGS], []) m4_define([DEFAULT_FREESTANDING_LDFLAGS], [])
AC_ARG_VAR([CROSS_LDFLAGS], [Linker flags for Limine @<:@default: ]DEFAULT_CROSS_LDFLAGS[@:>@]) AC_ARG_VAR([FREESTANDING_LDFLAGS], [Linker flags for Limine @<:@default: ]DEFAULT_FREESTANDING_LDFLAGS[@:>@])
test "x$CROSS_LDFLAGS" = "x" && CROSS_LDFLAGS="DEFAULT_CROSS_LDFLAGS" test "x$FREESTANDING_LDFLAGS" = "x" && FREESTANDING_LDFLAGS="DEFAULT_FREESTANDING_LDFLAGS"
LIMINE_COPYRIGHT=$($GREP Copyright "$SRCDIR/LICENSE") LIMINE_COPYRIGHT=$($GREP Copyright "$SRCDIR/LICENSE")
AC_SUBST([LIMINE_COPYRIGHT]) AC_SUBST([LIMINE_COPYRIGHT])

View File

@ -1,6 +1,6 @@
override MAKEFLAGS += -rR override MAKEFLAGS += -rR
include $(CROSS_FILE) include $(TOOLCHAIN_FILE)
BUILDDIR ?= BUILDDIR ?=
@ -14,7 +14,7 @@ ifeq ($(call MKESCAPE,$(BUILDDIR)),)
$(error BUILDDIR not specified) $(error BUILDDIR not specified)
endif endif
override CROSS_CFLAGS += \ override FREESTANDING_CFLAGS += \
-Os \ -Os \
-std=gnu11 \ -std=gnu11 \
-nostdinc \ -nostdinc \
@ -33,22 +33,22 @@ override CROSS_CFLAGS += \
-Wshadow \ -Wshadow \
-Wvla -Wvla
override CROSS_CPPFLAGS := \ override FREESTANDING_CPPFLAGS := \
-I../freestanding-headers \ -I../freestanding-headers \
-I'$(call SHESCAPE,$(BUILDDIR))/tinf' \ -I'$(call SHESCAPE,$(BUILDDIR))/tinf' \
-I. \ -I. \
$(CROSS_CPPFLAGS) \ $(FREESTANDING_CPPFLAGS) \
-MMD -MMD
override CROSS_LDFLAGS += \ override FREESTANDING_LDFLAGS += \
-m elf_i386 \ -m elf_i386 \
-nostdlib \ -nostdlib \
-z max-page-size=0x1000 \ -z max-page-size=0x1000 \
-static \ -static \
-T linker.ld -T linker.ld
ifeq ($(CROSS_LD_HAS_NO_PIE),yes) ifeq ($(FREESTANDING_LD_HAS_NO_PIE),yes)
override CROSS_LDFLAGS += -no-pie override FREESTANDING_LDFLAGS += -no-pie
endif endif
override C_FILES := $(shell find . -type f -name '*.c') override C_FILES := $(shell find . -type f -name '*.c')
@ -60,8 +60,8 @@ override HEADER_DEPS := $(addprefix $(call MKESCAPE,$(BUILDDIR))/, $(C_FILES:.c=
all: $(call MKESCAPE,$(BUILDDIR))/decompressor.bin all: $(call MKESCAPE,$(BUILDDIR))/decompressor.bin
$(call MKESCAPE,$(BUILDDIR))/decompressor.bin: $(OBJ) ../libgcc-binaries/libgcc-i686.a $(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o $(call MKESCAPE,$(BUILDDIR))/decompressor.bin: $(OBJ) ../libgcc-binaries/libgcc-i686.a $(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o $(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o
$(CROSS_LD) '$(call OBJESCAPE,$^)' $(CROSS_LDFLAGS) -o '$(call SHESCAPE,$(BUILDDIR))/decompressor.elf' $(FREESTANDING_LD) '$(call OBJESCAPE,$^)' $(FREESTANDING_LDFLAGS) -o '$(call SHESCAPE,$(BUILDDIR))/decompressor.elf'
$(CROSS_OBJCOPY) -O binary '$(call SHESCAPE,$(BUILDDIR))/decompressor.elf' '$(call SHESCAPE,$@)' $(FREESTANDING_OBJCOPY) -O binary '$(call SHESCAPE,$(BUILDDIR))/decompressor.elf' '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/tinf-copied: ../tinf/* $(call MKESCAPE,$(BUILDDIR))/tinf-copied: ../tinf/*
rm -rf '$(call SHESCAPE,$(BUILDDIR))/tinf' rm -rf '$(call SHESCAPE,$(BUILDDIR))/tinf'
@ -71,17 +71,17 @@ $(call MKESCAPE,$(BUILDDIR))/tinf-copied: ../tinf/*
$(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o: $(call MKESCAPE,$(BUILDDIR))/tinf-copied $(call MKESCAPE,$(BUILDDIR))/tinf/tinfgzip.o: $(call MKESCAPE,$(BUILDDIR))/tinf-copied
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
$(CROSS_CC) $(CROSS_CFLAGS) $(CROSS_CPPFLAGS) -c '$(call SHESCAPE,$(@:.o=.c))' -o '$(call SHESCAPE,$@)' $(FREESTANDING_CC) $(FREESTANDING_CFLAGS) $(FREESTANDING_CPPFLAGS) -c '$(call SHESCAPE,$(@:.o=.c))' -o '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o: $(call MKESCAPE,$(BUILDDIR))/tinf-copied $(call MKESCAPE,$(BUILDDIR))/tinf/tinflate.o: $(call MKESCAPE,$(BUILDDIR))/tinf-copied
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
$(CROSS_CC) $(CROSS_CFLAGS) $(CROSS_CPPFLAGS) -c '$(call SHESCAPE,$(@:.o=.c))' -o '$(call SHESCAPE,$@)' $(FREESTANDING_CC) $(FREESTANDING_CFLAGS) $(FREESTANDING_CPPFLAGS) -c '$(call SHESCAPE,$(@:.o=.c))' -o '$(call SHESCAPE,$@)'
-include $(HEADER_DEPS) -include $(HEADER_DEPS)
$(call MKESCAPE,$(BUILDDIR))/%.o: %.c $(call MKESCAPE,$(BUILDDIR))/tinf-copied $(call MKESCAPE,$(BUILDDIR))/%.o: %.c $(call MKESCAPE,$(BUILDDIR))/tinf-copied
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"
$(CROSS_CC) $(CROSS_CFLAGS) $(CROSS_CPPFLAGS) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)' $(FREESTANDING_CC) $(FREESTANDING_CFLAGS) $(FREESTANDING_CPPFLAGS) -c '$(call SHESCAPE,$<)' -o '$(call SHESCAPE,$@)'
$(call MKESCAPE,$(BUILDDIR))/%.o: %.asm $(call MKESCAPE,$(BUILDDIR))/%.o: %.asm
$(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')" $(MKDIR_P) "$$(dirname '$(call SHESCAPE,$@)')"

View File

@ -1,9 +1,9 @@
include $(CROSS_FILE) include $(TOOLCHAIN_FILE)
override CC := $(CROSS_CC) override CC := $(FREESTANDING_CC)
CFLAGS = -O2 -g -Wall -Wextra CFLAGS = -O2 -g -Wall -Wextra
LDFLAGS = LDFLAGS =
override LD := $(CROSS_LD) override LD := $(FREESTANDING_LD)
override QEMU := qemu-system-x86_64 override QEMU := qemu-system-x86_64
QEMUFLAGS = -m 1G -enable-kvm -cpu host QEMUFLAGS = -m 1G -enable-kvm -cpu host
@ -58,7 +58,7 @@ override INTERNALCFLAGS_MB := \
-I.. \ -I.. \
-I../common/protos -I../common/protos
ifneq ($(findstring 86,$(CROSS_CC)),) ifneq ($(findstring 86,$(FREESTANDING_CC)),)
all: test.elf multiboot2.elf multiboot.elf all: test.elf multiboot2.elf multiboot.elf
else else
all: test.elf all: test.elf