1
0
Fork 0
mirror of https://github.com/tailix/libkernaux.git synced 2024-10-30 11:54:01 -04:00
libkernaux/examples/bootloader-multiboot2-grub/Makefile

63 lines
1.3 KiB
Makefile
Raw Normal View History

2022-01-12 04:40:35 -05:00
all: test
2022-01-09 20:30:40 -05:00
2022-01-12 00:05:32 -05:00
CCPREFIX = ../../vendor/cross/bin/i386-elf-
2022-01-08 22:06:03 -05:00
AS = $(CCPREFIX)as
CC = $(CCPREFIX)gcc
2022-01-15 02:32:37 -05:00
CONFIG_LIBKERNAUX = ../../config/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-12 04:40:35 -05:00
QEMU = qemu-system-i386
2022-01-09 21:24:49 -05:00
2022-01-15 02:32:37 -05:00
BUILD_LIBKERNAUX = build-libkernaux
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-01-08 22:06:03 -05:00
-std=c99 \
-pedantic \
-Wall \
-Wextra \
2022-01-08 22:08:26 -05:00
-Werror \
2022-01-08 22:06:03 -05:00
-ffreestanding \
-fno-builtin \
-fno-stack-protector \
-I../../include
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-12 04:40:35 -05:00
$(QEMU) -cdrom $< -serial stdio -display none | tee $(OUTPUT)
2022-01-08 22:06:03 -05:00
clean:
2022-01-15 02:32:37 -05:00
make -C $(BUILD_LIBKERNAUX) distclean || true
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-01-15 02:32:37 -05:00
$(KERNEL): $(LINKERSCR) $(OBJS) build-libkernaux.a
$(CC) -T $(LINKERSCR) -o $@ $(OBJS) -ffreestanding -nostdlib -lgcc -lkernaux -Wl,-L$(BUILD_LIBKERNAUX)
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:
cd $(BUILD_LIBKERNAUX) && ../$(CONFIG_LIBKERNAUX)
cd $(BUILD_LIBKERNAUX) && make libkernaux.a
2022-01-08 22:06:03 -05:00
%.c.o: %.c
$(CC) -c $< -o $@ $(CFLAGS)
%.S.o: %.S
$(AS) $< -o $@