Makefile.source 10 KB

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