xref: /minix/minix/kernel/Makefile (revision e3b78ef1)
1# Makefile for kernel
2.include <bsd.own.mk>
3
4PROG=		kernel
5BINDIR=		/usr/sbin
6MAN=
7
8.if ${MACHINE_ARCH} == "earm" && ${MKLLVM:Uno} == "yes"
9# BJG - problems with optimisation of the kernel by llvm
10DBG=-O0
11.endif
12
13.include "arch/${MACHINE_ARCH}/Makefile.inc"
14
15SRCS+=	clock.c cpulocals.c interrupt.c main.c proc.c system.c \
16	table.c utility.c usermapped_data.c
17
18LDADD+=	-ltimers -lsys -lexec
19
20LINKERSCRIPT= ${.CURDIR}/arch/${MACHINE_ARCH}/kernel.lds
21
22.if ${HAVE_GOLD:U} != ""
23CFLAGS+= -fno-common
24.endif
25LDFLAGS+= -T ${LINKERSCRIPT}
26LDFLAGS+= -nostdlib -L${DESTDIR}/usr/lib
27CFLAGS += -fno-stack-protector
28
29CPPFLAGS+= -D__kernel__
30
31# kernel headers are always called through kernel/*.h
32CPPFLAGS+= -I${NETBSDSRCDIR}/minix
33
34# kernel headers are always called through kernel/*.h, this
35# time for generated headers, during cross compilation
36CPPFLAGS+= -I${.OBJDIR}/..
37
38# Machine-dependent headers, order is important!
39CPPFLAGS+= -I${.CURDIR}/arch/${MACHINE_ARCH}
40CPPFLAGS+= -I${.CURDIR}/arch/${MACHINE_ARCH}/include
41CPPFLAGS+= -I${.CURDIR}/arch/${MACHINE_ARCH}/bsp/include
42CPPFLAGS+= -I${NETBSDSRCDIR}/minix/include/arch/${MACHINE_ARCH}/include
43
44.include "system/Makefile.inc"
45
46.ifdef CONFIG_SMP
47SRCS+= smp.c
48.endif
49
50.if ${USE_WATCHDOG} != "no"
51SRCS+= watchdog.c
52CPPFLAGS+= -DUSE_WATCHDOG
53.endif
54
55# Extra debugging routines
56.if ${USE_SYSDEBUG} != "no"
57SRCS+= 	debug.c
58CPPFLAGS+= -DUSE_SYSDEBUG
59.endif
60
61# These come last, so the profiling buffer is at the end of the data segment
62SRCS+= profile.c do_sprofile.c
63
64.if ${USE_LIVEUPDATE} != "no"
65CPPFLAGS+= -DUSE_UPDATE
66.endif
67
68CLEANFILES+=extracted-errno.h extracted-mfield.h extracted-mtype.h procoffsets.h
69
70debug.o debug.d: extracted-errno.h extracted-mfield.h extracted-mtype.h
71
72extracted-errno.h: extract-errno.sh ../../include/errno.h
73	${_MKTARGET_CREATE}
74	cd ${.CURDIR} ; ${HOST_SH} extract-errno.sh > ${.OBJDIR}/extracted-errno.h
75
76extracted-mfield.h: extract-mfield.sh ../lib/libc/sys/*.c ../lib/libsys/*.c
77	${_MKTARGET_CREATE}
78	cd ${.CURDIR} ; ${HOST_SH} extract-mfield.sh > ${.OBJDIR}/extracted-mfield.h
79
80extracted-mtype.h: extract-mtype.sh ../include/minix/com.h
81	${_MKTARGET_CREATE}
82	cd ${.CURDIR} ; ${HOST_SH} extract-mtype.sh > ${.OBJDIR}/extracted-mtype.h
83
84.if ${USE_BITCODE:Uno} == "yes"
85kernel: kernel.bcl.o
86	${_MKTARGET_LINK}
87	${_CCLINK.kernel} \
88		${_LDFLAGS.kernel} \
89		-L${DESTDIR}/usr/lib \
90		${_LDSTATIC.kernel} -o ${.TARGET} \
91		${.TARGET}.bcl.o ${OBJS} ${_PROGLDOPTS} ${_LDADD.kernel} \
92		${BITCODE_LD_FLAGS_2ND.kernel} \
93		-Wl,--allow-multiple-definition
94.endif
95
96.include <minix.service.mk>
97