Makefile 4.2 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_rsa_encryption.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. SGX_COMMON_CFLAGS += -O0
  47. OPENSSL_LIBRARY_PATH := $(OPENSSL_PACKAGE)/lib64/debug
  48. else
  49. OPENSSL_LIBRARY_PATH := $(OPENSSL_PACKAGE)/lib64/release
  50. endif
  51. OpenSSL_Crypto_Library_Name := sgx_tsgxssl_crypto
  52. SGXSSL_Library_Name := sgx_tsgxssl
  53. PREPARE_SGXSSL := $(LINUX_EXTERNAL_DIR)/sgxssl/prepare_sgxssl.sh
  54. PREPRARE_SGX_SSL:
  55. chmod 755 $(PREPARE_SGXSSL)
  56. test -f $(OPENSSL_LIBRARY_PATH)/lib$(SGXSSL_Library_Name).a || $(PREPARE_SGXSSL)
  57. CPPFLAGS += -I$(OPENSSL_PACKAGE)/include
  58. CXXFLAGS += -DUSE_SGXSSL
  59. SRCDIR := sgxssl
  60. LIB_NAME := libsgx_tcrypto_sgxssl.a
  61. else
  62. CPPFLAGS += -I$(SGX_IPP_INC)
  63. OBJ += sgx_ecc256_common.o sgx_rsa_internal.o
  64. SRCDIR := ipp
  65. LIB_NAME := libsgx_tcrypto_ipp.a
  66. endif #!($(USE_OPT_LIBS), 1)
  67. OBJ := $(addprefix $(SRCDIR)/, $(OBJ))
  68. LIB_NAME := $(addprefix $(SRCDIR)/, $(LIB_NAME))
  69. TARGET := libsgx_tcrypto.a
  70. ifneq ($(USE_OPT_LIBS), 1)
  71. $(TARGET): PREPRARE_SGX_SSL
  72. $(MAKE) $(OBJ)
  73. $(MAKE) $(SHARED_OBJ)
  74. $(MKDIR) $(BUILD_DIR)/.libs
  75. $(RM) $(BUILD_DIR)/.libs/*
  76. cd $(BUILD_DIR)/.libs && \
  77. $(AR) x $(OPENSSL_LIBRARY_PATH)/lib$(OpenSSL_Crypto_Library_Name).a && \
  78. $(AR) x $(OPENSSL_LIBRARY_PATH)/lib$(SGXSSL_Library_Name).a
  79. $(AR) rsD $(LIB_NAME) $(OBJ) $(SHARED_OBJ) $(BUILD_DIR)/.libs/*.o
  80. $(CP) $(LIB_NAME) $@
  81. $(RM) -r $(BUILD_DIR)/.libs
  82. else
  83. $(TARGET): $(OBJ) $(SHARED_OBJ)
  84. $(MKDIR) $(BUILD_DIR)/.libippcore
  85. $(RM) $(BUILD_DIR)/.libippcore/*
  86. cd $(BUILD_DIR)/.libippcore && $(AR) x $(IPP_LIBS_DIR)/libippcore.a
  87. @$(CP) $(IPP_LIBS_DIR)/libippcp.a $(LIB_NAME)
  88. $(AR) rsD $(LIB_NAME) $(OBJ) $(SHARED_OBJ) $(BUILD_DIR)/.libippcore/*.o
  89. $(CP) $(LIB_NAME) $@
  90. $(RM) -r $(BUILD_DIR)/.libippcore
  91. endif #!($(USE_OPT_LIBS), 1)
  92. $(SRCDIR)/%.o: $(SRCDIR)/%.cpp
  93. $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) $< -o $@
  94. $(SHARED_OBJ): %.o: %.cpp
  95. $(CXX) -c $(CXXFLAGS) $(CPPFLAGS) $< -o $@
  96. $(BUILD_DIR):
  97. @$(MKDIR) $@
  98. .PHONY: all
  99. all: $(TARGET) | $(BUILD_DIR)
  100. @$(CP) $< $|
  101. .PHONY: clean
  102. clean:
  103. @$(RM) *.o ipp/*.o sgxssl/*.o $(TARGET) $(BUILD_DIR)/$(TARGET) $(LIB_NAME)
  104. .PHONY: rebuild
  105. rebuild:
  106. $(MAKE) clean
  107. $(MAKE) all