summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThierry Carré2013-04-15 17:36:29 +0200
committerThierry Carré2013-04-26 17:06:12 +0200
commit6e6d87914068ae615c3f08fa0a557a89f1257b6b (patch)
tree3caa31a90e734bc9940576ced2f9c39d3d948b5b
parent8dc1cc159e1749659b49a27c592344b74dd2e3a6 (diff)
cleo/devkit/tests/libspid: remove cesar's makefile usage and add coverage
-rw-r--r--cleopatre/devkit/tests/libspid/utests/Makefile77
1 files changed, 59 insertions, 18 deletions
diff --git a/cleopatre/devkit/tests/libspid/utests/Makefile b/cleopatre/devkit/tests/libspid/utests/Makefile
index c459df544d..dbc7df85e3 100644
--- a/cleopatre/devkit/tests/libspid/utests/Makefile
+++ b/cleopatre/devkit/tests/libspid/utests/Makefile
@@ -1,26 +1,67 @@
-BASE = ../../../../../cesar
-CLEO_BASE = ../cleopatre
+OBJ_DIR := obj
+SRC_DIR := src
+INC_DIR := .
+OVERRIDE_DIR := override
-# We test libspid.
-PROJECT_DIR = $(CLEO_BASE)/application/libspid
+CLEO_DIR := ../../../..
+LIBSPID_DIR := $(CLEO_DIR)/application/libspid
+LIBSPID_SRC_DIR := $(LIBSPID_DIR)/src
-INCLUDES = $(PROJECT_DIR)/inc $(CLEO_BASE)/include
+INCLUDES := -I $(OVERRIDE_DIR) \
+ -I $(INC_DIR) \
+ -I $(CLEO_DIR)/include \
+ $(shell $(LIBSPID_DIR)/libspid-config --I_opts)
-DEFS = -D__UTESTS__
+DEF_FLAGS := -D__UTESTS__
+CC := gcc
+CFLAGS := $(INCLUDES) $(DEF_FLAGS) -MMD -Wall -g
+CFLAGS_WITH_COV := $(CFLAGS) -fprofile-arcs -ftest-coverage
+LFLAGS := -lcheck -fprofile-arcs
-EXTRA_HOST_LDLIBS = -lcheck
-# Templates to define list of sources & module to use.
-# Parameter: $1 is executabe & source name (without .c).
-define utest_libspid
-$(1)_SOURCES = $(1).c
-$(1)_MODULES = $(PROJECT_DIR)
-endef
+UTEST_SRCS := $(subst $(SRC_DIR)/,,$(wildcard $(SRC_DIR)/*.c))
+UTEST_OBJS := $(addprefix $(OBJ_DIR)/,$(UTEST_SRCS:.c=.o))
+LIBSPID_SRCS := $(subst $(LIBSPID_SRC_DIR)/,,$(wildcard $(LIBSPID_SRC_DIR)/*.c))
+LIBSPID_OBJS := $(addprefix $(OBJ_DIR)/,$(LIBSPID_SRCS:.c=.o))
-HOST_PROGRAMS = system_utests network_utests config_item_utests \
- config_line_utests hpav_info_utests image_utests
+SRCS := $(UTEST_SRCS) $(LIBSPID_SRCS)
+OBJS := $(UTEST_OBJS) $(LIBSPID_OBJS)
+DEPS := $(patsubst %o,%d,$(OBJS))
+COVS := $(patsubst %o,%gcno,$(LIBSPID_OBJS)) $(patsubst %o,%gcda,$(LIBSPID_OBJS))
-# Generate sources & module list for each host programs.
-$(foreach prog,$(HOST_PROGRAMS),$(eval $(call utest_libspid,$(prog))))
+# list each host program to build
+HOST_PROGRAMS := system_utests network_utests config_item_utests \
+ config_line_utests hpav_info_utests image_utests
-include $(BASE)/common/make/top.mk
+HOST_PROGRAMS_BIN := $(addprefix $(OBJ_DIR)/, $(HOST_PROGRAMS))
+
+all: $(HOST_PROGRAMS_BIN)
+
+# Build target with all libspid sources.
+# It's really not the best, because that include all libspid.
+$(OBJ_DIR)/% : $(OBJ_DIR)/%.o $(LIBSPID_OBJS)
+ $(CC) -o $@ $^ $(LFLAGS)
+
+# Global rules
+$(OBJ_DIR)/%.o: $(SRC_DIR)/%.c
+ $(CC) $(CFLAGS) -o $@ -c $<
+
+$(OBJ_DIR)/%.o: $(LIBSPID_SRC_DIR)/%.c
+ $(CC) $(CFLAGS_WITH_COV) -o $@ -c $<
+
+$(OBJS): | $(OBJ_DIR)
+
+$(OBJ_DIR):
+ mkdir $@
+
+-include $(DEPS)
+
+.PHONY: all clean
+
+clean:
+ rm -f $(HOST_PROGRAMS_BIN)
+ rm -f $(LIBSPID_OBJS:.o=.info)
+ rm -f $(OBJS)
+ rm -f $(DEPS)
+ rm -f $(COVS)
+ -rmdir $(OBJ_DIR)