diff options
author | Romain Forlot <romain.forlot@iot.bzh> | 2017-05-02 17:52:11 +0200 |
---|---|---|
committer | Romain Forlot <romain.forlot@iot.bzh> | 2017-05-02 17:52:11 +0200 |
commit | 0242c26c2f5dc96387bca7efb118364c800f4ee7 (patch) | |
tree | ba0a67a78004a45afd158a3ca3fb01c6fc012e06 /CAN-binder/libs/uds-c/Makefile | |
parent | 3102ec9ce009d0f28355c5b7df9c5bd5013e6e75 (diff) | |
parent | ca20db3dd978871bbb9f01f3c862b510c03d1dc4 (diff) |
Add 'CAN-binder/libs/uds-c/' from commit 'ca20db3dd978871bbb9f01f3c862b510c03d1dc4'
git-subtree-dir: CAN-binder/libs/uds-c
git-subtree-mainline: 3102ec9ce009d0f28355c5b7df9c5bd5013e6e75
git-subtree-split: ca20db3dd978871bbb9f01f3c862b510c03d1dc4
Diffstat (limited to 'CAN-binder/libs/uds-c/Makefile')
-rw-r--r-- | CAN-binder/libs/uds-c/Makefile | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/CAN-binder/libs/uds-c/Makefile b/CAN-binder/libs/uds-c/Makefile new file mode 100644 index 00000000..4adf3ceb --- /dev/null +++ b/CAN-binder/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) |