]> CyberLeo.Net >> Repos - FreeBSD/FreeBSD.git/blob - contrib/arm-optimized-routines/math/Dir.mk
Merge llvm-project release/15.x llvmorg-15.0.0-rc2-40-gfbd2950d8d0d
[FreeBSD/FreeBSD.git] / contrib / arm-optimized-routines / math / Dir.mk
1 # Makefile fragment - requires GNU make
2 #
3 # Copyright (c) 2019, Arm Limited.
4 # SPDX-License-Identifier: MIT
5
6 S := $(srcdir)/math
7 B := build/math
8
9 math-lib-srcs := $(wildcard $(S)/*.[cS])
10 math-test-srcs := \
11         $(S)/test/mathtest.c \
12         $(S)/test/mathbench.c \
13         $(S)/test/ulp.c \
14
15 math-test-host-srcs := $(wildcard $(S)/test/rtest/*.[cS])
16
17 math-includes := $(patsubst $(S)/%,build/%,$(wildcard $(S)/include/*.h))
18
19 math-libs := \
20         build/lib/libmathlib.so \
21         build/lib/libmathlib.a \
22
23 math-tools := \
24         build/bin/mathtest \
25         build/bin/mathbench \
26         build/bin/mathbench_libc \
27         build/bin/runulp.sh \
28         build/bin/ulp \
29
30 math-host-tools := \
31         build/bin/rtest \
32
33 math-lib-objs := $(patsubst $(S)/%,$(B)/%.o,$(basename $(math-lib-srcs)))
34 math-test-objs := $(patsubst $(S)/%,$(B)/%.o,$(basename $(math-test-srcs)))
35 math-host-objs := $(patsubst $(S)/%,$(B)/%.o,$(basename $(math-test-host-srcs)))
36 math-target-objs := $(math-lib-objs) $(math-test-objs)
37 math-objs := $(math-target-objs) $(math-target-objs:%.o=%.os) $(math-host-objs)
38
39 math-files := \
40         $(math-objs) \
41         $(math-libs) \
42         $(math-tools) \
43         $(math-host-tools) \
44         $(math-includes) \
45
46 all-math: $(math-libs) $(math-tools) $(math-includes)
47
48 $(math-objs): $(math-includes)
49 $(math-objs): CFLAGS_ALL += $(math-cflags)
50 $(B)/test/mathtest.o: CFLAGS_ALL += -fmath-errno
51 $(math-host-objs): CC = $(HOST_CC)
52 $(math-host-objs): CFLAGS_ALL = $(HOST_CFLAGS)
53
54 $(B)/test/ulp.o: $(S)/test/ulp.h
55
56 build/lib/libmathlib.so: $(math-lib-objs:%.o=%.os)
57         $(CC) $(CFLAGS_ALL) $(LDFLAGS) -shared -o $@ $^
58
59 build/lib/libmathlib.a: $(math-lib-objs)
60         rm -f $@
61         $(AR) rc $@ $^
62         $(RANLIB) $@
63
64 $(math-host-tools): HOST_LDLIBS += -lm -lmpfr -lmpc
65 $(math-tools): LDLIBS += $(math-ldlibs) -lm
66
67 build/bin/rtest: $(math-host-objs)
68         $(HOST_CC) $(HOST_CFLAGS) $(HOST_LDFLAGS) -o $@ $^ $(HOST_LDLIBS)
69
70 build/bin/mathtest: $(B)/test/mathtest.o build/lib/libmathlib.a
71         $(CC) $(CFLAGS_ALL) $(LDFLAGS) -static -o $@ $^ $(LDLIBS)
72
73 build/bin/mathbench: $(B)/test/mathbench.o build/lib/libmathlib.a
74         $(CC) $(CFLAGS_ALL) $(LDFLAGS) -static -o $@ $^ $(LDLIBS)
75
76 # This is not ideal, but allows custom symbols in mathbench to get resolved.
77 build/bin/mathbench_libc: $(B)/test/mathbench.o build/lib/libmathlib.a
78         $(CC) $(CFLAGS_ALL) $(LDFLAGS) -static -o $@ $< $(LDLIBS) -lc build/lib/libmathlib.a -lm
79
80 build/bin/ulp: $(B)/test/ulp.o build/lib/libmathlib.a
81         $(CC) $(CFLAGS_ALL) $(LDFLAGS) -static -o $@ $^ $(LDLIBS)
82
83 build/include/%.h: $(S)/include/%.h
84         cp $< $@
85
86 build/bin/%.sh: $(S)/test/%.sh
87         cp $< $@
88
89 math-tests := $(wildcard $(S)/test/testcases/directed/*.tst)
90 math-rtests := $(wildcard $(S)/test/testcases/random/*.tst)
91
92 check-math-test: $(math-tools)
93         cat $(math-tests) | $(EMULATOR) build/bin/mathtest $(math-testflags)
94
95 check-math-rtest: $(math-host-tools) $(math-tools)
96         cat $(math-rtests) | build/bin/rtest | $(EMULATOR) build/bin/mathtest $(math-testflags)
97
98 check-math-ulp: $(math-tools)
99         ULPFLAGS="$(math-ulpflags)" build/bin/runulp.sh $(EMULATOR)
100
101 check-math: check-math-test check-math-rtest check-math-ulp
102
103 install-math: \
104  $(math-libs:build/lib/%=$(DESTDIR)$(libdir)/%) \
105  $(math-includes:build/include/%=$(DESTDIR)$(includedir)/%)
106
107 clean-math:
108         rm -f $(math-files)
109
110 .PHONY: all-math check-math-test check-math-rtest check-math-ulp check-math install-math clean-math