pkg-generic.mk 36 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030
  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) $($(PKG)_OVERRIDE_SRCDIR_RSYNC_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. # When doing a package, we're definitely not doing a rootfs, but we
  354. # may inherit it via the dependency chain, so we reset it.
  355. $(1): ROOTFS=
  356. # Ensure the package is only declared once, i.e. do not accept that a
  357. # package be re-defined by a br2-external tree
  358. ifneq ($(call strip,$(filter $(1),$(PACKAGES_ALL))),)
  359. $$(error Package '$(1)' defined a second time in '$(pkgdir)'; \
  360. previous definition was in '$$($(2)_PKGDIR)')
  361. endif
  362. PACKAGES_ALL += $(1)
  363. # Define default values for various package-related variables, if not
  364. # already defined. For some variables (version, source, site and
  365. # subdir), if they are undefined, we try to see if a variable without
  366. # the HOST_ prefix is defined. If so, we use such a variable, so that
  367. # this information has only to be specified once, for both the
  368. # target and host packages of a given .mk file.
  369. $(2)_TYPE = $(4)
  370. $(2)_NAME = $(1)
  371. $(2)_RAWNAME = $$(patsubst host-%,%,$(1))
  372. $(2)_PKGDIR = $(pkgdir)
  373. # Keep the package version that may contain forward slashes in the _DL_VERSION
  374. # variable, then replace all forward slashes ('/') by underscores ('_') to
  375. # sanitize the package version that is used in paths, directory and file names.
  376. # Forward slashes may appear in the package's version when pointing to a
  377. # version control system branch or tag, for example remotes/origin/1_10_stable.
  378. # Similar for spaces and colons (:) that may appear in date-based revisions for
  379. # CVS.
  380. ifndef $(2)_VERSION
  381. ifdef $(3)_DL_VERSION
  382. $(2)_DL_VERSION := $$($(3)_DL_VERSION)
  383. else ifdef $(3)_VERSION
  384. $(2)_DL_VERSION := $$($(3)_VERSION)
  385. endif
  386. else
  387. $(2)_DL_VERSION := $$(strip $$($(2)_VERSION))
  388. endif
  389. $(2)_VERSION := $$(call sanitize,$$($(2)_DL_VERSION))
  390. ifdef $(3)_OVERRIDE_SRCDIR
  391. $(2)_OVERRIDE_SRCDIR ?= $$($(3)_OVERRIDE_SRCDIR)
  392. endif
  393. $(2)_BASENAME = $$(if $$($(2)_VERSION),$(1)-$$($(2)_VERSION),$(1))
  394. $(2)_BASENAME_RAW = $$(if $$($(2)_VERSION),$$($(2)_RAWNAME)-$$($(2)_VERSION),$$($(2)_RAWNAME))
  395. $(2)_DL_DIR = $$(DL_DIR)
  396. $(2)_DIR = $$(BUILD_DIR)/$$($(2)_BASENAME)
  397. ifndef $(2)_SUBDIR
  398. ifdef $(3)_SUBDIR
  399. $(2)_SUBDIR = $$($(3)_SUBDIR)
  400. else
  401. $(2)_SUBDIR ?=
  402. endif
  403. endif
  404. ifndef $(2)_STRIP_COMPONENTS
  405. ifdef $(3)_STRIP_COMPONENTS
  406. $(2)_STRIP_COMPONENTS = $$($(3)_STRIP_COMPONENTS)
  407. else
  408. $(2)_STRIP_COMPONENTS ?= 1
  409. endif
  410. endif
  411. $(2)_SRCDIR = $$($(2)_DIR)/$$($(2)_SUBDIR)
  412. $(2)_BUILDDIR ?= $$($(2)_SRCDIR)
  413. ifneq ($$($(2)_OVERRIDE_SRCDIR),)
  414. $(2)_VERSION = custom
  415. endif
  416. ifndef $(2)_SOURCE
  417. ifdef $(3)_SOURCE
  418. $(2)_SOURCE = $$($(3)_SOURCE)
  419. else ifdef $(2)_VERSION
  420. $(2)_SOURCE ?= $$($(2)_BASENAME_RAW).tar.gz
  421. endif
  422. endif
  423. # If FOO_ACTUAL_SOURCE_TARBALL is explicitly defined, it means FOO_SOURCE is
  424. # indeed a binary (e.g. external toolchain) and FOO_ACTUAL_SOURCE_TARBALL/_SITE
  425. # point to the actual sources tarball. Use the actual sources for legal-info.
  426. # For most packages the FOO_SITE/FOO_SOURCE pair points to real source code,
  427. # so these are the defaults for FOO_ACTUAL_*.
  428. $(2)_ACTUAL_SOURCE_TARBALL ?= $$($(2)_SOURCE)
  429. $(2)_ACTUAL_SOURCE_SITE ?= $$(call qstrip,$$($(2)_SITE))
  430. ifndef $(2)_PATCH
  431. ifdef $(3)_PATCH
  432. $(2)_PATCH = $$($(3)_PATCH)
  433. endif
  434. endif
  435. $(2)_ALL_DOWNLOADS = \
  436. $$(foreach p,$$($(2)_SOURCE) $$($(2)_PATCH) $$($(2)_EXTRA_DOWNLOADS),\
  437. $$(if $$(findstring ://,$$(p)),$$(p),\
  438. $$($(2)_SITE)/$$(p)))
  439. ifndef $(2)_SITE
  440. ifdef $(3)_SITE
  441. $(2)_SITE = $$($(3)_SITE)
  442. endif
  443. endif
  444. ifndef $(2)_SITE_METHOD
  445. ifdef $(3)_SITE_METHOD
  446. $(2)_SITE_METHOD = $$($(3)_SITE_METHOD)
  447. else
  448. # Try automatic detection using the scheme part of the URI
  449. $(2)_SITE_METHOD = $$(call geturischeme,$$($(2)_SITE))
  450. endif
  451. endif
  452. # Do not accept to download git submodule if not using the git method
  453. ifneq ($$($(2)_GIT_SUBMODULES),)
  454. ifneq ($$($(2)_SITE_METHOD),git)
  455. $$(error $(2) declares having git sub-modules, but does not use the \
  456. 'git' method (uses '$$($(2)_SITE_METHOD)' instead))
  457. endif
  458. endif
  459. ifeq ($$($(2)_SITE_METHOD),local)
  460. ifeq ($$($(2)_OVERRIDE_SRCDIR),)
  461. $(2)_OVERRIDE_SRCDIR = $$($(2)_SITE)
  462. endif
  463. endif
  464. ifndef $(2)_LICENSE
  465. ifdef $(3)_LICENSE
  466. $(2)_LICENSE = $$($(3)_LICENSE)
  467. endif
  468. endif
  469. $(2)_LICENSE ?= unknown
  470. ifndef $(2)_LICENSE_FILES
  471. ifdef $(3)_LICENSE_FILES
  472. $(2)_LICENSE_FILES = $$($(3)_LICENSE_FILES)
  473. endif
  474. endif
  475. ifndef $(2)_REDISTRIBUTE
  476. ifdef $(3)_REDISTRIBUTE
  477. $(2)_REDISTRIBUTE = $$($(3)_REDISTRIBUTE)
  478. endif
  479. endif
  480. $(2)_REDISTRIBUTE ?= YES
  481. $(2)_REDIST_SOURCES_DIR = $$(REDIST_SOURCES_DIR_$$(call UPPERCASE,$(4)))/$$($(2)_BASENAME_RAW)
  482. # When a target package is a toolchain dependency set this variable to
  483. # 'NO' so the 'toolchain' dependency is not added to prevent a circular
  484. # dependency.
  485. # Similarly for the skeleton.
  486. $(2)_ADD_TOOLCHAIN_DEPENDENCY ?= YES
  487. $(2)_ADD_SKELETON_DEPENDENCY ?= YES
  488. ifeq ($(4),target)
  489. ifeq ($$($(2)_ADD_SKELETON_DEPENDENCY),YES)
  490. $(2)_DEPENDENCIES += skeleton
  491. endif
  492. ifeq ($$($(2)_ADD_TOOLCHAIN_DEPENDENCY),YES)
  493. $(2)_DEPENDENCIES += toolchain
  494. endif
  495. endif
  496. ifneq ($(1),host-skeleton)
  497. $(2)_DEPENDENCIES += host-skeleton
  498. endif
  499. ifeq ($(filter host-tar host-skeleton host-fakedate,$(1)),)
  500. $(2)_EXTRACT_DEPENDENCIES += $(BR2_TAR_HOST_DEPENDENCY)
  501. endif
  502. ifeq ($(filter host-tar host-skeleton host-xz host-lzip host-fakedate,$(1)),)
  503. $(2)_EXTRACT_DEPENDENCIES += $(BR2_XZCAT_HOST_DEPENDENCY)
  504. endif
  505. ifeq ($(filter host-tar host-skeleton host-xz host-lzip host-fakedate,$(1)),)
  506. $(2)_EXTRACT_DEPENDENCIES += $(BR2_LZIP_HOST_DEPENDENCY)
  507. endif
  508. ifeq ($(BR2_CCACHE),y)
  509. ifeq ($(filter host-tar host-skeleton host-xz host-lzip host-fakedate host-ccache,$(1)),)
  510. $(2)_DEPENDENCIES += host-ccache
  511. endif
  512. endif
  513. ifeq ($(BR2_REPRODUCIBLE),y)
  514. ifeq ($(filter host-skeleton host-fakedate,$(1)),)
  515. $(2)_DEPENDENCIES += host-fakedate
  516. endif
  517. endif
  518. # Eliminate duplicates in dependencies
  519. $(2)_FINAL_DEPENDENCIES = $$(sort $$($(2)_DEPENDENCIES))
  520. $(2)_FINAL_EXTRACT_DEPENDENCIES = $$(sort $$($(2)_EXTRACT_DEPENDENCIES))
  521. $(2)_FINAL_PATCH_DEPENDENCIES = $$(sort $$($(2)_PATCH_DEPENDENCIES))
  522. $(2)_FINAL_ALL_DEPENDENCIES = \
  523. $$(sort \
  524. $$($(2)_FINAL_DEPENDENCIES) \
  525. $$($(2)_FINAL_EXTRACT_DEPENDENCIES) \
  526. $$($(2)_FINAL_PATCH_DEPENDENCIES))
  527. $(2)_INSTALL_STAGING ?= NO
  528. $(2)_INSTALL_IMAGES ?= NO
  529. $(2)_INSTALL_TARGET ?= YES
  530. # define sub-target stamps
  531. $(2)_TARGET_INSTALL_TARGET = $$($(2)_DIR)/.stamp_target_installed
  532. $(2)_TARGET_INSTALL_STAGING = $$($(2)_DIR)/.stamp_staging_installed
  533. $(2)_TARGET_INSTALL_IMAGES = $$($(2)_DIR)/.stamp_images_installed
  534. $(2)_TARGET_INSTALL_HOST = $$($(2)_DIR)/.stamp_host_installed
  535. $(2)_TARGET_BUILD = $$($(2)_DIR)/.stamp_built
  536. $(2)_TARGET_CONFIGURE = $$($(2)_DIR)/.stamp_configured
  537. $(2)_TARGET_RSYNC = $$($(2)_DIR)/.stamp_rsynced
  538. $(2)_TARGET_PATCH = $$($(2)_DIR)/.stamp_patched
  539. $(2)_TARGET_EXTRACT = $$($(2)_DIR)/.stamp_extracted
  540. $(2)_TARGET_SOURCE = $$($(2)_DIR)/.stamp_downloaded
  541. $(2)_TARGET_ACTUAL_SOURCE = $$($(2)_DIR)/.stamp_actual_downloaded
  542. $(2)_TARGET_DIRCLEAN = $$($(2)_DIR)/.stamp_dircleaned
  543. # default extract command
  544. $(2)_EXTRACT_CMDS ?= \
  545. $$(if $$($(2)_SOURCE),$$(INFLATE$$(suffix $$($(2)_SOURCE))) $$(DL_DIR)/$$($(2)_SOURCE) | \
  546. $$(TAR) --strip-components=$$($(2)_STRIP_COMPONENTS) \
  547. -C $$($(2)_DIR) \
  548. $$(foreach x,$$($(2)_EXCLUDES),--exclude='$$(x)' ) \
  549. $$(TAR_OPTIONS) -)
  550. # pre/post-steps hooks
  551. $(2)_PRE_DOWNLOAD_HOOKS ?=
  552. $(2)_POST_DOWNLOAD_HOOKS ?=
  553. $(2)_PRE_EXTRACT_HOOKS ?=
  554. $(2)_POST_EXTRACT_HOOKS ?=
  555. $(2)_PRE_RSYNC_HOOKS ?=
  556. $(2)_POST_RSYNC_HOOKS ?=
  557. $(2)_PRE_PATCH_HOOKS ?=
  558. $(2)_POST_PATCH_HOOKS ?=
  559. $(2)_PRE_CONFIGURE_HOOKS ?=
  560. $(2)_POST_CONFIGURE_HOOKS ?=
  561. $(2)_PRE_BUILD_HOOKS ?=
  562. $(2)_POST_BUILD_HOOKS ?=
  563. $(2)_PRE_INSTALL_HOOKS ?=
  564. $(2)_POST_INSTALL_HOOKS ?=
  565. $(2)_PRE_INSTALL_STAGING_HOOKS ?=
  566. $(2)_POST_INSTALL_STAGING_HOOKS ?=
  567. $(2)_PRE_INSTALL_TARGET_HOOKS ?=
  568. $(2)_POST_INSTALL_TARGET_HOOKS ?=
  569. $(2)_PRE_INSTALL_IMAGES_HOOKS ?=
  570. $(2)_POST_INSTALL_IMAGES_HOOKS ?=
  571. $(2)_PRE_LEGAL_INFO_HOOKS ?=
  572. $(2)_POST_LEGAL_INFO_HOOKS ?=
  573. $(2)_TARGET_FINALIZE_HOOKS ?=
  574. $(2)_ROOTFS_PRE_CMD_HOOKS ?=
  575. # human-friendly targets and target sequencing
  576. $(1): $(1)-install
  577. ifeq ($$($(2)_TYPE),host)
  578. $(1)-install: $(1)-install-host
  579. else
  580. $(1)-install: $(1)-install-staging $(1)-install-target $(1)-install-images
  581. endif
  582. ifeq ($$($(2)_INSTALL_TARGET),YES)
  583. $(1)-install-target: $$($(2)_TARGET_INSTALL_TARGET)
  584. $$($(2)_TARGET_INSTALL_TARGET): $$($(2)_TARGET_BUILD)
  585. else
  586. $(1)-install-target:
  587. endif
  588. ifeq ($$($(2)_INSTALL_STAGING),YES)
  589. $(1)-install-staging: $$($(2)_TARGET_INSTALL_STAGING)
  590. $$($(2)_TARGET_INSTALL_STAGING): $$($(2)_TARGET_BUILD)
  591. # Some packages use install-staging stuff for install-target
  592. $$($(2)_TARGET_INSTALL_TARGET): $$($(2)_TARGET_INSTALL_STAGING)
  593. else
  594. $(1)-install-staging:
  595. endif
  596. ifeq ($$($(2)_INSTALL_IMAGES),YES)
  597. $(1)-install-images: $$($(2)_TARGET_INSTALL_IMAGES)
  598. $$($(2)_TARGET_INSTALL_IMAGES): $$($(2)_TARGET_BUILD)
  599. else
  600. $(1)-install-images:
  601. endif
  602. $(1)-install-host: $$($(2)_TARGET_INSTALL_HOST)
  603. $$($(2)_TARGET_INSTALL_HOST): $$($(2)_TARGET_BUILD)
  604. $(1)-build: $$($(2)_TARGET_BUILD)
  605. $$($(2)_TARGET_BUILD): $$($(2)_TARGET_CONFIGURE)
  606. # Since $(2)_FINAL_DEPENDENCIES are phony targets, they are always "newer"
  607. # than $(2)_TARGET_CONFIGURE. This would force the configure step (and
  608. # therefore the other steps as well) to be re-executed with every
  609. # invocation of make. Therefore, make $(2)_FINAL_DEPENDENCIES an order-only
  610. # dependency by using |.
  611. $(1)-configure: $$($(2)_TARGET_CONFIGURE)
  612. $$($(2)_TARGET_CONFIGURE): | $$($(2)_FINAL_DEPENDENCIES)
  613. $$($(2)_TARGET_SOURCE) $$($(2)_TARGET_RSYNC): | dirs prepare
  614. $$($(2)_TARGET_SOURCE) $$($(2)_TARGET_RSYNC): | dependencies
  615. ifeq ($$($(2)_OVERRIDE_SRCDIR),)
  616. # In the normal case (no package override), the sequence of steps is
  617. # source, by downloading
  618. # depends
  619. # extract
  620. # patch
  621. # configure
  622. $$($(2)_TARGET_CONFIGURE): $$($(2)_TARGET_PATCH)
  623. $(1)-patch: $$($(2)_TARGET_PATCH)
  624. $$($(2)_TARGET_PATCH): $$($(2)_TARGET_EXTRACT)
  625. # Order-only dependency
  626. $$($(2)_TARGET_PATCH): | $$(patsubst %,%-patch,$$($(2)_FINAL_PATCH_DEPENDENCIES))
  627. $(1)-extract: $$($(2)_TARGET_EXTRACT)
  628. $$($(2)_TARGET_EXTRACT): $$($(2)_TARGET_SOURCE)
  629. $$($(2)_TARGET_EXTRACT): | $$($(2)_FINAL_EXTRACT_DEPENDENCIES)
  630. $(1)-depends: $$($(2)_FINAL_DEPENDENCIES)
  631. $(1)-source: $$($(2)_TARGET_SOURCE)
  632. $(1)-all-source: $(1)-legal-source
  633. $(1)-legal-info: $(1)-legal-source
  634. $(1)-legal-source: $(1)-source
  635. # Only download the actual source if it differs from the 'main' archive
  636. ifneq ($$($(2)_ACTUAL_SOURCE_TARBALL),)
  637. ifneq ($$($(2)_ACTUAL_SOURCE_TARBALL),$$($(2)_SOURCE))
  638. $(1)-legal-source: $$($(2)_TARGET_ACTUAL_SOURCE)
  639. endif # actual sources != sources
  640. endif # actual sources != ""
  641. $(1)-external-deps:
  642. @for p in $$($(2)_SOURCE) $$($(2)_PATCH) $$($(2)_EXTRA_DOWNLOADS) ; do \
  643. echo `basename $$$$p` ; \
  644. done
  645. else
  646. # In the package override case, the sequence of steps
  647. # source, by rsyncing
  648. # depends
  649. # configure
  650. # Use an order-only dependency so the "<pkg>-clean-for-rebuild" rule
  651. # can remove the stamp file without triggering the configure step.
  652. $$($(2)_TARGET_CONFIGURE): | $$($(2)_TARGET_RSYNC)
  653. $(1)-depends: $$($(2)_FINAL_DEPENDENCIES)
  654. $(1)-patch: $(1)-rsync
  655. $(1)-extract: $(1)-rsync
  656. $(1)-rsync: $$($(2)_TARGET_RSYNC)
  657. $(1)-source:
  658. $(1)-legal-source:
  659. $(1)-external-deps:
  660. @echo "file://$$($(2)_OVERRIDE_SRCDIR)"
  661. endif
  662. $(1)-show-version:
  663. @echo $$($(2)_VERSION)
  664. $(1)-show-depends:
  665. @echo $$($(2)_FINAL_ALL_DEPENDENCIES)
  666. $(1)-show-rdepends:
  667. @echo $$($(2)_RDEPENDENCIES)
  668. $(1)-show-build-order: $$(patsubst %,%-show-build-order,$$($(2)_FINAL_ALL_DEPENDENCIES))
  669. $$(info $(1))
  670. $(1)-graph-depends: graph-depends-requirements
  671. $(call pkg-graph-depends,$(1),--direct)
  672. $(1)-graph-rdepends: graph-depends-requirements
  673. $(call pkg-graph-depends,$(1),--reverse)
  674. $(1)-all-source: $(1)-source
  675. $(1)-all-source: $$(foreach p,$$($(2)_FINAL_ALL_DEPENDENCIES),$$(p)-all-source)
  676. $(1)-all-external-deps: $(1)-external-deps
  677. $(1)-all-external-deps: $$(foreach p,$$($(2)_FINAL_ALL_DEPENDENCIES),$$(p)-all-external-deps)
  678. $(1)-all-legal-info: $(1)-legal-info
  679. $(1)-all-legal-info: $$(foreach p,$$($(2)_FINAL_ALL_DEPENDENCIES),$$(p)-all-legal-info)
  680. $(1)-dirclean: $$($(2)_TARGET_DIRCLEAN)
  681. $(1)-clean-for-reinstall:
  682. ifneq ($$($(2)_OVERRIDE_SRCDIR),)
  683. rm -f $$($(2)_TARGET_RSYNC)
  684. endif
  685. rm -f $$($(2)_TARGET_INSTALL_STAGING)
  686. rm -f $$($(2)_TARGET_INSTALL_TARGET)
  687. rm -f $$($(2)_TARGET_INSTALL_IMAGES)
  688. rm -f $$($(2)_TARGET_INSTALL_HOST)
  689. $(1)-reinstall: $(1)-clean-for-reinstall $(1)
  690. $(1)-clean-for-rebuild: $(1)-clean-for-reinstall
  691. rm -f $$($(2)_TARGET_BUILD)
  692. $(1)-rebuild: $(1)-clean-for-rebuild $(1)
  693. $(1)-clean-for-reconfigure: $(1)-clean-for-rebuild
  694. rm -f $$($(2)_TARGET_CONFIGURE)
  695. $(1)-reconfigure: $(1)-clean-for-reconfigure $(1)
  696. # define the PKG variable for all targets, containing the
  697. # uppercase package variable prefix
  698. $$($(2)_TARGET_INSTALL_TARGET): PKG=$(2)
  699. $$($(2)_TARGET_INSTALL_STAGING): PKG=$(2)
  700. $$($(2)_TARGET_INSTALL_IMAGES): PKG=$(2)
  701. $$($(2)_TARGET_INSTALL_HOST): PKG=$(2)
  702. $$($(2)_TARGET_BUILD): PKG=$(2)
  703. $$($(2)_TARGET_CONFIGURE): PKG=$(2)
  704. $$($(2)_TARGET_RSYNC): SRCDIR=$$($(2)_OVERRIDE_SRCDIR)
  705. $$($(2)_TARGET_RSYNC): PKG=$(2)
  706. $$($(2)_TARGET_PATCH): PKG=$(2)
  707. $$($(2)_TARGET_PATCH): RAWNAME=$$(patsubst host-%,%,$(1))
  708. $$($(2)_TARGET_PATCH): PKGDIR=$(pkgdir)
  709. $$($(2)_TARGET_EXTRACT): PKG=$(2)
  710. $$($(2)_TARGET_SOURCE): PKG=$(2)
  711. $$($(2)_TARGET_SOURCE): PKGDIR=$(pkgdir)
  712. $$($(2)_TARGET_ACTUAL_SOURCE): PKG=$(2)
  713. $$($(2)_TARGET_ACTUAL_SOURCE): PKGDIR=$(pkgdir)
  714. $$($(2)_TARGET_DIRCLEAN): PKG=$(2)
  715. # Compute the name of the Kconfig option that correspond to the
  716. # package being enabled. We handle three cases: the special Linux
  717. # kernel case, the bootloaders case, and the normal packages case.
  718. ifeq ($(1),linux)
  719. $(2)_KCONFIG_VAR = BR2_LINUX_KERNEL
  720. else ifneq ($$(filter boot/% $$(foreach dir,$$(BR2_EXTERNAL_DIRS),$$(dir)/boot/%),$(pkgdir)),)
  721. $(2)_KCONFIG_VAR = BR2_TARGET_$(2)
  722. else ifneq ($$(filter toolchain/% $$(foreach dir,$$(BR2_EXTERNAL_DIRS),$$(dir)/toolchain/%),$(pkgdir)),)
  723. $(2)_KCONFIG_VAR = BR2_$(2)
  724. else
  725. $(2)_KCONFIG_VAR = BR2_PACKAGE_$(2)
  726. endif
  727. # legal-info: declare dependencies and set values used later for the manifest
  728. ifneq ($$($(2)_LICENSE_FILES),)
  729. $(2)_MANIFEST_LICENSE_FILES = $$($(2)_LICENSE_FILES)
  730. endif
  731. # We need to extract and patch a package to be able to retrieve its
  732. # license files (if any) and the list of patches applied to it (if
  733. # any).
  734. $(1)-legal-info: $(1)-patch
  735. # We only save the sources of packages we want to redistribute, that are
  736. # non-overriden (local or true override).
  737. ifeq ($$($(2)_REDISTRIBUTE),YES)
  738. ifeq ($$($(2)_OVERRIDE_SRCDIR),)
  739. # Packages that have a tarball need it downloaded beforehand
  740. $(1)-legal-info: $(1)-source $$(REDIST_SOURCES_DIR_$$(call UPPERCASE,$(4)))
  741. endif
  742. endif
  743. # legal-info: produce legally relevant info.
  744. $(1)-legal-info: PKG=$(2)
  745. $(1)-legal-info:
  746. @$$(call MESSAGE,"Collecting legal info")
  747. # Packages without a source are assumed to be part of Buildroot, skip them.
  748. $$(foreach hook,$$($(2)_PRE_LEGAL_INFO_HOOKS),$$(call $$(hook))$$(sep))
  749. ifneq ($$(call qstrip,$$($(2)_SOURCE)),)
  750. # Save license files if defined
  751. # We save the license files for any kind of package: normal, local,
  752. # overridden, or non-redistributable alike.
  753. # The reason to save license files even for no-redistribute packages
  754. # is that the license still applies to the files distributed as part
  755. # of the rootfs, even if the sources are not themselves redistributed.
  756. ifeq ($$(call qstrip,$$($(2)_LICENSE_FILES)),)
  757. $(Q)$$(call legal-warning-pkg,$$($(2)_BASENAME_RAW),cannot save license ($(2)_LICENSE_FILES not defined))
  758. else
  759. $(Q)$$(foreach F,$$($(2)_LICENSE_FILES),$$(call legal-license-file,$$($(2)_RAWNAME),$$($(2)_BASENAME_RAW),$$($(2)_PKGDIR),$$(F),$$($(2)_DIR)/$$(F),$$(call UPPERCASE,$(4)))$$(sep))
  760. endif # license files
  761. ifeq ($$($(2)_SITE_METHOD),local)
  762. # Packages without a tarball: don't save and warn
  763. @$$(call legal-warning-nosource,$$($(2)_RAWNAME),local)
  764. else ifneq ($$($(2)_OVERRIDE_SRCDIR),)
  765. @$$(call legal-warning-nosource,$$($(2)_RAWNAME),override)
  766. else
  767. # Other packages
  768. ifeq ($$($(2)_REDISTRIBUTE),YES)
  769. # Save the source tarball and any extra downloads, but not
  770. # patches, as they are handled specially afterwards.
  771. $$(foreach e,$$($(2)_ACTUAL_SOURCE_TARBALL) $$(notdir $$($(2)_EXTRA_DOWNLOADS)),\
  772. $$(Q)support/scripts/hardlink-or-copy \
  773. $$(DL_DIR)/$$(e) \
  774. $$($(2)_REDIST_SOURCES_DIR)$$(sep))
  775. # Save patches and generate the series file
  776. $$(Q)while read f; do \
  777. support/scripts/hardlink-or-copy \
  778. $$$${f} \
  779. $$($(2)_REDIST_SOURCES_DIR) || exit 1; \
  780. printf "%s\n" "$$$${f##*/}" >>$$($(2)_REDIST_SOURCES_DIR)/series || exit 1; \
  781. done <$$($(2)_DIR)/.applied_patches_list
  782. endif # redistribute
  783. endif # other packages
  784. @$$(call legal-manifest,$$($(2)_RAWNAME),$$($(2)_VERSION),$$($(2)_LICENSE),$$($(2)_MANIFEST_LICENSE_FILES),$$($(2)_ACTUAL_SOURCE_TARBALL),$$($(2)_ACTUAL_SOURCE_SITE),$$(call UPPERCASE,$(4)))
  785. endif # ifneq ($$(call qstrip,$$($(2)_SOURCE)),)
  786. $$(foreach hook,$$($(2)_POST_LEGAL_INFO_HOOKS),$$(call $$(hook))$$(sep))
  787. # add package to the general list of targets if requested by the buildroot
  788. # configuration
  789. ifeq ($$($$($(2)_KCONFIG_VAR)),y)
  790. # Ensure the calling package is the declared provider for all the virtual
  791. # packages it claims to be an implementation of.
  792. ifneq ($$($(2)_PROVIDES),)
  793. $$(foreach pkg,$$($(2)_PROVIDES),\
  794. $$(eval $$(call virt-provides-single,$$(pkg),$$(call UPPERCASE,$$(pkg)),$(1))$$(sep)))
  795. endif
  796. # Register package as a reverse-dependencies of all its dependencies
  797. $$(eval $$(foreach p,$$($(2)_FINAL_ALL_DEPENDENCIES),\
  798. $$(call UPPERCASE,$$(p))_RDEPENDENCIES += $(1)$$(sep)))
  799. # Ensure unified variable name conventions between all packages Some
  800. # of the variables are used by more than one infrastructure; so,
  801. # rather than duplicating the checks in each infrastructure, we check
  802. # all variables here in pkg-generic, even though pkg-generic should
  803. # have no knowledge of infra-specific variables.
  804. $(eval $(call check-deprecated-variable,$(2)_MAKE_OPT,$(2)_MAKE_OPTS))
  805. $(eval $(call check-deprecated-variable,$(2)_INSTALL_OPT,$(2)_INSTALL_OPTS))
  806. $(eval $(call check-deprecated-variable,$(2)_INSTALL_TARGET_OPT,$(2)_INSTALL_TARGET_OPTS))
  807. $(eval $(call check-deprecated-variable,$(2)_INSTALL_STAGING_OPT,$(2)_INSTALL_STAGING_OPTS))
  808. $(eval $(call check-deprecated-variable,$(2)_INSTALL_HOST_OPT,$(2)_INSTALL_HOST_OPTS))
  809. $(eval $(call check-deprecated-variable,$(2)_AUTORECONF_OPT,$(2)_AUTORECONF_OPTS))
  810. $(eval $(call check-deprecated-variable,$(2)_CONF_OPT,$(2)_CONF_OPTS))
  811. $(eval $(call check-deprecated-variable,$(2)_BUILD_OPT,$(2)_BUILD_OPTS))
  812. $(eval $(call check-deprecated-variable,$(2)_GETTEXTIZE_OPT,$(2)_GETTEXTIZE_OPTS))
  813. $(eval $(call check-deprecated-variable,$(2)_KCONFIG_OPT,$(2)_KCONFIG_OPTS))
  814. PACKAGES += $(1)
  815. ifneq ($$($(2)_PERMISSIONS),)
  816. PACKAGES_PERMISSIONS_TABLE += $$($(2)_PERMISSIONS)$$(sep)
  817. endif
  818. ifneq ($$($(2)_DEVICES),)
  819. PACKAGES_DEVICES_TABLE += $$($(2)_DEVICES)$$(sep)
  820. endif
  821. ifneq ($$($(2)_USERS),)
  822. PACKAGES_USERS += $$($(2)_USERS)$$(sep)
  823. endif
  824. TARGET_FINALIZE_HOOKS += $$($(2)_TARGET_FINALIZE_HOOKS)
  825. ROOTFS_PRE_CMD_HOOKS += $$($(2)_ROOTFS_PRE_CMD_HOOKS)
  826. ifeq ($$($(2)_SITE_METHOD),svn)
  827. DL_TOOLS_DEPENDENCIES += svn
  828. else ifeq ($$($(2)_SITE_METHOD),git)
  829. DL_TOOLS_DEPENDENCIES += git
  830. else ifeq ($$($(2)_SITE_METHOD),bzr)
  831. DL_TOOLS_DEPENDENCIES += bzr
  832. else ifeq ($$($(2)_SITE_METHOD),scp)
  833. DL_TOOLS_DEPENDENCIES += scp ssh
  834. else ifeq ($$($(2)_SITE_METHOD),hg)
  835. DL_TOOLS_DEPENDENCIES += hg
  836. else ifeq ($$($(2)_SITE_METHOD),cvs)
  837. DL_TOOLS_DEPENDENCIES += cvs
  838. endif # SITE_METHOD
  839. DL_TOOLS_DEPENDENCIES += $$(call extractor-dependency,$$($(2)_SOURCE))
  840. # Ensure all virtual targets are PHONY. Listed alphabetically.
  841. .PHONY: $(1) \
  842. $(1)-all-external-deps \
  843. $(1)-all-legal-info \
  844. $(1)-all-source \
  845. $(1)-build \
  846. $(1)-clean-for-rebuild \
  847. $(1)-clean-for-reconfigure \
  848. $(1)-clean-for-reinstall \
  849. $(1)-configure \
  850. $(1)-depends \
  851. $(1)-dirclean \
  852. $(1)-external-deps \
  853. $(1)-extract \
  854. $(1)-graph-depends \
  855. $(1)-install \
  856. $(1)-install-host \
  857. $(1)-install-images \
  858. $(1)-install-staging \
  859. $(1)-install-target \
  860. $(1)-legal-info \
  861. $(1)-legal-source \
  862. $(1)-patch \
  863. $(1)-rebuild \
  864. $(1)-reconfigure \
  865. $(1)-reinstall \
  866. $(1)-rsync \
  867. $(1)-show-depends \
  868. $(1)-show-version \
  869. $(1)-source
  870. ifneq ($$($(2)_SOURCE),)
  871. ifeq ($$($(2)_SITE),)
  872. $$(error $(2)_SITE cannot be empty when $(2)_SOURCE is not)
  873. endif
  874. endif
  875. ifeq ($$(patsubst %/,ERROR,$$($(2)_SITE)),ERROR)
  876. $$(error $(2)_SITE ($$($(2)_SITE)) cannot have a trailing slash)
  877. endif
  878. ifneq ($$($(2)_HELP_CMDS),)
  879. HELP_PACKAGES += $(2)
  880. endif
  881. endif # $(2)_KCONFIG_VAR
  882. endef # inner-generic-package
  883. ################################################################################
  884. # generic-package -- the target generator macro for generic packages
  885. ################################################################################
  886. # In the case of target packages, keep the package name "pkg"
  887. generic-package = $(call inner-generic-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target)
  888. # In the case of host packages, turn the package name "pkg" into "host-pkg"
  889. host-generic-package = $(call inner-generic-package,host-$(pkgname),$(call UPPERCASE,host-$(pkgname)),$(call UPPERCASE,$(pkgname)),host)
  890. # :mode=makefile: