Brad Bishop | 96ff198 | 2019-08-19 13:50:42 -0400 | [diff] [blame^] | 1 | From 97668ae0bce776a36ea2001dea63d376be8274ac Mon Sep 17 00:00:00 2001 |
| 2 | From: Peter Jones <pjones@redhat.com> |
| 3 | Date: Wed, 6 Mar 2019 13:08:33 -0500 |
| 4 | Subject: [PATCH] Make sure PKGS= is propogated into the submake for "make |
| 5 | deps" |
| 6 | |
| 7 | When we're doing make deps with "$(CC) -MF", gcc and clang have different |
| 8 | behavior, both broken in different ways, which we're hitting because of a |
| 9 | missing -I argument for libefivar's includes. On clang, when a header can't |
| 10 | be found, it emits a rule with the header as a prerequisite without a path, |
| 11 | such as efivar.h here: |
| 12 | |
| 13 | efibootmgr.o: efibootmgr.c fix_coverity.h efivar.h efiboot.h \ |
| 14 | /home/pjones/devel/github.com/efibootmgr/master/src/include/list.h \ |
| 15 | /home/pjones/devel/github.com/efibootmgr/master/src/include/efi.h \ |
| 16 | /home/pjones/devel/github.com/efibootmgr/master/src/include/unparse_path.h \ |
| 17 | /home/pjones/devel/github.com/efibootmgr/master/src/include/efibootmgr.h \ |
| 18 | error.h |
| 19 | |
| 20 | Then the build that utilizes that rule will fail to find the |
| 21 | prerequisite and tell you something like: |
| 22 | |
| 23 | make[1]: *** No rule to make target 'efivar.h', needed by 'efibootmgr.o'. Stop. |
| 24 | make[1]: Leaving directory '/home/pjones/devel/github.com/efibootmgr/master/src' |
| 25 | |
| 26 | With gcc, when a header can't be found, it emits a rule without that header |
| 27 | as a prerequisite, as such (again with efivar.h): |
| 28 | |
| 29 | efibootmgr.o: efibootmgr.c fix_coverity.h \ |
| 30 | /home/pjones/devel/github.com/efibootmgr/master/src/include/list.h \ |
| 31 | /home/pjones/devel/github.com/efibootmgr/master/src/include/efi.h \ |
| 32 | /home/pjones/devel/github.com/efibootmgr/master/src/include/unparse_path.h \ |
| 33 | /home/pjones/devel/github.com/efibootmgr/master/src/include/efi.h \ |
| 34 | /home/pjones/devel/github.com/efibootmgr/master/src/include/efibootmgr.h \ |
| 35 | error.h |
| 36 | |
| 37 | And then your build will fail if you haven't adjusted CFLAGS to tell it |
| 38 | where to find the header. |
| 39 | |
| 40 | Both of these would be better just erroring, but at least gcc's doesn't |
| 41 | insert a *wrong* dependency. |
| 42 | |
| 43 | This patch adds "PKGS=efivar efibootmgr popt" for all deps under src/. |
| 44 | Technically that's overkill, as efibootmgr itself doesn't need popt, but it |
| 45 | doesn't hurt anything to have the extra part there. The resulting |
| 46 | .efibootmgr.d file has the prerequisites expressed correctly: |
| 47 | |
| 48 | efibootmgr.o: efibootmgr.c fix_coverity.h /usr/include/efivar/efivar.h \ |
| 49 | /usr/include/efivar/efiboot.h \ |
| 50 | /home/pjones/devel/github.com/efibootmgr/master/src/include/list.h \ |
| 51 | /home/pjones/devel/github.com/efibootmgr/master/src/include/efi.h \ |
| 52 | /home/pjones/devel/github.com/efibootmgr/master/src/include/unparse_path.h \ |
| 53 | /home/pjones/devel/github.com/efibootmgr/master/src/include/efi.h \ |
| 54 | /home/pjones/devel/github.com/efibootmgr/master/src/include/efibootmgr.h \ |
| 55 | error.h |
| 56 | |
| 57 | This fixes the issue described in github PR #96 |
| 58 | |
| 59 | Signed-off-by: Peter Jones <pjones@redhat.com> |
| 60 | Upstream-Status: Backport [https://github.com/rhboot/efibootmgr/commit/97668ae0bce776a36ea2001dea63d376be8274ac] |
| 61 | --- |
| 62 | src/Makefile | 7 ++++++- |
| 63 | 1 file changed, 6 insertions(+), 1 deletion(-) |
| 64 | |
| 65 | diff --git a/src/Makefile b/src/Makefile |
| 66 | index 258bac1..32fa188 100644 |
| 67 | --- a/src/Makefile |
| 68 | +++ b/src/Makefile |
| 69 | @@ -31,8 +31,13 @@ efibootdump : PKGS=efivar efiboot popt |
| 70 | efibootnext : $(call objects-of,$(EFIBOOTNEXT_SOURCES)) |
| 71 | efibootnext : PKGS=efivar efiboot popt |
| 72 | |
| 73 | +deps : PKGS=efivar efiboot popt |
| 74 | deps : $(ALL_SOURCES) |
| 75 | - $(MAKE) -f $(TOPDIR)/Make.deps deps SOURCES="$(ALL_SOURCES)" SUBDIR_CFLAGS="$(SUBDIR_CFLAGS)" |
| 76 | + $(MAKE) -f $(TOPDIR)/Make.deps \ |
| 77 | + SOURCES="$(ALL_SOURCES)" \ |
| 78 | + SUBDIR_CFLAGS="$(SUBDIR_CFLAGS)" \ |
| 79 | + PKGS="$(PKGS)" \ |
| 80 | + deps |
| 81 | |
| 82 | clean : |
| 83 | @rm -rfv *.o *.a *.so $(TARGETS) |