1
0
Fork 0
mirror of https://github.com/tailix/libkernaux.git synced 2024-10-30 11:54:01 -04:00
libkernaux/examples/arch-riscv64-min/Makefile
2022-01-17 17:13:54 +05:00

45 lines
918 B
Makefile

all: run
CCPREFIX = ../../vendor/cross/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 -lgcc -lkernaux -Wl,-L$(LIBKERNAUX_DEST)/lib
build-libkernaux.a:
cd $(LIBKERNAUX_BUILD) && ./config
cd $(LIBKERNAUX_BUILD) && make libkernaux.a
cd $(LIBKERNAUX_BUILD) && make install-data install-exec
%.c.o: %.c
$(CC) -c $< -o $@ $(CFLAGS)
%.S.o: %.S
$(AS) $< -o $@