2
0

sgx_t_static.mk 5.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153
  1. ######## Intel(R) SGX SDK Settings ########
  2. SGX_SDK ?= /opt/intel/sgxsdk
  3. SGX_MODE ?= SIM
  4. SGX_ARCH ?= x64
  5. WOLFSSL_ROOT ?= $(shell readlink -f ../..)
  6. ifeq ($(shell getconf LONG_BIT), 32)
  7. SGX_ARCH := x86
  8. else ifeq ($(findstring -m32, $(CXXFLAGS)), -m32)
  9. SGX_ARCH := x86
  10. endif
  11. ifeq ($(SGX_ARCH), x86)
  12. SGX_COMMON_CFLAGS := -m32
  13. SGX_LIBRARY_PATH := $(SGX_SDK)/lib
  14. SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x86/sgx_sign
  15. SGX_EDGER8R := $(SGX_SDK)/bin/x86/sgx_edger8r
  16. else
  17. SGX_COMMON_CFLAGS := -m64
  18. SGX_LIBRARY_PATH := $(SGX_SDK)/lib64
  19. SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x64/sgx_sign
  20. SGX_EDGER8R := $(SGX_SDK)/bin/x64/sgx_edger8r
  21. endif
  22. ifeq ($(SGX_DEBUG), 1)
  23. ifeq ($(SGX_PRERELEASE), 1)
  24. $(error Cannot set SGX_DEBUG and SGX_PRERELEASE at the same time!!)
  25. endif
  26. endif
  27. ifeq ($(SGX_DEBUG), 1)
  28. SGX_COMMON_CFLAGS += -O0 -g
  29. else
  30. SGX_COMMON_CFLAGS += -O2
  31. endif
  32. ifneq ($(SGX_MODE), HW)
  33. Trts_Library_Name := sgx_trts_sim
  34. Service_Library_Name := sgx_tservice_sim
  35. else
  36. Trts_Library_Name := sgx_trts
  37. Service_Library_Name := sgx_tservice
  38. endif
  39. Crypto_Library_Name := sgx_tcrypto
  40. Wolfssl_C_Extra_Flags := -DWOLFSSL_SGX
  41. Wolfssl_C_Files :=$(WOLFSSL_ROOT)/wolfcrypt/src/aes.c\
  42. $(WOLFSSL_ROOT)/wolfcrypt/src/arc4.c\
  43. $(WOLFSSL_ROOT)/wolfcrypt/src/asn.c\
  44. $(WOLFSSL_ROOT)/wolfcrypt/src/blake2b.c\
  45. $(WOLFSSL_ROOT)/wolfcrypt/src/camellia.c\
  46. $(WOLFSSL_ROOT)/wolfcrypt/src/coding.c\
  47. $(WOLFSSL_ROOT)/wolfcrypt/src/chacha.c\
  48. $(WOLFSSL_ROOT)/wolfcrypt/src/chacha20_poly1305.c\
  49. $(WOLFSSL_ROOT)/src/crl.c\
  50. $(WOLFSSL_ROOT)/wolfcrypt/src/des3.c\
  51. $(WOLFSSL_ROOT)/wolfcrypt/src/dh.c\
  52. $(WOLFSSL_ROOT)/wolfcrypt/src/tfm.c\
  53. $(WOLFSSL_ROOT)/wolfcrypt/src/ecc.c\
  54. $(WOLFSSL_ROOT)/wolfcrypt/src/error.c\
  55. $(WOLFSSL_ROOT)/wolfcrypt/src/hash.c\
  56. $(WOLFSSL_ROOT)/wolfcrypt/src/kdf.c\
  57. $(WOLFSSL_ROOT)/wolfcrypt/src/hmac.c\
  58. $(WOLFSSL_ROOT)/wolfcrypt/src/integer.c\
  59. $(WOLFSSL_ROOT)/src/internal.c\
  60. $(WOLFSSL_ROOT)/src/wolfio.c\
  61. $(WOLFSSL_ROOT)/src/keys.c\
  62. $(WOLFSSL_ROOT)/wolfcrypt/src/logging.c\
  63. $(WOLFSSL_ROOT)/wolfcrypt/src/md4.c\
  64. $(WOLFSSL_ROOT)/wolfcrypt/src/md5.c\
  65. $(WOLFSSL_ROOT)/wolfcrypt/src/memory.c\
  66. $(WOLFSSL_ROOT)/src/ocsp.c\
  67. $(WOLFSSL_ROOT)/wolfcrypt/src/pkcs7.c\
  68. $(WOLFSSL_ROOT)/wolfcrypt/src/pkcs12.c\
  69. $(WOLFSSL_ROOT)/wolfcrypt/src/poly1305.c\
  70. $(WOLFSSL_ROOT)/wolfcrypt/src/wc_port.c\
  71. $(WOLFSSL_ROOT)/wolfcrypt/src/wolfmath.c\
  72. $(WOLFSSL_ROOT)/wolfcrypt/src/pwdbased.c\
  73. $(WOLFSSL_ROOT)/wolfcrypt/src/random.c\
  74. $(WOLFSSL_ROOT)/wolfcrypt/src/ripemd.c\
  75. $(WOLFSSL_ROOT)/wolfcrypt/src/rsa.c\
  76. $(WOLFSSL_ROOT)/wolfcrypt/src/dsa.c\
  77. $(WOLFSSL_ROOT)/wolfcrypt/src/sha.c\
  78. $(WOLFSSL_ROOT)/wolfcrypt/src/sha256.c\
  79. $(WOLFSSL_ROOT)/wolfcrypt/src/sha512.c\
  80. $(WOLFSSL_ROOT)/wolfcrypt/src/signature.c\
  81. $(WOLFSSL_ROOT)/wolfcrypt/src/sp_c32.c\
  82. $(WOLFSSL_ROOT)/wolfcrypt/src/sp_c64.c\
  83. $(WOLFSSL_ROOT)/wolfcrypt/src/sp_int.c\
  84. $(WOLFSSL_ROOT)/src/ssl.c\
  85. $(WOLFSSL_ROOT)/src/tls.c\
  86. $(WOLFSSL_ROOT)/wolfcrypt/src/wc_encrypt.c\
  87. $(WOLFSSL_ROOT)/wolfcrypt/src/wolfevent.c\
  88. Wolfssl_Include_Paths := -I$(WOLFSSL_ROOT)/ \
  89. -I$(WOLFSSL_ROOT)/wolfcrypt/ \
  90. -I$(SGX_SDK)/include -I$(SGX_SDK)/include/tlibc -I$(SGX_SDK)/include/stlport
  91. ifeq ($(HAVE_WOLFSSL_TEST), 1)
  92. Wolfssl_Include_Paths += -I$(WOLFSSL_ROOT)/wolfcrypt/test
  93. Wolfssl_C_Files += $(WOLFSSL_ROOT)/wolfcrypt/test/test.c
  94. endif
  95. ifeq ($(HAVE_WOLFSSL_BENCHMARK), 1)
  96. Wolfssl_C_Files += $(WOLFSSL_ROOT)/wolfcrypt/benchmark/benchmark.c
  97. Wolfssl_Include_Paths += -I$(WOLFSSL_ROOT)/wolfcrypt/benchmark/
  98. endif
  99. ifeq ($(HAVE_WOLFSSL_SP), 1)
  100. Wolfssl_C_Extra_Flags += -DWOLFSSL_HAVE_SP_RSA \
  101. -DWOLFSSL_HAVE_SP_DH \
  102. -DWOLFSSL_HAVE_SP_ECC
  103. endif
  104. Flags_Just_For_C := -Wno-implicit-function-declaration -std=c99
  105. Common_C_Cpp_Flags := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden -fpie -fstack-protector $(Wolfssl_Include_Paths) -fno-builtin-printf -I.
  106. Wolfssl_C_Flags := $(Flags_Just_For_C) $(Common_C_Cpp_Flags) $(Wolfssl_C_Extra_Flags)
  107. Wolfssl_Link_Flags := $(SGX_COMMON_CFLAGS) -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L$(SGX_LIBRARY_PATH) \
  108. -Wl,--whole-archive -l$(Trts_Library_Name) -Wl,--no-whole-archive \
  109. -Wl,--start-group -lsgx_tstdc -lsgx_tstdcxx -l$(Crypto_Library_Name) -l$(Service_Library_Name) -Wl,--end-group \
  110. -Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined \
  111. -Wl,-pie,-eenclave_entry -Wl,--export-dynamic \
  112. -Wl,--defsym,__ImageBase=0 \
  113. -Wl,--version-script=trusted/wolfcrypt.lds
  114. Wolfssl_C_Objects := $(Wolfssl_C_Files:.c=.o)
  115. ifeq ($(SGX_MODE), HW)
  116. ifneq ($(SGX_DEBUG), 1)
  117. ifneq ($(SGX_PRERELEASE), 1)
  118. Build_Mode = HW_RELEASE
  119. endif
  120. endif
  121. endif
  122. override CFLAGS += $(Wolfssl_C_Flags)
  123. .PHONY: all run
  124. all: libwolfssl.sgx.static.lib.a
  125. ######## WolfSSL Objects ########
  126. libwolfssl.sgx.static.lib.a: $(Wolfssl_C_Objects)
  127. ar rcs libwolfssl.sgx.static.lib.a $(Wolfssl_C_Objects)
  128. @echo "LINK => $@"
  129. clean:
  130. @rm -f $(WOLFSSL_ROOT)/wolfcrypt/benchmark/*.o $(WOLFSSL_ROOT)/wolfcrypt/test/*.o static_trusted/wolfssl_t.* libwolfssl.sgx.static.lib.a $(Wolfssl_C_Objects)