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