# Copyright 2023 Mike Becker. All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted provided that the following conditions are met:
#
# 1. Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# 2. Redistributions in binary form must reproduce the above copyright
# notice, this list of conditions and the following disclaimer in the
# documentation and/or other materials provided with the distribution.
#
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
# AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
# SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
# CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
include ../config.mk
SRC = allocator.c array_list.c buffer.c compare.c hash_key.c hash_map.c \
iterator.c linked_list.c list.c map.c kv_list.c tree.c \
mempool.c printf.c string.c streams.c szmul.c properties.c json.c
OBJ_EXT=.o
OBJ=$(SRC:%.c=$(build_dir)/%$(OBJ_EXT))
static: $(build_dir)/libucx_static$(STLIB_EXT)
shared: $(build_dir)/libucx$(SHLIB_EXT)
check-coverage: $(SRC:%.c=$(build_dir)/%.gcda) $(build_dir)/coverage
gcovr --html-details $(build_dir)/coverage/ucx.html \
--object-directory $(build_dir) \
--root $(root_dir)/src \
--exclude-directories $(build_dir)/tests \
$(build_dir)
$(build_dir)/coverage:
$(MKDIR) $@/
$(build_dir)/%.gcda:
test -f "$@"
$(build_dir)/libucx_static$(STLIB_EXT): $(OBJ)
$(AR) $(ARFLAGS) $@ $^
$(build_dir)/libucx$(SHLIB_EXT): $(OBJ)
$(CC) $(LDFLAGS) -o $@ $^
rebuild_if_missing:
if test -f $(build_dir)/libucx_static$(STLIB_EXT) && test -f $(build_dir)/libucx$(SHLIB_EXT); \
then : ; else cd $(root_dir); $(MAKE) compile; fi
install: rebuild_if_missing
$(MKDIR) $(DESTDIR)$(libdir)/ $(DESTDIR)$(includedir)/cx/ $(DESTDIR)$(pkgconfigdir)/
$(RMFILE) $(DESTDIR)$(libdir)/libucx$(SHLIB_EXT).$(LIBVERSION_MAJOR)
$(RMFILE) $(DESTDIR)$(libdir)/libucx$(SHLIB_EXT)
$(COPYFILE) $(build_dir)/libucx_static$(STLIB_EXT) $(DESTDIR)$(libdir)/libucx_static$(STLIB_EXT)
$(SHELL) "$(INSTALL_LIB)" "$(build_dir)/libucx$(SHLIB_EXT)" "$(libdir)" $(LIBVERSION) $(LIBVERSION_MAJOR) "$(DESTDIR)"
$(COPYALL) $(root_dir)/src/cx $(DESTDIR)$(includedir)
$(SHELL) "$(root_dir)/make/install-pc-file.sh" "$(pkgconfigdir)" "$(VERSION)" "$(libdir)" "$(includedir)" "$(DESTDIR)"
FORCE:
$(build_dir)/allocator$(OBJ_EXT): allocator.c cx/allocator.h cx/common.h
@echo "Compiling $<"
$(CC) -o $@ $(CFLAGS) -c $<
$(build_dir)/array_list$(OBJ_EXT): array_list.c cx/array_list.h cx/list.h \
cx/common.h cx/collection.h cx/allocator.h cx/iterator.h cx/compare.h \
cx/compare.h
@echo "Compiling $<"
$(CC) -o $@ $(CFLAGS) -c $<
$(build_dir)/buffer$(OBJ_EXT): buffer.c cx/buffer.h cx/common.h \
cx/allocator.h cx/string.h
@echo "Compiling $<"
$(CC) -o $@ $(CFLAGS) -c $<
$(build_dir)/compare$(OBJ_EXT): compare.c cx/compare.h cx/common.h
@echo "Compiling $<"
$(CC) -o $@ $(CFLAGS) -c $<
$(build_dir)/hash_key$(OBJ_EXT): hash_key.c cx/hash_key.h cx/common.h \
cx/string.h cx/allocator.h cx/compare.h
@echo "Compiling $<"
$(CC) -o $@ $(CFLAGS) -c $<
$(build_dir)/hash_map$(OBJ_EXT): hash_map.c cx/hash_map.h cx/map.h \
cx/common.h cx/collection.h cx/allocator.h cx/iterator.h cx/compare.h \
cx/string.h cx/hash_key.h
@echo "Compiling $<"
$(CC) -o $@ $(CFLAGS) -c $<
$(build_dir)/iterator$(OBJ_EXT): iterator.c cx/iterator.h cx/common.h
@echo "Compiling $<"
$(CC) -o $@ $(CFLAGS) -c $<
$(build_dir)/json$(OBJ_EXT): json.c cx/json.h cx/common.h cx/allocator.h \
cx/string.h cx/buffer.h cx/array_list.h cx/list.h cx/collection.h \
cx/iterator.h cx/compare.h cx/map.h cx/hash_key.h cx/kv_list.h
@echo "Compiling $<"
$(CC) -o $@ $(CFLAGS) -c $<
$(build_dir)/kv_list$(OBJ_EXT): kv_list.c cx/kv_list.h cx/common.h \
cx/list.h cx/collection.h cx/allocator.h cx/iterator.h cx/compare.h \
cx/map.h cx/string.h cx/hash_key.h cx/hash_map.h cx/linked_list.h
@echo "Compiling $<"
$(CC) -o $@ $(CFLAGS) -c $<
$(build_dir)/linked_list$(OBJ_EXT): linked_list.c cx/linked_list.h \
cx/common.h cx/list.h cx/collection.h cx/allocator.h cx/iterator.h \
cx/compare.h cx/compare.h
@echo "Compiling $<"
$(CC) -o $@ $(CFLAGS) -c $<
$(build_dir)/list$(OBJ_EXT): list.c cx/list.h cx/common.h cx/collection.h \
cx/allocator.h cx/iterator.h cx/compare.h
@echo "Compiling $<"
$(CC) -o $@ $(CFLAGS) -c $<
$(build_dir)/map$(OBJ_EXT): map.c cx/map.h cx/common.h cx/collection.h \
cx/allocator.h cx/iterator.h cx/compare.h cx/string.h cx/hash_key.h \
cx/list.h
@echo "Compiling $<"
$(CC) -o $@ $(CFLAGS) -c $<
$(build_dir)/mempool$(OBJ_EXT): mempool.c cx/mempool.h cx/common.h \
cx/allocator.h
@echo "Compiling $<"
$(CC) -o $@ $(CFLAGS) -c $<
$(build_dir)/printf$(OBJ_EXT): printf.c cx/printf.h cx/common.h \
cx/string.h cx/allocator.h
@echo "Compiling $<"
$(CC) -o $@ $(CFLAGS) -c $<
$(build_dir)/properties$(OBJ_EXT): properties.c cx/properties.h \
cx/common.h cx/string.h cx/allocator.h cx/map.h cx/collection.h \
cx/iterator.h cx/compare.h cx/hash_key.h cx/buffer.h
@echo "Compiling $<"
$(CC) -o $@ $(CFLAGS) -c $<
$(build_dir)/streams$(OBJ_EXT): streams.c cx/streams.h cx/common.h \
cx/allocator.h
@echo "Compiling $<"
$(CC) -o $@ $(CFLAGS) -c $<
$(build_dir)/string$(OBJ_EXT): string.c cx/string.h cx/common.h \
cx/allocator.h
@echo "Compiling $<"
$(CC) -o $@ $(CFLAGS) -c $<
$(build_dir)/szmul$(OBJ_EXT): szmul.c cx/common.h
@echo "Compiling $<"
$(CC) -o $@ $(CFLAGS) -c $<
$(build_dir)/tree$(OBJ_EXT): tree.c cx/tree.h cx/common.h cx/collection.h \
cx/allocator.h cx/iterator.h cx/compare.h cx/array_list.h cx/list.h
@echo "Compiling $<"
$(CC) -o $@ $(CFLAGS) -c $<