-CP=cp -fpR
-MAKE1=make
-MAKEFLAGS=-j$(CONFIG_JLEVEL) V=$(V) $(EXTRA_MAKEFLAGS)
-# Strip off the annoying quoting
-ARCH:=$(strip $(subst ",, $(CONFIG_ARCH)))
-WGET:=$(strip $(subst ",, $(CONFIG_WGET)))
-GCC_VERSION:=$(strip $(subst ",, $(CONFIG_GCC_VERSION)))
-GCC_USE_SJLJ_EXCEPTIONS:=$(strip $(subst ",, $(CONFIG_GCC_USE_SJLJ_EXCEPTIONS)))
-TARGET_OPTIMIZATION:=$(strip $(subst ",, $(CONFIG_TARGET_OPTIMIZATION)))
-#"))"))"))"))")) # for vim's broken syntax highlighting :)
-
-
-ifeq ($(CONFIG_SOFT_FLOAT),y)
-# gcc 3.4.x soft float configuration is different than previous versions.
-ifeq ($(findstring 3.4.,$(GCC_VERSION)),3.4.)
-SOFT_FLOAT_CONFIG_OPTION:=--with-float=soft
-else
-SOFT_FLOAT_CONFIG_OPTION:=--without-float
-endif
-TARGET_SOFT_FLOAT:=-msoft-float
-ARCH_FPU_SUFFIX:=_nofpu
-else
-SOFT_FLOAT_CONFIG_OPTION:=
-TARGET_SOFT_FLOAT:=
-ARCH_FPU_SUFFIX:=
+define qstrip
+$(strip $(subst ",,$(1)))
+endef
+#"))
+
+ARCH:=$(call qstrip,$(shell echo $(CONFIG_ARCH) | sed -e 's/i[3-9]86/i386/'))
+BOARD:=$(call qstrip,$(CONFIG_TARGET_BOARD))
+TARGET_OPTIMIZATION:=$(call qstrip,$(CONFIG_TARGET_OPTIMIZATION))
+BUILD_SUFFIX:=$(call qstrip,$(CONFIG_BUILD_SUFFIX))
+GCCV:=$(call qstrip,$(CONFIG_GCC_VERSION))
+SUBDIR:=$(patsubst $(TOPDIR)/%,%,${CURDIR})
+
+OPTIMIZE_FOR_CPU=$(ARCH)
+
+DL_DIR:=$(if $(call qstrip,$(CONFIG_DOWNLOAD_FOLDER)),$(call qstrip,$(CONFIG_DOWNLOAD_FOLDER)),$(TOPDIR)/dl)
+BIN_DIR:=$(TOPDIR)/bin
+INCLUDE_DIR:=$(TOPDIR)/include
+SCRIPT_DIR:=$(TOPDIR)/scripts
+BUILD_DIR_BASE:=$(TOPDIR)/build_dir
+BUILD_DIR:=$(BUILD_DIR_BASE)/$(ARCH)$(if $(BUILD_SUFFIX),_$(BUILD_SUFFIX))
+BUILD_DIR_HOST:=$(BUILD_DIR_BASE)/host
+BUILD_DIR_TOOLCHAIN:=$(BUILD_DIR_BASE)/toolchain-$(ARCH)_gcc$(GCCV)
+STAGING_DIR:=$(TOPDIR)/staging_dir/$(ARCH)
+STAGING_DIR_HOST:=$(TOPDIR)/staging_dir/host
+TOOLCHAIN_DIR:=$(TOPDIR)/staging_dir/toolchain-$(ARCH)_gcc$(GCCV)
+PACKAGE_DIR:=$(BIN_DIR)/packages/$(TARGET)
+STAMP_DIR:=$(BUILD_DIR)/stamp
+STAMP_DIR_HOST=$(BUILD_DIR_HOST)/stamp
+TARGET_DIR:=$(BUILD_DIR)/root-$(BOARD)
+IPKG_STATE_DIR:=$(TARGET_DIR)/usr/lib/ipkg
+
+ifeq ($(CONFIG_NATIVE_TOOLCHAIN),)
+ -include $(TOOLCHAIN_DIR)/info.mk
+ REAL_GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux-uclibc
+ GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-linux
+ TARGET_CROSS:=$(if $(TARGET_CROSS),$(TARGET_CROSS),$(OPTIMIZE_FOR_CPU)-linux-uclibc-)