Makefile 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  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. 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 += $(COMMON_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. DIR5 := $(LINUX_PSW_DIR)/../common/src/linux
  58. LIB += -L$(COMMON_DIR)/se_wrapper \
  59. -L$(BUILD_DIR)
  60. OBJ1 := loader.o \
  61. node.o \
  62. se_detect.o \
  63. enclave.o \
  64. tcs.o \
  65. enclave_mutex.o \
  66. routine.o \
  67. urts_xsave.o \
  68. se_ocalls.o \
  69. cpu_features.o \
  70. launch_checker.o \
  71. urts_version.o \
  72. enclave_creator_hw_com.o
  73. OBJ2 := urts.o \
  74. enclave_creator_hw.o \
  75. misc.o \
  76. sig_handler.o \
  77. debugger_support.o \
  78. get_thread_id.o \
  79. prd_css_util.o \
  80. urts_emodpr.o \
  81. urts_trim.o \
  82. edmm_utility.o
  83. OBJ3 := enter_enclave.o \
  84. xsave_gnu.o
  85. OBJ4 := section.o \
  86. elfparser.o
  87. OBJ5 := urts_internal.o
  88. CPP_OBJ := $(OBJ1) $(OBJ2) $(OBJ4) $(OBJ5)
  89. URTS_OBJ := $(OBJ3) $(OBJ1) $(OBJ2) $(OBJ4)
  90. INTERNAL_OBJ := $(OBJ3) $(CPP_OBJ)
  91. vpath %.cpp $(DIR1):$(DIR2):$(DIR3):$(DIR4)
  92. vpath %.S $(DIR1):$(DIR5)
  93. LIBWRAPPER := libwrapper.a
  94. LIBURTS := libsgx_urts.so
  95. LIBURTS_INTERNAL := liburts_internal.a
  96. LIBURTS_DEBUG := libsgx_urts.so.debug
  97. .PHONY: all
  98. all: $(LIBURTS) $(LIBURTS_INTERNAL) $(LIBURTS_DEBUG) | $(BUILD_DIR)
  99. @$(CP) $(LIBURTS) $|
  100. @$(CP) $(LIBURTS_INTERNAL) $|
  101. ifndef DEBUG
  102. @$(CP) $(LIBURTS_DEBUG) $|
  103. endif
  104. $(LIBURTS_INTERNAL): $(INTERNAL_OBJ) $(LIBWRAPPER)
  105. $(CP) $(COMMON_DIR)/se_wrapper/libwrapper.a $@
  106. $(AR) rcs $@ $(INTERNAL_OBJ)
  107. $(LIBURTS): $(URTS_OBJ) $(LIBWRAPPER) uae_service ittnotify
  108. $(CXX) $(CXXFLAGS) -shared -Wl,-soname=$@ $(LIB) -o $@ $(URTS_OBJ) $(LDFLAGS)
  109. $(LIBURTS_DEBUG): $(LIBURTS)
  110. ifndef DEBUG
  111. $(CP) $(LIBURTS) $(LIBURTS).orig
  112. $(OBJCOPY) --only-keep-debug $(LIBURTS) $(LIBURTS_DEBUG)
  113. $(STRIP) -g $(LIBURTS)
  114. $(OBJCOPY) --add-gnu-debuglink=$(LIBURTS_DEBUG) $(LIBURTS)
  115. endif
  116. $(CPP_OBJ): %.o: %.cpp
  117. $(CXX) -c $(CXXFLAGS) $(INC) $< -o $@
  118. $(OBJ3): %.o: %.S
  119. $(CC) -c $(CFLAGS) $(INC) $< -o $@
  120. $(LIBWRAPPER):
  121. $(MAKE) -C $(COMMON_DIR)/se_wrapper/
  122. .PHONY:uae_service
  123. uae_service:
  124. $(MAKE) -C $(LINUX_PSW_DIR)/uae_service/linux
  125. .PHONY: ittnotify
  126. ittnotify:
  127. $(MAKE) -C $(VTUNE_DIR)/sdk/src/ittnotify
  128. $(BUILD_DIR):
  129. @$(MKDIR) $@
  130. .PHONY: clean
  131. clean::
  132. @$(RM) *.o $(LIBURTS) $(LIBURTS_INTERNAL) $(LIBURTS_DEBUG)
  133. @$(RM) $(BUILD_DIR)/$(LIBURTS) $(BUILD_DIR)/$(LIBURTS_INTERNAL)
  134. @$(RM) $(LIBURTS).orig $(BUILD_DIR)/$(LIBURTS_DEBUG)
  135. $(MAKE) -C $(COMMON_DIR)/se_wrapper/ clean
  136. $(MAKE) -C $(LINUX_PSW_DIR)/uae_service/linux/ clean
  137. $(MAKE) -C $(VTUNE_DIR)/sdk/src/ittnotify clean