Makefile.opt_lib 10 KB

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