Makefile 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  1. #
  2. # Copyright (C) 2011-2017 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 := $(TOP_DIR)/psw/ae/common
  34. IPC_COMMON_SRC_DIR := $(IPC_COMMON_DIR)/src
  35. IPC_COMMON_INC_DIR := $(IPC_COMMON_DIR)/inc
  36. IPC_COMMON_PROTO_DIR := $(IPC_COMMON_DIR)/proto
  37. UAE_WRAPPER_DIR := ../uae_wrapper
  38. UAE_SRC_DIR := $(UAE_WRAPPER_DIR)/src
  39. UAE_INC_DIR := $(UAE_WRAPPER_DIR)/inc
  40. AE_COMMON_DIR := $(LINUX_PSW_DIR)/ae/common
  41. INCLUDE += -I.
  42. INCLUDE += -I$(COMMON_DIR) \
  43. -I$(COMMON_DIR)/inc \
  44. -I$(COMMON_DIR)/inc/internal \
  45. INCLUDE += -I$(LINUX_PSW_DIR)/ae/common \
  46. -I$(LINUX_PSW_DIR)/ae/inc \
  47. -I$(LINUX_PSW_DIR)/ae/inc/internal \
  48. -I$(LINUX_SDK_DIR)/tseal
  49. INCLUDE += -I$(LINUX_EXTERNAL_DIR)/epid \
  50. -I$(IPC_COMMON_INC_DIR) \
  51. -I$(UAE_INC_DIR) \
  52. -I$(IPC_COMMON_PROTO_DIR) \
  53. -I$(LINUX_PSW_DIR)/ae/aesm_service/source
  54. CXXFLAGS += -fPIC -Werror -g -DPROTOBUF_INLINE_NOT_IN_HEADERS=0
  55. EXTERNAL_LIB += -lprotobuf
  56. vpath %.cpp .. $(COMMON_DIR)/src $(IPC_COMMON_SRC_DIR) $(IPC_COMMON_PROTO_DIR) $(UAE_SRC_DIR) $(AE_COMMON_DIR)
  57. IPC_SRC := AECloseSessionRequest.cpp \
  58. AEGetQuoteResponse.cpp \
  59. AECloseSessionResponse.cpp \
  60. AEInitQuoteRequest.cpp \
  61. AECreateSessionRequest.cpp \
  62. AEInitQuoteResponse.cpp \
  63. AECreateSessionResponse.cpp \
  64. AEInvokeServiceRequest.cpp \
  65. AEExchangeReportRequest.cpp \
  66. AEInvokeServiceResponse.cpp \
  67. AEExchangeReportResponse.cpp \
  68. AEGetPsCapRequest.cpp \
  69. AEGetPsCapResponse.cpp \
  70. AEReportAttestationRequest.cpp \
  71. AEReportAttestationResponse.cpp \
  72. ProtobufSerializer.cpp \
  73. AEGetLaunchTokenRequest.cpp \
  74. AEGetWhiteListSizeRequest.cpp \
  75. AEGetWhiteListSizeResponse.cpp \
  76. AEGetWhiteListRequest.cpp \
  77. AEGetWhiteListResponse.cpp \
  78. AESGXGetExtendedEpidGroupIdRequest.cpp \
  79. AESGXGetExtendedEpidGroupIdResponse.cpp \
  80. AESGXSwitchExtendedEpidGroupRequest.cpp \
  81. AESGXSwitchExtendedEpidGroupResponse.cpp \
  82. SocketTransporter.cpp \
  83. AEGetLaunchTokenResponse.cpp \
  84. UnixCommunicationSocket.cpp \
  85. AEGetQuoteRequest.cpp \
  86. UnixSocketFactory.cpp \
  87. NonBlockingUnixCommunicationSocket.cpp \
  88. NonBlockingUnixSocketFactory.cpp
  89. PROTOBUF_SRC := messages.pb.cc
  90. SRC := AEServicesImpl.cpp \
  91. AEServicesProvider.cpp \
  92. tae_ocall_api.cpp \
  93. uae_api.cpp \
  94. se_sig_rl.cpp \
  95. sgx_uae_service.cpp \
  96. uae_service_version.cpp \
  97. uae_service_assert.cpp
  98. OBJ := $(SRC:.cpp=.o) $(IPC_SRC:.cpp=.o) $(PROTOBUF_SRC:.cc=.o)
  99. LDUFLAGS:= -pthread -L$(BUILD_DIR)
  100. LDUFLAGS += -Wl,--version-script=uae_service.lds
  101. LIBNAME = libsgx_uae_service.so
  102. LIBNAME_DEBUG = libsgx_uae_service.so.debug
  103. .PHONY: all
  104. all: install_lib
  105. .PHONY: install_lib
  106. install_lib: $(LIBNAME) $(LIBNAME_DEBUG) | $(BUILD_DIR)
  107. @$(CP) $(LIBNAME) $|
  108. ifndef DEBUG
  109. @$(CP) $(LIBNAME_DEBUG) $|
  110. endif
  111. $(LIBNAME): $(OBJ)
  112. $(CXX) $(CXXFLAGS) $(OBJ) -shared $(LDUFLAGS) $(EXTERNAL_LIB) -o $@
  113. $(LIBNAME_DEBUG): $(LIBNAME)
  114. ((test -f $(LIBNAME_DEBUG)) || $(MAKE) separate_debug_info)
  115. .PHONY: separate_debug_info
  116. separate_debug_info:
  117. ifndef DEBUG
  118. $(CP) $(LIBNAME) $(LIBNAME).orig
  119. $(OBJCOPY) --only-keep-debug $(LIBNAME) $(LIBNAME_DEBUG)
  120. $(STRIP) -g $(LIBNAME)
  121. $(OBJCOPY) --add-gnu-debuglink=$(LIBNAME_DEBUG) $(LIBNAME)
  122. endif
  123. $(IPC_SRC:.cpp=.o) : $(IPC_COMMON_PROTO_DIR)/messages.pb.cc
  124. AEServicesImpl.o : $(IPC_COMMON_PROTO_DIR)/messages.pb.cc
  125. messages.pb.o : $(IPC_COMMON_PROTO_DIR)/messages.pb.cc
  126. $(CXX) $(filter-out -Wshadow, $(CXXFLAGS)) -c $< -o $@
  127. %.o :%.cpp
  128. $(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -o $@
  129. $(BUILD_DIR):
  130. @$(MKDIR) $@
  131. $(IPC_COMMON_PROTO_DIR)/messages.pb.cc: $(IPC_COMMON_PROTO_DIR)/messages.proto
  132. $(MAKE) -C $(IPC_COMMON_PROTO_DIR)
  133. .PHONY: clean
  134. clean:
  135. $(MAKE) -C $(IPC_COMMON_PROTO_DIR) clean
  136. @$(RM) $(OBJ) $(LIBNAME).orig
  137. @$(RM) $(LIBNAME) $(BUILD_DIR)/$(LIBNAME)
  138. @$(RM) $(LIBNAME_DEBUG) $(BUILD_DIR)/$(LIBNAME_DEBUG)
  139. .PHONY: rebuild
  140. rebuild:
  141. $(MAKE) clean
  142. $(MAKE) all