Makefile 3.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184
  1. #!/usr/bin/make -f
  2. #variables are set by configure
  3. prefix = /usr/local
  4. installdir = $(prefix)/
  5. epidinstalldir = $(installdir)/epid-sdk
  6. CC = gcc
  7. CXX = g++
  8. CFLAGS =
  9. LDFLAGS =
  10. RANLIB = ranlib
  11. TSS_PATH =
  12. TINY =
  13. #set performance affecting flags
  14. SIZE_CFLAGS := -O2
  15. #gcc flags
  16. CC_FLAGS := $(CFLAGS) $(SIZE_CFLAGS) -Werror -Wall -Wextra -Wno-missing-braces \
  17. -Wno-missing-field-initializers -Wno-unknown-pragmas -Wno-unused-function \
  18. -fno-strict-aliasing -Wno-unused-but-set-variable -Wno-comment -Wformat \
  19. -Wformat-security -fstack-protector -DNDEBUG -D_FORTIFY_SOURCE=2
  20. #intel c compiler flags
  21. ICC_FLAGS := $(CFLAGS) $(SIZE_CFLAGS) -Werror -Wall -Wextra -DNDEBUG \
  22. -fstack-protector -D_FORTIFY_SOURCE=2 \
  23. -Wformat -Wformat-security
  24. ifneq ($(OS),Windows_NT)
  25. CC_FLAGS += -fPIC
  26. ICC_FLAGS += -fPIC
  27. CXX11_FLAG = -std=c++0x
  28. EXE_EXTENSION =
  29. else
  30. CC_FLAGS += -D__int64='long long'
  31. CXX11_FLAG = -std=gnu++11
  32. EXE_EXTENSION = .exe
  33. endif
  34. #g++ flags
  35. CXX_FLAGS := $(CC_FLAGS) $(CXX11_FLAG)
  36. #intel c++ compiler flags
  37. ICPC_FLAGS := $(ICC_FLAGS) $(CXX11_FLAG)
  38. #check if architecture was specified
  39. #or take it by shell command
  40. ifeq ($(findstring -m32,$(CFLAGS)),-m32)
  41. ARCH = x86
  42. CXXFLAGS += -m32
  43. LDFLAGS += -m32
  44. else ifeq ($(findstring -m64,$(CFLAGS)),-m64)
  45. ARCH = x86_64
  46. CXXFLAGS += -m64
  47. LDFLAGS += -m64
  48. else
  49. ifeq ($(findstring arm-,$(CC)),arm-)
  50. ARCH = arm
  51. ifneq (,$(findstring gnueabihf,$(CC)))
  52. ARCH := $(addsuffix hf,$(ARCH))
  53. endif
  54. else
  55. ARCH := $(shell uname -m)
  56. endif
  57. endif
  58. #set tools and flags depending on specified compiler
  59. ifeq ($(findstring icc,$(CC)),icc)
  60. CFLAGS := $(ICC_FLAGS)
  61. CXXFLAGS := $(ICPC_FLAGS)
  62. AR = $(subst icc,xiar,$(CC))
  63. else
  64. CFLAGS := $(CC_FLAGS)
  65. CXXFLAGS := $(CXX_FLAGS)
  66. endif
  67. # ld flags
  68. LDFLAGS += -fstack-protector
  69. ifneq ($(OS),Windows_NT)
  70. LDFLAGS += -z noexecstack -z relro -z now -pie
  71. endif
  72. #gtest defines
  73. GTEST_DEFINES := -DGTEST_HAS_PTHREAD=0 -D_VARIADIC_MAX=10
  74. #set flags for unit tests executables
  75. GTEST_FLAGS = --gtest_color=yes \
  76. --gtest_print_time=1 \
  77. --gtest_output=xml
  78. export CC LDFLAGS ARCH CFLAGS
  79. export CXX CXXFLAGS
  80. export AR RANLIB
  81. export epidinstalldir
  82. export GTEST_FLAGS GTEST_DEFINES
  83. export EXE_EXTENSION
  84. export TSS_PATH
  85. export TINY
  86. #output of the main parameters
  87. $(info $$ccompiler is [${CC}])
  88. $(info $$cxxcompiler is [${CXX}])
  89. $(info $$architecture is [${ARCH}])
  90. #targets part
  91. all:
  92. $(MAKE) common member verifier argtable3
  93. clean:
  94. $(MAKE) -C ./epid/common/ clean
  95. $(MAKE) -C ./epid/member/ clean
  96. $(MAKE) -C ./epid/verifier/ clean
  97. $(MAKE) -C ./ext/gtest/ clean
  98. $(MAKE) -C ./epid/common-testhelper/ clean
  99. $(MAKE) -C ./ext/argtable3/ clean
  100. ifneq ("$(wildcard ./ext/google_benchmark)","")
  101. $(MAKE) -C ./ext/google_benchmark/ clean
  102. endif
  103. install:
  104. $(MAKE) -C ./epid/common/ install
  105. $(MAKE) -C ./epid/member/ install
  106. $(MAKE) -C ./epid/verifier/ install
  107. $(MAKE) -C ./epid/common-testhelper/ install
  108. uninstall:
  109. rm -rf $(epidinstalldir)
  110. common-testhelper:
  111. $(MAKE) -C ./epid/common-testhelper/ all
  112. common-testhelper_utest:
  113. $(MAKE) -C ./epid/common-testhelper/ utest
  114. common:
  115. $(MAKE) -C ./epid/common/ all
  116. common_utest:
  117. $(MAKE) -C ./epid/common/ utest
  118. member:
  119. $(MAKE) -C ./epid/member/ all
  120. member_utest:
  121. $(MAKE) -C ./epid/member/ utest
  122. verifier:
  123. $(MAKE) -C ./epid/verifier/ all
  124. verifier_utest:
  125. $(MAKE) -C ./epid/verifier/ utest
  126. gtest:
  127. $(MAKE) -C ./ext/gtest/ all
  128. argtable3:
  129. $(MAKE) -C ./ext/argtable3/ all
  130. utest:
  131. $(MAKE) gtest common-testhelper
  132. $(MAKE) common-testhelper_utest common_utest member_utest verifier_utest
  133. run_utest:
  134. $(MAKE) -C ./epid/common-testhelper/ run_utest
  135. $(MAKE) -C ./epid/common/ run_utest
  136. $(MAKE) -C ./epid/member/ run_utest
  137. $(MAKE) -C ./epid/verifier/ run_utest
  138. check:
  139. $(MAKE) utest
  140. $(MAKE) run_utest
  141. perf:
  142. ifneq ("$(wildcard ./ext/google_benchmark/)","")
  143. $(MAKE) -C ./ext/google_benchmark/ all
  144. $(MAKE) -C ./ext/google_benchmark/ utest
  145. $(MAKE) -C ./ext/google_benchmark/ run_utest
  146. endif
  147. build:
  148. $(MAKE) all
  149. $(MAKE) check
  150. $(MAKE) install