Newer
Older
Shubham Sharma
committed
# Makefile for qosmngr
include common.mk
Shubham Sharma
committed
QOSMNGR_LIB=libqosmngr.so
GCOV=gcov
SRC_DIR = src
CODECOVERAGE_SRC = $(addprefix $(SRC_DIR)/, qosmngr.c )
Shubham Sharma
committed
PROG = $(PROJECT_TOPLEVEL)/qosmngr
SHARED_LIB = $(PROJECT_TOPLEVEL)/libqosmngr.so
OBJS = $(addprefix $(SRC_DIR)/, main.o qosmngr.o )
PROG_CFLAGS = $(CFLAGS) -I$(INCLUDE_DIR) $(DIAG_CFLAGS) -Werror -fstrict-aliasing
Shubham Sharma
committed
PROG_LDFLAGS = $(LDFLAGS)
PROG_LIBS = $(COMMON_LDFLAGS) -lgcov
# MUSL has the following issue in snprintf, so it is ignored:
PROG_CFLAGS += -Wno-format-nonliteral
Shubham Sharma
committed
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
.PHONY: all clean
all: version $(PROG)
$(PROG): $(INCLUDE_DIR)/version.h $(OBJS)
$(CC) $(PROG_LDFLAGS) -o $@ $^ $(PROG_LIBS)
${QOSMNGR_LIB}:
$(CC) $(PROG_LDFLAGS) -shared -o $@ $^ $(PROG_LIBS)
$(SHARED_LIB): $(INCLUDE_DIR)/version.h $(OBJS)
version: $(INCLUDE_DIR)/version.h
$(INCLUDE_DIR)/version.h: $(PROJECT_TOPLEVEL)/VERSION
@(dirty=$(shell (git status --porcelain | grep -q .) && echo -dirty); \
[ -f $(PROJECT_TOPLEVEL)/VERSION ] && basever=$(shell cat $(PROJECT_TOPLEVEL)/VERSION) || \
basever=Unknown; \
xver=$(shell date +'%y%V%u-%H%M'); \
echo "const char *qosmngr_base_version = \"$$basever\";" > $@; \
echo "const char *qosmngr_xtra_version = \"$$xver$$dirty\";" >> $@; \
)
test: ${QOSMNGR_LIB}
coverage: CFLAGS += -g -O0 -fprofile-arcs -ftest-coverage -fPIC
coverage: LDFLAGS += --coverage
coverage: test $(PROG)
$(foreach testprog, $(CODECOVERAGE_SRC), $(GCOV) $(testprog);)
functional-test: test
$(MAKE) -C test/cmocka functional-test
%.o: %.c
$(CC) $(PROG_CFLAGS) $(FPIC) -c -o $@ $<
clean:
rm -f *.o $(SHARED_LIB) $(PROG) $(INCLUDE_DIR)/version.h
rm -f *.xml *.html
find -name '*.gcda' -exec rm {} -fv \;
find -name '*.gcno' -exec rm {} -fv \;
find -name '*.gcov' -exec rm {} -fv \;
make -C test/cmocka clean