|
1 | | -EFISIGNED = $(patsubst %.efi,%-signed.efi,$(EFIFILES)) |
2 | | -MANPAGES = $(patsubst doc/%.1.in,doc/%.1,$(wildcard doc/*.1.in)) |
3 | | -HELP2MAN = help2man |
4 | | -ARCH = $(shell uname -m | sed 's/i.86/ia32/;s/arm.*/arm/') |
5 | | -ifeq ($(ARCH),ia32) |
6 | | -ARCH3264 = -m32 |
7 | | -else ifeq ($(ARCH),x86_64) |
8 | | -ARCH3264 = |
9 | | -else ifeq ($(ARCH),aarch64) |
10 | | -ARCH3264 = |
11 | | -else ifeq ($(ARCH),arm) |
12 | | -ARCH3264 = |
13 | | -else |
14 | | -$(error unknown architecture $(ARCH)) |
15 | | -endif |
16 | | -INCDIR = -I$(TOPDIR)include/ -I/usr/include/efi -I/usr/include/efi/$(ARCH) -I/usr/include/efi/protocol |
17 | | -CPPFLAGS = -DCONFIG_$(ARCH) |
18 | | -CFLAGS = -O2 -g $(ARCH3264) -fpic -Wall -fshort-wchar -fno-strict-aliasing -fno-merge-constants -fno-stack-protector -ffreestanding -fno-stack-check |
19 | | -LDFLAGS = -nostdlib |
20 | | -CRTOBJ = crt0-efi-$(ARCH).o |
21 | | -CRTPATHS = /lib /lib64 /lib/efi /lib64/efi /usr/lib /usr/lib64 /usr/lib/efi /usr/lib64/efi /usr/lib/gnuefi /usr/lib64/gnuefi |
22 | | -CRTPATH = $(shell for f in $(CRTPATHS); do if [ -e $$f/$(CRTOBJ) ]; then echo $$f; break; fi; done) |
23 | | -CRTOBJS = $(CRTPATH)/$(CRTOBJ) |
24 | | -# there's a bug in the gnu tools ... the .reloc section has to be |
25 | | -# aligned otherwise the file alignment gets screwed up |
26 | | -LDSCRIPT = elf_$(ARCH)_efi.lds |
27 | | -LDFLAGS += -shared -Bsymbolic $(CRTOBJS) -L $(CRTPATH) -L /usr/lib -L /usr/lib64 -T $(LDSCRIPT) |
28 | | -LOADLIBES = -lefi -lgnuefi $(shell $(CC) $(ARCH3264) -print-libgcc-file-name) |
29 | | -FORMAT = --target=efi-app-$(ARCH) |
30 | | -OBJCOPY = objcopy |
31 | | -MYGUID = 11111111-2222-3333-4444-123456789abc |
32 | | -INSTALL = install |
33 | | -BINDIR = $(DESTDIR)/usr/bin |
34 | | -MANDIR = $(DESTDIR)/usr/share/man/man1 |
35 | | -EFIDIR = $(DESTDIR)/usr/share/efitools/efi |
36 | | -DOCDIR = $(DESTDIR)/usr/share/efitools |
37 | | - |
38 | | -# globally use EFI calling conventions (requires gcc >= 4.7) |
39 | | -CFLAGS += -DGNU_EFI_USE_MS_ABI |
40 | | -CFLAGS += -D_XOPEN_SOURCE=700 |
41 | | -CFLAGS += -D_DEFAULT_SOURCE |
42 | | - |
43 | | -ifeq ($(ARCH),x86_64) |
44 | | - CFLAGS += -DEFI_FUNCTION_WRAPPER -mno-red-zone |
45 | | -endif |
46 | | - |
47 | | -ifeq ($(ARCH),ia32) |
48 | | - CFLAGS += -mno-red-zone |
49 | | -endif |
50 | | - |
51 | | -ifeq ($(ARCH),arm) |
52 | | - LDFLAGS += --defsym=EFI_SUBSYSTEM=0x0a |
53 | | - FORMAT = -O binary |
54 | | -endif |
55 | | - |
56 | | -ifeq ($(ARCH),aarch64) |
57 | | - LDFLAGS += --defsym=EFI_SUBSYSTEM=0x0a |
58 | | - FORMAT = -O binary |
59 | | -endif |
60 | | - |
61 | | -%.so: %.o |
62 | | - $(LD) $(LDFLAGS) $^ -o $@ $(LOADLIBES) |
63 | | - # check we have no undefined symbols |
64 | | - nm -D $@ | grep ' U ' && exit 1 || exit 0 |
65 | | - |
66 | | -%.h: %.auth |
67 | | - ./xxdi.pl $< > $@ |
68 | | - |
69 | | -%.hash: %.efi hash-to-efi-sig-list |
70 | | - ./hash-to-efi-sig-list $< $@ |
71 | | - |
72 | | -%-blacklist.esl: %.crt cert-to-efi-hash-list |
73 | | - ./cert-to-efi-sig-list $< $@ |
74 | | - |
75 | | -%-hash-blacklist.esl: %.crt cert-to-efi-hash-list |
76 | | - ./cert-to-efi-hash-list $< $@ |
77 | | - |
78 | | -%.esl: %.crt cert-to-efi-sig-list |
79 | | - ./cert-to-efi-sig-list -g $(MYGUID) $< $@ |
80 | | - |
81 | | -%.o: %.c |
82 | | - $(CC) $(INCDIR) $(CFLAGS) $(CPPFLAGS) -c $< -o $@ |
83 | | - |
84 | | -%.crt: |
85 | | - openssl req -new -x509 -newkey rsa:2048 -subj "/CN=$*/" -keyout $*.key -out $@ -days 3650 -nodes -sha256 |
86 | | - |
87 | | -%.cer: %.crt |
88 | | - openssl x509 -in $< -out $@ -outform DER |
89 | | - |
90 | | -%-subkey.csr: |
91 | | - openssl req -new -newkey rsa:2048 -keyout $*-subkey.key -subj "/CN=Subkey $* of KEK/" -out $@ -nodes |
92 | | - |
93 | | -%-subkey.crt: %-subkey.csr KEK.crt |
94 | | - openssl x509 -req -in $< -CA DB.crt -CAkey DB.key -set_serial 1 -out $@ -days 365 |
95 | | - |
96 | | -## |
97 | | -# No need for KEK signing |
98 | | -## |
99 | | -#%-kek-signed.efi: %.efi KEK.crt |
100 | | -# sbsign --key KEK.key --cert KEK.crt --output $@ $< |
101 | | - |
102 | | -%.a: |
103 | | - ar rcv $@ $^ |
104 | | - |
105 | | -doc/%.1: doc/%.1.in % |
106 | | - $(HELP2MAN) --no-info -i $< -o $@ ./$* |
0 commit comments