# # 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 export TMP_DIR:=$(TOPDIR)/tmp qstrip=$(strip $(subst ",,$(1))) #")) empty:= space:= $(empty) $(empty) comma:=, merge=$(subst $(space),,$(1)) confvar=$(call merge,$(foreach v,$(1),$(if $($(v)),y,n))) 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))) _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}) 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 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)) 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) BIN_DIR:=$(BIN_DIR)$(if $(CONFIG_USE_MUSL),,-$(LIBC)) TARGET_DIR_NAME = target-$(ARCH)$(ARCH_SUFFIX)$(DIR_SUFFIX)$(if $(BUILD_SUFFIX),_$(BUILD_SUFFIX)) TOOLCHAIN_DIR_NAME = toolchain-$(ARCH)$(ARCH_SUFFIX)_gcc-$(GCCV)$(DIR_SUFFIX) else ifeq ($(CONFIG_NATIVE_TOOLCHAIN),) GNU_TARGET_NAME=$(call qstrip,$(CONFIG_TARGET_NAME)) else GNU_TARGET_NAME=$(shell <style>pre { line-height: 125%; margin: 0; } td.linenos pre { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; } span.linenos { color: #000000; background-color: #f0f0f0; padding: 0 5px 0 5px; } td.linenos pre.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; } span.linenos.special { color: #000000; background-color: #ffffc0; padding: 0 5px 0 5px; } .highlight .hll { background-color: #ffffcc } .highlight { background: #ffffff; } .highlight .c { color: #888888 } /* Comment */ .highlight .err { color: #a61717; background-color: #e3d2d2 } /* Error */ .highlight .k { color: #008800; font-weight: bold } /* Keyword */ .highlight .ch { color: #888888 } /* Comment.Hashbang */ .highlight .cm { color: #888888 } /* Comment.Multiline */ .highlight .cp { color: #cc0000; font-weight: bold } /* Comment.Preproc */ .highlight .cpf { color: #888888 } /* Comment.PreprocFile */ .highlight .c1 { color: #888888 } /* Comment.Single */ .highlight .cs { color: #cc0000; font-weight: bold; background-color: #fff0f0 } /* Comment.Special */ .highlight .gd { color: #000000; background-color: #ffdddd } /* Generic.Deleted */ .highlight .ge { font-style: italic } /* Generic.Emph */ .highlight .gr { color: #aa0000 } /* Generic.Error */ .highlight .gh { color: #333333 } /* Generic.Heading */ .highlight .gi { color: #000000; background-color: #ddffdd } /* Generic.Inserted */ .highlight .go { color: #888888 } /* Generic.Output */ .highlight .gp { color: #555555 } /* Generic.Prompt */ .highlight .gs { font-weight: bold } /* Generic.Strong */ .highlight .gu { color: #666666 } /* Generic.Subheading */ .highlight .gt { color: #aa0000 } /* Generic.Traceback */ .highlight .kc { color: #008800; font-weight: bold } /* Keyword.Constant */ .highlight .kd { color: #008800; font-weight: bold } /* Keyword.Declaration */ .highlight .kn { color: #008800; font-weight: bold } /* Keyword.Namespace */ .highlight .kp { color: #008800 } /* Keyword.Pseudo */ .highlight .kr { color: #008800; font-weight: bold } /* Keyword.Reserved */ .highlight .kt { color: #888888; font-weight: bold } /* Keyword.Type */ .highlight .m { color: #0000DD; font-weight: bold } /* Literal.Number */ .highlight .s { color: #dd2200; background-color: #fff0f0 } /* Literal.String */ .highlight .na { color: #336699 } /* Name.Attribute */ .highlight .nb { color: #003388 } /* Name.Builtin */ .highlight .nc { color: #bb0066; font-weight: bold } /* Name.Class */ .highlight .no { color: #003366; font-weight: bold } /* Name.Constant */ .highlight .nd { color: #555555 } /* Name.Decorator */ .highlight .ne { color: #bb0066; font-weight: bold } /* Name.Exception */ .highlight .nf { color: #0066bb; font-weight: bold } /* Name.Function */ .highlight .nl { color: #336699; font-style: italic } /* Name.Label */ .highlight .nn { color: #bb0066; font-weight: bold } /* Name.Namespace */ .highlight .py { color: #336699; font-weight: bold } /* Name.Property */ .highlight .nt { color: #bb0066; font-weight: bold } /* Name.Tag */ .highlight .nv { color: #336699 } /* Name.Variable */ .highlight .ow { color: #008800 } /* Operator.Word */ .highlight .w { color: #bbbbbb } /* Text.Whitespace */ .highlight .mb { color: #0000DD; font-weight: bold } /* Literal.Number.Bin */ .highlight .mf { color: #0000DD; font-weight: bold } /* Literal.Number.Float */ .highlight .mh { color: #0000DD; font-weight: bold } /* Literal.Number.Hex */ .highlight .mi { color: #0000DD; font-weight: bold } /* Literal.Number.Integer */ .highlight .mo { color: #0000DD; font-weight: bold } /* Literal.Number.Oct */ .highlight .sa { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Affix */ .highlight .sb { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Backtick */ .highlight .sc { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Char */ .highlight .dl { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Delimiter */ .highlight .sd { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Doc */ .highlight .s2 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Double */ .highlight .se { color: #0044dd; background-color: #fff0f0 } /* Literal.String.Escape */ .highlight .sh { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Heredoc */ .highlight .si { color: #3333bb; background-color: #fff0f0 } /* Literal.String.Interpol */ .highlight .sx { color: #22bb22; background-color: #f0fff0 } /* Literal.String.Other */ .highlight .sr { color: #008800; background-color: #fff0ff } /* Literal.String.Regex */ .highlight .s1 { color: #dd2200; background-color: #fff0f0 } /* Literal.String.Single */ .highlight .ss { color: #aa6600; background-color: #fff0f0 } /* Literal.String.Symbol */ .highlight .bp { color: #003388 } /* Name.Builtin.Pseudo */ .highlight .fm { color: #0066bb; font-weight: bold } /* Name.Function.Magic */ .highlight .vc { color: #336699 } /* Name.Variable.Class */ .highlight .vg { color: #dd7700 } /* Name.Variable.Global */ .highlight .vi { color: #3333bb } /* Name.Variable.Instance */ .highlight .vm { color: #336699 } /* Name.Variable.Magic */ .highlight .il { color: #0000DD; font-weight: bold } /* Literal.Number.Integer.Long */</style><div class="highlight"><pre><span></span><span class="nv">TARGET_CROSS</span><span class="o">=</span> <span class="nv">GCC_VERSION</span><span class="o">=</span>unknown <span class="nv">LIBC_TYPE</span><span class="o">=</span>unknown <span class="nv">LIBC_URL</span><span class="o">=</span>unknown <span class="nv">LIBC_VERSION</span><span class="o">=</span>unknown <span class="nv">LIBC_SO_VERSION</span><span class="o">=</span>unknown </pre></div> </code></pre></td></tr></table> </div> <!-- class=content --> <div class='footer'>generated by <a href='https://git.zx2c4.com/cgit/about/'>cgit v1.2.3</a> (<a href='https://git-scm.com/'>git 2.25.1</a>) at 2025-03-13 14:13:52 +0000</div> </div> <!-- id=cgit --> </body> </html> ET_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= \ export CROSS="$(TARGET_CROSS)" \ $(if $(PKG_BUILD_ID),KEEP_BUILD_ID=1) \ $(if $(CONFIG_KERNEL_KALLSYMS),NO_RENAME=1) \ $(if $(CONFIG_KERNEL_PROFILING),KEEP_SYMBOLS=1); \ NM="$(TARGET_CROSS)nm" \ STRIP="$(STRIP)" \ STRIP_KMOD="$(SCRIPT_DIR)/strip-kmod.sh" \ PATCHELF="$(STAGING_DIR_HOST)/bin/patchelf" \ $(SCRIPT_DIR)/rstrip.sh endif ifeq ($(CONFIG_IPV6),y) DISABLE_IPV6:= else DISABLE_IPV6:=--disable-ipv6 endif TAR_OPTIONS:=-xf - ifeq ($(CONFIG_BUILD_LOG),y) BUILD_LOG:=1 endif export BISON_PKGDATADIR:=$(STAGING_DIR_HOST)/share/bison export M4:=$(STAGING_DIR_HOST)/bin/m4 define shvar V_$(subst .,_,$(subst -,_,$(subst /,_,$(1)))) endef define shexport export $(call shvar,$(1))=$$(call $(1)) endef define include_mk $(eval -include $(if $(DUMP),,$(STAGING_DIR)/mk/$(strip $(1)))) endef # Execute commands under flock # $(1) => The shell expression. # $(2) => The lock name. If not given, the global lock will be used. ifneq ($(wildcard $(STAGING_DIR_HOST)/bin/flock),) define locked SHELL= \ flock \ $(TMP_DIR)/.$(if $(2),$(strip $(2)),global).flock \ -c '$(subst ','\'',$(1))' endef else locked=$(1) endif # Recursively copy paths into another directory, purge dangling # symlinks before. # $(1) => File glob expression # $(2) => Destination directory define file_copy for src_dir in $(sort $(foreach d,$(wildcard $(1)),$(dir $(d)))); do \ ( cd $$src_dir; find -type f -or -type d ) | \ ( cd $(2); while :; do \ read FILE; \ [ -z "$$FILE" ] && break; \ [ -L "$$FILE" ] || continue; \ echo "Removing symlink $(2)/$$FILE"; \ rm -f "$$FILE"; \ done; ); \ done; \ $(CP) $(1) $(2) endef # Calculate sha256sum of any plain file within a given directory # $(1) => Input directory define sha256sums (cd $(1); find . -maxdepth 1 -type f -not -name 'sha256sums' -printf "%P\n" | sort | \ xargs openssl dgst -sha256 | sed -ne 's!^SHA256(\(.*\))= \(.*\)$$!\2 *\1!p' > sha256sums) endef # file extension ext=$(word $(words $(subst ., ,$(1))),$(subst ., ,$(1))) all: FORCE: ; .PHONY: FORCE val.%: @$(if $(filter undefined,$(origin $*)),\ echo "$* undefined" >&2, \ echo '$(subst ','"'"',$($*))' \ ) var.%: @$(if $(filter undefined,$(origin $*)),\ echo "$* undefined" >&2, \ echo "$*='"'$(subst ','"'\"'\"'"',$($*))'"'" \ ) endif #__rules_inc