Skip to content

Commit 4de9e1b

Browse files
zhijianli88lijinxia
authored andcommitted
HV Makefile: fix detection of gnu-efi tools location
The previous logic assumes LIBDIR to be /usr/lib64 if it exists. some x86_64 distros, like ubuntu and debian, the default x86_64 libs(gnu-efi) are installed into /usr/lib while /usr/lib64 is for i386 ~/workspace$ dpkg -L gnu-efi | grep elf_x86_64_efi.lds /usr/lib/elf_x86_64_efi.lds ~/workspace$ dpkg -S /usr/lib64 libc6-amd64:i386: /usr/lib64 so it failed to compile efi perviously as following errors: ----------------- ld: cannot open linker script file /usr/lib64/elf_x86_64_efi.lds: No such file or directory Makefile:102: recipe for target '/home/lizj/workspace/acrn-hypervisor/build/hypervisor/bsp/uefi/efi/boot.so' failed make[2]: *** [/home/lizj/workspace/acrn-hypervisor/build/hypervisor/bsp/uefi/efi/boot.so] Error 1 make[2]: Leaving directory '/home/lizj/workspace/acrn-hypervisor/hypervisor/bsp/uefi/efi' Makefile:191: recipe for target 'efi' failed make[1]: *** [efi] Error 2 ----------------- v3: Keep the LIBDIR determination logic for linking ('-lgnuefi -lefi'). v2: addressed Geoffroy's comments Acked-by: "VanCutsem, Geoffroy" <geoffroy.vancutsem@intel.com> Signed-off-by: Li Zhijian <lizhijian@cn.fujitsu.com>
1 parent c585172 commit 4de9e1b

File tree

1 file changed

+9
-14
lines changed

1 file changed

+9
-14
lines changed

hypervisor/bsp/uefi/efi/Makefile

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -43,27 +43,22 @@ HOST = $(shell $(CC) -dumpmachine | sed "s/\(-\).*$$//")
4343
ARCH := $(shell $(CC) -dumpmachine | sed "s/\(-\).*$$//")
4444

4545
ifeq ($(ARCH),x86_64)
46-
LIBDIR := $(shell if [ -d /usr/lib64 ]; then echo /usr/lib64; \
47-
else if [ -d /usr/lib ]; then echo /usr/lib; fi ; fi;)
4846
FORMAT=efi-app-x86-64
4947
else
5048
ARCH=ia32
51-
LIBDIR=/usr/lib32
5249
FORMAT=efi-app-ia32
5350
endif
5451

55-
INCDIR := /usr/include
56-
57-
# gnuefi sometimes installs these under a gnuefi/ directory, and sometimes not
58-
ifneq ("$(wildcard $(LIBDIR)/gnuefi/crt0-efi-$(ARCH).o)","")
59-
CRT0 := $(LIBDIR)/gnuefi/crt0-efi-$(ARCH).o
60-
LDSCRIPT := $(LIBDIR)/gnuefi/elf_$(ARCH)_efi.lds
61-
else
62-
CRT0 := $(LIBDIR)/crt0-efi-$(ARCH).o
63-
LDSCRIPT := $(LIBDIR)/elf_$(ARCH)_efi.lds
64-
endif
65-
52+
# Different Linux distributions have the 'gnu-efi' package install
53+
# its tools and libraries in different folders. The next couple of
54+
# variables will determine and set the right path for both the
55+
# tools $(GNUEFI_DIR) and libraries $(LIBDIR)
56+
GNUEFI_DIR := $(shell find /usr/lib* -name elf_$(ARCH)_efi.lds -type f | xargs dirname)
57+
LIBDIR := $(subst gnuefi,,$(GNUEFI_DIR))
58+
CRT0 := $(GNUEFI_DIR)/crt0-efi-$(ARCH).o
59+
LDSCRIPT := $(GNUEFI_DIR)/elf_$(ARCH)_efi.lds
6660

61+
INCDIR := /usr/include
6762

6863
CFLAGS=-I. -I.. -I$(INCDIR)/efi -I$(INCDIR)/efi/$(ARCH) \
6964
-DEFI_FUNCTION_WRAPPER -fPIC -fshort-wchar -ffreestanding \

0 commit comments

Comments
 (0)