Dir.mk
2.63 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
# Makefile fragment - requires GNU make
#
# Part of the LLVM Project, under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception
S := $(srcdir)/string
B := build/string
ifeq ($(ARCH),)
all-string check-string install-string clean-string:
@echo "*** Please set ARCH in config.mk. ***"
@exit 1
else
string-lib-srcs := $(wildcard $(S)/$(ARCH)/*.[cS])
string-test-srcs := $(wildcard $(S)/test/*.c)
string-includes := $(patsubst $(S)/%,build/%,$(wildcard $(S)/include/*.h))
string-libs := \
build/lib/libstringlib.so \
build/lib/libstringlib.a \
string-tools := \
build/bin/test/memcpy \
build/bin/test/memmove \
build/bin/test/memset \
build/bin/test/memchr \
build/bin/test/memcmp \
build/bin/test/strcpy \
build/bin/test/stpcpy \
build/bin/test/strcmp \
build/bin/test/strchr \
build/bin/test/strrchr \
build/bin/test/strchrnul \
build/bin/test/strlen \
build/bin/test/strnlen \
build/bin/test/strncmp
string-lib-objs := $(patsubst $(S)/%,$(B)/%.o,$(basename $(string-lib-srcs)))
string-test-objs := $(patsubst $(S)/%,$(B)/%.o,$(basename $(string-test-srcs)))
string-objs := \
$(string-lib-objs) \
$(string-lib-objs:%.o=%.os) \
$(string-test-objs) \
string-files := \
$(string-objs) \
$(string-libs) \
$(string-tools) \
$(string-includes) \
all-string: $(string-libs) $(string-tools) $(string-includes)
$(string-objs): $(string-includes)
$(string-objs): CFLAGS_ALL += $(string-cflags)
build/lib/libstringlib.so: $(string-lib-objs:%.o=%.os)
$(CC) $(CFLAGS_ALL) $(LDFLAGS) -shared -o $@ $^
build/lib/libstringlib.a: $(string-lib-objs)
rm -f $@
$(AR) rc $@ $^
$(RANLIB) $@
build/bin/test/%: $(B)/test/%.o build/lib/libstringlib.a
$(CC) $(CFLAGS_ALL) $(LDFLAGS) -static -o $@ $^ $(LDLIBS)
build/include/%.h: $(S)/include/%.h
cp $< $@
build/bin/%.sh: $(S)/test/%.sh
cp $< $@
check-string: $(string-tools)
$(EMULATOR) build/bin/test/memcpy
$(EMULATOR) build/bin/test/memmove
$(EMULATOR) build/bin/test/memset
$(EMULATOR) build/bin/test/memchr
$(EMULATOR) build/bin/test/memcmp
$(EMULATOR) build/bin/test/strcpy
$(EMULATOR) build/bin/test/stpcpy
$(EMULATOR) build/bin/test/strcmp
$(EMULATOR) build/bin/test/strchr
$(EMULATOR) build/bin/test/strrchr
$(EMULATOR) build/bin/test/strchrnul
$(EMULATOR) build/bin/test/strlen
$(EMULATOR) build/bin/test/strnlen
$(EMULATOR) build/bin/test/strncmp
install-string: \
$(string-libs:build/lib/%=$(DESTDIR)$(libdir)/%) \
$(string-includes:build/include/%=$(DESTDIR)$(includedir)/%)
clean-string:
rm -f $(string-files)
endif
.PHONY: all-string check-string install-string clean-string