Add gbs.conf
[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 = $(prefix)/lib/gummiboot
23
24 AM_CPPFLAGS = -include config.h
25 AM_CFLAGS = \
26         -D_GNU_SOURCE \
27         -Wall \
28         -Wextra \
29         -Wmissing-prototypes \
30         -Wno-unused-parameter
31 AM_LDFLAGS =
32
33 EXTRA_DIST = autogen.sh README LICENSE
34 CLEANFILES =
35
36 # ------------------------------------------------------------------------------
37 bin_PROGRAMS = gummiboot
38
39 gummiboot_SOURCES = \
40         src/setup/setup.c \
41         src/setup/efivars.c \
42         src/setup/efivars.h
43
44 gummiboot_CPPFLAGS = \
45         $(AM_CPPFLAGS) \
46         -DMACHINE_TYPE_NAME=\"$(MACHINE_TYPE_NAME)\" \
47         -DGUMMIBOOTLIBDIR=\"$(gummibootlibdir)\"
48
49 gummiboot_CFLAGS = \
50         $(AM_CFLAGS) \
51         $(BLKID_CFLAGS)
52
53 gummiboot_LDADD = \
54         $(BLKID_LIBS)
55
56 if ENABLE_MANPAGES
57 %.8: %.xml
58         $(AM_V_GEN)$(XSLTPROC) -o $@ --nonet \
59           --stringparam man.output.quietly 1 \
60           --stringparam man.th.extra1.suppress 1 \
61           --stringparam man.authors.section.enabled 0 \
62           --stringparam man.copyright.section.enabled 0 \
63           http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
64
65 dist_man_MANS = man/gummiboot.8
66 endif
67
68 EXTRA_DIST += man/gummiboot.xml
69 CLEANFILES += man/gummiboot.8
70
71 # ------------------------------------------------------------------------------
72 # EFI compilation -- this part of the build system uses custom make rules and
73 # bypasses regular automake to provide absolute control on compiler and linker
74 # flags.
75 efi_loadername = gummiboot$(MACHINE_TYPE_NAME).efi
76 efi_sources = \
77         src/efi/util.c \
78         src/efi/console.c \
79         src/efi/graphics.c \
80         src/efi/gummiboot.c
81
82 efi_headers = \
83         src/efi/util.h \
84         src/efi/console.h \
85         src/efi/graphics.h
86
87 efi_cppflags = \
88         $(EFI_CPPFLAGS) \
89         -I$(top_builddir) -include config.h \
90         -I$(EFI_INC_DIR)/efi \
91         -I$(EFI_INC_DIR)/efi/$(ARCH) \
92         -DMACHINE_TYPE_NAME=\"$(MACHINE_TYPE_NAME)\"
93
94 efi_cflags = \
95         $(EFI_CFLAGS) \
96         -Wall \
97         -Wextra \
98         -nostdinc \
99         -ggdb -O0 \
100         -fpic \
101         -fshort-wchar \
102         -nostdinc \
103         -ffreestanding \
104         -fno-strict-aliasing \
105         -fno-stack-protector \
106         -Wsign-compare \
107         -mno-sse \
108         -mno-mmx
109
110 if ARCH_X86_64
111 efi_cflags += \
112         -mno-red-zone \
113         -DEFI_FUNCTION_WRAPPER \
114         -DGNU_EFI_USE_MS_ABI
115 endif
116
117 efi_ldflags = \
118         $(EFI_LDLAGS) \
119         -T $(EFI_LDS_DIR)/elf_$(ARCH)_efi.lds \
120         -shared \
121         -Bsymbolic \
122         -nostdlib \
123         -znocombreloc \
124         -L $(EFI_LIB_DIR) \
125         $(EFI_LDS_DIR)/crt0-efi-$(ARCH).o
126
127 efi_objects = $(addprefix $(top_builddir)/,$(efi_sources:.c=.o))
128 efi_solib = $(top_builddir)/src/efi/gummiboot.so
129
130 # ------------------------------------------------------------------------------
131 gummibootlib_DATA = $(efi_loadername)
132 CLEANFILES += $(efi_objects) $(efi_solib) $(efi_loadername)
133 EXTRA_DIST += $(efi_sources) $(efi_headers)
134
135 $(top_builddir)/src/efi/%.o: $(top_srcdir)/src/efi/%.c $(addprefix $(top_srcdir)/,$(efi_headers))
136         @$(MKDIR_P) $(top_builddir)/src/efi/
137         $(AM_V_CC)$(EFI_CC) $(efi_cppflags) $(efi_cflags) -c $< -o $@
138
139 $(efi_solib): $(efi_objects)
140         $(AM_V_CCLD)$(LD) $(efi_ldflags) $(efi_objects) \
141                 -o $@ -lefi -lgnuefi $(shell $(CC) -print-libgcc-file-name); \
142         nm -D -u $@ | grep ' U ' && exit 1 || :
143 .DELETE_ON_ERROR: $(efi_solib)
144
145 $(efi_loadername): $(efi_solib)
146         $(AM_V_GEN) objcopy -j .text -j .sdata -j .data -j .dynamic \
147           -j .dynsym -j .rel -j .rela -j .reloc -j .eh_frame \
148           --target=efi-app-$(ARCH) $< $@
149
150 # ------------------------------------------------------------------------------
151 CLEANFILES += test-disk.img
152 EXTRA_DIST += test/test-create-disk.sh
153
154 test-disk.img: gummiboot$(MACHINE_TYPE_NAME).efi test/test-create-disk.sh
155         $(AM_V_GEN)test/test-create-disk.sh
156
157 qemu: test-disk.img
158         $(QEMU) -machine accel=kvm -m 256 -bios $(QEMU_BIOS) -snapshot test-disk.img
159
160 install-tree: all
161         rm -rf $(abs_srcdir)/install-tree
162         $(MAKE) install DESTDIR=$(abs_srcdir)/install-tree
163         tree $(abs_srcdir)/install-tree