forked from jinengandhi-intel/graphene_local_ci
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile.Test
94 lines (74 loc) · 2.25 KB
/
Makefile.Test
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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
LTP_DIR := $(dir $(lastword $(MAKEFILE_LIST)))
SYS ?= $(shell gcc -dumpmachine)
export SYS
PALDIR = $(LTP_DIR)/../../../../Pal/src
SHIMDIR = $(LTP_DIR)/../../src
CC = gcc
CXX = g++
CFLAGS =
CXXFLAGS =
LDFLAGS =
.PHONY: default
default: all
ifeq ($(SGX),1)
expand_target = $(1) $(foreach t,$(filter-out manifest,$(1)), \
$(patsubst %.manifest,%,$(t)).manifest.sgx)
else
expand_target = $(1)
endif
.PHONY: all
all: $(target) | $(call expand_target,$(exec_target))
ifeq ($(DEBUG),1)
CC += -g
CXX += -g
endif
export DEBUG
ifeq ($(WERROR),1)
CFLAGS += -Werror
endif
COREUTILS_LIBDIR := /usr/$(ARCH_LIBDIR)/coreutils
ifeq ($(wildcard $(COREUTILS_LIBDIR)/*),)
COREUTILS_LIBDIR := /usr/libexec/coreutils
ifeq ($(wildcard $(COREUTILS_LIBDIR)/*),)
$(error Cannot determine coreutils libdir)
endif
endif
manifest_rules = \
-Darch_libdir=$(ARCH_LIBDIR) \
-Dcoreutils_libdir=$(COREUTILS_LIBDIR) \
$(extra_rules)
relative-to = $(shell python -c "import os.path; print os.path.relpath(\"$(abspath $2)\",\"$(abspath $1)\")")
%.manifest: %.manifest.template
@echo [ $@ ]
RELDIR=$(filter-out ./,$(call relative-to,$(dir $@),$(shell pwd))/) && \
gramine-manifest \
-Dentrypoint=$* \
$(manifest_rules) \
$< > $@
%.manifest: manifest.template
@echo [ $@ ]
gramine-manifest \
-Dentrypoint=$* \
$(manifest_rules) \
$< > $@
ifeq ($(SGX),1)
SGX_DIR = $(PALDIR)/host/Linux-SGX
SGX_SIGNER_KEY ?= $(SGX_DIR)/signer/enclave-key.pem
SGX_SIGN = gramine-sgx-sign --key $(SGX_SIGNER_KEY)
# sgx manifest.sgx/sig/token
drop_manifest_suffix = $(filter-out manifest,$(sort $(patsubst %.manifest,%,$(1))))
expand_target_to_sig = $(addsuffix .sig,$(call drop_manifest_suffix,$(1)))
expand_target_to_sgx = $(addsuffix .manifest.sgx,$(call drop_manifest_suffix,$(1)))
%.sig %.manifest.sgx: %.manifest $(SGX_SIGNER_KEY) %.manifest.sgx.d
@echo [ $@ ]
@$(SGX_SIGN) --output $*.manifest.sgx --manifest $< > .output.sgx_sign.$*
.PRECIOUS: %.manifest.sgx.d
%.manifest.sgx.d: %.manifest
$(call cmd,manifest_gen_depend)
ifeq ($(filter clean,$(MAKECMDGOALS)),)
include $(addsuffix .manifest.sgx.d,$(call drop_manifest_suffix,$(manifests)))
endif
endif
.PHONY: clean
clean: $(clean-extra)
$(RM) -r $(manifests) *.token *.sig *.manifest.sgx $(target) $(wildcard *.d) .output.*