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