rules.mk 13 KB

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