pkg-generic.mk 33 KB

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