Makefile 1.6 KB
Newer Older
1 2 3 4 5 6
ifndef OBJCOPY
OBJCOPY := $(CROSS_COMPILE)objcopy
endif

OUTPUT ?= ./
HOST_CFLAGS := -Wall -Werror -g -fPIC -z noexecstack \
7
	       -Wno-unused-const-variable -std=gnu11
8
ENCL_CFLAGS := -Wall -Werror -static -nostdlib -nostartfiles -fPIC \
9
	       -fno-stack-protector -mrdrnd -std=gnu11
10
HOST_LDFLAGS := -fPIC -shared -Wl,-Bsymbolic
11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57

TEST_CUSTOM_PROGS := $(OUTPUT)/encl.bin $(OUTPUT)/encl.ss $(OUTPUT)/liberpal-skeleton.so $(OUTPUT)/signing_key.pem $(OUTPUT)/encl.token

all: $(TEST_CUSTOM_PROGS)

$(OUTPUT)/liberpal-skeleton.so: $(OUTPUT)/sgx_call.o $(OUTPUT)/liberpal-skeleton.o
	$(CC) $(HOST_LDFLAGS) -o $@ $^

$(OUTPUT)/liberpal-skeleton.o: liberpal-skeleton.c
	$(CC) $(HOST_CFLAGS) -c $< -o $@

$(OUTPUT)/sgx_call.o: sgx_call.S
	$(CC) $(HOST_CFLAGS) -c $< -o $@

$(OUTPUT)/encl.bin: $(OUTPUT)/encl.elf $(OUTPUT)/sgxsign
	$(OBJCOPY) -O binary $< $@

$(OUTPUT)/encl.elf: encl.lds encl.c encl_bootstrap.S
	$(CC) $(ENCL_CFLAGS) -T $^ -o $@

$(OUTPUT)/signing_key.pem:
	openssl genrsa -3 -out $@ 3072

$(OUTPUT)/encl.ss: $(OUTPUT)/encl.bin $(OUTPUT)/signing_key.pem
	$(OUTPUT)/sgxsign signing_key.pem $(OUTPUT)/encl.bin $(OUTPUT)/encl.ss

$(OUTPUT)/encl.token: $(OUTPUT)/encl.ss
	runectl gen-token --signature encl.ss --token $@

$(OUTPUT)/sgxsign: sgxsign.c
	$(CC) -I../include -o $@ $< -lcrypto

EXTRA_CLEAN := \
	$(OUTPUT)/encl.bin \
	$(OUTPUT)/encl.elf \
	$(OUTPUT)/encl.ss \
	$(OUTPUT)/sgx_call.o \
	$(OUTPUT)/sgxsign \
	$(OUTPUT)/liberpal-skeleton.o \
	$(OUTPUT)/liberpal-skeleton.so \
	$(OUTPUT)/signing_key.pem \
	$(OUTPUT)/encl.token

clean:
	rm -f ${EXTRA_CLEAN}

.PHONY: clean all