Attempt to fix cross compilation for libpayload / coreinfo by honoring
the setting of CC in the payload (coreinfo) when calling

make CC=i386-elf-gcc AS=i386-elf-as AR=i386-elf-ar STRIP=i386-elf-strip

This still does not cope with the hardcoded -fno-stack-protector in
libpayload's Makefile.

Signed-off-by: Stefan Reinauer <stepan@coresystems.de>


Index: libpayload/bin/lpgcc
===================================================================
--- libpayload/bin/lpgcc	(revision 3473)
+++ libpayload/bin/lpgcc	(working copy)
@@ -28,8 +28,7 @@
 
 # GCC wrapper for libpayload
 
-DEFAULT_PREFIX=/opt
-DEFAULT_CC=gcc
+DEFAULT_CC=$CC
 
 BASE=`dirname $0`
 
@@ -37,9 +36,10 @@
 . $BASE/lp.functions
 
 trygccoption() {
-	$DEFAULT_CC $1 -S -xc /dev/null -o .$$.tmp > /dev/null
+	$DEFAULT_CC $1 -S -xc /dev/null -o .$$.tmp &> /dev/null
+	RET=$?
 	rm -f .$$.tmp
-	return $?
+	return $RET
 }
 
 DEBUGME=0
Index: libpayload/util/kconfig/lxdialog/check-lxdialog.sh
===================================================================
--- libpayload/util/kconfig/lxdialog/check-lxdialog.sh	(revision 3473)
+++ libpayload/util/kconfig/lxdialog/check-lxdialog.sh	(working copy)
@@ -19,6 +19,11 @@
 		echo '-lcurses'
 		exit
 	fi
+	$cc -print-file-name=libcurses.dylib | grep -q /
+	if [ $? -eq 0 ]; then
+		echo '-lcurses'
+		exit
+	fi
 	exit 1
 }
 
Index: coreinfo/Makefile
===================================================================
--- coreinfo/Makefile	(revision 3472)
+++ coreinfo/Makefile	(working copy)
@@ -45,8 +45,9 @@
 HOSTCXXFLAGS := -I$(srck) -I$(objk)
 
 LIBPAYLOAD_DIR := ../libpayload
-CC = $(LIBPAYLOAD_DIR)/bin/lpgcc
+XCC := CC=$(CC) $(LIBPAYLOAD_DIR)/bin/lpgcc
 AS = $(LIBPAYLOAD_DIR)/bin/lpas
+STRIP ?= strip
 
 INCLUDES = -Ibuild
 CFLAGS := -Wall -Werror -Os $(INCLUDES)
@@ -68,9 +69,9 @@
 
 $(TARGET): $(src)/.config $(OBJS)
 	$(Q)printf "  LD      $(subst $(shell pwd)/,,$(@))\n"
-	$(Q)$(CC) -o $@ $(OBJS)
+	$(Q)$(XCC) -o $@ $(OBJS)
 	$(Q)printf "  STRIP   $(subst $(shell pwd)/,,$(@))\n"
-	$(Q)strip -s $@
+	$(Q)$(STRIP) -s $@
 
 $(obj)/%.S.o: $(src)/%.S
 	$(Q)printf "  AS      $(subst $(shell pwd)/,,$(@))\n"
@@ -78,7 +79,7 @@
 
 $(obj)/%.o: $(src)/%.c
 	$(Q)printf "  CC      $(subst $(shell pwd)/,,$(@))\n"
-	$(Q)$(CC) $(CFLAGS) -c -o $@ $<
+	$(Q)$(XCC) $(CFLAGS) -c -o $@ $<
 
 endif
 
