Makefile.arm revision 1.52
11.52Sskrll#	$NetBSD: Makefile.arm,v 1.52 2020/01/02 14:33:55 skrll 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.15Satatat##
251.15Satatat## (1) port identification
261.15Satatat##
271.15SatatatTHISARM=	$S/arch/${MACHINE}
281.15SatatatARM=		$S/arch/arm
291.24SchristosGENASSYM_CONF=	${ARM}/arm32/genassym.cf
301.15Satatat.-include "$S/arch/${MACHINE}/conf/Makefile.${MACHINE}.inc"
311.1Smatt
321.15Satatat##
331.15Satatat## (2) compile settings
341.15Satatat##
351.18Sthorpej# CPPFLAGS set by platform-specific Makefile fragment.
361.15SatatatAFLAGS+=	-x assembler-with-cpp
371.35SmattCOPTS.arm32_kvminit.c+=		-fno-stack-protector
381.42SjoergCOPTS.vfp_init.c=		-mfpu=vfp
391.51SjoergCLANG_OBSOLETE_MULTI_ST=	${${ACTIVE_CC} == "clang":? -Wa,-W :}
401.51SjoergAFLAGS.bcopyinout.S+=	-marm
411.51SjoergAFLAGS.blockio.S+=	-marm ${CLANG_OBSOLETE_MULTI_ST}
421.51SjoergAFLAGS.copystr.S+=	-marm
431.51SjoergAFLAGS.cpufunc_asm.S+=	${CLANG_OBSOLETE_MULTI_ST}
441.51SjoergAFLAGS.cpuswitch.S+=	-marm -mfpu=vfp
451.51SjoergAFLAGS.exception.S+=	-marm ${CLANG_OBSOLETE_MULTI_ST}
461.51SjoergAFLAGS.fiq_subr.S+=	${CLANG_OBSOLETE_MULTI_ST}
471.51SjoergAFLAGS.fusu.S+=		-marm
481.51SjoergAFLAGS.irq_dispatch.S+=	-marm ${CLANG_OBSOLETE_MULTI_ST}
491.51SjoergAFLAGS.locore.S+=	-marm ${CLANG_OBSOLETE_MULTI_ST}
501.51SjoergCFLAGS+=	 	-mfloat-abi=soft
511.15Satatat
521.40Sjoerg# This files use instructions deprecated for ARMv7+, but still
531.40Sjoerg# included in kernel that build with higher -mcpu=... settings.
541.41SmartinCPPFLAGS.cpufunc_asm_armv4.S+=	-mcpu=arm8
551.40SjoergCPPFLAGS.cpufunc_asm_armv6.S+=	-mcpu=arm1136j-s
561.40SjoergCPPFLAGS.cpufunc_asm_arm11.S+=	-mcpu=arm1136j-s
571.40SjoergCPPFLAGS.cpufunc_asm_xscale.S+=	-mcpu=xscale
581.40Sjoerg
591.50Srin.if !empty(MACHINE_ARCH:Mearmv6*) || !empty(MACHINE_ARCH:Mearmv7*)
601.50Srin# XXX
611.50Srin#
621.50Srin# Workaround for alignment faults on ARMv6+, at least occur with
631.50Srin# axe(4) and athn(4) drivers.
641.50Srin#
651.50Srin# For ARMv6+, unaligned access is enabled by default. However, it
661.50Srin# cannot be used for non-cacheable memory, which is used as DMA
671.50Srin# buffers. This results in alignment faults above. A real fix is
681.50Srin# to use cacheable memory as DMA buffers. However, it breaks some
691.50Srin# drivers, awge(4) and vchiq(4) at least.
701.50Srin#
711.50Srin# Until we figure out problems and fix them, we choose a fail-safe
721.50Srin# workaround here; forbid unaligned memory access for whole kernel.
731.50Srin# Affects on performance is negligibly small as far as we can see.
741.50Srin#
751.50Srin# See PR kern/54486 for more details.
761.50SrinCFLAGS+=	-mno-unaligned-access
771.50Srin.endif
781.50Srin
791.52SskrllOPT_DDB=	%DDB%
801.52Sskrll.if !empty(OPT_DDB) && ${HAVE_GCC:U0} > 0
811.52SskrllCOPTS+=		-mapcs-frame
821.52Sskrll.endif
831.52Sskrll
841.15Satatat##
851.15Satatat## (3) libkern and compat
861.15Satatat##
871.49SrinOPT_MODULAR=	%MODULAR%
881.38Smatt
891.15Satatat##
901.15Satatat## (4) local objects, compile rules, and dependencies
911.15Satatat##
921.28SscwMD_OBJS+=	${SYSTEM_FIRST_OBJ} locore.o
931.28SscwMD_CFILES+=
941.28SscwMD_SFILES+=	${SYSTEM_FIRST_SFILE} ${ARM}/arm32/locore.S
951.7Smatt
961.15Satatat.if defined(SYSTEM_FIRST_OBJ)
971.15Satatat${SYSTEM_FIRST_OBJ}: ${SYSTEM_FIRST_SFILE} assym.h
981.15Satatat	${NORMAL_S}
991.7Smatt.endif
1001.1Smatt
1011.15Satatatlocore.o: ${ARM}/arm32/locore.S assym.h
1021.15Satatat	${NORMAL_S}
1031.1Smatt
1041.15Satatat##
1051.15Satatat## (5) link settings
1061.15Satatat##
1071.3SmattLOADADDRESS?=	0xF0000000
1081.15SatatatLINKFLAGS_NORMAL=	-X
1091.25Sscw# Strip ARM mapping symbols from the kernel image, as they interfere
1101.27Sdbj# with ddb. Do it differently if 'makeoptions DEBUG="-g"' was specified.
1111.27Sdbj.if !defined(DEBUG) || empty(DEBUG:M-g*)
1121.45SjoergSYSTEM_LD_TAIL?=	${OBJCOPY} --wildcard --strip-symbol='[$$][atd]' \
1131.43Sjoerg				    --strip-symbol='[$$][atd]\.*' $@;   \
1141.27Sdbj			${SIZE} $@; chmod 755 $@
1151.27Sdbj.else
1161.44SjoergSTRIPFLAGS=-g --wildcard --strip-symbol='[$$][atd]' \
1171.44Sjoerg	   --strip-symbol='[$$][atd]\.*'
1181.27Sdbj.endif
1191.1Smatt
1201.15Satatat##
1211.15Satatat## (6) port specific target dependencies
1221.15Satatat##
1231.1Smatt
1241.15Satatat# depend on CPU configuration
1251.15Satatatcpufunc.o cpufunc_asm.o: Makefile
1261.1Smatt
1271.15Satatat# depend on DIAGNOSTIC etc.
1281.15Satatatcpuswitch.o fault.o machdep.o: Makefile
1291.1Smatt
1301.22Ssimonb# various assembly files that depend on assym.h
1311.31Schrisatomic.o bcopy_page.o bcopyinout.o copystr.o cpuswitch.o cpu_in_cksum.o: assym.h
1321.31Schrisexception.o fiq_subr.o fusu.o irq_dispatch.o isa_irq.o sigcode.o: assym.h
1331.23Ssimonbspl.o vectors.o: assym.h
1341.22Ssimonb
1351.15Satatat##
1361.15Satatat## (7) misc settings
1371.15Satatat##
1381.19Sskrll
1391.15Satatat##
1401.15Satatat## (8) config(8) generated machinery
1411.15Satatat##
1421.15Satatat%INCLUDES
1431.1Smatt
1441.1Smatt%OBJS
1451.1Smatt
1461.1Smatt%CFILES
1471.1Smatt
1481.1Smatt%SFILES
1491.1Smatt
1501.1Smatt%LOAD
1511.1Smatt
1521.15Satatat%RULES
1531.1Smatt
1541.15Satatat##
1551.38Smatt## (9) after the config file is inserted
1561.38Smatt##
1571.38Smatt
1581.38Smatt.for f in ${SFILES:T:Mcpufunc_asm*}
1591.38SmattAFLAGS.${f}+=-marm
1601.38Smatt.endfor
1611.38Smatt
1621.38Smatt##
1631.38Smatt## (10) port independent kernel machinery
1641.15Satatat##
1651.38Smatt
1661.15Satatat.include "$S/conf/Makefile.kern.inc"
1671.21Sthorpej
1681.21Sthorpej##
1691.38Smatt## (11) Appending make options.
1701.21Sthorpej##
1711.21Sthorpej%MAKEOPTIONSAPPEND
172