Makefile 7.6 KB

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