UNIXworkcode

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 TEST_DIR=$(build_dir)/tests 27 28 SRC = util_allocator.c \ 29 test_szmul.c test_allocator.c \ 30 test_compare.c \ 31 test_string.c test_buffer.c \ 32 test_hash_key.c test_hash_map.c \ 33 test_iterator.c test_list.c test_tree.c \ 34 test_kv_list.c \ 35 test_properties.c test_json.c \ 36 test_printf.c test_streams.c \ 37 test_mempool.c \ 38 ucxtest.c 39 40 OBJ_EXT=.o 41 OBJ=$(SRC:%.c=$(TEST_DIR)/%$(OBJ_EXT)) 42 43 all: $(TEST_DIR) $(TEST_DIR)/ucxtest $(TEST_DIR)/test_header_only$(OBJ_EXT) 44 45 $(TEST_DIR)/ucxtest: $(OBJ) $(build_dir)/libucx_static.a 46 $(CC) -o $@ $(LDFLAGS) $+ 47 48 # tests that the test.h can be used header-only 49 $(TEST_DIR)/test_header_only$(OBJ_EXT): ../src/cx/test.h 50 @echo "Checking if test.h is standalone" 51 $(CC) -o "$@" -c test_header_only.c 52 53 $(build_dir)/libucx_static.a: 54 test -f "$@" 55 56 $(TEST_DIR): 57 $(MKDIR) $@/ 58 59 FORCE: 60 61 $(TEST_DIR)/test_allocator$(OBJ_EXT): test_allocator.c ../src/cx/test.h \ 62 ../src/cx/allocator.h ../src/cx/common.h 63 @echo "Compiling $<" 64 $(CC) -o $@ $(CFLAGS) -I../src -c $< 65 66 $(TEST_DIR)/test_buffer$(OBJ_EXT): test_buffer.c ../src/cx/test.h \ 67 util_allocator.h ../src/cx/allocator.h ../src/cx/common.h \ 68 ../src/cx/buffer.h ../src/cx/allocator.h ../src/cx/string.h 69 @echo "Compiling $<" 70 $(CC) -o $@ $(CFLAGS) -I../src -c $< 71 72 $(TEST_DIR)/test_compare$(OBJ_EXT): test_compare.c ../src/cx/test.h \ 73 ../src/cx/compare.h ../src/cx/common.h 74 @echo "Compiling $<" 75 $(CC) -o $@ $(CFLAGS) -I../src -c $< 76 77 $(TEST_DIR)/test_hash_key$(OBJ_EXT): test_hash_key.c ../src/cx/test.h \ 78 ../src/cx/hash_key.h ../src/cx/common.h ../src/cx/string.h \ 79 ../src/cx/allocator.h ../src/cx/string.h 80 @echo "Compiling $<" 81 $(CC) -o $@ $(CFLAGS) -I../src -c $< 82 83 $(TEST_DIR)/test_hash_map$(OBJ_EXT): test_hash_map.c ../src/cx/test.h \ 84 util_allocator.h ../src/cx/allocator.h ../src/cx/common.h \ 85 ../src/cx/array_list.h ../src/cx/list.h ../src/cx/collection.h \ 86 ../src/cx/allocator.h ../src/cx/iterator.h ../src/cx/compare.h \ 87 ../src/cx/list.h ../src/cx/hash_map.h ../src/cx/map.h ../src/cx/string.h \ 88 ../src/cx/hash_key.h 89 @echo "Compiling $<" 90 $(CC) -o $@ $(CFLAGS) -I../src -c $< 91 92 $(TEST_DIR)/test_iterator$(OBJ_EXT): test_iterator.c ../src/cx/test.h \ 93 ../src/cx/iterator.h ../src/cx/common.h 94 @echo "Compiling $<" 95 $(CC) -o $@ $(CFLAGS) -I../src -c $< 96 97 $(TEST_DIR)/test_json$(OBJ_EXT): test_json.c util_allocator.h \ 98 ../src/cx/allocator.h ../src/cx/common.h ../src/cx/test.h \ 99 ../src/cx/json.h ../src/cx/allocator.h ../src/cx/string.h \ 100 ../src/cx/buffer.h ../src/cx/array_list.h ../src/cx/list.h \ 101 ../src/cx/collection.h ../src/cx/iterator.h ../src/cx/compare.h \ 102 ../src/cx/map.h ../src/cx/hash_key.h ../src/cx/compare.h 103 @echo "Compiling $<" 104 $(CC) -o $@ $(CFLAGS) -I../src -c $< 105 106 $(TEST_DIR)/test_kv_list$(OBJ_EXT): test_kv_list.c ../src/cx/test.h \ 107 util_allocator.h ../src/cx/allocator.h ../src/cx/common.h \ 108 ../src/cx/kv_list.h ../src/cx/list.h ../src/cx/collection.h \ 109 ../src/cx/allocator.h ../src/cx/iterator.h ../src/cx/compare.h \ 110 ../src/cx/map.h ../src/cx/string.h ../src/cx/hash_key.h 111 @echo "Compiling $<" 112 $(CC) -o $@ $(CFLAGS) -I../src -c $< 113 114 $(TEST_DIR)/test_list$(OBJ_EXT): test_list.c ../src/cx/test.h \ 115 util_allocator.h ../src/cx/allocator.h ../src/cx/common.h \ 116 ../src/cx/compare.h ../src/cx/array_list.h ../src/cx/list.h \ 117 ../src/cx/collection.h ../src/cx/allocator.h ../src/cx/iterator.h \ 118 ../src/cx/compare.h ../src/cx/linked_list.h ../src/cx/kv_list.h \ 119 ../src/cx/map.h ../src/cx/string.h ../src/cx/hash_key.h 120 @echo "Compiling $<" 121 $(CC) -o $@ $(CFLAGS) -I../src -c $< 122 123 $(TEST_DIR)/test_mempool$(OBJ_EXT): test_mempool.c ../src/cx/test.h \ 124 ../src/cx/mempool.h ../src/cx/common.h ../src/cx/allocator.h 125 @echo "Compiling $<" 126 $(CC) -o $@ $(CFLAGS) -I../src -c $< 127 128 $(TEST_DIR)/test_printf$(OBJ_EXT): test_printf.c ../src/cx/test.h \ 129 util_allocator.h ../src/cx/allocator.h ../src/cx/common.h \ 130 ../src/cx/printf.h ../src/cx/string.h ../src/cx/allocator.h \ 131 ../src/cx/buffer.h 132 @echo "Compiling $<" 133 $(CC) -o $@ $(CFLAGS) -I../src -c $< 134 135 $(TEST_DIR)/test_properties$(OBJ_EXT): test_properties.c ../src/cx/test.h \ 136 util_allocator.h ../src/cx/allocator.h ../src/cx/common.h \ 137 ../src/cx/properties.h ../src/cx/string.h ../src/cx/allocator.h \ 138 ../src/cx/map.h ../src/cx/collection.h ../src/cx/iterator.h \ 139 ../src/cx/compare.h ../src/cx/hash_key.h ../src/cx/buffer.h \ 140 ../src/cx/hash_map.h 141 @echo "Compiling $<" 142 $(CC) -o $@ $(CFLAGS) -I../src -c $< 143 144 $(TEST_DIR)/test_streams$(OBJ_EXT): test_streams.c ../src/cx/test.h \ 145 ../src/cx/streams.h ../src/cx/common.h ../src/cx/buffer.h \ 146 ../src/cx/allocator.h ../src/cx/string.h 147 @echo "Compiling $<" 148 $(CC) -o $@ $(CFLAGS) -I../src -c $< 149 150 $(TEST_DIR)/test_string$(OBJ_EXT): test_string.c ../src/cx/test.h \ 151 util_allocator.h ../src/cx/allocator.h ../src/cx/common.h \ 152 ../src/cx/string.h ../src/cx/allocator.h ../src/cx/compare.h 153 @echo "Compiling $<" 154 $(CC) -o $@ $(CFLAGS) -I../src -c $< 155 156 $(TEST_DIR)/test_szmul$(OBJ_EXT): test_szmul.c ../src/cx/test.h \ 157 ../src/cx/common.h ../src/szmul.c ../src/cx/common.h 158 @echo "Compiling $<" 159 $(CC) -o $@ $(CFLAGS) -I../src -c $< 160 161 $(TEST_DIR)/test_tree$(OBJ_EXT): test_tree.c ../src/cx/tree.h \ 162 ../src/cx/common.h ../src/cx/collection.h ../src/cx/allocator.h \ 163 ../src/cx/iterator.h ../src/cx/compare.h ../src/cx/test.h \ 164 util_allocator.h ../src/cx/allocator.h 165 @echo "Compiling $<" 166 $(CC) -o $@ $(CFLAGS) -I../src -c $< 167 168 $(TEST_DIR)/ucxtest$(OBJ_EXT): ucxtest.c util_allocator.h \ 169 ../src/cx/allocator.h ../src/cx/common.h ../src/cx/common.h \ 170 ../src/cx/test.h 171 @echo "Compiling $<" 172 $(CC) -o $@ $(CFLAGS) -I../src -c $< 173 174 $(TEST_DIR)/util_allocator$(OBJ_EXT): util_allocator.c util_allocator.h \ 175 ../src/cx/allocator.h ../src/cx/common.h ../src/cx/test.h 176 @echo "Compiling $<" 177 $(CC) -o $@ $(CFLAGS) -I../src -c $< 178 179