1
0
Fork 0
mirror of https://github.com/tailix/libkernaux.git synced 2024-11-13 11:04:27 -05:00
libkernaux/examples/arch-riscv64-min/Makefile

43 lines
836 B
Makefile

all: run
CCPREFIX = ../../vendor/cross/root/bin/riscv64-elf-
AS = $(CCPREFIX)as
CC = $(CCPREFIX)gcc
LIBKERNAUX_BUILD = ../../build/dev-cross-riscv64
LIBKERNAUX_DEST = ../../dest/dev-cross-riscv64
QEMU = qemu-system-riscv64 -serial stdio -display none
KERNEL = kernel.elf
LINKERSCR = linker.ld
CFLAGS = \
-std=c99 \
-pedantic \
-Wall \
-Wextra \
-Werror \
-ffreestanding \
-mcmodel=medany
OBJS = main.c.o start.S.o
run: $(KERNEL)
$(QEMU) -machine virt -bios $<
clean:
rm -f $(KERNEL) $(OBJS)
$(KERNEL): $(LINKERSCR) $(OBJS) build-libkernaux.a
$(CC) -T $(LINKERSCR) -o $@ $(OBJS) -nostdlib -lkernaux -lgcc -Wl,-L$(LIBKERNAUX_DEST)/lib
build-libkernaux.a:
cd $(LIBKERNAUX_BUILD) && ./config && make install
%.c.o: %.c
$(CC) -c $< -o $@ $(CFLAGS)
%.S.o: %.S
$(AS) $< -o $@