setup: fix is_secure_boot()
[platform/upstream/gummiboot.git] / Makefile.am
1 #
2 #  This file is part of gummiboot
3 #
4 #  Copyright (C) 2013 Karel Zak <kzak@redhat.com>
5 #
6 #  gummiboot is free software; you can redistribute it and/or modify it
7 #  under the terms of the GNU Lesser General Public License as published by
8 #  the Free Software Foundation; either version 2.1 of the License, or
9 #  (at your option) any later version.
10 #
11 #  gummiboot is distributed in the hope that it will be useful, but
12 #  WITHOUT ANY WARRANTY; without even the implied warranty of
13 #  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 #  Lesser General Public License for more details.
15 #
16 #  You should have received a copy of the GNU Lesser General Public License
17 #  along with systemd; If not, see <http://www.gnu.org/licenses/>.
18 #
19 ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
20 AM_MAKEFLAGS = --no-print-directory
21
22 gummibootlibdir = $(libexecdir)/gummiboot
23
24 AM_CPPFLAGS = -include config.h
25 AM_CFLAGS = -Wall -Wextra
26 AM_LDFLAGS =
27
28 EXTRA_DIST = autogen.sh README LICENSE
29 CLEANFILES =
30
31 #
32 # gummiboot setup binary
33 #
34 bin_PROGRAMS = gummiboot
35 dist_man_MANS = src/setup/gummiboot.8
36
37 EXTRA_DIST += src/setup/gummiboot.xml
38 CLEANFILES += src/setup/gummiboot.8
39
40 gummiboot_SOURCES = \
41         src/setup/setup.c \
42         src/setup/efivars.c \
43         src/setup/efivars.h
44
45 gummiboot_CFLAGS = \
46         $(AM_CFLAGS) \
47         -Wno-unused-parameter -D_GNU_SOURCE \
48         -DMACHINE_TYPE_NAME=\"$(MACHINE_TYPE_NAME)\" \
49         $(BLKID_CFLAGS)
50
51 gummiboot_LDADD = \
52         $(BLKID_LIBS)
53
54 %.8: %.xml
55         $(AM_V_GEN)$(XSLTPROC) -o $@ --nonet \
56           --stringparam man.output.quietly 1 \
57           --stringparam man.th.extra1.suppress 1 \
58           --stringparam man.authors.section.enabled 0 \
59           --stringparam man.copyright.section.enabled 0 \
60           http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
61
62 #
63 # EFI compilation
64 #
65 # This part of the build system uses custom make rules and bypass regular
66 # automake to provide absolute control on compiler and linker flags.
67 #
68 efi_loadername = gummiboot$(MACHINE_TYPE_NAME).efi
69 efi_sources = src/efi/gummiboot.c
70
71 efi_cppflags = \
72         -I$(top_builddir) -include config.h \
73         -I/usr/include/efi \
74         -I/usr/include/efi/$(ARCH)
75
76 efi_cflags = \
77         -Wall \
78         -Wextra \
79         -nostdinc \
80         -ggdb -O0 \
81         -fpic \
82         -fshort-wchar \
83         -nostdinc \
84         -ffreestanding \
85         -fno-strict-aliasing \
86         -fno-stack-protector \
87         -Wsign-compare
88
89 if ARCH_X86_64
90 efi_cflags += \
91         -DEFI_FUNCTION_WRAPPER \
92         -mno-red-zone
93 endif
94
95 efi_ldflags = \
96         -T $(GNUEFI_LDS_DIR)/elf_$(ARCH)_efi.lds \
97         -shared \
98         -Bsymbolic \
99         -nostdlib \
100         -znocombreloc \
101         $(GNUEFI_LIBS) \
102         $(GNUEFI_LDS_DIR)/crt0-efi-$(ARCH).o
103
104 efi_objects = $(addprefix $(top_builddir)/,$(efi_sources:.c=.o))
105 efi_solib = $(top_builddir)/src/efi/gummiboot.so
106
107 # automake stuff
108 gummibootlib_DATA = $(efi_loadername)
109 CLEANFILES += $(efi_objects) $(efi_solib) $(efi_loadername)
110 EXTRA_DIST += $(efi_sources)
111
112 $(top_builddir)/src/efi/%.o: $(top_srcdir)/src/efi/%.c
113         @$(MKDIR_P) $(top_builddir)/src/efi/
114         $(AM_V_CC)$(GNUEFI_CC) $(efi_cppflags) $(efi_cflags) -c $< -o $@
115
116 $(efi_solib): $(efi_objects)
117         $(AM_V_CCLD)$(LD) $(efi_ldflags) $(efi_objects) \
118                 -o $@ -lefi -lgnuefi $(shell $(CC) -print-libgcc-file-name); \
119         nm -D -u $@ | grep ' U ' && exit 1 || :
120 .DELETE_ON_ERROR: $(efi_solib)
121
122 $(efi_loadername): $(efi_solib)
123         $(AM_V_GEN) objcopy -j .text -j .sdata -j .data -j .dynamic \
124           -j .dynsym -j .rel -j .rela -j .reloc -j .eh_frame \
125           --target=efi-app-$(ARCH) $< $@
126
127 #
128 # tests
129 #
130 CLEANFILES += test-disk
131 EXTRA_DIST += test/test-create-disk.sh
132
133 test-disk: gummiboot$(MACHINE_TYPE_NAME).efi test/test-create-disk.sh
134         $(AM_V_GEN)test/test-create-disk.sh
135
136 qemu: test-disk
137         $(QEMU_KVM) -m 256 -L $(BIOS) -snapshot test-disk