Makefile 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134
  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. CFLAGS += $(CPPFLAGS) $(ENCLAVE_CFLAGS) $(SGX_COMMON_CFLAGS) -Werror -fno-exceptions -fPIC
  64. OBJ += sgx_tcrypto_common.o sgx_rsa_internal.o
  65. SRCDIR := ipp
  66. C_Files := $(wildcard $(SRCDIR)/ipp_disp/*.c)
  67. C_OBJS := $(C_Files:.c=.o)
  68. C_OBJS := $(sort $(C_OBJS))
  69. LIB_NAME := libsgx_tcrypto_ipp.a
  70. endif #!($(USE_OPT_LIBS), 1)
  71. OBJ := $(addprefix $(SRCDIR)/, $(OBJ))
  72. LIB_NAME := $(addprefix $(SRCDIR)/, $(LIB_NAME))
  73. TARGET := libsgx_tcrypto.a
  74. ifneq ($(USE_OPT_LIBS), 1)
  75. $(TARGET): PREPRARE_SGX_SSL
  76. $(MAKE) $(OBJ)
  77. $(MAKE) $(SHARED_OBJ)
  78. $(MKDIR) $(BUILD_DIR)/.libs
  79. $(RM) $(BUILD_DIR)/.libs/*
  80. cd $(BUILD_DIR)/.libs && \
  81. $(AR) x $(OPENSSL_LIBRARY_PATH)/lib$(OpenSSL_Crypto_Library_Name).a && \
  82. $(AR) x $(OPENSSL_LIBRARY_PATH)/lib$(SGXSSL_Library_Name).a
  83. $(AR) rsD $(LIB_NAME) $(OBJ) $(SHARED_OBJ) $(BUILD_DIR)/.libs/*.o
  84. $(CP) $(LIB_NAME) $@
  85. $(RM) -r $(BUILD_DIR)/.libs
  86. else
  87. $(TARGET): $(OBJ) $(SHARED_OBJ) $(C_OBJS)
  88. @$(CP) $(IPP_LIBS_DIR)/libippcp.a $(LIB_NAME)
  89. $(AR) rsD $(LIB_NAME) $(OBJ) $(SHARED_OBJ) $(C_OBJS)
  90. $(CP) $(LIB_NAME) $@
  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 ipp/ipp_disp/*.o sgxssl/*.o $(TARGET) $(BUILD_DIR)/$(TARGET) $(LIB_NAME)
  104. .PHONY: rebuild
  105. rebuild:
  106. $(MAKE) clean
  107. $(MAKE) all