summaryrefslogtreecommitdiff
path: root/sys/arch/arm/conf/Makefile.arm
blob: 7209597f65275c2e73f8a68e857540eab1a35a9f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
#	$NetBSD: Makefile.arm,v 1.55 2020/07/10 12:25:09 skrll Exp $

# Makefile for NetBSD
#
# This makefile is constructed from a machine description:
#	config machineid
# Most changes should be made in the machine description
#	/sys/arch/<arch>/conf/``machineid''
# after which you should do
#	config machineid
# Machine generic makefile changes should be made in
#	/sys/arch/arm/conf/Makefile.arm
# after which config should be rerun for all machines of that type.
#
# To specify debugging, add the config line: makeoptions DEBUG="-g"
# A better way is to specify -g only for a few files.
#
#	makeoptions DEBUGLIST="uvm* trap if_*"

USETOOLS?=	no
NEED_OWN_INSTALL_TARGET?=no
.include <bsd.own.mk>

##
## (1) port identification
##
THISARM=	$S/arch/${MACHINE}
ARM=		$S/arch/arm
GENASSYM_CONF=	${ARM}/arm32/genassym.cf
.-include "$S/arch/${MACHINE}/conf/Makefile.${MACHINE}.inc"

##
## (2) compile settings
##
# CPPFLAGS set by platform-specific Makefile fragment.
AFLAGS+=	-x assembler-with-cpp
COPTS.arm32_kvminit.c+=		-fno-stack-protector
COPTS.vfp_init.c=		-mfpu=vfp
CLANG_OBSOLETE_MULTI_ST=	${${ACTIVE_CC} == "clang":? -Wa,-W :}
AFLAGS.bcopyinout.S+=	-marm
AFLAGS.blockio.S+=	-marm ${CLANG_OBSOLETE_MULTI_ST}
AFLAGS.copystr.S+=	-marm
AFLAGS.cpufunc_asm.S+=	${CLANG_OBSOLETE_MULTI_ST}
AFLAGS.cpuswitch.S+=	-marm -mfpu=vfp
AFLAGS.exception.S+=	-marm ${CLANG_OBSOLETE_MULTI_ST}
AFLAGS.fiq_subr.S+=	${CLANG_OBSOLETE_MULTI_ST}
AFLAGS.fusu.S+=		-marm
AFLAGS.irq_dispatch.S+=	-marm ${CLANG_OBSOLETE_MULTI_ST}
AFLAGS.locore.S+=	-marm ${CLANG_OBSOLETE_MULTI_ST}
CFLAGS+=	 	-mfloat-abi=soft

# This files use instructions deprecated for ARMv7+, but still
# included in kernel that build with higher -mcpu=... settings.
CPPFLAGS.cpufunc_asm_armv4.S+=	-mcpu=arm8
CPPFLAGS.cpufunc_asm_armv6.S+=	-mcpu=arm1136j-s
CPPFLAGS.cpufunc_asm_arm11.S+=	-mcpu=arm1136j-s
CPPFLAGS.cpufunc_asm_xscale.S+=	-mcpu=xscale

OPT_DDB=	%DDB%
.if !empty(OPT_DDB) && ${HAVE_GCC:U0} > 0
CFLAGS+=	-mapcs-frame
.endif

# Note: -fasan-shadow-offset=
#	KASAN_SHADOW_START - (__MD_KERNMEM_BASE >> KASAN_SHADOW_SCALE_SHIFT) =
#       0xc000_0000 - (0x8000_0000 >> 3) = 0xb000_0000
#

.if ${KASAN:U0} > 0 && ${HAVE_GCC:U0} > 0
KASANFLAGS=	\
	-fsanitize=kernel-address \
	--param asan-globals=1 \
	--param asan-stack=1 \
	--param asan-instrument-allocas=1 \
	-fsanitize-address-use-after-scope \
	-fasan-shadow-offset=0xb0000000
.for f in subr_asan.c
KASANFLAGS.${f}=	# empty
.endfor
CFLAGS+=	${KASANFLAGS.${.IMPSRC:T}:U${KASANFLAGS}}
.endif

##
## (3) libkern and compat
##
OPT_MODULAR=	%MODULAR%

##
## (4) local objects, compile rules, and dependencies
##
MD_OBJS+=	${SYSTEM_FIRST_OBJ} locore.o
MD_CFILES+=
MD_SFILES+=	${SYSTEM_FIRST_SFILE} ${ARM}/arm32/locore.S

.if defined(SYSTEM_FIRST_OBJ)
${SYSTEM_FIRST_OBJ}: ${SYSTEM_FIRST_SFILE} assym.h
	${NORMAL_S}
.endif

locore.o: ${ARM}/arm32/locore.S assym.h
	${NORMAL_S}

##
## (5) link settings
##
LOADADDRESS?=	0xF0000000
LINKFLAGS_NORMAL=	-X
# Strip ARM mapping symbols from the kernel image, as they interfere
# with ddb. Do it differently if 'makeoptions DEBUG="-g"' was specified.
.if !defined(DEBUG) || empty(DEBUG:M-g*)
SYSTEM_LD_TAIL?=	${OBJCOPY} --wildcard --strip-symbol='[$$][atd]' \
				    --strip-symbol='[$$][atd]\.*' $@;   \
			${SIZE} $@; chmod 755 $@
.else
STRIPFLAGS=-g --wildcard --strip-symbol='[$$][atd]' \
	   --strip-symbol='[$$][atd]\.*'
.endif

##
## (6) port specific target dependencies
##

# depend on CPU configuration
cpufunc.o cpufunc_asm.o: Makefile

# depend on DIAGNOSTIC etc.
cpuswitch.o fault.o machdep.o: Makefile

# various assembly files that depend on assym.h
atomic.o bcopy_page.o bcopyinout.o copystr.o cpuswitch.o cpu_in_cksum.o: assym.h
exception.o fiq_subr.o fusu.o irq_dispatch.o isa_irq.o sigcode.o: assym.h
spl.o vectors.o: assym.h

##
## (7) misc settings
##

##
## (8) config(8) generated machinery
##
%INCLUDES

%OBJS

%CFILES

%SFILES

%LOAD

%RULES

##
## (9) after the config file is inserted
##

.for f in ${SFILES:T:Mcpufunc_asm*}
AFLAGS.${f}+=-marm
.endfor

##
## (10) port independent kernel machinery
##

.include "$S/conf/Makefile.kern.inc"

##
## (11) Appending make options.
##
%MAKEOPTIONSAPPEND