Makefile 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. #
  2. # Copyright (C) 2011-2018 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-sdk \
  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 -Wno-unused-parameter -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. vpath %.c $(COMMON_DIR)/src
  58. C_SRC := se_trace.c
  59. IPC_SRC := AECloseSessionRequest.cpp \
  60. AEGetQuoteResponse.cpp \
  61. AECloseSessionResponse.cpp \
  62. AEInitQuoteRequest.cpp \
  63. AECreateSessionRequest.cpp \
  64. AEInitQuoteResponse.cpp \
  65. AECreateSessionResponse.cpp \
  66. AEInvokeServiceRequest.cpp \
  67. AEExchangeReportRequest.cpp \
  68. AEInvokeServiceResponse.cpp \
  69. AEExchangeReportResponse.cpp \
  70. AEGetPsCapRequest.cpp \
  71. AEGetPsCapResponse.cpp \
  72. AEReportAttestationRequest.cpp \
  73. AEReportAttestationResponse.cpp \
  74. ProtobufSerializer.cpp \
  75. AEGetLaunchTokenRequest.cpp \
  76. AEGetWhiteListSizeRequest.cpp \
  77. AEGetWhiteListSizeResponse.cpp \
  78. AEGetWhiteListRequest.cpp \
  79. AEGetWhiteListResponse.cpp \
  80. AESGXGetExtendedEpidGroupIdRequest.cpp \
  81. AESGXGetExtendedEpidGroupIdResponse.cpp \
  82. AESGXSwitchExtendedEpidGroupRequest.cpp \
  83. AESGXSwitchExtendedEpidGroupResponse.cpp \
  84. AESGXRegisterRequest.cpp \
  85. AESGXRegisterResponse.cpp \
  86. SocketTransporter.cpp \
  87. AEGetLaunchTokenResponse.cpp \
  88. UnixCommunicationSocket.cpp \
  89. AEGetQuoteRequest.cpp \
  90. UnixSocketFactory.cpp \
  91. NonBlockingUnixCommunicationSocket.cpp \
  92. NonBlockingUnixSocketFactory.cpp
  93. PROTOBUF_SRC := messages.pb.cc
  94. SRC := AEServicesImpl.cpp \
  95. AEServicesProvider.cpp \
  96. tae_ocall_api.cpp \
  97. uae_api.cpp \
  98. se_sig_rl.cpp \
  99. sgx_uae_service.cpp \
  100. uae_service_version.cpp \
  101. uae_service_assert.cpp
  102. OBJ := $(C_SRC:.c=.o) $(SRC:.cpp=.o) $(IPC_SRC:.cpp=.o) $(PROTOBUF_SRC:.cc=.o)
  103. LDUFLAGS:= -pthread $(COMMON_LDFLAGS)
  104. LDUFLAGS += -Wl,--version-script=uae_service.lds -Wl,--gc-sections
  105. LIBNAME = libsgx_uae_service.so
  106. LIBNAME_DEBUG = libsgx_uae_service.so.debug
  107. .PHONY: all
  108. all: install_lib
  109. .PHONY: install_lib
  110. install_lib: $(LIBNAME) $(LIBNAME_DEBUG) | $(BUILD_DIR)
  111. @$(CP) $(LIBNAME) $|
  112. ifndef DEBUG
  113. @$(CP) $(LIBNAME_DEBUG) $|
  114. endif
  115. $(LIBNAME): $(OBJ)
  116. $(CXX) $(CXXFLAGS) $(OBJ) -shared $(LDUFLAGS) $(EXTERNAL_LIB) -o $@
  117. $(LIBNAME_DEBUG): $(LIBNAME)
  118. ((test -f $(LIBNAME_DEBUG)) || $(MAKE) separate_debug_info)
  119. .PHONY: separate_debug_info
  120. separate_debug_info:
  121. ifndef DEBUG
  122. $(CP) $(LIBNAME) $(LIBNAME).orig
  123. $(OBJCOPY) --only-keep-debug $(LIBNAME) $(LIBNAME_DEBUG)
  124. $(STRIP) -g $(LIBNAME)
  125. $(OBJCOPY) --add-gnu-debuglink=$(LIBNAME_DEBUG) $(LIBNAME)
  126. endif
  127. $(IPC_SRC:.cpp=.o) : $(IPC_COMMON_PROTO_DIR)/messages.pb.cc
  128. AEServicesImpl.o : $(IPC_COMMON_PROTO_DIR)/messages.pb.cc
  129. messages.pb.o : $(IPC_COMMON_PROTO_DIR)/messages.pb.cc
  130. $(CXX) $(filter-out -Wshadow, $(CXXFLAGS)) -c $< -o $@
  131. %.o :%.cpp
  132. $(CXX) $(CXXFLAGS) $(INCLUDE) -c $< -o $@
  133. %.o: %.c
  134. $(CC) $(CFLAGS) $(INCLUDE) -Werror -fPIC -c $< -o $@
  135. $(BUILD_DIR):
  136. @$(MKDIR) $@
  137. $(IPC_COMMON_PROTO_DIR)/messages.pb.cc: $(IPC_COMMON_PROTO_DIR)/messages.proto
  138. $(MAKE) -C $(IPC_COMMON_PROTO_DIR)
  139. .PHONY: clean
  140. clean:
  141. $(MAKE) -C $(IPC_COMMON_PROTO_DIR) clean
  142. @$(RM) $(OBJ) $(LIBNAME).orig
  143. @$(RM) $(LIBNAME) $(BUILD_DIR)/$(LIBNAME)
  144. @$(RM) $(LIBNAME_DEBUG) $(BUILD_DIR)/$(LIBNAME_DEBUG)
  145. .PHONY: rebuild
  146. rebuild:
  147. $(MAKE) clean
  148. $(MAKE) all