-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
68 lines (56 loc) · 1.88 KB
/
Makefile
1
2
3
4
5
6
7
8
9
10
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
58
59
60
61
62
63
64
65
66
67
68
CFLAGS = -Wall -Wextra -Dsgx=enabled
ifeq ($(DEBUG),1)
GRAMINE_LOG_LEVEL = debug
CFLAGS += -g
else
GRAMINE_LOG_LEVEL = error
CFLAGS += -O3
endif
.PHONY: all
all: main main.manifest
ifeq ($(SGX),1)
all: main.manifest.sgx main.sig main.token
endif
main: main.o grouping.c quicksort.c mergesort.c printfunctions.c insertionsort.c
main.o: main.c
main.manifest: main.manifest.template
gramine-manifest \
-Dlog_level=$(GRAMINE_LOG_LEVEL) \
$< $@
# gramine-sgx-sign generates both a .sig file and a .manifest.sgx file. This is somewhat
# hard to express properly in Make. The simple solution would be to use
# "Rules with Grouped Targets" (`&:`), however make on Ubuntu <= 20.04 doesn't support it.
#
# Simply using a normal rule with "two targets" is equivalent to creating separate rules
# for each of the targets, and when using `make -j`, this might cause two instances
# of gramine-sgx-sign to get launched simultaneously, potentially breaking the build.#
# As a workaround, we use a dummy intermediate target, and mark both files as depending on it, to
# get the dependency graph we want. We mark this dummy target as .INTERMEDIATE, which means
# that make will consider the source tree up-to-date even if the sgx_sign file doesn't exist,
# as long as the other dependencies check out. This is in contrast to .PHONY, which would
# be rebuilt on every invocation of make.
main.sig main.manifest.sgx: sgx_sign
@:
.INTERMEDIATE: sgx_sign
sgx_sign: main.manifest main
gramine-sgx-sign \
--manifest $< \
--output $<.sgx
main.token: main.sig
gramine-sgx-get-token \
--output $@ --sig $<
ifeq ($(SGX),)
GRAMINE = gramine-direct
else
GRAMINE = gramine-sgx
endif
.PHONY: check
check: all
$(GRAMINE) helloworld > OUTPUT
echo "Hello, world" | diff OUTPUT -
@echo "[ Success ]"
.PHONY: clean
clean:
$(RM) *.token *.sig *.manifest.sgx *.manifest main.o main OUTPUT
.PHONY: distclean
distclean: clean