pkg-generic.mk 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537
  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 informations 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. # Implicit targets -- produce a stamp file for each step of a package build
  24. ################################################################################
  25. # Retrieve the archive
  26. $(BUILD_DIR)/%/.stamp_downloaded:
  27. ifeq ($(DL_MODE),DOWNLOAD)
  28. # Only show the download message if it isn't already downloaded
  29. $(Q)(test -e $(DL_DIR)/$($(PKG)_SOURCE) && \
  30. (test -z $($(PKG)_PATCH) || test -e $(DL_DIR)$($(PKG)_PATCH))) || \
  31. $(call MESSAGE,"Downloading")
  32. endif
  33. $(if $($(PKG)_SOURCE),$(call DOWNLOAD,$($(PKG)_SITE)/$($(PKG)_SOURCE)))
  34. $(if $($(PKG)_PATCH),$(call DOWNLOAD,$($(PKG)_SITE)/$($(PKG)_PATCH)))
  35. $(foreach hook,$($(PKG)_POST_DOWNLOAD_HOOKS),$(call $(hook))$(sep))
  36. ifeq ($(DL_MODE),DOWNLOAD)
  37. $(Q)mkdir -p $(@D)
  38. $(Q)touch $@
  39. endif
  40. # Unpack the archive
  41. $(BUILD_DIR)/%/.stamp_extracted:
  42. @$(call MESSAGE,"Extracting")
  43. $(Q)mkdir -p $(@D)
  44. $($(PKG)_EXTRACT_CMDS)
  45. # some packages have messed up permissions inside
  46. $(Q)chmod -R +rw $(@D)
  47. $(foreach hook,$($(PKG)_POST_EXTRACT_HOOKS),$(call $(hook))$(sep))
  48. $(Q)touch $@
  49. # Rsync the source directory if the <pkg>_OVERRIDE_SRCDIR feature is
  50. # used.
  51. $(BUILD_DIR)/%/.stamp_rsynced:
  52. @$(call MESSAGE,"Syncing from source dir $(SRCDIR)")
  53. @test -d $(SRCDIR) || (echo "ERROR: $(SRCDIR) does not exist" ; exit 1)
  54. rsync -au $(SRCDIR)/ $(@D)
  55. $(Q)touch $@
  56. # Handle the SOURCE_CHECK and SHOW_EXTERNAL_DEPS cases for rsynced
  57. # packages
  58. $(BUILD_DIR)/%/.stamp_rsync_sourced:
  59. ifeq ($(DL_MODE),SOURCE_CHECK)
  60. test -d $(SRCDIR)
  61. else ifeq ($(DL_MODE),SHOW_EXTERNAL_DEPS)
  62. echo "file://$(SRCDIR)"
  63. else
  64. @true # Nothing to do to source a local package
  65. endif
  66. # Patch
  67. #
  68. # The RAWNAME variable is the lowercased package name, which allows to
  69. # find the package directory (typically package/<pkgname>) and the
  70. # prefix of the patches
  71. $(BUILD_DIR)/%/.stamp_patched: NAMEVER = $(RAWNAME)-$($(PKG)_VERSION)
  72. $(BUILD_DIR)/%/.stamp_patched:
  73. @$(call MESSAGE,"Patching $($(PKG)_DIR_PREFIX)/$(RAWNAME)")
  74. $(foreach hook,$($(PKG)_PRE_PATCH_HOOKS),$(call $(hook))$(sep))
  75. $(if $($(PKG)_PATCH),support/scripts/apply-patches.sh $(@D) $(DL_DIR) $($(PKG)_PATCH))
  76. $(Q)( \
  77. if test -d $($(PKG)_DIR_PREFIX)/$(RAWNAME); then \
  78. if test "$(wildcard $($(PKG)_DIR_PREFIX)/$(RAWNAME)/$(NAMEVER)*.patch*)"; then \
  79. support/scripts/apply-patches.sh $(@D) $($(PKG)_DIR_PREFIX)/$(RAWNAME) $(NAMEVER)\*.patch $(NAMEVER)\*.patch.$(ARCH) || exit 1; \
  80. else \
  81. support/scripts/apply-patches.sh $(@D) $($(PKG)_DIR_PREFIX)/$(RAWNAME) $(RAWNAME)\*.patch $(RAWNAME)\*.patch.$(ARCH) || exit 1; \
  82. if test -d $($(PKG)_DIR_PREFIX)/$(RAWNAME)/$(NAMEVER); then \
  83. support/scripts/apply-patches.sh $(@D) $($(PKG)_DIR_PREFIX)/$(RAWNAME)/$(NAMEVER) \*.patch \*.patch.$(ARCH) || exit 1; \
  84. fi; \
  85. fi; \
  86. fi; \
  87. )
  88. $(foreach hook,$($(PKG)_POST_PATCH_HOOKS),$(call $(hook))$(sep))
  89. $(Q)touch $@
  90. # Configure
  91. $(BUILD_DIR)/%/.stamp_configured:
  92. $(foreach hook,$($(PKG)_PRE_CONFIGURE_HOOKS),$(call $(hook))$(sep))
  93. @$(call MESSAGE,"Configuring")
  94. $($(PKG)_CONFIGURE_CMDS)
  95. $(foreach hook,$($(PKG)_POST_CONFIGURE_HOOKS),$(call $(hook))$(sep))
  96. $(Q)touch $@
  97. # Build
  98. $(BUILD_DIR)/%/.stamp_built::
  99. @$(call MESSAGE,"Building")
  100. $($(PKG)_BUILD_CMDS)
  101. $(foreach hook,$($(PKG)_POST_BUILD_HOOKS),$(call $(hook))$(sep))
  102. $(Q)touch $@
  103. # Install to host dir
  104. $(BUILD_DIR)/%/.stamp_host_installed:
  105. @$(call MESSAGE,"Installing to host directory")
  106. $($(PKG)_INSTALL_CMDS)
  107. $(foreach hook,$($(PKG)_POST_INSTALL_HOOKS),$(call $(hook))$(sep))
  108. $(Q)touch $@
  109. # Install to staging dir
  110. $(BUILD_DIR)/%/.stamp_staging_installed:
  111. @$(call MESSAGE,"Installing to staging directory")
  112. $($(PKG)_INSTALL_STAGING_CMDS)
  113. $(foreach hook,$($(PKG)_POST_INSTALL_STAGING_HOOKS),$(call $(hook))$(sep))
  114. $(Q)touch $@
  115. # Install to images dir
  116. $(BUILD_DIR)/%/.stamp_images_installed:
  117. @$(call MESSAGE,"Installing to images directory")
  118. $($(PKG)_INSTALL_IMAGES_CMDS)
  119. $(foreach hook,$($(PKG)_POST_INSTALL_IMAGES_HOOKS),$(call $(hook))$(sep))
  120. $(Q)touch $@
  121. # Install to target dir
  122. $(BUILD_DIR)/%/.stamp_target_installed:
  123. @$(call MESSAGE,"Installing to target")
  124. $(if $(BR2_INIT_SYSTEMD),\
  125. $($(PKG)_INSTALL_INIT_SYSTEMD))
  126. $(if $(BR2_INIT_SYSV)$(BR2_INIT_BUSYBOX),\
  127. $($(PKG)_INSTALL_INIT_SYSV))
  128. $($(PKG)_INSTALL_TARGET_CMDS)
  129. $(foreach hook,$($(PKG)_POST_INSTALL_TARGET_HOOKS),$(call $(hook))$(sep))
  130. $(Q)touch $@
  131. # Clean package
  132. $(BUILD_DIR)/%/.stamp_cleaned:
  133. @$(call MESSAGE,"Cleaning up")
  134. $($(PKG)_CLEAN_CMDS)
  135. rm -f $(@D)/.stamp_built
  136. # Uninstall package from target and staging
  137. # Uninstall commands tend to fail, so remove the stamp files first
  138. $(BUILD_DIR)/%/.stamp_uninstalled:
  139. @$(call MESSAGE,"Uninstalling")
  140. rm -f $($(PKG)_TARGET_INSTALL_STAGING)
  141. rm -f $($(PKG)_TARGET_INSTALL_TARGET)
  142. $($(PKG)_UNINSTALL_STAGING_CMDS)
  143. $($(PKG)_UNINSTALL_TARGET_CMDS)
  144. $(if $(BR2_INIT_SYSTEMD),\
  145. $($(PKG)_UNINSTALL_INIT_SYSTEMD))
  146. $(if $(BR2_INIT_SYSV)$(BR2_INIT_BUSYBOX),\
  147. $($(PKG)_UNINSTALL_INIT_SYSV))
  148. # Remove package sources
  149. $(BUILD_DIR)/%/.stamp_dircleaned:
  150. rm -Rf $(@D)
  151. ################################################################################
  152. # inner-generic-package -- generates the make targets needed to build a
  153. # generic package
  154. #
  155. # argument 1 is the lowercase package name
  156. # argument 2 is the uppercase package name, including an HOST_ prefix
  157. # for host packages
  158. # argument 3 is the uppercase package name, without the HOST_ prefix
  159. # for host packages
  160. # argument 4 is the package directory prefix
  161. # argument 5 is the type (target or host)
  162. ################################################################################
  163. define inner-generic-package
  164. # Define default values for various package-related variables, if not
  165. # already defined. For some variables (version, source, site and
  166. # subdir), if they are undefined, we try to see if a variable without
  167. # the HOST_ prefix is defined. If so, we use such a variable, so that
  168. # these informations have only to be specified once, for both the
  169. # target and host packages of a given .mk file.
  170. $(2)_TYPE = $(5)
  171. $(2)_NAME = $(1)
  172. $(2)_RAWNAME = $(patsubst host-%,%,$(1))
  173. # Keep the package version that may contain forward slashes in the _DL_VERSION
  174. # variable, then replace all forward slashes ('/') by underscores ('_') to
  175. # sanitize the package version that is used in paths, directory and file names.
  176. # Forward slashes may appear in the package's version when pointing to a
  177. # version control system branch or tag, for example remotes/origin/1_10_stable.
  178. ifndef $(2)_VERSION
  179. ifdef $(3)_VERSION
  180. $(2)_DL_VERSION = $($(3)_VERSION)
  181. $(2)_VERSION = $(subst /,_,$($(3)_VERSION))
  182. else
  183. $(2)_VERSION = undefined
  184. $(2)_DL_VERSION = undefined
  185. endif
  186. else
  187. $(2)_DL_VERSION = $($(2)_VERSION)
  188. $(2)_VERSION = $(subst /,_,$($(2)_VERSION))
  189. endif
  190. $(2)_BASE_NAME = $(1)-$$($(2)_VERSION)
  191. $(2)_DL_DIR = $$(DL_DIR)/$$($(2)_BASE_NAME)
  192. $(2)_DIR = $$(BUILD_DIR)/$$($(2)_BASE_NAME)
  193. ifndef $(2)_SUBDIR
  194. ifdef $(3)_SUBDIR
  195. $(2)_SUBDIR = $$($(3)_SUBDIR)
  196. else
  197. $(2)_SUBDIR ?=
  198. endif
  199. endif
  200. $(2)_SRCDIR = $$($(2)_DIR)/$$($(2)_SUBDIR)
  201. $(2)_BUILDDIR ?= $$($(2)_SRCDIR)
  202. ifneq ($$($(2)_OVERRIDE_SRCDIR),)
  203. $(2)_VERSION = custom
  204. endif
  205. ifndef $(2)_SOURCE
  206. ifdef $(3)_SOURCE
  207. $(2)_SOURCE = $($(3)_SOURCE)
  208. else
  209. $(2)_SOURCE ?= $$($(2)_RAWNAME)-$$($(2)_VERSION).tar.gz
  210. endif
  211. endif
  212. ifndef $(2)_PATCH
  213. ifdef $(3)_PATCH
  214. $(2)_PATCH = $($(3)_PATCH)
  215. endif
  216. endif
  217. ifndef $(2)_SITE
  218. ifdef $(3)_SITE
  219. $(2)_SITE = $($(3)_SITE)
  220. endif
  221. endif
  222. ifndef $(2)_SITE_METHOD
  223. ifdef $(3)_SITE_METHOD
  224. $(2)_SITE_METHOD = $($(3)_SITE_METHOD)
  225. else
  226. # Try automatic detection using the scheme part of the URI
  227. $(2)_SITE_METHOD = $(firstword $(subst ://, ,$(call qstrip,$($(2)_SITE))))
  228. endif
  229. endif
  230. ifeq ($$($(2)_SITE_METHOD),local)
  231. ifeq ($$($(2)_OVERRIDE_SRCDIR),)
  232. $(2)_OVERRIDE_SRCDIR = $($(2)_SITE)
  233. endif
  234. endif
  235. ifndef $(2)_LICENSE
  236. ifdef $(3)_LICENSE
  237. $(2)_LICENSE = $($(3)_LICENSE)
  238. endif
  239. endif
  240. $(2)_LICENSE ?= unknown
  241. ifndef $(2)_LICENSE_FILES
  242. ifdef $(3)_LICENSE_FILES
  243. $(2)_LICENSE_FILES = $($(3)_LICENSE_FILES)
  244. endif
  245. endif
  246. ifndef $(2)_REDISTRIBUTE
  247. ifdef $(3)_REDISTRIBUTE
  248. $(2)_REDISTRIBUTE = $($(3)_REDISTRIBUTE)
  249. endif
  250. endif
  251. $(2)_REDISTRIBUTE ?= YES
  252. $(2)_DEPENDENCIES ?= $(filter-out $(1),$(patsubst host-host-%,host-%,$(addprefix host-,$($(3)_DEPENDENCIES))))
  253. $(2)_INSTALL_STAGING ?= NO
  254. $(2)_INSTALL_IMAGES ?= NO
  255. $(2)_INSTALL_TARGET ?= YES
  256. $(2)_DIR_PREFIX = $(if $(4),$(4),$(TOP_SRCDIR)/package)
  257. # define sub-target stamps
  258. $(2)_TARGET_INSTALL_TARGET = $$($(2)_DIR)/.stamp_target_installed
  259. $(2)_TARGET_INSTALL_STAGING = $$($(2)_DIR)/.stamp_staging_installed
  260. $(2)_TARGET_INSTALL_IMAGES = $$($(2)_DIR)/.stamp_images_installed
  261. $(2)_TARGET_INSTALL_HOST = $$($(2)_DIR)/.stamp_host_installed
  262. $(2)_TARGET_BUILD = $$($(2)_DIR)/.stamp_built
  263. $(2)_TARGET_CONFIGURE = $$($(2)_DIR)/.stamp_configured
  264. $(2)_TARGET_RSYNC = $$($(2)_DIR)/.stamp_rsynced
  265. $(2)_TARGET_RSYNC_SOURCE = $$($(2)_DIR)/.stamp_rsync_sourced
  266. $(2)_TARGET_PATCH = $$($(2)_DIR)/.stamp_patched
  267. $(2)_TARGET_EXTRACT = $$($(2)_DIR)/.stamp_extracted
  268. $(2)_TARGET_SOURCE = $$($(2)_DIR)/.stamp_downloaded
  269. $(2)_TARGET_UNINSTALL = $$($(2)_DIR)/.stamp_uninstalled
  270. $(2)_TARGET_CLEAN = $$($(2)_DIR)/.stamp_cleaned
  271. $(2)_TARGET_DIRCLEAN = $$($(2)_DIR)/.stamp_dircleaned
  272. # default extract command
  273. $(2)_EXTRACT_CMDS ?= \
  274. $$(if $$($(2)_SOURCE),$$(INFLATE$$(suffix $$($(2)_SOURCE))) $(DL_DIR)/$$($(2)_SOURCE) | \
  275. $(TAR) $(TAR_STRIP_COMPONENTS)=1 -C $$($(2)_DIR) $(TAR_OPTIONS) -)
  276. # post-steps hooks
  277. $(2)_POST_DOWNLOAD_HOOKS ?=
  278. $(2)_POST_EXTRACT_HOOKS ?=
  279. $(2)_PRE_PATCH_HOOKS ?=
  280. $(2)_POST_PATCH_HOOKS ?=
  281. $(2)_PRE_CONFIGURE_HOOKS ?=
  282. $(2)_POST_CONFIGURE_HOOKS ?=
  283. $(2)_POST_BUILD_HOOKS ?=
  284. $(2)_POST_INSTALL_HOOKS ?=
  285. $(2)_POST_INSTALL_STAGING_HOOKS ?=
  286. $(2)_POST_INSTALL_TARGET_HOOKS ?=
  287. $(2)_POST_INSTALL_IMAGES_HOOKS ?=
  288. $(2)_POST_LEGAL_INFO_HOOKS ?=
  289. # human-friendly targets and target sequencing
  290. $(1): $(1)-install
  291. ifeq ($$($(2)_TYPE),host)
  292. $(1)-install: $(1)-install-host
  293. else
  294. $(1)-install: $(1)-install-staging $(1)-install-target $(1)-install-images
  295. endif
  296. ifeq ($$($(2)_INSTALL_TARGET),YES)
  297. $(1)-install-target: $(1)-build \
  298. $$($(2)_TARGET_INSTALL_TARGET)
  299. else
  300. $(1)-install-target:
  301. endif
  302. ifeq ($$($(2)_INSTALL_STAGING),YES)
  303. $(1)-install-staging: $(1)-build \
  304. $$($(2)_TARGET_INSTALL_STAGING)
  305. else
  306. $(1)-install-staging:
  307. endif
  308. ifeq ($$($(2)_INSTALL_IMAGES),YES)
  309. $(1)-install-images: $(1)-build \
  310. $$($(2)_TARGET_INSTALL_IMAGES)
  311. else
  312. $(1)-install-images:
  313. endif
  314. $(1)-install-host: $(1)-build $$($(2)_TARGET_INSTALL_HOST)
  315. $(1)-build: $(1)-configure \
  316. $$($(2)_TARGET_BUILD)
  317. ifeq ($$($(2)_OVERRIDE_SRCDIR),)
  318. # In the normal case (no package override), the sequence of steps is
  319. # source, by downloading
  320. # depends
  321. # extract
  322. # patch
  323. # configure
  324. $(1)-configure: $(1)-patch $(1)-depends \
  325. $$($(2)_TARGET_CONFIGURE)
  326. $(1)-patch: $(1)-extract $$($(2)_TARGET_PATCH)
  327. $(1)-extract: $(1)-source \
  328. $$($(2)_TARGET_EXTRACT)
  329. $(1)-depends: $$($(2)_DEPENDENCIES)
  330. $(1)-source: $$($(2)_TARGET_SOURCE)
  331. else
  332. # In the package override case, the sequence of steps
  333. # source, by rsyncing
  334. # depends
  335. # configure
  336. $(1)-configure: $(1)-depends \
  337. $$($(2)_TARGET_CONFIGURE)
  338. $(1)-depends: $(1)-rsync $$($(2)_DEPENDENCIES)
  339. $(1)-rsync: $$($(2)_TARGET_RSYNC)
  340. $(1)-source: $$($(2)_TARGET_RSYNC_SOURCE)
  341. endif
  342. $(1)-show-depends:
  343. @echo $$($(2)_DEPENDENCIES)
  344. $(1)-uninstall: $(1)-configure $$($(2)_TARGET_UNINSTALL)
  345. $(1)-clean: $(1)-uninstall \
  346. $$($(2)_TARGET_CLEAN)
  347. $(1)-dirclean: $$($(2)_TARGET_DIRCLEAN)
  348. $(1)-clean-for-rebuild:
  349. ifneq ($$($(2)_OVERRIDE_SRCDIR),)
  350. rm -f $$($(2)_TARGET_RSYNC)
  351. endif
  352. rm -f $$($(2)_TARGET_BUILD)
  353. rm -f $$($(2)_TARGET_INSTALL_STAGING)
  354. rm -f $$($(2)_TARGET_INSTALL_TARGET)
  355. rm -f $$($(2)_TARGET_INSTALL_IMAGES)
  356. rm -f $$($(2)_TARGET_INSTALL_HOST)
  357. $(1)-rebuild: $(1)-clean-for-rebuild all
  358. $(1)-clean-for-reconfigure: $(1)-clean-for-rebuild
  359. rm -f $$($(2)_TARGET_CONFIGURE)
  360. $(1)-reconfigure: $(1)-clean-for-reconfigure all
  361. # define the PKG variable for all targets, containing the
  362. # uppercase package variable prefix
  363. $$($(2)_TARGET_INSTALL_TARGET): PKG=$(2)
  364. $$($(2)_TARGET_INSTALL_STAGING): PKG=$(2)
  365. $$($(2)_TARGET_INSTALL_IMAGES): PKG=$(2)
  366. $$($(2)_TARGET_INSTALL_HOST): PKG=$(2)
  367. $$($(2)_TARGET_BUILD): PKG=$(2)
  368. $$($(2)_TARGET_CONFIGURE): PKG=$(2)
  369. $$($(2)_TARGET_RSYNC): SRCDIR=$$($(2)_OVERRIDE_SRCDIR)
  370. $$($(2)_TARGET_RSYNC): PKG=$(2)
  371. $$($(2)_TARGET_RSYNC_SOURCE): SRCDIR=$$($(2)_OVERRIDE_SRCDIR)
  372. $$($(2)_TARGET_RSYNC_SOURCE): PKG=$(2)
  373. $$($(2)_TARGET_PATCH): PKG=$(2)
  374. $$($(2)_TARGET_PATCH): RAWNAME=$(patsubst host-%,%,$(1))
  375. $$($(2)_TARGET_EXTRACT): PKG=$(2)
  376. $$($(2)_TARGET_SOURCE): PKG=$(2)
  377. $$($(2)_TARGET_UNINSTALL): PKG=$(2)
  378. $$($(2)_TARGET_CLEAN): PKG=$(2)
  379. $$($(2)_TARGET_DIRCLEAN): PKG=$(2)
  380. # Compute the name of the Kconfig option that correspond to the
  381. # package being enabled. We handle three cases: the special Linux
  382. # kernel case, the bootloaders case, and the normal packages case.
  383. ifeq ($(1),linux)
  384. $(2)_KCONFIG_VAR = BR2_LINUX_KERNEL
  385. else ifeq ($(4),boot/)
  386. $(2)_KCONFIG_VAR = BR2_TARGET_$(2)
  387. else
  388. $(2)_KCONFIG_VAR = BR2_PACKAGE_$(2)
  389. endif
  390. # legal-info: declare dependencies and set values used later for the manifest
  391. ifneq ($$($(2)_LICENSE_FILES),)
  392. $(2)_MANIFEST_LICENSE_FILES = $$($(2)_LICENSE_FILES)
  393. endif
  394. $(2)_MANIFEST_LICENSE_FILES ?= not saved
  395. ifeq ($$($(2)_REDISTRIBUTE),YES)
  396. ifneq ($$($(2)_SITE_METHOD),local)
  397. ifneq ($$($(2)_SITE_METHOD),override)
  398. # Packages that have a tarball need it downloaded and extracted beforehand
  399. $(1)-legal-info: $(1)-extract $(REDIST_SOURCES_DIR)
  400. $(2)_MANIFEST_TARBALL = $$($(2)_SOURCE)
  401. endif
  402. endif
  403. endif
  404. $(2)_MANIFEST_TARBALL ?= not saved
  405. # legal-info: produce legally relevant info.
  406. $(1)-legal-info:
  407. # Packages without a source are assumed to be part of Buildroot, skip them.
  408. ifneq ($(call qstrip,$$($(2)_SOURCE)),)
  409. ifeq ($$($(2)_SITE_METHOD),local)
  410. # Packages without a tarball: don't save and warn
  411. @$(call legal-warning-pkg-savednothing,$$($(2)_RAWNAME),local)
  412. else ifeq ($$($(2)_SITE_METHOD),override)
  413. @$(call legal-warning-pkg-savednothing,$$($(2)_RAWNAME),override)
  414. else
  415. # Other packages
  416. # Save license files if defined
  417. ifeq ($(call qstrip,$$($(2)_LICENSE_FILES)),)
  418. @$(call legal-license-nofiles,$$($(2)_RAWNAME))
  419. @$(call legal-warning-pkg,$$($(2)_RAWNAME),cannot save license ($(2)_LICENSE_FILES not defined))
  420. else
  421. @for F in $$($(2)_LICENSE_FILES); do \
  422. $(call legal-license-file,$$($(2)_RAWNAME),$$$${F},$$($(2)_DIR)/$$$${F}); \
  423. done
  424. endif
  425. ifeq ($$($(2)_REDISTRIBUTE),YES)
  426. # Copy the source tarball (just hardlink if possible)
  427. @cp -l $(DL_DIR)/$$($(2)_SOURCE) $(REDIST_SOURCES_DIR) 2>/dev/null || \
  428. cp $(DL_DIR)/$$($(2)_SOURCE) $(REDIST_SOURCES_DIR)
  429. endif
  430. endif
  431. @$(call legal-manifest,$$($(2)_RAWNAME),$$($(2)_VERSION),$$($(2)_LICENSE),$$($(2)_MANIFEST_LICENSE_FILES),$$($(2)_MANIFEST_TARBALL))
  432. endif # ifneq ($(call qstrip,$$($(2)_SOURCE)),)
  433. $(foreach hook,$($(2)_POST_LEGAL_INFO_HOOKS),$(call $(hook))$(sep))
  434. # add package to the general list of targets if requested by the buildroot
  435. # configuration
  436. ifeq ($$($$($(2)_KCONFIG_VAR)),y)
  437. TARGETS += $(1)
  438. PACKAGES_PERMISSIONS_TABLE += $$($(2)_PERMISSIONS)$$(sep)
  439. PACKAGES_DEVICES_TABLE += $$($(2)_DEVICES)$$(sep)
  440. ifeq ($$($(2)_SITE_METHOD),svn)
  441. DL_TOOLS_DEPENDENCIES += svn
  442. else ifeq ($$($(2)_SITE_METHOD),git)
  443. DL_TOOLS_DEPENDENCIES += git
  444. else ifeq ($$($(2)_SITE_METHOD),bzr)
  445. DL_TOOLS_DEPENDENCIES += bzr
  446. else ifeq ($$($(2)_SITE_METHOD),scp)
  447. DL_TOOLS_DEPENDENCIES += scp ssh
  448. else ifeq ($$($(2)_SITE_METHOD),hg)
  449. DL_TOOLS_DEPENDENCIES += hg
  450. endif # SITE_METHOD
  451. DL_TOOLS_DEPENDENCIES += $(firstword $(INFLATE$(suffix $($(2)_SOURCE))))
  452. endif # $(2)_KCONFIG_VAR
  453. endef # inner-generic-package
  454. ################################################################################
  455. # generic-package -- the target generator macro for generic packages
  456. ################################################################################
  457. # In the case of target packages, keep the package name "pkg"
  458. generic-package = $(call inner-generic-package,$(call pkgname),$(call UPPERCASE,$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),target)
  459. # In the case of host packages, turn the package name "pkg" into "host-pkg"
  460. host-generic-package = $(call inner-generic-package,host-$(call pkgname),$(call UPPERCASE,host-$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),host)
  461. # :mode=makefile: