xref: /minix/minix/kernel/Makefile (revision 045e0ed3)
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.if ${MKPAE:Uno} != "no"
47CPPFLAGS+= -DPAE=1
48.endif
49
50.ifdef CONFIG_SMP
51SRCS+= smp.c
52.endif
53
54.if ${USE_WATCHDOG} != "no"
55SRCS+= watchdog.c
56CPPFLAGS+= -DUSE_WATCHDOG=1
57.endif
58
59# Extra debugging routines
60.if ${USE_SYSDEBUG} != "no"
61SRCS+= 	debug.c
62CPPFLAGS+= -DUSE_SYSDEBUG=1
63.endif
64
65# These come last, so the profiling buffer is at the end of the data segment
66SRCS+= profile.c do_sprofile.c
67
68.if ${USE_LIVEUPDATE} != "no"
69CPPFLAGS+= -DUSE_UPDATE=1
70.endif
71
72CLEANFILES+=extracted-errno.h extracted-mfield.h extracted-mtype.h procoffsets.h
73
74debug.o debug.d: extracted-errno.h extracted-mfield.h extracted-mtype.h
75
76extracted-errno.h: extract-errno.sh ../../include/errno.h
77	${_MKTARGET_CREATE}
78	cd ${.CURDIR} ; ${HOST_SH} extract-errno.sh > ${.OBJDIR}/extracted-errno.h
79
80extracted-mfield.h: extract-mfield.sh ../lib/libc/sys/*.c ../lib/libsys/*.c
81	${_MKTARGET_CREATE}
82	cd ${.CURDIR} ; ${HOST_SH} extract-mfield.sh > ${.OBJDIR}/extracted-mfield.h
83
84extracted-mtype.h: extract-mtype.sh ../include/minix/com.h
85	${_MKTARGET_CREATE}
86	cd ${.CURDIR} ; ${HOST_SH} extract-mtype.sh > ${.OBJDIR}/extracted-mtype.h
87
88.if ${USE_BITCODE:Uno} == "yes"
89# dcvmoole: this is a copy of the "${_P}: ${_P}.bcl.o" block from bsd.prog.mk,
90# with two changes: 1) ${OBJS} is added so as to link in objects that have not
91# been compiled with bitcode, and 2) we are directly loading the gold plugin
92# rather than through ${BITCODE_LD_FLAGS_2ND.kernel}, because LLVMgold will
93# not load libLTO when no LTO can be performed (due to the non- bitcode
94# objects), causing it to fail on unrecognized -disable-opt/-disable-inlining
95# options.  At least I think that's what's going on?  I'm no expert here..
96kernel: kernel.bcl.o
97	${_MKTARGET_LINK}
98	${_CCLINK.kernel} \
99		${_LDFLAGS.kernel} \
100		-L${DESTDIR}/usr/lib \
101		${_LDSTATIC.kernel} -o ${.TARGET} \
102		${.TARGET}.bcl.o ${OBJS} ${_PROGLDOPTS} ${_LDADD.kernel} \
103		-Wl,-plugin=${GOLD_PLUGIN} \
104		-Wl,--allow-multiple-definition
105.endif
106
107# Disable magic and ASR passes for the kernel.
108USE_MAGIC=no
109
110# Disable coverage profiling for the kernel, at least for now.
111MKCOVERAGE=no
112
113.include <minix.service.mk>
114