Makefile 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132
  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. include ../../buildenv.mk
  32. CPPFLAGS := -I$(COMMON_DIR)/inc/internal \
  33. -I$(COMMON_DIR)/inc \
  34. -I$(COMMON_DIR)/inc/tlibc
  35. CXXFLAGS += $(ENCLAVE_CXXFLAGS) -Werror -fno-exceptions -fno-rtti
  36. OBJ = init_tcrypto_lib.o sgx_aes_ctr.o sgx_aes_gcm.o sgx_cmac128.o sgx_ecc256.o sgx_ecc256_ecdsa.o sgx_sha256.o sgx_sha256_msg.o sgx_ecc256_internal.o sgx_rsa3072.o
  37. SHARED_OBJ = tcrypto_version.o
  38. ifneq ($(USE_OPT_LIBS), 1)
  39. # Added to build with SgxSSL libraries
  40. ifeq ($(ARCH), x86_64)
  41. OPENSSL_PACKAGE = $(LINUX_EXTERNAL_DIR)/sgxssl/Linux/package
  42. else
  43. $(error SGXSSL doesn't support 32bit)
  44. endif #($(ARCH), x86_64)
  45. ifdef DEBUG
  46. OPENSSL_LIBRARY_PATH := $(OPENSSL_PACKAGE)/lib64/debug
  47. else
  48. OPENSSL_LIBRARY_PATH := $(OPENSSL_PACKAGE)/lib64/release
  49. endif
  50. SGXSSL_Library_Name := sgx_tsgxssl
  51. OpenSSL_Crypto_Library_Name := sgx_tsgxssl_crypto
  52. PREPARE_SGXSSL := $(LINUX_EXTERNAL_DIR)/sgxssl/prepare_sgxssl.sh
  53. PREPRARE_SGX_SSL:
  54. chmod 755 $(PREPARE_SGXSSL)
  55. test -f $(OPENSSL_LIBRARY_PATH)/lib$(SGXSSL_Library_Name).a || $(PREPARE_SGXSSL)
  56. CPPFLAGS += -I$(OPENSSL_PACKAGE)/include
  57. CXXFLAGS += -DUSE_SGXSSL
  58. SRCDIR := sgxssl
  59. LIB_NAME := libsgx_tcrypto_sgxssl.a
  60. else
  61. CPPFLAGS += -I$(SGX_IPP_INC)
  62. OBJ += sgx_ecc256_common.o
  63. SRCDIR := ipp
  64. LIB_NAME := libsgx_tcrypto_ipp.a
  65. endif #!($(USE_OPT_LIBS), 1)
  66. OBJ := $(addprefix $(SRCDIR)/, $(OBJ))
  67. LIB_NAME := $(addprefix $(SRCDIR)/, $(LIB_NAME))
  68. TARGET := libsgx_tcrypto.a
  69. ifneq ($(USE_OPT_LIBS), 1)
  70. $(TARGET): PREPRARE_SGX_SSL
  71. $(MAKE) $(OBJ)
  72. $(MAKE) $(SHARED_OBJ)
  73. $(MKDIR) $(BUILD_DIR)/.libs
  74. $(RM) $(BUILD_DIR)/.libs/*
  75. cd $(BUILD_DIR)/.libs && \
  76. $(AR) x $(OPENSSL_LIBRARY_PATH)/lib$(OpenSSL_Crypto_Library_Name).a && \
  77. $(AR) x $(OPENSSL_LIBRARY_PATH)/lib$(SGXSSL_Library_Name).a
  78. $(AR) rsD $(LIB_NAME) $(OBJ) $(SHARED_OBJ) $(BUILD_DIR)/.libs/*.o
  79. $(CP) $(LIB_NAME) $@
  80. $(RM) -r $(BUILD_DIR)/.libs
  81. else
  82. $(TARGET): $(OBJ) $(SHARED_OBJ)
  83. $(MKDIR) $(BUILD_DIR)/.libippcore
  84. $(RM) $(BUILD_DIR)/.libippcore/*
  85. cd $(BUILD_DIR)/.libippcore && $(AR) x $(IPP_LIBS_DIR)/libippcore.a
  86. @$(CP) $(IPP_LIBS_DIR)/libippcp.a $(LIB_NAME)
  87. $(AR) rsD $(LIB_NAME) $(OBJ) $(SHARED_OBJ) $(BUILD_DIR)/.libippcore/*.o
  88. $(CP) $(LIB_NAME) $@
  89. $(RM) -r $(BUILD_DIR)/.libippcore
  90. endif #!($(USE_OPT_LIBS), 1)
  91. $(SRCDIR)/%.o: $(SRCDIR)/%.cpp
  92. $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) $< -o $@
  93. $(SHARED_OBJ): %.o: %.cpp
  94. $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) $< -o $@
  95. $(BUILD_DIR):
  96. @$(MKDIR) $@
  97. .PHONY: all
  98. all: $(TARGET) | $(BUILD_DIR)
  99. @$(CP) $< $|
  100. .PHONY: clean
  101. clean:
  102. @$(RM) *.o ipp/*.o sgxssl/*.o $(TARGET) $(BUILD_DIR)/$(TARGET) $(LIB_NAME)
  103. .PHONY: rebuild
  104. rebuild:
  105. $(MAKE) clean
  106. $(MAKE) all