Mirror of the official OpenWrt repository https://openwrt.org
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

437 lines
14 KiB

  1. #
  2. # Copyright (C) 2006-2010 OpenWrt.org
  3. # Copyright (C) 2016 LEDE Project
  4. #
  5. # This is free software, licensed under the GNU General Public License v2.
  6. # See /LICENSE for more information.
  7. #
  8. ifneq ($(__rules_inc),1)
  9. __rules_inc=1
  10. ifeq ($(DUMP),)
  11. -include $(TOPDIR)/.config
  12. endif
  13. include $(TOPDIR)/include/debug.mk
  14. include $(TOPDIR)/include/verbose.mk
  15. ifneq ($(filter check,$(MAKECMDGOALS)),)
  16. CHECK:=1
  17. DUMP:=1
  18. endif
  19. export TMP_DIR:=$(TOPDIR)/tmp
  20. export TMPDIR:=$(TMP_DIR)
  21. qstrip=$(strip $(subst ",,$(1)))
  22. #"))
  23. empty:=
  24. space:= $(empty) $(empty)
  25. comma:=,
  26. merge=$(subst $(space),,$(1))
  27. confvar=$(shell echo '$(foreach v,$(1),$(v)=$(subst ','\'',$($(v))))' | $(STAGING_DIR_HOST)/bin/mkhash md5)
  28. strip_last=$(patsubst %.$(lastword $(subst .,$(space),$(1))),%,$(1))
  29. paren_left = (
  30. paren_right = )
  31. 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
  32. 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
  33. define sep
  34. endef
  35. define newline
  36. endef
  37. __tr_list = $(join $(join $(1),$(foreach char,$(1),$(comma))),$(2))
  38. __tr_head_stripped = $(subst $(space),,$(foreach cv,$(call __tr_list,$(1),$(2)),$$$(paren_left)subst$(cv)$(comma)))
  39. __tr_head = $(subst $(paren_left)subst,$(paren_left)subst$(space),$(__tr_head_stripped))
  40. __tr_tail = $(subst $(space),,$(foreach cv,$(1),$(paren_right)))
  41. __tr_template = $(__tr_head)$$(1)$(__tr_tail)
  42. $(eval toupper = $(call __tr_template,$(chars_lower),$(chars_upper)))
  43. $(eval tolower = $(call __tr_template,$(chars_upper),$(chars_lower)))
  44. version_abbrev = $(if $(if $(CHECK),,$(DUMP)),$(1),$(shell printf '%.8s' $(1)))
  45. _SINGLE=export MAKEFLAGS=$(space);
  46. CFLAGS:=
  47. ARCH:=$(subst i486,i386,$(subst i586,i386,$(subst i686,i386,$(call qstrip,$(CONFIG_ARCH)))))
  48. ARCH_PACKAGES:=$(call qstrip,$(CONFIG_TARGET_ARCH_PACKAGES))
  49. BOARD:=$(call qstrip,$(CONFIG_TARGET_BOARD))
  50. SUBTARGET:=$(call qstrip,$(CONFIG_TARGET_SUBTARGET))
  51. TARGET_OPTIMIZATION:=$(call qstrip,$(CONFIG_TARGET_OPTIMIZATION))
  52. export EXTRA_OPTIMIZATION:=$(filter-out -fno-plt,$(call qstrip,$(CONFIG_EXTRA_OPTIMIZATION)))
  53. TARGET_SUFFIX=$(call qstrip,$(CONFIG_TARGET_SUFFIX))
  54. BUILD_SUFFIX:=$(call qstrip,$(CONFIG_BUILD_SUFFIX))
  55. SUBDIR:=$(patsubst $(TOPDIR)/%,%,${CURDIR})
  56. BUILD_SUBDIR:=$(patsubst $(TOPDIR)/%,%,${CURDIR})
  57. NPROC:=$(shell sysctl -n hw.ncpu 2>/dev/null || nproc)
  58. export SHELL:=/usr/bin/env bash
  59. IS_PACKAGE_BUILD := $(if $(filter package/%,$(BUILD_SUBDIR)),1)
  60. OPTIMIZE_FOR_CPU=$(subst i386,i486,$(ARCH))
  61. ifeq ($(ARCH),powerpc)
  62. FPIC:=-fPIC
  63. else
  64. FPIC:=-fpic
  65. endif
  66. HOST_FPIC:=-fPIC
  67. ARCH_SUFFIX:=$(call qstrip,$(CONFIG_CPU_TYPE))
  68. GCC_ARCH:=
  69. ifneq ($(ARCH_SUFFIX),)
  70. ARCH_SUFFIX:=_$(ARCH_SUFFIX)
  71. endif
  72. ifneq ($(filter -march=armv%,$(TARGET_OPTIMIZATION)),)
  73. GCC_ARCH:=$(patsubst -march=%,%,$(filter -march=armv%,$(TARGET_OPTIMIZATION)))
  74. endif
  75. ifdef CONFIG_HAS_SPE_FPU
  76. TARGET_SUFFIX:=$(TARGET_SUFFIX)spe
  77. endif
  78. ifdef CONFIG_MIPS64_ABI
  79. ifneq ($(CONFIG_MIPS64_ABI_O32),y)
  80. ARCH_SUFFIX:=$(ARCH_SUFFIX)_$(call qstrip,$(CONFIG_MIPS64_ABI))
  81. endif
  82. endif
  83. DEFAULT_SUBDIR_TARGETS:=clean download prepare compile update refresh prereq dist distcheck configure check check-depends
  84. define DefaultTargets
  85. $(foreach t,$(DEFAULT_SUBDIR_TARGETS) $(1),
  86. .$(t):
  87. $(t): .$(t)
  88. .PHONY: $(t) .$(t)
  89. )
  90. endef
  91. DL_DIR:=$(if $(call qstrip,$(CONFIG_DOWNLOAD_FOLDER)),$(call qstrip,$(CONFIG_DOWNLOAD_FOLDER)),$(TOPDIR)/dl)
  92. OUTPUT_DIR:=$(if $(call qstrip,$(CONFIG_BINARY_FOLDER)),$(call qstrip,$(CONFIG_BINARY_FOLDER)),$(TOPDIR)/bin)
  93. BIN_DIR:=$(OUTPUT_DIR)/targets/$(BOARD)/$(SUBTARGET)
  94. INCLUDE_DIR:=$(TOPDIR)/include
  95. SCRIPT_DIR:=$(TOPDIR)/scripts
  96. BUILD_DIR_BASE:=$(TOPDIR)/build_dir
  97. ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
  98. GCCV:=$(call qstrip,$(CONFIG_GCC_VERSION))
  99. LIBC:=$(call qstrip,$(CONFIG_LIBC))
  100. REAL_GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-openwrt-linux$(if $(TARGET_SUFFIX),-$(TARGET_SUFFIX))
  101. GNU_TARGET_NAME=$(OPTIMIZE_FOR_CPU)-openwrt-linux
  102. DIR_SUFFIX:=_$(LIBC)$(if $(CONFIG_arm),_eabi)
  103. BIN_DIR:=$(BIN_DIR)$(if $(CONFIG_USE_MUSL),,-$(LIBC))
  104. TARGET_DIR_NAME = target-$(ARCH)$(ARCH_SUFFIX)$(DIR_SUFFIX)$(if $(BUILD_SUFFIX),_$(BUILD_SUFFIX))
  105. TOOLCHAIN_DIR_NAME = toolchain-$(ARCH)$(ARCH_SUFFIX)_gcc-$(GCCV)$(DIR_SUFFIX)
  106. else
  107. ifeq ($(CONFIG_NATIVE_TOOLCHAIN),)
  108. GNU_TARGET_NAME=$(call qstrip,$(CONFIG_TARGET_NAME))
  109. else
  110. GNU_TARGET_NAME=$(shell gcc -dumpmachine)
  111. endif
  112. REAL_GNU_TARGET_NAME=$(GNU_TARGET_NAME)
  113. LIBC:=$(call qstrip,$(CONFIG_LIBC))
  114. TARGET_DIR_NAME:=target-$(GNU_TARGET_NAME)_$(LIBC)$(if $(BUILD_SUFFIX),_$(BUILD_SUFFIX))
  115. TOOLCHAIN_DIR_NAME:=toolchain-$(GNU_TARGET_NAME)
  116. endif
  117. ifeq ($(or $(CONFIG_EXTERNAL_TOOLCHAIN),$(CONFIG_TARGET_uml)),)
  118. ifeq ($(CONFIG_GCC_USE_IREMAP),y)
  119. iremap = -iremap$(1):$(2)
  120. else
  121. iremap = -f$(if $(CONFIG_REPRODUCIBLE_DEBUG_INFO),file,macro)-prefix-map=$(1)=$(2)
  122. endif
  123. endif
  124. PACKAGE_DIR:=$(BIN_DIR)/packages
  125. PACKAGE_DIR_ALL:=$(TOPDIR)/staging_dir/packages/$(BOARD)
  126. BUILD_DIR:=$(BUILD_DIR_BASE)/$(TARGET_DIR_NAME)
  127. STAGING_DIR:=$(TOPDIR)/staging_dir/$(TARGET_DIR_NAME)
  128. BUILD_DIR_TOOLCHAIN:=$(BUILD_DIR_BASE)/$(TOOLCHAIN_DIR_NAME)
  129. TOOLCHAIN_DIR:=$(TOPDIR)/staging_dir/$(TOOLCHAIN_DIR_NAME)
  130. STAMP_DIR:=$(BUILD_DIR)/stamp
  131. STAMP_DIR_HOST=$(BUILD_DIR_HOST)/stamp
  132. TARGET_ROOTFS_DIR?=$(if $(call qstrip,$(CONFIG_TARGET_ROOTFS_DIR)),$(call qstrip,$(CONFIG_TARGET_ROOTFS_DIR)),$(BUILD_DIR))
  133. TARGET_DIR:=$(TARGET_ROOTFS_DIR)/root-$(BOARD)
  134. STAGING_DIR_ROOT:=$(STAGING_DIR)/root-$(BOARD)
  135. STAGING_DIR_IMAGE:=$(STAGING_DIR)/image
  136. BUILD_LOG_DIR:=$(if $(call qstrip,$(CONFIG_BUILD_LOG_DIR)),$(call qstrip,$(CONFIG_BUILD_LOG_DIR)),$(TOPDIR)/logs)
  137. PKG_INFO_DIR := $(STAGING_DIR)/pkginfo
  138. BUILD_DIR_HOST:=$(if $(IS_PACKAGE_BUILD),$(BUILD_DIR_BASE)/hostpkg,$(BUILD_DIR_BASE)/host)
  139. STAGING_DIR_HOST:=$(TOPDIR)/staging_dir/host
  140. STAGING_DIR_HOSTPKG:=$(TOPDIR)/staging_dir/hostpkg
  141. TARGET_PATH:=$(subst $(space),:,$(filter-out .,$(filter-out ./,$(subst :,$(space),$(PATH)))))
  142. TARGET_INIT_PATH:=$(call qstrip,$(CONFIG_TARGET_INIT_PATH))
  143. TARGET_INIT_PATH:=$(if $(TARGET_INIT_PATH),$(TARGET_INIT_PATH),/usr/sbin:/sbin:/usr/bin:/bin)
  144. TARGET_CFLAGS:=$(TARGET_OPTIMIZATION)$(if $(CONFIG_DEBUG), -g3) $(call qstrip,$(CONFIG_EXTRA_OPTIMIZATION))
  145. TARGET_CXXFLAGS = $(TARGET_CFLAGS)
  146. TARGET_ASFLAGS_DEFAULT = $(TARGET_CFLAGS)
  147. TARGET_ASFLAGS = $(TARGET_ASFLAGS_DEFAULT)
  148. TARGET_CPPFLAGS:=-I$(STAGING_DIR)/usr/include
  149. TARGET_LDFLAGS:=-L$(STAGING_DIR)/usr/lib -L$(STAGING_DIR)/lib
  150. ifneq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
  151. LIBGCC_S_PATH=$(realpath $(wildcard $(call qstrip,$(CONFIG_LIBGCC_ROOT_DIR))/$(call qstrip,$(CONFIG_LIBGCC_FILE_SPEC))))
  152. LIBGCC_S=$(if $(LIBGCC_S_PATH),-L$(dir $(LIBGCC_S_PATH)) -lgcc_s)
  153. LIBGCC_A=$(realpath $(lastword $(wildcard $(dir $(LIBGCC_S_PATH))/gcc/*/*/libgcc.a)))
  154. else
  155. LIBGCC_A=$(lastword $(wildcard $(TOOLCHAIN_DIR)/lib/gcc/*/*/libgcc.a))
  156. LIBGCC_S=$(if $(wildcard $(TOOLCHAIN_DIR)/lib/libgcc_s.so),-L$(TOOLCHAIN_DIR)/lib -lgcc_s,$(LIBGCC_A))
  157. endif
  158. ifeq ($(CONFIG_ARCH_64BIT),y)
  159. LIB_SUFFIX:=64
  160. endif
  161. ifndef DUMP
  162. ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
  163. -include $(TOOLCHAIN_DIR)/info.mk
  164. export GCC_HONOUR_COPTS:=0
  165. TARGET_CROSS:=$(if $(TARGET_CROSS),$(TARGET_CROSS),$(OPTIMIZE_FOR_CPU)-openwrt-linux$(if $(TARGET_SUFFIX),-$(TARGET_SUFFIX))-)
  166. TARGET_CFLAGS+= -fhonour-copts -Wno-error=unused-but-set-variable -Wno-error=unused-result
  167. TARGET_CPPFLAGS+= -I$(TOOLCHAIN_DIR)/usr/include
  168. ifeq ($(CONFIG_USE_MUSL),y)
  169. TARGET_CPPFLAGS+= -I$(TOOLCHAIN_DIR)/include/fortify
  170. endif
  171. TARGET_CPPFLAGS+= -I$(TOOLCHAIN_DIR)/include
  172. TARGET_LDFLAGS+= -L$(TOOLCHAIN_DIR)/usr/lib -L$(TOOLCHAIN_DIR)/lib
  173. TARGET_PATH:=$(TOOLCHAIN_DIR)/bin:$(TARGET_PATH)
  174. else
  175. ifeq ($(CONFIG_NATIVE_TOOLCHAIN),)
  176. TARGET_CROSS:=$(call qstrip,$(CONFIG_TOOLCHAIN_PREFIX))
  177. TOOLCHAIN_ROOT_DIR:=$(call qstrip,$(CONFIG_TOOLCHAIN_ROOT))
  178. TOOLCHAIN_BIN_DIRS:=$(patsubst ./%,$(TOOLCHAIN_ROOT_DIR)/%,$(call qstrip,$(CONFIG_TOOLCHAIN_BIN_PATH)))
  179. TOOLCHAIN_INC_DIRS:=$(patsubst ./%,$(TOOLCHAIN_ROOT_DIR)/%,$(call qstrip,$(CONFIG_TOOLCHAIN_INC_PATH)))
  180. TOOLCHAIN_LIB_DIRS:=$(patsubst ./%,$(TOOLCHAIN_ROOT_DIR)/%,$(call qstrip,$(CONFIG_TOOLCHAIN_LIB_PATH)))
  181. ifneq ($(TOOLCHAIN_BIN_DIRS),)
  182. TARGET_PATH:=$(subst $(space),:,$(TOOLCHAIN_BIN_DIRS)):$(TARGET_PATH)
  183. endif
  184. ifneq ($(TOOLCHAIN_INC_DIRS),)
  185. TARGET_CPPFLAGS+= $(patsubst %,-I%,$(TOOLCHAIN_INC_DIRS))
  186. endif
  187. ifneq ($(TOOLCHAIN_LIB_DIRS),)
  188. TARGET_LDFLAGS+= $(patsubst %,-L%,$(TOOLCHAIN_LIB_DIRS))
  189. endif
  190. TARGET_PATH:=$(TOOLCHAIN_DIR)/bin:$(TARGET_PATH)
  191. endif
  192. endif
  193. endif
  194. TARGET_PATH_PKG:=$(STAGING_DIR)/host/bin:$(STAGING_DIR_HOSTPKG)/bin:$(TARGET_PATH)
  195. ifeq ($(CONFIG_SOFT_FLOAT),y)
  196. SOFT_FLOAT_CONFIG_OPTION:=--with-float=soft
  197. ifeq ($(CONFIG_arm),y)
  198. TARGET_CFLAGS+= -mfloat-abi=soft
  199. else
  200. TARGET_CFLAGS+= -msoft-float
  201. endif
  202. else
  203. SOFT_FLOAT_CONFIG_OPTION:=
  204. ifeq ($(CONFIG_arm),y)
  205. TARGET_CFLAGS+= -mfloat-abi=hard
  206. endif
  207. endif
  208. export PATH:=$(TARGET_PATH)
  209. export STAGING_DIR STAGING_DIR_HOST STAGING_DIR_HOSTPKG
  210. export SH_FUNC:=. $(INCLUDE_DIR)/shell.sh;
  211. PKG_CONFIG:=$(STAGING_DIR_HOST)/bin/pkg-config
  212. export PKG_CONFIG
  213. HOSTCC:=gcc
  214. HOSTCXX:=g++
  215. HOST_CPPFLAGS:=-I$(STAGING_DIR_HOST)/include $(if $(IS_PACKAGE_BUILD),-I$(STAGING_DIR_HOSTPKG)/include -I$(STAGING_DIR)/host/include)
  216. HOST_CFLAGS:=-O2 $(HOST_CPPFLAGS)
  217. HOST_LDFLAGS:=-L$(STAGING_DIR_HOST)/lib $(if $(IS_PACKAGE_BUILD),-L$(STAGING_DIR_HOSTPKG)/lib -L$(STAGING_DIR)/host/lib)
  218. ifeq ($(CONFIG_EXTERNAL_TOOLCHAIN),)
  219. TARGET_AR:=$(TARGET_CROSS)gcc-ar
  220. TARGET_RANLIB:=$(TARGET_CROSS)gcc-ranlib
  221. TARGET_NM:=$(TARGET_CROSS)gcc-nm
  222. else
  223. TARGET_AR:=$(TARGET_CROSS)ar
  224. TARGET_RANLIB:=$(TARGET_CROSS)ranlib
  225. TARGET_NM:=$(TARGET_CROSS)nm
  226. endif
  227. BUILD_KEY=$(TOPDIR)/key-build
  228. ifeq ($(HOST_OS),Darwin)
  229. FAKEROOT_SO:=$(STAGING_DIR_HOST)/lib/libfakeroot.dylib
  230. else
  231. FAKEROOT_SO:=$(STAGING_DIR_HOST)/lib/libfakeroot.so
  232. endif
  233. FAKEROOT:=$(STAGING_DIR_HOST)/bin/fakeroot -l $(FAKEROOT_SO) -f $(STAGING_DIR_HOST)/bin/faked
  234. TARGET_CC:=$(TARGET_CROSS)gcc
  235. TARGET_CXX:=$(TARGET_CROSS)g++
  236. KPATCH:=$(SCRIPT_DIR)/patch-kernel.sh
  237. SED:=$(STAGING_DIR_HOST)/bin/sed -i -e
  238. ESED:=$(STAGING_DIR_HOST)/bin/sed -E -i -e
  239. CP:=cp -fpR
  240. LN:=ln -sf
  241. XARGS:=xargs -r
  242. BASH:=bash
  243. TAR:=tar
  244. FIND:=find
  245. PATCH:=patch
  246. PYTHON:=python
  247. INSTALL_BIN:=install -m0755
  248. INSTALL_SUID:=install -m4755
  249. INSTALL_DIR:=install -d -m0755
  250. INSTALL_DATA:=install -m0644
  251. INSTALL_CONF:=install -m0600
  252. TARGET_CC_NOCACHE:=$(TARGET_CC)
  253. TARGET_CXX_NOCACHE:=$(TARGET_CXX)
  254. HOSTCC_NOCACHE:=$(HOSTCC)
  255. HOSTCXX_NOCACHE:=$(HOSTCXX)
  256. export TARGET_CC_NOCACHE
  257. export TARGET_CXX_NOCACHE
  258. export HOSTCC_NOCACHE
  259. ifneq ($(CONFIG_CCACHE),)
  260. TARGET_CC:= ccache_cc
  261. TARGET_CXX:= ccache_cxx
  262. HOSTCC:= ccache $(HOSTCC)
  263. HOSTCXX:= ccache $(HOSTCXX)
  264. export CCACHE_BASEDIR:=$(TOPDIR)
  265. export CCACHE_DIR:=$(if $(call qstrip,$(CONFIG_CCACHE_DIR)),$(call qstrip,$(CONFIG_CCACHE_DIR)),$(TOPDIR)/.ccache)
  266. export CCACHE_COMPILERCHECK:=%compiler% -dumpmachine; %compiler% -dumpversion
  267. endif
  268. TARGET_CONFIGURE_OPTS = \
  269. AR="$(TARGET_AR)" \
  270. AS="$(TARGET_CC) -c $(TARGET_ASFLAGS)" \
  271. LD=$(TARGET_CROSS)ld \
  272. NM="$(TARGET_NM)" \
  273. CC="$(TARGET_CC)" \
  274. GCC="$(TARGET_CC)" \
  275. CXX="$(TARGET_CXX)" \
  276. RANLIB="$(TARGET_RANLIB)" \
  277. STRIP=$(TARGET_CROSS)strip \
  278. OBJCOPY=$(TARGET_CROSS)objcopy \
  279. OBJDUMP=$(TARGET_CROSS)objdump \
  280. SIZE=$(TARGET_CROSS)size
  281. # strip an entire directory
  282. ifneq ($(CONFIG_NO_STRIP),)
  283. RSTRIP:=:
  284. STRIP:=:
  285. else
  286. ifneq ($(CONFIG_USE_STRIP),)
  287. STRIP:=$(TARGET_CROSS)strip $(call qstrip,$(CONFIG_STRIP_ARGS))
  288. else
  289. ifneq ($(CONFIG_USE_SSTRIP),)
  290. STRIP:=$(STAGING_DIR_HOST)/bin/sstrip
  291. endif
  292. endif
  293. RSTRIP= \
  294. export CROSS="$(TARGET_CROSS)" \
  295. $(if $(PKG_BUILD_ID),KEEP_BUILD_ID=1) \
  296. $(if $(CONFIG_KERNEL_KALLSYMS),NO_RENAME=1) \
  297. $(if $(CONFIG_KERNEL_PROFILING),KEEP_SYMBOLS=1); \
  298. NM="$(TARGET_CROSS)nm" \
  299. STRIP="$(STRIP)" \
  300. STRIP_KMOD="$(SCRIPT_DIR)/strip-kmod.sh" \
  301. PATCHELF="$(STAGING_DIR_HOST)/bin/patchelf" \
  302. $(SCRIPT_DIR)/rstrip.sh
  303. endif
  304. ifeq ($(CONFIG_IPV6),y)
  305. DISABLE_IPV6:=
  306. else
  307. DISABLE_IPV6:=--disable-ipv6
  308. endif
  309. TAR_OPTIONS:=-xf -
  310. ifeq ($(CONFIG_BUILD_LOG),y)
  311. BUILD_LOG:=1
  312. endif
  313. export BISON_PKGDATADIR:=$(STAGING_DIR_HOST)/share/bison
  314. export M4:=$(STAGING_DIR_HOST)/bin/m4
  315. define shvar
  316. V_$(subst .,_,$(subst -,_,$(subst /,_,$(1))))
  317. endef
  318. define shexport
  319. export $(call shvar,$(1))=$$(call $(1))
  320. endef
  321. # Execute commands under flock
  322. # $(1) => The shell expression.
  323. # $(2) => The lock name. If not given, the global lock will be used.
  324. ifneq ($(wildcard $(STAGING_DIR_HOST)/bin/flock),)
  325. define locked
  326. SHELL= \
  327. flock \
  328. $(TMP_DIR)/.$(if $(2),$(strip $(2)),global).flock \
  329. -c '$(subst ','\'',$(1))'
  330. endef
  331. else
  332. locked=$(1)
  333. endif
  334. # Recursively copy paths into another directory, purge dangling
  335. # symlinks before.
  336. # $(1) => File glob expression
  337. # $(2) => Destination directory
  338. define file_copy
  339. for src_dir in $(sort $(foreach d,$(wildcard $(1)),$(dir $(d)))); do \
  340. ( cd $$src_dir; find -type f -or -type d ) | \
  341. ( cd $(2); while :; do \
  342. read FILE; \
  343. [ -z "$$FILE" ] && break; \
  344. [ -L "$$FILE" ] || continue; \
  345. echo "Removing symlink $(2)/$$FILE"; \
  346. rm -f "$$FILE"; \
  347. done; ); \
  348. done; \
  349. $(CP) $(1) $(2)
  350. endef
  351. # Calculate sha256sum of any plain file within a given directory
  352. # $(1) => Input directory
  353. # $(2) => If set, recurse into subdirectories
  354. define sha256sums
  355. (cd $(1); find . $(if $(2),,-maxdepth 1) -type f -not -name 'sha256sums' -printf "%P\n" | sort | \
  356. xargs -r $(STAGING_DIR_HOST)/bin/mkhash -n sha256 | sed -ne 's!^\(.*\) \(.*\)$$!\1 *\2!p' > sha256sums)
  357. endef
  358. # file extension
  359. ext=$(word $(words $(subst ., ,$(1))),$(subst ., ,$(1)))
  360. all:
  361. FORCE: ;
  362. .PHONY: FORCE
  363. check: FORCE
  364. @true
  365. val.%:
  366. @$(if $(filter undefined,$(origin $*)),\
  367. echo "$* undefined" >&2, \
  368. echo '$(subst ','"'"',$($*))' \
  369. )
  370. var.%:
  371. @$(if $(filter undefined,$(origin $*)),\
  372. echo "$* undefined" >&2, \
  373. echo "$*='"'$(subst ','"'\"'\"'"',$($*))'"'" \
  374. )
  375. endif #__rules_inc