Makefile: fix cross-compiling issues

Replace all the host paths with a prefix sysroot directory, it defaults
to be empty, but can be overridden by the variable set in
environment(make -e) or being passed to make command.

Tracked-On: #1307
Signed-off-by: Ming Liu <liu.ming50@gmail.com>
This commit is contained in:
Ming Liu 2018-09-25 08:57:34 +02:00 committed by lijinxia
parent 8787c06d3b
commit f1cce6710a
3 changed files with 9 additions and 9 deletions

View File

@ -53,12 +53,12 @@ endif
# its tools and libraries in different folders. The next couple of
# variables will determine and set the right path for both the
# tools $(GNUEFI_DIR) and libraries $(LIBDIR)
GNUEFI_DIR := $(shell find /usr/lib* -name elf_$(ARCH)_efi.lds -type f | xargs dirname)
GNUEFI_DIR := $(shell find $(SYSROOT)/usr/lib* -name elf_$(ARCH)_efi.lds -type f | xargs dirname)
LIBDIR := $(subst gnuefi,,$(GNUEFI_DIR))
CRT0 := $(GNUEFI_DIR)/crt0-efi-$(ARCH).o
LDSCRIPT := $(GNUEFI_DIR)/elf_$(ARCH)_efi.lds
INCDIR := /usr/include
INCDIR := $(SYSROOT)/usr/include
CFLAGS=-I. -I.. -I../../../include/arch/x86/guest -I$(INCDIR)/efi -I$(INCDIR)/efi/$(ARCH) \
-DEFI_FUNCTION_WRAPPER -fPIC -fshort-wchar -ffreestanding \

View File

@ -54,12 +54,12 @@ export BUILDDIR
export CC
export RM
PKG_CONFIG_PATH := $(PKG_CONFIG_PATH):/usr/lib/pkgconfig
PKG_CONFIG_PATH := $(PKG_CONFIG_PATH):/usr/share/pkgconfig
PKG_CONFIG_PATH := $(PKG_CONFIG_PATH):/usr/local/lib/pkgconfig
PKG_CONFIG_PATH := $(PKG_CONFIG_PATH):/usr/local/share/pkgconfig
PKG_CONFIG_PATH := $(PKG_CONFIG_PATH):/usr/lib32/pkgconfig
PKG_CONFIG_PATH := $(PKG_CONFIG_PATH):/usr/lib64/pkgconfig
PKG_CONFIG_PATH := $(PKG_CONFIG_PATH):$(SYSROOT)/usr/lib/pkgconfig
PKG_CONFIG_PATH := $(PKG_CONFIG_PATH):$(SYSROOT)/usr/share/pkgconfig
PKG_CONFIG_PATH := $(PKG_CONFIG_PATH):$(SYSROOT)/usr/local/lib/pkgconfig
PKG_CONFIG_PATH := $(PKG_CONFIG_PATH):$(SYSROOT)/usr/local/share/pkgconfig
PKG_CONFIG_PATH := $(PKG_CONFIG_PATH):$(SYSROOT)/usr/lib32/pkgconfig
PKG_CONFIG_PATH := $(PKG_CONFIG_PATH):$(SYSROOT)/usr/lib64/pkgconfig
EXTRA_LIBS = -lsystemd-journal
PKG_CONFIG := $(shell export PKG_CONFIG_PATH=$(PKG_CONFIG_PATH); \

View File

@ -5,7 +5,7 @@ VERSION_H = $(BUILDDIR)/include/acrnprobe/version.h
LIBS = -lpthread -lxml2 -lcrypto -lrt -lblkid -lext2fs -lcom_err \
$(EXTRA_LIBS)
INCLUDE += -I $(CURDIR)/include -I /usr/include/libxml2
INCLUDE += -I $(CURDIR)/include -I $(SYSROOT)/usr/include/libxml2
INCLUDE += -I $(BUILDDIR)/include/acrnprobe
CFLAGS += $(INCLUDE)
CFLAGS += -fdata-sections