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