+ifneq ($(filter -march=armv%,$(TARGET_OPTIMIZATION)),)
+ ARCH_SUFFIX:=_$(patsubst -march=arm%,%,$(filter -march=armv%,$(TARGET_OPTIMIZATION)))
+ GCC_ARCH:=$(patsubst -march=%,%,$(filter -march=armv%,$(TARGET_OPTIMIZATION)))
+endif
+ifneq ($(findstring -mips32r2,$(TARGET_OPTIMIZATION)),)
+ ARCH_SUFFIX:=_r2
+endif
+ifdef CONFIG_HAS_SPE_FPU
+ TARGET_SUFFIX:=$(TARGET_SUFFIX)spe
+endif
+
+DL_DIR:=$(if $(call qstrip,$(CONFIG_DOWNLOAD_FOLDER)),$(call qstrip,$(CONFIG_DOWNLOAD_FOLDER)),$(TOPDIR)/dl)
+BIN_DIR:=$(TOPDIR)/bin/$(BOARD)
+INCLUDE_DIR:=$(TOPDIR)/include
+SCRIPT_DIR:=$(TOPDIR)/scripts
+BUILD_DIR_BASE:=$(TOPDIR)/build_dir
+BUILD_DIR_HOST:=$(BUILD_DIR_BASE)/host
+STAGING_DIR_HOST:=$(TOPDIR)/staging_dir/host
+ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
+ GCCV:=$(call qstrip,$(CONFIG_GCC_VERSION))
+ LIBC:=$(call qstrip,$(CONFIG_LIBC))
+ LIBCV:=$(call qstrip,$(CONFIG_LIBC_VERSION))
+ REAL_GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-openwrt-linux$(if $(TARGET_SUFFIX),-$(TARGET_SUFFIX))
+ GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-openwrt-linux
+ DIR_SUFFIX:=_$(LIBC)-$(LIBCV)$(if $(CONFIG_arm),_eabi)
+ BUILD_DIR:=$(BUILD_DIR_BASE)/target-$(ARCH)$(ARCH_SUFFIX)$(DIR_SUFFIX)$(if $(BUILD_SUFFIX),_$(BUILD_SUFFIX))
+ STAGING_DIR:=$(TOPDIR)/staging_dir/target-$(ARCH)$(ARCH_SUFFIX)$(DIR_SUFFIX)
+ BUILD_DIR_TOOLCHAIN:=$(BUILD_DIR_BASE)/toolchain-$(ARCH)$(ARCH_SUFFIX)_gcc-$(GCCV)$(DIR_SUFFIX)
+ TOOLCHAIN_DIR:=$(TOPDIR)/staging_dir/toolchain-$(ARCH)$(ARCH_SUFFIX)_gcc-$(GCCV)$(DIR_SUFFIX)
+ PACKAGE_DIR:=$(BIN_DIR)/packages
+else
+ ifeq ($(CONFIG_NATIVE_TOOLCHAIN),)
+ GNU_TARGET_NAME=$(call qstrip,$(CONFIG_TARGET_NAME))
+ else
+ GNU_TARGET_NAME=$(shell gcc -dumpmachine)
+ endif
+ REAL_GNU_TARGET_NAME=$(GNU_TARGET_NAME)
+ BUILD_DIR:=$(BUILD_DIR_BASE)/target-$(GNU_TARGET_NAME)$(if $(BUILD_SUFFIX),_$(BUILD_SUFFIX))
+ STAGING_DIR:=$(TOPDIR)/staging_dir/target-$(GNU_TARGET_NAME)
+ BUILD_DIR_TOOLCHAIN:=$(BUILD_DIR_BASE)/toolchain-$(GNU_TARGET_NAME)
+ TOOLCHAIN_DIR:=$(TOPDIR)/staging_dir/toolchain-$(GNU_TARGET_NAME)
+ PACKAGE_DIR:=$(BIN_DIR)/packages
+endif
+STAMP_DIR:=$(BUILD_DIR)/stamp
+STAMP_DIR_HOST=$(BUILD_DIR_HOST)/stamp
+TARGET_ROOTFS_DIR?=$(if $(call qstrip,$(CONFIG_TARGET_ROOTFS_DIR)),$(call qstrip,$(CONFIG_TARGET_ROOTFS_DIR)),$(BUILD_DIR))
+TARGET_DIR:=$(TARGET_ROOTFS_DIR)/root-$(BOARD)
+STAGING_DIR_ROOT:=$(STAGING_DIR)/root-$(BOARD)
+BUILD_LOG_DIR:=$(TOPDIR)/logs
+
+TARGET_PATH:=$(STAGING_DIR_HOST)/bin:$(PATH)
+TARGET_CFLAGS:=$(TARGET_OPTIMIZATION)$(if $(CONFIG_DEBUG), -g3)
+TARGET_CPPFLAGS:=-I$(STAGING_DIR)/usr/include -I$(STAGING_DIR)/include
+TARGET_LDFLAGS:=-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib
+ifneq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
+LIBGCC_S_PATH=$(realpath $(wildcard $(call qstrip,$(CONFIG_LIBGCC_ROOT_DIR))/$(call qstrip,$(CONFIG_LIBGCC_FILE_SPEC))))
+LIBGCC_S=$(if $(LIBGCC_S_PATH),-L$(dir $(LIBGCC_S_PATH)) -lgcc_s)