[syslinux] [PATCH 2/4] efi: Proper dependencies to gnu-efi

celelibi at gmail.com celelibi at gmail.com
Sun Sep 13 20:50:57 PDT 2015


From: Sylvain Gault <sylvain.gault at gmail.com>

The Makefile dependencies weren't good enough to recompile / relink when
the gnu-efi headers / objects were updated.

Signed-off-by: Sylvain Gault <sylvain.gault at gmail.com>
---
 efi/Makefile |  5 +++--
 mk/efi.mk    | 21 ++++++++++++++++-----
 2 files changed, 19 insertions(+), 7 deletions(-)

diff --git a/efi/Makefile b/efi/Makefile
index bbf23f2..4fdcedd 100644
--- a/efi/Makefile
+++ b/efi/Makefile
@@ -68,8 +68,9 @@ $(OBJS): | $(OBJ)/$(ARCH)
 # The targets to build in this directory
 BTARGET  = syslinux.efi
 
-syslinux.so: $(OBJS) $(CORE_OBJS) $(LIB_OBJS)
-	$(LD) $(LDFLAGS) --strip-debug -o $@ $^ -lgnuefi -lefi
+syslinux.so: $(OBJS) $(CORE_OBJS) $(LIB_OBJS) $(CRT0) $(LIBEFI)
+	$(LD) $(LDFLAGS) --strip-debug -o $@ $(OBJS) $(CORE_OBJS) $(LIB_OBJS) \
+		$(LDLIBSEFI)
 
 # We need to rename the .hash section because the EFI firmware
 # linker really doesn't like it.
diff --git a/mk/efi.mk b/mk/efi.mk
index f097ad2..a705440 100644
--- a/mk/efi.mk
+++ b/mk/efi.mk
@@ -44,9 +44,16 @@ SFLAGS     = $(GCCOPT) $(GCCWARN) $(ARCHOPT) \
 	     -nostdinc -iwithprefix include \
 	     -I$(com32)/libutil/include -I$(com32)/include -I$(com32)/include/sys $(GPLINCLUDE)
 
-LIBEFI = $(objdir)/lib/libefi.a
+LIBEFI = $(LIBDIR)/libefi.a $(LIBDIR)/libgnuefi.a
+LDLIBSEFI = $(patsubst $(LIBDIR)/lib%.a,-l%,$(LIBEFI))
 
-$(LIBEFI):
+# The empty commands are needed in order to force make to check the files date
+$(LIBEFI): gnuefi ;
+$(CRT0) $(LDSCRIPT): gnuefi ;
+$(EFIINC)/%.h $(EFIINC)/protocol/%.h $(EFIINC)/$(EFI_SUBARCH)/%.h: gnuefi ;
+
+.PHONY: gnuefi
+gnuefi:
 	@echo Building gnu-efi for $(EFI_SUBARCH)
 	$(topdir)/efi/check-gnu-efi.sh $(EFI_SUBARCH) $(objdir)
 
@@ -55,11 +62,15 @@ $(LIBEFI):
 %.o: %.c
 
 .PRECIOUS: %.o
-%.o: %.S $(LIBEFI)
+%.o: %.S
 	$(CC) $(SFLAGS) -c -o $@ $<
 
-.PRECIOUS: %.o
-%.o: %.c $(LIBEFI)
+# efi/*.c depends on some headers installed by gnuefi, so here we add two
+# dependencies that are always installed. And since gnu-efi is installed as a
+# whole by check-gnu-efi.sh, those two headers are always a good timestamp
+# marker.
+.SECONDARY: $(EFIINC)/efi.h $(EFIINC)/efilib.h
+%.o: %.c $(EFIINC)/efi.h $(EFIINC)/efilib.h
 	$(CC) $(CFLAGS) -c -o $@ $<
 
 #%.efi: %.so
-- 
2.5.1



More information about the Syslinux mailing list