Makefile 4.3 KB

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