summaryrefslogtreecommitdiff
path: root/sys/Makefile
blob: a766174967ee7690560de10c05a0f6482f1e5e0e (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
31
32
33
34
35
36
37
38
39
40
41
BUILDDIR=build/${TARGET}
TARGETDIR=../mainboard/${TARGET}

.if !exists(${TARGETDIR}/conf/mainboard.conf)
.error 'ERROR: invalid target "${TARGET}"'
.else
.include <${TARGETDIR}/conf/mainboard.conf>
.endif

SRC=\
    sys/entry.S\
    sys/init.c\
    sys/printf.c\
    sys/mm/kalloc.c\
    sys/smp/spinlock.c\
    dev/fdt/fdt.c
    

${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}\
		-DLOAD_ADDR=${LOAD_ADDR}\
		-DNPROC=${NPROC}\
		-DPAGE_SIZE=${PAGE_SIZE}\
		-I ../include\
		-I ./include\
		${CFLAGS} -T sys/kernel.lds ${LDFLAGS}\
		-L../lib/${BUILDDIR}/\
		-l:libc.a\
		-o $@

debug: ${BUILDDIR}/kernel.elf
	${DEBUG} ${BUILDDIR}/kernel.elf

clean:
	rm -rf ${BUILDDIR}

.PHONY: debug clean