Makefile 2.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. #!/usr/bin/make -f
  2. #define path variables
  3. IPP_INCLUDE_DIR = ../../ext/ipp/sources/ippcp/src
  4. GTEST_INCLUDE_DIR = ../../ext
  5. LIB_INSTALL_DIR = $(epidinstalldir)/lib/posix-$(ARCH)/
  6. TEST_INSTALL_DIR = $(epidinstalldir)/test/
  7. HEADERS_INSTALL_DIR := $(epidinstalldir)/include/epid/common/
  8. HEADERS_11_INSTALL_DIR := $(epidinstalldir)/include/epid/common/1.1
  9. API_HEADERS_INSTALL = $(wildcard ./*.h)
  10. API_11_HEADERS_INSTALL = $(wildcard ./1.1/*.h)
  11. COMMON_INCLUDE_DIR = ../../
  12. COMMON_MATH_INCLUDE_DIR = ./math
  13. COMMON_SRC = $(wildcard ./src/*.c)
  14. COMMON_SRC += $(wildcard ./math/src/*.c)
  15. COMMON_SRC += $(wildcard ./1.1/src/*.c)
  16. COMMON_OBJ = $(COMMON_SRC:.c=.o)
  17. COMMON_LIB = ./libcommon.a
  18. COMMON_UTEST_EXE = ./common-utest$(EXE_EXTENSION)
  19. COMMON_UTEST_SRC = $(wildcard ./math/unittests/*.cc)
  20. COMMON_UTEST_SRC += $(wildcard ./unittests/*.cc)
  21. COMMON_UTEST_SRC += $(wildcard ./1.1/unittests/*.cc)
  22. COMMON_UTEST_OBJ = $(COMMON_UTEST_SRC:.cc=.o)
  23. LIB_COMMON_DIR = .
  24. LIB_COMMON_TESTHELPER_DIR = ../common-testhelper
  25. LIB_IPPCP_DIR = ../../ext/ipp/sources/ippcp/src
  26. #set flags for linker
  27. LDFLAGS += -L$(GTEST_INCLUDE_DIR)/gtest -L$(LIB_COMMON_TESTHELPER_DIR) \
  28. -L$(LIB_COMMON_DIR) -L$(LIB_IPPCP_DIR) \
  29. -lgtest -lcommon-testhelper -lcommon -lippcp
  30. #target part
  31. $(COMMON_OBJ): %.o: %.c
  32. $(CC) $(CFLAGS) -I$(IPP_INCLUDE_DIR) -I$(COMMON_MATH_INCLUDE_DIR) -I$(COMMON_INCLUDE_DIR) -c $^ -o $@
  33. $(COMMON_LIB): $(COMMON_OBJ)
  34. $(AR) rc $(COMMON_LIB) $(COMMON_OBJ)
  35. $(RANLIB) $(COMMON_LIB)
  36. $(COMMON_UTEST_EXE): $(COMMON_UTEST_OBJ)
  37. $(CXX) -o $@ $^ $(LDFLAGS)
  38. $(COMMON_UTEST_OBJ): %.o: %.cc
  39. $(CXX) -o $@ $(CXXFLAGS) $(GTEST_DEFINES) -I$(COMMON_INCLUDE_DIR) -I$(GTEST_INCLUDE_DIR) -c $^
  40. build: all
  41. all: $(COMMON_LIB)
  42. install:
  43. mkdir -p '$(LIB_INSTALL_DIR)'
  44. mkdir -p '$(HEADERS_INSTALL_DIR)'
  45. mkdir -p '$(HEADERS_11_INSTALL_DIR)'
  46. cp $(COMMON_LIB) '$(LIB_INSTALL_DIR)'
  47. cp $(API_HEADERS_INSTALL) '$(HEADERS_INSTALL_DIR)'
  48. cp $(API_11_HEADERS_INSTALL) '$(HEADERS_11_INSTALL_DIR)'
  49. #install tests if they exist
  50. ifneq (,$(wildcard $(COMMON_UTEST_EXE)))
  51. mkdir -p '$(TEST_INSTALL_DIR)'
  52. cp $(COMMON_UTEST_EXE) '$(TEST_INSTALL_DIR)'
  53. endif
  54. utest: $(COMMON_UTEST_EXE)
  55. run_utest:
  56. $(COMMON_UTEST_EXE) $(GTEST_FLAGS)
  57. check: utest run_utest
  58. clean:
  59. rm -f $(COMMON_OBJ) \
  60. $(COMMON_LIB) \
  61. $(COMMON_UTEST_OBJ) \
  62. $(COMMON_UTEST_EXE) \
  63. *.xml