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