-STRIP:=$(STAGING_DIR)/bin/sstrip
-PATCH=$(SCRIPT_DIR)/patch-kernel.sh
-SED:=$(STAGING_DIR)/bin/sed -i -e
-LINUX_DIR:=$(BUILD_DIR)/linux
-LINUX_HEADERS_DIR:=$(TOOL_BUILD_DIR)/linux
-
-
-HOST_ARCH:=$(shell $(HOSTCC) -dumpmachine | sed -e s'/-.*//' \
- -e 's/sparc.*/sparc/' \
- -e 's/arm.*/arm/g' \
- -e 's/m68k.*/m68k/' \
- -e 's/ppc/powerpc/g' \
- -e 's/v850.*/v850/g' \
- -e 's/sh[234]/sh/' \
- -e 's/mips-.*/mips/' \
- -e 's/mipsel-.*/mipsel/' \
- -e 's/cris.*/cris/' \
- -e 's/i[3-9]86/i386/' \
- )
-GNU_HOST_NAME:=$(HOST_ARCH)-pc-linux-gnu
-TARGET_CONFIGURE_OPTS=PATH=$(TARGET_PATH) \
- AR=$(TARGET_CROSS)ar \
- AS=$(TARGET_CROSS)as \
- LD=$(TARGET_CROSS)ld \
- NM=$(TARGET_CROSS)nm \
- CC=$(TARGET_CROSS)gcc \
- GCC=$(TARGET_CROSS)gcc \
- CXX=$(TARGET_CROSS)g++ \
- RANLIB=$(TARGET_CROSS)ranlib
-
-ifeq ($(ENABLE_LOCALE),true)
-DISABLE_NLS:=
+TARGET_CXX:=$(if $(CONFIG_INSTALL_LIBSTDCPP),$(TARGET_CROSS)g++,no)
+KPATCH:=$(SCRIPT_DIR)/patch-kernel.sh
+SED:=$(STAGING_DIR_HOST)/bin/sed -i -e
+CP:=cp -fpR
+LN:=ln -sf
+
+INSTALL_BIN:=install -m0755
+INSTALL_DIR:=install -d -m0755
+INSTALL_DATA:=install -m0644
+INSTALL_CONF:=install -m0600
+
+ifneq ($(CONFIG_CCACHE),)
+ TARGET_CC:= ccache $(TARGET_CC)
+ TARGET_CXX:= ccache $(TARGET_CXX)
+endif
+
+TARGET_CONFIGURE_OPTS = \
+ AR=$(TARGET_CROSS)ar \
+ AS="$(TARGET_CC) -c $(TARGET_CFLAGS)" \
+ LD=$(TARGET_CROSS)ld \
+ NM=$(TARGET_CROSS)nm \
+ CC="$(TARGET_CC)" \
+ GCC="$(TARGET_CC)" \
+ CXX="$(TARGET_CXX)" \
+ RANLIB=$(TARGET_CROSS)ranlib \
+ STRIP=$(TARGET_CROSS)strip \
+ OBJCOPY=$(TARGET_CROSS)objcopy \
+ OBJDUMP=$(TARGET_CROSS)objdump \
+ SIZE=$(TARGET_CROSS)size
+
+# strip an entire directory
+ifneq ($(CONFIG_NO_STRIP),)
+ RSTRIP:=:
+ STRIP:=:
+else
+ ifneq ($(CONFIG_USE_STRIP),)
+ STRIP:=$(TARGET_CROSS)strip $(call qstrip,$(CONFIG_STRIP_ARGS))
+ else
+ ifneq ($(CONFIG_USE_SSTRIP),)
+ STRIP:=$(STAGING_DIR_HOST)/bin/sstrip
+ endif
+ endif
+ RSTRIP:= \
+ NM="$(TARGET_CROSS)nm" \
+ STRIP="$(STRIP)" \
+ STRIP_KMOD="$(TARGET_CROSS)strip --strip-unneeded -R .comment -R .pdr -R .mdebug.abi32 -R .note.gnu.build-id -R .gnu.attributes -R .reginfo -x" \
+ $(SCRIPT_DIR)/rstrip.sh
+endif
+
+ifeq ($(CONFIG_ENABLE_LOCALE),true)
+ DISABLE_NLS:=--enable-nls
+else
+ DISABLE_NLS:=--disable-nls
+endif
+
+ifeq ($(CONFIG_IPV6),y)
+ DISABLE_IPV6:=
+else
+ DISABLE_IPV6:=--disable-ipv6
+endif
+
+ifeq ($(CONFIG_TAR_VERBOSITY),y)
+ TAR_OPTIONS:=-xvf -