From 3ffad59e2ed24e79d52ab65e511b0c7c8c9d15e5 Mon Sep 17 00:00:00 2001 From: Cyrill Gorcunov Date: Tue, 29 Sep 2015 22:26:21 +0300 Subject: [PATCH] piegen: Allow to compile piegen tool in cross environment To build piegen tool with different compiler/linker than gcc/ld -- simply run make as HOSTCC="host-compiler" HOSTLD="host-ld" make where host-compiler/ld is appropriate program needed. https://github.com/xemul/criu/issues/63 Signed-off-by: Cyrill Gorcunov Reviewed-by: Christopher Covington Signed-off-by: Pavel Emelyanov --- Makefile | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/Makefile b/Makefile index 0f0447962..c9011a863 100644 --- a/Makefile +++ b/Makefile @@ -32,8 +32,15 @@ NM := $(CROSS_COMPILE)nm SH := bash MAKE := make OBJCOPY := $(CROSS_COMPILE)objcopy +HOSTCC ?= gcc +HOSTLD ?= ld CFLAGS += $(USERCFLAGS) +HOSTCFLAGS ?= $(CFLAGS) + +export HOSTCC +export HOSTLD +export HOSTCFLAGS # # Fetch ARCH from the uname if not yet set @@ -209,12 +216,12 @@ $(ARCH_DIR): protobuf config ifeq ($(piegen-y),y) pie/piegen/%: config - $(Q) $(MAKE) $(build)=pie/piegen $@ + $(Q) CC=$(HOSTCC) LD=$(HOSTLD) CFLAGS="$(HOSTCFLAGS)" $(MAKE) $(build)=pie/piegen $@ pie/piegen: config - $(Q) $(MAKE) $(build)=pie/piegen all + $(Q) CC=$(HOSTCC) LD=$(HOSTLD) CFLAGS="$(HOSTCFLAGS)" $(MAKE) $(build)=pie/piegen all $(piegen): pie/piegen/built-in.o $(E) " LINK " $@ - $(Q) $(CC) $(CFLAGS) $^ $(LDFLAGS) -o $@ + $(Q) $(HOSTCC) $(HOSTCFLAGS) $^ $(LDFLAGS) -o $@ .PHONY: pie/piegen endif