# # Copyright (C) 2006-2010 OpenWrt.org # Copyright (C) 2016 LEDE Project # # This is free software, licensed under the GNU General Public License v2. # See /LICENSE for more information. # ifneq ($(__rules_inc),1) __rules_inc=1 ifeq ($(DUMP),) -include $(TOPDIR)/.config endif include $(TOPDIR)/include/debug.mk include $(TOPDIR)/include/verbose.mk ifneq ($(filter check,$(MAKECMDGOALS)),) CHECK:=1 DUMP:=1 endif export TMP_DIR:=$(TOPDIR)/tmp export TMPDIR:=$(TMP_DIR) qstrip=$(strip $(subst ",,$(1))) #")) empty:= space:= $(empty) $(empty) comma:=, merge=$(subst $(space),,$(1)) confvar=$(shell echo '$(foreach v,$(1),$(v)=$(subst ','\'',$($(v))))' | $(STAGING_DIR_HOST)/bin/mkhash md5) strip_last=$(patsubst %.$(lastword $(subst .,$(space),$(1))),%,$(1)) paren_left = ( paren_right = ) chars_lower = a b c d e f g h i j k l m n o p q r s t u v w x y z chars_upper = A B C D E F G H I J K L M N O P Q R S T U V W X Y Z define sep endef define newline endef __tr_list = $(join $(join $(1),$(foreach char,$(1),$(comma))),$(2)) __tr_head_stripped = $(subst $(space),,$(foreach cv,$(call __tr_list,$(1),$(2)),$$$(paren_left)subst$(cv)$(comma))) __tr_head = $(subst $(paren_left)subst,$(paren_left)subst$(space),$(__tr_head_stripped)) __tr_tail = $(subst $(space),,$(foreach cv,$(1),$(paren_right))) __tr_template = $(__tr_head)$$(1)$(__tr_tail) $(eval toupper = $(call __tr_template,$(chars_lower),$(chars_upper))) $(eval tolower = $(call __tr_template,$(chars_upper),$(chars_lower))) version_abbrev = $(if $(if $(CHECK),,$(DUMP)),$(1),$(shell printf '%.8s' $(1))) _SINGLE=export MAKEFLAGS=$(space); CFLAGS:= ARCH:=$(subst i486,i386,$(subst i586,i386,$(subst i686,i386,$(call qstrip,$(CONFIG_ARCH))))) ARCH_PACKAGES:=$(call qstrip,$(CONFIG_TARGET_ARCH_PACKAGES)) BOARD:=$(call qstrip,$(CONFIG_TARGET_BOARD)) SUBTARGET:=$(call qstrip,$(CONFIG_TARGET_SUBTARGET)) TARGET_OPTIMIZATION:=$(call qstrip,$(CONFIG_TARGET_OPTIMIZATION)) export EXTRA_OPTIMIZATION:=$(filter-out -fno-plt,$(call qstrip,$(CONFIG_EXTRA_OPTIMIZATION))) TARGET_SUFFIX=$(call qstrip,$(CONFIG_TARGET_SUFFIX)) BUILD_SUFFIX:=$(call qstrip,$(CONFIG_BUILD_SUFFIX)) SUBDIR:=$(patsubst $(TOPDIR)/%,%,${CURDIR}) BUILD_SUBDIR:=$(patsubst $(TOPDIR)/%,%,${CURDIR}) NPROC:=$(shell sysctl -n hw.ncpu 2>/dev/null || nproc) export SHELL:=/usr/bin/env bash IS_PACKAGE_BUILD := $(if $(filter package/%,$(BUILD_SUBDIR)),1) OPTIMIZE_FOR_CPU=$(subst i386,i486,$(ARCH)) ifeq ($(ARCH),powerpc) FPIC:=-fPIC else FPIC:=-fpic endif HOST_FPIC:=-fPIC ARCH_SUFFIX:=$(call qstrip,$(CONFIG_CPU_TYPE)) GCC_ARCH:= ifneq ($(ARCH_SUFFIX),) ARCH_SUFFIX:=_$(ARCH_SUFFIX) endif ifneq ($(filter -march=armv%,$(TARGET_OPTIMIZATION)),) GCC_ARCH:=$(patsubst -march=%,%,$(filter -march=armv%,$(TARGET_OPTIMIZATION))) endif ifdef CONFIG_HAS_SPE_FPU TARGET_SUFFIX:=$(TARGET_SUFFIX)spe endif ifdef CONFIG_MIPS64_ABI ifneq ($(CONFIG_MIPS64_ABI_O32),y) ARCH_SUFFIX:=$(ARCH_SUFFIX)_$(call qstrip,$(CONFIG_MIPS64_ABI)) endif endif DEFAULT_SUBDIR_TARGETS:=clean download prepare compile update refresh prereq dist distcheck configure check check-depends define DefaultTargets $(foreach t,$(DEFAULT_SUBDIR_TARGETS) $(1), .$(t): $(t): .$(t) .PHONY: $(t) .$(t) ) endef DL_DIR:=$(if $(call qstrip,$(CONFIG_DOWNLOAD_FOLDER)),$(call qstrip,$(CONFIG_DOWNLOAD_FOLDER)),$(TOPDIR)/dl) OUTPUT_DIR:=$(if $(call qstrip,$(CONFIG_BINARY_FOLDER)),$(call qstrip,$(CONFIG_BINARY_FOLDER)),$(TOPDIR)/bin) BIN_DIR:=$(OUTPUT_DIR)/targets/$(BOARD)/$(SUBTARGET) INCLUDE_DIR:=$(TOPDIR)/include SCRIPT_DIR:=$(TOPDIR)/scripts BUILD_DIR_BASE:=$(TOPDIR)/build_dir ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),) GCCV:=$(call qstrip,$(CONFIG_GCC_VERSION)) LIBC:=$(call qstrip,$(CONFIG_LIBC)) REAL_GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-openwrt-linux$(