Makefile 4.4 KB

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