2022-01-13 01:38:45 -05:00
|
|
|
all: run
|
|
|
|
|
2022-01-17 13:06:32 -05:00
|
|
|
CCPREFIX = ../../vendor/cross/root/bin/riscv64-elf-
|
2022-01-13 01:38:45 -05:00
|
|
|
|
|
|
|
AS = $(CCPREFIX)as
|
|
|
|
CC = $(CCPREFIX)gcc
|
|
|
|
|
2022-01-17 07:13:54 -05:00
|
|
|
LIBKERNAUX_BUILD = ../../build/dev-cross-riscv64
|
|
|
|
LIBKERNAUX_DEST = ../../dest/dev-cross-riscv64
|
|
|
|
|
2022-01-15 11:10:56 -05:00
|
|
|
QEMU = qemu-system-riscv64 -serial stdio -display none
|
2022-01-13 01:38:45 -05:00
|
|
|
|
2022-01-13 02:11:20 -05:00
|
|
|
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)
|
2022-01-15 11:10:56 -05:00
|
|
|
$(QEMU) -machine virt -bios $<
|
2022-01-13 02:11:20 -05:00
|
|
|
|
|
|
|
clean:
|
|
|
|
rm -f $(KERNEL) $(OBJS)
|
|
|
|
|
2022-01-15 02:57:15 -05:00
|
|
|
$(KERNEL): $(LINKERSCR) $(OBJS) build-libkernaux.a
|
2022-01-17 07:13:54 -05:00
|
|
|
$(CC) -T $(LINKERSCR) -o $@ $(OBJS) -nostdlib -lgcc -lkernaux -Wl,-L$(LIBKERNAUX_DEST)/lib
|
2022-01-15 02:57:15 -05:00
|
|
|
|
|
|
|
build-libkernaux.a:
|
2022-01-17 07:13:54 -05:00
|
|
|
cd $(LIBKERNAUX_BUILD) && ./config
|
|
|
|
cd $(LIBKERNAUX_BUILD) && make libkernaux.a
|
|
|
|
cd $(LIBKERNAUX_BUILD) && make install-data install-exec
|
2022-01-13 02:11:20 -05:00
|
|
|
|
|
|
|
%.c.o: %.c
|
|
|
|
$(CC) -c $< -o $@ $(CFLAGS)
|
|
|
|
|
|
|
|
%.S.o: %.S
|
|
|
|
$(AS) $< -o $@
|