Makefile.source 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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. # 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. # - tcmalloc: libsgx_tcmalloc.a
  43. # - Untrtusted libraries
  44. # - ukey_exchange: libsgx_ukey_exchange.a
  45. # - uprotected_fs: libsgx_uprotected_fs.a
  46. # - ptrace: libsgx_ptrace.so, gdb-sgx-plugin
  47. # - sample_crypto: libsample_crypto.so (for sample code use)
  48. # - Standalone, untrusted libraries
  49. # - libcapable: libsgx_capable.a libsgx_capable.so
  50. # - Tools
  51. # - signtool: sgx_sign
  52. # - edger8r: sgx_edger8r
  53. # - Simulation libraries and tools
  54. # - simulation: libsgx_trts_sim.a, libsgx_tservice_sim.a, libsgx_urts_sim.so, libsgx_uae_service_sim.so, sgx_config_cpusvn
  55. #
  56. include ../buildenv.mk
  57. LIBTLIBC := $(BUILD_DIR)/libsgx_tstdc.a
  58. LIBTLIBCXX := $(BUILD_DIR)/libsgx_tstdcxx.a
  59. LIBTCXX := $(BUILD_DIR)/libsgx_tcxx.a
  60. LIBTSE := $(BUILD_DIR)/libsgx_tservice.a
  61. .PHONY: components
  62. components: tstdc tstdcxx tcxx tservice trts tcrypto tkey_exchange ukey_exchange tprotected_fs uprotected_fs ptrace sample_crypto libcapable simulation signtool edger8r tcmalloc
  63. # ---------------------------------------------------
  64. # tstdc
  65. # includes: tlibc, libm, tlibthread, compiler-rt, tsafecrt
  66. # ---------------------------------------------------
  67. .PHONY: tstdc
  68. tstdc: $(LIBTLIBC)
  69. $(LIBTLIBC): tlibthread compiler-rt tsafecrt sgx_libm tsetjmp
  70. $(MAKE) -C tlibc/ -j4 2> /dev/null
  71. @$(MKDIR) $(BUILD_DIR)/.libm $(BUILD_DIR)/.tlibc $(BUILD_DIR)/.tlibthread $(BUILD_DIR)/.tsafecrt $(BUILD_DIR)/.tsetjmp
  72. @$(RM) -f $(BUILD_DIR)/.libm/* && cd $(BUILD_DIR)/.libm && $(AR) x $(LINUX_EXTERNAL_DIR)/sgx_libm/libm.a
  73. @$(RM) -f $(BUILD_DIR)/.tlibc/* && cd $(BUILD_DIR)/.tlibc && $(AR) x $(LINUX_SDK_DIR)/tlibc/libtlibc.a
  74. @$(RM) -f $(BUILD_DIR)/.tlibthread/* && cd $(BUILD_DIR)/.tlibthread && $(AR) x $(LINUX_SDK_DIR)/tlibthread/libtlibthread.a
  75. @$(RM) -f $(BUILD_DIR)/.tsafecrt/* && cd $(BUILD_DIR)/.tsafecrt && $(AR) x $(LINUX_SDK_DIR)/tsafecrt/libsgx_tsafecrt.a
  76. @$(RM) -f $(BUILD_DIR)/.tsetjmp/*.o && cd $(BUILD_DIR)/.tsetjmp && $(AR) x $(LINUX_SDK_DIR)/tsetjmp/libsgx_tsetjmp.a
  77. $(CP) compiler-rt/libcompiler-rt.a $@
  78. $(AR) qD $@ $(BUILD_DIR)/.libm/*.o
  79. $(AR) qD $@ $(BUILD_DIR)/.tlibc/*.o
  80. $(AR) qD $@ $(BUILD_DIR)/.tlibthread/*.o
  81. $(AR) qD $@ $(BUILD_DIR)/.tsafecrt/*.o
  82. $(AR) qD $@ $(BUILD_DIR)/.tsetjmp/*.o
  83. @$(RM) -rf $(BUILD_DIR)/.libm $(BUILD_DIR)/.tlibc
  84. @$(RM) -rf $(BUILD_DIR)/.tlibthread $(BUILD_DIR)/.tsafecrt $(BUILD_DIR)/.tsetjmp
  85. .PHONY: tlibthread
  86. tlibthread:
  87. $(MAKE) -C tlibthread/
  88. .PHONY: tsafecrt
  89. tsafecrt:
  90. $(MAKE) -C tsafecrt/
  91. .PHONY: compiler-rt
  92. compiler-rt:
  93. $(MAKE) -C compiler-rt/ 2> /dev/null
  94. LIBM_PATH = $(LINUX_EXTERNAL_DIR)/sgx_libm/
  95. M_ARCH = intel64
  96. ifneq ($(ARCH), x86_64)
  97. M_ARCH := ia32
  98. endif
  99. .PHONY: sgx_libm
  100. sgx_libm:
  101. $(MAKE) -C $(LIBM_PATH) ARCH=$(M_ARCH) 2> /dev/null
  102. .PHONY: tsetjmp
  103. tsetjmp:
  104. $(MAKE) -C tsetjmp/
  105. # ---------------------------------------------------
  106. # tstdcxx
  107. # includes: cpprt, tlibstdcxx
  108. # ---------------------------------------------------
  109. .PHONY: tstdcxx
  110. tstdcxx: $(LIBTLIBCXX)
  111. $(LIBTLIBCXX): cpprt tlibstdcxx
  112. @$(MKDIR) $(BUILD_DIR)/.tlibstdcxx
  113. @$(RM) -f $(BUILD_DIR)/.tlibstdcxx/*
  114. @cd $(BUILD_DIR)/.tlibstdcxx && $(AR) x $(LINUX_SDK_DIR)/tlibstdcxx/libtlibstdcxx.a
  115. $(CP) $(LINUX_SDK_DIR)/cpprt/libcpprt.a $@
  116. $(AR) qD $@ $(BUILD_DIR)/.tlibstdcxx/*.o
  117. @$(RM) -rf $(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. # tcxx
  127. # includes: cpprt, tlibcxx
  128. # ---------------------------------------------------
  129. .PHONY: tcxx
  130. tcxx: $(LIBTCXX)
  131. $(LIBTCXX): cpprt tlibcxx
  132. @$(MKDIR) $(BUILD_DIR)/.tlibcxx
  133. @$(RM) -f $(BUILD_DIR)/.tlibcxx/*
  134. @cd $(BUILD_DIR)/.tlibcxx && $(AR) x $(LINUX_SDK_DIR)/tlibcxx/libcxx.a
  135. $(CP) $(LINUX_SDK_DIR)/cpprt/libcpprt.a $@
  136. $(AR) qD $@ $(BUILD_DIR)/.tlibcxx/*.o
  137. @$(RM) -rf $(BUILD_DIR)/.tlibcxx
  138. .PHONY: tlibcxx
  139. tlibcxx: $(BUILD_DIR)
  140. $(MAKE) -C tlibcxx/ 2> /dev/null
  141. $(CP) tlibcxx/README.sgx $(BUILD_DIR)/libc++_Changes_SGX.txt
  142. # ---------------------------------------------------
  143. # tse
  144. # includes: selib, tseal, tae_service, ec_dh_lib
  145. # ---------------------------------------------------
  146. .PHONY: tservice
  147. tservice: $(LIBTSE)
  148. $(LIBTSE): selib tseal tae_service
  149. @$(MKDIR) $(BUILD_DIR)/.tservice
  150. @$(RM) -f $(BUILD_DIR)/.tservice/*
  151. cd $(BUILD_DIR)/.tservice && $(AR) x $(LINUX_SDK_DIR)/tseal/linux/libtSeal.a
  152. cd $(BUILD_DIR)/.tservice && $(AR) x $(LINUX_SDK_DIR)/tae_service/libtae_service.a
  153. $(CP) $(LINUX_SDK_DIR)/selib/linux/libselib.a $@
  154. $(AR) rsD $@ $(BUILD_DIR)/.tservice/*.o
  155. @$(RM) -rf $(BUILD_DIR)/.tservice
  156. .PHONY: selib
  157. selib:
  158. $(MAKE) -C selib/linux/
  159. .PHONY: tseal
  160. tseal:
  161. $(MAKE) -C tseal/linux/
  162. .PHONY: tae_service
  163. tae_service: edger8r
  164. $(MAKE) -C tae_service
  165. # ---------------------------------------------------
  166. # Other trusted libraries
  167. # ---------------------------------------------------
  168. .PHONY: trts
  169. trts:
  170. $(MAKE) -C trts/
  171. .PHONY: tcrypto
  172. tcrypto:
  173. $(MAKE) -C tlibcrypto/
  174. .PHONY: tkey_exchange
  175. tkey_exchange: edger8r
  176. $(MAKE) -C tkey_exchange
  177. .PHONY: tcmalloc
  178. tcmalloc:
  179. $(MAKE) -C gperftools/
  180. .PHONY: tprotected_fs
  181. tprotected_fs: edger8r
  182. $(MAKE) -C protected_fs/sgx_tprotected_fs
  183. # ---------------------------------------------------
  184. # Untrusted libraries
  185. # ---------------------------------------------------
  186. .PHONY: ukey_exchange
  187. ukey_exchange:
  188. $(MAKE) -C ukey_exchange
  189. .PHONY: uprotected_fs
  190. uprotected_fs: edger8r
  191. $(MAKE) -C protected_fs/sgx_uprotected_fs
  192. .PHONY: ptrace
  193. ptrace:
  194. $(MAKE) -C debugger_interface/linux/
  195. .PHONY: sample_crypto
  196. sample_crypto:
  197. $(MAKE) -C sample_libcrypto
  198. # ---------------------------------------------------
  199. # standalone, untrusted libraries
  200. # ---------------------------------------------------
  201. .PHONY: libcapable
  202. libcapable:
  203. $(MAKE) -C libcapable/linux/
  204. # ---------------------------------------------------
  205. # simualtion libraries and tools
  206. # ---------------------------------------------------
  207. .PHONY: simulation
  208. simulation: edger8r
  209. $(MAKE) -C simulation/
  210. # ---------------------------------------------------
  211. # tools
  212. # ---------------------------------------------------
  213. .PHONY: signtool
  214. signtool:
  215. $(MAKE) -C sign_tool/SignTool/
  216. .PHONY: edger8r
  217. edger8r:
  218. $(MAKE) -C edger8r/linux/
  219. $(BUILD_DIR):
  220. $(MKDIR) $@
  221. .PHONY: clean
  222. clean:
  223. $(MAKE) -C $(LIBM_PATH) ARCH=$(M_ARCH) 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 tsafecrt/ clean
  236. $(MAKE) -C gperftools/ clean
  237. $(MAKE) -C tlibcrypto/ clean
  238. $(MAKE) -C tkey_exchange/ clean
  239. $(MAKE) -C ukey_exchange/ clean
  240. $(MAKE) -C protected_fs/sgx_tprotected_fs/ clean
  241. $(MAKE) -C protected_fs/sgx_uprotected_fs/ clean
  242. $(MAKE) -C debugger_interface/linux/ clean
  243. $(MAKE) -C sample_libcrypto/ clean
  244. $(MAKE) -C libcapable/linux/ clean
  245. $(MAKE) -C simulation/ clean
  246. $(MAKE) -C sign_tool/SignTool clean
  247. $(MAKE) -C edger8r/linux clean
  248. @$(RM) $(LIBTLIBC) $(LIBTLIBCXX) $(LIBTSE)
  249. @$(RM) $(BUILD_DIR)/STLport_Changes_SGX.txt
  250. @$(RM) $(BUILD_DIR)/libc++_Changes_SGX.txt