-
Notifications
You must be signed in to change notification settings - Fork 13
Expand file tree
/
Copy pathMakefile
More file actions
158 lines (118 loc) · 3.53 KB
/
Makefile
File metadata and controls
158 lines (118 loc) · 3.53 KB
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
145
146
147
148
149
150
151
152
153
154
155
156
157
158
TARGET = varstored
OBJS := guid.o \
depriv.o \
handler.o \
handler_port.o \
io_port.o \
mor.o \
ppi.o \
ppi_vdata.o \
varstored.o \
xapidb.o \
xapidb-lib.o
CC = gcc
CFLAGS = -I$(shell pwd)/include
# _GNU_SOURCE for asprintf.
CFLAGS += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_GNU_SOURCE
# EXTRA_CFLAGS can be set through make command line
CFLAGS += $(EXTRA_CFLAGS)
CFLAGS += $$(pkg-config --cflags libxml-2.0)
CFLAGS += -g -O2 -std=gnu99 \
-Wall \
-Wstrict-prototypes \
-Wold-style-declaration \
-Wmissing-prototypes \
-Wunused
ifeq ($(shell uname),Linux)
LDLIBS := -lutil -lrt
endif
LDLIBS += -lxenstore \
-lxenforeignmemory \
-lxendevicemodel \
-lxenevtchn \
-lxentoolcore \
-lcrypto \
-lseccomp \
$$(pkg-config --libs libxml-2.0)
# Get the compiler to generate the dependencies for us.
CFLAGS += -Wp,-MD,$(@D)/.$(@F).d -MT $(@D)/$(@F)
SUBDIRS = $(filter-out ./,$(dir $(OBJS) $(LIBS)))
DEPS = .*.d tools/.*.d
LDFLAGS := -g
all: $(TARGET) tools
.PHONY: all
$(TARGET): $(LIBS) $(OBJS)
$(CC) -o $@ $(LDFLAGS) $(OBJS) $(LIBS) $(LDLIBS)
%.o: %.c
$(CC) -o $@ $(CFLAGS) -c $<
TOOLLIBS := -lcrypto -lseccomp $$(pkg-config --libs libxml-2.0)
TOOLOBJS := tools/xapidb-cmdline.o \
tools/xapidb-file.o \
tools/cert-check.o \
tools/tool-lib.o \
depriv.o \
guid.o \
handler.o \
mor.o \
ppi_vdata.o \
xapidb-lib.o
TOOLS := tools/varstore-ls \
tools/varstore-get \
tools/varstore-rm \
tools/varstore-set \
tools/varstore-sb-state \
tools/varstore-nvram-certcheck \
tools/varstore-authfile-certcheck
tools: $(TOOLS)
.PHONY: tools
$(TOOLS): %: $(TOOLOBJS) %.o
$(CC) -o $@ $(LDFLAGS) $^ $(TOOLLIBS)
test.o: test.c
$(CC) -o $@ $(CFLAGS) $$(pkg-config --cflags glib-2.0) -c $<
test: test.o guid.o ppi_vdata.o
$(CC) -o $@ $(LDFLAGS) $^ -lcrypto $$(pkg-config --libs glib-2.0 libxml-2.0)
TESTKEYS := testPK.pem testPK.key testcertA.pem testcertA.key testcertB.pem testcertB.key
TESTDEPS := test $(TESTKEYS) guid.o
check: $(TESTDEPS)
./test
valgrind-check: $(TESTDEPS)
valgrind --leak-check=full --track-origins=yes ./test
.PHONY: check valgrind-check
AUTHS = PK.auth KEK.auth db.auth
auth: $(AUTHS)
.PHONY: auth
create-auth: create-auth.c guid.o
$(CC) -o $@ $(CFLAGS) create-auth.c guid.o -Iinclude -lcrypto
%.pem %.key:
openssl req -new -x509 -newkey rsa:2048 -subj "/CN=$*/" -keyout $*.key -out $*.pem -days 36500 -nodes -sha256
PK.auth: create-auth PK.pem PK.key
./create-auth -k PK.key -c PK.pem PK PK.auth PK.pem
KEK.auth: create-auth PK.pem PK.key KEK.list
./create-auth -k PK.key -c PK.pem KEK KEK.auth $$(cat KEK.list)
db.auth: create-auth PK.pem PK.key db.list
./create-auth -k PK.key -c PK.pem db db.auth $$(cat db.list)
db.list:
echo certs/MicWinProPCA2011_2011-10-19.pem \
certs/MicCorUEFCA2011_2011-06-27.pem \
certs/windows-uefi-ca-2023.pem \
certs/ms-uefi-ca-2023.pem > $@
KEK.list:
echo certs/MicCorKEKCA2011_2011-06-24.pem certs/ms-kek-ca-2023.pem > $@
clean:
$(foreach dir,$(SUBDIRS),make -C $(dir) clean)
rm -f $(OBJS)
rm -f $(DEPS)
rm -f $(TARGET)
rm -f TAGS
rm -f test.o test test.dat
rm -f $(TESTKEYS)
rm -f $(AUTHS)
rm -f create-auth
rm -f PK.pem PK.key KEK.auth KEK.list db.auth db.list
rm -f $(TOOLS) $(TOOLOBJS) $(TOOLS:%=%.o)
.PHONY: TAGS
TAGS:
find . -name \*.[ch] | etags -
-include $(DEPS)
print-%:
echo $($*)