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