Makefile.opt_lib 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245
  1. #
  2. # Copyright (C) 2011-2016 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. # This Makefile will compile SDK to generate various components
  32. # including:
  33. # - Trusted libraries
  34. # - tstdc: libsgx_tstdc.a
  35. # - tstdcxx: libsgx_tstdcxx.a
  36. # - tservice: libsgx_tservice.a
  37. # - trts: libsgx_trts.a
  38. # - tcrypto: libsgx_tcrypto.a
  39. # - tkey_exchange: libsgx_tkey_exchange.a
  40. # - tsetjmp: libsgx_tsetjmp.a
  41. # - Untrtusted libraries
  42. # - ukey_exchange: libsgx_ukey_exchange.a
  43. # - sample_crypto: libsample_crypto.so (for sample code use)
  44. # - ptrace: libsgx_ptrace.so, gdb-sgx-plugin
  45. # - Tools
  46. # - signtool: sgx_sign
  47. # - edger8r: sgx_edger8r
  48. # - Simulation libraries and tools
  49. # - simulation: libsgx_trts_sim.a, libsgx_tservice_sim.a, libsgx_urts_sim.a, libsgx_uae_service_sim.a, sgx_config_cpusvn
  50. #
  51. include ../buildenv.mk
  52. LIBTLIBC := $(BUILD_DIR)/libsgx_tstdc.a
  53. LIBTLIBCXX := $(BUILD_DIR)/libsgx_tstdcxx.a
  54. LIBTSE := $(BUILD_DIR)/libsgx_tservice.a
  55. CHECK_OPT :=
  56. ifeq ("$(wildcard $(LINUX_EXTERNAL_DIR)/ippcp_internal/inc)", "")
  57. CHECK_OPT := opt_check_failed
  58. endif
  59. .PHONY: opt_check_failed
  60. opt_check_failed:
  61. @echo "ERROR: Please run 'download_prebuilt.sh' to download the prebuilt optimized libraries before compiling."
  62. @echo "Exiting......"
  63. @exit -2
  64. .PHONY: all
  65. all: $(CHECK_OPT)
  66. $(MAKE) components
  67. .PHONY: components
  68. components: tstdc tstdcxx tservice trts tcrypto tkey_exchange ukey_exchange ptrace sample_crypto simulation signtool edger8r tsetjmp
  69. # ---------------------------------------------------
  70. # tstdc
  71. # includes: tlibc, tlibthread, compiler-rt
  72. # libimf, libirc, libsvml, etc.
  73. # ---------------------------------------------------
  74. .PHONY: tstdc
  75. tstdc: $(LIBTLIBC)
  76. ifeq ($(ARCH), x86_64)
  77. LIBM_PATH := $(LINUX_EXTERNAL_DIR)/libm/Libm_ct_Linux
  78. LIBIRC_PATH := $(LINUX_EXTERNAL_DIR)/libirc/efi2
  79. SVML_PATH := $(LINUX_EXTERNAL_DIR)/libm/SVML_Intel64_Linux
  80. else
  81. LIBM_PATH := $(LINUX_EXTERNAL_DIR)/libm/Libm_Linux
  82. LIBIRC_PATH := $(LINUX_EXTERNAL_DIR)/libirc/ia32
  83. SVML_PATH := $(LINUX_EXTERNAL_DIR)/libm/SVML_IA32_Linux
  84. endif
  85. LIBIRC_NAME := libirc.a
  86. $(LIBTLIBC): tlibthread compiler-rt $(LIBM_PATH)/libimf.a $(LIBIRC_PATH)/$(LIBIRC_NAME) $(SVML_PATH)/libsvml.a
  87. $(MAKE) -C tlibc/ -j4 2> /dev/null
  88. @$(MKDIR) $(BUILD_DIR)/.libimf $(BUILD_DIR)/.libirc $(BUILD_DIR)/.libsvml $(BUILD_DIR)/.tlibc $(BUILD_DIR)/.tlibthread
  89. @$(RM) -f $(BUILD_DIR)/.libimf/* $(BUILD_DIR)/.libirc/* $(BUILD_DIR)/.libsvml/* $(BUILD_DIR)/.tlibc/* $(BUILD_DIR)/.tlibthread/*
  90. @cd $(BUILD_DIR)/.libimf && $(AR) x $(LIBM_PATH)/libimf.a
  91. @cd $(BUILD_DIR)/.libirc && $(AR) x $(LIBIRC_PATH)/$(LIBIRC_NAME)
  92. @cd $(BUILD_DIR)/.libsvml && $(AR) x $(SVML_PATH)/libsvml.a
  93. @cd $(BUILD_DIR)/.tlibc && $(AR) x $(LINUX_SDK_DIR)/tlibc/libtlibc.a
  94. @cd $(BUILD_DIR)/.tlibthread && $(AR) x $(LINUX_SDK_DIR)/tlibthread/libtlibthread.a
  95. $(CP) compiler-rt/libcompiler-rt.a $@
  96. $(AR) rsD $@ $(BUILD_DIR)/.libimf/*.o $(BUILD_DIR)/.libirc/*.o $(BUILD_DIR)/.libsvml/*.o $(BUILD_DIR)/.tlibc/*.o $(BUILD_DIR)/.tlibthread/*.o
  97. @$(RM) -rf $(BUILD_DIR)/.libimf $(BUILD_DIR)/.libirc $(BUILD_DIR)/.libsvml $(BUILD_DIR)/.tlibc $(BUILD_DIR)/.tlibthread
  98. .PHONY: tlibthread
  99. tlibthread:
  100. $(MAKE) -C tlibthread/
  101. .PHONY: compiler-rt
  102. compiler-rt:
  103. $(MAKE) -C compiler-rt/ 2> /dev/null
  104. # ---------------------------------------------------
  105. # tstdcxx
  106. # includes: cpprt, tlibstdcxx
  107. # ---------------------------------------------------
  108. .PHONY: tstdcxx
  109. tstdcxx: $(LIBTLIBCXX)
  110. $(LIBTLIBCXX): cpprt tlibstdcxx
  111. @$(MKDIR) $(BUILD_DIR)/.cpprt $(BUILD_DIR)/.tlibstdcxx
  112. @$(RM) -f $(BUILD_DIR)/.cpprt/* $(BUILD_DIR)/.tlibstdcxx/*
  113. @cd $(BUILD_DIR)/.cpprt && $(AR) x $(LINUX_SDK_DIR)/cpprt/libcpprt.a
  114. @cd $(BUILD_DIR)/.tlibstdcxx && $(AR) x $(LINUX_SDK_DIR)/tlibstdcxx/libtlibstdcxx.a
  115. $(AR) rcsD $@ $(BUILD_DIR)/.cpprt/*.o $(BUILD_DIR)/.tlibstdcxx/*.o
  116. @$(RM) -rf $(BUILD_DIR)/.cpprt $(BUILD_DIR)/.tlibstdcxx
  117. .PHONY: cpprt
  118. cpprt:
  119. $(MAKE) -C cpprt
  120. .PHONY: tlibstdcxx
  121. tlibstdcxx: $(BUILD_DIR)
  122. $(MAKE) -C tlibstdcxx/ 2> /dev/null
  123. $(CP) tlibstdcxx/README.sgx $(BUILD_DIR)/STLport_Changes_SGX.txt
  124. # ---------------------------------------------------
  125. # tservice
  126. # includes: selib, tseal, tae_service, ec_dh_lib
  127. # ---------------------------------------------------
  128. .PHONY: tservice
  129. tservice: $(LIBTSE)
  130. $(LIBTSE): selib tseal tae_service
  131. @$(MKDIR) $(BUILD_DIR)/.tservice
  132. @$(RM) -f $(BUILD_DIR)/.tservice/*
  133. cd $(BUILD_DIR)/.tservice && $(AR) x $(LINUX_SDK_DIR)/tseal/linux/libtSeal.a
  134. cd $(BUILD_DIR)/.tservice && $(AR) x $(LINUX_SDK_DIR)/tae_service/libtae_service.a
  135. $(CP) $(LINUX_SDK_DIR)/selib/linux/libselib.a $@
  136. $(AR) rsD $@ $(BUILD_DIR)/.tservice/*.o
  137. @$(RM) -rf $(BUILD_DIR)/.tservice
  138. .PHONY: selib
  139. selib:
  140. $(MAKE) -C selib/linux/
  141. .PHONY: tseal
  142. tseal:
  143. $(MAKE) -C tseal/linux/
  144. .PHONY: tae_service
  145. tae_service: edger8r
  146. $(MAKE) -C tae_service MODE=$(MODE)
  147. # ---------------------------------------------------
  148. # Other trusted libraries
  149. # ---------------------------------------------------
  150. .PHONY: trts
  151. trts:
  152. $(MAKE) -C trts/
  153. .PHONY: tcrypto
  154. tcrypto:
  155. $(MAKE) -C tlibcrypto/
  156. .PHONY: tkey_exchange
  157. tkey_exchange: edger8r
  158. $(MAKE) -C tkey_exchange
  159. .PHONY: tsetjmp
  160. tsetjmp:
  161. $(MAKE) -C tsetjmp/
  162. # ---------------------------------------------------
  163. # Untrusted libraries
  164. # ---------------------------------------------------
  165. .PHONY: ukey_exchange
  166. ukey_exchange:
  167. $(MAKE) -C ukey_exchange
  168. .PHONY: ptrace
  169. ptrace:
  170. $(MAKE) -C debugger_interface/linux/
  171. .PHONY: sample_crypto
  172. sample_crypto:
  173. $(MAKE) -C sample_libcrypto
  174. # ---------------------------------------------------
  175. # simualtion libraries and tools
  176. # ---------------------------------------------------
  177. .PHONY: simulation
  178. simulation: edger8r
  179. $(MAKE) -C simulation/
  180. # ---------------------------------------------------
  181. # tools
  182. # ---------------------------------------------------
  183. .PHONY: signtool
  184. signtool:
  185. $(MAKE) -C sign_tool/SignTool/
  186. .PHONY: edger8r
  187. edger8r:
  188. $(MAKE) -C edger8r/linux/
  189. $(BUILD_DIR):
  190. $(MKDIR) $@
  191. .PHONY: clean
  192. clean:
  193. $(MAKE) -C tlibc/ clean
  194. $(MAKE) -C tlibthread/ clean
  195. $(MAKE) -C compiler-rt/ clean
  196. $(MAKE) -C cpprt clean
  197. $(MAKE) -C tlibstdcxx/ clean
  198. $(MAKE) -C tseal/linux/ clean
  199. $(MAKE) -C selib/linux/ clean
  200. $(MAKE) -C tae_service/ clean
  201. $(MAKE) -C trts/ clean
  202. $(MAKE) -C tsetjmp/ clean
  203. $(MAKE) -C tlibcrypto/ clean
  204. $(MAKE) -C tkey_exchange/ clean
  205. $(MAKE) -C ukey_exchange/ clean
  206. $(MAKE) -C debugger_interface/linux/ clean
  207. $(MAKE) -C sample_libcrypto/ clean
  208. $(MAKE) -C simulation/ clean
  209. $(MAKE) -C sign_tool/SignTool clean
  210. $(MAKE) -C edger8r/linux clean
  211. @$(RM) $(LIBTLIBC) $(LIBTLIBCXX) $(LIBTSE)
  212. @$(RM) $(BUILD_DIR)/STLport_Changes_SGX.txt