makefile 947 B

12345678910111213141516171819202122232425262728293031323334353637
  1. include $(top_dir)/helpers.mk
  2. src = $(wildcard **/*_test.c)
  3. target ::= $(addprefix $(build_test_dir), $(basename $(src)))
  4. build_dir = $(call uniq,$(dir $(target)))
  5. CFLAGS += -I$(cmoka_include) -I$(bot_include)
  6. LDFLAGS :=
  7. LDLIBS := -L$(cmoka_lib_path) -lcmocka -L$(bot_lib_path) -lscrapper
  8. DYNAMIC_LIBRARY_PATH := LD_LIBRARY_PATH=$(cmoka_lib_path):$(bot_lib_path)
  9. all: $(build_dir) $(target) run_test
  10. $(build_dir):
  11. @mkdir -p $(build_dir)
  12. -include $(addsuffix .d, $(target))
  13. $(target): $(bot_shared_lib)
  14. $(target): $(build_test_dir)%: %.c
  15. @$(call print_info,building test)
  16. $(CC) -o $@ $< $(CFLAGS) $(LDLIBS)
  17. run_test:
  18. @$(call print_info,running test)
  19. $(if $(test_suite), \
  20. $(foreach file, \
  21. $(foreach _, $(target), $(if $(findstring $(test_suite), $(notdir $_)), $_)), \
  22. $(DYNAMIC_LIBRARY_PATH) $(file)), \
  23. $(foreach file, $(target), $(DYNAMIC_LIBRARY_PATH) $(file)))
  24. clean:
  25. rm -fr $(build_test_dir)
  26. .PHONY: clean run_test