test: General makefile updates
This commit is contained in:
parent
b8fff872de
commit
1e9a42e7ce
|
@ -1,3 +1,4 @@
|
||||||
test.o
|
test.o
|
||||||
test.elf
|
test.elf
|
||||||
flanterm
|
flanterm
|
||||||
|
limine.h
|
||||||
|
|
164
test/GNUmakefile
164
test/GNUmakefile
|
@ -12,62 +12,93 @@ override LD := $(LD_FOR_TARGET)
|
||||||
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
|
||||||
|
|
||||||
override INTERNALLDFLAGS := \
|
ifneq ($(findstring x86_64,$(CC_FOR_TARGET)),)
|
||||||
-Tlinker.ld \
|
override LDFLAGS += \
|
||||||
-nostdlib \
|
-m elf_x86_64
|
||||||
-zmax-page-size=0x1000 \
|
endif
|
||||||
-static \
|
ifneq ($(findstring aarch64,$(CC_FOR_TARGET)),)
|
||||||
-pie \
|
override LDFLAGS += \
|
||||||
--no-dynamic-linker \
|
-m aarch64elf
|
||||||
-ztext
|
endif
|
||||||
|
ifneq ($(findstring riscv64,$(CC_FOR_TARGET)),)
|
||||||
override INTERNAL_LD_FLAGS_MULTIBOOT2 := \
|
override LDFLAGS += \
|
||||||
-m elf_i386 \
|
-m elf64lriscv
|
||||||
-Tmultiboot2.ld \
|
|
||||||
-nostdlib \
|
|
||||||
-zmax-page-size=0x1000 \
|
|
||||||
-static
|
|
||||||
|
|
||||||
override INTERNAL_LD_FLAGS_MULTIBOOT1 := \
|
|
||||||
-m elf_i386 \
|
|
||||||
-Tmultiboot.ld \
|
|
||||||
-nostdlib \
|
|
||||||
-zmax-page-size=0x1000 \
|
|
||||||
-static
|
|
||||||
|
|
||||||
override INTERNALCFLAGS := \
|
|
||||||
-std=c11 \
|
|
||||||
-ffreestanding \
|
|
||||||
-fno-stack-protector \
|
|
||||||
-fno-stack-check \
|
|
||||||
-fno-lto \
|
|
||||||
-fPIE \
|
|
||||||
-mgeneral-regs-only \
|
|
||||||
-mno-red-zone \
|
|
||||||
-I. \
|
|
||||||
-I.. \
|
|
||||||
-D_LIMINE_PROTO
|
|
||||||
|
|
||||||
ifneq ($(findstring riscv,$(CC_FOR_TARGET)),)
|
|
||||||
override INTERNALCFLAGS += -march=rv64imac -mabi=lp64 -mno-relax
|
|
||||||
override INTERNALLDFLAGS += --no-relax
|
|
||||||
endif
|
endif
|
||||||
|
|
||||||
override INTERNALCFLAGS_MB := \
|
override LDFLAGS += \
|
||||||
-std=c11 \
|
-Tlinker.ld \
|
||||||
-ffreestanding \
|
-nostdlib \
|
||||||
-fno-stack-protector \
|
-zmax-page-size=0x1000 \
|
||||||
-fno-stack-check \
|
-static \
|
||||||
-fno-lto \
|
-pie \
|
||||||
-fno-PIE \
|
--no-dynamic-linker \
|
||||||
-fno-PIC \
|
-ztext
|
||||||
-m32 \
|
|
||||||
-march=i686 \
|
override LDFLAGS_MB2 := \
|
||||||
-mabi=sysv \
|
-m elf_i386 \
|
||||||
-mno-80387 \
|
-Tmultiboot2.ld \
|
||||||
-I. \
|
-nostdlib \
|
||||||
-I.. \
|
-zmax-page-size=0x1000 \
|
||||||
-I../common/protos
|
-static
|
||||||
|
|
||||||
|
override LDFLAGS_MB1 := \
|
||||||
|
-m elf_i386 \
|
||||||
|
-Tmultiboot.ld \
|
||||||
|
-nostdlib \
|
||||||
|
-zmax-page-size=0x1000 \
|
||||||
|
-static
|
||||||
|
|
||||||
|
override CFLAGS += \
|
||||||
|
-std=c11 \
|
||||||
|
-nostdinc \
|
||||||
|
-ffreestanding \
|
||||||
|
-fno-stack-protector \
|
||||||
|
-fno-stack-check \
|
||||||
|
-fno-lto \
|
||||||
|
-fPIE \
|
||||||
|
-I../freestanding-headers \
|
||||||
|
-I. \
|
||||||
|
-D_LIMINE_PROTO
|
||||||
|
|
||||||
|
ifneq ($(findstring x86_64,$(CC_FOR_TARGET)),)
|
||||||
|
override CFLAGS += \
|
||||||
|
-m64 \
|
||||||
|
-march=x86-64 \
|
||||||
|
-mabi=sysv \
|
||||||
|
-mgeneral-regs-only \
|
||||||
|
-mno-red-zone
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(findstring aarch64,$(CC_FOR_TARGET)),)
|
||||||
|
override CFLAGS += \
|
||||||
|
-mgeneral-regs-only
|
||||||
|
endif
|
||||||
|
|
||||||
|
ifneq ($(findstring riscv64,$(CC_FOR_TARGET)),)
|
||||||
|
override CFLAGS += \
|
||||||
|
-march=rv64imac \
|
||||||
|
-mabi=lp64 \
|
||||||
|
-mno-relax
|
||||||
|
override LDFLAGS += \
|
||||||
|
--no-relax
|
||||||
|
endif
|
||||||
|
|
||||||
|
override CFLAGS_MB := \
|
||||||
|
-std=c11 \
|
||||||
|
-nostdinc \
|
||||||
|
-ffreestanding \
|
||||||
|
-fno-stack-protector \
|
||||||
|
-fno-stack-check \
|
||||||
|
-fno-lto \
|
||||||
|
-fno-PIE \
|
||||||
|
-fno-PIC \
|
||||||
|
-m32 \
|
||||||
|
-march=i686 \
|
||||||
|
-mabi=sysv \
|
||||||
|
-mgeneral-regs-only \
|
||||||
|
-I../freestanding-headers \
|
||||||
|
-I. \
|
||||||
|
-I../common/protos
|
||||||
|
|
||||||
ifneq ($(findstring 86,$(CC_FOR_TARGET)),)
|
ifneq ($(findstring 86,$(CC_FOR_TARGET)),)
|
||||||
all: test.elf multiboot2.elf multiboot.elf
|
all: test.elf multiboot2.elf multiboot.elf
|
||||||
|
@ -79,21 +110,26 @@ flanterm:
|
||||||
mkdir -p flanterm
|
mkdir -p flanterm
|
||||||
cp -rv ../common/flanterm/* ./flanterm/
|
cp -rv ../common/flanterm/* ./flanterm/
|
||||||
|
|
||||||
|
limine.h:
|
||||||
|
cp -v ../limine.h ./
|
||||||
|
|
||||||
test.elf: limine.o e9print.o memory.o flanterm/flanterm.o flanterm/backends/fb.o
|
test.elf: limine.o e9print.o memory.o flanterm/flanterm.o flanterm/backends/fb.o
|
||||||
$(LD) $^ $(LDFLAGS) $(INTERNALLDFLAGS) -o $@
|
$(LD) $^ $(LDFLAGS) -o $@
|
||||||
|
|
||||||
multiboot2.elf: multiboot2_trampoline.o
|
multiboot2.elf: multiboot2_trampoline.o
|
||||||
$(CC) $(CFLAGS) $(INTERNALCFLAGS_MB) -c multiboot2.c -o multiboot2.o
|
$(CC) $(CFLAGS_MB) -c memory.c -o memory.o
|
||||||
$(CC) $(CFLAGS) $(INTERNALCFLAGS_MB) -c e9print.c -o e9print.o
|
$(CC) $(CFLAGS_MB) -c multiboot2.c -o multiboot2.o
|
||||||
$(LD) $^ multiboot2.o e9print.o $(LDFLAGS) $(INTERNAL_LD_FLAGS_MULTIBOOT2) -m elf_i386 -o $@
|
$(CC) $(CFLAGS_MB) -c e9print.c -o e9print.o
|
||||||
|
$(LD) $^ memory.o multiboot2.o e9print.o $(LDFLAGS_MB2) -o $@
|
||||||
|
|
||||||
multiboot.elf: multiboot_trampoline.o
|
multiboot.elf: multiboot_trampoline.o
|
||||||
$(CC) $(CFLAGS) $(INTERNALCFLAGS_MB) -c multiboot.c -o multiboot.o
|
$(CC) $(CFLAGS_MB) -c memory.c -o memory.o
|
||||||
$(CC) $(CFLAGS) $(INTERNALCFLAGS_MB) -c e9print.c -o e9print.o
|
$(CC) $(CFLAGS_MB) -c multiboot.c -o multiboot.o
|
||||||
$(LD) $^ multiboot.o e9print.o $(LDFLAGS) $(INTERNAL_LD_FLAGS_MULTIBOOT1) -m elf_i386 -o $@
|
$(CC) $(CFLAGS_MB) -c e9print.c -o e9print.o
|
||||||
|
$(LD) $^ memory.o multiboot.o e9print.o $(LDFLAGS_MB1) -o $@
|
||||||
|
|
||||||
%.o: %.c flanterm
|
%.o: %.c flanterm limine.h
|
||||||
$(CC) $(CFLAGS) $(INTERNALCFLAGS) -c $< -o $@
|
$(CC) $(CFLAGS) -c $< -o $@
|
||||||
|
|
||||||
%.o: %.asm
|
%.o: %.asm
|
||||||
nasm -felf32 -F dwarf -g $< -o $@
|
nasm -felf32 -F dwarf -g $< -o $@
|
||||||
|
@ -102,4 +138,4 @@ clean:
|
||||||
rm -rf test.elf limine.o e9print.o memory.o
|
rm -rf test.elf limine.o e9print.o memory.o
|
||||||
rm -rf multiboot2.o multiboot2.elf multiboot2_trampoline.o
|
rm -rf multiboot2.o multiboot2.elf multiboot2_trampoline.o
|
||||||
rm -rf multiboot.o multiboot_trampoline.o multiboot.elf
|
rm -rf multiboot.o multiboot_trampoline.o multiboot.elf
|
||||||
rm -rf flanterm
|
rm -rf flanterm limine.h
|
||||||
|
|
|
@ -236,7 +236,7 @@ extern char kernel_start[];
|
||||||
|
|
||||||
struct flanterm_context *ft_ctx = NULL;
|
struct flanterm_context *ft_ctx = NULL;
|
||||||
|
|
||||||
void limine_main(void) {
|
static void limine_main(void) {
|
||||||
e9_printf("\nWe're alive");
|
e9_printf("\nWe're alive");
|
||||||
|
|
||||||
struct limine_framebuffer *fb = framebuffer_request.response->framebuffers[0];
|
struct limine_framebuffer *fb = framebuffer_request.response->framebuffers[0];
|
||||||
|
|
|
@ -1,5 +1,3 @@
|
||||||
ENTRY(limine_main)
|
|
||||||
|
|
||||||
PHDRS
|
PHDRS
|
||||||
{
|
{
|
||||||
text PT_LOAD FLAGS((1 << 0) | (1 << 2)) ; /* Execute + Read */
|
text PT_LOAD FLAGS((1 << 0) | (1 << 2)) ; /* Execute + Read */
|
||||||
|
|
Loading…
Reference in New Issue