]> git.ipfire.org Git - thirdparty/glibc.git/blame - math/Makefile
Add CVE-2016-6323 missing from NEWS entry
[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
b9e05ed0
PM
45
46libm-calls = \
47 e_acosF e_acoshF e_asinF e_atan2F e_atanhF e_coshF e_expF e_fmodF \
48 e_hypotF e_j0F e_j1F e_jnF e_lgammaF_r e_logF e_log10F e_powF \
49 e_rem_pio2F e_remainderF e_scalbF e_sinhF e_sqrtF e_gammaF_r \
50 e_ilogbF \
51 k_cosF k_rem_pio2F k_sinF k_tanF s_asinhF s_atanF s_cbrtF \
52 s_ceilF s_cosF s_erfF s_expm1F s_fabsF \
53 s_floorF s_log1pF w_log1pF s_logbF \
54 s_nextafterF s_nexttowardF s_rintF s_scalblnF w_scalblnF \
55 s_significandF s_sinF s_tanF s_tanhF w_acosF w_acoshF w_asinF \
56 w_atan2F w_atanhF w_coshF w_expF w_exp2F w_exp10F w_fmodF \
57 w_tgammaF w_hypotF w_j0F w_j1F w_jnF w_lgammaF w_lgammaF_r \
58 w_logF w_log10F w_powF w_remainderF w_scalbF w_sinhF w_sqrtF \
59 w_ilogbF \
60 s_fpclassifyF s_fmaxF s_fminF s_fdimF s_nanF s_truncF \
61 s_remquoF e_log2F e_exp2F s_roundF s_nearbyintF s_sincosF \
62 conjF cimagF crealF cabsF cargF s_cexpF s_csinhF s_ccoshF s_clogF \
63 s_catanF s_casinF s_ccosF s_csinF s_ctanF s_ctanhF s_cacosF \
64 s_casinhF s_cacoshF s_catanhF s_csqrtF s_cpowF s_cprojF s_clog10F \
65 s_fmaF s_lrintF s_llrintF s_lroundF s_llroundF e_exp10F w_log2F \
66 s_issignalingF $(calls:s_%=m_%) x2y2m1F k_casinhF \
67 gamma_productF lgamma_negF lgamma_productF \
68 s_nextupF s_nextdownF
69
70libm-compat-calls-ldouble-yes = w_lgamma_compatl k_standardl
71libm-compat-calls = w_lgamma_compatf w_lgamma_compat k_standard k_standardf \
72 $(libm-compat-calls-ldouble-$(long-double-fcts))
73
74
75# Type specific routine support.
76#
77# The following three variables control what is included for each type:
78#
79# type-floatN-suffix = The suffix of the type
80# type-floatN-routines = Type specific support objects
81# type-floatN-yes = If the type is supported, evaluates to floatN
82#
83# Finally, note that types is an intentionally recursive variable.
84# We only know the full set of supported types for the target machine
85# after the Rules makefile has been parsed.
86types = $(type-ldouble-$(long-double-fcts)) double float
87
88# long double support
89type-ldouble-suffix := l
90type-ldouble-routines := t_sincosl k_sincosl
91type-ldouble-yes := ldouble
92
93# double support
94type-double-suffix :=
95type-double-routines := branred doasin dosincos halfulp mpa mpatan2 \
96 mpatan mpexp mplog mpsqrt mptan sincos32 slowexp \
97 slowpow sincostab
98
99# float support
100type-float-suffix := f
101type-float-routines :=
102
103
104# Apply suffix to each type in arg 1
105type-foreach = $(foreach t,$(types),$(subst F,$(type-$(t)-suffix),$(1)))
106
107libm-routines = $(strip $(libm-support) $(libm-compat-calls) \
108 $(call type-foreach, $(libm-calls)) \
109 $(foreach t, $(types), $(type-$(t)-routines))) \
58e07151 110
f7eac6eb
RM
111# These functions are in libc instead of libm because __printf_fp
112# calls them, so any program using printf will need them linked in,
113# and we don't want to have to link every program with -lm.
92712dee
RM
114# In libm-calls (above), list m_foo in place of s_foo for any
115# routine that should be compiled separately for its libc and libm versions.
b9e05ed0
PM
116calls = s_isinfF s_isnanF s_finiteF s_copysignF s_modfF s_scalbnF s_frexpF \
117 s_ldexpF s_signbitF
118generated += $(foreach s,.c .S,$(call type-foreach, $(calls:s_%=m_%$(s))))
119routines = $(call type-foreach, $(calls))
8847214f 120
5695d46f
AS
121ifeq ($(build-mathvec),yes)
122# We need to install libm.so as linker script
123# for more comfortable use of vector math library.
124install-lib-ldscripts := libm.so
125install_subdir: $(inst_libdir)/libm.so
126$(inst_libdir)/libm.so: $(common-objpfx)format.lds \
127 $(libm) \
128 $(libmvec) \
129 $(+force)
130 (echo '/* GNU ld script'; echo '*/';\
131 cat $<; \
132 echo 'GROUP ( $(slibdir)/libm.so$(libm.so-version) ' \
b3f60407 133 'AS_NEEDED ( $(libdir)/libmvec_nonshared.a $(slibdir)/libmvec.so$(libmvec.so-version) ) )' \
f9378ac3
DAS
134 ) > $@.new
135 mv -f $@.new $@
5695d46f
AS
136endif
137
c57abfa7 138# Rules for the test suite.
9861985f 139tests = test-matherr test-fenv atest-exp atest-sincos atest-exp2 basic-test \
95e7cf29
MR
140 test-misc test-fpucw test-fpucw-ieee tst-definitions test-tgmath \
141 test-tgmath-ret bug-nextafter bug-nexttoward bug-tgmath1 \
142 test-tgmath-int test-tgmath2 test-powl tst-CMPLX tst-CMPLX2 test-snan \
85b29045 143 test-fenv-tls test-fenv-preserve test-fenv-return test-fenvinline \
939fdd1c 144 test-nearbyint-except test-fenv-clear test-signgam-finite \
71d1b016 145 test-signgam-finite-c99 test-signgam-finite-c11 \
d709042a
JM
146 test-nearbyint-except-2 test-signgam-uchar test-signgam-uchar-init \
147 test-signgam-uint test-signgam-uint-init test-signgam-ullong \
8f5e8b01 148 test-signgam-ullong-init test-nan-overflow test-nan-payload \
5220a1aa 149 test-fexcept test-fexcept-traps $(tests-static)
d709042a
JM
150tests-static = test-fpucw-static test-fpucw-ieee-static \
151 test-signgam-uchar-static test-signgam-uchar-init-static \
152 test-signgam-uint-static test-signgam-uint-init-static \
153 test-signgam-ullong-static test-signgam-ullong-init-static
c57abfa7 154
0800411f
RM
155ifneq (,$(CXX))
156tests += test-math-isinff
157endif
158
8847214f 159ifneq (no,$(PERL))
24a2718f 160libm-vec-tests = $(addprefix test-,$(libmvec-tests))
b9e05ed0
PM
161
162libm-tests = $(foreach t,$(types),test-$(t) test-$(t)-finite test-i$(t)) \
163 $(libm-vec-tests)
164
8847214f
UD
165libm-tests.o = $(addsuffix .o,$(libm-tests))
166
167tests += $(libm-tests)
b4bcb3ae
AS
168libm-vec-test-wrappers = $(addsuffix -wrappers, $(libm-vec-tests))
169test-extras += $(libm-vec-test-wrappers)
170extra-test-objs += $(addsuffix .o, $(libm-vec-test-wrappers))
58c50f06 171libm-tests-generated = libm-test-ulps.h libm-have-vector-test.h libm-test.c
882ed1be 172generated += $(libm-tests-generated) libm-test.stmp
8847214f 173
882ed1be
UD
174# This is needed for dependencies
175before-compile += $(objpfx)libm-test.c
8847214f 176
e0a3ed4f 177ulps-file = $(firstword $(wildcard $(sysdirs:%=%/libm-test-ulps)))
882ed1be
UD
178
179$(addprefix $(objpfx), $(libm-tests-generated)): $(objpfx)libm-test.stmp
8847214f 180
ffb536d0 181$(objpfx)libm-test.stmp: $(ulps-file) libm-test.inc gen-libm-test.pl \
58c50f06 182 gen-libm-have-vector-test.sh auto-libm-test-out
882ed1be
UD
183 $(make-target-directory)
184 $(PERL) gen-libm-test.pl -u $< -o "$(objpfx)"
58c50f06 185 $(SHELL) gen-libm-have-vector-test.sh > $(objpfx)libm-have-vector-test.h
8847214f 186 @echo > $@
8847214f
UD
187endif
188
24a2718f
AS
189libm-test-fast-math-cflags = -fno-builtin -D__FAST_MATH__ -DTEST_FAST_MATH
190libm-test-vec-cflags = $(libm-test-fast-math-cflags) -fno-inline \
191 -ffloat-store -D_OPENMP=201307 -Wno-unknown-pragmas
192
193CFLAGS-test-double-vlen2.c = $(libm-test-vec-cflags)
24a2718f
AS
194
195CFLAGS-test-double-vlen4.c = $(libm-test-vec-cflags)
196CFLAGS-test-double-vlen4-wrappers.c = $(double-vlen4-arch-ext-cflags)
197
198CFLAGS-test-double-vlen8.c = $(libm-test-vec-cflags)
199CFLAGS-test-double-vlen8-wrappers.c = $(double-vlen8-arch-ext-cflags)
200
2a523216 201CFLAGS-test-float-vlen4.c = $(libm-test-vec-cflags)
2a523216
AS
202
203CFLAGS-test-float-vlen8.c = $(libm-test-vec-cflags)
204CFLAGS-test-float-vlen8-wrappers.c = $(float-vlen8-arch-ext-cflags)
205
206CFLAGS-test-float-vlen16.c = $(libm-test-vec-cflags)
207CFLAGS-test-float-vlen16-wrappers.c = $(float-vlen16-arch-ext-cflags)
208
26211284
JM
209# The no-inline tests use -fsignaling-nans, and thereby use the
210# versions of classification macros that support sNaNs. The inline
211# function tests use the versions of classification macros that may
212# raise spurious exceptions for sNaNs, but also do not test for
213# exceptions. Thus both versions of the classification macros are
214# validated.
215libm-test-no-inline-cflags = -fno-inline -ffloat-store -fno-builtin \
216 -fsignaling-nans
5a28590a
JM
217libm-test-finite-cflags = $(libm-test-no-inline-cflags) \
218 -U__FINITE_MATH_ONLY__ -D__FINITE_MATH_ONLY__=1
219CFLAGS-test-float.c = $(libm-test-no-inline-cflags)
220CFLAGS-test-float-finite.c = $(libm-test-finite-cflags)
221CFLAGS-test-double.c = $(libm-test-no-inline-cflags)
222CFLAGS-test-double-finite.c = $(libm-test-finite-cflags)
223CFLAGS-test-ldouble.c = $(libm-test-no-inline-cflags)
224CFLAGS-test-ldouble-finite.c = $(libm-test-finite-cflags)
4f2689f4 225CFLAGS-test-tgmath.c = -fno-builtin
d077f65f
MT
226# The following testcase uses very long lines (>3 million), so it may take a
227# while to compile it. See: http://llvm.org/bugs/show_bug.cgi?id=14106 and
228# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54402
8790af5f 229CFLAGS-test-tgmath2.c = -fno-builtin
301a6724 230CFLAGS-test-tgmath-ret.c = -fno-builtin
8db73634 231CFLAGS-test-powl.c = -fno-builtin
8df4e219
WD
232
233CFLAGS-test-snan.c = -fsignaling-nans
24a2718f
AS
234CPPFLAGS-test-ifloat.c = -U__LIBC_INTERNAL_MATH_INLINES \
235 $(libm-test-fast-math-cflags)
236CPPFLAGS-test-idouble.c = -U__LIBC_INTERNAL_MATH_INLINES \
237 $(libm-test-fast-math-cflags)
b9e05ed0 238CPPFLAGS-test-ildouble.c = -U__LIBC_INTERNAL_MATH_INLINES \
24a2718f 239 $(libm-test-fast-math-cflags)
c57abfa7 240
939fdd1c
JM
241CFLAGS-test-signgam-finite.c = -ffinite-math-only
242CFLAGS-test-signgam-finite-c99.c = -ffinite-math-only -std=c99
243CFLAGS-test-signgam-finite-c11.c = -ffinite-math-only -std=c11
d709042a
JM
244CFLAGS-test-signgam-uchar.c = -std=c99
245CFLAGS-test-signgam-uchar-init.c = -std=c99
246CFLAGS-test-signgam-uchar-static.c = -std=c99
247CFLAGS-test-signgam-uchar-init-static.c = -std=c99
248CFLAGS-test-signgam-uint.c = -std=c99
249CFLAGS-test-signgam-uint-init.c = -std=c99
250CFLAGS-test-signgam-uint-static.c = -std=c99
251CFLAGS-test-signgam-uint-init-static.c = -std=c99
252CFLAGS-test-signgam-ullong.c = -std=c99
253CFLAGS-test-signgam-ullong-init.c = -std=c99
254CFLAGS-test-signgam-ullong-static.c = -std=c99
255CFLAGS-test-signgam-ullong-init-static.c = -std=c99
939fdd1c 256
3c47c83a
CD
257CFLAGS-test-math-isinff.cc = -std=gnu++11
258
26da047f
RM
259# The -lieee module sets the _LIB_VERSION_ switch to IEEE mode
260# for error handling in the -lm functions.
261install-lib += libieee.a
262non-lib.a += libieee.a
263extra-objs += libieee.a ieee-math.o
264
28f540f4
RM
265include ../Rules
266
26510bdd 267ifneq (no,$(PERL))
b2faf4ea 268# This must come after the inclusion of sysdeps Makefiles via Rules.
b9e05ed0 269$(addprefix $(objpfx), $(libm-tests.o)): $(objpfx)libm-test.stmp
b2faf4ea 270
26510bdd
CD
271# Run the math programs to automatically generate ULPs files.
272.PHONY: regen-ulps
273
274run-regen-ulps = $(test-wrapper-env) \
8540f6d2 275 $(run-program-env) \
01dc6df9 276 $($*-ENV) $(rtld-prefix) $${run}
26510bdd
CD
277
278regen-ulps: $(addprefix $(objpfx),$(libm-tests))
279 rm -f $(objpfx)ULPs; rm -f $(objpfx)NewUlps; \
280 cp $(ulps-file) $(objpfx)libm-test-ulps; \
281 for run in $^; do \
282 echo "Regenerating ULPs for $${run}"; \
283 $(run-regen-ulps) -u -o $(objpfx); \
284 cat $(objpfx)ULPs >> $(objpfx)libm-test-ulps; \
285 rm $(objpfx)ULPs; \
286 done; \
287 $(PERL) gen-libm-test.pl -o $(objpfx) -n -u $(objpfx)libm-test-ulps; \
288 echo "Automatic regeneration of ULPs complete."; \
289 echo "Difference between the current baseline and the new baseline is:";\
290 diff -urN $(ulps-file) $(objpfx)NewUlps; \
291 echo "Copy $(objpfx)NewUlps to $(ulps-file) (relative to source)."
292else
293regen-ulps:
294 @echo "Automatic regeneration of ULPs requires perl."; \
295 exit 1;
296endif
f7eac6eb 297
2f663a98
RM
298# The generated sysd-rules file defines rules like this for sources
299# coming from sysdeps/ directories. These rules find the generic sources.
300define o-iterator-doit
301$(objpfx)m_%$o: s_%.c $(before-compile); $$(compile-command.c)
302endef
303object-suffixes-left := $(all-object-suffixes)
304include $(o-iterator)
305
306
f7eac6eb
RM
307# This file defines the default _LIB_VERSION variable that controls
308# the error return conventions for the math functions.
309CPPFLAGS-s_lib_version.c := -D_POSIX_MODE
310
a641835a
RM
311# We don't want the fdlibm code to use the inline math functions,
312# only the fdlibm code.
4b9afc43 313math-CPPFLAGS += -D__NO_MATH_INLINES -D__LIBC_INTERNAL_MATH_INLINES
a641835a 314
58e07151
RM
315ifneq ($(long-double-fcts),yes)
316# The `double' and `long double' types are the same on this machine.
317# We won't compile the `long double' code at all. Tell the `double' code
f5cb4a5c
RM
318# to define aliases for the `FUNCl' names. To avoid type conflicts in
319# defining those aliases, tell <math.h> to declare the `FUNCl' names with
320# `double' instead of `long double'.
4b9afc43 321math-CPPFLAGS += -DNO_LONG_DOUBLE -D_Mlong_double_=double
58e07151
RM
322endif
323
a6a4395d
JM
324# These files quiet sNaNs in a way that is optimized away without
325# -fsignaling-nans.
326CFLAGS-s_modf.c += -fsignaling-nans
327CFLAGS-s_modff.c += -fsignaling-nans
328CFLAGS-s_modfl.c += -fsignaling-nans
329
26da047f
RM
330# The -lieee library is actually an object file.
331# The module just defines the _LIB_VERSION_ variable.
332# It's not a library to make sure it is linked in instead of s_lib_version.o.
333$(objpfx)libieee.a: $(objpfx)ieee-math.o
334 rm -f $@
e7c5513d
UD
335 $(patsubst %/,cd % &&,$(objpfx)) \
336 $(LN_S) $(<F) $(@F)
3e5f5557 337
b4bcb3ae
AS
338$(addprefix $(objpfx),\
339 $(filter-out $(tests-static) $(libm-vec-tests),$(tests))): $(libm)
95e7cf29 340$(addprefix $(objpfx),$(tests-static)): $(objpfx)libm.a
b4bcb3ae
AS
341$(addprefix $(objpfx), $(libm-vec-tests)): $(objpfx)%: $(objpfx)%-wrappers.o \
342 $(libm) $(libmvec)
9498096c 343
2119dcfa 344gmp-objs = $(patsubst %,$(common-objpfx)stdlib/%.o,\
6075607b 345 add_n sub_n cmp addmul_1 mul_1 mul_n divmod_1 \
32fcb36d
DM
346 lshift rshift mp_clz_tab udiv_qrnnd inlines \
347 $(gmp-sysdep_routines))
6075607b
UD
348$(objpfx)atest-exp: $(gmp-objs)
349$(objpfx)atest-sincos: $(gmp-objs)
350$(objpfx)atest-exp2: $(gmp-objs)
79520f4b 351$(objpfx)test-fenv-tls: $(shared-thread-library)