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.4 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-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)
$(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:
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 $@