]> git.proxmox.com Git - efi-boot-shim.git/blame - Makefile
Add draft version of Neil's netboot code
[efi-boot-shim.git] / Makefile
CommitLineData
b2fe1780
MG
1ARCH = $(shell uname -m | sed s,i[3456789]86,ia32,)
2
b2d0e06f
MG
3SUBDIRS = Cryptlib
4
b2fe1780
MG
5LIB_PATH = /usr/lib64
6
7EFI_INCLUDE = /usr/include/efi
b2d0e06f 8EFI_INCLUDES = -nostdinc -ICryptlib -ICryptlib/Include -I$(EFI_INCLUDE) -I$(EFI_INCLUDE)/$(ARCH) -I$(EFI_INCLUDE)/protocol
b2fe1780
MG
9EFI_PATH = /usr/lib64/gnuefi
10
11LIB_GCC = $(shell $(CC) -print-libgcc-file-name)
b2d0e06f 12EFI_LIBS = -lefi -lgnuefi --start-group Cryptlib/libcryptlib.a Cryptlib/OpenSSL/libopenssl.a --end-group $(LIB_GCC)
b2fe1780
MG
13
14EFI_CRT_OBJS = $(EFI_PATH)/crt0-efi-$(ARCH).o
15EFI_LDS = $(EFI_PATH)/elf_$(ARCH)_efi.lds
16
5b1bf558
MG
17CFLAGS = -ggdb -O0 -fno-stack-protector -fno-strict-aliasing -fpic -fshort-wchar \
18 -Wall -mno-red-zone \
b2fe1780
MG
19 $(EFI_INCLUDES)
20ifeq ($(ARCH),x86_64)
21 CFLAGS += -DEFI_FUNCTION_WRAPPER
22endif
8518b8cc
PJ
23ifneq ($(origin VENDOR_CERT_FILE), undefined)
24 CFLAGS += -DVENDOR_CERT_FILE=\"$(VENDOR_CERT_FILE)\"
25endif
26
b2d0e06f 27LDFLAGS = -nostdlib -znocombreloc -T $(EFI_LDS) -shared -Bsymbolic -L$(EFI_PATH) -L$(LIB_PATH) -LCryptlib -LCryptlib/OpenSSL $(EFI_CRT_OBJS)
b2fe1780 28
43eeb538
PJ
29VERSION = 0.1
30
333bd977 31TARGET = shim.efi MokManager.efi
1c595706
MG
32OBJS = shim.o netboot.o cert.o
33SOURCES = shim.c shim.h netboot.c signature.h PeImage.h
333bd977
GCPL
34MOK_OBJS = MokManager.o
35MOK_SOURCES = MokManager.c shim.h
b2fe1780 36
37e456be 37all: $(TARGET)
b2fe1780 38
8877e131 39shim.o: $(SOURCES)
b2fe1780 40
8518b8cc
PJ
41cert.o : cert.S
42 $(CC) $(CFLAGS) -c -o $@ $<
43
44shim.so: $(OBJS) Cryptlib/libcryptlib.a Cryptlib/OpenSSL/libopenssl.a cert.o
7f055335
MG
45 $(LD) -o $@ $(LDFLAGS) $^ $(EFI_LIBS)
46
333bd977
GCPL
47MokManager.o: $(SOURCES)
48
49MokManager.so: $(MOK_OBJS) Cryptlib/libcryptlib.a Cryptlib/OpenSSL/libopenssl.a
50 $(LD) -o $@ $(LDFLAGS) $^ $(EFI_LIBS)
51
b2d0e06f
MG
52Cryptlib/libcryptlib.a:
53 $(MAKE) -C Cryptlib
54
55Cryptlib/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
70clean:
b2d0e06f
MG
71 $(MAKE) -C Cryptlib clean
72 $(MAKE) -C Cryptlib/OpenSSL clean
b2fe1780 73 rm -f $(TARGET) $(OBJS)
43eeb538
PJ
74
75GITTAG = $(VERSION)
76
77test-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
87archive:
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"