2023-03-14 19:20:46 +03:00
|
|
|
include $(TOOLCHAIN_FILE)
|
2021-07-25 15:48:58 +03:00
|
|
|
|
2023-03-14 19:20:46 +03:00
|
|
|
override CC := $(FREESTANDING_CC)
|
2022-09-05 03:17:53 +03:00
|
|
|
CFLAGS = -O2 -g -Wall -Wextra
|
|
|
|
LDFLAGS =
|
2023-03-14 19:20:46 +03:00
|
|
|
override LD := $(FREESTANDING_LD)
|
2022-09-05 03:17:53 +03:00
|
|
|
override QEMU := qemu-system-x86_64
|
|
|
|
QEMUFLAGS = -m 1G -enable-kvm -cpu host
|
|
|
|
|
|
|
|
override INTERNALLDFLAGS := \
|
2021-07-25 15:48:58 +03:00
|
|
|
-Tlinker.ld \
|
|
|
|
-nostdlib \
|
|
|
|
-zmax-page-size=0x1000 \
|
2021-10-29 20:51:22 +03:00
|
|
|
-static \
|
|
|
|
-pie \
|
|
|
|
--no-dynamic-linker \
|
|
|
|
-ztext
|
2021-07-25 15:48:58 +03:00
|
|
|
|
2022-09-05 03:17:53 +03:00
|
|
|
override INTERNAL_LD_FLAGS_MULTIBOOT2 := \
|
|
|
|
-m elf_i386 \
|
2021-11-10 09:34:19 +03:00
|
|
|
-Tmultiboot2.ld \
|
|
|
|
-nostdlib \
|
|
|
|
-zmax-page-size=0x1000 \
|
2022-06-29 13:32:50 +03:00
|
|
|
-static
|
2021-11-10 09:34:19 +03:00
|
|
|
|
2022-09-05 03:17:53 +03:00
|
|
|
override INTERNAL_LD_FLAGS_MULTIBOOT1 := \
|
|
|
|
-m elf_i386 \
|
2021-11-10 09:34:19 +03:00
|
|
|
-Tmultiboot.ld \
|
|
|
|
-nostdlib \
|
|
|
|
-zmax-page-size=0x1000 \
|
2022-06-29 13:32:50 +03:00
|
|
|
-static
|
2021-11-09 08:33:54 +03:00
|
|
|
|
2022-09-05 03:17:53 +03:00
|
|
|
override INTERNALCFLAGS := \
|
2022-03-18 00:47:58 +03:00
|
|
|
-std=c11 \
|
2021-07-25 15:48:58 +03:00
|
|
|
-ffreestanding \
|
|
|
|
-fno-stack-protector \
|
2022-09-05 03:17:53 +03:00
|
|
|
-fno-stack-check \
|
|
|
|
-fno-lto \
|
2021-10-29 20:51:22 +03:00
|
|
|
-fpie \
|
2022-09-05 03:17:53 +03:00
|
|
|
-mgeneral-regs-only \
|
|
|
|
-mno-red-zone \
|
2022-06-29 13:32:50 +03:00
|
|
|
-I. \
|
2022-09-05 03:17:53 +03:00
|
|
|
-I..
|
|
|
|
|
|
|
|
override INTERNALCFLAGS_MB := \
|
2022-06-29 13:32:50 +03:00
|
|
|
-std=c11 \
|
|
|
|
-ffreestanding \
|
|
|
|
-fno-stack-protector \
|
2022-09-05 03:17:53 +03:00
|
|
|
-fno-stack-check \
|
|
|
|
-fno-lto \
|
2022-06-29 13:32:50 +03:00
|
|
|
-fno-pie \
|
|
|
|
-fno-pic \
|
2022-09-05 03:17:53 +03:00
|
|
|
-m32 \
|
|
|
|
-march=i686 \
|
2022-06-29 13:32:50 +03:00
|
|
|
-mabi=sysv \
|
|
|
|
-mno-80387 \
|
2022-09-05 03:17:53 +03:00
|
|
|
-I. \
|
|
|
|
-I.. \
|
|
|
|
-I../common/protos
|
2022-06-29 13:32:50 +03:00
|
|
|
|
2023-03-14 19:20:46 +03:00
|
|
|
ifneq ($(findstring 86,$(FREESTANDING_CC)),)
|
2021-11-10 09:34:19 +03:00
|
|
|
all: test.elf multiboot2.elf multiboot.elf
|
2022-09-05 03:17:53 +03:00
|
|
|
else
|
|
|
|
all: test.elf
|
|
|
|
endif
|
2020-09-30 01:31:42 +03:00
|
|
|
|
2022-06-14 04:56:30 +03:00
|
|
|
test.elf: limine.o e9print.o memory.o
|
2021-07-25 15:48:58 +03:00
|
|
|
$(LD) $^ $(LDFLAGS) $(INTERNALLDFLAGS) -o $@
|
2020-09-30 01:31:42 +03:00
|
|
|
|
2021-11-09 08:33:54 +03:00
|
|
|
multiboot2.elf: multiboot2_trampoline.o
|
2022-06-29 13:32:50 +03:00
|
|
|
$(CC) $(CFLAGS) $(INTERNALCFLAGS_MB) -c multiboot2.c -o multiboot2.o
|
|
|
|
$(CC) $(CFLAGS) $(INTERNALCFLAGS_MB) -c e9print.c -o e9print.o
|
2021-11-10 09:34:19 +03:00
|
|
|
$(LD) $^ multiboot2.o e9print.o $(LDFLAGS) $(INTERNAL_LD_FLAGS_MULTIBOOT2) -m elf_i386 -o $@
|
|
|
|
|
|
|
|
multiboot.elf: multiboot_trampoline.o
|
2022-06-29 13:32:50 +03:00
|
|
|
$(CC) $(CFLAGS) $(INTERNALCFLAGS_MB) -c multiboot.c -o multiboot.o
|
|
|
|
$(CC) $(CFLAGS) $(INTERNALCFLAGS_MB) -c e9print.c -o e9print.o
|
2021-11-10 09:34:19 +03:00
|
|
|
$(LD) $^ multiboot.o e9print.o $(LDFLAGS) $(INTERNAL_LD_FLAGS_MULTIBOOT1) -m elf_i386 -o $@
|
2021-11-09 08:33:54 +03:00
|
|
|
|
2020-09-30 01:31:42 +03:00
|
|
|
%.o: %.c
|
|
|
|
$(CC) $(CFLAGS) $(INTERNALCFLAGS) -c $< -o $@
|
|
|
|
|
2021-11-09 08:33:54 +03:00
|
|
|
%.o: %.asm
|
2022-06-29 13:32:50 +03:00
|
|
|
nasm -felf32 -F dwarf -g $< -o $@
|
2021-11-09 08:33:54 +03:00
|
|
|
|
2020-09-30 01:31:42 +03:00
|
|
|
clean:
|
2022-06-14 04:56:30 +03:00
|
|
|
rm -rf test.elf limine.o e9print.o memory.o
|
2021-11-19 17:17:37 +03:00
|
|
|
rm -rf multiboot2.o multiboot2.elf multiboot2_trampoline.o
|
|
|
|
rm -rf multiboot.o multiboot_trampoline.o multiboot.elf
|