]> git.ipfire.org Git - thirdparty/glibc.git/blame - math/Makefile
Consistently include Makeconfig after defining subdir.
[thirdparty/glibc.git] / math / Makefile
CommitLineData
d4697bc9 1# Copyright (C) 1996-2014 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
UD
28 bits/fenv.h bits/fenvinline.h bits/mathdef.h tgmath.h \
29 bits/math-finite.h
f7eac6eb 30
5fbef188 31# FPU support code.
c94a8080 32aux := setfpucw fpu_control
28f540f4 33
f7eac6eb 34# Build the -lm library.
28f540f4 35
f7eac6eb 36extra-libs := libm
ec4b0518 37extra-libs-others = $(extra-libs)
58e07151 38
f9a73ae1 39libm-support = k_standard s_lib_version s_matherr s_signgam \
63551311
UD
40 fclrexcpt fgetexcptflg fraiseexcpt fsetexcptflg \
41 ftestexcept fegetround fesetround fegetenv feholdexcpt \
05ef7ce9
UD
42 fesetenv feupdateenv t_exp fedisblxcpt feenablxcpt \
43 fegetexcept
58e07151
RM
44libm-calls = e_acos e_acosh e_asin e_atan2 e_atanh e_cosh e_exp e_fmod \
45 e_hypot e_j0 e_j1 e_jn e_lgamma_r e_log e_log10 e_pow \
d705269e 46 e_rem_pio2 e_remainder e_scalb e_sinh e_sqrt e_gamma_r \
76da7265 47 e_ilogb \
d705269e 48 k_cos k_rem_pio2 k_sin k_tan s_asinh s_atan s_cbrt \
502328b2 49 s_ceil s_cos s_erf s_expm1 s_fabs \
76da7265 50 s_floor s_log1p s_logb \
502328b2 51 s_nextafter s_nexttoward s_rint s_scalbln \
dfd2257a 52 s_significand s_sin s_tan s_tanh w_acos w_acosh w_asin \
4bbac92a 53 w_atan2 w_atanh w_cosh w_drem w_exp w_exp2 w_exp10 w_fmod \
e852e889 54 w_tgamma w_hypot w_j0 w_j1 w_jn w_lgamma w_lgamma_r \
377a515b 55 w_log w_log10 w_pow w_remainder w_scalb w_sinh w_sqrt \
76da7265 56 w_ilogb \
502328b2 57 s_fpclassify s_fmax s_fmin s_fdim s_nan s_trunc \
601d2942 58 s_remquo e_log2 e_exp2 s_round s_nearbyint s_sincos \
63551311
UD
59 conj cimag creal cabs carg s_cexp s_csinh s_ccosh s_clog \
60 s_catan s_casin s_ccos s_csin s_ctan s_ctanh s_cacos \
dfd2257a 61 s_casinh s_cacosh s_catanh s_csqrt s_cpow s_cproj s_clog10 \
76f2646f 62 s_fma s_lrint s_llrint s_lround s_llround e_exp10 w_log2 \
d8cd06db
JM
63 s_isinf_ns s_issignaling $(calls:s_%=m_%) x2y2m1 k_casinh \
64 gamma_product
dddf0ed0 65
e4d82761
UD
66dbl-only-routines := branred doasin dosincos halfulp mpa mpatan2 \
67 mpatan mpexp mplog mpsqrt mptan sincos32 slowexp \
af968f62 68 slowpow sincostab
9d1efe33
UD
69libm-routines = $(strip $(libm-support) $(libm-calls) \
70 $(patsubst %_rf,%f_r,$(libm-calls:=f)) \
e4d82761
UD
71 $(long-m-$(long-double-fcts))) \
72 $(dbl-only-routines)
cccda09f 73long-m-routines = $(patsubst %_rl,%l_r,$(libm-calls:=l))
3fe4dc41
UD
74long-m-support = t_sincosl k_sincosl
75long-m-yes = $(long-m-routines) $(long-m-support)
58e07151 76
f7eac6eb
RM
77# These functions are in libc instead of libm because __printf_fp
78# calls them, so any program using printf will need them linked in,
79# and we don't want to have to link every program with -lm.
92712dee
RM
80# In libm-calls (above), list m_foo in place of s_foo for any
81# routine that should be compiled separately for its libc and libm versions.
1f205a47
UD
82calls = s_isinf s_isnan s_finite s_copysign s_modf s_scalbn s_frexp s_ldexp \
83 s_signbit
dddf0ed0 84generated += $(foreach s,.c .S l.c l.S f.c f.S,$(calls:s_%=m_%$s))
e6c9a67a 85routines = $(calls) $(calls:=f) $(long-c-$(long-double-fcts))
58e07151 86long-c-yes = $(calls:=l)
8847214f 87
c57abfa7 88# Rules for the test suite.
9861985f 89tests = test-matherr test-fenv atest-exp atest-sincos atest-exp2 basic-test \
95e7cf29
MR
90 test-misc test-fpucw test-fpucw-ieee tst-definitions test-tgmath \
91 test-tgmath-ret bug-nextafter bug-nexttoward bug-tgmath1 \
92 test-tgmath-int test-tgmath2 test-powl tst-CMPLX tst-CMPLX2 test-snan \
73c1ce4f 93 test-fenv-tls $(tests-static)
95e7cf29 94tests-static = test-fpucw-static test-fpucw-ieee-static
c57abfa7 95# We do the `long double' tests only if this data type is available and
af6f3906 96# distinct from `double'.
40a55d20 97test-longdouble-yes = test-ldouble test-ildoubl
c57abfa7 98
8847214f
UD
99ifneq (no,$(PERL))
100libm-tests = test-float test-double $(test-longdouble-$(long-double-fcts)) \
101 test-ifloat test-idouble
102libm-tests.o = $(addsuffix .o,$(libm-tests))
103
104tests += $(libm-tests)
882ed1be
UD
105libm-tests-generated = libm-test-ulps.h libm-test.c
106generated += $(libm-tests-generated) libm-test.stmp
8847214f 107
882ed1be
UD
108# This is needed for dependencies
109before-compile += $(objpfx)libm-test.c
8847214f 110
e0a3ed4f 111ulps-file = $(firstword $(wildcard $(sysdirs:%=%/libm-test-ulps)))
882ed1be
UD
112
113$(addprefix $(objpfx), $(libm-tests-generated)): $(objpfx)libm-test.stmp
8847214f 114
ffb536d0
JM
115$(objpfx)libm-test.stmp: $(ulps-file) libm-test.inc gen-libm-test.pl \
116 auto-libm-test-out
882ed1be
UD
117 $(make-target-directory)
118 $(PERL) gen-libm-test.pl -u $< -o "$(objpfx)"
8847214f
UD
119 @echo > $@
120
121$(objpfx)test-float.o: $(objpfx)libm-test.stmp
122$(objpfx)test-ifloat.o: $(objpfx)libm-test.stmp
123$(objpfx)test-double.o: $(objpfx)libm-test.stmp
124$(objpfx)test-idouble.o: $(objpfx)libm-test.stmp
125$(objpfx)test-ldouble.o: $(objpfx)libm-test.stmp
126$(objpfx)test-ildoubl.o: $(objpfx)libm-test.stmp
127endif
128
0be196ad
AJ
129CFLAGS-test-float.c = -fno-inline -ffloat-store -fno-builtin -frounding-math
130CFLAGS-test-double.c = -fno-inline -ffloat-store -fno-builtin -frounding-math
131CFLAGS-test-ldouble.c = -fno-inline -ffloat-store -fno-builtin -frounding-math
4f2689f4 132CFLAGS-test-tgmath.c = -fno-builtin
d077f65f
MT
133# The following testcase uses very long lines (>3 million), so it may take a
134# while to compile it. See: http://llvm.org/bugs/show_bug.cgi?id=14106 and
135# http://gcc.gnu.org/bugzilla/show_bug.cgi?id=54402
8790af5f 136CFLAGS-test-tgmath2.c = -fno-builtin
301a6724 137CFLAGS-test-tgmath-ret.c = -fno-builtin
8db73634 138CFLAGS-test-powl.c = -fno-builtin
0be196ad
AJ
139CFLAGS-test-test-fenv.c = -frounding-math
140CFLAGS-test-misc.c = -frounding-math
d747a0a5 141CPPFLAGS-test-ifloat.c = -U__LIBC_INTERNAL_MATH_INLINES -D__FAST_MATH__ \
0be196ad 142 -DTEST_FAST_MATH -fno-builtin -frounding-math
d747a0a5 143CPPFLAGS-test-idouble.c = -U__LIBC_INTERNAL_MATH_INLINES -D__FAST_MATH__ \
0be196ad 144 -DTEST_FAST_MATH -fno-builtin -frounding-math
d747a0a5 145CPPFLAGS-test-ildoubl.c = -U__LIBC_INTERNAL_MATH_INLINES -D__FAST_MATH__ \
0be196ad 146 -DTEST_FAST_MATH -fno-builtin -frounding-math
c57abfa7 147
28f540f4 148
26da047f
RM
149# The -lieee module sets the _LIB_VERSION_ switch to IEEE mode
150# for error handling in the -lm functions.
151install-lib += libieee.a
152non-lib.a += libieee.a
153extra-objs += libieee.a ieee-math.o
154
28f540f4
RM
155include ../Rules
156
26510bdd
CD
157ifneq (no,$(PERL))
158# Run the math programs to automatically generate ULPs files.
159.PHONY: regen-ulps
160
161run-regen-ulps = $(test-wrapper-env) \
162 GCONV_PATH=$(common-objpfx)iconvdata LC_ALL=C \
01dc6df9 163 $($*-ENV) $(rtld-prefix) $${run}
26510bdd
CD
164
165regen-ulps: $(addprefix $(objpfx),$(libm-tests))
166 rm -f $(objpfx)ULPs; rm -f $(objpfx)NewUlps; \
167 cp $(ulps-file) $(objpfx)libm-test-ulps; \
168 for run in $^; do \
169 echo "Regenerating ULPs for $${run}"; \
170 $(run-regen-ulps) -u -o $(objpfx); \
171 cat $(objpfx)ULPs >> $(objpfx)libm-test-ulps; \
172 rm $(objpfx)ULPs; \
173 done; \
174 $(PERL) gen-libm-test.pl -o $(objpfx) -n -u $(objpfx)libm-test-ulps; \
175 echo "Automatic regeneration of ULPs complete."; \
176 echo "Difference between the current baseline and the new baseline is:";\
177 diff -urN $(ulps-file) $(objpfx)NewUlps; \
178 echo "Copy $(objpfx)NewUlps to $(ulps-file) (relative to source)."
179else
180regen-ulps:
181 @echo "Automatic regeneration of ULPs requires perl."; \
182 exit 1;
183endif
f7eac6eb 184
2f663a98
RM
185# The generated sysd-rules file defines rules like this for sources
186# coming from sysdeps/ directories. These rules find the generic sources.
187define o-iterator-doit
188$(objpfx)m_%$o: s_%.c $(before-compile); $$(compile-command.c)
189endef
190object-suffixes-left := $(all-object-suffixes)
191include $(o-iterator)
192
193
f7eac6eb
RM
194# This file defines the default _LIB_VERSION variable that controls
195# the error return conventions for the math functions.
196CPPFLAGS-s_lib_version.c := -D_POSIX_MODE
197
a641835a
RM
198# We don't want the fdlibm code to use the inline math functions,
199# only the fdlibm code.
4b9afc43 200math-CPPFLAGS += -D__NO_MATH_INLINES -D__LIBC_INTERNAL_MATH_INLINES
a641835a 201
58e07151
RM
202ifneq ($(long-double-fcts),yes)
203# The `double' and `long double' types are the same on this machine.
204# We won't compile the `long double' code at all. Tell the `double' code
f5cb4a5c
RM
205# to define aliases for the `FUNCl' names. To avoid type conflicts in
206# defining those aliases, tell <math.h> to declare the `FUNCl' names with
207# `double' instead of `long double'.
4b9afc43 208math-CPPFLAGS += -DNO_LONG_DOUBLE -D_Mlong_double_=double
58e07151
RM
209endif
210
f7eac6eb 211# The fdlibm code generates a lot of these warnings but is otherwise clean.
0ed99ce4 212override CFLAGS += -Wno-uninitialized
26da047f
RM
213
214# The -lieee library is actually an object file.
215# The module just defines the _LIB_VERSION_ variable.
216# It's not a library to make sure it is linked in instead of s_lib_version.o.
217$(objpfx)libieee.a: $(objpfx)ieee-math.o
218 rm -f $@
e7c5513d
UD
219 $(patsubst %/,cd % &&,$(objpfx)) \
220 $(LN_S) $(<F) $(@F)
3e5f5557
UD
221
222ifeq ($(build-shared),yes)
95e7cf29
MR
223$(addprefix $(objpfx),$(filter-out $(tests-static),$(tests))): $(objpfx)libm.so$(libm.so-version)
224$(addprefix $(objpfx),$(tests-static)): $(objpfx)libm.a
3e5f5557
UD
225else
226$(addprefix $(objpfx),$(tests)): $(objpfx)libm.a
227endif
9498096c 228
2119dcfa 229gmp-objs = $(patsubst %,$(common-objpfx)stdlib/%.o,\
6075607b 230 add_n sub_n cmp addmul_1 mul_1 mul_n divmod_1 \
32fcb36d
DM
231 lshift rshift mp_clz_tab udiv_qrnnd inlines \
232 $(gmp-sysdep_routines))
6075607b
UD
233$(objpfx)atest-exp: $(gmp-objs)
234$(objpfx)atest-sincos: $(gmp-objs)
235$(objpfx)atest-exp2: $(gmp-objs)
73c1ce4f 236$(objpfx)test-fenv-tls: $(common-objpfx)nptl/libpthread.so