xref: /minix/minix/kernel/Makefile (revision b89261ba)
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=1
53.endif
54
55# Extra debugging routines
56.if ${USE_SYSDEBUG} != "no"
57SRCS+= 	debug.c
58CPPFLAGS+= -DUSE_SYSDEBUG=1
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=1
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"
85# dcvmoole: this is a copy of the "${_P}: ${_P}.bcl.o" block from bsd.prog.mk,
86# with two changes: 1) ${OBJS} is added so as to link in objects that have not
87# been compiled with bitcode, and 2) we are directly loading the gold plugin
88# rather than through ${BITCODE_LD_FLAGS_2ND.kernel}, because LLVMgold will
89# not load libLTO when no LTO can be performed (due to the non- bitcode
90# objects), causing it to fail on unrecognized -disable-opt/-disable-inlining
91# options.  At least I think that's what's going on?  I'm no expert here..
92kernel: kernel.bcl.o
93	${_MKTARGET_LINK}
94	${_CCLINK.kernel} \
95		${_LDFLAGS.kernel} \
96		-L${DESTDIR}/usr/lib \
97		${_LDSTATIC.kernel} -o ${.TARGET} \
98		${.TARGET}.bcl.o ${OBJS} ${_PROGLDOPTS} ${_LDADD.kernel} \
99		-Wl,-plugin=${GOLD_PLUGIN} \
100		-Wl,--allow-multiple-definition
101.endif
102
103# Disable magic and ASR passes for the kernel.
104USE_MAGIC=no
105
106.include <minix.service.mk>
107