Makefile 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192
  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. 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. LDFLAGS += -L$(COMMON_DIR)/se_wrapper \
  56. -L$(SIM_DIR)/uae_service_sim/linux
  57. LDFLAGS += -L$(VTUNE_DIR)/sdk/src/ittnotify/ -littnotify -ldl
  58. OBJ1 := enclave.o \
  59. tcs.o \
  60. loader.o \
  61. se_detect.o \
  62. enclave_mutex.o \
  63. routine.o \
  64. urts_xsave.o \
  65. se_ocalls.o \
  66. cpu_features.o \
  67. node.o \
  68. launch_checker.o
  69. OBJ2 := urts.o \
  70. misc.o \
  71. sig_handler.o \
  72. debugger_support.o \
  73. get_thread_id.o
  74. OBJ3 := section.o \
  75. elfparser.o
  76. OBJ4 := enter_enclave.o
  77. OBJ5 := enclave_creator_sim.o \
  78. cpusvn_util.o
  79. OBJ6 := $(SIM_DIR)/driver_api/driver_api.o \
  80. $(SIM_DIR)/assembly/linux/lowlib.o \
  81. $(SIM_DIR)/assembly/linux/sgxsim.o \
  82. $(SIM_DIR)/uinst/u_instructions.o \
  83. $(SIM_DIR)/uinst/enclave_mngr.o \
  84. $(SIM_DIR)/uinst/linux/set_tls.o \
  85. $(SIM_DIR)/uinst/linux/restore_tls.o
  86. CPP_OBJ := $(OBJ1) $(OBJ2) $(OBJ3) $(OBJ5)
  87. OBJ := $(CPP_OBJ) $(OBJ4)
  88. vpath %.cpp .:$(DIR1):$(DIR2):$(DIR3):$(DIR4)
  89. LDFLAGS += -L$(IPP_LIBS_DIR)
  90. LDFLAGS += -Wl,--version-script=$(LINUX_PSW_DIR)/urts/linux/urts.lds
  91. LIBURTSSIM_SHARED := libsgx_urts_sim.so
  92. LIBURTSSIM_DEBUG := libsgx_urts_sim.so.debug
  93. LIBURTS_DEPLOY := libsgx_urts_deploy.so
  94. LDLIBS += -lwrapper $(LD_IPP) -Wl,-Bdynamic -Wl,-Bsymbolic -lsgx_uae_service_sim
  95. SONAME = $(LIBURTSSIM_SHARED)
  96. .PHONY: all
  97. all: $(LIBURTSSIM_SHARED) $(LIBURTSSIM_DEBUG) $(LIBURTS_DEPLOY)| $(BUILD_DIR)
  98. $(CP) $(LIBURTSSIM_SHARED) $|
  99. $(CP) $(LIBURTS_DEPLOY) $|
  100. ifndef DEBUG
  101. $(CP) $(LIBURTSSIM_DEBUG) $|
  102. endif
  103. ifneq ($(USE_OPT_LIBS), 0)
  104. $(LIBURTSSIM_SHARED): simasm uinst driver_api wrapper uae_service_sim $(OBJ) $(OBJ6) ittnotify
  105. $(CXX) $(CXXFLAGS) -shared -Wl,-soname=$(SONAME) $(OBJ) $(OBJ6) $(LDFLAGS) $(LDLIBS) -o $@
  106. else
  107. -lcrypto_px:
  108. $(MAKE) -C $(IPP_LIBS_DIR)
  109. $(LIBURTSSIM_SHARED): simasm uinst driver_api wrapper uae_service_sim $(OBJ) $(OBJ6) -lcrypto_px ittnotify
  110. $(CXX) $(CXXFLAGS) -shared -Wl,-soname=$(SONAME) $(OBJ) $(OBJ6) $(LDFLAGS) $(LDLIBS) -o $@
  111. endif
  112. $(LIBURTSSIM_DEBUG): $(LIBURTSSIM_SHARED)
  113. ifndef DEBUG
  114. $(CP) $(LIBURTSSIM_SHARED) $(LIBURTSSIM_SHARED).orig
  115. $(OBJCOPY) --only-keep-debug $(LIBURTSSIM_SHARED) $(LIBURTSSIM_DEBUG)
  116. $(STRIP) -g $(LIBURTSSIM_SHARED)
  117. $(OBJCOPY) --add-gnu-debuglink=$(LIBURTSSIM_DEBUG) $(LIBURTSSIM_SHARED)
  118. endif
  119. $(BUILD_DIR):
  120. @$(MKDIR) $@
  121. $(OBJ4): %.o: $(DIR2)/%.S
  122. $(CC) -c $(CFLAGS) $(CPPFLAGS) $< -o $@
  123. $(CPP_OBJ): %.o: %.cpp
  124. $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) $< -o $@
  125. .PHONY: wrapper
  126. wrapper:
  127. $(MAKE) -C $(COMMON_DIR)/se_wrapper/
  128. .PHONY: driver_api
  129. driver_api:
  130. $(MAKE) -C $(SIM_DIR)/driver_api/
  131. .PHONY: simasm
  132. simasm:
  133. $(MAKE) -C $(SIM_DIR)/assembly/
  134. .PHONY: uinst
  135. uinst:
  136. $(MAKE) -C $(SIM_DIR)/uinst/
  137. .PHONY: uae_service_sim
  138. uae_service_sim:
  139. $(MAKE) -C $(SIM_DIR)/uae_service_sim/linux
  140. .PHONY: ittnotify
  141. ittnotify:
  142. $(MAKE) -C $(VTUNE_DIR)/sdk/src/ittnotify/
  143. $(LIBURTS_DEPLOY):../urts_deploy.c
  144. $(CC) -I$(COMMON_DIR)/inc -shared -fPIC -Wl,-soname=libsgx_urts.so $< -o $@
  145. .PHONY: clean
  146. clean::
  147. @$(RM) *.o $(LIBURTSSIM_SHARED) $(LIBURTS_DEPLOY) $(LIBURTSSIM_DEBUG) $(LIBURTSSIM_SHARED).orig
  148. @$(RM) $(BUILD_DIR)/$(LIBURTSSIM_SHARED) $(BUILD_DIR)/$(LIBURTS_DEPLOY) $(BUILD_DIR)/$(LIBURTSSIM_DEBUG)
  149. $(MAKE) -C $(COMMON_DIR)/se_wrapper clean
  150. $(MAKE) -C $(SIM_DIR)/driver_api/ clean
  151. $(MAKE) -C $(SIM_DIR)/assembly/ clean
  152. $(MAKE) -C $(SIM_DIR)/uinst/ clean
  153. $(MAKE) -C $(SIM_DIR)/uae_service_sim/linux clean
  154. ifeq ($(USE_OPT_LIBS), 0)
  155. $(MAKE) -C $(IPP_LIBS_DIR) clean
  156. endif
  157. $(MAKE) -C $(VTUNE_DIR)/sdk/src/ittnotify/ clean