Skip to content

Commit e76049f

Browse files
committed
simplify the makefile
support x86_64 only
1 parent 0b40902 commit e76049f

11 files changed

Lines changed: 16 additions & 336 deletions

Make.rules

Lines changed: 0 additions & 106 deletions
Original file line numberDiff line numberDiff line change
@@ -1,106 +0,0 @@
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 $@ ./$*

Makefile

Lines changed: 13 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,18 @@
1-
BINARIES = efi-updatevar
1+
BINARY = efi-updatevar
22

3-
export TOPDIR := $(shell pwd)/
3+
CFLAGS =
4+
CFLAGS += -Iinclude
5+
CFLAGS += -I/usr/include/efi
6+
CFLAGS += -Wall
7+
CFLAGS += -pedantic-errors
48

5-
include Make.rules
9+
all: $(BINARY).o lib/guid.o lib/kernel_efivars.o
10+
$(CC) $(CFLAGS) -o $(BINARY) $^
611

7-
efi-updatevar: efi-updatevar.o lib/lib.a
8-
$(CC) $(ARCH3264) -o $@ $< lib/lib.a
9-
10-
all: $(BINARIES) $(MANPAGES)
11-
12-
install: all
13-
$(INSTALL) -m 755 -d $(MANDIR)
14-
$(INSTALL) -m 644 $(MANPAGES) $(MANDIR)
15-
$(INSTALL) -m 755 -d $(BINDIR)
16-
$(INSTALL) -m 755 $(BINARIES) $(BINDIR)
17-
$(INSTALL) -m 755 -d $(DOCDIR)
18-
$(INSTALL) -m 644 README COPYING $(DOCDIR)
19-
20-
lib/lib.a:
21-
$(MAKE) -C lib $(notdir $@)
12+
%.o: %.c
13+
$(CC) $(CFLAGS) -o $@ -c $<
2214

2315
clean:
24-
rm -f $(BINARIES) *.o
25-
rm -f doc/*.1
26-
$(MAKE) -C lib clean
16+
rm -f $(BINARY)
17+
rm -f *.o
18+
rm -f lib/*.o

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ This may only work in setup mode.
5757

5858
To verify that the system is in setup mode, run `mokutil --sb-state` or `sbctl status`.
5959

60-
Now copy each vardata file to its correct destination in the efivars fs:
60+
Now copy each vardata file to its correct destination in the efivars filesystem:
6161

6262
```sh
6363
sudo chattr -i /sys/firmware/efi/efivars/*
@@ -68,5 +68,5 @@ sudo cp /tmp/PK.vardata /sys/firmware/efi/efivars/PK-8be4df61-93ca-11d2-aa0d-00e
6868

6969
Notes:
7070

71-
* The destination filenames in the efivars fs look random, but they are always the same.
71+
* The destination filenames in the efivars filesystem look random, but they are always the same.
7272
* After copying `PK.vardata`, the system should not be in setup mode anymore.

doc/cert-to-efi-hash-list.1.in

Lines changed: 0 additions & 30 deletions
This file was deleted.

doc/cert-to-efi-sig-list.1.in

Lines changed: 0 additions & 26 deletions
This file was deleted.

doc/efi-readvar.1.in

Lines changed: 0 additions & 25 deletions
This file was deleted.

doc/hash-to-efi-sig-list.1.in

Lines changed: 0 additions & 17 deletions
This file was deleted.

doc/sig-list-to-certs.1.in

Lines changed: 0 additions & 49 deletions
This file was deleted.

doc/sign-efi-sig-list.1.in

Lines changed: 0 additions & 50 deletions
This file was deleted.

efi-updatevar.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,7 +67,7 @@ int main(int argc, char *argv[]) {
6767

6868
EFI_GUID *owner = get_owner(var);
6969
if (!owner) {
70-
printf(RED "[ERROR]" NC " Variable must be one of: PK, KEK, db, dbx\n", var);
70+
printf(RED "[ERROR]" NC " Variable must be one of: PK, KEK, db, dbx\n");
7171
return 1;
7272
}
7373

0 commit comments

Comments
 (0)