Makefile 6.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186
  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. SIM_DIR := $(LINUX_SDK_DIR)/simulation
  33. VTUNE_DIR = $(LINUX_EXTERNAL_DIR)/vtune/linux
  34. ifndef DEBUG
  35. CXXFLAGS += -DDISABLE_TRACE
  36. CFLAGS += -DDISABLE_TRACE
  37. endif
  38. CXXFLAGS += -fPIC -DSE_SIM -Werror -g
  39. CFLAGS += -fPIC -DSE_SIM -Werror -g
  40. CPPFLAGS += $(ADDED_INC) #for ubuntu 11 and later version
  41. CPPFLAGS += -I$(COMMON_DIR)/inc \
  42. -I$(COMMON_DIR)/inc/internal/linux \
  43. -I$(LINUX_PSW_DIR)/urts \
  44. -I$(LINUX_PSW_DIR)/urts/parser \
  45. -I$(VTUNE_DIR)/include \
  46. -I$(VTUNE_DIR)/sdk/src/ittnotify
  47. CPPFLAGS += -I$(COMMON_DIR)/inc/internal \
  48. -I$(LINUX_PSW_DIR)/urts/linux \
  49. -I$(SIM_DIR)/tinst \
  50. -I$(SIM_DIR)/uinst
  51. DIR1 := $(LINUX_PSW_DIR)/urts/
  52. DIR2 := $(LINUX_PSW_DIR)/urts/linux/
  53. DIR3 := $(LINUX_PSW_DIR)/urts/parser/
  54. DIR4 := ../
  55. DIR5 := $(LINUX_PSW_DIR)/../common/src/linux
  56. DIR6 := $(LINUX_PSW_DIR)/../common/src
  57. LDFLAGS += -L$(COMMON_DIR)/se_wrapper \
  58. -L$(SIM_DIR)/uae_service_sim/linux
  59. LDFLAGS += -L$(VTUNE_DIR)/sdk/src/ittnotify/ -littnotify -ldl
  60. OBJ1 := enclave.o \
  61. tcs.o \
  62. loader.o \
  63. se_detect.o \
  64. enclave_mutex.o \
  65. routine.o \
  66. urts_xsave.o \
  67. se_ocalls.o \
  68. cpu_features.o \
  69. node.o \
  70. launch_checker.o
  71. OBJ2 := urts.o \
  72. misc.o \
  73. sig_handler.o \
  74. debugger_support.o \
  75. get_thread_id.o \
  76. urts_trim.o \
  77. urts_emodpr.o
  78. OBJ3 := section.o \
  79. elfparser.o
  80. OBJ4 := enter_enclave.o \
  81. xsave_gnu.o
  82. OBJ5 := enclave_creator_sim.o \
  83. cpusvn_util.o \
  84. crypto_evp_digest.o
  85. OBJ6 := $(SIM_DIR)/driver_api/driver_api.o \
  86. $(SIM_DIR)/assembly/linux/lowlib.o \
  87. $(SIM_DIR)/assembly/linux/sgxsim.o \
  88. $(SIM_DIR)/uinst/u_instructions.o \
  89. $(SIM_DIR)/uinst/enclave_mngr.o \
  90. $(SIM_DIR)/uinst/linux/set_tls.o \
  91. $(SIM_DIR)/uinst/linux/restore_tls.o
  92. CPP_OBJ := $(OBJ1) $(OBJ2) $(OBJ3) $(OBJ5)
  93. OBJ := $(CPP_OBJ) $(OBJ4)
  94. vpath %.cpp .:$(DIR1):$(DIR2):$(DIR3):$(DIR4):$(DIR6)
  95. vpath %.S .:$(DIR2):$(DIR5)
  96. LDFLAGS += $(COMMON_LDFLAGS) -Wl,--version-script=$(LINUX_PSW_DIR)/urts/linux/urts.lds
  97. LIBURTSSIM_SHARED := libsgx_urts_sim.so
  98. LIBURTSSIM_DEBUG := libsgx_urts_sim.so.debug
  99. LIBURTS_DEPLOY := libsgx_urts_deploy.so
  100. LDLIBS += -lwrapper -lcrypto -Wl,-Bdynamic -Wl,-Bsymbolic -lsgx_uae_service_sim
  101. SONAME = $(LIBURTSSIM_SHARED)
  102. .PHONY: all
  103. all: $(LIBURTSSIM_SHARED) $(LIBURTSSIM_DEBUG) $(LIBURTS_DEPLOY)| $(BUILD_DIR)
  104. $(CP) $(LIBURTSSIM_SHARED) $|
  105. $(CP) $(LIBURTS_DEPLOY) $|
  106. ifndef DEBUG
  107. $(CP) $(LIBURTSSIM_DEBUG) $|
  108. endif
  109. $(LIBURTSSIM_SHARED): simasm uinst driver_api wrapper uae_service_sim $(OBJ) $(OBJ6) ittnotify
  110. $(CXX) $(CXXFLAGS) -shared -Wl,-soname=$(SONAME) $(OBJ) $(OBJ6) $(LDFLAGS) $(LDLIBS) -o $@
  111. $(LIBURTSSIM_DEBUG): $(LIBURTSSIM_SHARED)
  112. ifndef DEBUG
  113. $(CP) $(LIBURTSSIM_SHARED) $(LIBURTSSIM_SHARED).orig
  114. $(OBJCOPY) --only-keep-debug $(LIBURTSSIM_SHARED) $(LIBURTSSIM_DEBUG)
  115. $(STRIP) -g $(LIBURTSSIM_SHARED)
  116. $(OBJCOPY) --add-gnu-debuglink=$(LIBURTSSIM_DEBUG) $(LIBURTSSIM_SHARED)
  117. endif
  118. $(BUILD_DIR):
  119. @$(MKDIR) $@
  120. $(OBJ4): %.o: %.S
  121. $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
  122. $(CPP_OBJ): %.o: %.cpp
  123. $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) $< -o $@
  124. .PHONY: wrapper
  125. wrapper:
  126. $(MAKE) -C $(COMMON_DIR)/se_wrapper/
  127. .PHONY: driver_api
  128. driver_api:
  129. $(MAKE) -C $(SIM_DIR)/driver_api/
  130. .PHONY: simasm
  131. simasm:
  132. $(MAKE) -C $(SIM_DIR)/assembly/
  133. .PHONY: uinst
  134. uinst:
  135. $(MAKE) -C $(SIM_DIR)/uinst/
  136. .PHONY: uae_service_sim
  137. uae_service_sim:
  138. $(MAKE) -C $(SIM_DIR)/uae_service_sim/linux
  139. .PHONY: ittnotify
  140. ittnotify:
  141. $(MAKE) -C $(VTUNE_DIR)/sdk/src/ittnotify/
  142. $(LIBURTS_DEPLOY):../urts_deploy.c
  143. $(CC) -I$(COMMON_DIR)/inc -shared -fPIC -Wl,-soname=libsgx_urts.so $< -o $@
  144. .PHONY: clean
  145. clean::
  146. @$(RM) *.o $(LIBURTSSIM_SHARED) $(LIBURTS_DEPLOY) $(LIBURTSSIM_DEBUG) $(LIBURTSSIM_SHARED).orig
  147. @$(RM) $(BUILD_DIR)/$(LIBURTSSIM_SHARED) $(BUILD_DIR)/$(LIBURTS_DEPLOY) $(BUILD_DIR)/$(LIBURTSSIM_DEBUG)
  148. $(MAKE) -C $(COMMON_DIR)/se_wrapper clean
  149. $(MAKE) -C $(SIM_DIR)/driver_api/ clean
  150. $(MAKE) -C $(SIM_DIR)/assembly/ clean
  151. $(MAKE) -C $(SIM_DIR)/uinst/ clean
  152. $(MAKE) -C $(SIM_DIR)/uae_service_sim/linux clean
  153. $(MAKE) -C $(VTUNE_DIR)/sdk/src/ittnotify/ clean