Makefile.aarch64 revision 1.24
1#	$NetBSD: Makefile.aarch64,v 1.24 2023/07/26 03:39:55 rin 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 defined(PROF) && ${HAVE_GCC:U0} > 0
43# For accurate profiling, it is better to suppress the tail call.
44CFLAGS+=	-fno-optimize-sibling-calls
45.endif
46
47.if ${ARMV83_PAC:U0} > 0 && ${ARMV85_BTI:U0} > 0
48CFLAGS+=	-mbranch-protection=pac-ret+bti
49.else
50.if ${ARMV83_PAC:U0} > 0
51CFLAGS+=	-mbranch-protection=pac-ret
52.endif
53.if ${ARMV85_BTI:U0} > 0
54CFLAGS+=	-mbranch-protection=bti
55.endif
56.endif
57
58.if ${KASAN:U0} > 0 && ${HAVE_GCC:U0} > 0
59KASANFLAGS=	-fsanitize=kernel-address \
60		--param asan-globals=1 --param asan-stack=1 \
61		--param asan-instrument-allocas=1 \
62		-fsanitize-address-use-after-scope \
63		-fasan-shadow-offset=0xDFFF600000000000
64.for f in subr_asan.c
65KASANFLAGS.${f}=	# empty
66.endfor
67CFLAGS+=	${KASANFLAGS.${.IMPSRC:T}:U${KASANFLAGS}}
68.endif
69
70##
71## (3) libkern and compat
72##
73OPT_MODULAR=	%MODULAR%
74
75##
76## (4) local objects, compile rules, and dependencies
77##
78MD_OBJS+=	${SYSTEM_FIRST_OBJ} locore.o
79MD_CFILES+=
80MD_SFILES+=	${SYSTEM_FIRST_SFILE} ${ARM}/aarch64/locore.S
81
82.if defined(SYSTEM_FIRST_OBJ)
83${SYSTEM_FIRST_OBJ}: ${SYSTEM_FIRST_SFILE} assym.h
84	${NORMAL_S}
85.endif
86
87locore.o: ${ARM}/aarch64/locore.S assym.h
88	${NORMAL_S}
89
90##
91## (5) link settings
92##
93KERNLDSCRIPT?=	${ARM}/conf/kern.ldscript
94LOADADDRESS?=	0xffffc00000000000
95LINKFLAGS_NORMAL=	-X
96
97# Strip AArch64 mapping symbols from the kernel image, as they interfere
98# with ddb, but don't strip them in netbsd.gdb.
99AA64_STRIP_SYMBOLS=	--strip-symbol='[$$][dx]' \
100			--strip-symbol='[$$][dx]\.*'
101.if (defined(DEBUG) && !empty(DEBUG:M-g*)) || (!defined(DEBUG) && \
102	(${MKDEBUGKERNEL:Uno} == "yes" || ${MKDEBUG:Uno} == "yes"))
103OBJCOPY_STRIPFLAGS=	-g -w ${AA64_STRIP_SYMBOLS}
104.else
105SYSTEM_LD_TAIL=		@${OBJCOPY} -w ${AA64_STRIP_SYMBOLS} $@
106.endif
107
108##
109## (6) port specific target dependencies
110##
111
112# depend on DIAGNOSTIC etc.
113cpuswitch.o fault.o machdep.o: Makefile
114
115# various assembly files that depend on assym.h
116atomic.o bcopy_page.o bcopyinout.o copystr.o cpuswitch.o cpu_in_cksum.o: assym.h
117exception.o sigcode.o: assym.h
118spl.o vectors.o: assym.h
119
120##
121## (7) misc settings
122##
123
124# define .MAIN _before_ the make() check, so that implicit target
125# would be defined
126.MAIN: all
127
128.if !make(obj) && !make(clean) && !make(cleandir)
129.BEGIN::
130	-@rm -f arm && \
131		ln -s $S/arch/arm/include arm
132.endif
133
134##
135## (8) config(8) generated machinery
136##
137%INCLUDES
138
139%OBJS
140
141%CFILES
142
143%SFILES
144
145%LOAD
146
147%RULES
148
149##
150## (9) after the config file is inserted
151##
152
153##
154## (10) port independent kernel machinery
155##
156
157.include "$S/conf/Makefile.kern.inc"
158
159##
160## (11) Appending make options.
161##
162%MAKEOPTIONSAPPEND
163