summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2013-02-28 19:41:32 +0100
committerKarel Zak <kzak@redhat.com>2013-03-01 11:50:18 +0100
commit83906a9b920c05a5cf6a89beaee4ab7297cf2e31 (patch)
treeaad1481eb01ecd41efd20f6e37ec6b2228af8291
parent3804212cc804496a6e57c429afaab6d0d9237c8c (diff)
build-sys: add automake stuff for src/efi
- implemented by on automake independent build rules - uses automake _DATA for make install Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--Makefile.am66
-rwxr-xr-xautogen.sh1
-rw-r--r--configure.ac1
3 files changed, 68 insertions, 0 deletions
diff --git a/Makefile.am b/Makefile.am
index b00dec3..bb82bf3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -19,6 +19,8 @@
ACLOCAL_AMFLAGS = -I m4 ${ACLOCAL_FLAGS}
AM_MAKEFLAGS =
+gummibootlibdir = $(libexecdir)/gummiboot
+
AM_CPPFLAGS = -include config.h
AM_CFLAGS =
AM_LDFLAGS =
@@ -56,3 +58,67 @@ gummiboot_LDADD = \
--stringparam man.authors.section.enabled 0 \
--stringparam man.copyright.section.enabled 0 \
http://docbook.sourceforge.net/release/xsl/current/manpages/docbook.xsl $<
+
+#
+# EFI compilation
+#
+# This part of the build system uses custom make rules and bypass 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/usr/include/efi \
+ -I/usr/include/efi/$(ARCH) \
+ -DVERSION=$(VERSION)
+
+efi_cflags = \
+ -Wall \
+ -Wextra \
+ -nostdinc \
+ -ggdb -O0 \
+ -fpic \
+ -fshort-wchar \
+ -nostdinc \
+ -ffreestanding \
+ -fno-strict-aliasing \
+ -fno-stack-protector \
+ -Wsign-compare
+
+if ARCH_X86_64
+efi_cflags += \
+ -DEFI_FUNCTION_WRAPPER \
+ -mno-red-zone
+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
+
+# automake stuff
+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 || :
+
+$(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) $< $@
diff --git a/autogen.sh b/autogen.sh
index 8e063ec..0c67475 100755
--- a/autogen.sh
+++ b/autogen.sh
@@ -25,6 +25,7 @@ libdir() {
args="\
--sysconfdir=/etc \
+--libexecdir=/usr/lib \
--libdir=$(libdir /usr/lib)"
if [ "x$1" = "xc" ]; then
diff --git a/configure.ac b/configure.ac
index cb22632..f85fb61 100644
--- a/configure.ac
+++ b/configure.ac
@@ -107,6 +107,7 @@ AC_MSG_RESULT([
machine type: $MACHINE_TYPE_NAME
prefix: ${prefix}
+ libexecdir: ${libexecdir}
libdir: ${libdir}
blkid: ${have_blkid}