xref: /netbsd-src/sys/arch/aarch64/conf/Makefile.aarch64 (revision 8ecbf5f02b752fcb7debe1a8fab1dc82602bc760)
1#	$NetBSD: Makefile.aarch64,v 1.21 2020/05/11 03:00:57 ryo Exp $
2
3# Makefile for NetBSD
4#
5# This makefile is constructed from a machine description:
6#	config machineid
7# Most changes should be made in the machine description
8#	/sys/arch/<arch>/conf/``machineid''
9# after which you should do
10#	config machineid
11# Machine generic makefile changes should be made in
12#	/sys/arch/arm/conf/Makefile.arm
13# after which config should be rerun for all machines of that type.
14#
15# To specify debugging, add the config line: makeoptions DEBUG="-g"
16# A better way is to specify -g only for a few files.
17#
18#	makeoptions DEBUGLIST="uvm* trap if_*"
19
20USETOOLS?=	no
21NEED_OWN_INSTALL_TARGET?=no
22.include <bsd.own.mk>
23
24##
25## (1) port identification
26##
27THISARM=	$S/arch/${MACHINE}
28ARM=		$S/arch/aarch64
29GENASSYM_CONF=	${ARM}/aarch64/genassym.cf
30.-include "$S/arch/${MACHINE}/conf/Makefile.${MACHINE}.inc"
31
32##
33## (2) compile settings
34##
35# CPPFLAGS set by platform-specific Makefile fragment.
36CFLAGS+=	-march=armv8-a+nofp+nosimd
37#CFLAGS+=	-fomit-frame-pointer
38CFLAGS+=	-fno-omit-frame-pointer
39CFLAGS+=	-mno-omit-leaf-frame-pointer
40#CFLAGS+=	-mno-unaligned-access
41
42.if ${HAVE_LLVM:Uno} == "yes"
43.if ${ARMV83_PAC:U0} > 0 && ${ARMV85_BTI:U0} > 0
44CFLAGS+=	-mbranch-protection=pac-ret+bti
45.else
46.if ${ARMV83_PAC:U0} > 0
47CFLAGS+=	-mbranch-protection=pac-ret
48.endif
49.if ${ARMV85_BTI:U0} > 0
50CFLAGS+=	-mbranch-protection=bti
51.endif
52.endif
53.endif
54
55.if ${HAVE_GCC:U0} > 0
56.if ${ARMV83_PAC:U0} > 0
57CFLAGS+=	-msign-return-address=all
58.endif
59.if ${ARMV85_BTI:U0} > 0
60# XXX: notyet for gcc
61.endif
62.endif
63
64.if ${KASAN:U0} > 0 && ${HAVE_GCC:U0} > 0
65KASANFLAGS=	-fsanitize=kernel-address \
66		--param asan-globals=1 --param asan-stack=1 \
67		--param asan-instrument-allocas=1 \
68		-fsanitize-address-use-after-scope \
69		-fasan-shadow-offset=0xDFFF600000000000
70.for f in subr_asan.c
71KASANFLAGS.${f}=	# empty
72.endfor
73CFLAGS+=	${KASANFLAGS.${.IMPSRC:T}:U${KASANFLAGS}}
74.endif
75
76##
77## (3) libkern and compat
78##
79OPT_MODULAR=	%MODULAR%
80
81##
82## (4) local objects, compile rules, and dependencies
83##
84MD_OBJS+=	${SYSTEM_FIRST_OBJ} locore.o
85MD_CFILES+=
86MD_SFILES+=	${SYSTEM_FIRST_SFILE} ${ARM}/aarch64/locore.S
87
88.if defined(SYSTEM_FIRST_OBJ)
89${SYSTEM_FIRST_OBJ}: ${SYSTEM_FIRST_SFILE} assym.h
90	${NORMAL_S}
91.endif
92
93locore.o: ${ARM}/aarch64/locore.S assym.h
94	${NORMAL_S}
95
96##
97## (5) link settings
98##
99KERNLDSCRIPT?=	${ARM}/conf/kern.ldscript
100LOADADDRESS?=	0xffffc00000000000
101LINKFLAGS_NORMAL=	-X
102
103# Strip AArch64 mapping symbols from the kernel image, as they interfere
104# with ddb. Do it differently if 'makeoptions DEBUG="-g"' was specified.
105.if !defined(DEBUG) || empty(DEBUG:M-g*)
106SYSTEM_LD_TAIL?=	${OBJCOPY} -w --strip-symbol='[$$][dx]'	\
107				   --strip-symbol='[$$][dx]\.*' $@ ;\
108			${SIZE} $@; chmod 755 $@
109.else
110STRIPFLAGS=-g --strip-symbol='$$x' --strip-symbol='$$d'
111.endif
112
113##
114## (6) port specific target dependencies
115##
116
117# depend on DIAGNOSTIC etc.
118cpuswitch.o fault.o machdep.o: Makefile
119
120# various assembly files that depend on assym.h
121atomic.o bcopy_page.o bcopyinout.o copystr.o cpuswitch.o cpu_in_cksum.o: assym.h
122exception.o sigcode.o: assym.h
123spl.o vectors.o: assym.h
124
125##
126## (7) misc settings
127##
128
129# define .MAIN _before_ the make() check, so that implicit target
130# would be defined
131.MAIN: all
132
133.if !make(obj) && !make(clean) && !make(cleandir)
134.BEGIN::
135	-@rm -f arm && \
136		ln -s $S/arch/arm/include arm
137.endif
138
139##
140## (8) config(8) generated machinery
141##
142%INCLUDES
143
144%OBJS
145
146%CFILES
147
148%SFILES
149
150%LOAD
151
152%RULES
153
154##
155## (9) after the config file is inserted
156##
157
158##
159## (10) port independent kernel machinery
160##
161
162.include "$S/conf/Makefile.kern.inc"
163
164##
165## (11) Appending make options.
166##
167%MAKEOPTIONSAPPEND
168