1 # Copyright 2023 Mike Becker. All rights reserved.
2 #
3 # Redistribution and use in source and binary forms, with or without
4 # modification, are permitted provided that the following conditions are met:
5 #
6 # 1. Redistributions of source code must retain the above copyright
7 # notice, this list of conditions and the following disclaimer.
8 #
9 # 2. Redistributions in binary form must reproduce the above copyright
10 # notice, this list of conditions and the following disclaimer in the
11 # documentation and/or other materials provided with the distribution.
12 #
13 # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
14 # AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
15 # IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
16 # DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
17 # FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
18 # DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
19 # SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
20 # CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
21 # OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
22 # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
23
24 include ../config.mk
25
26 SRC = allocator.c array_list.c buffer.c compare.c hash_key.c hash_map.c \
27 iterator.c linked_list.c list.c map.c kv_list.c tree.c \
28 mempool.c printf.c string.c streams.c szmul.c properties.c json.c
29
30 OBJ_EXT=.o
31 OBJ=$(SRC:%.c=$(build_dir)/%$(OBJ_EXT))
32
33 static: $(build_dir)/libucx_static$(STLIB_EXT)
34
35 shared: $(build_dir)/libucx$(SHLIB_EXT)
36
37 check-coverage: $(SRC:%.c=$(build_dir)/%.gcda) $(build_dir)/coverage
38 gcovr --html-details $(build_dir)/coverage/ucx.html \
39 --object-directory $(build_dir) \
40 --root $(root_dir)/src \
41 --exclude-directories $(build_dir)/tests \
42 $(build_dir)
43
44 $(build_dir)/coverage:
45 $(MKDIR) $@/
46
47 $(build_dir)/%.gcda:
48 test -f "$@"
49
50 $(build_dir)/libucx_static$(STLIB_EXT): $(OBJ)
51 $(AR) $(ARFLAGS) $@ $^
52
53 $(build_dir)/libucx$(SHLIB_EXT): $(OBJ)
54 $(CC) $(LDFLAGS) -o $@ $^
55
56 rebuild_if_missing:
57 if test -f $(build_dir)/libucx_static$(STLIB_EXT) && test -f $(build_dir)/libucx$(SHLIB_EXT); \
58 then : ; else cd $(root_dir); $(MAKE) compile; fi
59
60 install: rebuild_if_missing
61 $(MKDIR) $(DESTDIR)$(libdir)/ $(DESTDIR)$(includedir)/cx/ $(DESTDIR)$(pkgconfigdir)/
62 $(RMFILE) $(DESTDIR)$(libdir)/libucx$(SHLIB_EXT).$(LIBVERSION_MAJOR)
63 $(RMFILE) $(DESTDIR)$(libdir)/libucx$(SHLIB_EXT)
64 $(COPYFILE) $(build_dir)/libucx_static$(STLIB_EXT) $(DESTDIR)$(libdir)/libucx_static$(STLIB_EXT)
65 $(SHELL) "$(INSTALL_LIB)" "$(build_dir)/libucx$(SHLIB_EXT)" "$(libdir)" $(LIBVERSION) $(LIBVERSION_MAJOR) "$(DESTDIR)"
66 $(COPYALL) $(root_dir)/src/cx $(DESTDIR)$(includedir)
67 $(SHELL) "$(root_dir)/make/install-pc-file.sh" "$(pkgconfigdir)" "$(VERSION)" "$(libdir)" "$(includedir)" "$(DESTDIR)"
68
69 FORCE:
70
71 $(build_dir)/allocator$(OBJ_EXT): allocator.c cx/allocator.h cx/common.h
72 @echo "Compiling $<"
73 $(CC) -o $@ $(CFLAGS) -c $<
74
75 $(build_dir)/array_list$(OBJ_EXT): array_list.c cx/array_list.h cx/list.h \
76 cx/common.h cx/collection.h cx/allocator.h cx/iterator.h cx/compare.h \
77 cx/compare.h
78 @echo "Compiling $<"
79 $(CC) -o $@ $(CFLAGS) -c $<
80
81 $(build_dir)/buffer$(OBJ_EXT): buffer.c cx/buffer.h cx/common.h \
82 cx/allocator.h
83 @echo "Compiling $<"
84 $(CC) -o $@ $(CFLAGS) -c $<
85
86 $(build_dir)/compare$(OBJ_EXT): compare.c cx/compare.h cx/common.h
87 @echo "Compiling $<"
88 $(CC) -o $@ $(CFLAGS) -c $<
89
90 $(build_dir)/hash_key$(OBJ_EXT): hash_key.c cx/hash_key.h cx/common.h \
91 cx/string.h cx/allocator.h cx/compare.h
92 @echo "Compiling $<"
93 $(CC) -o $@ $(CFLAGS) -c $<
94
95 $(build_dir)/hash_map$(OBJ_EXT): hash_map.c cx/hash_map.h cx/map.h \
96 cx/common.h cx/collection.h cx/allocator.h cx/iterator.h cx/compare.h \
97 cx/string.h cx/hash_key.h
98 @echo "Compiling $<"
99 $(CC) -o $@ $(CFLAGS) -c $<
100
101 $(build_dir)/iterator$(OBJ_EXT): iterator.c cx/iterator.h cx/common.h
102 @echo "Compiling $<"
103 $(CC) -o $@ $(CFLAGS) -c $<
104
105 $(build_dir)/json$(OBJ_EXT): json.c cx/json.h cx/common.h cx/allocator.h \
106 cx/string.h cx/buffer.h cx/array_list.h cx/list.h cx/collection.h \
107 cx/iterator.h cx/compare.h cx/map.h cx/hash_key.h cx/kv_list.h
108 @echo "Compiling $<"
109 $(CC) -o $@ $(CFLAGS) -c $<
110
111 $(build_dir)/kv_list$(OBJ_EXT): kv_list.c cx/kv_list.h cx/common.h \
112 cx/list.h cx/collection.h cx/allocator.h cx/iterator.h cx/compare.h \
113 cx/map.h cx/string.h cx/hash_key.h cx/hash_map.h cx/linked_list.h
114 @echo "Compiling $<"
115 $(CC) -o $@ $(CFLAGS) -c $<
116
117 $(build_dir)/linked_list$(OBJ_EXT): linked_list.c cx/linked_list.h \
118 cx/common.h cx/list.h cx/collection.h cx/allocator.h cx/iterator.h \
119 cx/compare.h cx/compare.h
120 @echo "Compiling $<"
121 $(CC) -o $@ $(CFLAGS) -c $<
122
123 $(build_dir)/list$(OBJ_EXT): list.c cx/list.h cx/common.h cx/collection.h \
124 cx/allocator.h cx/iterator.h cx/compare.h
125 @echo "Compiling $<"
126 $(CC) -o $@ $(CFLAGS) -c $<
127
128 $(build_dir)/map$(OBJ_EXT): map.c cx/map.h cx/common.h cx/collection.h \
129 cx/allocator.h cx/iterator.h cx/compare.h cx/string.h cx/hash_key.h \
130 cx/list.h
131 @echo "Compiling $<"
132 $(CC) -o $@ $(CFLAGS) -c $<
133
134 $(build_dir)/mempool$(OBJ_EXT): mempool.c cx/mempool.h cx/common.h \
135 cx/allocator.h
136 @echo "Compiling $<"
137 $(CC) -o $@ $(CFLAGS) -c $<
138
139 $(build_dir)/printf$(OBJ_EXT): printf.c cx/printf.h cx/common.h \
140 cx/string.h cx/allocator.h
141 @echo "Compiling $<"
142 $(CC) -o $@ $(CFLAGS) -c $<
143
144 $(build_dir)/properties$(OBJ_EXT): properties.c cx/properties.h \
145 cx/common.h cx/string.h cx/allocator.h cx/map.h cx/collection.h \
146 cx/iterator.h cx/compare.h cx/hash_key.h cx/buffer.h
147 @echo "Compiling $<"
148 $(CC) -o $@ $(CFLAGS) -c $<
149
150 $(build_dir)/streams$(OBJ_EXT): streams.c cx/streams.h cx/common.h \
151 cx/allocator.h
152 @echo "Compiling $<"
153 $(CC) -o $@ $(CFLAGS) -c $<
154
155 $(build_dir)/string$(OBJ_EXT): string.c cx/string.h cx/common.h \
156 cx/allocator.h
157 @echo "Compiling $<"
158 $(CC) -o $@ $(CFLAGS) -c $<
159
160 $(build_dir)/szmul$(OBJ_EXT): szmul.c cx/common.h
161 @echo "Compiling $<"
162 $(CC) -o $@ $(CFLAGS) -c $<
163
164 $(build_dir)/tree$(OBJ_EXT): tree.c cx/tree.h cx/common.h cx/collection.h \
165 cx/allocator.h cx/iterator.h cx/compare.h cx/array_list.h cx/list.h
166 @echo "Compiling $<"
167 $(CC) -o $@ $(CFLAGS) -c $<
168
169