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
10 math-lib-srcs
:= $(wildcard $(S
)/*.
[cS
])
12 $(S
)/test/mathtest.c \
13 $(S
)/test/mathbench.c \
16 math-test-host-srcs
:= $(wildcard $(S
)/test/rtest
/*.
[cS
])
18 math-includes
:= $(patsubst $(S
)/%,build
/%,$(wildcard $(S
)/include/*.h
))
21 build
/lib
/libmathlib.so \
22 build
/lib
/libmathlib.a \
27 build
/bin
/mathbench_libc \
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
)
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
)
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
87 build
/bin
/%.sh
: $(S
)/test/%.sh
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
105 $(math-libs
:build
/lib
/%=$(DESTDIR
)$(libdir)/%) \
106 $(math-includes
:build
/include/%=$(DESTDIR
)$(includedir)/%)
111 .PHONY
: all-math check-math-test check-math-rtest check-math-ulp check-math install-math clean-math