Makefile 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325
  1. #
  2. # Copyright (C) 2011-2016 Intel Corporation. All rights reserved.
  3. #
  4. # Redistribution and use in source and binary forms, with or without
  5. # modification, are permitted provided that the following conditions
  6. # are met:
  7. #
  8. # * Redistributions of source code must retain the above copyright
  9. # notice, this list of conditions and the following disclaimer.
  10. # * Redistributions in binary form must reproduce the above copyright
  11. # notice, this list of conditions and the following disclaimer in
  12. # the documentation and/or other materials provided with the
  13. # distribution.
  14. # * Neither the name of Intel Corporation nor the names of its
  15. # contributors may be used to endorse or promote products derived
  16. # from this software without specific prior written permission.
  17. #
  18. # THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
  19. # "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
  20. # LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
  21. # A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
  22. # OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
  23. # SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
  24. # LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
  25. # DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
  26. # THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
  27. # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  28. # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  29. #
  30. #
  31. TOP_DIR = ../../..
  32. include $(TOP_DIR)/buildenv.mk
  33. IPC_COMMON_DIR := ../common/
  34. IPC_COMMON_SRC_DIR := $(IPC_COMMON_DIR)/src
  35. IPC_COMMON_INC_DIR := $(IPC_COMMON_DIR)/inc
  36. IPC_COMMON_PROTO_DIR := source/protobuf
  37. AESM_WRAPPER_DIR := $(LINUX_PSW_DIR)/ae/aesm_service/source/aesm_wrapper
  38. AESM_SRC_DIR := $(AESM_WRAPPER_DIR)/src
  39. AESM_INC_DIR := $(AESM_WRAPPER_DIR)/inc
  40. AESM_APPLICATION := $(LINUX_PSW_DIR)/ae/aesm_service/source/aesm/application
  41. AESM_EXTENSION := $(LINUX_PSW_DIR)/ae/aesm_service/source/aesm/extension
  42. INCLUDE += -I$(COMMON_DIR)/inc \
  43. -I$(COMMON_DIR)/inc/internal \
  44. -I./include \
  45. -I./include/oal \
  46. -I./source/ \
  47. -I./source/aesm_wrapper/inc
  48. INCLUDE += -I$(LINUX_SDK_DIR)/tseal
  49. INCLUDE += -I$(LINUX_PSW_DIR)/ae/aesm_service/source/aesm/application/
  50. INCLUDE += -I$(LINUX_PSW_DIR)/ae/aesm_service/source/aesm/extension/
  51. INCLUDE += -I$(LINUX_PSW_DIR)/ae/aesm_service/source/epid_provision/
  52. INCLUDE += -I$(LINUX_PSW_DIR)/ae/aesm_service/source/le/
  53. INCLUDE += -I$(LINUX_PSW_DIR)/ae/aesm_service/source/network/
  54. INCLUDE += -I$(LINUX_PSW_DIR)/ae/aesm_service/source/oal/
  55. INCLUDE += -I$(LINUX_PSW_DIR)/ae/aesm_service/source/protobuf/
  56. INCLUDE += -I$(LINUX_PSW_DIR)/ae/aesm_service/source/pve/
  57. INCLUDE += -I$(LINUX_PSW_DIR)/ae/aesm_service/source/qe/
  58. INCLUDE += -I$(LINUX_PSW_DIR)/ae/aesm_service/source/storage/
  59. INCLUDE += -I$(LINUX_PSW_DIR)/ae/data/constants/linux
  60. INCLUDE += -I$(LINUX_PSW_DIR)/ae/inc \
  61. -I$(LINUX_PSW_DIR)/ae/inc/internal \
  62. -I$(LINUX_PSW_DIR)/ae/common
  63. INCLUDE += -I$(LINUX_PSW_DIR)/ae/aesm_service/source/epid_provision
  64. INCLUDE += -I$(LINUX_EXTERNAL_DIR)/epid/inc
  65. INCLUDE += -I$(LINUX_EXTERNAL_DIR)/crypto_px/include/ \
  66. -I$(LINUX_EXTERNAL_DIR)/tinyxml/ \
  67. -I$(LINUX_EXTERNAL_DIR)/ \
  68. -I$(LINUX_EXTERNAL_DIR)/rdrand \
  69. -I$(IPC_COMMON_INC_DIR) \
  70. -I$(AESM_INC_DIR) \
  71. -I$(IPC_COMMON_PROTO_DIR)
  72. EDGER8R := $(LINUX_SDK_DIR)/edger8r/linux/_build/Edger8r.native
  73. PROTPBUF_CXXFLAGS := -fstack-protector -fPIC -Wall -Werror
  74. ifdef DEBUG
  75. PROTPBUF_CXXFLAGS += -ggdb -DDEBUG -UNDEBUG
  76. else
  77. PROTPBUF_CXXFLAGS += -O2 -UDEBUG -DNDEBUG
  78. endif
  79. ifeq ($(ARCH), x86)
  80. PROTPBUF_CXXFLAGS += -m32
  81. else
  82. PROTPBUF_CXXFLAGS += -m64
  83. endif
  84. ifdef PROFILE
  85. CXXFLAGS += -D_PROFILE_
  86. CFLAGS += -D_PROFILE_
  87. endif
  88. CXXFLAGS += -fPIC
  89. CFLAGS := $(filter-out -fPIC -Werror, $(CFLAGS))
  90. LINUX_SE_WRAPPER = $(COMMON_DIR)/se_wrapper
  91. ifdef DEBUG
  92. CXXFLAGS += -DDBG_LOG
  93. CFLAGS += -DDBG_LOG
  94. endif
  95. URTSLIB := -lurts_internal
  96. TRTSLIB := -lsgx_trts
  97. WHITE_LIST_FILE := $(LINUX_PSW_DIR)/ae/data/prebuilt/white_list_cert_to_be_verify.bin
  98. TCRYPTO_LIBDIR := $(LINUX_SDK_DIR)/tlibcrypto
  99. PROTOBUF_LIBDIR := $(LINUX_PROTOBUF)/intel64
  100. VTUNE_LIBDIR := $(LINUX_EXTERNAL_DIR)/vtune/linux/sdk/src/ittnotify
  101. RDRAND_LIBDIR :=$(LINUX_EXTERNAL_DIR)/rdrand/src
  102. RDRAND_MAKEFILE := $(RDRAND_LIBDIR)/Makefile
  103. ifeq ($(ARCH), x86)
  104. PROTOBUF_LIBDIR = $(LINUX_PROTOBUF)/ia32
  105. endif
  106. EXTERNAL_LIB += -L$(TCRYPTO_LIBDIR) -lsgx_tcrypto
  107. EXTERNAL_LIB += -lprotobuf -lrt
  108. EXTERNAL_LIB += -lcrypto
  109. EXTERNAL_LIB += $(shell curl-config --libs)
  110. EXTERNAL_LIB += -L$(LINUX_SE_WRAPPER) -lwrapper -lrt
  111. EXTERNAL_LIB += -L$(RDRAND_LIBDIR) -lrdrand
  112. EXTERNAL_LIB += -L$(VTUNE_LIBDIR) -littnotify
  113. vpath %.cpp $(COMMON_DIR)/src $(LINUX_EXTERNAL_DIR)/tinyxml ./source/epid_provision $(LINUX_PSW_DIR)/ae/common $(AESM_APPLICATION) $(AESM_EXTENSION) $(AESM_SRC_DIR) $(IPC_COMMON_PROTO_DIR) $(COMMON_DIR)/src $(TOP_DIR)/sdk/tseal
  114. vpath %.cc $(IPC_COMMON_PROTO_DIR)
  115. vpath %.c $(TOP_DIR)/sdk/tlibc/string
  116. COMMON_SRC := tinyxmlparser.cpp \
  117. tinyxmlerror.cpp \
  118. tinyxml.cpp \
  119. tinystr.cpp \
  120. ./source/le/LEClass.cpp \
  121. ./source/oal/aesm_util.cpp \
  122. ./source/storage/persistent_storage_table.cpp \
  123. aesm_logic.cpp \
  124. ./source/oal/oal_power.cpp \
  125. aesm_rand.cpp \
  126. ipp_bn.cpp \
  127. ipp_rsa_pub_key.cpp \
  128. ./source/oal/error_report.cpp \
  129. ./source/oal/internal_log.cpp \
  130. sgx_memset_s.cpp \
  131. sgx_read_rand.cpp \
  132. sgx_profile.cpp \
  133. tSeal_util.cpp \
  134. ./source/oal/aesm_thread.cpp \
  135. event_strings.cpp
  136. COMMON_SRC += ./source/qe/QEClass.cpp \
  137. ./source/pve/PVEClass.cpp \
  138. aesm_encode.cpp \
  139. aesm_epid_blob.cpp \
  140. epid_provision_msg1.cpp \
  141. epid_provision_msg2.cpp \
  142. epid_provision_msg4.cpp \
  143. epid_endpoint_selection.cpp \
  144. epid_utility.cpp \
  145. type_length_value.cpp \
  146. ./source/qe/qe_logic.cpp \
  147. ./source/pve/pve_logic.cpp \
  148. platform_info_logic.cpp \
  149. pve_pub_key.cpp \
  150. pek_pub_key.cpp \
  151. ./source/network/network_encoding_wrapper.cpp \
  152. endpoint_select_info.cpp \
  153. aesm_ecdsa.cpp \
  154. se_sig_rl.cpp \
  155. aesm_long_lived_thread.cpp
  156. COMMON_OBJ := $(COMMON_SRC:.cpp=.o)
  157. IPC_SRC := $(IPC_COMMON_SRC_DIR)/AECloseSessionRequest.cpp \
  158. $(IPC_COMMON_SRC_DIR)/AEGetQuoteResponse.cpp \
  159. $(IPC_COMMON_SRC_DIR)/AECloseSessionResponse.cpp \
  160. $(IPC_COMMON_SRC_DIR)/AEInitQuoteRequest.cpp \
  161. $(IPC_COMMON_SRC_DIR)/AECreateSessionRequest.cpp \
  162. $(IPC_COMMON_SRC_DIR)/AEInitQuoteResponse.cpp \
  163. $(IPC_COMMON_SRC_DIR)/AECreateSessionResponse.cpp \
  164. $(IPC_COMMON_SRC_DIR)/AEInvokeServiceRequest.cpp \
  165. $(IPC_COMMON_SRC_DIR)/AEExchangeReportRequest.cpp \
  166. $(IPC_COMMON_SRC_DIR)/AEInvokeServiceResponse.cpp \
  167. $(IPC_COMMON_SRC_DIR)/AEExchangeReportResponse.cpp \
  168. $(IPC_COMMON_SRC_DIR)/ProtobufSerializer.cpp \
  169. $(IPC_COMMON_SRC_DIR)/AEGetLaunchTokenRequest.cpp \
  170. $(IPC_COMMON_SRC_DIR)/AEGetPsCapRequest.cpp \
  171. $(IPC_COMMON_SRC_DIR)/AEGetPsCapResponse.cpp \
  172. $(IPC_COMMON_SRC_DIR)/AEReportAttestationRequest.cpp \
  173. $(IPC_COMMON_SRC_DIR)/AEReportAttestationResponse.cpp \
  174. $(IPC_COMMON_SRC_DIR)/SocketTransporter.cpp \
  175. $(IPC_COMMON_SRC_DIR)/AEGetLaunchTokenResponse.cpp \
  176. $(IPC_COMMON_SRC_DIR)/UnixCommunicationSocket.cpp \
  177. $(IPC_COMMON_SRC_DIR)/NonBlockingUnixCommunicationSocket.cpp \
  178. $(IPC_COMMON_SRC_DIR)/AEGetQuoteRequest.cpp \
  179. $(IPC_COMMON_SRC_DIR)/UnixSocketFactory.cpp \
  180. $(IPC_COMMON_SRC_DIR)/NonBlockingUnixSocketFactory.cpp
  181. PROTOBUF_SRC := messages.pb.cc
  182. AESM_SRC := AESMLogicWrapper.cpp \
  183. CAESMServer.cpp \
  184. main.cpp \
  185. Thread.cpp \
  186. AESMWorkerThread.cpp \
  187. AESMQueueManager.cpp \
  188. CSelector.cpp \
  189. UnixServerSocket.cpp \
  190. ./source/oal/aesm_util.cpp \
  191. aesm_config.cpp
  192. AESM_SRC += aesm_http_msg.cpp
  193. CSRC := $(wildcard *.c)
  194. MEMCMPSRC := consttime_memequal.c
  195. OBJ := $(IPC_SRC:.cpp=.o) \
  196. $(CSRC:.c=.o) \
  197. $(MEMCMPSRC:.c=.o) \
  198. $(AESM_SRC:.cpp=.o) \
  199. $(PROTOBUF_SRC:.cc=.o)
  200. LDUFLAGS := -pthread -L$(BUILD_DIR) $(URTSLIB)
  201. APPNAME := aesm_service
  202. LIBNAME := libaesm_service_common.a
  203. .PHONY: all
  204. all: $(APPNAME) copy_data_file | $(BUILD_DIR)
  205. @$(CP) $< $|
  206. copy_data_file:
  207. @$(MKDIR) -p data
  208. @$(CP) $(WHITE_LIST_FILE) data/white_list_cert_to_be_verify.bin
  209. sgx_tcrypto:
  210. $(MAKE) -C $(TCRYPTO_LIBDIR)
  211. $(LIBNAME): $(COMMON_OBJ)
  212. $(AR) rcs $@ $^
  213. %.o :%.cpp
  214. $(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -o $@
  215. %.o :%.cc
  216. $(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -o $@
  217. consttime_memequal.o :consttime_memequal.c
  218. $(CC) $(filter-out -O2,$(CFLAGS)) -fPIC -O1 $(INCLUDE) -c $< -o $@
  219. $(APPNAME): $(OBJ) $(LIBNAME) sgx_tcrypto -lrdrand
  220. $(CXX) $(CXXFLAGS) $(OBJ) $(LIBNAME) $(LDUFLAGS) $(EXTERNAL_LIB) -o $@ -ldl
  221. $(IPC_SRC): PROTPBUF
  222. ./source/le/LEClass.o: ${AESM_EXTENSION}/launch_enclave_u.c
  223. ./source/pve/PVEClass.o: ${AESM_EXTENSION}/provision_enclave_u.c
  224. ./source/qe/QEClass.o: ${AESM_EXTENSION}/quoting_enclave_u.c
  225. uecall_bridge.o: ${AESM_EXTENSION}/pse_pr_u.c
  226. -lrdrand: $(RDRAND_MAKEFILE)
  227. $(MAKE) -C $(RDRAND_LIBDIR)
  228. $(RDRAND_MAKEFILE):
  229. ifeq ($(ARCH), x86)
  230. @cd $(RDRAND_LIBDIR);./configure
  231. else
  232. @cd $(RDRAND_LIBDIR);./configure CFLAGS=-fPIC
  233. endif
  234. ${AESM_EXTENSION}/launch_enclave_u.c: ${LINUX_PSW_DIR}/ae/le/launch_enclave.edl
  235. @$(EDGER8R) --untrusted --untrusted-dir ${AESM_EXTENSION} $<
  236. ${AESM_EXTENSION}/provision_enclave_u.c: ${LINUX_PSW_DIR}/ae/pve/provision_enclave.edl
  237. @$(EDGER8R) --untrusted --untrusted-dir ${AESM_EXTENSION} $<
  238. ${AESM_EXTENSION}/quoting_enclave_u.c: ${LINUX_PSW_DIR}/ae/qe/quoting_enclave.edl
  239. @$(EDGER8R) --untrusted --untrusted-dir ${AESM_EXTENSION} $<
  240. ${AESM_EXTENSION}/pse_pr_u.c: ${LINUX_PSW_DIR}/ae/pse/pse_pr/pse_pr.edl
  241. @$(EDGER8R) --untrusted --untrusted-dir ${AESM_EXTENSION} $<
  242. .PHONY: PROTPBUF
  243. PROTPBUF:
  244. $(MAKE) -C $(IPC_COMMON_PROTO_DIR)
  245. (test -f messages.pb.o) || ($(CXX) $(PROTPBUF_CXXFLAGS) -c $(IPC_COMMON_PROTO_DIR)/messages.pb.cc -o messages.pb.o)
  246. .PHONY: urts
  247. urts:
  248. $(MAKE) -C $(LINUX_PSW_DIR)/urts/linux
  249. $(BUILD_DIR):
  250. @$(MKDIR) $@
  251. .PHONY: clean
  252. clean:
  253. @$(RM) *.o $(IPC_COMMON_SRC_DIR)/*.o
  254. @$(RM) -r data
  255. @$(RM) $(APPNAME)
  256. @$(RM) $(LIBNAME)
  257. $(MAKE) -C $(IPC_COMMON_PROTO_DIR) clean
  258. @$(RM) source/le/*.o
  259. @$(RM) source/pve/*.o
  260. @$(RM) source/pve/*.o
  261. @$(RM) source/network/*.o
  262. @$(RM) source/oal/*.o
  263. @$(RM) source/qe/*.o
  264. @$(RM) source/qe/*.o
  265. @$(RM) source/storage/*.o
  266. @$(RM) $(AESM_EXTENSION)/*_u.c $(AESM_EXTENSION)/*_u.h
  267. ifeq ($(RDRAND_MAKEFILE), $(wildcard $(RDRAND_MAKEFILE)))
  268. @$(MAKE) distclean -C $(RDRAND_LIBDIR)
  269. endif
  270. .PHONY: rebuild
  271. rebuild: clean all