Files
datalink_nc_mode/datalink814_ge/unit_test/Makefile
T

82 lines
2.7 KiB
Makefile

PMD_HOME ?= /home/gatsby/Software/pmd-bin-6.0.1
OCLINT_HOME ?= /home/gatsby/Software/oclint-0.13.1
# Source files
COMMON_SRC := ../src/error.h ../src/common.h ../src/common.c
TEST_FRAME := ../../unit_test_framework.h
UTIL_SRC := $(wildcard ../src/util/*.c ../src/util/*.h)
TMC_SRC := $(wildcard ../src/time_ctrl/*.c ../src/time_ctrl/*.h)
PHY_SRC := $(wildcard ../src/phy_ctrl/*.c ../src/phy_ctrl/*.h)
GEOMETRY_SRC := $(wildcard ../src/linklayer/geometry/*.c ../src/linklayer/geometry/*.h)
LINK_SRC := $(wildcard ../src/linklayer/*.c ../src/linklayer/*.h)
BIARRAY_SRC := $(wildcard ../src/bit_array/*.c ../src/bit_array/*.h)
# Compiler
CC ?= gcc
# Compiler flags
CFLAGS ?= --std=c11 -O0 -I../src -Wall -Wformat=2 -Werror -pedantic -g -Wno-sign-compare -Wno-comment
# Add sanitizer flags for identifying undefined behavior. The flags are
# different on macOS (AKA Darwin) and Windows/WSL/Linux.
UNAME := $(shell uname -s)
ifeq "$(UNAME)" "Darwin"
CFLAGS += -fsanitize=address -fsanitize=undefined
else
CFLAGS += -m32 -fsanitize=address -fsanitize=undefined -D_GLIBCC_DEBUG
endif
test: tmc_emulate_unit_test.exe linklayer_emulate_unit_test.exe
./tmc_emulate_unit_test.exe > tmc_emulate_unit_test.log
./linklayer_emulate_unit_test.exe > linklayer_emulate_unit_test.log
tmc_board_unit_test.exe: tmc_board_unit_test.c $(TMC_SRC) $(UTIL_SRC) $(COMMON_SRC) $(TEST_FRAME)
$(CC) $(CFLAGS) $(filter %.c, $^) -o $@
tmc_emulate_unit_test.exe: tmc_emulate_unit_test.c $(TMC_SRC) $(UTIL_SRC) $(COMMON_SRC) $(TEST_FRAME)
$(CC) $(CFLAGS) -DEMULATION $(filter %.c, $^) -o $@
linklayer_emulate_unit_test.exe: linklayer_emulate_unit_test.c \
$(LINK_SRC) \
$(BIARRAY_SRC) \
$(GEOMETRY_SRC) \
$(PHY_SRC) \
$(TMC_SRC) \
$(UTIL_SRC) \
$(COMMON_SRC) \
$(TEST_FRAME)
$(CC) $(CFLAGS) -lm -DEMULATION $(filter %.c, $^) -o $@
clean:
rm -f *.exe *.log
# Style check
CPD ?= $(PMD_HOME)/bin/run.sh cpd
OCLINT ?= $(OCLINT_HOME)/bin/oclint
FILES := $(SRCS)
CPD_FILES := $(SRCS)
style :
$(OCLINT) \
-no-analytics \
-rule=LongLine \
-rule=HighNcssMethod \
-rule=DeepNestedBlock \
-rule=TooManyParameters \
-rc=LONG_LINE=80 \
-rc=NCSS_METHOD=1000 \
-rc=NESTED_BLOCK_DEPTH=4 \
-rc=TOO_MANY_PARAMETERS=4 \
-max-priority-1 0 \
-max-priority-2 0 \
-max-priority-3 0 \
$(FILES) \
-- -xc++ --std=c99
$(CPD) \
--minimum-tokens 100 \
--language c \
--failOnViolation true \
--files $(CPD_FILES)
@echo "########################################"
@echo "Style checks PASS"
.PHONY: clean test