run rule
[efitest1] / Makefile
1 obj = test.o
2 efiso = test.so
3 efibin = bootx64.efi
4
5 inc = -I/usr/include/efi -I/usr/include/efi/x86_64 -I/usr/include/efi/protocol
6 def = -DEFI_FUNCTION_WRAPPER
7 eficrt = /usr/lib/crt0-efi-x86_64.o
8 ldscript = /usr/lib/elf_x86_64_efi.lds
9
10 CFLAGS = -pedantic -Wall $(inc) $(def) -fno-stack-protector -fPIC -fshort-wchar \
11                  -mno-red-zone
12 LDFLAGS = -nostdlib -znocombreloc -T $(ldscript) -L/usr/lib $(eficrt) -lefi -lgnuefi
13
14 .PHONY: all
15 all: $(efibin)
16
17 $(efiso): $(obj)
18         $(LD) -o $@ -shared -Bsymbolic $(obj) $(LDFLAGS)
19
20 $(efibin): $(efiso)
21         objcopy -j .text -j .sdata -j .data -j .dynamic -j .dynsym -j .rel \
22                 -j .rela -j .reloc --target=efi-app-x86_64 $< $@
23
24 part.img: $(efibin)
25         dd if=/dev/zero of=$@ bs=1024 count=2080
26         mkfs -t vfat $@
27         mmd -i $@ ::/EFI
28         mmd -i $@ ::/EFI/BOOT
29         mcopy -i $@ $< ::/EFI/BOOT
30
31 disk.img: part.img
32         dd if=/dev/zero of=$@ bs=1024 count=2048
33         echo start=2048 type=ef | sfdisk $@
34         dd if=$< of=$@ bs=512 seek=2048 conv=notrunc
35
36
37 .PHONY: clean
38 clean:
39         rm -f $(obj) $(efibin) $(efiso) *.img