summaryrefslogtreecommitdiff
path: root/Makefile.am
blob: c3dfcb295239155f616ce563d4f872a48b5619f6 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
#
#  This file is part of gummiboot
#
#  Copyright (C) 2013 Karel Zak <kzak@redhat.com>
#
#  gummiboot is free software; you can redistribute it and/or modify it
#  under the terms of the GNU Lesser General Public License as published by
#  the Free Software Foundation; either version 2.1 of the License, or
#  (at your option) any later version.
#
#  gummiboot is distributed in the hope that it will be useful, but
#  WITHOUT ANY WARRANTY; without even the implied warranty of
#  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
#  Lesser General Public License for more details.
#
#  You should have received a copy of the GNU Lesser General Public License
#  along with systemd; If not, see <http://www.gnu.org/licenses/>.

ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
AM_MAKEFLAGS = --no-print-directory

gummibootlibdir = $(prefix)/lib/gummiboot

AM_CPPFLAGS = -include config.h
AM_CFLAGS = \
	-D_GNU_SOURCE \
	-Wall \
	-Wextra \
	-Wmissing-prototypes \
	-Wno-unused-parameter
AM_LDFLAGS =

EXTRA_DIST = autogen.sh README LICENSE
CLEANFILES =

# ------------------------------------------------------------------------------
bin_PROGRAMS = gummiboot

gummiboot_SOURCES = \
	src/setup/setup.c \
	src/setup/efivars.c \
	src/setup/efivars.h

gummiboot_CFLAGS = \
	$(AM_CFLAGS) \
	-DMACHINE_TYPE_NAME=\"$(MACHINE_TYPE_NAME)\" \
	-DGUMMIBOOTLIBDIR=\"$(gummibootlibdir)\" \
	$(BLKID_CFLAGS)

gummiboot_LDADD = \
	$(BLKID_LIBS)

if ENABLE_MANPAGES
%.8: %.xml
	$(AM_V_GEN)$(XSLTPROC) -o $@ --nonet \
	  --stringparam man.output.quietly 1 \
	  --stringparam man.th.extra1.suppress 1 \
	  --stringparam man.authors.section.enabled 0 \
	  --stringparam man.copyright.section.enabled 0 \
	  http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<

dist_man_MANS = man/gummiboot.8
endif

EXTRA_DIST += man/gummiboot.xml
CLEANFILES += man/gummiboot.8

# ------------------------------------------------------------------------------
# EFI compilation -- this part of the build system uses custom make rules and
# bypasses regular automake to provide absolute control on compiler and linker
# flags.
efi_loadername = gummiboot$(MACHINE_TYPE_NAME).efi
efi_sources = src/efi/gummiboot.c

efi_cppflags = \
	-I$(top_builddir) -include config.h \
	-I/usr/include/efi \
	-I/usr/include/efi/$(ARCH)

efi_cflags = \
	-Wall \
	-Wextra \
	-nostdinc \
	-ggdb -O0 \
	-fpic \
	-fshort-wchar \
	-nostdinc \
	-ffreestanding \
	-fno-strict-aliasing \
	-fno-stack-protector \
	-Wsign-compare \
	-mno-sse \
	-mno-mmx

if ARCH_X86_64
efi_cflags += \
	-mno-red-zone \
	-DEFI_FUNCTION_WRAPPER \
	-DGNU_EFI_USE_MS_ABI
endif

efi_ldflags = \
	-T $(GNUEFI_LDS_DIR)/elf_$(ARCH)_efi.lds \
	-shared \
	-Bsymbolic \
	-nostdlib \
	-znocombreloc \
	$(GNUEFI_LIBS) \
	$(GNUEFI_LDS_DIR)/crt0-efi-$(ARCH).o

efi_objects = $(addprefix $(top_builddir)/,$(efi_sources:.c=.o))
efi_solib = $(top_builddir)/src/efi/gummiboot.so

# ------------------------------------------------------------------------------
gummibootlib_DATA = $(efi_loadername)
CLEANFILES += $(efi_objects) $(efi_solib) $(efi_loadername)
EXTRA_DIST += $(efi_sources)

$(top_builddir)/src/efi/%.o: $(top_srcdir)/src/efi/%.c
	@$(MKDIR_P) $(top_builddir)/src/efi/
	$(AM_V_CC)$(GNUEFI_CC) $(efi_cppflags) $(efi_cflags) -c $< -o $@

$(efi_solib): $(efi_objects)
	$(AM_V_CCLD)$(LD) $(efi_ldflags) $(efi_objects) \
		-o $@ -lefi -lgnuefi $(shell $(CC) -print-libgcc-file-name); \
	nm -D -u $@ | grep ' U ' && exit 1 || :
.DELETE_ON_ERROR: $(efi_solib)

$(efi_loadername): $(efi_solib)
	$(AM_V_GEN) objcopy -j .text -j .sdata -j .data -j .dynamic \
	  -j .dynsym -j .rel -j .rela -j .reloc -j .eh_frame \
	  --target=efi-app-$(ARCH) $< $@

# ------------------------------------------------------------------------------
CLEANFILES += test-disk
EXTRA_DIST += test/test-create-disk.sh

test-disk: gummiboot$(MACHINE_TYPE_NAME).efi test/test-create-disk.sh
	$(AM_V_GEN)test/test-create-disk.sh

qemu: test-disk
	$(QEMU_KVM) -m 256 -L $(BIOS) -snapshot test-disk

install-tree: all
	rm -rf $(abs_srcdir)/install-tree
	$(MAKE) install DESTDIR=$(abs_srcdir)/install-tree
	tree $(abs_srcdir)/install-tree