]>
Commit | Line | Data |
---|---|---|
b2fe1780 MG |
1 | ARCH = $(shell uname -m | sed s,i[3456789]86,ia32,) |
2 | ||
b2d0e06f MG |
3 | SUBDIRS = Cryptlib |
4 | ||
b2fe1780 MG |
5 | LIB_PATH = /usr/lib64 |
6 | ||
7 | EFI_INCLUDE = /usr/include/efi | |
b2d0e06f | 8 | EFI_INCLUDES = -nostdinc -ICryptlib -ICryptlib/Include -I$(EFI_INCLUDE) -I$(EFI_INCLUDE)/$(ARCH) -I$(EFI_INCLUDE)/protocol |
b2fe1780 MG |
9 | EFI_PATH = /usr/lib64/gnuefi |
10 | ||
11 | LIB_GCC = $(shell $(CC) -print-libgcc-file-name) | |
b2d0e06f | 12 | EFI_LIBS = -lefi -lgnuefi --start-group Cryptlib/libcryptlib.a Cryptlib/OpenSSL/libopenssl.a --end-group $(LIB_GCC) |
b2fe1780 MG |
13 | |
14 | EFI_CRT_OBJS = $(EFI_PATH)/crt0-efi-$(ARCH).o | |
15 | EFI_LDS = $(EFI_PATH)/elf_$(ARCH)_efi.lds | |
16 | ||
5b1bf558 MG |
17 | CFLAGS = -ggdb -O0 -fno-stack-protector -fno-strict-aliasing -fpic -fshort-wchar \ |
18 | -Wall -mno-red-zone \ | |
b2fe1780 MG |
19 | $(EFI_INCLUDES) |
20 | ifeq ($(ARCH),x86_64) | |
21 | CFLAGS += -DEFI_FUNCTION_WRAPPER | |
22 | endif | |
8518b8cc PJ |
23 | ifneq ($(origin VENDOR_CERT_FILE), undefined) |
24 | CFLAGS += -DVENDOR_CERT_FILE=\"$(VENDOR_CERT_FILE)\" | |
25 | endif | |
26 | ||
b2d0e06f | 27 | LDFLAGS = -nostdlib -znocombreloc -T $(EFI_LDS) -shared -Bsymbolic -L$(EFI_PATH) -L$(LIB_PATH) -LCryptlib -LCryptlib/OpenSSL $(EFI_CRT_OBJS) |
b2fe1780 | 28 | |
43eeb538 PJ |
29 | VERSION = 0.1 |
30 | ||
333bd977 | 31 | TARGET = shim.efi MokManager.efi |
1c595706 MG |
32 | OBJS = shim.o netboot.o cert.o |
33 | SOURCES = shim.c shim.h netboot.c signature.h PeImage.h | |
333bd977 GCPL |
34 | MOK_OBJS = MokManager.o |
35 | MOK_SOURCES = MokManager.c shim.h | |
b2fe1780 | 36 | |
37e456be | 37 | all: $(TARGET) |
b2fe1780 | 38 | |
8877e131 | 39 | shim.o: $(SOURCES) |
b2fe1780 | 40 | |
8518b8cc PJ |
41 | cert.o : cert.S |
42 | $(CC) $(CFLAGS) -c -o $@ $< | |
43 | ||
44 | shim.so: $(OBJS) Cryptlib/libcryptlib.a Cryptlib/OpenSSL/libopenssl.a cert.o | |
7f055335 MG |
45 | $(LD) -o $@ $(LDFLAGS) $^ $(EFI_LIBS) |
46 | ||
333bd977 GCPL |
47 | MokManager.o: $(SOURCES) |
48 | ||
49 | MokManager.so: $(MOK_OBJS) Cryptlib/libcryptlib.a Cryptlib/OpenSSL/libopenssl.a | |
50 | $(LD) -o $@ $(LDFLAGS) $^ $(EFI_LIBS) | |
51 | ||
b2d0e06f MG |
52 | Cryptlib/libcryptlib.a: |
53 | $(MAKE) -C Cryptlib | |
54 | ||
55 | Cryptlib/OpenSSL/libopenssl.a: | |
56 | $(MAKE) -C Cryptlib/OpenSSL | |
57 | ||
58 | %.efi: %.so | |
b2fe1780 MG |
59 | objcopy -j .text -j .sdata -j .data \ |
60 | -j .dynamic -j .dynsym -j .rel \ | |
5b1bf558 | 61 | -j .rela -j .reloc -j .eh_frame \ |
7f055335 | 62 | --target=efi-app-$(ARCH) $^ $@ |
5b1bf558 MG |
63 | objcopy -j .text -j .sdata -j .data \ |
64 | -j .dynamic -j .dynsym -j .rel \ | |
65 | -j .rela -j .reloc -j .eh_frame \ | |
66 | -j .debug_info -j .debug_abbrev -j .debug_aranges \ | |
67 | -j .debug_line -j .debug_str -j .debug_ranges \ | |
e676d64a | 68 | --target=efi-app-$(ARCH) $^ $@.debug |
b2fe1780 MG |
69 | |
70 | clean: | |
b2d0e06f MG |
71 | $(MAKE) -C Cryptlib clean |
72 | $(MAKE) -C Cryptlib/OpenSSL clean | |
b2fe1780 | 73 | rm -f $(TARGET) $(OBJS) |
43eeb538 PJ |
74 | |
75 | GITTAG = $(VERSION) | |
76 | ||
77 | test-archive: | |
78 | @rm -rf /tmp/shim-$(VERSION) /tmp/shim-$(VERSION)-tmp | |
79 | @mkdir -p /tmp/shim-$(VERSION)-tmp | |
80 | @git archive --format=tar $(shell git branch | awk '/^*/ { print $$2 }') | ( cd /tmp/shim-$(VERSION)-tmp/ ; tar x ) | |
81 | @git diff | ( cd /tmp/shim-$(VERSION)-tmp/ ; patch -s -p1 -b -z .gitdiff ) | |
82 | @mv /tmp/shim-$(VERSION)-tmp/ /tmp/shim-$(VERSION)/ | |
83 | @dir=$$PWD; cd /tmp; tar -c --bzip2 -f $$dir/shim-$(VERSION).tar.bz2 shim-$(VERSION) | |
84 | @rm -rf /tmp/shim-$(VERSION) | |
85 | @echo "The archive is in shim-$(VERSION).tar.bz2" | |
86 | ||
87 | archive: | |
88 | git tag $(GITTAG) refs/heads/master | |
89 | @rm -rf /tmp/shim-$(VERSION) /tmp/shim-$(VERSION)-tmp | |
90 | @mkdir -p /tmp/shim-$(VERSION)-tmp | |
91 | @git archive --format=tar $(GITTAG) | ( cd /tmp/shim-$(VERSION)-tmp/ ; tar x ) | |
92 | @mv /tmp/shim-$(VERSION)-tmp/ /tmp/shim-$(VERSION)/ | |
93 | @dir=$$PWD; cd /tmp; tar -c --bzip2 -f $$dir/shim-$(VERSION).tar.bz2 shim-$(VERSION) | |
94 | @rm -rf /tmp/shim-$(VERSION) | |
95 | @echo "The archive is in shim-$(VERSION).tar.bz2" |