2022-01-12 04:40:35 -05:00
|
|
|
all: test
|
2022-01-09 21:24:49 -05:00
|
|
|
|
2022-01-17 13:06:32 -05:00
|
|
|
CCPREFIX = ../../vendor/cross/root/bin/i386-elf-
|
2022-01-09 21:24:49 -05:00
|
|
|
|
|
|
|
AS = $(CCPREFIX)as
|
|
|
|
CC = $(CCPREFIX)gcc
|
|
|
|
|
2022-02-01 21:46:21 -05:00
|
|
|
LIBKERNAUX_SRC = ../..
|
2022-01-17 07:13:54 -05:00
|
|
|
LIBKERNAUX_BUILD = ../../build/dev-cross-i386
|
|
|
|
LIBKERNAUX_DEST = ../../dest/dev-cross-i386
|
|
|
|
|
2022-01-12 04:40:35 -05:00
|
|
|
DIFF = diff
|
2022-01-09 21:24:49 -05:00
|
|
|
GRUB_FILE = grub-file
|
|
|
|
LIMINE = ../../vendor/limine/build/bin
|
2022-01-15 11:10:56 -05:00
|
|
|
QEMU = qemu-system-x86_64 -serial stdio -display none
|
2022-01-09 21:24:49 -05:00
|
|
|
XORRISO = xorriso
|
|
|
|
|
2022-01-12 04:40:35 -05:00
|
|
|
EXPECTED = expected.txt
|
2022-01-09 21:24:49 -05:00
|
|
|
IMAGE = image.iso
|
|
|
|
LINKERSCR = linker.ld
|
2022-01-12 04:40:35 -05:00
|
|
|
OUTPUT = output.txt
|
2022-01-09 21:24:49 -05:00
|
|
|
ROOTFS = rootfs
|
|
|
|
|
|
|
|
LIMINE_CD = $(LIMINE)/limine-cd.bin
|
|
|
|
LIMINE_ELTORITO = $(LIMINE)/limine-eltorito-efi.bin
|
|
|
|
LIMINE_INSTALL = $(LIMINE)/limine-install
|
|
|
|
LIMINE_SYS = $(LIMINE)/limine.sys
|
|
|
|
|
|
|
|
REL_KERNEL = boot/kernel
|
|
|
|
REL_LIMINE_CD = boot/limine-cd.bin
|
|
|
|
REL_LIMINE_CFG = boot/limine.cfg
|
|
|
|
REL_LIMINE_ELTORITO = boot/limine-eltorito-efi.bin
|
|
|
|
REL_LIMINE_SYS = boot/limine.sys
|
|
|
|
|
|
|
|
FULL_KERNEL = $(ROOTFS)/$(REL_KERNEL)
|
|
|
|
FULL_LIMINE_CD = $(ROOTFS)/$(REL_LIMINE_CD)
|
|
|
|
FULL_LIMINE_CFG = $(ROOTFS)/$(REL_LIMINE_CFG)
|
|
|
|
FULL_LIMINE_ELTORITO = $(ROOTFS)/$(REL_LIMINE_ELTORITO)
|
|
|
|
FULL_LIMINE_SYS = $(ROOTFS)/$(REL_LIMINE_SYS)
|
|
|
|
|
|
|
|
CFLAGS = \
|
2022-02-01 21:46:21 -05:00
|
|
|
-std=c99 \
|
|
|
|
-pedantic \
|
|
|
|
-Wall \
|
|
|
|
-Wextra \
|
|
|
|
-Werror \
|
|
|
|
-ffreestanding \
|
|
|
|
-fno-stack-protector \
|
|
|
|
-I$(LIBKERNAUX_SRC)/include \
|
|
|
|
-I$(LIBKERNAUX_BUILD)/include
|
2022-01-09 21:24:49 -05:00
|
|
|
|
2022-01-14 00:40:51 -05:00
|
|
|
OBJS = main.c.o multiboot2.c.o start.S.o
|
2022-01-09 21:24:49 -05:00
|
|
|
|
2022-01-12 04:40:35 -05:00
|
|
|
test: run
|
|
|
|
$(DIFF) -a -Z $(EXPECTED) $(OUTPUT)
|
|
|
|
|
2022-01-09 21:24:49 -05:00
|
|
|
run: $(IMAGE)
|
2022-01-15 11:10:56 -05:00
|
|
|
$(QEMU) -cdrom $< | tee $(OUTPUT)
|
2022-01-09 21:24:49 -05:00
|
|
|
|
|
|
|
clean:
|
2022-01-12 04:40:35 -05:00
|
|
|
rm -f $(OUTPUT) $(IMAGE) $(FULL_KERNEL) $(FULL_LIMINE_CD) $(FULL_LIMINE_ELTORITO) $(FULL_LIMINE_SYS) $(OBJS)
|
2022-01-09 21:24:49 -05:00
|
|
|
|
|
|
|
$(IMAGE): $(FULL_KERNEL) $(FULL_LIMINE_CD) $(FULL_LIMINE_ELTORITO) $(FULL_LIMINE_SYS)
|
|
|
|
$(XORRISO) -as mkisofs -b $(REL_LIMINE_CD) -no-emul-boot -boot-load-size 4 -boot-info-table --efi-boot $(REL_LIMINE_ELTORITO) -efi-boot-part --efi-boot-image --protective-msdos-label $(ROOTFS) -o $@
|
|
|
|
$(LIMINE_INSTALL) $@
|
|
|
|
|
2022-02-01 22:43:20 -05:00
|
|
|
$(FULL_KERNEL): $(LINKERSCR) build-libkernaux.a $(OBJS)
|
2022-01-20 12:41:37 -05:00
|
|
|
$(CC) -T $(LINKERSCR) -o $@ $(OBJS) -ffreestanding -nostdlib -lkernaux -lgcc -Wl,-L$(LIBKERNAUX_DEST)/lib
|
2022-01-09 21:24:49 -05:00
|
|
|
$(GRUB_FILE) --is-x86-multiboot2 $@
|
|
|
|
|
|
|
|
$(FULL_LIMINE_CD):
|
|
|
|
cp -f $(LIMINE_CD) $(FULL_LIMINE_CD)
|
|
|
|
|
|
|
|
$(FULL_LIMINE_ELTORITO):
|
|
|
|
cp -f $(LIMINE_ELTORITO) $(FULL_LIMINE_ELTORITO)
|
|
|
|
|
|
|
|
$(FULL_LIMINE_SYS):
|
|
|
|
cp -f $(LIMINE_SYS) $(FULL_LIMINE_SYS)
|
|
|
|
|
2022-01-15 02:32:37 -05:00
|
|
|
build-libkernaux.a:
|
2022-01-17 07:13:54 -05:00
|
|
|
cd $(LIBKERNAUX_BUILD) && ./config
|
|
|
|
cd $(LIBKERNAUX_BUILD) && make libkernaux.a
|
|
|
|
cd $(LIBKERNAUX_BUILD) && make install-data install-exec
|
2022-01-15 02:32:37 -05:00
|
|
|
|
2022-01-09 21:24:49 -05:00
|
|
|
%.c.o: %.c
|
|
|
|
$(CC) -c $< -o $@ $(CFLAGS)
|
|
|
|
|
|
|
|
%.S.o: %.S
|
|
|
|
$(AS) $< -o $@
|