Makefile.arm revision 1.51
1#	$NetBSD: Makefile.arm,v 1.51 2019/11/11 22:45:27 joerg 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
59.if !empty(MACHINE_ARCH:Mearmv6*) || !empty(MACHINE_ARCH:Mearmv7*)
60# XXX
61#
62# Workaround for alignment faults on ARMv6+, at least occur with
63# axe(4) and athn(4) drivers.
64#
65# For ARMv6+, unaligned access is enabled by default. However, it
66# cannot be used for non-cacheable memory, which is used as DMA
67# buffers. This results in alignment faults above. A real fix is
68# to use cacheable memory as DMA buffers. However, it breaks some
69# drivers, awge(4) and vchiq(4) at least.
70#
71# Until we figure out problems and fix them, we choose a fail-safe
72# workaround here; forbid unaligned memory access for whole kernel.
73# Affects on performance is negligibly small as far as we can see.
74#
75# See PR kern/54486 for more details.
76CFLAGS+=	-mno-unaligned-access
77.endif
78
79##
80## (3) libkern and compat
81##
82OPT_MODULAR=	%MODULAR%
83
84##
85## (4) local objects, compile rules, and dependencies
86##
87MD_OBJS+=	${SYSTEM_FIRST_OBJ} locore.o
88MD_CFILES+=
89MD_SFILES+=	${SYSTEM_FIRST_SFILE} ${ARM}/arm32/locore.S
90
91.if defined(SYSTEM_FIRST_OBJ)
92${SYSTEM_FIRST_OBJ}: ${SYSTEM_FIRST_SFILE} assym.h
93	${NORMAL_S}
94.endif
95
96locore.o: ${ARM}/arm32/locore.S assym.h
97	${NORMAL_S}
98
99##
100## (5) link settings
101##
102LOADADDRESS?=	0xF0000000
103LINKFLAGS_NORMAL=	-X
104# Strip ARM mapping symbols from the kernel image, as they interfere
105# with ddb. Do it differently if 'makeoptions DEBUG="-g"' was specified.
106.if !defined(DEBUG) || empty(DEBUG:M-g*)
107SYSTEM_LD_TAIL?=	${OBJCOPY} --wildcard --strip-symbol='[$$][atd]' \
108				    --strip-symbol='[$$][atd]\.*' $@;   \
109			${SIZE} $@; chmod 755 $@
110.else
111STRIPFLAGS=-g --wildcard --strip-symbol='[$$][atd]' \
112	   --strip-symbol='[$$][atd]\.*'
113.endif
114
115##
116## (6) port specific target dependencies
117##
118
119# depend on CPU configuration
120cpufunc.o cpufunc_asm.o: Makefile
121
122# depend on DIAGNOSTIC etc.
123cpuswitch.o fault.o machdep.o: Makefile
124
125# various assembly files that depend on assym.h
126atomic.o bcopy_page.o bcopyinout.o copystr.o cpuswitch.o cpu_in_cksum.o: assym.h
127exception.o fiq_subr.o fusu.o irq_dispatch.o isa_irq.o sigcode.o: assym.h
128spl.o vectors.o: assym.h
129
130##
131## (7) misc settings
132##
133
134##
135## (8) config(8) generated machinery
136##
137%INCLUDES
138
139%OBJS
140
141%CFILES
142
143%SFILES
144
145%LOAD
146
147%RULES
148
149##
150## (9) after the config file is inserted
151##
152
153.for f in ${SFILES:T:Mcpufunc_asm*}
154AFLAGS.${f}+=-marm
155.endfor
156
157##
158## (10) port independent kernel machinery
159##
160
161.include "$S/conf/Makefile.kern.inc"
162
163##
164## (11) Appending make options.
165##
166%MAKEOPTIONSAPPEND
167