Makefile.opt_lib 8.7 KB

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