mirror of
https://github.com/tailix/libkernaux.git
synced 2025-04-14 17:32:55 -04:00
Automate kernel example for RISC-V
This commit is contained in:
parent
0f3747e5b6
commit
536c1f44f7
4 changed files with 31 additions and 2 deletions
19
config/riscv64
Executable file
19
config/riscv64
Executable file
|
@ -0,0 +1,19 @@
|
|||
#!/bin/sh
|
||||
|
||||
set -e
|
||||
|
||||
ARCH='riscv64'
|
||||
HOST="$ARCH-elf"
|
||||
REPO="$(realpath "$(dirname "$(realpath "$0")")/..")"
|
||||
PREFIX="$REPO/vendor/cross"
|
||||
BIN="$PREFIX/bin"
|
||||
|
||||
if [ -f "$REPO/Makefile" ]; then make -C "$REPO" distclean; fi
|
||||
|
||||
export AR="$BIN/$HOST-ar"
|
||||
export CC="$BIN/$HOST-gcc"
|
||||
export RANLIB="$BIN/$HOST-ranlib"
|
||||
|
||||
export CFLAGS='-ffreestanding -nostdlib -fno-builtin -fno-stack-protector'
|
||||
|
||||
"$REPO/configure" --host="$HOST" --enable-assert --enable-guard --with-libc
|
3
examples/arch-riscv64-min/.gitignore
vendored
3
examples/arch-riscv64-min/.gitignore
vendored
|
@ -1 +1,4 @@
|
|||
/build-libkernaux/*
|
||||
!/build-libkernaux/.keep
|
||||
|
||||
/kernel.elf
|
||||
|
|
|
@ -5,8 +5,10 @@ CCPREFIX = ../../vendor/cross/bin/riscv64-elf-
|
|||
AS = $(CCPREFIX)as
|
||||
CC = $(CCPREFIX)gcc
|
||||
|
||||
CONFIG_LIBKERNAUX = ../../config/riscv64
|
||||
QEMU = qemu-system-riscv64
|
||||
|
||||
BUILD_LIBKERNAUX = build-libkernaux
|
||||
KERNEL = kernel.elf
|
||||
LINKERSCR = linker.ld
|
||||
|
||||
|
@ -25,10 +27,15 @@ run: $(KERNEL)
|
|||
$(QEMU) -machine virt -bios $< -serial stdio -display none
|
||||
|
||||
clean:
|
||||
make -C $(BUILD_LIBKERNAUX) distclean || true
|
||||
rm -f $(KERNEL) $(OBJS)
|
||||
|
||||
$(KERNEL): $(LINKERSCR) $(OBJS)
|
||||
$(CC) -T $(LINKERSCR) -o $@ $(OBJS) -nostdlib -lgcc
|
||||
$(KERNEL): $(LINKERSCR) $(OBJS) build-libkernaux.a
|
||||
$(CC) -T $(LINKERSCR) -o $@ $(OBJS) -nostdlib -lgcc -lkernaux -Wl,-L$(BUILD_LIBKERNAUX)
|
||||
|
||||
build-libkernaux.a:
|
||||
cd $(BUILD_LIBKERNAUX) && ../$(CONFIG_LIBKERNAUX)
|
||||
cd $(BUILD_LIBKERNAUX) && make libkernaux.a
|
||||
|
||||
%.c.o: %.c
|
||||
$(CC) -c $< -o $@ $(CFLAGS)
|
||||
|
|
0
examples/arch-riscv64-min/build-libkernaux/.keep
Normal file
0
examples/arch-riscv64-min/build-libkernaux/.keep
Normal file
Loading…
Add table
Reference in a new issue