properly terminate edited line
[platform/upstream/gummiboot.git] / Makefile
1 VERSION=1
2
3 ARCH=$(shell $(CC) -dumpmachine | sed "s/\(-\).*$$//")
4 LIBDIR=$(shell echo $$(cd /usr/lib/$$(gcc -print-multi-os-directory); pwd))
5
6 CPPFLAGS = \
7         -I. \
8         -I/usr/include/efi \
9         -I/usr/include/efi/$(ARCH)
10
11 CFLAGS = \
12         -DVERSION=$(VERSION) \
13         -Wall \
14         -g -O0 \
15         -fpic \
16         -fshort-wchar \
17         -ffreestanding \
18         -DEFI_FUNCTION_WRAPPER
19
20 LDFLAGS = -T $(LIBDIR)/gnuefi/elf_$(ARCH)_efi.lds \
21         -shared \
22         -Bsymbolic \
23         -nostdlib \
24         -znocombreloc \
25         -L $(LIBDIR) \
26         $(LIBDIR)/gnuefi/crt0-efi-$(ARCH).o
27
28 %.o: %.c
29         $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
30
31 gummiboot.efi: gummiboot.so
32         objcopy -j .text -j .sdata -j .data -j .dynamic \
33           -j .dynsym -j .rel -j .rela -j .reloc \
34           --target=efi-app-$(ARCH) $< $@
35
36 gummiboot.so: gummiboot.o
37         $(LD) $(LDFLAGS) gummiboot.o -o $@ -lefi -lgnuefi
38
39 clean:
40         rm -f gummiboot.o gummiboot.so gummiboot.efi
41
42 test: gummiboot.efi
43         @# UUID=677B-ECF2 /boot2 vfat noauto,x-systemd.automount,x-gvfs-hide 1 3
44         cp -v gummiboot.efi /boot2/EFI/gummiboot/
45         @# unmount to sync EFI partition to disk
46         sync
47         umount /boot2
48         echo 3 > /proc/sys/vm/drop_caches
49         @# run UEFI KVM
50         qemu-kvm -m 512 -L /home/kay/data/bios -snapshot /dev/sda