1# $NetBSD: Makefile.compiler-rt,v 1.14 2023/11/13 19:07:00 mrg Exp $
2
3COMPILER_RT_DIR=	${.PARSEDIR}/../../external/bsd/compiler_rt
4COMPILER_RT_SRCDIR=	${COMPILER_RT_DIR}/dist
5
6.if ${MACHINE_ARCH} == "powerpc"
7COMPILER_RT_CPU_DIR=	${COMPILER_RT_SRCDIR}/lib/builtins/ppc
8COMPILER_RT_ARCH_DIR=	${COMPILER_RT_SRCDIR}/lib/builtins/ppc
9.else
10COMPILER_RT_CPU_DIR=	${COMPILER_RT_SRCDIR}/lib/builtins/${MACHINE_CPU}
11COMPILER_RT_ARCH_DIR=	${COMPILER_RT_SRCDIR}/lib/builtins/${MACHINE_ARCH}
12.endif
13
14.PATH: ${COMPILER_RT_CPU_DIR}
15.PATH: ${COMPILER_RT_ARCH_DIR}
16.PATH: ${COMPILER_RT_SRCDIR}/lib/builtins
17
18GENERIC_SRCS+= \
19	absvdi2.c \
20	absvsi2.c \
21	absvti2.c \
22	addvdi3.c \
23	addvsi3.c \
24	addvti3.c \
25	ashlti3.c \
26	ashrti3.c \
27	clzti2.c \
28	cmpti2.c \
29	ctzti2.c \
30	divti3.c \
31	ffsti2.c \
32	int_util.c \
33	lshrti3.c \
34	modti3.c \
35	mulodi4.c \
36	mulosi4.c \
37	muloti4.c \
38	multi3.c \
39	mulvdi3.c \
40	mulvsi3.c \
41	mulvti3.c \
42	negti2.c \
43	negvdi2.c \
44	negvsi2.c \
45	negvti2.c \
46	paritydi2.c \
47	paritysi2.c \
48	parityti2.c \
49	popcountdi2.c \
50	popcountsi2.c \
51	popcountti2.c \
52	subvdi3.c \
53	subvsi3.c \
54	subvti3.c \
55	ucmpti2.c \
56	udivmodti4.c \
57	udivti3.c \
58	umodti3.c
59
60.if ${MACHINE_CPU} != "aarch64" && ${MACHINE} != "alpha"
61GENERIC_SRCS+= \
62	clzsi2.c \
63	ctzsi2.c
64.endif
65
66.if ${MACHINE_CPU} != "aarch64" && ${MACHINE} != "alpha" && \
67    ${MACHINE_ARCH} != "m68k"
68GENERIC_SRCS+= \
69	divmodsi4.c \
70	divsi3.c \
71	modsi3.c \
72	udivmodsi4.c \
73	udivsi3.c \
74	umodsi3.c
75.endif
76
77.if ${MACHINE_CPU} != "aarch64"
78GENERIC_SRCS+= \
79	clzdi2.c \
80	ctzdi2.c \
81	ffsdi2.c
82.endif
83
84.if ${MACHINE_CPU} != "aarch64" && ${MACHINE} != "alpha"
85GENERIC_SRCS+= \
86	ashldi3.c \
87	ashrdi3.c \
88	lshrdi3.c
89.endif
90
91.if ${MACHINE_CPU} != "aarch64" && ${MACHINE} != "alpha"
92GENERIC_SRCS+= \
93	cmpdi2.c \
94	divdi3.c \
95	divmoddi4.c \
96	moddi3.c \
97	muldi3.c \
98	negdi2.c \
99	ucmpdi2.c \
100	udivdi3.c \
101	udivmoddi4.c \
102	umoddi3.c
103.endif
104
105.if ${MACHINE_CPU} == "arm"
106.  if !empty(MACHINE_ARCH:Mearm*)
107GENERIC_SRCS+= \
108	aeabi_idivmod.S \
109	aeabi_ldivmod.S \
110	aeabi_uidivmod.S \
111	aeabi_uldivmod.S \
112	__aeabi_idiv0.c \
113	__aeabi_ldiv0.c
114.  endif
115.endif
116
117.for src in ${GENERIC_SRCS}
118.  if exists(${COMPILER_RT_CPU_DIR}/${src:R}.S) || \
119      exists(${COMPILER_RT_ARCH_DIR}/${src:R}.S)
120SRCS+=	${src:R}.S
121.  else
122SRCS+=	${src}
123COPTS.${src}+=	-Wno-missing-prototypes \
124		-Wno-old-style-definition \
125		-Wno-strict-prototypes \
126		-Wno-uninitialized
127.  endif
128.endfor
129
130CPPFLAGS.int_util.c+=	-DKERNEL_USE
131
132# XXX Explicit divide by zero in udivmoddi4.c -> abort().
133.if defined(HAVE_GCC) && ${HAVE_GCC} >= 7 && ${ACTIVE_CC} == "gcc"
134. if ${MACHINE_CPU} != "arm"
135COPTS.udivmoddi4.c+=	-fnon-call-exceptions
136. endif
137.endif
138
139# XXX This makes no binary changes at the moment.
140.include "${COMPILER_RT_DIR}/abi.mk"
141