src/Makefile

Tue, 02 Jan 2024 23:31:00 +0100

author
Mike Becker <universe@uap-core.de>
date
Tue, 02 Jan 2024 23:31:00 +0100
changeset 791
945ee9bf2dd1
parent 774
4fd4e0c6107a
child 794
23c6e3e846a8
permissions
-rw-r--r--

generate (release) config.mk if none exists - fixes #350

# 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 \
  linked_list.c list.c map.c mempool.c printf.c string.c utils.c

OBJ_EXT=.o
OBJ=$(SRC:%.c=$(build_dir)/%$(OBJ_EXT))
GCOV=$(SRC:%.c=%.c.gcov)

static: $(build_dir)/libucx_static$(STLIB_EXT)

shared: $(build_dir)/libucx$(SHLIB_EXT)

check-coverage: $(GCOV)
	mv *.gcov "$(build_dir)"

%.c.gcov: %.c $(build_dir)/%.gcno
	gcov -Ho "$(build_dir)" $<

$(build_dir)/%.gcno:
	test -f "$@"

$(build_dir)/libucx_static$(STLIB_EXT): $(OBJ)
	$(AR) $(ARFLAGS) $@ $^

$(build_dir)/libucx$(SHLIB_EXT): $(OBJ)
	$(CC) $(LDFLAGS) -o $@ $^

install: $(build_dir)/libucx_static$(STLIB_EXT) $(build_dir)/libucx$(SHLIB_EXT)
	$(MKDIR) $(libdir) $(includedir)/cx
	$(RMFILE) $(libdir)/libucx$(SHLIB_EXT).$(LIBVERSION_MAJOR)
	$(RMFILE) $(libdir)/libucx$(SHLIB_EXT)
	$(COPYFILE) $(build_dir)/libucx_static$(STLIB_EXT) $(libdir)/libucx_static$(STLIB_EXT)
	$(COPYFILE) $(build_dir)/libucx$(SHLIB_EXT) $(libdir)/libucx$(SHLIB_EXT).$(LIBVERSION)
	$(COPYALL) $(src_dir)/src/cx $(includedir)
	$(SYMLINK) $(libdir)/libucx$(SHLIB_EXT).$(LIBVERSION) $(libdir)/libucx$(SHLIB_EXT).$(LIBVERSION_MAJOR)
	$(SYMLINK) $(libdir)/libucx$(SHLIB_EXT).$(LIBVERSION_MAJOR) $(libdir)/libucx$(SHLIB_EXT)

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
	@echo "Compiling $<"
	$(CC) -o $@ $(CFLAGS) -c $<

$(build_dir)/buffer$(OBJ_EXT): buffer.c cx/buffer.h cx/common.h \
 cx/allocator.h cx/utils.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
	@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/string.h \
 cx/hash_key.h cx/utils.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/utils.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
	@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/string.h cx/hash_key.h
	@echo "Compiling $<"
	$(CC) -o $@ $(CFLAGS) -c $<

$(build_dir)/mempool$(OBJ_EXT): mempool.c cx/mempool.h cx/common.h \
 cx/allocator.h cx/utils.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)/string$(OBJ_EXT): string.c cx/string.h cx/common.h \
 cx/allocator.h cx/utils.h
	@echo "Compiling $<"
	$(CC) -o $@ $(CFLAGS) -c $<

$(build_dir)/szmul$(OBJ_EXT): szmul.c
	@echo "Compiling $<"
	$(CC) -o $@ $(CFLAGS) -c $<

$(build_dir)/utils$(OBJ_EXT): utils.c cx/utils.h cx/common.h
	@echo "Compiling $<"
	$(CC) -o $@ $(CFLAGS) -c $<

mercurial