pkg-generic.mk 35 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010
  1. ################################################################################
  2. # Generic package infrastructure
  3. #
  4. # This file implements an infrastructure that eases development of
  5. # package .mk files. It should be used for packages that do not rely
  6. # on a well-known build system for which Buildroot has a dedicated
  7. # infrastructure (so far, Buildroot has special support for
  8. # autotools-based and CMake-based packages).
  9. #
  10. # See the Buildroot documentation for details on the usage of this
  11. # infrastructure
  12. #
  13. # In terms of implementation, this generic infrastructure requires the
  14. # .mk file to specify:
  15. #
  16. # 1. Metadata information about the package: name, version,
  17. # download URL, etc.
  18. #
  19. # 2. Description of the commands to be executed to configure, build
  20. # and install the package
  21. ################################################################################
  22. ################################################################################
  23. # Helper functions to catch start/end of each step
  24. ################################################################################
  25. # Those two functions are called by each step below.
  26. # They are responsible for calling all hooks defined in
  27. # $(GLOBAL_INSTRUMENTATION_HOOKS) and pass each of them
  28. # three arguments:
  29. # $1: either 'start' or 'end'
  30. # $2: the name of the step
  31. # $3: the name of the package
  32. # Start step
  33. # $1: step name
  34. define step_start
  35. $(foreach hook,$(GLOBAL_INSTRUMENTATION_HOOKS),$(call $(hook),start,$(1),$($(PKG)_NAME))$(sep))
  36. endef
  37. # End step
  38. # $1: step name
  39. define step_end
  40. $(foreach hook,$(GLOBAL_INSTRUMENTATION_HOOKS),$(call $(hook),end,$(1),$($(PKG)_NAME))$(sep))
  41. endef
  42. #######################################
  43. # Actual steps hooks
  44. # Time steps
  45. define step_time
  46. printf "%s:%-5.5s:%-20.20s: %s\n" \
  47. "$$(date +%s)" "$(1)" "$(2)" "$(3)" \
  48. >>"$(BUILD_DIR)/build-time.log"
  49. endef
  50. GLOBAL_INSTRUMENTATION_HOOKS += step_time
  51. # Hooks to collect statistics about installed files
  52. # The suffix is typically empty for the target variant, for legacy backward
  53. # compatibility.
  54. # $(1): package name
  55. # $(2): base directory to search in
  56. # $(3): suffix of file (optional)
  57. define step_pkg_size_inner
  58. cd $(2); \
  59. find . \( -type f -o -type l \) \
  60. -newer $($(PKG)_DIR)/.stamp_built \
  61. -exec printf '$(1),%s\n' {} + \
  62. >> $(BUILD_DIR)/packages-file-list$(3).txt
  63. endef
  64. define step_pkg_size
  65. $(if $(filter install-target,$(2)),\
  66. $(if $(filter end,$(1)),$(call step_pkg_size_inner,$(3),$(TARGET_DIR))))
  67. $(if $(filter install-staging,$(2)),\
  68. $(if $(filter end,$(1)),$(call step_pkg_size_inner,$(3),$(STAGING_DIR),-staging)))
  69. $(if $(filter install-host,$(2)),\
  70. $(if $(filter end,$(1)),$(call step_pkg_size_inner,$(3),$(HOST_DIR),-host)))
  71. endef
  72. GLOBAL_INSTRUMENTATION_HOOKS += step_pkg_size
  73. # Relies on step_pkg_size, so must be after
  74. define check_bin_arch
  75. $(if $(filter end-install-target,$(1)-$(2)),\
  76. support/scripts/check-bin-arch -p $(3) \
  77. -l $(BUILD_DIR)/packages-file-list.txt \
  78. $(foreach i,$($(PKG)_BIN_ARCH_EXCLUDE),-i "$(i)") \
  79. -r $(TARGET_READELF) \
  80. -a $(BR2_READELF_ARCH_NAME))
  81. endef
  82. GLOBAL_INSTRUMENTATION_HOOKS += check_bin_arch
  83. # This hook checks that host packages that need libraries that we build
  84. # have a proper DT_RPATH or DT_RUNPATH tag
  85. define check_host_rpath
  86. $(if $(filter install-host,$(2)),\
  87. $(if $(filter end,$(1)),support/scripts/check-host-rpath $(3) $(HOST_DIR)))
  88. endef
  89. GLOBAL_INSTRUMENTATION_HOOKS += check_host_rpath
  90. define step_check_build_dir_one
  91. if [ -d $(2) ]; then \
  92. printf "%s: installs files in %s\n" $(1) $(2) >&2; \
  93. exit 1; \
  94. fi
  95. endef
  96. define step_check_build_dir
  97. $(if $(filter install-staging,$(2)),\
  98. $(if $(filter end,$(1)),$(call step_check_build_dir_one,$(3),$(STAGING_DIR)/$(O))))
  99. $(if $(filter install-target,$(2)),\
  100. $(if $(filter end,$(1)),$(call step_check_build_dir_one,$(3),$(TARGET_DIR)/$(O))))
  101. endef
  102. GLOBAL_INSTRUMENTATION_HOOKS += step_check_build_dir
  103. # User-supplied script
  104. ifneq ($(BR2_INSTRUMENTATION_SCRIPTS),)
  105. define step_user
  106. @$(foreach user_hook, $(BR2_INSTRUMENTATION_SCRIPTS), \
  107. $(EXTRA_ENV) $(user_hook) "$(1)" "$(2)" "$(3)"$(sep))
  108. endef
  109. GLOBAL_INSTRUMENTATION_HOOKS += step_user
  110. endif
  111. ################################################################################
  112. # Implicit targets -- produce a stamp file for each step of a package build
  113. ################################################################################
  114. # Retrieve the archive
  115. $(BUILD_DIR)/%/.stamp_downloaded:
  116. $(foreach hook,$($(PKG)_PRE_DOWNLOAD_HOOKS),$(call $(hook))$(sep))
  117. # Only show the download message if it isn't already downloaded
  118. $(Q)for p in $($(PKG)_ALL_DOWNLOADS); do \
  119. if test ! -e $(DL_DIR)/`basename $$p` ; then \
  120. $(call MESSAGE,"Downloading") ; \
  121. break ; \
  122. fi ; \
  123. done
  124. $(foreach p,$($(PKG)_ALL_DOWNLOADS),$(call DOWNLOAD,$(p))$(sep))
  125. $(foreach hook,$($(PKG)_POST_DOWNLOAD_HOOKS),$(call $(hook))$(sep))
  126. $(Q)mkdir -p $(@D)
  127. $(Q)touch $@
  128. # Retrieve actual source archive, e.g. for prebuilt external toolchains
  129. $(BUILD_DIR)/%/.stamp_actual_downloaded:
  130. $(call DOWNLOAD,$($(PKG)_ACTUAL_SOURCE_SITE)/$($(PKG)_ACTUAL_SOURCE_TARBALL)); \
  131. $(Q)mkdir -p $(@D)
  132. $(Q)touch $@
  133. # Unpack the archive
  134. $(BUILD_DIR)/%/.stamp_extracted:
  135. @$(call step_start,extract)
  136. @$(call MESSAGE,"Extracting")
  137. $(foreach hook,$($(PKG)_PRE_EXTRACT_HOOKS),$(call $(hook))$(sep))
  138. $(Q)mkdir -p $(@D)
  139. $($(PKG)_EXTRACT_CMDS)
  140. # some packages have messed up permissions inside
  141. $(Q)chmod -R +rw $(@D)
  142. $(foreach hook,$($(PKG)_POST_EXTRACT_HOOKS),$(call $(hook))$(sep))
  143. @$(call step_end,extract)
  144. $(Q)touch $@
  145. # Rsync the source directory if the <pkg>_OVERRIDE_SRCDIR feature is
  146. # used.
  147. $(BUILD_DIR)/%/.stamp_rsynced:
  148. @$(call MESSAGE,"Syncing from source dir $(SRCDIR)")
  149. $(foreach hook,$($(PKG)_PRE_RSYNC_HOOKS),$(call $(hook))$(sep))
  150. @test -d $(SRCDIR) || (echo "ERROR: $(SRCDIR) does not exist" ; exit 1)
  151. rsync -au --chmod=u=rwX,go=rX $(RSYNC_VCS_EXCLUSIONS) $(call qstrip,$(SRCDIR))/ $(@D)
  152. $(foreach hook,$($(PKG)_POST_RSYNC_HOOKS),$(call $(hook))$(sep))
  153. $(Q)touch $@
  154. # Patch
  155. #
  156. # The RAWNAME variable is the lowercased package name, which allows to
  157. # find the package directory (typically package/<pkgname>) and the
  158. # prefix of the patches
  159. #
  160. # For BR2_GLOBAL_PATCH_DIR, only generate if it is defined
  161. $(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_DIRS = $(PKGDIR)
  162. $(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_DIRS += $(addsuffix /$(RAWNAME),$(call qstrip,$(BR2_GLOBAL_PATCH_DIR)))
  163. $(BUILD_DIR)/%/.stamp_patched:
  164. @$(call step_start,patch)
  165. @$(call MESSAGE,"Patching")
  166. $(foreach hook,$($(PKG)_PRE_PATCH_HOOKS),$(call $(hook))$(sep))
  167. $(foreach p,$($(PKG)_PATCH),$(APPLY_PATCHES) $(@D) $(DL_DIR) $(notdir $(p))$(sep))
  168. $(Q)( \
  169. for D in $(PATCH_BASE_DIRS); do \
  170. if test -d $${D}; then \
  171. if test -d $${D}/$($(PKG)_VERSION); then \
  172. $(APPLY_PATCHES) $(@D) $${D}/$($(PKG)_VERSION) \*.patch \*.patch.$(ARCH) || exit 1; \
  173. else \
  174. $(APPLY_PATCHES) $(@D) $${D} \*.patch \*.patch.$(ARCH) || exit 1; \
  175. fi; \
  176. fi; \
  177. done; \
  178. )
  179. $(foreach hook,$($(PKG)_POST_PATCH_HOOKS),$(call $(hook))$(sep))
  180. @$(call step_end,patch)
  181. $(Q)touch $@
  182. # Check that all directories specified in BR2_GLOBAL_PATCH_DIR exist.
  183. $(foreach dir,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR)),\
  184. $(if $(wildcard $(dir)),,\
  185. $(error BR2_GLOBAL_PATCH_DIR contains nonexistent directory $(dir))))
  186. # Configure
  187. $(BUILD_DIR)/%/.stamp_configured:
  188. @$(call step_start,configure)
  189. @$(call MESSAGE,"Configuring")
  190. $(foreach hook,$($(PKG)_PRE_CONFIGURE_HOOKS),$(call $(hook))$(sep))
  191. $($(PKG)_CONFIGURE_CMDS)
  192. $(foreach hook,$($(PKG)_POST_CONFIGURE_HOOKS),$(call $(hook))$(sep))
  193. @$(call step_end,configure)
  194. $(Q)touch $@
  195. # Build
  196. $(BUILD_DIR)/%/.stamp_built::
  197. @$(call step_start,build)
  198. @$(call MESSAGE,"Building")
  199. $(foreach hook,$($(PKG)_PRE_BUILD_HOOKS),$(call $(hook))$(sep))
  200. +$($(PKG)_BUILD_CMDS)
  201. $(foreach hook,$($(PKG)_POST_BUILD_HOOKS),$(call $(hook))$(sep))
  202. @$(call step_end,build)
  203. $(Q)touch $@
  204. # Install to host dir
  205. $(BUILD_DIR)/%/.stamp_host_installed:
  206. @$(call step_start,install-host)
  207. @$(call MESSAGE,"Installing to host directory")
  208. $(foreach hook,$($(PKG)_PRE_INSTALL_HOOKS),$(call $(hook))$(sep))
  209. +$($(PKG)_INSTALL_CMDS)
  210. $(foreach hook,$($(PKG)_POST_INSTALL_HOOKS),$(call $(hook))$(sep))
  211. @$(call step_end,install-host)
  212. $(Q)touch $@
  213. # Install to staging dir
  214. #
  215. # Some packages install libtool .la files alongside any installed
  216. # libraries. These .la files sometimes refer to paths relative to the
  217. # sysroot, which libtool will interpret as absolute paths to host
  218. # libraries instead of the target libraries. Since this is not what we
  219. # want, these paths are fixed by prefixing them with $(STAGING_DIR).
  220. # As we configure with --prefix=/usr, this fix needs to be applied to
  221. # any path that starts with /usr.
  222. #
  223. # To protect against the case that the output or staging directories or
  224. # the pre-installed external toolchain themselves are under /usr, we first
  225. # substitute away any occurrences of these directories with @BASE_DIR@,
  226. # @STAGING_DIR@ and @TOOLCHAIN_EXTERNAL_INSTALL_DIR@ respectively.
  227. #
  228. # Note that STAGING_DIR can be outside BASE_DIR when the user sets
  229. # BR2_HOST_DIR to a custom value. Note that TOOLCHAIN_EXTERNAL_INSTALL_DIR
  230. # can be under @BASE_DIR@ when it's a downloaded toolchain, and can be
  231. # empty when we use an internal toolchain.
  232. #
  233. $(BUILD_DIR)/%/.stamp_staging_installed:
  234. @$(call step_start,install-staging)
  235. @$(call MESSAGE,"Installing to staging directory")
  236. $(foreach hook,$($(PKG)_PRE_INSTALL_STAGING_HOOKS),$(call $(hook))$(sep))
  237. +$($(PKG)_INSTALL_STAGING_CMDS)
  238. $(foreach hook,$($(PKG)_POST_INSTALL_STAGING_HOOKS),$(call $(hook))$(sep))
  239. $(Q)if test -n "$($(PKG)_CONFIG_SCRIPTS)" ; then \
  240. $(call MESSAGE,"Fixing package configuration files") ;\
  241. $(SED) "s,$(BASE_DIR),@BASE_DIR@,g" \
  242. -e "s,$(STAGING_DIR),@STAGING_DIR@,g" \
  243. -e "s,^\(exec_\)\?prefix=.*,\1prefix=@STAGING_DIR@/usr,g" \
  244. -e "s,-I/usr/,-I@STAGING_DIR@/usr/,g" \
  245. -e "s,-L/usr/,-L@STAGING_DIR@/usr/,g" \
  246. -e "s,@STAGING_DIR@,$(STAGING_DIR),g" \
  247. -e "s,@BASE_DIR@,$(BASE_DIR),g" \
  248. $(addprefix $(STAGING_DIR)/usr/bin/,$($(PKG)_CONFIG_SCRIPTS)) ;\
  249. fi
  250. @$(call MESSAGE,"Fixing libtool files")
  251. $(Q)find $(STAGING_DIR)/usr/lib* -name "*.la" | xargs --no-run-if-empty \
  252. $(SED) "s:$(BASE_DIR):@BASE_DIR@:g" \
  253. -e "s:$(STAGING_DIR):@STAGING_DIR@:g" \
  254. $(if $(TOOLCHAIN_EXTERNAL_INSTALL_DIR),\
  255. -e "s:$(TOOLCHAIN_EXTERNAL_INSTALL_DIR):@TOOLCHAIN_EXTERNAL_INSTALL_DIR@:g") \
  256. -e "s:\(['= ]\)/usr:\\1@STAGING_DIR@/usr:g" \
  257. $(if $(TOOLCHAIN_EXTERNAL_INSTALL_DIR),\
  258. -e "s:@TOOLCHAIN_EXTERNAL_INSTALL_DIR@:$(TOOLCHAIN_EXTERNAL_INSTALL_DIR):g") \
  259. -e "s:@STAGING_DIR@:$(STAGING_DIR):g" \
  260. -e "s:@BASE_DIR@:$(BASE_DIR):g"
  261. @$(call step_end,install-staging)
  262. $(Q)touch $@
  263. # Install to images dir
  264. $(BUILD_DIR)/%/.stamp_images_installed:
  265. @$(call step_start,install-image)
  266. $(foreach hook,$($(PKG)_PRE_INSTALL_IMAGES_HOOKS),$(call $(hook))$(sep))
  267. @$(call MESSAGE,"Installing to images directory")
  268. +$($(PKG)_INSTALL_IMAGES_CMDS)
  269. $(foreach hook,$($(PKG)_POST_INSTALL_IMAGES_HOOKS),$(call $(hook))$(sep))
  270. @$(call step_end,install-image)
  271. $(Q)touch $@
  272. # Install to target dir
  273. $(BUILD_DIR)/%/.stamp_target_installed:
  274. @$(call step_start,install-target)
  275. @$(call MESSAGE,"Installing to target")
  276. $(foreach hook,$($(PKG)_PRE_INSTALL_TARGET_HOOKS),$(call $(hook))$(sep))
  277. +$($(PKG)_INSTALL_TARGET_CMDS)
  278. $(if $(BR2_INIT_SYSTEMD),\
  279. $($(PKG)_INSTALL_INIT_SYSTEMD))
  280. $(if $(BR2_INIT_SYSV)$(BR2_INIT_BUSYBOX),\
  281. $($(PKG)_INSTALL_INIT_SYSV))
  282. $(foreach hook,$($(PKG)_POST_INSTALL_TARGET_HOOKS),$(call $(hook))$(sep))
  283. $(Q)if test -n "$($(PKG)_CONFIG_SCRIPTS)" ; then \
  284. $(RM) -f $(addprefix $(TARGET_DIR)/usr/bin/,$($(PKG)_CONFIG_SCRIPTS)) ; \
  285. fi
  286. @$(call step_end,install-target)
  287. $(Q)touch $@
  288. # Remove package sources
  289. $(BUILD_DIR)/%/.stamp_dircleaned:
  290. rm -Rf $(@D)
  291. ################################################################################
  292. # virt-provides-single -- check that provider-pkg is the declared provider for
  293. # the virtual package virt-pkg
  294. #
  295. # argument 1 is the lower-case name of the virtual package
  296. # argument 2 is the upper-case name of the virtual package
  297. # argument 3 is the lower-case name of the provider
  298. #
  299. # example:
  300. # $(call virt-provides-single,libegl,LIBEGL,rpi-userland)
  301. ################################################################################
  302. define virt-provides-single
  303. ifneq ($$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(2))),$(3))
  304. $$(error Configuration error: both "$(3)" and $$(BR2_PACKAGE_PROVIDES_$(2))\
  305. are selected as providers for virtual package "$(1)". Only one provider can\
  306. be selected at a time. Please fix your configuration)
  307. endif
  308. endef
  309. define pkg-graph-depends
  310. @$$(INSTALL) -d $$(GRAPHS_DIR)
  311. @cd "$$(CONFIG_DIR)"; \
  312. $$(TOPDIR)/support/scripts/graph-depends $$(BR2_GRAPH_DEPS_OPTS) \
  313. -p $(1) $(2) -o $$(GRAPHS_DIR)/$$(@).dot
  314. dot $$(BR2_GRAPH_DOT_OPTS) -T$$(BR_GRAPH_OUT) \
  315. -o $$(GRAPHS_DIR)/$$(@).$$(BR_GRAPH_OUT) \
  316. $$(GRAPHS_DIR)/$$(@).dot
  317. endef
  318. ################################################################################
  319. # inner-generic-package -- generates the make targets needed to build a
  320. # generic package
  321. #
  322. # argument 1 is the lowercase package name
  323. # argument 2 is the uppercase package name, including a HOST_ prefix
  324. # for host packages
  325. # argument 3 is the uppercase package name, without the HOST_ prefix
  326. # for host packages
  327. # argument 4 is the type (target or host)
  328. #
  329. # Note about variable and function references: inside all blocks that are
  330. # evaluated with $(eval), which includes all 'inner-xxx-package' blocks,
  331. # specific rules apply with respect to variable and function references.
  332. # - Numbered variables (parameters to the block) can be referenced with a single
  333. # dollar sign: $(1), $(2), $(3), etc.
  334. # - pkgdir and pkgname should be referenced with a single dollar sign too. These
  335. # functions rely on 'the most recently parsed makefile' which is supposed to
  336. # be the package .mk file. If we defer the evaluation of these functions using
  337. # double dollar signs, then they may be evaluated too late, when other
  338. # makefiles have already been parsed. One specific case is when $$(pkgdir) is
  339. # assigned to a variable using deferred evaluation with '=' and this variable
  340. # is used in a target rule outside the eval'ed inner block. In this case, the
  341. # pkgdir will be that of the last makefile parsed by buildroot, which is not
  342. # the expected value. This mechanism is for example used for the TARGET_PATCH
  343. # rule.
  344. # - All other variables should be referenced with a double dollar sign:
  345. # $$(TARGET_DIR), $$($(2)_VERSION), etc. Also all make functions should be
  346. # referenced with a double dollar sign: $$(subst), $$(call), $$(filter-out),
  347. # etc. This rule ensures that these variables and functions are only expanded
  348. # during the $(eval) step, and not earlier. Otherwise, unintuitive and
  349. # undesired behavior occurs with respect to these variables and functions.
  350. #
  351. ################################################################################
  352. define inner-generic-package
  353. # Ensure the package is only declared once, i.e. do not accept that a
  354. # package be re-defined by a br2-external tree
  355. ifneq ($(call strip,$(filter $(1),$(PACKAGES_ALL))),)
  356. $$(error Package '$(1)' defined a second time in '$(pkgdir)'; \
  357. previous definition was in '$$($(2)_PKGDIR)')
  358. endif
  359. PACKAGES_ALL += $(1)
  360. # Define default values for various package-related variables, if not
  361. # already defined. For some variables (version, source, site and
  362. # subdir), if they are undefined, we try to see if a variable without
  363. # the HOST_ prefix is defined. If so, we use such a variable, so that
  364. # this information has only to be specified once, for both the
  365. # target and host packages of a given .mk file.
  366. $(2)_TYPE = $(4)
  367. $(2)_NAME = $(1)
  368. $(2)_RAWNAME = $$(patsubst host-%,%,$(1))
  369. $(2)_PKGDIR = $(pkgdir)
  370. # Keep the package version that may contain forward slashes in the _DL_VERSION
  371. # variable, then replace all forward slashes ('/') by underscores ('_') to
  372. # sanitize the package version that is used in paths, directory and file names.
  373. # Forward slashes may appear in the package's version when pointing to a
  374. # version control system branch or tag, for example remotes/origin/1_10_stable.
  375. # Similar for spaces and colons (:) that may appear in date-based revisions for
  376. # CVS.
  377. ifndef $(2)_VERSION
  378. ifdef $(3)_DL_VERSION
  379. $(2)_DL_VERSION := $$($(3)_DL_VERSION)
  380. else ifdef $(3)_VERSION
  381. $(2)_DL_VERSION := $$($(3)_VERSION)
  382. endif
  383. else
  384. $(2)_DL_VERSION := $$(strip $$($(2)_VERSION))
  385. endif
  386. $(2)_VERSION := $$(call sanitize,$$($(2)_DL_VERSION))
  387. ifdef $(3)_OVERRIDE_SRCDIR
  388. $(2)_OVERRIDE_SRCDIR ?= $$($(3)_OVERRIDE_SRCDIR)
  389. endif
  390. $(2)_BASE_NAME = $$(if $$($(2)_VERSION),$(1)-$$($(2)_VERSION),$(1))
  391. $(2)_RAW_BASE_NAME = $$(if $$($(2)_VERSION),$$($(2)_RAWNAME)-$$($(2)_VERSION),$$($(2)_RAWNAME))
  392. $(2)_DL_DIR = $$(DL_DIR)
  393. $(2)_DIR = $$(BUILD_DIR)/$$($(2)_BASE_NAME)
  394. ifndef $(2)_SUBDIR
  395. ifdef $(3)_SUBDIR
  396. $(2)_SUBDIR = $$($(3)_SUBDIR)
  397. else
  398. $(2)_SUBDIR ?=
  399. endif
  400. endif
  401. ifndef $(2)_STRIP_COMPONENTS
  402. ifdef $(3)_STRIP_COMPONENTS
  403. $(2)_STRIP_COMPONENTS = $$($(3)_STRIP_COMPONENTS)
  404. else
  405. $(2)_STRIP_COMPONENTS ?= 1
  406. endif
  407. endif
  408. $(2)_SRCDIR = $$($(2)_DIR)/$$($(2)_SUBDIR)
  409. $(2)_BUILDDIR ?= $$($(2)_SRCDIR)
  410. ifneq ($$($(2)_OVERRIDE_SRCDIR),)
  411. $(2)_VERSION = custom
  412. endif
  413. ifndef $(2)_SOURCE
  414. ifdef $(3)_SOURCE
  415. $(2)_SOURCE = $$($(3)_SOURCE)
  416. else ifdef $(2)_VERSION
  417. $(2)_SOURCE ?= $$($(2)_RAW_BASE_NAME).tar.gz
  418. endif
  419. endif
  420. # If FOO_ACTUAL_SOURCE_TARBALL is explicitly defined, it means FOO_SOURCE is
  421. # indeed a binary (e.g. external toolchain) and FOO_ACTUAL_SOURCE_TARBALL/_SITE
  422. # point to the actual sources tarball. Use the actual sources for legal-info.
  423. # For most packages the FOO_SITE/FOO_SOURCE pair points to real source code,
  424. # so these are the defaults for FOO_ACTUAL_*.
  425. $(2)_ACTUAL_SOURCE_TARBALL ?= $$($(2)_SOURCE)
  426. $(2)_ACTUAL_SOURCE_SITE ?= $$(call qstrip,$$($(2)_SITE))
  427. ifndef $(2)_PATCH
  428. ifdef $(3)_PATCH
  429. $(2)_PATCH = $$($(3)_PATCH)
  430. endif
  431. endif
  432. $(2)_ALL_DOWNLOADS = \
  433. $$(foreach p,$$($(2)_SOURCE) $$($(2)_PATCH) $$($(2)_EXTRA_DOWNLOADS),\
  434. $$(if $$(findstring ://,$$(p)),$$(p),\
  435. $$($(2)_SITE)/$$(p)))
  436. ifndef $(2)_SITE
  437. ifdef $(3)_SITE
  438. $(2)_SITE = $$($(3)_SITE)
  439. endif
  440. endif
  441. ifndef $(2)_SITE_METHOD
  442. ifdef $(3)_SITE_METHOD
  443. $(2)_SITE_METHOD = $$($(3)_SITE_METHOD)
  444. else
  445. # Try automatic detection using the scheme part of the URI
  446. $(2)_SITE_METHOD = $$(call geturischeme,$$($(2)_SITE))
  447. endif
  448. endif
  449. # Do not accept to download git submodule if not using the git method
  450. ifneq ($$($(2)_GIT_SUBMODULES),)
  451. ifneq ($$($(2)_SITE_METHOD),git)
  452. $$(error $(2) declares having git sub-modules, but does not use the \
  453. 'git' method (uses '$$($(2)_SITE_METHOD)' instead))
  454. endif
  455. endif
  456. ifeq ($$($(2)_SITE_METHOD),local)
  457. ifeq ($$($(2)_OVERRIDE_SRCDIR),)
  458. $(2)_OVERRIDE_SRCDIR = $$($(2)_SITE)
  459. endif
  460. endif
  461. ifndef $(2)_LICENSE
  462. ifdef $(3)_LICENSE
  463. $(2)_LICENSE = $$($(3)_LICENSE)
  464. endif
  465. endif
  466. $(2)_LICENSE ?= unknown
  467. ifndef $(2)_LICENSE_FILES
  468. ifdef $(3)_LICENSE_FILES
  469. $(2)_LICENSE_FILES = $$($(3)_LICENSE_FILES)
  470. endif
  471. endif
  472. ifndef $(2)_REDISTRIBUTE
  473. ifdef $(3)_REDISTRIBUTE
  474. $(2)_REDISTRIBUTE = $$($(3)_REDISTRIBUTE)
  475. endif
  476. endif
  477. $(2)_REDISTRIBUTE ?= YES
  478. $(2)_REDIST_SOURCES_DIR = $$(REDIST_SOURCES_DIR_$$(call UPPERCASE,$(4)))/$$($(2)_RAW_BASE_NAME)
  479. # When a target package is a toolchain dependency set this variable to
  480. # 'NO' so the 'toolchain' dependency is not added to prevent a circular
  481. # dependency.
  482. # Similarly for the skeleton.
  483. $(2)_ADD_TOOLCHAIN_DEPENDENCY ?= YES
  484. $(2)_ADD_SKELETON_DEPENDENCY ?= YES
  485. ifeq ($(4),target)
  486. ifeq ($$($(2)_ADD_SKELETON_DEPENDENCY),YES)
  487. $(2)_DEPENDENCIES += skeleton
  488. endif
  489. ifeq ($$($(2)_ADD_TOOLCHAIN_DEPENDENCY),YES)
  490. $(2)_DEPENDENCIES += toolchain
  491. endif
  492. endif
  493. ifneq ($(1),host-skeleton)
  494. $(2)_DEPENDENCIES += host-skeleton
  495. endif
  496. ifeq ($(filter host-tar host-skeleton,$(1)),)
  497. $(2)_EXTRACT_DEPENDENCIES += $(BR2_TAR_HOST_DEPENDENCY)
  498. endif
  499. # Eliminate duplicates in dependencies
  500. $(2)_FINAL_DEPENDENCIES = $$(sort $$($(2)_DEPENDENCIES))
  501. $(2)_FINAL_EXTRACT_DEPENDENCIES = $$(sort $$($(2)_EXTRACT_DEPENDENCIES))
  502. $(2)_FINAL_PATCH_DEPENDENCIES = $$(sort $$($(2)_PATCH_DEPENDENCIES))
  503. $(2)_FINAL_ALL_DEPENDENCIES = \
  504. $$(sort \
  505. $$($(2)_FINAL_DEPENDENCIES) \
  506. $$($(2)_FINAL_EXTRACT_DEPENDENCIES) \
  507. $$($(2)_FINAL_PATCH_DEPENDENCIES))
  508. $(2)_INSTALL_STAGING ?= NO
  509. $(2)_INSTALL_IMAGES ?= NO
  510. $(2)_INSTALL_TARGET ?= YES
  511. # define sub-target stamps
  512. $(2)_TARGET_INSTALL_TARGET = $$($(2)_DIR)/.stamp_target_installed
  513. $(2)_TARGET_INSTALL_STAGING = $$($(2)_DIR)/.stamp_staging_installed
  514. $(2)_TARGET_INSTALL_IMAGES = $$($(2)_DIR)/.stamp_images_installed
  515. $(2)_TARGET_INSTALL_HOST = $$($(2)_DIR)/.stamp_host_installed
  516. $(2)_TARGET_BUILD = $$($(2)_DIR)/.stamp_built
  517. $(2)_TARGET_CONFIGURE = $$($(2)_DIR)/.stamp_configured
  518. $(2)_TARGET_RSYNC = $$($(2)_DIR)/.stamp_rsynced
  519. $(2)_TARGET_PATCH = $$($(2)_DIR)/.stamp_patched
  520. $(2)_TARGET_EXTRACT = $$($(2)_DIR)/.stamp_extracted
  521. $(2)_TARGET_SOURCE = $$($(2)_DIR)/.stamp_downloaded
  522. $(2)_TARGET_ACTUAL_SOURCE = $$($(2)_DIR)/.stamp_actual_downloaded
  523. $(2)_TARGET_DIRCLEAN = $$($(2)_DIR)/.stamp_dircleaned
  524. # default extract command
  525. $(2)_EXTRACT_CMDS ?= \
  526. $$(if $$($(2)_SOURCE),$$(INFLATE$$(suffix $$($(2)_SOURCE))) $$(DL_DIR)/$$($(2)_SOURCE) | \
  527. $$(TAR) --strip-components=$$($(2)_STRIP_COMPONENTS) \
  528. -C $$($(2)_DIR) \
  529. $$(foreach x,$$($(2)_EXCLUDES),--exclude='$$(x)' ) \
  530. $$(TAR_OPTIONS) -)
  531. # pre/post-steps hooks
  532. $(2)_PRE_DOWNLOAD_HOOKS ?=
  533. $(2)_POST_DOWNLOAD_HOOKS ?=
  534. $(2)_PRE_EXTRACT_HOOKS ?=
  535. $(2)_POST_EXTRACT_HOOKS ?=
  536. $(2)_PRE_RSYNC_HOOKS ?=
  537. $(2)_POST_RSYNC_HOOKS ?=
  538. $(2)_PRE_PATCH_HOOKS ?=
  539. $(2)_POST_PATCH_HOOKS ?=
  540. $(2)_PRE_CONFIGURE_HOOKS ?=
  541. $(2)_POST_CONFIGURE_HOOKS ?=
  542. $(2)_PRE_BUILD_HOOKS ?=
  543. $(2)_POST_BUILD_HOOKS ?=
  544. $(2)_PRE_INSTALL_HOOKS ?=
  545. $(2)_POST_INSTALL_HOOKS ?=
  546. $(2)_PRE_INSTALL_STAGING_HOOKS ?=
  547. $(2)_POST_INSTALL_STAGING_HOOKS ?=
  548. $(2)_PRE_INSTALL_TARGET_HOOKS ?=
  549. $(2)_POST_INSTALL_TARGET_HOOKS ?=
  550. $(2)_PRE_INSTALL_IMAGES_HOOKS ?=
  551. $(2)_POST_INSTALL_IMAGES_HOOKS ?=
  552. $(2)_PRE_LEGAL_INFO_HOOKS ?=
  553. $(2)_POST_LEGAL_INFO_HOOKS ?=
  554. $(2)_TARGET_FINALIZE_HOOKS ?=
  555. $(2)_ROOTFS_PRE_CMD_HOOKS ?=
  556. $(2)_ROOTFS_POST_CMD_HOOKS ?=
  557. # human-friendly targets and target sequencing
  558. $(1): $(1)-install
  559. ifeq ($$($(2)_TYPE),host)
  560. $(1)-install: $(1)-install-host
  561. else
  562. $(1)-install: $(1)-install-staging $(1)-install-target $(1)-install-images
  563. endif
  564. ifeq ($$($(2)_INSTALL_TARGET),YES)
  565. $(1)-install-target: $$($(2)_TARGET_INSTALL_TARGET)
  566. $$($(2)_TARGET_INSTALL_TARGET): $$($(2)_TARGET_BUILD)
  567. else
  568. $(1)-install-target:
  569. endif
  570. ifeq ($$($(2)_INSTALL_STAGING),YES)
  571. $(1)-install-staging: $$($(2)_TARGET_INSTALL_STAGING)
  572. $$($(2)_TARGET_INSTALL_STAGING): $$($(2)_TARGET_BUILD)
  573. # Some packages use install-staging stuff for install-target
  574. $$($(2)_TARGET_INSTALL_TARGET): $$($(2)_TARGET_INSTALL_STAGING)
  575. else
  576. $(1)-install-staging:
  577. endif
  578. ifeq ($$($(2)_INSTALL_IMAGES),YES)
  579. $(1)-install-images: $$($(2)_TARGET_INSTALL_IMAGES)
  580. $$($(2)_TARGET_INSTALL_IMAGES): $$($(2)_TARGET_BUILD)
  581. else
  582. $(1)-install-images:
  583. endif
  584. $(1)-install-host: $$($(2)_TARGET_INSTALL_HOST)
  585. $$($(2)_TARGET_INSTALL_HOST): $$($(2)_TARGET_BUILD)
  586. $(1)-build: $$($(2)_TARGET_BUILD)
  587. $$($(2)_TARGET_BUILD): $$($(2)_TARGET_CONFIGURE)
  588. # Since $(2)_FINAL_DEPENDENCIES are phony targets, they are always "newer"
  589. # than $(2)_TARGET_CONFIGURE. This would force the configure step (and
  590. # therefore the other steps as well) to be re-executed with every
  591. # invocation of make. Therefore, make $(2)_FINAL_DEPENDENCIES an order-only
  592. # dependency by using |.
  593. $(1)-configure: $$($(2)_TARGET_CONFIGURE)
  594. $$($(2)_TARGET_CONFIGURE): | $$($(2)_FINAL_DEPENDENCIES)
  595. $$($(2)_TARGET_SOURCE) $$($(2)_TARGET_RSYNC): | dirs prepare
  596. ifeq ($$(filter $(1),$$(DEPENDENCIES_HOST_PREREQ)),)
  597. $$($(2)_TARGET_SOURCE) $$($(2)_TARGET_RSYNC): | dependencies
  598. endif
  599. ifeq ($$($(2)_OVERRIDE_SRCDIR),)
  600. # In the normal case (no package override), the sequence of steps is
  601. # source, by downloading
  602. # depends
  603. # extract
  604. # patch
  605. # configure
  606. $$($(2)_TARGET_CONFIGURE): $$($(2)_TARGET_PATCH)
  607. $(1)-patch: $$($(2)_TARGET_PATCH)
  608. $$($(2)_TARGET_PATCH): $$($(2)_TARGET_EXTRACT)
  609. # Order-only dependency
  610. $$($(2)_TARGET_PATCH): | $$(patsubst %,%-patch,$$($(2)_FINAL_PATCH_DEPENDENCIES))
  611. $(1)-extract: $$($(2)_TARGET_EXTRACT)
  612. $$($(2)_TARGET_EXTRACT): $$($(2)_TARGET_SOURCE)
  613. $$($(2)_TARGET_EXTRACT): | $$($(2)_FINAL_EXTRACT_DEPENDENCIES)
  614. $(1)-depends: $$($(2)_FINAL_DEPENDENCIES)
  615. $(1)-source: $$($(2)_TARGET_SOURCE)
  616. $(1)-all-source: $(1)-legal-source
  617. $(1)-legal-info: $(1)-legal-source
  618. $(1)-legal-source: $(1)-source
  619. # Only download the actual source if it differs from the 'main' archive
  620. ifneq ($$($(2)_ACTUAL_SOURCE_TARBALL),)
  621. ifneq ($$($(2)_ACTUAL_SOURCE_TARBALL),$$($(2)_SOURCE))
  622. $(1)-legal-source: $$($(2)_TARGET_ACTUAL_SOURCE)
  623. endif # actual sources != sources
  624. endif # actual sources != ""
  625. $(1)-external-deps:
  626. @for p in $$($(2)_SOURCE) $$($(2)_PATCH) $$($(2)_EXTRA_DOWNLOADS) ; do \
  627. echo `basename $$$$p` ; \
  628. done
  629. else
  630. # In the package override case, the sequence of steps
  631. # source, by rsyncing
  632. # depends
  633. # configure
  634. # Use an order-only dependency so the "<pkg>-clean-for-rebuild" rule
  635. # can remove the stamp file without triggering the configure step.
  636. $$($(2)_TARGET_CONFIGURE): | $$($(2)_TARGET_RSYNC)
  637. $(1)-depends: $$($(2)_FINAL_DEPENDENCIES)
  638. $(1)-patch: $(1)-rsync
  639. $(1)-extract: $(1)-rsync
  640. $(1)-rsync: $$($(2)_TARGET_RSYNC)
  641. $(1)-source:
  642. $(1)-legal-source:
  643. $(1)-external-deps:
  644. @echo "file://$$($(2)_OVERRIDE_SRCDIR)"
  645. endif
  646. $(1)-show-version:
  647. @echo $$($(2)_VERSION)
  648. $(1)-show-depends:
  649. @echo $$($(2)_FINAL_ALL_DEPENDENCIES)
  650. $(1)-show-rdepends:
  651. @echo $$($(2)_RDEPENDENCIES)
  652. $(1)-show-build-order: $$(patsubst %,%-show-build-order,$$($(2)_FINAL_ALL_DEPENDENCIES))
  653. $$(info $(1))
  654. $(1)-graph-depends: graph-depends-requirements
  655. $(call pkg-graph-depends,$(1),--direct)
  656. $(1)-graph-rdepends: graph-depends-requirements
  657. $(call pkg-graph-depends,$(1),--reverse)
  658. $(1)-all-source: $(1)-source
  659. $(1)-all-source: $$(foreach p,$$($(2)_FINAL_ALL_DEPENDENCIES),$$(p)-all-source)
  660. $(1)-all-external-deps: $(1)-external-deps
  661. $(1)-all-external-deps: $$(foreach p,$$($(2)_FINAL_ALL_DEPENDENCIES),$$(p)-all-external-deps)
  662. $(1)-all-legal-info: $(1)-legal-info
  663. $(1)-all-legal-info: $$(foreach p,$$($(2)_FINAL_ALL_DEPENDENCIES),$$(p)-all-legal-info)
  664. $(1)-dirclean: $$($(2)_TARGET_DIRCLEAN)
  665. $(1)-clean-for-reinstall:
  666. ifneq ($$($(2)_OVERRIDE_SRCDIR),)
  667. rm -f $$($(2)_TARGET_RSYNC)
  668. endif
  669. rm -f $$($(2)_TARGET_INSTALL_STAGING)
  670. rm -f $$($(2)_TARGET_INSTALL_TARGET)
  671. rm -f $$($(2)_TARGET_INSTALL_IMAGES)
  672. rm -f $$($(2)_TARGET_INSTALL_HOST)
  673. $(1)-reinstall: $(1)-clean-for-reinstall $(1)
  674. $(1)-clean-for-rebuild: $(1)-clean-for-reinstall
  675. rm -f $$($(2)_TARGET_BUILD)
  676. $(1)-rebuild: $(1)-clean-for-rebuild $(1)
  677. $(1)-clean-for-reconfigure: $(1)-clean-for-rebuild
  678. rm -f $$($(2)_TARGET_CONFIGURE)
  679. $(1)-reconfigure: $(1)-clean-for-reconfigure $(1)
  680. # define the PKG variable for all targets, containing the
  681. # uppercase package variable prefix
  682. $$($(2)_TARGET_INSTALL_TARGET): PKG=$(2)
  683. $$($(2)_TARGET_INSTALL_STAGING): PKG=$(2)
  684. $$($(2)_TARGET_INSTALL_IMAGES): PKG=$(2)
  685. $$($(2)_TARGET_INSTALL_HOST): PKG=$(2)
  686. $$($(2)_TARGET_BUILD): PKG=$(2)
  687. $$($(2)_TARGET_CONFIGURE): PKG=$(2)
  688. $$($(2)_TARGET_RSYNC): SRCDIR=$$($(2)_OVERRIDE_SRCDIR)
  689. $$($(2)_TARGET_RSYNC): PKG=$(2)
  690. $$($(2)_TARGET_PATCH): PKG=$(2)
  691. $$($(2)_TARGET_PATCH): RAWNAME=$$(patsubst host-%,%,$(1))
  692. $$($(2)_TARGET_PATCH): PKGDIR=$(pkgdir)
  693. $$($(2)_TARGET_EXTRACT): PKG=$(2)
  694. $$($(2)_TARGET_SOURCE): PKG=$(2)
  695. $$($(2)_TARGET_SOURCE): PKGDIR=$(pkgdir)
  696. $$($(2)_TARGET_ACTUAL_SOURCE): PKG=$(2)
  697. $$($(2)_TARGET_ACTUAL_SOURCE): PKGDIR=$(pkgdir)
  698. $$($(2)_TARGET_DIRCLEAN): PKG=$(2)
  699. # Compute the name of the Kconfig option that correspond to the
  700. # package being enabled. We handle three cases: the special Linux
  701. # kernel case, the bootloaders case, and the normal packages case.
  702. ifeq ($(1),linux)
  703. $(2)_KCONFIG_VAR = BR2_LINUX_KERNEL
  704. else ifneq ($$(filter boot/% $$(foreach dir,$$(BR2_EXTERNAL_DIRS),$$(dir)/boot/%),$(pkgdir)),)
  705. $(2)_KCONFIG_VAR = BR2_TARGET_$(2)
  706. else ifneq ($$(filter toolchain/% $$(foreach dir,$$(BR2_EXTERNAL_DIRS),$$(dir)/toolchain/%),$(pkgdir)),)
  707. $(2)_KCONFIG_VAR = BR2_$(2)
  708. else
  709. $(2)_KCONFIG_VAR = BR2_PACKAGE_$(2)
  710. endif
  711. # legal-info: declare dependencies and set values used later for the manifest
  712. ifneq ($$($(2)_LICENSE_FILES),)
  713. $(2)_MANIFEST_LICENSE_FILES = $$($(2)_LICENSE_FILES)
  714. endif
  715. # We need to extract and patch a package to be able to retrieve its
  716. # license files (if any) and the list of patches applied to it (if
  717. # any).
  718. $(1)-legal-info: $(1)-patch
  719. # We only save the sources of packages we want to redistribute, that are
  720. # non-overriden (local or true override).
  721. ifeq ($$($(2)_REDISTRIBUTE),YES)
  722. ifeq ($$($(2)_OVERRIDE_SRCDIR),)
  723. # Packages that have a tarball need it downloaded beforehand
  724. $(1)-legal-info: $(1)-source $$(REDIST_SOURCES_DIR_$$(call UPPERCASE,$(4)))
  725. endif
  726. endif
  727. # legal-info: produce legally relevant info.
  728. $(1)-legal-info: PKG=$(2)
  729. $(1)-legal-info:
  730. @$$(call MESSAGE,"Collecting legal info")
  731. # Packages without a source are assumed to be part of Buildroot, skip them.
  732. $$(foreach hook,$$($(2)_PRE_LEGAL_INFO_HOOKS),$$(call $$(hook))$$(sep))
  733. ifneq ($$(call qstrip,$$($(2)_SOURCE)),)
  734. # Save license files if defined
  735. # We save the license files for any kind of package: normal, local,
  736. # overridden, or non-redistributable alike.
  737. # The reason to save license files even for no-redistribute packages
  738. # is that the license still applies to the files distributed as part
  739. # of the rootfs, even if the sources are not themselves redistributed.
  740. ifeq ($$(call qstrip,$$($(2)_LICENSE_FILES)),)
  741. $(Q)$$(call legal-warning-pkg,$$($(2)_RAW_BASE_NAME),cannot save license ($(2)_LICENSE_FILES not defined))
  742. else
  743. $(Q)$$(foreach F,$$($(2)_LICENSE_FILES),$$(call legal-license-file,$$($(2)_RAWNAME),$$($(2)_RAW_BASE_NAME),$$($(2)_PKGDIR),$$(F),$$($(2)_DIR)/$$(F),$$(call UPPERCASE,$(4)))$$(sep))
  744. endif # license files
  745. ifeq ($$($(2)_SITE_METHOD),local)
  746. # Packages without a tarball: don't save and warn
  747. @$$(call legal-warning-nosource,$$($(2)_RAWNAME),local)
  748. else ifneq ($$($(2)_OVERRIDE_SRCDIR),)
  749. @$$(call legal-warning-nosource,$$($(2)_RAWNAME),override)
  750. else
  751. # Other packages
  752. ifeq ($$($(2)_REDISTRIBUTE),YES)
  753. # Save the source tarball and any extra downloads, but not
  754. # patches, as they are handled specially afterwards.
  755. $$(foreach e,$$($(2)_ACTUAL_SOURCE_TARBALL) $$(notdir $$($(2)_EXTRA_DOWNLOADS)),\
  756. $$(Q)support/scripts/hardlink-or-copy \
  757. $$(DL_DIR)/$$(e) \
  758. $$($(2)_REDIST_SOURCES_DIR)$$(sep))
  759. # Save patches and generate the series file
  760. $$(Q)while read f; do \
  761. support/scripts/hardlink-or-copy \
  762. $$$${f} \
  763. $$($(2)_REDIST_SOURCES_DIR) || exit 1; \
  764. printf "%s\n" "$$$${f##*/}" >>$$($(2)_REDIST_SOURCES_DIR)/series || exit 1; \
  765. done <$$($(2)_DIR)/.applied_patches_list
  766. endif # redistribute
  767. endif # other packages
  768. @$$(call legal-manifest,$$($(2)_RAWNAME),$$($(2)_VERSION),$$($(2)_LICENSE),$$($(2)_MANIFEST_LICENSE_FILES),$$($(2)_ACTUAL_SOURCE_TARBALL),$$($(2)_ACTUAL_SOURCE_SITE),$$(call UPPERCASE,$(4)))
  769. endif # ifneq ($$(call qstrip,$$($(2)_SOURCE)),)
  770. $$(foreach hook,$$($(2)_POST_LEGAL_INFO_HOOKS),$$(call $$(hook))$$(sep))
  771. # add package to the general list of targets if requested by the buildroot
  772. # configuration
  773. ifeq ($$($$($(2)_KCONFIG_VAR)),y)
  774. # Ensure the calling package is the declared provider for all the virtual
  775. # packages it claims to be an implementation of.
  776. ifneq ($$($(2)_PROVIDES),)
  777. $$(foreach pkg,$$($(2)_PROVIDES),\
  778. $$(eval $$(call virt-provides-single,$$(pkg),$$(call UPPERCASE,$$(pkg)),$(1))$$(sep)))
  779. endif
  780. # Register package as a reverse-dependencies of all its dependencies
  781. $$(eval $$(foreach p,$$($(2)_FINAL_ALL_DEPENDENCIES),\
  782. $$(call UPPERCASE,$$(p))_RDEPENDENCIES += $(1)$$(sep)))
  783. # Ensure unified variable name conventions between all packages Some
  784. # of the variables are used by more than one infrastructure; so,
  785. # rather than duplicating the checks in each infrastructure, we check
  786. # all variables here in pkg-generic, even though pkg-generic should
  787. # have no knowledge of infra-specific variables.
  788. $(eval $(call check-deprecated-variable,$(2)_MAKE_OPT,$(2)_MAKE_OPTS))
  789. $(eval $(call check-deprecated-variable,$(2)_INSTALL_OPT,$(2)_INSTALL_OPTS))
  790. $(eval $(call check-deprecated-variable,$(2)_INSTALL_TARGET_OPT,$(2)_INSTALL_TARGET_OPTS))
  791. $(eval $(call check-deprecated-variable,$(2)_INSTALL_STAGING_OPT,$(2)_INSTALL_STAGING_OPTS))
  792. $(eval $(call check-deprecated-variable,$(2)_INSTALL_HOST_OPT,$(2)_INSTALL_HOST_OPTS))
  793. $(eval $(call check-deprecated-variable,$(2)_AUTORECONF_OPT,$(2)_AUTORECONF_OPTS))
  794. $(eval $(call check-deprecated-variable,$(2)_CONF_OPT,$(2)_CONF_OPTS))
  795. $(eval $(call check-deprecated-variable,$(2)_BUILD_OPT,$(2)_BUILD_OPTS))
  796. $(eval $(call check-deprecated-variable,$(2)_GETTEXTIZE_OPT,$(2)_GETTEXTIZE_OPTS))
  797. $(eval $(call check-deprecated-variable,$(2)_KCONFIG_OPT,$(2)_KCONFIG_OPTS))
  798. PACKAGES += $(1)
  799. ifneq ($$($(2)_PERMISSIONS),)
  800. PACKAGES_PERMISSIONS_TABLE += $$($(2)_PERMISSIONS)$$(sep)
  801. endif
  802. ifneq ($$($(2)_DEVICES),)
  803. PACKAGES_DEVICES_TABLE += $$($(2)_DEVICES)$$(sep)
  804. endif
  805. ifneq ($$($(2)_USERS),)
  806. PACKAGES_USERS += $$($(2)_USERS)$$(sep)
  807. endif
  808. TARGET_FINALIZE_HOOKS += $$($(2)_TARGET_FINALIZE_HOOKS)
  809. ROOTFS_PRE_CMD_HOOKS += $$($(2)_ROOTFS_PRE_CMD_HOOKS)
  810. ROOTFS_POST_CMD_HOOKS += $$($(2)_ROOTFS_POST_CMD_HOOKS)
  811. ifeq ($$($(2)_SITE_METHOD),svn)
  812. DL_TOOLS_DEPENDENCIES += svn
  813. else ifeq ($$($(2)_SITE_METHOD),git)
  814. DL_TOOLS_DEPENDENCIES += git
  815. else ifeq ($$($(2)_SITE_METHOD),bzr)
  816. DL_TOOLS_DEPENDENCIES += bzr
  817. else ifeq ($$($(2)_SITE_METHOD),scp)
  818. DL_TOOLS_DEPENDENCIES += scp ssh
  819. else ifeq ($$($(2)_SITE_METHOD),hg)
  820. DL_TOOLS_DEPENDENCIES += hg
  821. else ifeq ($$($(2)_SITE_METHOD),cvs)
  822. DL_TOOLS_DEPENDENCIES += cvs
  823. endif # SITE_METHOD
  824. DL_TOOLS_DEPENDENCIES += $$(call extractor-dependency,$$($(2)_SOURCE))
  825. # Ensure all virtual targets are PHONY. Listed alphabetically.
  826. .PHONY: $(1) \
  827. $(1)-all-external-deps \
  828. $(1)-all-legal-info \
  829. $(1)-all-source \
  830. $(1)-build \
  831. $(1)-clean-for-rebuild \
  832. $(1)-clean-for-reconfigure \
  833. $(1)-clean-for-reinstall \
  834. $(1)-configure \
  835. $(1)-depends \
  836. $(1)-dirclean \
  837. $(1)-external-deps \
  838. $(1)-extract \
  839. $(1)-graph-depends \
  840. $(1)-install \
  841. $(1)-install-host \
  842. $(1)-install-images \
  843. $(1)-install-staging \
  844. $(1)-install-target \
  845. $(1)-legal-info \
  846. $(1)-legal-source \
  847. $(1)-patch \
  848. $(1)-rebuild \
  849. $(1)-reconfigure \
  850. $(1)-reinstall \
  851. $(1)-rsync \
  852. $(1)-show-depends \
  853. $(1)-show-version \
  854. $(1)-source
  855. ifneq ($$($(2)_SOURCE),)
  856. ifeq ($$($(2)_SITE),)
  857. $$(error $(2)_SITE cannot be empty when $(2)_SOURCE is not)
  858. endif
  859. endif
  860. ifeq ($$(patsubst %/,ERROR,$$($(2)_SITE)),ERROR)
  861. $$(error $(2)_SITE ($$($(2)_SITE)) cannot have a trailing slash)
  862. endif
  863. ifneq ($$($(2)_HELP_CMDS),)
  864. HELP_PACKAGES += $(2)
  865. endif
  866. endif # $(2)_KCONFIG_VAR
  867. endef # inner-generic-package
  868. ################################################################################
  869. # generic-package -- the target generator macro for generic packages
  870. ################################################################################
  871. # In the case of target packages, keep the package name "pkg"
  872. generic-package = $(call inner-generic-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target)
  873. # In the case of host packages, turn the package name "pkg" into "host-pkg"
  874. host-generic-package = $(call inner-generic-package,host-$(pkgname),$(call UPPERCASE,host-$(pkgname)),$(call UPPERCASE,$(pkgname)),host)
  875. # :mode=makefile: