Makefile 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343
  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/pce/
  59. INCLUDE += -I$(LINUX_PSW_DIR)/ae/aesm_service/source/storage/
  60. INCLUDE += -I$(LINUX_PSW_DIR)/ae/data/constants/linux
  61. INCLUDE += -I$(LINUX_PSW_DIR)/ae/pve
  62. INCLUDE += -I$(LINUX_PSW_DIR)/ae/inc \
  63. -I$(LINUX_PSW_DIR)/ae/inc/internal \
  64. -I$(LINUX_PSW_DIR)/ae/common
  65. INCLUDE += -I$(LINUX_PSW_DIR)/ae/aesm_service/source/epid_provision
  66. INCLUDE += -I$(LINUX_EXTERNAL_DIR)/epid
  67. INCLUDE += -I$(SGX_IPP_INC) \
  68. -I$(LINUX_EXTERNAL_DIR)/ \
  69. -I$(LINUX_EXTERNAL_DIR)/rdrand \
  70. -I$(IPC_COMMON_INC_DIR) \
  71. -I$(AESM_INC_DIR) \
  72. -I$(IPC_COMMON_PROTO_DIR)
  73. EDGER8R := $(LINUX_SDK_DIR)/edger8r/linux/_build/Edger8r.native
  74. ifdef PROFILE
  75. CXXFLAGS += -D_PROFILE_
  76. CFLAGS += -D_PROFILE_
  77. endif
  78. CXXFLAGS += -fPIC
  79. CFLAGS := $(filter-out -fPIC -Werror, $(CFLAGS))
  80. LINUX_SE_WRAPPER = $(COMMON_DIR)/se_wrapper
  81. ifdef DEBUG
  82. CXXFLAGS += -DDBG_LOG
  83. CFLAGS += -DDBG_LOG
  84. endif
  85. URTSLIB := -lurts_internal
  86. TRTSLIB := -lsgx_trts
  87. WHITE_LIST_FILE := $(LINUX_PSW_DIR)/ae/data/prebuilt/white_list_cert_to_be_verify.bin
  88. TCRYPTO_LIBDIR := $(LINUX_SDK_DIR)/tlibcrypto
  89. VTUNE_LIBDIR := $(LINUX_EXTERNAL_DIR)/vtune/linux/sdk/src/ittnotify
  90. RDRAND_LIBDIR :=$(LINUX_EXTERNAL_DIR)/rdrand/src
  91. RDRAND_MAKEFILE := $(RDRAND_LIBDIR)/Makefile
  92. ifeq ($(ARCH), x86)
  93. VTUNE_LIBDIR = $(LINUX_EXTERNAL_DIR)/vtune/linux/lib32
  94. endif
  95. EXTERNAL_LIB += -L$(TCRYPTO_LIBDIR) -lsgx_tcrypto
  96. EXTERNAL_LIB += -lprotobuf -lrt
  97. EXTERNAL_LIB += -lcrypto
  98. EXTERNAL_LIB += $(shell curl-config --libs)
  99. EXTERNAL_LIB += -L$(LINUX_SE_WRAPPER) -lwrapper -lrt
  100. EXTERNAL_LIB += -L$(RDRAND_LIBDIR) -lrdrand
  101. EXTERNAL_LIB += -L$(VTUNE_LIBDIR) -littnotify
  102. vpath %.cpp $(COMMON_DIR)/src ./source/epid_provision $(LINUX_PSW_DIR)/ae/common $(AESM_APPLICATION) $(AESM_EXTENSION) $(AESM_SRC_DIR) $(IPC_COMMON_PROTO_DIR) $(TOP_DIR)/sdk/tseal $(IPC_COMMON_SRC_DIR)
  103. vpath %.cc $(IPC_COMMON_PROTO_DIR)
  104. vpath %.c $(TOP_DIR)/sdk/tlibc/string
  105. COMMON_SRC := ./source/le/LEClass.cpp \
  106. ./source/oal/aesm_util.cpp \
  107. ./source/storage/persistent_storage_table.cpp \
  108. aesm_logic.cpp \
  109. ./source/oal/oal_power.cpp \
  110. aesm_rand.cpp \
  111. ipp_bn.cpp \
  112. ipp_rsa_pub_key.cpp \
  113. ./source/oal/error_report.cpp \
  114. ./source/oal/internal_log.cpp \
  115. sgx_memset_s.cpp \
  116. sgx_read_rand.cpp \
  117. sgx_profile.cpp \
  118. tSeal_util.cpp \
  119. ./source/oal/aesm_thread.cpp \
  120. event_strings.cpp
  121. COMMON_SRC += ./source/qe/QEClass.cpp \
  122. ./source/pve/PVEClass.cpp \
  123. ./source/pce/PCEClass.cpp \
  124. aesm_encode.cpp \
  125. aesm_epid_blob.cpp \
  126. aesm_xegd_blob.cpp \
  127. epid_provision_msg1.cpp \
  128. epid_provision_msg2.cpp \
  129. epid_provision_msg4.cpp \
  130. epid_endpoint_selection.cpp \
  131. epid_utility.cpp \
  132. type_length_value.cpp \
  133. ./source/qe/qe_logic.cpp \
  134. ./source/pve/pve_logic.cpp \
  135. platform_info_logic.cpp \
  136. platform_info_facility.cpp \
  137. pve_pub_key.cpp \
  138. pek_pub_key.cpp \
  139. ./source/network/network_encoding_wrapper.cpp \
  140. endpoint_select_info.cpp \
  141. aesm_ecdsa.cpp \
  142. se_sig_rl.cpp \
  143. aesm_long_lived_thread.cpp
  144. COMMON_OBJ := $(COMMON_SRC:.cpp=.o)
  145. IPC_SRC := AECloseSessionRequest.cpp \
  146. AEGetQuoteResponse.cpp \
  147. AECloseSessionResponse.cpp \
  148. AEInitQuoteRequest.cpp \
  149. AECreateSessionRequest.cpp \
  150. AEInitQuoteResponse.cpp \
  151. AECreateSessionResponse.cpp \
  152. AEInvokeServiceRequest.cpp \
  153. AEExchangeReportRequest.cpp \
  154. AEInvokeServiceResponse.cpp \
  155. AEExchangeReportResponse.cpp \
  156. ProtobufSerializer.cpp \
  157. AEGetLaunchTokenRequest.cpp \
  158. AEGetPsCapRequest.cpp \
  159. AEGetPsCapResponse.cpp \
  160. AEGetWhiteListSizeRequest.cpp \
  161. AEGetWhiteListSizeResponse.cpp \
  162. AEGetWhiteListRequest.cpp \
  163. AEGetWhiteListResponse.cpp \
  164. AESGXGetExtendedEpidGroupIdRequest.cpp \
  165. AESGXGetExtendedEpidGroupIdResponse.cpp \
  166. AESGXSwitchExtendedEpidGroupRequest.cpp \
  167. AESGXSwitchExtendedEpidGroupResponse.cpp \
  168. AEReportAttestationRequest.cpp \
  169. AEReportAttestationResponse.cpp \
  170. SocketTransporter.cpp \
  171. AEGetLaunchTokenResponse.cpp \
  172. UnixCommunicationSocket.cpp \
  173. NonBlockingUnixCommunicationSocket.cpp \
  174. AEGetQuoteRequest.cpp \
  175. UnixSocketFactory.cpp \
  176. NonBlockingUnixSocketFactory.cpp
  177. PROTOBUF_SRC := messages.pb.cc
  178. AESM_SRC := AESMLogicWrapper.cpp \
  179. CAESMServer.cpp \
  180. main.cpp \
  181. Thread.cpp \
  182. AESMWorkerThread.cpp \
  183. AESMQueueManager.cpp \
  184. CSelector.cpp \
  185. UnixServerSocket.cpp \
  186. ./source/oal/aesm_util.cpp \
  187. aesm_config.cpp
  188. AESM_SRC += aesm_http_msg.cpp
  189. CSRC := $(wildcard *.c)
  190. MEMCMPSRC := consttime_memequal.c
  191. OBJ := $(IPC_SRC:.cpp=.o) \
  192. $(CSRC:.c=.o) \
  193. $(MEMCMPSRC:.c=.o) \
  194. $(AESM_SRC:.cpp=.o) \
  195. $(PROTOBUF_SRC:.cc=.o)
  196. LDUFLAGS := -pthread -L$(BUILD_DIR) $(URTSLIB)
  197. APPNAME := aesm_service
  198. APPNAME_DEBUG := aesm_service.debug
  199. LIBNAME := libaesm_service_common.a
  200. .PHONY: all
  201. all: $(APPNAME) $(APPNAME_DEBUG) copy_data_file | $(BUILD_DIR)
  202. @$(CP) $(APPNAME) $|
  203. ifndef DEBUG
  204. @$(CP) $(APPNAME_DEBUG) $|
  205. endif
  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. ProtobufSerializer.o : $(IPC_COMMON_PROTO_DIR)/messages.pb.cc
  214. CAESMServer.o : $(IPC_COMMON_PROTO_DIR)/messages.pb.cc
  215. %.o :%.cpp
  216. $(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -o $@
  217. messages.pb.o : $(IPC_COMMON_PROTO_DIR)/messages.pb.cc
  218. $(CXX) $(filter-out -Wshadow, $(CXXFLAGS)) $(INCLUDE) -c $< -o $@
  219. consttime_memequal.o :consttime_memequal.c
  220. $(CC) $(filter-out -O2,$(CFLAGS)) -fPIC -O1 $(INCLUDE) -c $< -o $@
  221. $(APPNAME): $(OBJ) $(LIBNAME) sgx_tcrypto -lrdrand urts
  222. $(CXX) $(CXXFLAGS) $(OBJ) $(LIBNAME) $(LDUFLAGS) $(EXTERNAL_LIB) -o $@ -ldl
  223. $(APPNAME_DEBUG): $(APPNAME)
  224. ((test -f $(APPNAME_DEBUG)) || $(MAKE) separate_debug_info)
  225. .PHONY: separate_debug_info
  226. separate_debug_info:
  227. ifndef DEBUG
  228. $(CP) $(APPNAME) $(APPNAME).orig
  229. $(OBJCOPY) --only-keep-debug $(APPNAME) $(APPNAME_DEBUG)
  230. $(STRIP) -g $(APPNAME)
  231. $(OBJCOPY) --add-gnu-debuglink=$(APPNAME_DEBUG) $(APPNAME)
  232. endif
  233. ./source/le/LEClass.o: ${AESM_EXTENSION}/launch_enclave_u.c
  234. ./source/pve/PVEClass.o: ${AESM_EXTENSION}/provision_enclave_u.c
  235. ./source/qe/QEClass.o: ${AESM_EXTENSION}/quoting_enclave_u.c
  236. ./source/pce/PCEClass.o: ${AESM_EXTENSION}/pce_u.c
  237. uecall_bridge.o: ${AESM_EXTENSION}/pse_pr_u.c
  238. -lrdrand: $(RDRAND_MAKEFILE)
  239. $(MAKE) -C $(RDRAND_LIBDIR)
  240. $(RDRAND_MAKEFILE):
  241. ifeq ($(ARCH), x86)
  242. @cd $(RDRAND_LIBDIR);./configure
  243. else
  244. @cd $(RDRAND_LIBDIR);./configure CFLAGS=-fPIC
  245. endif
  246. ${AESM_EXTENSION}/launch_enclave_u.c: ${LINUX_PSW_DIR}/ae/le/launch_enclave.edl
  247. @$(EDGER8R) --untrusted --untrusted-dir ${AESM_EXTENSION} $<
  248. ${AESM_EXTENSION}/provision_enclave_u.c: ${LINUX_PSW_DIR}/ae/pve/provision_enclave.edl
  249. @$(EDGER8R) --untrusted --untrusted-dir ${AESM_EXTENSION} $<
  250. ${AESM_EXTENSION}/quoting_enclave_u.c: ${LINUX_PSW_DIR}/ae/qe/quoting_enclave.edl
  251. @$(EDGER8R) --untrusted --untrusted-dir ${AESM_EXTENSION} $<
  252. ${AESM_EXTENSION}/pse_pr_u.c: ${LINUX_PSW_DIR}/ae/pse/pse_pr/pse_pr.edl
  253. @$(EDGER8R) --untrusted --untrusted-dir ${AESM_EXTENSION} $<
  254. ${AESM_EXTENSION}/pce_u.c: ${LINUX_PSW_DIR}/ae/pce/pce.edl
  255. @$(EDGER8R) --untrusted --untrusted-dir ${AESM_EXTENSION} $<
  256. $(IPC_COMMON_PROTO_DIR)/messages.pb.cc:
  257. $(MAKE) -C $(IPC_COMMON_PROTO_DIR)
  258. .PHONY: urts
  259. urts:
  260. $(MAKE) -C $(LINUX_PSW_DIR)/urts/linux
  261. $(BUILD_DIR):
  262. @$(MKDIR) $@
  263. .PHONY: clean
  264. clean:
  265. @$(RM) *.o $(IPC_COMMON_SRC_DIR)/*.o
  266. @$(RM) -r data
  267. @$(RM) $(APPNAME) $(APPNAME).orig $(APPNAME_DEBUG)
  268. @$(RM) $(BUILD_DIR)/$(APPNAME) $(BUILD_DIR)/$(APPNAME_DEBUG)
  269. @$(RM) $(LIBNAME)
  270. $(MAKE) -C $(IPC_COMMON_PROTO_DIR) clean
  271. @$(RM) source/le/*.o
  272. @$(RM) source/pve/*.o
  273. @$(RM) source/pce/*.o
  274. @$(RM) source/network/*.o
  275. @$(RM) source/oal/*.o
  276. @$(RM) source/qe/*.o
  277. @$(RM) source/storage/*.o
  278. @$(RM) $(AESM_EXTENSION)/*_u.c $(AESM_EXTENSION)/*_u.h
  279. ifeq ($(RDRAND_MAKEFILE), $(wildcard $(RDRAND_MAKEFILE)))
  280. @$(MAKE) distclean -C $(RDRAND_LIBDIR)
  281. endif
  282. .PHONY: rebuild
  283. rebuild:
  284. $(MAKE) clean
  285. $(MAKE) all