summaryrefslogtreecommitdiff
path: root/Makefile
blob: 3c2a9814546194cc7e58435c50a257b2ce90897b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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