aboutsummaryrefslogtreecommitdiffstats
path: root/libs/uds-c/Makefile
diff options
context:
space:
mode:
authorRomain Forlot <romain.forlot@iot.bzh>2017-06-20 10:24:05 +0000
committerRomain Forlot <romain.forlot@iot.bzh>2017-06-20 10:24:05 +0000
commit32e25cbca210a359b09768537b6f443fe90a3070 (patch)
tree3309794c15d8a8f8e9c1c08cad072ee1378813ba /libs/uds-c/Makefile
parent76c43dec62b2e21cd6446360c00d4fe6b437533f (diff)
Separation Generator to a dedicated repo
Change-Id: Id94831651c3266861435272a6e36c7884bef2c45 Signed-off-by: Romain Forlot <romain.forlot@iot.bzh>
Diffstat (limited to 'libs/uds-c/Makefile')
-rw-r--r--libs/uds-c/Makefile56
1 files changed, 56 insertions, 0 deletions
diff --git a/libs/uds-c/Makefile b/libs/uds-c/Makefile
new file mode 100644
index 00000000..4adf3ceb
--- /dev/null
+++ b/libs/uds-c/Makefile
@@ -0,0 +1,56 @@
+CC = gcc
+INCLUDES = -Isrc -Ideps/bitfield-c/src -Ideps/isotp-c/src
+CFLAGS = $(INCLUDES) -c -Wall -Werror -g -ggdb -std=gnu99 -coverage
+LDFLAGS = -coverage -lm
+LDLIBS = -lcheck
+
+TEST_DIR = tests
+TEST_OBJDIR = build
+
+# Guard against \r\n line endings only in Cygwin
+OSTYPE := $(shell uname)
+ifneq ($(OSTYPE),Darwin)
+ OSTYPE := $(shell uname -o)
+ ifeq ($(OSTYPE),Cygwin)
+ TEST_SET_OPTS = igncr
+ endif
+endif
+
+SRC = $(wildcard src/**/*.c)
+SRC += $(wildcard deps/bitfield-c/src/**/*.c)
+SRC += $(wildcard deps/isotp-c/src/**/*.c)
+OBJS = $(patsubst %,$(TEST_OBJDIR)/%,$(SRC:.c=.o))
+TEST_SRC = $(wildcard $(TEST_DIR)/test_*.c)
+TESTS=$(patsubst %.c,$(TEST_OBJDIR)/%.bin,$(TEST_SRC))
+TEST_SUPPORT_SRC = $(TEST_DIR)/common.c
+TEST_SUPPORT_OBJS = $(patsubst %,$(TEST_OBJDIR)/%,$(TEST_SUPPORT_SRC:.c=.o))
+
+all: $(OBJS)
+
+test: $(TESTS)
+ @set -o $(TEST_SET_OPTS) >/dev/null 2>&1
+ @export SHELLOPTS
+ @sh runtests.sh $(TEST_OBJDIR)/$(TEST_DIR)
+
+COVERAGE_INFO_FILENAME = coverage.info
+COVERAGE_INFO_PATH = $(TEST_OBJDIR)/$(COVERAGE_INFO_FILENAME)
+coverage:
+ @lcov --base-directory . --directory src --zerocounters -q
+ @make clean
+ @make test
+ @lcov --base-directory . --directory $(TEST_OBJDIR) -c -o $(TEST_OBJDIR)/coverage.info
+ @lcov --remove $(COVERAGE_INFO_PATH) "deps/*" -o $(COVERAGE_INFO_PATH)
+ @genhtml -o $(TEST_OBJDIR)/coverage -t "isotp-c test coverage" --num-spaces 4 $(COVERAGE_INFO_PATH)
+ @$(BROWSER) $(TEST_OBJDIR)/coverage/index.html
+ @echo "$(GREEN)Coverage information generated in $(TEST_OBJDIR)/coverage/index.html.$(COLOR_RESET)"
+
+$(TEST_OBJDIR)/%.o: %.c
+ @mkdir -p $(dir $@)
+ $(CC) $(CFLAGS) $(CC_SYMBOLS) $(INCLUDES) -o $@ $<
+
+$(TEST_OBJDIR)/%.bin: $(TEST_OBJDIR)/%.o $(OBJS) $(TEST_SUPPORT_OBJS)
+ @mkdir -p $(dir $@)
+ $(CC) $(LDFLAGS) $(CC_SYMBOLS) $(INCLUDES) -o $@ $^ $(LDLIBS)
+
+clean:
+ rm -rf $(TEST_OBJDIR)