93 lines
2.7 KiB
Makefile
93 lines
2.7 KiB
Makefile
GPP_ARGS = -std=c++17 -Wall -Wextra -O3 -ggdb -nostdinc \
|
|
-fno-exceptions -ffreestanding -fno-rtti -mno-sse
|
|
KGPP_ARGS = ${GPP_ARGS} -I kernel/include -I mintsuki-freestanding-headers
|
|
AGPP_ARGS = ${GPP_ARGS} -I libraries/euler/include \
|
|
-I libraries/daguerre/include
|
|
|
|
LD_ARGS = -z noexecstack
|
|
KLD_ARGS = -T kernel/link.ld ${LD_ARGS}
|
|
ALD_ARGS = -T applications/link.ld ${LD_ARGS}
|
|
LLD_ARGS = ${LD_ARGS}
|
|
|
|
all: out/disk.iso
|
|
|
|
run: out/disk.iso
|
|
gdb -x qemu.gdb
|
|
|
|
clean:
|
|
rm -rf obj out
|
|
|
|
dist-clean:
|
|
rm -rf limine mintsuki-freestanding-headers
|
|
|
|
limine:
|
|
git clone --depth=1 -b v6.x-branch \
|
|
https://github.com/limine-bootloader/limine.git limine
|
|
cd limine && ./bootstrap && ./configure -q --enable-bios --enable-bios-cd
|
|
+make -C limine
|
|
|
|
mintsuki-freestanding-headers:
|
|
git clone --depth=1 \
|
|
https://github.com/mintsuki/freestanding-headers.git \
|
|
mintsuki-freestanding-headers
|
|
|
|
obj/kernel/entry.cpp.o: kernel/entry.cpp limine mintsuki-freestanding-headers
|
|
@mkdir -p $(@D)
|
|
g++ -c ${KGPP_ARGS} $< -o $@
|
|
|
|
obj/kernel/%.cpp.o: kernel/%.cpp mintsuki-freestanding-headers
|
|
@mkdir -p $(@D)
|
|
g++ -c ${KGPP_ARGS} $< -o $@
|
|
|
|
obj/kernel/%.asm.o: kernel/%.asm
|
|
@mkdir -p $(@D)
|
|
nasm -f elf64 $< -o $@
|
|
|
|
KERNEL_OBJECTS = allocator.cpp application.cpp entry.cpp framebuffer.cpp \
|
|
paging.asm paging.cpp storage.cpp storage/bd/memory.cpp terminal.cpp \
|
|
storage/fs/tarfs.cpp utility.cpp vfile.cpp syscall.asm syscall.cpp \
|
|
interrupts.asm interrupts.cpp
|
|
obj/kernel.elf: ${KERNEL_OBJECTS:%=obj/kernel/%.o}
|
|
ld ${KLD_ARGS} $^ -o $@
|
|
|
|
obj/%.cpp.o: %.cpp mintsuki-freestanding-headers
|
|
@mkdir -p $(@D)
|
|
g++ -c ${AGPP_ARGS} $< -o $@
|
|
|
|
obj/%.asm.o: %.asm
|
|
@mkdir -p $(@D)
|
|
nasm -f elf64 $< -o $@
|
|
|
|
EULER_OBJECTS = entry.cpp syscall.asm cassert.cpp allocator.cpp cstdio.cpp \
|
|
cctype.cpp
|
|
obj/euler.o: ${EULER_OBJECTS:%=obj/libraries/euler/%.o}
|
|
ld -r ${LLD_ARGS} $^ -o $@
|
|
|
|
DAGUERRE_OBJECTS = ppm.cpp
|
|
obj/daguerre.o: ${DAGUERRE_OBJECTS:%=obj/libraries/daguerre/%.o}
|
|
ld -r ${LLD_ARGS} $^ -o $@
|
|
|
|
INIT_OBJECTS = main.cpp
|
|
obj/initfs/bin/init.elf: ${INIT_OBJECTS:%=obj/applications/init/%.o} \
|
|
obj/euler.o obj/daguerre.o
|
|
@mkdir -p $(@D)
|
|
ld ${ALD_ARGS} $^ -o $@
|
|
|
|
obj/initfs/.skeleton:
|
|
@mkdir -p obj/initfs
|
|
cp -r skeleton/* obj/initfs/
|
|
@touch obj/initfs/.skeleton
|
|
|
|
APPLICATIONS = init
|
|
obj/initfs.tgz: ${APPLICATIONS:%=obj/initfs/bin/%.elf} obj/initfs/.skeleton
|
|
tar czf obj/initfs.tgz -C obj/initfs .
|
|
|
|
out/disk.iso: obj/kernel.elf obj/initfs.tgz limine
|
|
mkdir -p obj/iso out
|
|
cp obj/kernel.elf obj/initfs.tgz limine/bin/limine-bios.sys \
|
|
limine/bin/limine-bios-cd.bin limine.cfg obj/iso/
|
|
cp terminus/ter-u16b.psf obj/iso/termfont.psf
|
|
xorriso -as mkisofs -quiet -no-emul-boot -boot-info-table \
|
|
-boot-load-size 4 -b limine-bios-cd.bin obj/iso -o $@
|
|
limine/bin/limine bios-install $@
|
|
rm -rf obj/iso
|