build: Misc enhancements

This commit is contained in:
mintsuki 2021-04-03 22:12:40 +02:00
parent e80e20f209
commit f899648d86
4 changed files with 18 additions and 7 deletions

View File

@ -10,6 +10,8 @@ OBJCOPY = $(TOOLCHAIN)-objcopy
PATH := $(shell pwd)/toolchain/bin:$(PATH)
STAGE1_FILES := $(shell find -L ./stage1 -type f -name '*.asm' | sort)
.PHONY: all bin/limine-install clean install distclean limine-bios limine-uefi limine-bios-clean limine-uefi-clean stage23-bios stage23-bios-clean stage23-uefi stage23-uefi-clean decompressor decompressor-clean toolchain test.hdd echfs-test ext2-test fat16-test fat32-test iso9660-test iso9660-uefi-test pxe-test uefi-test hybrid-iso9660-test
all:
@ -36,19 +38,23 @@ install: all
install -m 644 bin/limine-pxe.bin $(DESTDIR)$(PREFIX)/share/limine/
install -m 644 bin/BOOTX64.EFI $(DESTDIR)$(PREFIX)/share/limine/
limine-bios: stage23-bios decompressor
build/stage1: $(STAGE1_FILES) build/decompressor/decompressor.bin build/stage23-bios/stage2.bin.gz
mkdir -p bin
cd stage1/hdd && nasm bootsect.asm -fbin -o ../../bin/limine-hdd.bin
cd stage1/cd && nasm bootsect.asm -fbin -o ../../bin/limine-cd.bin
cd stage1/pxe && nasm bootsect.asm -fbin -o ../../bin/limine-pxe.bin
cp build/stage23-bios/limine.sys ./bin/
touch build/stage1
bin/limine-eltorito-efi.bin: bin/BOOTX64.EFI
limine-bios: stage23-bios decompressor
$(MAKE) build/stage1
bin/limine-eltorito-efi.bin: build/stage23-uefi/BOOTX64.EFI
dd if=/dev/zero of=$@ bs=512 count=2880
mformat -i $@ -f 1440 ::
mmd -D s -i $@ ::/EFI
mmd -D s -i $@ ::/EFI/BOOT
mcopy -D o -i $@ bin/BOOTX64.EFI ::/EFI/BOOT
mcopy -D o -i $@ build/stage23-uefi/BOOTX64.EFI ::/EFI/BOOT
limine-uefi:
$(MAKE) gnu-efi
@ -94,7 +100,7 @@ toolchain:
gnu-efi:
git clone https://git.code.sf.net/p/gnu-efi/code --branch=3.0.13 --depth=1 $@
$(MAKE) -C gnu-efi/gnuefi CC="$(TOOLCHAIN_CC) -m64"
$(MAKE) -C gnu-efi/gnuefi CC="$(TOOLCHAIN_CC) -m64" AR="$(AR)"
$(MAKE) -C gnu-efi/lib CC="$(TOOLCHAIN_CC) -m64" ARCH=x86_64 x86_64/efi_stub.o
ovmf:

View File

@ -13,6 +13,7 @@ CFLAGS = -flto -Os -pipe -Wall -Wextra -Werror
INTERNAL_CFLAGS = \
-m32 \
-march=i386 \
-std=gnu11 \
-ffreestanding \
-fno-stack-protector \
@ -29,6 +30,7 @@ LDFLAGS = -flto -Os
INTERNAL_LDFLAGS = \
-m32 \
-march=i386 \
-Wl,-melf_i386 \
-nostdlib \
-no-pie \

View File

@ -21,5 +21,5 @@ void entry(uint8_t *compressed_stage2, size_t stage2_size, uint8_t boot_drive, i
: "memory"
);
for (;;);
__builtin_unreachable();
}

View File

@ -23,8 +23,9 @@ READELF = $(TOOLCHAIN)-readelf
COM_OUTPUT = false
E9_OUTPUT = false
BUILD_ID := $(shell dd if=/dev/urandom count=8 bs=1 | od -An -t x8 | sed 's/^ /0x/')
LIMINE_VERSION := $(shell git describe --exact-match --tags `git log -n1 --pretty='%h'` || ( git log -n1 --pretty='%h' && echo -n "(`git branch --show-current`)" ) )
BUILD_ID := $(shell dd if=/dev/urandom count=8 bs=1 2>/dev/null | od -An -t x8 | sed 's/^ /0x/')
LIMINE_VERSION := $(shell git describe --exact-match --tags `git log -n1 --pretty='%h'` 2>/dev/null || ( git log -n1 --pretty='%h' && echo -n "(`git branch --show-current`)" ) )
WERROR = -Werror
CFLAGS = -O3 -g -pipe -Wall -Wextra $(WERROR)
S2CFLAGS = -Os -g -pipe -Wall -Wextra $(WERROR)
@ -83,6 +84,7 @@ INTERNAL_LDFLAGS := \
ifeq ($(TARGET), bios)
INTERNAL_LDFLAGS += \
-m32 \
-march=i386 \
-Wl,-melf_i386 \
-static \
-no-pie \
@ -92,6 +94,7 @@ endif
ifeq ($(TARGET), uefi)
INTERNAL_LDFLAGS += \
-m64 \
-march=x86-64 \
-Wl,-melf_x86_64 \
-shared \
-Wl,-Bsymbolic \