build-sys: add automake stuff for src/efi
authorKarel Zak <kzak@redhat.com>
Thu, 28 Feb 2013 18:41:32 +0000 (19:41 +0100)
committerKarel Zak <kzak@redhat.com>
Fri, 1 Mar 2013 10:50:18 +0000 (11:50 +0100)
 - implemented by on automake independent build rules
 - uses automake _DATA for make install

Signed-off-by: Karel Zak <kzak@redhat.com>
Makefile.am
autogen.sh
configure.ac

index b00dec3..bb82bf3 100644 (file)
@@ -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) $< $@
index 8e063ec..0c67475 100755 (executable)
@@ -25,6 +25,7 @@ libdir() {
 
 args="\
 --sysconfdir=/etc \
+--libexecdir=/usr/lib \
 --libdir=$(libdir /usr/lib)"
 
 if [ "x$1" = "xc" ]; then
index cb22632..f85fb61 100644 (file)
@@ -107,6 +107,7 @@ AC_MSG_RESULT([
         machine type:            $MACHINE_TYPE_NAME
 
         prefix:                  ${prefix}
+        libexecdir:              ${libexecdir}
         libdir:                  ${libdir}
 
        blkid:                   ${have_blkid}