forked from gramineproject/graphene
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile.rules
144 lines (112 loc) · 4.42 KB
/
Makefile.rules
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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
#
# All Makefiles must follow the following conventions:
#
# - Compilation and linking steps must be done via the 'cmd' function:
# e.g., use '$(call cmd,ld_so_o)' to create a shared library using LD
#
# - File-specific build flags must be specified via variables of the format 'FLAG-filename':
# e.g., use 'LDFLAGS-libsysdb.so=...' to specify libsysdb.so-specific linker flags
#
ifeq ("$(origin V)", "command line")
BUILD_VERBOSE = $(V)
endif
ifndef BUILD_VERBOSE
BUILD_VERBOSE = 0
endif
ifeq ($(BUILD_VERBOSE),1)
quiet =
Q =
else
quiet = quiet_
Q = @
endif
export Q quiet BUILD_VERBOSE
squote := '
escsq = $(subst $(squote),'\$(squote)',$1)
echo-cmd = $(if $($(quiet)cmd_$(1)), echo ' $(call escsq,$($(quiet)cmd_$(1)))';)
cmd = @$(echo-cmd) $(cmd_$(1))
quiet_cmd_generated_offsets_s = [ $@ ]
cmd_generated_offsets_s = $(CC) $(CFLAGS) $(defs) -S $< -o $@
generated-offsets.s: generated-offsets.c $(filter-out asm-offsets.h,$(headers))
$(call cmd,generated_offsets_s)
CLEAN_FILES += generated-offsets.s
quiet_cmd_asm_offsets_h = [ $@ ]
cmd_asm_offsets_h = \
(set -e; \
echo "/* DO NOT MODIFY. THIS FILE WAS AUTO-GENERATED. */"; \
echo "\#ifndef _ASM_OFFSETS_H_"; \
echo "\#define _ASM_OFFSETS_H_"; \
echo ""; \
awk '/\.ascii "GENERATED_INTEGER/{print "\#ifndef " $$3 "\n\#define " $$3 " " $$4 "\n\#endif"}' $^; \
echo ""; \
echo "\#endif") > $@
asm-offsets.h: generated-offsets.s
$(call cmd,asm_offsets_h)
CLEAN_FILES += asm-offsets.h
quiet_cmd_generated_offsets_py = [ $@ ]
cmd_generated_offsets_py = \
(set -e; \
echo "\# DO NOT MODIFY. THIS FILE WAS AUTO-GENERATED."; \
echo ""; \
awk '/\.ascii "GENERATED_INTEGER/{print $$3 " = " $$4}' $^) > $@
generated_offsets.py: generated-offsets.s
$(call cmd,generated_offsets_py)
CLEAN_FILES += generated_offsets.py generated_offsets.pyc
quiet_cmd_ln_sf = [ $@ ]
cmd_ln_sf = ln -sf $(abspath $<) $@
cc-option = $(shell set -e; \
if ($(CC) -Werror $(1) -c -x c /dev/null -o /dev/null) >/dev/null 2>&1; \
then echo "$(1)"; \
fi)
# .c
quiet_cmd_cc_o_c = [ $@ ]
cmd_cc_o_c = $(CC) -MD -MP $(CFLAGS) $(CFLAGS-$@) -c -o $@ $<
quiet_cmd_cpp_i_c = [ $@ ]
cmd_cpp_i_c = $(CC) -MD -MP -MF [email protected] $(CFLAGS) $(CFLAGS-$@) -E -o $@ $<
quiet_cmd_cc_s_c = [ $@ ]
cmd_cc_s_c = $(CC) -MD -MP -MF [email protected] $(CFLAGS) $(CFLAGS-$@) -S -o $@ $<
# .S
quiet_cmd_as_o_S = [ $@ ]
cmd_as_o_S = $(CC) -MD -MP $(ASFLAGS) $(ASFLAGS-$@) -c -o $@ $<
quiet_cmd_cpp_s_S = [ $@ ]
cmd_cpp_s_S = $(CC) -MD -MP -MF [email protected] $(ASFLAGS) $(ASFLAGS-$@) -E -o $@ $<
# LD
quiet_cmd_ld_so_o = [ $@ ]
cmd_ld_so_o = $(LD) $(LDFLAGS) $(LDFLAGS-$@) -o $@ $(filter-out %.map %.lds,$^) -soname $(notdir $@)
# AR
quiet_cmd_ar_so_o = [ $@ ]
cmd_ar_so_o = $(AR) $(ARFLAGS) $(ARFLAGS-$@) $@ $^
quiet_cmd_ar_a_o = [ $@ ]
cmd_ar_a_o = $(AR) $(ARFLAGS) $(ARFLAGS-$@) $@ $^
# LD only
quiet_cmd_ld = [ $@ ]
cmd_ld = $(LD) $(LDFLAGS) $(LDFLAGS-$@) -o $@ $(filter-out %.map %.lds,$^)
# OBJCOPY
quiet_cmd_objcopy = [ $@ ]
cmd_objcopy = $(OBJCOPY) $(OBJCOPYFLAGS) $(OBJCOPYFLAGS-$@) $< $@
# check_no_reloc
# This depends on the output of readelf command.
quiet_cmd_check_no_reloc = [ check_no_reloc $^ ]
cmd_check_no_reloc = LC_ALL=C readelf -r $^ | grep -q 'There are no relocations in this file.'
# single .c => executable
quiet_cmd_csingle = [ $@ ]
cmd_csingle = $(CC) -MD -MP $(CFLAGS) $(CFLAGS-$@) -o $@ $< $(LDLIBS) $(LDLIBS-$@)
# single .cpp => executable
quiet_cmd_cxxsingle = [ $@ ]
cmd_cxxsingle = $(CXX) -MD -MP $(CXXFLAGS) $(CXXFLAGS-$@) -o $@ $< $(LDLIBS) $(LDLIBS-$@)
# sgx sign
quiet_cmd_sgx_sign_manifest = [ $*.{sig, manifest.sgx} ]
cmd_sgx_sign_manifest = $(SGX_SIGN) -output $*.manifest.sgx -exec $* -manifest $<
quiet_cmd_sgx_sign = [ $*.{sig, manifest.sgx} ]
cmd_sgx_sign = $(SGX_SIGN) -output $*.manifest.sgx -manifest $<
# sgx token
quiet_cmd_sgx_get_token = [ Token: $(basename $*) ]
cmd_sgx_get_token = $(SGX_GET_TOKEN) -output $@ -sig $^
# sgx manifest dependency
quiet_cmd_sgx_manifest_dependency = [ $@ ]
cmd_sgx_manifest_dependency = \
(set -e; \
echo -n "$(patsubst %.d,%,$@) $(patsubst %.manifest.sgx.d,%.sig,$@) :"; \
awk -F= '/^\s*sgx.trusted_files./{file=$$2; gsub("file:", "", file); printf(" \\\n\t%s", file)}' $<; \
awk -F= '/^\s*sgx.trusted_children./{file=$$2; gsub("file:", "", file); printf(" \\\n\t%s", file); gsub(".sig", "", file); printf(" \\\n\t%s.manifest.sgx", file)}' $<; \
echo "") > $@