sgx_u.without_app.mk 1.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071
  1. ######## Intel(R) SGX SDK Settings ########
  2. SGX_SDK ?= $(SdkPathFromPlugin)
  3. SGX_MODE ?= SIM
  4. SGX_ARCH ?= x64
  5. UNTRUSTED_DIR=untrusted
  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_EDGER8R := $(SGX_SDK)/bin/x86/sgx_edger8r
  14. else
  15. SGX_COMMON_CFLAGS := -m64
  16. SGX_EDGER8R := $(SGX_SDK)/bin/x64/sgx_edger8r
  17. endif
  18. ifeq ($(SGX_DEBUG), 1)
  19. ifeq ($(SGX_PRERELEASE), 1)
  20. $(error Cannot set SGX_DEBUG and SGX_PRERELEASE at the same time!!)
  21. endif
  22. endif
  23. ifeq ($(SGX_DEBUG), 1)
  24. SGX_COMMON_CFLAGS += -O0 -g
  25. else
  26. SGX_COMMON_CFLAGS += -O2
  27. endif
  28. ######## App Settings ########
  29. App_Include_Paths := -IInclude -I$(UNTRUSTED_DIR) -I$(SGX_SDK)/include
  30. App_C_Flags := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes $(App_Include_Paths)
  31. # Three configuration modes - Debug, prerelease, release
  32. # Debug - Macro DEBUG enabled.
  33. # Prerelease - Macro NDEBUG and EDEBUG enabled.
  34. # Release - Macro NDEBUG enabled.
  35. ifeq ($(SGX_DEBUG), 1)
  36. App_C_Flags += -DDEBUG -UNDEBUG -UEDEBUG
  37. else ifeq ($(SGX_PRERELEASE), 1)
  38. App_C_Flags += -DNDEBUG -DEDEBUG -UDEBUG
  39. else
  40. App_C_Flags += -DNDEBUG -UEDEBUG -UDEBUG
  41. endif
  42. App_Cpp_Flags := $(App_C_Flags) -std=c++11
  43. .PHONY: all run
  44. all: $(UNTRUSTED_DIR)/$(enclaveName)_u.o
  45. ######## App Objects ########
  46. $(UNTRUSTED_DIR)/$(enclaveName)_u.c: $(SGX_EDGER8R) trusted/$(enclaveName).edl
  47. @mkdir -p $(UNTRUSTED_DIR)
  48. @cd $(UNTRUSTED_DIR) && $(SGX_EDGER8R) --untrusted ../trusted/$(enclaveName).edl --search-path ../trusted --search-path $(SGX_SDK)/include
  49. @echo "GEN => $@"
  50. $(UNTRUSTED_DIR)/$(enclaveName)_u.o: $(UNTRUSTED_DIR)/$(enclaveName)_u.c
  51. @$(CC) $(App_C_Flags) -c $< -o $@
  52. @echo "CC <= $<"
  53. .PHONY: clean
  54. clean:
  55. @rm -f $(UNTRUSTED_DIR)/$(enclaveName)_u.*