]> git.ipfire.org Git - thirdparty/glibc.git/blame - math/Makefile
Update copyright dates with scripts/update-copyrights.
[thirdparty/glibc.git] / math / Makefile
CommitLineData
f7a9f785 1# Copyright (C) 1996-2016 Free Software Foundation, Inc.
28f540f4
RM
2# This file is part of the GNU C Library.
3
4# The GNU C Library is free software; you can redistribute it and/or
41bdb6e2
AJ
5# modify it under the terms of the GNU Lesser General Public
6# License as published by the Free Software Foundation; either
7# version 2.1 of the License, or (at your option) any later version.
28f540f4
RM
8
9# The GNU C Library is distributed in the hope that it will be useful,
10# but WITHOUT ANY WARRANTY; without even the implied warranty of
11# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
41bdb6e2 12# Lesser General Public License for more details.
28f540f4 13
41bdb6e2 14# You should have received a copy of the GNU Lesser General Public
59ba27a6
PE
15# License along with the GNU C Library; if not, see
16# <http://www.gnu.org/licenses/>.
0c5ecdc4
UD
17
18# Makefile for the math library.
28f540f4 19
f7eac6eb
RM
20subdir := math
21
a5f891ac
JM
22include ../Makeconfig
23
f7eac6eb 24# Installed header files.
5107cf1d 25headers := math.h bits/mathcalls.h bits/mathinline.h bits/huge_val.h \
a86573f4
RH
26 bits/huge_valf.h bits/huge_vall.h bits/inf.h bits/nan.h \
27 fpu_control.h complex.h bits/cmathcalls.h fenv.h \
0ac5ae23 28 bits/fenv.h bits/fenvinline.h bits/mathdef.h tgmath.h \
202d48da
AS
29 bits/math-finite.h bits/math-vector.h \
30 bits/libm-simd-decl-stubs.h
f7eac6eb 31
5fbef188 32# FPU support code.
c94a8080 33aux := setfpucw fpu_control
28f540f4 34
f7eac6eb 35# Build the -lm library.
28f540f4 36
f7eac6eb 37extra-libs := libm
ec4b0518 38extra-libs-others = $(extra-libs)
58e07151 39
f56f9124 40libm-support = s_lib_version s_matherr s_signgam \
63551311
UD
41 fclrexcpt fgetexcptflg fraiseexcpt fsetexcptflg \
42 ftestexcept fegetround fesetround fegetenv feholdexcpt \
05ef7ce9
UD
43 fesetenv feupdateenv t_exp fedisblxcpt feenablxcpt \
44 fegetexcept
58e07151
RM
45libm-calls = e_acos e_acosh e_asin e_atan2 e_atanh e_cosh e_exp e_fmod \
46 e_hypot e_j0 e_j1 e_jn e_lgamma_r e_log e_log10 e_pow \
d705269e 47 e_rem_pio2 e_remainder e_scalb e_sinh e_sqrt e_gamma_r \
76da7265 48 e_ilogb \
d705269e 49 k_cos k_rem_pio2 k_sin k_tan s_asinh s_atan s_cbrt \
502328b2 50 s_ceil s_cos s_erf s_expm1 s_fabs \
de8aadd5 51 s_floor s_log1p w_log1p s_logb \
3ef6b850 52 s_nextafter s_nexttoward s_rint s_scalbln w_scalbln \
dfd2257a 53 s_significand s_sin s_tan s_tanh w_acos w_acosh w_asin \
5ce8f125 54 w_atan2 w_atanh w_cosh w_exp w_exp2 w_exp10 w_fmod \
e852e889 55 w_tgamma w_hypot w_j0 w_j1 w_jn w_lgamma w_lgamma_r \
377a515b 56 w_log w_log10 w_pow w_remainder w_scalb w_sinh w_sqrt \
76da7265 57 w_ilogb \
502328b2 58 s_fpclassify s_fmax s_fmin s_fdim s_nan s_trunc \
601d2942 59 s_remquo e_log2 e_exp2 s_round s_nearbyint s_sincos \
63551311
UD
60 conj cimag creal cabs carg s_cexp s_csinh s_ccosh s_clog \
61 s_catan s_casin s_ccos s_csin s_ctan s_ctanh s_cacos \
dfd2257a 62 s_casinh s_cacosh s_catanh s_csqrt s_cpow s_cproj s_clog10 \
76f2646f 63 s_fma s_lrint s_llrint s_lround s_llround e_exp10 w_log2 \
fe8c2b33 64 s_issignaling $(calls:s_%=m_%) x2y2m1 k_casinh \
d709042a
JM
65 gamma_product k_standard lgamma_neg lgamma_product \
66 w_lgamma_compat
dddf0ed0 67
e4d82761
UD
68dbl-only-routines := branred doasin dosincos halfulp mpa mpatan2 \
69 mpatan mpexp mplog mpsqrt mptan sincos32 slowexp \
af968f62 70 slowpow sincostab
9d1efe33
UD
71libm-routines = $(strip $(libm-support) $(libm-calls) \
72 $(patsubst %_rf,%f_r,$(libm-calls:=f)) \
e4d82761
UD
73 $(long-m-$(long-double-fcts))) \
74 $(dbl-only-routines)
cccda09f 75long-m-routines = $(patsubst %_rl,%l_r,$(libm-calls:=l))
3fe4dc41
UD
76long-m-support = t_sincosl k_sincosl
77long-m-yes = $(long-m-routines) $(long-m-support)
58e07151 78
f7eac6eb
RM
79# These functions are in libc instead of libm because __printf_fp
80# calls them, so any program using printf will need them linked in,
81# and we don't want to have to link every program with -lm.
92712dee
RM
82# In libm-calls (above), list m_foo in place of s_foo for any
83# routine that should be compiled separately for its libc and libm versions.
1f205a47
UD
84calls = s_isinf s_isnan s_finite s_copysign s_modf s_scalbn s_frexp s_ldexp \
85 s_signbit
dddf0ed0 86generated += $(foreach s,.c .S l.c l.S f.c f.S,$(calls:s_%=m_%$s))
e6c9a67a 87routines = $(calls) $(calls:=f) $(long-c-$(long-double-fcts))
58e07151 88long-c-yes = $(calls:=l)
8847214f 89
5695d46f
AS
90ifeq ($(build-mathvec),yes)
91# We need to install libm.so as linker script
92# for more comfortable use of vector math library.
93install-lib-ldscripts := libm.so
94install_subdir: $(inst_libdir)/libm.so
95$(inst_libdir)/libm.so: $(common-objpfx)format.lds \
96 $(libm) \
97 $(libmvec) \
98 $(+force)
99 (echo '/* GNU ld script'; echo '*/';\
100 cat $<; \
101 echo 'GROUP ( $(slibdir)/libm.so$(libm.so-version) ' \
b3f60407 102 'AS_NEEDED ( $(libdir)/libmvec_nonshared.a $(slibdir)/libmvec.so$(libmvec.so-version) ) )' \
5695d46f
AS
103 ) > $@
104endif
105
c57abfa7 106# Rules for the test suite.
9861985f 107tests = test-matherr test-fenv atest-exp atest-sincos atest-exp2 basic-test \
95e7cf29
MR
108 test-misc test-fpucw test-fpucw-ieee tst-definitions test-tgmath \
109 test-tgmath-ret bug-nextafter bug-nexttoward bug-tgmath1 \
110 test-tgmath-int test-tgmath2 test-powl tst-CMPLX tst-CMPLX2 test-snan \
85b29045 111 test-fenv-tls test-fenv-preserve test-fenv-return test-fenvinline \
939fdd1c 112 test-nearbyint-except test-fenv-clear test-signgam-finite \
71d1b016 113 test-signgam-finite-c99 test-signgam-finite-c11 \
d709042a
JM
114 test-nearbyint-except-2 test-signgam-uchar test-signgam-uchar-init \
115 test-signgam-uint test-signgam-uint-init test-signgam-ullong \
8f5e8b01
JM
116 test-signgam-ullong-init test-nan-overflow test-nan-payload \
117 $(tests-static)
d709042a
JM
118tests-static = test-fpucw-static test-fpucw-ieee-static \
119 test-signgam-uchar-static test-signgam-uchar-init-static \
120 test-signgam-uint-static test-signgam-uint-init-static \
121 test-signgam-ullong-static test-signgam-ullong-init-static
c57abfa7 122# We do the `long double' tests only if this data type is available and
af6f3906 123# distinct from `double'.
5a28590a 124test-longdouble-yes = test-ldouble test-ildoubl test-ldouble-finite
c57abfa7 125
8847214f 126ifneq (no,$(PERL))
24a2718f 127libm-vec-tests = $(addprefix test-,$(libmvec-tests))
8847214f 128libm-tests = test-float test-double $(test-longdouble-$(long-double-fcts)) \
5a28590a
JM
129 test-ifloat test-idouble test-float-finite test-double-finite \
130 $(libm-vec-tests)
8847214f
UD
131libm-tests.o = $(addsuffix .o,$(libm-tests))
132
133tests += $(libm-tests)
58c50f06 134libm-tests-generated = libm-test-ulps.h libm-have-vector-test.h libm-test.c
882ed1be 135generated += $(libm-tests-generated) libm-test.stmp
8847214f 136
882ed1be
UD
137# This is needed for dependencies
138before-compile += $(objpfx)libm-test.c
8847214f 139
e0a3ed4f 140ulps-file = $(firstword $(wildcard $(sysdirs:%=%/libm-test-ulps)))
882ed1be
UD
141
142$(addprefix $(objpfx), $(libm-tests-generated)): $(objpfx)libm-test.stmp
8847214f 143
ffb536d0 144$(objpfx)libm-test.stmp: $(ulps-file) libm-test.inc gen-libm-test.pl \
58c50f06 145 gen-libm-have-vector-test.sh auto-libm-test-out
882ed1be
UD
146 $(make-target-directory)
147 $(PERL) gen-libm-test.pl -u $< -o "$(objpfx)"
58c50f06 148 $(SHELL) gen-libm-have-vector-test.sh > $(objpfx)libm-have-vector-test.h
8847214f
UD
149 @echo > $@
150
151$(objpfx)test-float.o: $(objpfx)libm-test.stmp
152$(objpfx)test-ifloat.o: $(objpfx)libm-test.stmp
5a28590a 153$(objpfx)test-float-finite.o: $(objpfx)libm-test.stmp
8847214f
UD
154$(objpfx)test-double.o: $(objpfx)libm-test.stmp
155$(objpfx)test-idouble.o: $(objpfx)libm-test.stmp
5a28590a 156$(objpfx)test-double-finite.o: $(objpfx)libm-test.stmp
8847214f
UD
157$(objpfx)test-ldouble.o: $(objpfx)libm-test.stmp
158$(objpfx)test-ildoubl.o: $(objpfx)libm-test.stmp
5a28590a 159$(objpfx)test-ldouble-finite.o: $(objpfx)libm-test.stmp
8847214f
UD
160endif
161
24a2718f
AS
162libm-test-fast-math-cflags = -fno-builtin -D__FAST_MATH__ -DTEST_FAST_MATH
163libm-test-vec-cflags = $(libm-test-fast-math-cflags) -fno-inline \
164 -ffloat-store -D_OPENMP=201307 -Wno-unknown-pragmas
165
166CFLAGS-test-double-vlen2.c = $(libm-test-vec-cflags)
24a2718f
AS
167
168CFLAGS-test-double-vlen4.c = $(libm-test-vec-cflags)
169CFLAGS-test-double-vlen4-wrappers.c = $(double-vlen4-arch-ext-cflags)
170
171CFLAGS-test-double-vlen8.c = $(libm-test-vec-cflags)
172CFLAGS-test-double-vlen8-wrappers.c = $(double-vlen8-arch-ext-cflags)
173
2a523216 174CFLAGS-test-float-vlen4.c = $(libm-test-vec-cflags)
2a523216
AS
175
176CFLAGS-test-float-vlen8.c = $(libm-test-vec-cflags)
177CFLAGS-test-float-vlen8-wrappers.c = $(float-vlen8-arch-ext-cflags)
178
179CFLAGS-test-float-vlen16.c = $(libm-test-vec-cflags)
180CFLAGS-test-float-vlen16-wrappers.c = $(float-vlen16-arch-ext-cflags)
181
5a28590a
JM
182libm-test-no-inline-cflags = -fno-inline -ffloat-store -fno-builtin
183libm-test-finite-cflags = $(libm-test-no-inline-cflags) \
184 -U__FINITE_MATH_ONLY__ -D__FINITE_MATH_ONLY__=1
185CFLAGS-test-float.c = $(libm-test-no-inline-cflags)
186CFLAGS-test-float-finite.c = $(libm-test-finite-cflags)
187CFLAGS-test-double.c = $(libm-test-no-inline-cflags)
188CFLAGS-test-double-finite.c = $(libm-test-finite-cflags)
189CFLAGS-test-ldouble.c = $(libm-test-no-inline-cflags)
190CFLAGS-test-ldouble-finite.c = $(libm-test-finite-cflags)
4f2689f4 191CFLAGS-test-tgmath.c = -fno-builtin
d077f65f
MT
192# The following testcase uses very long lines (>3 million), so it may take a
193# while to compile it. See: http://llvm.org/bugs/show_bug.cgi?id=14106 and
194# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54402
8790af5f 195CFLAGS-test-tgmath2.c = -fno-builtin
301a6724 196CFLAGS-test-tgmath-ret.c = -fno-builtin
8db73634 197CFLAGS-test-powl.c = -fno-builtin
8df4e219
WD
198
199CFLAGS-test-snan.c = -fsignaling-nans
24a2718f
AS
200CPPFLAGS-test-ifloat.c = -U__LIBC_INTERNAL_MATH_INLINES \
201 $(libm-test-fast-math-cflags)
202CPPFLAGS-test-idouble.c = -U__LIBC_INTERNAL_MATH_INLINES \
203 $(libm-test-fast-math-cflags)
204CPPFLAGS-test-ildoubl.c = -U__LIBC_INTERNAL_MATH_INLINES \
205 $(libm-test-fast-math-cflags)
c57abfa7 206
939fdd1c
JM
207CFLAGS-test-signgam-finite.c = -ffinite-math-only
208CFLAGS-test-signgam-finite-c99.c = -ffinite-math-only -std=c99
209CFLAGS-test-signgam-finite-c11.c = -ffinite-math-only -std=c11
d709042a
JM
210CFLAGS-test-signgam-uchar.c = -std=c99
211CFLAGS-test-signgam-uchar-init.c = -std=c99
212CFLAGS-test-signgam-uchar-static.c = -std=c99
213CFLAGS-test-signgam-uchar-init-static.c = -std=c99
214CFLAGS-test-signgam-uint.c = -std=c99
215CFLAGS-test-signgam-uint-init.c = -std=c99
216CFLAGS-test-signgam-uint-static.c = -std=c99
217CFLAGS-test-signgam-uint-init-static.c = -std=c99
218CFLAGS-test-signgam-ullong.c = -std=c99
219CFLAGS-test-signgam-ullong-init.c = -std=c99
220CFLAGS-test-signgam-ullong-static.c = -std=c99
221CFLAGS-test-signgam-ullong-init-static.c = -std=c99
939fdd1c 222
26da047f
RM
223# The -lieee module sets the _LIB_VERSION_ switch to IEEE mode
224# for error handling in the -lm functions.
225install-lib += libieee.a
226non-lib.a += libieee.a
227extra-objs += libieee.a ieee-math.o
228
28f540f4
RM
229include ../Rules
230
26510bdd 231ifneq (no,$(PERL))
b2faf4ea
JM
232# This must come after the inclusion of sysdeps Makefiles via Rules.
233$(addprefix $(objpfx), $(addsuffix .o, $(libm-vec-tests))): $(objpfx)libm-test.stmp
234
26510bdd
CD
235# Run the math programs to automatically generate ULPs files.
236.PHONY: regen-ulps
237
238run-regen-ulps = $(test-wrapper-env) \
8540f6d2 239 $(run-program-env) \
01dc6df9 240 $($*-ENV) $(rtld-prefix) $${run}
26510bdd
CD
241
242regen-ulps: $(addprefix $(objpfx),$(libm-tests))
243 rm -f $(objpfx)ULPs; rm -f $(objpfx)NewUlps; \
244 cp $(ulps-file) $(objpfx)libm-test-ulps; \
245 for run in $^; do \
246 echo "Regenerating ULPs for $${run}"; \
247 $(run-regen-ulps) -u -o $(objpfx); \
248 cat $(objpfx)ULPs >> $(objpfx)libm-test-ulps; \
249 rm $(objpfx)ULPs; \
250 done; \
251 $(PERL) gen-libm-test.pl -o $(objpfx) -n -u $(objpfx)libm-test-ulps; \
252 echo "Automatic regeneration of ULPs complete."; \
253 echo "Difference between the current baseline and the new baseline is:";\
254 diff -urN $(ulps-file) $(objpfx)NewUlps; \
255 echo "Copy $(objpfx)NewUlps to $(ulps-file) (relative to source)."
256else
257regen-ulps:
258 @echo "Automatic regeneration of ULPs requires perl."; \
259 exit 1;
260endif
f7eac6eb 261
2f663a98
RM
262# The generated sysd-rules file defines rules like this for sources
263# coming from sysdeps/ directories. These rules find the generic sources.
264define o-iterator-doit
265$(objpfx)m_%$o: s_%.c $(before-compile); $$(compile-command.c)
266endef
267object-suffixes-left := $(all-object-suffixes)
268include $(o-iterator)
269
270
f7eac6eb
RM
271# This file defines the default _LIB_VERSION variable that controls
272# the error return conventions for the math functions.
273CPPFLAGS-s_lib_version.c := -D_POSIX_MODE
274
a641835a
RM
275# We don't want the fdlibm code to use the inline math functions,
276# only the fdlibm code.
4b9afc43 277math-CPPFLAGS += -D__NO_MATH_INLINES -D__LIBC_INTERNAL_MATH_INLINES
a641835a 278
58e07151
RM
279ifneq ($(long-double-fcts),yes)
280# The `double' and `long double' types are the same on this machine.
281# We won't compile the `long double' code at all. Tell the `double' code
f5cb4a5c
RM
282# to define aliases for the `FUNCl' names. To avoid type conflicts in
283# defining those aliases, tell <math.h> to declare the `FUNCl' names with
284# `double' instead of `long double'.
4b9afc43 285math-CPPFLAGS += -DNO_LONG_DOUBLE -D_Mlong_double_=double
58e07151
RM
286endif
287
26da047f
RM
288# The -lieee library is actually an object file.
289# The module just defines the _LIB_VERSION_ variable.
290# It's not a library to make sure it is linked in instead of s_lib_version.o.
291$(objpfx)libieee.a: $(objpfx)ieee-math.o
292 rm -f $@
e7c5513d
UD
293 $(patsubst %/,cd % &&,$(objpfx)) \
294 $(LN_S) $(<F) $(@F)
3e5f5557 295
24a2718f 296$(addprefix $(objpfx),$(filter-out $(tests-static) $(libm-vec-tests),$(tests))): $(libm)
95e7cf29 297$(addprefix $(objpfx),$(tests-static)): $(objpfx)libm.a
24a2718f 298$(addprefix $(objpfx), $(libm-vec-tests)): $(objpfx)%: $(libm) $(libmvec) \
1dfa4a94 299 $(objpfx)%-wrappers.o
9498096c 300
2119dcfa 301gmp-objs = $(patsubst %,$(common-objpfx)stdlib/%.o,\
6075607b 302 add_n sub_n cmp addmul_1 mul_1 mul_n divmod_1 \
32fcb36d
DM
303 lshift rshift mp_clz_tab udiv_qrnnd inlines \
304 $(gmp-sysdep_routines))
6075607b
UD
305$(objpfx)atest-exp: $(gmp-objs)
306$(objpfx)atest-sincos: $(gmp-objs)
307$(objpfx)atest-exp2: $(gmp-objs)
79520f4b 308$(objpfx)test-fenv-tls: $(shared-thread-library)