Thu, 23 May 2024 19:29:14 +0200
simplify iterator structures
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.
24 include ../config.mk
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 mempool.c printf.c string.c tree.c \
28 utils.c
30 OBJ_EXT=.o
31 OBJ=$(SRC:%.c=$(build_dir)/%$(OBJ_EXT))
32 GCOV=$(SRC:%.c=%.c.gcov)
34 static: $(build_dir)/libucx_static$(STLIB_EXT)
36 shared: $(build_dir)/libucx$(SHLIB_EXT)
38 check-coverage: $(GCOV)
39 mv *.gcov "$(build_dir)"
41 %.c.gcov: %.c $(build_dir)/%.gcno
42 @printf '%16s - %s\n' "$<" "`gcov -Ho "$(build_dir)" $< | grep --max-count=1 -i 'lines executed'`"
44 $(build_dir)/%.gcno:
45 test -f "$@"
47 $(build_dir)/libucx_static$(STLIB_EXT): $(OBJ)
48 $(AR) $(ARFLAGS) $@ $^
50 $(build_dir)/libucx$(SHLIB_EXT): $(OBJ)
51 $(CC) $(LDFLAGS) -o $@ $^
53 install: $(build_dir)/libucx_static$(STLIB_EXT) $(build_dir)/libucx$(SHLIB_EXT)
54 $(MKDIR) $(libdir) $(includedir)/cx
55 $(RMFILE) $(libdir)/libucx$(SHLIB_EXT).$(LIBVERSION_MAJOR)
56 $(RMFILE) $(libdir)/libucx$(SHLIB_EXT)
57 $(COPYFILE) $(build_dir)/libucx_static$(STLIB_EXT) $(libdir)/libucx_static$(STLIB_EXT)
58 $(COPYFILE) $(build_dir)/libucx$(SHLIB_EXT) $(libdir)/libucx$(SHLIB_EXT).$(LIBVERSION)
59 $(COPYALL) $(src_dir)/src/cx $(includedir)
60 $(SYMLINK) $(libdir)/libucx$(SHLIB_EXT).$(LIBVERSION) $(libdir)/libucx$(SHLIB_EXT).$(LIBVERSION_MAJOR)
61 $(SYMLINK) $(libdir)/libucx$(SHLIB_EXT).$(LIBVERSION_MAJOR) $(libdir)/libucx$(SHLIB_EXT)
63 FORCE:
65 $(build_dir)/allocator$(OBJ_EXT): allocator.c cx/allocator.h cx/common.h
66 @echo "Compiling $<"
67 $(CC) -o $@ $(CFLAGS) -c $<
69 $(build_dir)/array_list$(OBJ_EXT): array_list.c cx/array_list.h cx/list.h \
70 cx/common.h cx/collection.h cx/allocator.h cx/iterator.h cx/compare.h
71 @echo "Compiling $<"
72 $(CC) -o $@ $(CFLAGS) -c $<
74 $(build_dir)/buffer$(OBJ_EXT): buffer.c cx/buffer.h cx/common.h \
75 cx/allocator.h cx/utils.h
76 @echo "Compiling $<"
77 $(CC) -o $@ $(CFLAGS) -c $<
79 $(build_dir)/compare$(OBJ_EXT): compare.c cx/compare.h cx/common.h
80 @echo "Compiling $<"
81 $(CC) -o $@ $(CFLAGS) -c $<
83 $(build_dir)/hash_key$(OBJ_EXT): hash_key.c cx/hash_key.h cx/common.h
84 @echo "Compiling $<"
85 $(CC) -o $@ $(CFLAGS) -c $<
87 $(build_dir)/hash_map$(OBJ_EXT): hash_map.c cx/hash_map.h cx/map.h \
88 cx/common.h cx/collection.h cx/allocator.h cx/iterator.h cx/string.h \
89 cx/hash_key.h cx/utils.h
90 @echo "Compiling $<"
91 $(CC) -o $@ $(CFLAGS) -c $<
93 $(build_dir)/iterator$(OBJ_EXT): iterator.c cx/iterator.h cx/common.h
94 @echo "Compiling $<"
95 $(CC) -o $@ $(CFLAGS) -c $<
97 $(build_dir)/linked_list$(OBJ_EXT): linked_list.c cx/linked_list.h \
98 cx/common.h cx/list.h cx/collection.h cx/allocator.h cx/iterator.h \
99 cx/utils.h cx/compare.h
100 @echo "Compiling $<"
101 $(CC) -o $@ $(CFLAGS) -c $<
103 $(build_dir)/list$(OBJ_EXT): list.c cx/list.h cx/common.h cx/collection.h \
104 cx/allocator.h cx/iterator.h
105 @echo "Compiling $<"
106 $(CC) -o $@ $(CFLAGS) -c $<
108 $(build_dir)/map$(OBJ_EXT): map.c cx/map.h cx/common.h cx/collection.h \
109 cx/allocator.h cx/iterator.h cx/string.h cx/hash_key.h
110 @echo "Compiling $<"
111 $(CC) -o $@ $(CFLAGS) -c $<
113 $(build_dir)/mempool$(OBJ_EXT): mempool.c cx/mempool.h cx/common.h \
114 cx/allocator.h cx/utils.h
115 @echo "Compiling $<"
116 $(CC) -o $@ $(CFLAGS) -c $<
118 $(build_dir)/printf$(OBJ_EXT): printf.c cx/printf.h cx/common.h \
119 cx/string.h cx/allocator.h
120 @echo "Compiling $<"
121 $(CC) -o $@ $(CFLAGS) -c $<
123 $(build_dir)/string$(OBJ_EXT): string.c cx/string.h cx/common.h \
124 cx/allocator.h cx/utils.h
125 @echo "Compiling $<"
126 $(CC) -o $@ $(CFLAGS) -c $<
128 $(build_dir)/szmul$(OBJ_EXT): szmul.c
129 @echo "Compiling $<"
130 $(CC) -o $@ $(CFLAGS) -c $<
132 $(build_dir)/tree$(OBJ_EXT): tree.c cx/tree.h cx/common.h cx/iterator.h \
133 cx/array_list.h cx/list.h cx/collection.h cx/allocator.h
134 @echo "Compiling $<"
135 $(CC) -o $@ $(CFLAGS) -c $<
137 $(build_dir)/utils$(OBJ_EXT): utils.c cx/utils.h cx/common.h
138 @echo "Compiling $<"
139 $(CC) -o $@ $(CFLAGS) -c $<