Makefile 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161
  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. include ../../../buildenv.mk
  32. ifndef DEBUG
  33. CXXFLAGS += -DDISABLE_TRACE
  34. CFLAGS += -DDISABLE_TRACE
  35. endif
  36. CXXFLAGS += -fPIC -Werror -g
  37. CXXFLAGS += $(ADDED_INC)
  38. CFLAGS += -fPIC -Werror -g
  39. CFLAGS += $(ADDED_INC)
  40. VTUNE_DIR = $(LINUX_EXTERNAL_DIR)/vtune/linux
  41. INC += -I$(COMMON_DIR)/inc \
  42. -I$(COMMON_DIR)/inc/internal \
  43. -I$(COMMON_DIR)/inc/internal/linux \
  44. -I$(LINUX_PSW_DIR)/urts/ \
  45. -I$(LINUX_PSW_DIR)/urts/linux \
  46. -I$(LINUX_PSW_DIR)/urts/parser \
  47. -I$(VTUNE_DIR)/include \
  48. -I$(VTUNE_DIR)/sdk/src/ittnotify
  49. LDFLAGS := -lwrapper
  50. LDFLAGS += -Wl,-Bdynamic -lsgx_uae_service
  51. LDFLAGS += -L$(VTUNE_DIR)/sdk/src/ittnotify -littnotify -ldl
  52. LDFLAGS += -Wl,--version-script=urts.lds -Wl,--gc-sections
  53. DIR1 := $(LINUX_PSW_DIR)/urts/linux
  54. DIR2 := $(LINUX_PSW_DIR)/urts
  55. DIR3 := $(LINUX_PSW_DIR)/urts/parser
  56. DIR4 := $(LINUX_PSW_DIR)/urts/parser/linux
  57. LIB += -L$(COMMON_DIR)/se_wrapper \
  58. -L$(BUILD_DIR)
  59. OBJ1 := loader.o \
  60. node.o \
  61. se_detect.o \
  62. enclave.o \
  63. tcs.o \
  64. enclave_mutex.o \
  65. routine.o \
  66. urts_xsave.o \
  67. se_ocalls.o \
  68. cpu_features.o \
  69. launch_checker.o \
  70. urts_version.o \
  71. enclave_creator_hw_com.o
  72. OBJ2 := urts.o \
  73. enclave_creator_hw.o \
  74. misc.o \
  75. sig_handler.o \
  76. debugger_support.o \
  77. get_thread_id.o \
  78. prd_css_util.o
  79. OBJ3 := enter_enclave.o
  80. OBJ4 := section.o \
  81. elfparser.o
  82. OBJ5 := urts_internal.o
  83. CPP_OBJ := $(OBJ1) $(OBJ2) $(OBJ4) $(OBJ5)
  84. URTS_OBJ := $(OBJ3) $(OBJ1) $(OBJ2) $(OBJ4)
  85. INTERNAL_OBJ := $(OBJ3) $(CPP_OBJ)
  86. vpath %.cpp $(DIR1):$(DIR2):$(DIR3):$(DIR4)
  87. LIBWRAPPER := libwrapper.a
  88. LIBURTS := libsgx_urts.so
  89. LIBURTS_INTERNAL := liburts_internal.a
  90. LIBURTS_DEBUG := libsgx_urts.so.debug
  91. .PHONY: all
  92. all: $(LIBURTS) $(LIBURTS_INTERNAL) $(LIBURTS_DEBUG) | $(BUILD_DIR)
  93. @$(CP) $(LIBURTS) $|
  94. @$(CP) $(LIBURTS_INTERNAL) $|
  95. ifndef DEBUG
  96. @$(CP) $(LIBURTS_DEBUG) $|
  97. endif
  98. $(LIBURTS_INTERNAL): $(INTERNAL_OBJ) $(LIBWRAPPER)
  99. $(CP) $(COMMON_DIR)/se_wrapper/libwrapper.a $@
  100. $(AR) rcs $@ $(INTERNAL_OBJ)
  101. $(LIBURTS): $(URTS_OBJ) $(LIBWRAPPER) uae_service ittnotify
  102. $(CXX) $(CXXFLAGS) -shared -Wl,-soname=$@ $(LIB) -o $@ $(URTS_OBJ) $(LDFLAGS)
  103. $(LIBURTS_DEBUG): $(LIBURTS)
  104. ifndef DEBUG
  105. $(CP) $(LIBURTS) $(LIBURTS).orig
  106. $(OBJCOPY) --only-keep-debug $(LIBURTS) $(LIBURTS_DEBUG)
  107. $(STRIP) -g $(LIBURTS)
  108. $(OBJCOPY) --add-gnu-debuglink=$(LIBURTS_DEBUG) $(LIBURTS)
  109. endif
  110. $(CPP_OBJ): %.o: %.cpp
  111. $(CXX) -c $(CXXFLAGS) $(INC) $< -o $@
  112. $(OBJ3): %.o: %.S
  113. $(CC) -c $(CFLAGS) $(INC) $< -o $@
  114. $(LIBWRAPPER):
  115. $(MAKE) -C $(COMMON_DIR)/se_wrapper/
  116. .PHONY:uae_service
  117. uae_service:
  118. $(MAKE) -C $(LINUX_PSW_DIR)/uae_service/linux
  119. .PHONY: ittnotify
  120. ittnotify:
  121. $(MAKE) -C $(VTUNE_DIR)/sdk/src/ittnotify
  122. $(BUILD_DIR):
  123. @$(MKDIR) $@
  124. .PHONY: clean
  125. clean::
  126. @$(RM) *.o $(LIBURTS) $(LIBURTS_INTERNAL) $(LIBURTS_DEBUG)
  127. @$(RM) $(BUILD_DIR)/$(LIBURTS) $(BUILD_DIR)/$(LIBURTS_INTERNAL)
  128. @$(RM) $(LIBURTS).orig $(BUILD_DIR)/$(LIBURTS_DEBUG)
  129. $(MAKE) -C $(COMMON_DIR)/se_wrapper/ clean
  130. $(MAKE) -C $(LINUX_PSW_DIR)/uae_service/linux/ clean
  131. $(MAKE) -C $(VTUNE_DIR)/sdk/src/ittnotify clean