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
11 all-string check-string install-string clean-string
:
12 @echo
"*** Please set ARCH in config.mk. ***"
16 string-lib-srcs
:= $(wildcard $(S
)/$(ARCH
)/*.
[cS
])
17 string-test-srcs
:= $(wildcard $(S
)/test/*.c
)
19 string-includes
:= $(patsubst $(S
)/%,build
/%,$(wildcard $(S
)/include/*.h
))
22 build
/lib
/libstringlib.so \
23 build
/lib
/libstringlib.a \
26 build
/bin
/test/memcpy \
27 build
/bin
/test/memmove \
28 build
/bin
/test/memset \
29 build
/bin
/test/memchr \
30 build
/bin
/test/memcmp \
31 build
/bin
/test/strcpy \
32 build
/bin
/test/stpcpy \
33 build
/bin
/test/strcmp \
34 build
/bin
/test/strchr \
35 build
/bin
/test/strrchr \
36 build
/bin
/test/strchrnul \
37 build
/bin
/test/strlen \
38 build
/bin
/test/strnlen \
39 build
/bin
/test/strncmp
41 string-lib-objs
:= $(patsubst $(S
)/%,$(B
)/%.o
,$(basename $(string-lib-srcs
)))
42 string-test-objs
:= $(patsubst $(S
)/%,$(B
)/%.o
,$(basename $(string-test-srcs
)))
46 $(string-lib-objs
:%.o
=%.os
) \
55 all-string
: $(string-libs
) $(string-tools
) $(string-includes
)
57 $(string-objs
): $(string-includes
)
58 $(string-objs
): CFLAGS_ALL
+= $(string-cflags
)
60 build
/lib
/libstringlib.so
: $(string-lib-objs
:%.o
=%.os
)
61 $(CC
) $(CFLAGS_ALL
) $(LDFLAGS
) -shared
-o
$@
$^
63 build
/lib
/libstringlib.a
: $(string-lib-objs
)
68 build
/bin
/test/%: $(B
)/test/%.o build
/lib
/libstringlib.a
69 $(CC
) $(CFLAGS_ALL
) $(LDFLAGS
) -static
-o
$@
$^
$(LDLIBS
)
71 build
/include/%.h
: $(S
)/include/%.h
74 build
/bin
/%.sh
: $(S
)/test/%.sh
77 check-string
: $(string-tools
)
78 $(EMULATOR
) build
/bin
/test/memcpy
79 $(EMULATOR
) build
/bin
/test/memmove
80 $(EMULATOR
) build
/bin
/test/memset
81 $(EMULATOR
) build
/bin
/test/memchr
82 $(EMULATOR
) build
/bin
/test/memcmp
83 $(EMULATOR
) build
/bin
/test/strcpy
84 $(EMULATOR
) build
/bin
/test/stpcpy
85 $(EMULATOR
) build
/bin
/test/strcmp
86 $(EMULATOR
) build
/bin
/test/strchr
87 $(EMULATOR
) build
/bin
/test/strrchr
88 $(EMULATOR
) build
/bin
/test/strchrnul
89 $(EMULATOR
) build
/bin
/test/strlen
90 $(EMULATOR
) build
/bin
/test/strnlen
91 $(EMULATOR
) build
/bin
/test/strncmp
94 $(string-libs
:build
/lib
/%=$(DESTDIR
)$(libdir)/%) \
95 $(string-includes
:build
/include/%=$(DESTDIR
)$(includedir)/%)
101 .PHONY
: all-string check-string install-string clean-string