Makefile 7.4 KB

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