2020-09-30 01:31:42 +03:00
|
|
|
CC = cc
|
2021-10-29 02:15:11 +03:00
|
|
|
CFLAGS = -O2 -g
|
2021-07-25 15:48:58 +03:00
|
|
|
LDFLAGS =
|
|
|
|
LD = ld
|
2020-09-30 01:31:42 +03:00
|
|
|
QEMU = qemu-system-x86_64
|
|
|
|
QEMUFLAGS = -m 1G -enable-kvm -cpu host
|
2021-07-25 15:48:58 +03:00
|
|
|
|
|
|
|
INTERNALLDFLAGS := \
|
|
|
|
-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
|
|
|
|
2021-11-10 09:34:19 +03:00
|
|
|
INTERNAL_LD_FLAGS_MULTIBOOT2 := \
|
|
|
|
-Tmultiboot2.ld \
|
|
|
|
-nostdlib \
|
|
|
|
-zmax-page-size=0x1000 \
|
|
|
|
-static \
|
|
|
|
--no-dynamic-linker \
|
|
|
|
|
|
|
|
INTERNAL_LD_FLAGS_MULTIBOOT1 := \
|
|
|
|
-Tmultiboot.ld \
|
|
|
|
-nostdlib \
|
|
|
|
-zmax-page-size=0x1000 \
|
|
|
|
-static \
|
|
|
|
--no-dynamic-linker \
|
2021-11-09 08:33:54 +03:00
|
|
|
|
2021-07-25 15:48:58 +03:00
|
|
|
INTERNALCFLAGS := \
|
|
|
|
-I../stivale \
|
|
|
|
-I. \
|
2022-03-12 21:40:49 +03:00
|
|
|
-I../common \
|
2021-07-25 15:48:58 +03:00
|
|
|
-std=gnu11 \
|
|
|
|
-ffreestanding \
|
|
|
|
-fno-stack-protector \
|
2021-10-29 20:51:22 +03:00
|
|
|
-fpie \
|
2021-07-31 22:28:06 +03:00
|
|
|
-mabi=sysv \
|
2021-07-25 15:48:58 +03:00
|
|
|
-mno-80387 \
|
|
|
|
-mno-mmx \
|
|
|
|
-mno-3dnow \
|
|
|
|
-mno-sse \
|
|
|
|
-mno-sse2 \
|
2021-10-29 20:51:22 +03:00
|
|
|
-mno-red-zone
|
2020-09-30 01:31:42 +03:00
|
|
|
|
2021-11-10 09:34:19 +03:00
|
|
|
all: test.elf multiboot2.elf multiboot.elf
|
2020-09-30 01:31:42 +03:00
|
|
|
|
2022-03-12 21:40:49 +03:00
|
|
|
test.elf: stivale.o stivale2.o 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-02-03 12:38:43 +03:00
|
|
|
$(CC) $(CFLAGS) $(INTERNALCFLAGS) -I../common/protos -m32 -c multiboot2.c -o multiboot2.o
|
2021-11-09 08:33:54 +03:00
|
|
|
$(CC) $(CFLAGS) $(INTERNALCFLAGS) -m32 -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-02-03 12:38:43 +03:00
|
|
|
$(CC) $(CFLAGS) $(INTERNALCFLAGS) -I../common/protos -m32 -c multiboot.c -o multiboot.o
|
2021-11-10 09:34:19 +03:00
|
|
|
$(CC) $(CFLAGS) $(INTERNALCFLAGS) -m32 -c e9print.c -o e9print.o
|
|
|
|
$(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
|
|
|
|
nasm -felf32 $< -o $@
|
|
|
|
|
2020-09-30 01:31:42 +03:00
|
|
|
clean:
|
2022-03-17 21:21:35 +03:00
|
|
|
rm -rf test.elf limine.o stivale.o stivale2.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
|