Makefile.source 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284
  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. # - 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/* $(BUILD_DIR)/.tlibc/* $(BUILD_DIR)/.tlibthread/* $(BUILD_DIR)/.tsafecrt/* $(BUILD_DIR)/.tsetjmp/*.o
  73. @cd $(BUILD_DIR)/.libm && $(AR) x $(LINUX_EXTERNAL_DIR)/sgx_libm/libm.a
  74. @cd $(BUILD_DIR)/.tlibc && $(AR) x $(LINUX_SDK_DIR)/tlibc/libtlibc.a
  75. @cd $(BUILD_DIR)/.tlibthread && $(AR) x $(LINUX_SDK_DIR)/tlibthread/libtlibthread.a
  76. @cd $(BUILD_DIR)/.tsafecrt && $(AR) x $(LINUX_SDK_DIR)/tsafecrt/libsgx_tsafecrt.a
  77. @cd $(BUILD_DIR)/.tsetjmp && $(AR) x $(LINUX_SDK_DIR)/tsetjmp/libsgx_tsetjmp.a
  78. $(CP) compiler-rt/libcompiler-rt.a $@
  79. $(AR) rsD $@ $(BUILD_DIR)/.libm/*.o $(BUILD_DIR)/.tlibc/*.o $(BUILD_DIR)/.tlibthread/*.o $(BUILD_DIR)/.tsafecrt/*.o $(BUILD_DIR)/.tsetjmp/*.o
  80. @$(RM) -rf $(BUILD_DIR)/.libm $(BUILD_DIR)/.tlibc $(BUILD_DIR)/.tlibthread $(BUILD_DIR)/.tsafecrt $(BUILD_DIR)/.tsetjmp
  81. .PHONY: tlibthread
  82. tlibthread:
  83. $(MAKE) -C tlibthread/
  84. .PHONY: tsafecrt
  85. tsafecrt:
  86. $(MAKE) -C tsafecrt/
  87. .PHONY: compiler-rt
  88. compiler-rt:
  89. $(MAKE) -C compiler-rt/ 2> /dev/null
  90. LIBM_PATH = $(LINUX_EXTERNAL_DIR)/sgx_libm/
  91. M_ARCH = intel64
  92. ifneq ($(ARCH), x86_64)
  93. M_ARCH := ia32
  94. endif
  95. .PHONY: sgx_libm
  96. sgx_libm:
  97. $(MAKE) -C $(LIBM_PATH) ARCH=$(M_ARCH) 2> /dev/null
  98. .PHONY: tsetjmp
  99. tsetjmp:
  100. $(MAKE) -C tsetjmp/
  101. # ---------------------------------------------------
  102. # tstdcxx
  103. # includes: cpprt, tlibstdcxx
  104. # ---------------------------------------------------
  105. .PHONY: tstdcxx
  106. tstdcxx: $(LIBTLIBCXX)
  107. $(LIBTLIBCXX): cpprt tlibstdcxx
  108. @$(MKDIR) $(BUILD_DIR)/.cpprt $(BUILD_DIR)/.tlibstdcxx
  109. @$(RM) -f $(BUILD_DIR)/.cpprt/* $(BUILD_DIR)/.tlibstdcxx/*
  110. @cd $(BUILD_DIR)/.cpprt && $(AR) x $(LINUX_SDK_DIR)/cpprt/libcpprt.a
  111. @cd $(BUILD_DIR)/.tlibstdcxx && $(AR) x $(LINUX_SDK_DIR)/tlibstdcxx/libtlibstdcxx.a
  112. $(AR) rcsD $@ $(BUILD_DIR)/.cpprt/*.o $(BUILD_DIR)/.tlibstdcxx/*.o
  113. @$(RM) -rf $(BUILD_DIR)/.cpprt $(BUILD_DIR)/.tlibstdcxx
  114. .PHONY: cpprt
  115. cpprt:
  116. $(MAKE) -C cpprt
  117. .PHONY: tlibstdcxx
  118. tlibstdcxx: $(BUILD_DIR)
  119. $(MAKE) -C tlibstdcxx/ 2> /dev/null
  120. $(CP) tlibstdcxx/README.sgx $(BUILD_DIR)/STLport_Changes_SGX.txt
  121. # ---------------------------------------------------
  122. # tcxx
  123. # includes: cpprt, tlibcxx
  124. # ---------------------------------------------------
  125. .PHONY: tcxx
  126. tcxx: $(LIBTCXX)
  127. $(LIBTCXX): cpprt tlibcxx
  128. @$(MKDIR) $(BUILD_DIR)/._cpprt $(BUILD_DIR)/.tlibcxx
  129. @$(RM) -f $(BUILD_DIR)/._cpprt/* $(BUILD_DIR)/.tlibcxx/*
  130. @cd $(BUILD_DIR)/._cpprt && $(AR) x $(LINUX_SDK_DIR)/cpprt/libcpprt.a
  131. @cd $(BUILD_DIR)/.tlibcxx && $(AR) x $(LINUX_SDK_DIR)/tlibcxx/libcxx.a
  132. $(AR) rcsD $@ $(BUILD_DIR)/._cpprt/*.o $(BUILD_DIR)/.tlibcxx/*.o
  133. @$(RM) -rf $(BUILD_DIR)/._cpprt $(BUILD_DIR)/.tlibcxx
  134. .PHONY: tlibcxx
  135. tlibcxx: $(BUILD_DIR)
  136. $(MAKE) -C tlibcxx/ 2> /dev/null
  137. $(CP) tlibcxx/README.sgx $(BUILD_DIR)/libc++_Changes_SGX.txt
  138. # ---------------------------------------------------
  139. # tse
  140. # includes: selib, tseal, tae_service, ec_dh_lib
  141. # ---------------------------------------------------
  142. .PHONY: tservice
  143. tservice: $(LIBTSE)
  144. $(LIBTSE): selib tseal tae_service
  145. @$(MKDIR) $(BUILD_DIR)/.tservice
  146. @$(RM) -f $(BUILD_DIR)/.tservice/*
  147. cd $(BUILD_DIR)/.tservice && $(AR) x $(LINUX_SDK_DIR)/tseal/linux/libtSeal.a
  148. cd $(BUILD_DIR)/.tservice && $(AR) x $(LINUX_SDK_DIR)/tae_service/libtae_service.a
  149. $(CP) $(LINUX_SDK_DIR)/selib/linux/libselib.a $@
  150. $(AR) rsD $@ $(BUILD_DIR)/.tservice/*.o
  151. @$(RM) -rf $(BUILD_DIR)/.tservice
  152. .PHONY: selib
  153. selib:
  154. $(MAKE) -C selib/linux/
  155. .PHONY: tseal
  156. tseal:
  157. $(MAKE) -C tseal/linux/
  158. .PHONY: tae_service
  159. tae_service: edger8r
  160. $(MAKE) -C tae_service
  161. # ---------------------------------------------------
  162. # Other trusted libraries
  163. # ---------------------------------------------------
  164. .PHONY: trts
  165. trts:
  166. $(MAKE) -C trts/
  167. .PHONY: tcrypto
  168. tcrypto:
  169. $(MAKE) -C tlibcrypto/
  170. .PHONY: tkey_exchange
  171. tkey_exchange: edger8r
  172. $(MAKE) -C tkey_exchange
  173. .PHONY: tcmalloc
  174. tcmalloc:
  175. $(MAKE) -C gperftools/
  176. .PHONY: tprotected_fs
  177. tprotected_fs: edger8r
  178. $(MAKE) -C protected_fs/sgx_tprotected_fs
  179. # ---------------------------------------------------
  180. # Untrusted libraries
  181. # ---------------------------------------------------
  182. .PHONY: ukey_exchange
  183. ukey_exchange:
  184. $(MAKE) -C ukey_exchange
  185. .PHONY: uprotected_fs
  186. uprotected_fs: edger8r
  187. $(MAKE) -C protected_fs/sgx_uprotected_fs
  188. .PHONY: ptrace
  189. ptrace:
  190. $(MAKE) -C debugger_interface/linux/
  191. .PHONY: sample_crypto
  192. sample_crypto:
  193. $(MAKE) -C sample_libcrypto
  194. # ---------------------------------------------------
  195. # standalone, untrusted libraries
  196. # ---------------------------------------------------
  197. .PHONY: libcapable
  198. libcapable:
  199. $(MAKE) -C libcapable/linux/
  200. # ---------------------------------------------------
  201. # simualtion libraries and tools
  202. # ---------------------------------------------------
  203. .PHONY: simulation
  204. simulation: edger8r
  205. $(MAKE) -C simulation/
  206. # ---------------------------------------------------
  207. # tools
  208. # ---------------------------------------------------
  209. .PHONY: signtool
  210. signtool:
  211. $(MAKE) -C sign_tool/SignTool/
  212. .PHONY: edger8r
  213. edger8r:
  214. $(MAKE) -C edger8r/linux/
  215. $(BUILD_DIR):
  216. $(MKDIR) $@
  217. .PHONY: clean
  218. clean:
  219. $(MAKE) -C $(LIBM_PATH) ARCH=$(M_ARCH) clean
  220. $(MAKE) -C tlibc/ clean
  221. $(MAKE) -C tlibthread/ clean
  222. $(MAKE) -C compiler-rt/ clean
  223. $(MAKE) -C cpprt clean
  224. $(MAKE) -C tlibstdcxx/ clean
  225. $(MAKE) -C tlibcxx/ clean
  226. $(MAKE) -C tseal/linux/ clean
  227. $(MAKE) -C selib/linux/ clean
  228. $(MAKE) -C tae_service/ clean
  229. $(MAKE) -C trts/ clean
  230. $(MAKE) -C tsetjmp/ clean
  231. $(MAKE) -C tsafecrt/ clean
  232. $(MAKE) -C gperftools/ clean
  233. $(MAKE) -C tlibcrypto/ clean
  234. $(MAKE) -C tkey_exchange/ clean
  235. $(MAKE) -C ukey_exchange/ clean
  236. $(MAKE) -C protected_fs/sgx_tprotected_fs/ clean
  237. $(MAKE) -C protected_fs/sgx_uprotected_fs/ clean
  238. $(MAKE) -C debugger_interface/linux/ clean
  239. $(MAKE) -C sample_libcrypto/ clean
  240. $(MAKE) -C libcapable/linux/ clean
  241. $(MAKE) -C simulation/ clean
  242. $(MAKE) -C sign_tool/SignTool clean
  243. $(MAKE) -C edger8r/linux clean
  244. @$(RM) $(LIBTLIBC) $(LIBTLIBCXX) $(LIBTSE)
  245. @$(RM) $(BUILD_DIR)/STLport_Changes_SGX.txt
  246. @$(RM) $(BUILD_DIR)/libc++_Changes_SGX.txt