build: Misc enhancements
This commit is contained in:
parent
e80e20f209
commit
f899648d86
14
Makefile
14
Makefile
@ -10,6 +10,8 @@ OBJCOPY = $(TOOLCHAIN)-objcopy
|
|||||||
|
|
||||||
PATH := $(shell pwd)/toolchain/bin:$(PATH)
|
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
|
.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:
|
all:
|
||||||
@ -36,19 +38,23 @@ install: all
|
|||||||
install -m 644 bin/limine-pxe.bin $(DESTDIR)$(PREFIX)/share/limine/
|
install -m 644 bin/limine-pxe.bin $(DESTDIR)$(PREFIX)/share/limine/
|
||||||
install -m 644 bin/BOOTX64.EFI $(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
|
mkdir -p bin
|
||||||
cd stage1/hdd && nasm bootsect.asm -fbin -o ../../bin/limine-hdd.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/cd && nasm bootsect.asm -fbin -o ../../bin/limine-cd.bin
|
||||||
cd stage1/pxe && nasm bootsect.asm -fbin -o ../../bin/limine-pxe.bin
|
cd stage1/pxe && nasm bootsect.asm -fbin -o ../../bin/limine-pxe.bin
|
||||||
cp build/stage23-bios/limine.sys ./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
|
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
|
||||||
mcopy -D o -i $@ bin/BOOTX64.EFI ::/EFI/BOOT
|
mcopy -D o -i $@ build/stage23-uefi/BOOTX64.EFI ::/EFI/BOOT
|
||||||
|
|
||||||
limine-uefi:
|
limine-uefi:
|
||||||
$(MAKE) gnu-efi
|
$(MAKE) gnu-efi
|
||||||
@ -94,7 +100,7 @@ toolchain:
|
|||||||
|
|
||||||
gnu-efi:
|
gnu-efi:
|
||||||
git clone https://git.code.sf.net/p/gnu-efi/code --branch=3.0.13 --depth=1 $@
|
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
|
$(MAKE) -C gnu-efi/lib CC="$(TOOLCHAIN_CC) -m64" ARCH=x86_64 x86_64/efi_stub.o
|
||||||
|
|
||||||
ovmf:
|
ovmf:
|
||||||
|
@ -13,6 +13,7 @@ CFLAGS = -flto -Os -pipe -Wall -Wextra -Werror
|
|||||||
|
|
||||||
INTERNAL_CFLAGS = \
|
INTERNAL_CFLAGS = \
|
||||||
-m32 \
|
-m32 \
|
||||||
|
-march=i386 \
|
||||||
-std=gnu11 \
|
-std=gnu11 \
|
||||||
-ffreestanding \
|
-ffreestanding \
|
||||||
-fno-stack-protector \
|
-fno-stack-protector \
|
||||||
@ -29,6 +30,7 @@ LDFLAGS = -flto -Os
|
|||||||
|
|
||||||
INTERNAL_LDFLAGS = \
|
INTERNAL_LDFLAGS = \
|
||||||
-m32 \
|
-m32 \
|
||||||
|
-march=i386 \
|
||||||
-Wl,-melf_i386 \
|
-Wl,-melf_i386 \
|
||||||
-nostdlib \
|
-nostdlib \
|
||||||
-no-pie \
|
-no-pie \
|
||||||
|
@ -21,5 +21,5 @@ void entry(uint8_t *compressed_stage2, size_t stage2_size, uint8_t boot_drive, i
|
|||||||
: "memory"
|
: "memory"
|
||||||
);
|
);
|
||||||
|
|
||||||
for (;;);
|
__builtin_unreachable();
|
||||||
}
|
}
|
||||||
|
@ -23,8 +23,9 @@ READELF = $(TOOLCHAIN)-readelf
|
|||||||
COM_OUTPUT = false
|
COM_OUTPUT = false
|
||||||
E9_OUTPUT = false
|
E9_OUTPUT = false
|
||||||
|
|
||||||
BUILD_ID := $(shell dd if=/dev/urandom count=8 bs=1 | od -An -t x8 | sed 's/^ /0x/')
|
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'` || ( git log -n1 --pretty='%h' && echo -n "(`git branch --show-current`)" ) )
|
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
|
WERROR = -Werror
|
||||||
CFLAGS = -O3 -g -pipe -Wall -Wextra $(WERROR)
|
CFLAGS = -O3 -g -pipe -Wall -Wextra $(WERROR)
|
||||||
S2CFLAGS = -Os -g -pipe -Wall -Wextra $(WERROR)
|
S2CFLAGS = -Os -g -pipe -Wall -Wextra $(WERROR)
|
||||||
@ -83,6 +84,7 @@ INTERNAL_LDFLAGS := \
|
|||||||
ifeq ($(TARGET), bios)
|
ifeq ($(TARGET), bios)
|
||||||
INTERNAL_LDFLAGS += \
|
INTERNAL_LDFLAGS += \
|
||||||
-m32 \
|
-m32 \
|
||||||
|
-march=i386 \
|
||||||
-Wl,-melf_i386 \
|
-Wl,-melf_i386 \
|
||||||
-static \
|
-static \
|
||||||
-no-pie \
|
-no-pie \
|
||||||
@ -92,6 +94,7 @@ endif
|
|||||||
ifeq ($(TARGET), uefi)
|
ifeq ($(TARGET), uefi)
|
||||||
INTERNAL_LDFLAGS += \
|
INTERNAL_LDFLAGS += \
|
||||||
-m64 \
|
-m64 \
|
||||||
|
-march=x86-64 \
|
||||||
-Wl,-melf_x86_64 \
|
-Wl,-melf_x86_64 \
|
||||||
-shared \
|
-shared \
|
||||||
-Wl,-Bsymbolic \
|
-Wl,-Bsymbolic \
|
||||||
|
Loading…
Reference in New Issue
Block a user