1 ifneq ($(TARGET_USE_PRIVATE_LIBM),true)
2 LOCAL_PATH:= $(call my-dir)
4 bionic_coverage := false
6 # TODO: this comes from from upstream's libc, not libm, but it's an
7 # implementation detail that should have hidden visibility, so it needs
8 # to be in whatever library the math code is in.
9 libm_common_src_files := \
12 # TODO: this is not in the BSDs.
13 libm_common_src_files += \
17 libm_common_src_files += \
18 upstream-freebsd/lib/msun/bsdsrc/b_exp.c \
19 upstream-freebsd/lib/msun/bsdsrc/b_log.c \
20 upstream-freebsd/lib/msun/bsdsrc/b_tgamma.c \
21 upstream-freebsd/lib/msun/src/catrig.c \
22 upstream-freebsd/lib/msun/src/catrigf.c \
23 upstream-freebsd/lib/msun/src/e_acos.c \
24 upstream-freebsd/lib/msun/src/e_acosf.c \
25 upstream-freebsd/lib/msun/src/e_acosh.c \
26 upstream-freebsd/lib/msun/src/e_acoshf.c \
27 upstream-freebsd/lib/msun/src/e_asin.c \
28 upstream-freebsd/lib/msun/src/e_asinf.c \
29 upstream-freebsd/lib/msun/src/e_atan2.c \
30 upstream-freebsd/lib/msun/src/e_atan2f.c \
31 upstream-freebsd/lib/msun/src/e_atanh.c \
32 upstream-freebsd/lib/msun/src/e_atanhf.c \
33 upstream-freebsd/lib/msun/src/e_cosh.c \
34 upstream-freebsd/lib/msun/src/e_coshf.c \
35 upstream-freebsd/lib/msun/src/e_exp.c \
36 upstream-freebsd/lib/msun/src/e_expf.c \
37 upstream-freebsd/lib/msun/src/e_fmod.c \
38 upstream-freebsd/lib/msun/src/e_fmodf.c \
39 upstream-freebsd/lib/msun/src/e_gamma.c \
40 upstream-freebsd/lib/msun/src/e_gammaf.c \
41 upstream-freebsd/lib/msun/src/e_gammaf_r.c \
42 upstream-freebsd/lib/msun/src/e_gamma_r.c \
43 upstream-freebsd/lib/msun/src/e_hypot.c \
44 upstream-freebsd/lib/msun/src/e_hypotf.c \
45 upstream-freebsd/lib/msun/src/e_j0.c \
46 upstream-freebsd/lib/msun/src/e_j0f.c \
47 upstream-freebsd/lib/msun/src/e_j1.c \
48 upstream-freebsd/lib/msun/src/e_j1f.c \
49 upstream-freebsd/lib/msun/src/e_jn.c \
50 upstream-freebsd/lib/msun/src/e_jnf.c \
51 upstream-freebsd/lib/msun/src/e_lgamma.c \
52 upstream-freebsd/lib/msun/src/e_lgammaf.c \
53 upstream-freebsd/lib/msun/src/e_lgammaf_r.c \
54 upstream-freebsd/lib/msun/src/e_lgamma_r.c \
55 upstream-freebsd/lib/msun/src/e_log10.c \
56 upstream-freebsd/lib/msun/src/e_log10f.c \
57 upstream-freebsd/lib/msun/src/e_log2.c \
58 upstream-freebsd/lib/msun/src/e_log2f.c \
59 upstream-freebsd/lib/msun/src/e_log.c \
60 upstream-freebsd/lib/msun/src/e_logf.c \
61 upstream-freebsd/lib/msun/src/e_pow.c \
62 upstream-freebsd/lib/msun/src/e_powf.c \
63 upstream-freebsd/lib/msun/src/e_remainder.c \
64 upstream-freebsd/lib/msun/src/e_remainderf.c \
65 upstream-freebsd/lib/msun/src/e_rem_pio2.c \
66 upstream-freebsd/lib/msun/src/e_rem_pio2f.c \
67 upstream-freebsd/lib/msun/src/e_scalb.c \
68 upstream-freebsd/lib/msun/src/e_scalbf.c \
69 upstream-freebsd/lib/msun/src/e_sinh.c \
70 upstream-freebsd/lib/msun/src/e_sinhf.c \
71 upstream-freebsd/lib/msun/src/e_sqrt.c \
72 upstream-freebsd/lib/msun/src/e_sqrtf.c \
73 upstream-freebsd/lib/msun/src/imprecise.c \
74 upstream-freebsd/lib/msun/src/k_cos.c \
75 upstream-freebsd/lib/msun/src/k_cosf.c \
76 upstream-freebsd/lib/msun/src/k_exp.c \
77 upstream-freebsd/lib/msun/src/k_expf.c \
78 upstream-freebsd/lib/msun/src/k_rem_pio2.c \
79 upstream-freebsd/lib/msun/src/k_sin.c \
80 upstream-freebsd/lib/msun/src/k_sinf.c \
81 upstream-freebsd/lib/msun/src/k_tan.c \
82 upstream-freebsd/lib/msun/src/k_tanf.c \
83 upstream-freebsd/lib/msun/src/s_asinh.c \
84 upstream-freebsd/lib/msun/src/s_asinhf.c \
85 upstream-freebsd/lib/msun/src/s_atan.c \
86 upstream-freebsd/lib/msun/src/s_atanf.c \
87 upstream-freebsd/lib/msun/src/s_carg.c \
88 upstream-freebsd/lib/msun/src/s_cargf.c \
89 upstream-freebsd/lib/msun/src/s_cargl.c \
90 upstream-freebsd/lib/msun/src/s_cbrt.c \
91 upstream-freebsd/lib/msun/src/s_cbrtf.c \
92 upstream-freebsd/lib/msun/src/s_ccosh.c \
93 upstream-freebsd/lib/msun/src/s_ccoshf.c \
94 upstream-freebsd/lib/msun/src/s_ceil.c \
95 upstream-freebsd/lib/msun/src/s_ceilf.c \
96 upstream-freebsd/lib/msun/src/s_cexp.c \
97 upstream-freebsd/lib/msun/src/s_cexpf.c \
98 upstream-freebsd/lib/msun/src/s_cimag.c \
99 upstream-freebsd/lib/msun/src/s_cimagf.c \
100 upstream-freebsd/lib/msun/src/s_cimagl.c \
101 upstream-freebsd/lib/msun/src/s_conj.c \
102 upstream-freebsd/lib/msun/src/s_conjf.c \
103 upstream-freebsd/lib/msun/src/s_conjl.c \
104 upstream-freebsd/lib/msun/src/s_copysign.c \
105 upstream-freebsd/lib/msun/src/s_copysignf.c \
106 upstream-freebsd/lib/msun/src/s_cos.c \
107 upstream-freebsd/lib/msun/src/s_cosf.c \
108 upstream-freebsd/lib/msun/src/s_cproj.c \
109 upstream-freebsd/lib/msun/src/s_cprojf.c \
110 upstream-freebsd/lib/msun/src/s_cprojl.c \
111 upstream-freebsd/lib/msun/src/s_creal.c \
112 upstream-freebsd/lib/msun/src/s_crealf.c \
113 upstream-freebsd/lib/msun/src/s_creall.c \
114 upstream-freebsd/lib/msun/src/s_csinh.c \
115 upstream-freebsd/lib/msun/src/s_csinhf.c \
116 upstream-freebsd/lib/msun/src/s_csqrt.c \
117 upstream-freebsd/lib/msun/src/s_csqrtf.c \
118 upstream-freebsd/lib/msun/src/s_csqrtl.c \
119 upstream-freebsd/lib/msun/src/s_ctanh.c \
120 upstream-freebsd/lib/msun/src/s_ctanhf.c \
121 upstream-freebsd/lib/msun/src/s_erf.c \
122 upstream-freebsd/lib/msun/src/s_erff.c \
123 upstream-freebsd/lib/msun/src/s_exp2.c \
124 upstream-freebsd/lib/msun/src/s_exp2f.c \
125 upstream-freebsd/lib/msun/src/s_expm1.c \
126 upstream-freebsd/lib/msun/src/s_expm1f.c \
127 upstream-freebsd/lib/msun/src/s_fabs.c \
128 upstream-freebsd/lib/msun/src/s_fabsf.c \
129 upstream-freebsd/lib/msun/src/s_fdim.c \
130 upstream-freebsd/lib/msun/src/s_finite.c \
131 upstream-freebsd/lib/msun/src/s_finitef.c \
132 upstream-freebsd/lib/msun/src/s_floor.c \
133 upstream-freebsd/lib/msun/src/s_floorf.c \
134 upstream-freebsd/lib/msun/src/s_fma.c \
135 upstream-freebsd/lib/msun/src/s_fmaf.c \
136 upstream-freebsd/lib/msun/src/s_fmax.c \
137 upstream-freebsd/lib/msun/src/s_fmaxf.c \
138 upstream-freebsd/lib/msun/src/s_fmin.c \
139 upstream-freebsd/lib/msun/src/s_fminf.c \
140 upstream-freebsd/lib/msun/src/s_frexp.c \
141 upstream-freebsd/lib/msun/src/s_frexpf.c \
142 upstream-freebsd/lib/msun/src/s_ilogb.c \
143 upstream-freebsd/lib/msun/src/s_ilogbf.c \
144 upstream-freebsd/lib/msun/src/s_llrint.c \
145 upstream-freebsd/lib/msun/src/s_llrintf.c \
146 upstream-freebsd/lib/msun/src/s_llround.c \
147 upstream-freebsd/lib/msun/src/s_llroundf.c \
148 upstream-freebsd/lib/msun/src/s_log1p.c \
149 upstream-freebsd/lib/msun/src/s_log1pf.c \
150 upstream-freebsd/lib/msun/src/s_logb.c \
151 upstream-freebsd/lib/msun/src/s_logbf.c \
152 upstream-freebsd/lib/msun/src/s_lrint.c \
153 upstream-freebsd/lib/msun/src/s_lrintf.c \
154 upstream-freebsd/lib/msun/src/s_lround.c \
155 upstream-freebsd/lib/msun/src/s_lroundf.c \
156 upstream-freebsd/lib/msun/src/s_modf.c \
157 upstream-freebsd/lib/msun/src/s_modff.c \
158 upstream-freebsd/lib/msun/src/s_nan.c \
159 upstream-freebsd/lib/msun/src/s_nearbyint.c \
160 upstream-freebsd/lib/msun/src/s_nextafter.c \
161 upstream-freebsd/lib/msun/src/s_nextafterf.c \
162 upstream-freebsd/lib/msun/src/s_remquo.c \
163 upstream-freebsd/lib/msun/src/s_remquof.c \
164 upstream-freebsd/lib/msun/src/s_rint.c \
165 upstream-freebsd/lib/msun/src/s_rintf.c \
166 upstream-freebsd/lib/msun/src/s_round.c \
167 upstream-freebsd/lib/msun/src/s_roundf.c \
168 upstream-freebsd/lib/msun/src/s_scalbln.c \
169 upstream-freebsd/lib/msun/src/s_scalbn.c \
170 upstream-freebsd/lib/msun/src/s_scalbnf.c \
171 upstream-freebsd/lib/msun/src/s_signgam.c \
172 upstream-freebsd/lib/msun/src/s_significand.c \
173 upstream-freebsd/lib/msun/src/s_significandf.c \
174 upstream-freebsd/lib/msun/src/s_sin.c \
175 upstream-freebsd/lib/msun/src/s_sinf.c \
176 upstream-freebsd/lib/msun/src/s_tan.c \
177 upstream-freebsd/lib/msun/src/s_tanf.c \
178 upstream-freebsd/lib/msun/src/s_tanh.c \
179 upstream-freebsd/lib/msun/src/s_tanhf.c \
180 upstream-freebsd/lib/msun/src/s_tgammaf.c \
181 upstream-freebsd/lib/msun/src/s_trunc.c \
182 upstream-freebsd/lib/msun/src/s_truncf.c \
183 upstream-freebsd/lib/msun/src/w_cabs.c \
184 upstream-freebsd/lib/msun/src/w_cabsf.c \
185 upstream-freebsd/lib/msun/src/w_cabsl.c \
186 upstream-freebsd/lib/msun/src/w_drem.c \
187 upstream-freebsd/lib/msun/src/w_dremf.c \
189 libm_common_src_files += \
193 libm_ld128_src_files = \
194 upstream-freebsd/lib/msun/src/e_acosl.c \
195 upstream-freebsd/lib/msun/src/e_acoshl.c \
196 upstream-freebsd/lib/msun/src/e_asinl.c \
197 upstream-freebsd/lib/msun/src/e_atan2l.c \
198 upstream-freebsd/lib/msun/src/e_atanhl.c \
199 upstream-freebsd/lib/msun/src/e_fmodl.c \
200 upstream-freebsd/lib/msun/src/e_hypotl.c \
201 upstream-freebsd/lib/msun/src/e_lgammal.c \
202 upstream-freebsd/lib/msun/src/e_remainderl.c \
203 upstream-freebsd/lib/msun/src/e_sqrtl.c \
204 upstream-freebsd/lib/msun/src/s_asinhl.c \
205 upstream-freebsd/lib/msun/src/s_atanl.c \
206 upstream-freebsd/lib/msun/src/s_cbrtl.c \
207 upstream-freebsd/lib/msun/src/s_ceill.c \
208 upstream-freebsd/lib/msun/src/s_copysignl.c \
209 upstream-freebsd/lib/msun/src/e_coshl.c \
210 upstream-freebsd/lib/msun/src/s_cosl.c \
211 upstream-freebsd/lib/msun/src/s_fabsl.c \
212 upstream-freebsd/lib/msun/src/s_floorl.c \
213 upstream-freebsd/lib/msun/src/s_fmal.c \
214 upstream-freebsd/lib/msun/src/s_fmaxl.c \
215 upstream-freebsd/lib/msun/src/s_fminl.c \
216 upstream-freebsd/lib/msun/src/s_modfl.c \
217 upstream-freebsd/lib/msun/src/s_frexpl.c \
218 upstream-freebsd/lib/msun/src/s_ilogbl.c \
219 upstream-freebsd/lib/msun/src/s_llrintl.c \
220 upstream-freebsd/lib/msun/src/s_llroundl.c \
221 upstream-freebsd/lib/msun/src/s_logbl.c \
222 upstream-freebsd/lib/msun/src/s_lrintl.c \
223 upstream-freebsd/lib/msun/src/s_lroundl.c \
224 upstream-freebsd/lib/msun/src/s_nextafterl.c \
225 upstream-freebsd/lib/msun/src/s_nexttoward.c \
226 upstream-freebsd/lib/msun/src/s_nexttowardf.c \
227 upstream-freebsd/lib/msun/src/s_remquol.c \
228 upstream-freebsd/lib/msun/src/s_rintl.c \
229 upstream-freebsd/lib/msun/src/s_roundl.c \
230 upstream-freebsd/lib/msun/src/s_scalbnl.c \
231 upstream-freebsd/lib/msun/src/e_sinhl.c \
232 upstream-freebsd/lib/msun/src/s_sinl.c \
233 upstream-freebsd/lib/msun/src/s_tanhl.c \
234 upstream-freebsd/lib/msun/src/s_tanl.c \
235 upstream-freebsd/lib/msun/src/s_truncl.c \
237 libm_ld128_src_files += \
238 upstream-freebsd/lib/msun/ld128/invtrig.c \
239 upstream-freebsd/lib/msun/ld128/e_lgammal_r.c \
240 upstream-freebsd/lib/msun/ld128/k_cosl.c \
241 upstream-freebsd/lib/msun/ld128/k_sinl.c \
242 upstream-freebsd/lib/msun/ld128/k_tanl.c \
243 upstream-freebsd/lib/msun/ld128/s_erfl.c \
244 upstream-freebsd/lib/msun/ld128/s_exp2l.c \
245 upstream-freebsd/lib/msun/ld128/s_expl.c \
246 upstream-freebsd/lib/msun/ld128/s_logl.c \
247 upstream-freebsd/lib/msun/ld128/s_nanl.c \
249 # TODO: re-enable i387/e_sqrtf.S for x86, and maybe others.
251 libm_common_cflags := \
252 -DFLT_EVAL_METHOD=0 \
254 -include $(LOCAL_PATH)/freebsd-compat.h \
255 -Wno-missing-braces \
259 -Wno-unknown-pragmas \
260 -fvisibility=hidden \
262 # Workaround the GCC "(long)fn -> lfn" optimization bug which will result in
263 # self recursions for lrint, lrintf, and lrintl.
265 libm_common_cflags += -fno-builtin-rint -fno-builtin-rintf -fno-builtin-rintl
267 libm_common_includes := $(LOCAL_PATH)/upstream-freebsd/lib/msun/src/
269 libm_ld_includes := $(LOCAL_PATH)/upstream-freebsd/lib/msun/ld128/
274 include $(CLEAR_VARS)
275 ifneq (,$(filter $(TARGET_ARCH),x86 x86_64))
276 # Clang has wrong long double sizes for x86.
280 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
281 LOCAL_ARM_MODE := arm
282 LOCAL_CFLAGS := $(libm_common_cflags)
283 LOCAL_C_INCLUDES += $(libm_common_includes)
284 LOCAL_SRC_FILES := $(libm_common_src_files)
285 LOCAL_SYSTEM_SHARED_LIBRARIES := libc
287 LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
288 LOCAL_ADDRESS_SANITIZER := false
290 # arch-specific settings
291 LOCAL_C_INCLUDES_arm := $(LOCAL_PATH)/arm
292 LOCAL_SRC_FILES_arm := arm/fenv.c
294 LOCAL_C_INCLUDES_arm64 := $(libm_ld_includes)
295 LOCAL_SRC_FILES_arm64 := arm64/fenv.c $(libm_ld128_src_files)
297 LOCAL_C_INCLUDES_x86 := $(LOCAL_PATH)/i387
298 LOCAL_SRC_FILES_x86 := i387/fenv.c
300 LOCAL_C_INCLUDES_x86_64 := $(libm_ld_includes)
301 LOCAL_SRC_FILES_x86_64 := amd64/fenv.c $(libm_ld128_src_files)
303 LOCAL_SRC_FILES_mips := mips/fenv.c
305 LOCAL_C_INCLUDES_mips64 := $(libm_ld_includes)
306 LOCAL_SRC_FILES_mips64 := mips/fenv.c $(libm_ld128_src_files)
308 LOCAL_CXX_STL := none
309 include $(BUILD_STATIC_LIBRARY)
312 # libm.so for target.
314 include $(CLEAR_VARS)
315 ifneq (,$(filter $(TARGET_ARCH),x86 x86_64))
316 # Clang has wrong long double sizes for x86.
320 LOCAL_ADDITIONAL_DEPENDENCIES := $(LOCAL_PATH)/Android.mk
321 LOCAL_SYSTEM_SHARED_LIBRARIES := libc
322 LOCAL_WHOLE_STATIC_LIBRARIES := libm
324 LOCAL_NATIVE_COVERAGE := $(bionic_coverage)
325 LOCAL_ADDRESS_SANITIZER := false
327 LOCAL_CXX_STL := none
329 # We'd really like to do this for all architectures, but since this wasn't done
330 # before, these symbols must continue to be exported on LP32 for binary
332 LOCAL_LDFLAGS_arm64 := -Wl,--exclude-libs,libgcc.a
333 LOCAL_LDFLAGS_mips64 := -Wl,--exclude-libs,libgcc.a
334 LOCAL_LDFLAGS_x86_64 := -Wl,--exclude-libs,libgcc.a
335 include $(BUILD_SHARED_LIBRARY)