82 lines
2.4 KiB
Makefile
82 lines
2.4 KiB
Makefile
SGX_SDK ?= /opt/intel/sgxsdk
|
|
SGX_MODE ?= HW
|
|
SGX_ARCH ?= x64
|
|
|
|
ifeq ($(shell getconf LONG_BIT), 32)
|
|
SGX_ARCH := x86
|
|
else ifeq ($(findstring -m32, $(CXXFLAGS)), -m32)
|
|
SGX_ARCH := x86
|
|
endif
|
|
|
|
ifeq ($(SGX_ARCH), x86)
|
|
SGX_COMMON_CFLAGS := -m32
|
|
SGX_LIBRARY_PATH := $(SGX_SDK)/lib
|
|
SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x86/sgx_sign
|
|
SGX_EDGER8R := $(SGX_SDK)/bin/x86/sgx_edger8r
|
|
else
|
|
SGX_COMMON_CFLAGS := -m64
|
|
SGX_LIBRARY_PATH := $(SGX_SDK)/lib64
|
|
SGX_ENCLAVE_SIGNER := $(SGX_SDK)/bin/x64/sgx_sign
|
|
SGX_EDGER8R := $(SGX_SDK)/bin/x64/sgx_edger8r
|
|
endif
|
|
|
|
ifeq ($(SGX_DEBUG), 1)
|
|
ifeq ($(SGX_PRERELEASE), 1)
|
|
$(error Cannot set SGX_DEBUG and SGX_PRERELEASE at the same time!!)
|
|
endif
|
|
endif
|
|
|
|
ifeq ($(SGX_DEBUG), 1)
|
|
SGX_COMMON_CFLAGS += -O0 -g
|
|
else
|
|
SGX_COMMON_CFLAGS += -O2
|
|
endif
|
|
|
|
ifneq ($(SGX_MODE), HW)
|
|
Urts_Library_Name := sgx_urts_sim
|
|
else
|
|
Urts_Library_Name := sgx_urts
|
|
endif
|
|
|
|
ifneq ($(SGX_MODE), HW)
|
|
Trts_Library_Name := sgx_trts_sim
|
|
Service_Library_Name := sgx_tservice_sim
|
|
else
|
|
Trts_Library_Name := sgx_trts
|
|
Service_Library_Name := sgx_tservice
|
|
endif
|
|
Crypto_Library_Name := sgx_tcrypto
|
|
KeyExchange_Library_Name := sgx_tkey_exchange
|
|
ProtectedFs_Library_Name := sgx_tprotected_fs
|
|
|
|
|
|
#
|
|
# Export flags used to compile or link untrusted modules
|
|
#
|
|
SGX_CFLAGS_U := $(SGX_COMMON_CFLAGS) -fPIC -Wno-attributes
|
|
SGX_CFLAGS_U += -I$(SGX_SDK)/include
|
|
|
|
SGX_LFLAGS_U := $(SGX_COMMON_CFLAGS) -lpthread
|
|
SGX_LFLAGS_U += -L$(SGX_LIBRARY_PATH) -l$(Urts_Library_Name)
|
|
ifneq ($(SGX_MODE), HW)
|
|
SGX_LFLAGS_U += -lsgx_uae_service_sim
|
|
else
|
|
SGX_LFLAGS_U += -lsgx_uae_service
|
|
endif
|
|
|
|
#
|
|
# Export flags used to compile or link untrusted modules
|
|
#
|
|
SGX_CFLAGS_T := $(SGX_COMMON_CFLAGS) -nostdinc -fvisibility=hidden -fpie -fstack-protector
|
|
SGX_CFLAGS_T += -I$(SGX_SDK)/include -I$(SGX_SDK)/include/tlibc -I$(SGX_SDK)/include/stlport -I$(SGX_SDK)/include/epid
|
|
# Before use this linker flag, the user should define $(Other_Enclave_Libs),
|
|
# which lists all libraries that are to be part of the enclave.
|
|
SGX_LFLAGS_T = $(SGX_COMMON_CFLAGS) -Wl,--no-undefined -nostdlib -nodefaultlibs -nostartfiles -L$(SGX_LIBRARY_PATH) $(Other_Link_Flags) \
|
|
-Wl,--whole-archive -l$(Trts_Library_Name) -Wl,--no-whole-archive \
|
|
-Wl,--start-group -lsgx_tstdc -lsgx_tstdcxx -l$(Crypto_Library_Name) $(Other_Enclave_Libs) -Wl,--end-group \
|
|
-Wl,-Bstatic -Wl,-Bsymbolic -Wl,--no-undefined \
|
|
-Wl,-pie,-eenclave_entry -Wl,--export-dynamic \
|
|
-Wl,--defsym,__ImageBase=0 \
|
|
-Wl,--gc-sections \
|
|
-Wl,--version-script=Enclave.lds
|