Makefile.arm revision 1.56
1#	$NetBSD: Makefile.arm,v 1.56 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/arm
29GENASSYM_CONF=	${ARM}/arm32/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.
36AFLAGS+=	-x assembler-with-cpp
37COPTS.arm32_kvminit.c+=		-fno-stack-protector
38COPTS.vfp_init.c=		-mfpu=vfp
39CLANG_OBSOLETE_MULTI_ST=	${${ACTIVE_CC} == "clang":? -Wa,-W :}
40AFLAGS.bcopyinout.S+=	-marm
41AFLAGS.blockio.S+=	-marm ${CLANG_OBSOLETE_MULTI_ST}
42AFLAGS.copystr.S+=	-marm
43AFLAGS.cpufunc_asm.S+=	${CLANG_OBSOLETE_MULTI_ST}
44AFLAGS.cpuswitch.S+=	-marm -mfpu=vfp
45AFLAGS.exception.S+=	-marm ${CLANG_OBSOLETE_MULTI_ST}
46AFLAGS.fiq_subr.S+=	${CLANG_OBSOLETE_MULTI_ST}
47AFLAGS.fusu.S+=		-marm
48AFLAGS.irq_dispatch.S+=	-marm ${CLANG_OBSOLETE_MULTI_ST}
49AFLAGS.locore.S+=	-marm ${CLANG_OBSOLETE_MULTI_ST}
50CFLAGS+=	 	-mfloat-abi=soft
51
52# This files use instructions deprecated for ARMv7+, but still
53# included in kernel that build with higher -mcpu=... settings.
54CPPFLAGS.cpufunc_asm_armv4.S+=	-mcpu=arm8
55CPPFLAGS.cpufunc_asm_armv6.S+=	-mcpu=arm1136j-s
56CPPFLAGS.cpufunc_asm_arm11.S+=	-mcpu=arm1136j-s
57CPPFLAGS.cpufunc_asm_xscale.S+=	-mcpu=xscale
58
59OPT_DDB=	%DDB%
60.if !empty(OPT_DDB) && ${HAVE_GCC:U0} > 0
61CFLAGS+=	-mapcs-frame
62.endif
63
64# Note: -fasan-shadow-offset=
65#	KASAN_SHADOW_START - (__MD_KERNMEM_BASE >> KASAN_SHADOW_SCALE_SHIFT) =
66#       0xc000_0000 - (0x8000_0000 >> 3) = 0xb000_0000
67#
68
69.if ${KASAN:U0} > 0 && ${HAVE_GCC:U0} > 0
70KASANFLAGS=	\
71	-fsanitize=kernel-address \
72	--param asan-globals=1 \
73	--param asan-stack=1 \
74	--param asan-instrument-allocas=1 \
75	-fsanitize-address-use-after-scope \
76	-fasan-shadow-offset=0xb0000000
77.for f in subr_asan.c
78KASANFLAGS.${f}=	# empty
79.endfor
80CFLAGS+=	${KASANFLAGS.${.IMPSRC:T}:U${KASANFLAGS}}
81.endif
82
83##
84## (3) libkern and compat
85##
86OPT_MODULAR=	%MODULAR%
87
88##
89## (4) local objects, compile rules, and dependencies
90##
91MD_OBJS+=	${SYSTEM_FIRST_OBJ} locore.o
92MD_CFILES+=
93MD_SFILES+=	${SYSTEM_FIRST_SFILE} ${ARM}/arm32/locore.S
94
95.if defined(SYSTEM_FIRST_OBJ)
96${SYSTEM_FIRST_OBJ}: ${SYSTEM_FIRST_SFILE} assym.h
97	${NORMAL_S}
98.endif
99
100locore.o: ${ARM}/arm32/locore.S assym.h
101	${NORMAL_S}
102
103##
104## (5) link settings
105##
106LOADADDRESS?=	0xF0000000
107LINKFLAGS_NORMAL=	-X
108# Strip ARM mapping symbols from the kernel image, as they interfere
109# with ddb, but don't strip them in netbsd.gdb.
110ARM_STRIP_SYMBOLS=	--strip-symbol='[$$][atd]' \
111			--strip-symbol='[$$][atd]\.*'
112.if (defined(DEBUG) && !empty(DEBUG:M-g*)) || (!defined(DEBUG) && \
113	(${MKDEBUGKERNEL:Uno} == "yes" || ${MKDEBUG:Uno} == "yes"))
114OBJCOPY_STRIPFLAGS=	-g -w ${ARM_STRIP_SYMBOLS}
115.else
116SYSTEM_LD_TAIL=		@${OBJCOPY} -w ${ARM_STRIP_SYMBOLS} $@
117.endif
118
119##
120## (6) port specific target dependencies
121##
122
123# depend on CPU configuration
124cpufunc.o cpufunc_asm.o: Makefile
125
126# depend on DIAGNOSTIC etc.
127cpuswitch.o fault.o machdep.o: Makefile
128
129# various assembly files that depend on assym.h
130atomic.o bcopy_page.o bcopyinout.o copystr.o cpuswitch.o cpu_in_cksum.o: assym.h
131exception.o fiq_subr.o fusu.o irq_dispatch.o isa_irq.o sigcode.o: assym.h
132spl.o vectors.o: assym.h
133
134##
135## (7) misc settings
136##
137
138##
139## (8) config(8) generated machinery
140##
141%INCLUDES
142
143%OBJS
144
145%CFILES
146
147%SFILES
148
149%LOAD
150
151%RULES
152
153##
154## (9) after the config file is inserted
155##
156
157.for f in ${SFILES:T:Mcpufunc_asm*}
158AFLAGS.${f}+=-marm
159.endfor
160
161##
162## (10) port independent kernel machinery
163##
164
165.include "$S/conf/Makefile.kern.inc"
166
167##
168## (11) Appending make options.
169##
170%MAKEOPTIONSAPPEND
171