summaryrefslogtreecommitdiff
path: root/Makefile
diff options
context:
space:
mode:
authorstefan <stefan@s00.xyz>2023-03-31 20:10:19 -0400
committerstefan <stefan@s00.xyz>2023-03-31 20:10:19 -0400
commit254ffbc869c2376e77ecc298dfd396f077e9d58a (patch)
treeab663049beb9002c286602bab9ee97990817a873 /Makefile
parent598b964ee3c1fab162bfc85fa3725501ab238881 (diff)
downloadsv-254ffbc869c2376e77ecc298dfd396f077e9d58a.tar.gz
start of makefile
Diffstat (limited to 'Makefile')
-rw-r--r--Makefile30
1 files changed, 30 insertions, 0 deletions
diff --git a/Makefile b/Makefile
new file mode 100644
index 0000000..3c2a981
--- /dev/null
+++ b/Makefile
@@ -0,0 +1,30 @@
+TARGET?=virt
+CROSS_COMPILE?=riscv64-unknown-elf-
+
+BUILDDIR=build/${TARGET}
+TARGETDIR=mainboard/${TARGET}
+
+CFLAGS=-nostdlib -ffreestanding -mcmodel=medany
+
+.if !exists(${TARGETDIR}/conf/mainboard.mk)
+.error 'ERROR: invalid target "${TARGET}"'
+.else
+.include <${TARGETDIR}/conf/mainboard.mk>
+.endif
+
+all: ${BUILDDIR}/kernel.elf
+
+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 $@
+
+.PHONY: all clean