setup: add "status" to help text
[platform/upstream/gummiboot.git] / Makefile
1 VERSION=22
2
3 ifeq ($(strip $(V)),)
4         E = @echo
5         Q = @
6 else
7         E = @\#
8         Q =
9 endif
10 export E Q
11
12 ARCH=$(shell $(CC) -dumpmachine | sed "s/\(-\).*$$//")
13 LIBDIR=$(shell echo $$(cd /usr/lib/$$(gcc -print-multi-os-directory); pwd))
14 LIBEFIDIR=$(or $(wildcard $(LIBDIR)/gnuefi), $(LIBDIR))
15
16 ifeq ($(ARCH),i686)
17         ARCH=ia32
18         MACHINE_TYPE_NAME=ia32
19 endif
20
21 ifeq ($(ARCH),x86_64)
22         MACHINE_TYPE_NAME=x64
23         ARCH_CFLAGS= \
24                 -DEFI_FUNCTION_WRAPPER \
25                 -mno-red-zone
26 endif
27
28 all: gummiboot$(MACHINE_TYPE_NAME).efi gummiboot
29
30 # ------------------------------------------------------------------------------
31 CPPFLAGS = \
32         -I. \
33         -I/usr/include/efi \
34         -I/usr/include/efi/$(ARCH)
35
36 CFLAGS = \
37         -DVERSION=$(VERSION) \
38         -Wall \
39         -Wextra \
40         -nostdinc \
41         -ggdb -O0 \
42         -fpic \
43         -fshort-wchar \
44         -nostdinc \
45         -ffreestanding \
46         -fno-strict-aliasing \
47         -fno-stack-protector \
48         -Wsign-compare \
49         $(ARCH_CFLAGS)
50
51 LDFLAGS = -T $(LIBEFIDIR)/elf_$(ARCH)_efi.lds \
52         -shared \
53         -Bsymbolic \
54         -nostdlib \
55         -znocombreloc \
56         -L $(LIBDIR) \
57         $(LIBEFIDIR)/crt0-efi-$(ARCH).o
58
59 %.o: %.c
60         $(E) "  CC       " $@
61         $(Q) $(CC) $(CPPFLAGS) $(CFLAGS) -c $< -o $@
62
63 src/efi/gummiboot.o: src/efi/gummiboot.c Makefile
64
65 src/efi/gummiboot.so: src/efi/gummiboot.o
66         $(E) "  LD       " $@
67         $(Q) $(LD) $(LDFLAGS) src/efi/gummiboot.o -o $@ -lefi -lgnuefi \
68           $(shell $(CC) -print-libgcc-file-name)
69
70 gummiboot$(MACHINE_TYPE_NAME).efi: src/efi/gummiboot.so
71         $(E) "  OBJCOPY  " $@
72         $(Q) objcopy -j .text -j .sdata -j .data -j .dynamic \
73           -j .dynsym -j .rel -j .rela -j .reloc -j .eh_frame \
74           --target=efi-app-$(ARCH) $< $@
75
76 # ------------------------------------------------------------------------------
77 gummiboot: src/setup/setup.c src/setup/efivars.h src/setup/efivars.c Makefile
78         $(E) "  CCLD     " $@
79         $(Q) $(CC) -O0 -g -Wall -Wextra \
80           -Wno-unused-parameter -D_GNU_SOURCE \
81           -DMACHINE_TYPE_NAME=\"$(MACHINE_TYPE_NAME)\" \
82           `pkg-config --cflags --libs blkid` \
83           src/setup/setup.c \
84           src/setup/efivars.c \
85           -o $@
86
87 # ------------------------------------------------------------------------------
88 man: gummiboot.1
89
90 gummiboot.1: src/setup/gummiboot.xml
91         $(E) "  XSLT     " $@
92         $(Q) xsltproc -o @ --nonet \
93           --stringparam man.output.quietly 1 \
94           --stringparam man.th.extra1.suppress 1 \
95           --stringparam man.authors.section.enabled 0 \
96           --stringparam man.copyright.section.enabled 0 \
97           http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
98
99 # ------------------------------------------------------------------------------
100 clean:
101         rm -f src/efi/gummiboot.o src/efi/gummiboot.so gummiboot gummiboot$(MACHINE_TYPE_NAME).efi
102
103 install: all
104         mkdir -p $(DESTDIR)/usr/bin/
105         cp gummiboot $(DESTDIR)/usr/bin
106         mkdir -p $(DESTDIR)/usr/lib/gummiboot/
107         cp gummiboot$(MACHINE_TYPE_NAME).efi $(DESTDIR)/usr/lib/gummiboot/
108         [ -e gummiboot.1 ] && mkdir -p $(DESTDIR)/usr/share/man/man1/ && cp gummiboot.1 $(DESTDIR)/usr/share/man/man1/ || :
109
110 tar:
111         git archive --format=tar --prefix=gummiboot-$(VERSION)/ $(VERSION) | xz > gummiboot-$(VERSION).tar.xz
112
113 test-disk: gummiboot$(MACHINE_TYPE_NAME).efi test/test-create-disk.sh
114         test/test-create-disk.sh
115
116 test: test-disk
117         qemu-kvm -m 256 -L /usr/lib/qemu-bios -snapshot test-disk