sgx_u.without_app.mk 1.8 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970
  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. .PHONY: all run
  43. all: $(UNTRUSTED_DIR)/$(enclaveName)_u.o
  44. ######## App Objects ########
  45. $(UNTRUSTED_DIR)/$(enclaveName)_u.c: $(SGX_EDGER8R) trusted/$(enclaveName).edl
  46. @mkdir -p $(UNTRUSTED_DIR)
  47. @cd $(UNTRUSTED_DIR) && $(SGX_EDGER8R) --untrusted ../trusted/$(enclaveName).edl --search-path ../trusted --search-path $(SGX_SDK)/include
  48. @echo "GEN => $@"
  49. $(UNTRUSTED_DIR)/$(enclaveName)_u.o: $(UNTRUSTED_DIR)/$(enclaveName)_u.c
  50. @$(CC) $(App_C_Flags) -c $< -o $@
  51. @echo "CC <= $<"
  52. .PHONY: clean
  53. clean:
  54. @rm -f $(UNTRUSTED_DIR)/$(enclaveName)_u.*