2022-01-12 04:40:35 -05:00
|
|
|
all: test
|
2022-01-09 20:30:40 -05:00
|
|
|
|
2022-01-17 13:06:32 -05:00
|
|
|
CCPREFIX = ../../vendor/cross/root/bin/i386-elf-
|
2022-01-08 22:06:03 -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
|
|
|
|
GRUB_MKRESCUE = grub-mkrescue
|
2022-01-15 11:10:56 -05:00
|
|
|
QEMU = qemu-system-i386 -serial stdio -display none
|
2022-01-09 21:24:49 -05:00
|
|
|
|
2022-01-12 04:40:35 -05:00
|
|
|
EXPECTED = expected.txt
|
2022-01-08 22:06:03 -05:00
|
|
|
IMAGE = image.iso
|
|
|
|
LINKERSCR = linker.ld
|
2022-01-12 04:40:35 -05:00
|
|
|
OUTPUT = output.txt
|
2022-01-08 22:06:03 -05:00
|
|
|
ROOTFS = rootfs
|
|
|
|
|
|
|
|
GRUBCFG = $(ROOTFS)/boot/grub/grub.cfg
|
|
|
|
KERNEL = $(ROOTFS)/boot/kernel
|
|
|
|
|
2022-01-08 22:16:54 -05:00
|
|
|
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-08 22:06:03 -05:00
|
|
|
|
2022-01-14 00:40:51 -05:00
|
|
|
OBJS = main.c.o multiboot2.c.o start.S.o
|
2022-01-08 22:06:03 -05:00
|
|
|
|
2022-01-12 04:40:35 -05:00
|
|
|
test: run
|
|
|
|
$(DIFF) -a -Z $(EXPECTED) $(OUTPUT)
|
|
|
|
|
2022-01-09 20:30:40 -05:00
|
|
|
run: $(IMAGE)
|
2022-01-15 11:10:56 -05:00
|
|
|
$(QEMU) -cdrom $< | tee $(OUTPUT)
|
2022-01-08 22:06:03 -05:00
|
|
|
|
|
|
|
clean:
|
2022-01-12 04:40:35 -05:00
|
|
|
rm -f $(OUTPUT) $(IMAGE) $(KERNEL) $(OBJS)
|
2022-01-08 22:06:03 -05:00
|
|
|
|
|
|
|
$(IMAGE): $(GRUBCFG) $(KERNEL)
|
2022-01-09 21:24:49 -05:00
|
|
|
$(GRUB_MKRESCUE) $(ROOTFS) -o $@
|
2022-01-08 22:06:03 -05:00
|
|
|
|
2022-02-01 22:43:20 -05:00
|
|
|
$(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 $@
|
2022-01-08 22:06:03 -05:00
|
|
|
|
2022-01-15 02:32:37 -05:00
|
|
|
build-libkernaux.a:
|
2022-06-10 01:23:03 -04:00
|
|
|
cd $(LIBKERNAUX_BUILD) && ./config && make install
|
2022-01-15 02:32:37 -05:00
|
|
|
|
2022-01-08 22:06:03 -05:00
|
|
|
%.c.o: %.c
|
|
|
|
$(CC) -c $< -o $@ $(CFLAGS)
|
|
|
|
|
|
|
|
%.S.o: %.S
|
|
|
|
$(AS) $< -o $@
|