[clang] Avoid linking libdl unless needed
[llvm-project.git] / libc / AOR_v20.02 / math / Dir.mk
blob6be9115e86b0854e2ec91fb9846322624dfd21ba
1 # Makefile fragment - requires GNU make
3 # Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
4 # See https://llvm.org/LICENSE.txt for license information.
5 # SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
7 S := $(srcdir)/math
8 B := build/math
10 math-lib-srcs := $(wildcard $(S)/*.[cS])
11 math-test-srcs := \
12 $(S)/test/mathtest.c \
13 $(S)/test/mathbench.c \
14 $(S)/test/ulp.c \
16 math-test-host-srcs := $(wildcard $(S)/test/rtest/*.[cS])
18 math-includes := $(patsubst $(S)/%,build/%,$(wildcard $(S)/include/*.h))
20 math-libs := \
21 build/lib/libmathlib.so \
22 build/lib/libmathlib.a \
24 math-tools := \
25 build/bin/mathtest \
26 build/bin/mathbench \
27 build/bin/mathbench_libc \
28 build/bin/runulp.sh \
29 build/bin/ulp \
31 math-host-tools := \
32 build/bin/rtest \
34 math-lib-objs := $(patsubst $(S)/%,$(B)/%.o,$(basename $(math-lib-srcs)))
35 math-test-objs := $(patsubst $(S)/%,$(B)/%.o,$(basename $(math-test-srcs)))
36 math-host-objs := $(patsubst $(S)/%,$(B)/%.o,$(basename $(math-test-host-srcs)))
37 math-target-objs := $(math-lib-objs) $(math-test-objs)
38 math-objs := $(math-target-objs) $(math-target-objs:%.o=%.os) $(math-host-objs)
40 math-files := \
41 $(math-objs) \
42 $(math-libs) \
43 $(math-tools) \
44 $(math-host-tools) \
45 $(math-includes) \
47 all-math: $(math-libs) $(math-tools) $(math-includes)
49 $(math-objs): $(math-includes)
50 $(math-objs): CFLAGS_ALL += $(math-cflags)
51 $(B)/test/mathtest.o: CFLAGS_ALL += -fmath-errno
52 $(math-host-objs): CC = $(HOST_CC)
53 $(math-host-objs): CFLAGS_ALL = $(HOST_CFLAGS)
55 $(B)/test/ulp.o: $(S)/test/ulp.h
57 build/lib/libmathlib.so: $(math-lib-objs:%.o=%.os)
58 $(CC) $(CFLAGS_ALL) $(LDFLAGS) -shared -o $@ $^
60 build/lib/libmathlib.a: $(math-lib-objs)
61 rm -f $@
62 $(AR) rc $@ $^
63 $(RANLIB) $@
65 $(math-host-tools): HOST_LDLIBS += -lm -lmpfr -lmpc
66 $(math-tools): LDLIBS += $(math-ldlibs) -lm
68 build/bin/rtest: $(math-host-objs)
69 $(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ $^ $(HOST_LDLIBS)
71 build/bin/mathtest: $(B)/test/mathtest.o build/lib/libmathlib.a
72 $(CC) $(CFLAGS_ALL) $(LDFLAGS) -static -o $@ $^ $(LDLIBS)
74 build/bin/mathbench: $(B)/test/mathbench.o build/lib/libmathlib.a
75 $(CC) $(CFLAGS_ALL) $(LDFLAGS) -static -o $@ $^ $(LDLIBS)
77 # This is not ideal, but allows custom symbols in mathbench to get resolved.
78 build/bin/mathbench_libc: $(B)/test/mathbench.o build/lib/libmathlib.a
79 $(CC) $(CFLAGS_ALL) $(LDFLAGS) -static -o $@ $< $(LDLIBS) -lc build/lib/libmathlib.a -lm
81 build/bin/ulp: $(B)/test/ulp.o build/lib/libmathlib.a
82 $(CC) $(CFLAGS_ALL) $(LDFLAGS) -static -o $@ $^ $(LDLIBS)
84 build/include/%.h: $(S)/include/%.h
85 cp $< $@
87 build/bin/%.sh: $(S)/test/%.sh
88 cp $< $@
90 math-tests := $(wildcard $(S)/test/testcases/directed/*.tst)
91 math-rtests := $(wildcard $(S)/test/testcases/random/*.tst)
93 check-math-test: $(math-tools)
94 cat $(math-tests) | $(EMULATOR) build/bin/mathtest $(math-testflags)
96 check-math-rtest: $(math-host-tools) $(math-tools)
97 cat $(math-rtests) | build/bin/rtest | $(EMULATOR) build/bin/mathtest $(math-testflags)
99 check-math-ulp: $(math-tools)
100 ULPFLAGS="$(math-ulpflags)" build/bin/runulp.sh $(EMULATOR)
102 check-math: check-math-test check-math-rtest check-math-ulp
104 install-math: \
105 $(math-libs:build/lib/%=$(DESTDIR)$(libdir)/%) \
106 $(math-includes:build/include/%=$(DESTDIR)$(includedir)/%)
108 clean-math:
109 rm -f $(math-files)
111 .PHONY: all-math check-math-test check-math-rtest check-math-ulp check-math install-math clean-math