From 25108684fe235d4296c3cbc480298df209682586 Mon Sep 17 00:00:00 2001 From: stefan Date: Tue, 4 Apr 2023 06:01:50 +0000 Subject: build system and some other stuff --- Makefile | 36 ++++++++++++++---------------------- 1 file changed, 14 insertions(+), 22 deletions(-) (limited to 'Makefile') diff --git a/Makefile b/Makefile index 3c2a981..e683c86 100644 --- a/Makefile +++ b/Makefile @@ -1,30 +1,22 @@ TARGET?=virt CROSS_COMPILE?=riscv64-unknown-elf- +GDB_PORT?=1234 +CFLAGS=-nostdlib -ffreestanding -mcmodel=medany -nostdinc -I${.CURDIR}/include +.export -BUILDDIR=build/${TARGET} -TARGETDIR=mainboard/${TARGET} +sys: ${SRC} lib/build/libc.a + @echo "building kernel" + (${MAKE} -C sys -e) -CFLAGS=-nostdlib -ffreestanding -mcmodel=medany +lib/build/libc.a: + @echo "building libc" + (${MAKE} -C lib -e) -.if !exists(${TARGETDIR}/conf/mainboard.mk) -.error 'ERROR: invalid target "${TARGET}"' -.else -.include <${TARGETDIR}/conf/mainboard.mk> -.endif - -all: ${BUILDDIR}/kernel.elf +debug: sys + (${MAKE} -C sys -e debug) clean: - rm -rf ${BUILDDIR} - -${BUILDDIR}/kernel.elf: ${SRC} - mkdir -p ${BUILDDIR} - ${CROSS_COMPILE}gcc ${SRC} \ - -Wl,--defsym=LOAD_ADDR=${LOAD_ADDR}\ - -Wl,--defsym=PAGE_SIZE=${PAGE_SIZE}\ - -Wl,--defsym=NPROC=${NPROC}\ - -DPAGE_SIZE=${PAGE_SIZE}\ - ${CFLAGS} -T kernel/lds/kernel.ld ${LDFLAGS}\ - -o $@ + (${MAKE} -C sys -e clean) + (${MAKE} -C lib -e clean) -.PHONY: all clean +.PHONY: sys debug all clean -- cgit v1.2.3