Makefile.source 7.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234
  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. # - ptrace: libsgx_ptrace.so, gdb-sgx-plugin
  45. # - sample_crypto: libsample_crypto.so (for sample code use)
  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. .PHONY: all
  57. all: tstdc tstdcxx tservice trts tcrypto tkey_exchange ukey_exchange ptrace sample_crypto simulation signtool edger8r tsetjmp tcmalloc
  58. # ---------------------------------------------------
  59. # tstdc
  60. # includes: tlibc, libm, tlibthread, compiler-rt
  61. # ---------------------------------------------------
  62. .PHONY: tstdc
  63. tstdc: $(LIBTLIBC)
  64. $(LIBTLIBC): tlibthread compiler-rt sgx_libm
  65. $(MAKE) -C tlibc/ -j4 2> /dev/null
  66. @$(MKDIR) $(BUILD_DIR)/.libm $(BUILD_DIR)/.tlibc $(BUILD_DIR)/.tlibthread
  67. @$(RM) -f $(BUILD_DIR)/.libm/* $(BUILD_DIR)/.tlibc/* $(BUILD_DIR)/.tlibthread/*
  68. @cd $(BUILD_DIR)/.libm && $(AR) x $(LINUX_EXTERNAL_DIR)/sgx_libm/libm.a
  69. @cd $(BUILD_DIR)/.tlibc && $(AR) x $(LINUX_SDK_DIR)/tlibc/libtlibc.a
  70. @cd $(BUILD_DIR)/.tlibthread && $(AR) x $(LINUX_SDK_DIR)/tlibthread/libtlibthread.a
  71. $(CP) compiler-rt/libcompiler-rt.a $@
  72. $(AR) rsD $@ $(BUILD_DIR)/.libm/*.o $(BUILD_DIR)/.tlibc/*.o $(BUILD_DIR)/.tlibthread/*.o
  73. @$(RM) -rf $(BUILD_DIR)/.libm $(BUILD_DIR)/.tlibc $(BUILD_DIR)/.tlibthread
  74. .PHONY: tlibthread
  75. tlibthread:
  76. $(MAKE) -C tlibthread/
  77. .PHONY: compiler-rt
  78. compiler-rt:
  79. $(MAKE) -C compiler-rt/ 2> /dev/null
  80. LIBM_PATH = $(LINUX_EXTERNAL_DIR)/sgx_libm/
  81. M_ARCH = intel64
  82. ifneq ($(ARCH), x86_64)
  83. M_ARCH := ia32
  84. endif
  85. .PHONY: sgx_libm
  86. sgx_libm:
  87. $(MAKE) -C $(LIBM_PATH) ARCH=$(M_ARCH) 2> /dev/null
  88. # ---------------------------------------------------
  89. # tstdcxx
  90. # includes: cpprt, tlibstdcxx
  91. # ---------------------------------------------------
  92. .PHONY: tstdcxx
  93. tstdcxx: $(LIBTLIBCXX)
  94. $(LIBTLIBCXX): cpprt tlibstdcxx
  95. @$(MKDIR) $(BUILD_DIR)/.cpprt $(BUILD_DIR)/.tlibstdcxx
  96. @$(RM) -f $(BUILD_DIR)/.cpprt/* $(BUILD_DIR)/.tlibstdcxx/*
  97. @cd $(BUILD_DIR)/.cpprt && $(AR) x $(LINUX_SDK_DIR)/cpprt/libcpprt.a
  98. @cd $(BUILD_DIR)/.tlibstdcxx && $(AR) x $(LINUX_SDK_DIR)/tlibstdcxx/libtlibstdcxx.a
  99. $(AR) rcsD $@ $(BUILD_DIR)/.cpprt/*.o $(BUILD_DIR)/.tlibstdcxx/*.o
  100. @$(RM) -rf $(BUILD_DIR)/.cpprt $(BUILD_DIR)/.tlibstdcxx
  101. .PHONY: cpprt
  102. cpprt:
  103. $(MAKE) -C cpprt
  104. .PHONY: tlibstdcxx
  105. tlibstdcxx: $(BUILD_DIR)
  106. $(MAKE) -C tlibstdcxx/ 2> /dev/null
  107. $(CP) tlibstdcxx/README.sgx $(BUILD_DIR)/STLport_Changes_SGX.txt
  108. # ---------------------------------------------------
  109. # tse
  110. # includes: selib, tseal, tae_service, ec_dh_lib
  111. # ---------------------------------------------------
  112. .PHONY: tservice
  113. tservice: $(LIBTSE)
  114. $(LIBTSE): selib tseal tae_service
  115. @$(MKDIR) $(BUILD_DIR)/.tservice
  116. @$(RM) -f $(BUILD_DIR)/.tservice/*
  117. cd $(BUILD_DIR)/.tservice && $(AR) x $(LINUX_SDK_DIR)/tseal/linux/libtSeal.a
  118. cd $(BUILD_DIR)/.tservice && $(AR) x $(LINUX_SDK_DIR)/tae_service/libtae_service.a
  119. $(CP) $(LINUX_SDK_DIR)/selib/linux/libselib.a $@
  120. $(AR) rsD $@ $(BUILD_DIR)/.tservice/*.o
  121. @$(RM) -rf $(BUILD_DIR)/.tservice
  122. .PHONY: selib
  123. selib:
  124. $(MAKE) -C selib/linux/
  125. .PHONY: tseal
  126. tseal:
  127. $(MAKE) -C tseal/linux/
  128. .PHONY: tae_service
  129. tae_service: edger8r
  130. $(MAKE) -C tae_service
  131. # ---------------------------------------------------
  132. # Other trusted libraries
  133. # ---------------------------------------------------
  134. .PHONY: trts
  135. trts:
  136. $(MAKE) -C trts/
  137. .PHONY: tcrypto
  138. tcrypto:
  139. $(MAKE) -C tlibcrypto/
  140. .PHONY: tkey_exchange
  141. tkey_exchange: edger8r
  142. $(MAKE) -C tkey_exchange
  143. .PHONY: tsetjmp
  144. tsetjmp:
  145. $(MAKE) -C tsetjmp/
  146. .PHONY: tcmalloc
  147. tcmalloc:
  148. $(MAKE) -C gperftools/
  149. # ---------------------------------------------------
  150. # Untrusted libraries
  151. # ---------------------------------------------------
  152. .PHONY: ukey_exchange
  153. ukey_exchange:
  154. $(MAKE) -C ukey_exchange
  155. .PHONY: ptrace
  156. ptrace:
  157. $(MAKE) -C debugger_interface/linux/
  158. .PHONY: sample_crypto
  159. sample_crypto:
  160. $(MAKE) -C sample_libcrypto
  161. # ---------------------------------------------------
  162. # simualtion libraries and tools
  163. # ---------------------------------------------------
  164. .PHONY: simulation
  165. simulation: edger8r
  166. $(MAKE) -C simulation/
  167. # ---------------------------------------------------
  168. # tools
  169. # ---------------------------------------------------
  170. .PHONY: signtool
  171. signtool:
  172. $(MAKE) -C sign_tool/SignTool/
  173. .PHONY: edger8r
  174. edger8r:
  175. $(MAKE) -C edger8r/linux/
  176. $(BUILD_DIR):
  177. $(MKDIR) $@
  178. .PHONY: clean
  179. clean:
  180. $(MAKE) -C $(LIBM_PATH) ARCH=$(M_ARCH) clean
  181. $(MAKE) -C tlibc/ clean
  182. $(MAKE) -C tlibthread/ clean
  183. $(MAKE) -C compiler-rt/ clean
  184. $(MAKE) -C cpprt clean
  185. $(MAKE) -C tlibstdcxx/ clean
  186. $(MAKE) -C tseal/linux/ clean
  187. $(MAKE) -C selib/linux/ clean
  188. $(MAKE) -C tae_service/ clean
  189. $(MAKE) -C trts/ clean
  190. $(MAKE) -C tsetjmp/ clean
  191. $(MAKE) -C gperftools/ clean
  192. $(MAKE) -C tlibcrypto/ clean
  193. $(MAKE) -C tkey_exchange/ clean
  194. $(MAKE) -C ukey_exchange/ clean
  195. $(MAKE) -C debugger_interface/linux/ clean
  196. $(MAKE) -C sample_libcrypto/ clean
  197. $(MAKE) -C simulation/ clean
  198. $(MAKE) -C sign_tool/SignTool clean
  199. $(MAKE) -C edger8r/linux clean
  200. @$(RM) $(LIBTLIBC) $(LIBTLIBCXX) $(LIBTSE)
  201. @$(RM) $(BUILD_DIR)/STLport_Changes_SGX.txt