11.58Smrg#	$NetBSD: Makefile.arm,v 1.58 2024/02/18 10:49:43 mrg Exp $
21.1Smatt
31.1Smatt# Makefile for NetBSD
41.1Smatt#
51.1Smatt# This makefile is constructed from a machine description:
61.1Smatt#	config machineid
71.1Smatt# Most changes should be made in the machine description
81.1Smatt#	/sys/arch/<arch>/conf/``machineid''
91.1Smatt# after which you should do
101.1Smatt#	config machineid
111.1Smatt# Machine generic makefile changes should be made in
121.1Smatt#	/sys/arch/arm/conf/Makefile.arm
131.1Smatt# after which config should be rerun for all machines of that type.
141.15Satatat#
151.15Satatat# To specify debugging, add the config line: makeoptions DEBUG="-g"
161.15Satatat# A better way is to specify -g only for a few files.
171.15Satatat#
181.15Satatat#	makeoptions DEBUGLIST="uvm* trap if_*"
191.10Sjmc
201.10SjmcUSETOOLS?=	no
211.15SatatatNEED_OWN_INSTALL_TARGET?=no
221.8Sthorpej.include <bsd.own.mk>
231.1Smatt
241.58Smrg.if ${MACHINE_CPU} == "aarch64" && ${HAVE_GCC} != "no"
251.58Smrg. info (Building GENERIC instead of GENERIC64?)
261.58Smrg. error Don't build 32-bit kernel with 64-bit toolchain
271.58Smrg.endif
281.58Smrg
291.15Satatat##
301.15Satatat## (1) port identification
311.15Satatat##
321.15SatatatTHISARM=	$S/arch/${MACHINE}
331.15SatatatARM=		$S/arch/arm
341.24SchristosGENASSYM_CONF=	${ARM}/arm32/genassym.cf
351.15Satatat.-include "$S/arch/${MACHINE}/conf/Makefile.${MACHINE}.inc"
361.1Smatt
371.15Satatat##
381.15Satatat## (2) compile settings
391.15Satatat##
401.18Sthorpej# CPPFLAGS set by platform-specific Makefile fragment.
411.15SatatatAFLAGS+=	-x assembler-with-cpp
421.35SmattCOPTS.arm32_kvminit.c+=		-fno-stack-protector
431.42SjoergCOPTS.vfp_init.c=		-mfpu=vfp
441.51SjoergCLANG_OBSOLETE_MULTI_ST=	${${ACTIVE_CC} == "clang":? -Wa,-W :}
451.51SjoergAFLAGS.bcopyinout.S+=	-marm
461.51SjoergAFLAGS.blockio.S+=	-marm ${CLANG_OBSOLETE_MULTI_ST}
471.51SjoergAFLAGS.copystr.S+=	-marm
481.51SjoergAFLAGS.cpufunc_asm.S+=	${CLANG_OBSOLETE_MULTI_ST}
491.51SjoergAFLAGS.cpuswitch.S+=	-marm -mfpu=vfp
501.51SjoergAFLAGS.exception.S+=	-marm ${CLANG_OBSOLETE_MULTI_ST}
511.51SjoergAFLAGS.fiq_subr.S+=	${CLANG_OBSOLETE_MULTI_ST}
521.51SjoergAFLAGS.fusu.S+=		-marm
531.51SjoergAFLAGS.irq_dispatch.S+=	-marm ${CLANG_OBSOLETE_MULTI_ST}
541.51SjoergAFLAGS.locore.S+=	-marm ${CLANG_OBSOLETE_MULTI_ST}
551.51SjoergCFLAGS+=	 	-mfloat-abi=soft
561.15Satatat
571.40Sjoerg# This files use instructions deprecated for ARMv7+, but still
581.40Sjoerg# included in kernel that build with higher -mcpu=... settings.
591.41SmartinCPPFLAGS.cpufunc_asm_armv4.S+=	-mcpu=arm8
601.40SjoergCPPFLAGS.cpufunc_asm_armv6.S+=	-mcpu=arm1136j-s
611.40SjoergCPPFLAGS.cpufunc_asm_arm11.S+=	-mcpu=arm1136j-s
621.40SjoergCPPFLAGS.cpufunc_asm_xscale.S+=	-mcpu=xscale
631.40Sjoerg
641.52SskrllOPT_DDB=	%DDB%
651.52Sskrll.if !empty(OPT_DDB) && ${HAVE_GCC:U0} > 0
661.53SskrllCFLAGS+=	-mapcs-frame
671.52Sskrll.endif
681.52Sskrll
691.55Sskrll# Note: -fasan-shadow-offset=
701.55Sskrll#	KASAN_SHADOW_START - (__MD_KERNMEM_BASE >> KASAN_SHADOW_SCALE_SHIFT) =
711.55Sskrll#       0xc000_0000 - (0x8000_0000 >> 3) = 0xb000_0000
721.55Sskrll#
731.55Sskrll
741.55Sskrll.if ${KASAN:U0} > 0 && ${HAVE_GCC:U0} > 0
751.55SskrllKASANFLAGS=	\
761.55Sskrll	-fsanitize=kernel-address \
771.55Sskrll	--param asan-globals=1 \
781.55Sskrll	--param asan-stack=1 \
791.55Sskrll	--param asan-instrument-allocas=1 \
801.55Sskrll	-fsanitize-address-use-after-scope \
811.55Sskrll	-fasan-shadow-offset=0xb0000000
821.55Sskrll.for f in subr_asan.c
831.55SskrllKASANFLAGS.${f}=	# empty
841.55Sskrll.endfor
851.55SskrllCFLAGS+=	${KASANFLAGS.${.IMPSRC:T}:U${KASANFLAGS}}
861.55Sskrll.endif
871.55Sskrll
881.15Satatat##
891.15Satatat## (3) libkern and compat
901.15Satatat##
911.49SrinOPT_MODULAR=	%MODULAR%
921.38Smatt
931.15Satatat##
941.15Satatat## (4) local objects, compile rules, and dependencies
951.15Satatat##
961.28SscwMD_OBJS+=	${SYSTEM_FIRST_OBJ} locore.o
971.28SscwMD_CFILES+=
981.28SscwMD_SFILES+=	${SYSTEM_FIRST_SFILE} ${ARM}/arm32/locore.S
991.7Smatt
1001.15Satatat.if defined(SYSTEM_FIRST_OBJ)
1011.15Satatat${SYSTEM_FIRST_OBJ}: ${SYSTEM_FIRST_SFILE} assym.h
1021.15Satatat	${NORMAL_S}
1031.7Smatt.endif
1041.1Smatt
1051.15Satatatlocore.o: ${ARM}/arm32/locore.S assym.h
1061.15Satatat	${NORMAL_S}
1071.1Smatt
1081.15Satatat##
1091.15Satatat## (5) link settings
1101.15Satatat##
1111.3SmattLOADADDRESS?=	0xF0000000
1121.15SatatatLINKFLAGS_NORMAL=	-X
1131.25Sscw# Strip ARM mapping symbols from the kernel image, as they interfere
1141.57Srin# with ddb, but don't strip them in netbsd.gdb. See Makefile.kern.inc.
1151.57SrinARCH_STRIP_SYMBOLS=	--strip-symbol='[$$][atd]' \
1161.56Srin			--strip-symbol='[$$][atd]\.*'
1171.1Smatt
1181.15Satatat##
1191.15Satatat## (6) port specific target dependencies
1201.15Satatat##
1211.1Smatt
1221.15Satatat# depend on CPU configuration
1231.15Satatatcpufunc.o cpufunc_asm.o: Makefile
1241.1Smatt
1251.15Satatat# depend on DIAGNOSTIC etc.
1261.15Satatatcpuswitch.o fault.o machdep.o: Makefile
1271.1Smatt
1281.22Ssimonb# various assembly files that depend on assym.h
1291.31Schrisatomic.o bcopy_page.o bcopyinout.o copystr.o cpuswitch.o cpu_in_cksum.o: assym.h
1301.31Schrisexception.o fiq_subr.o fusu.o irq_dispatch.o isa_irq.o sigcode.o: assym.h
1311.23Ssimonbspl.o vectors.o: assym.h
1321.22Ssimonb
1331.15Satatat##
1341.15Satatat## (7) misc settings
1351.15Satatat##
1361.19Sskrll
1371.15Satatat##
1381.15Satatat## (8) config(8) generated machinery
1391.15Satatat##
1401.15Satatat%INCLUDES
1411.1Smatt
1421.1Smatt%OBJS
1431.1Smatt
1441.1Smatt%CFILES
1451.1Smatt
1461.1Smatt%SFILES
1471.1Smatt
1481.1Smatt%LOAD
1491.1Smatt
1501.15Satatat%RULES
1511.1Smatt
1521.15Satatat##
1531.38Smatt## (9) after the config file is inserted
1541.38Smatt##
1551.38Smatt
1561.38Smatt.for f in ${SFILES:T:Mcpufunc_asm*}
1571.38SmattAFLAGS.${f}+=-marm
1581.38Smatt.endfor
1591.38Smatt
1601.38Smatt##
1611.38Smatt## (10) port independent kernel machinery
1621.15Satatat##
1631.38Smatt
1641.15Satatat.include "$S/conf/Makefile.kern.inc"
1651.21Sthorpej
1661.21Sthorpej##
1671.38Smatt## (11) Appending make options.
1681.21Sthorpej##
1691.21Sthorpej%MAKEOPTIONSAPPEND
170