Makefile 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354
  1. TEST_PROGRAM=test_multi_heap
  2. all: $(TEST_PROGRAM)
  3. ifneq ($(filter clean,$(MAKECMDGOALS)),)
  4. .NOTPARALLEL: # prevent make clean racing the other targets
  5. endif
  6. SOURCE_FILES = $(abspath \
  7. ../multi_heap.c \
  8. ../heap_tlsf.c \
  9. ../multi_heap_poisoning.c \
  10. test_multi_heap.cpp \
  11. main.cpp \
  12. )
  13. INCLUDE_FLAGS = -I../include -I../../../tools/catch
  14. GCOV ?= gcov
  15. CPPFLAGS += $(INCLUDE_FLAGS) -D CONFIG_LOG_DEFAULT_LEVEL -g -fstack-protector-all -m32 -DCONFIG_HEAP_POISONING_COMPREHENSIVE
  16. CFLAGS += -Wall -Werror -fprofile-arcs -ftest-coverage
  17. CXXFLAGS += -std=c++11 -Wall -Werror -fprofile-arcs -ftest-coverage
  18. LDFLAGS += -lstdc++ -fprofile-arcs -ftest-coverage -m32
  19. OBJ_FILES = $(filter %.o, $(SOURCE_FILES:.cpp=.o) $(SOURCE_FILES:.c=.o))
  20. COVERAGE_FILES = $(OBJ_FILES:.o=.gc*)
  21. $(TEST_PROGRAM): $(OBJ_FILES)
  22. g++ $(LDFLAGS) -o $(TEST_PROGRAM) $(OBJ_FILES)
  23. $(OUTPUT_DIR):
  24. mkdir -p $(OUTPUT_DIR)
  25. test: $(TEST_PROGRAM)
  26. ./$(TEST_PROGRAM)
  27. $(COVERAGE_FILES): $(TEST_PROGRAM) test
  28. coverage.info: $(COVERAGE_FILES)
  29. find ../ -name "*.gcno" -exec $(GCOV) -r -pb {} +
  30. lcov --capture --directory $(abspath ../) --no-external --output-file coverage.info --gcov-tool $(GCOV)
  31. coverage_report: coverage.info
  32. genhtml coverage.info --output-directory coverage_report
  33. @echo "Coverage report is in coverage_report/index.html"
  34. clean:
  35. rm -f $(OBJ_FILES) $(TEST_PROGRAM)
  36. rm -f $(COVERAGE_FILES) *.gcov
  37. rm -rf coverage_report/
  38. rm -f coverage.info
  39. .PHONY: clean all test