PageRenderTime 2053ms CodeModel.GetById 29ms RepoModel.GetById 0ms app.codeStats 1ms

/package/pkg-generic.mk

https://gitlab.com/arnout/buildroot
Makefile | 1300 lines | 866 code | 168 blank | 266 comment | 28 complexity | a250d911fcfeaa05fbb5529e1966a6fa MD5 | raw file
  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.%N)" "$(1)" "$(2)" "$(3)" \
  48. >>"$(BUILD_DIR)/build-time.log"
  49. endef
  50. GLOBAL_INSTRUMENTATION_HOOKS += step_time
  51. # This hook checks that host packages that need libraries that we build
  52. # have a proper DT_RPATH or DT_RUNPATH tag
  53. define check_host_rpath
  54. $(if $(filter install-host,$(2)),\
  55. $(if $(filter end,$(1)),support/scripts/check-host-rpath $(3) $(HOST_DIR) $(PER_PACKAGE_DIR)))
  56. endef
  57. GLOBAL_INSTRUMENTATION_HOOKS += check_host_rpath
  58. define step_check_build_dir_one
  59. if [ -d $(2) ]; then \
  60. printf "%s: installs files in %s\n" $(1) $(2) >&2; \
  61. exit 1; \
  62. fi
  63. endef
  64. define step_check_build_dir
  65. $(if $(filter install-staging,$(2)),\
  66. $(if $(filter end,$(1)),$(call step_check_build_dir_one,$(3),$(STAGING_DIR)/$(O))))
  67. $(if $(filter install-target,$(2)),\
  68. $(if $(filter end,$(1)),$(call step_check_build_dir_one,$(3),$(TARGET_DIR)/$(O))))
  69. endef
  70. GLOBAL_INSTRUMENTATION_HOOKS += step_check_build_dir
  71. # User-supplied script
  72. ifneq ($(BR2_INSTRUMENTATION_SCRIPTS),)
  73. define step_user
  74. @$(foreach user_hook, $(BR2_INSTRUMENTATION_SCRIPTS), \
  75. $(EXTRA_ENV) $(user_hook) "$(1)" "$(2)" "$(3)"$(sep))
  76. endef
  77. GLOBAL_INSTRUMENTATION_HOOKS += step_user
  78. endif
  79. #######################################
  80. # Helper functions
  81. # Make sure .la files only reference the current per-package
  82. # directory.
  83. # $1: package name (lower case)
  84. # $2: staging directory of the package
  85. ifeq ($(BR2_PER_PACKAGE_DIRECTORIES),y)
  86. define fixup-libtool-files
  87. $(Q)find $(2) \( -path '$(2)/lib*' -o -path '$(2)/usr/lib*' \) \
  88. -name "*.la" -print0 | xargs -0 --no-run-if-empty \
  89. $(SED) "s:$(PER_PACKAGE_DIR)/[^/]\+/:$(PER_PACKAGE_DIR)/$(1)/:g"
  90. endef
  91. endif
  92. # Make sure python _sysconfigdata*.py files only reference the current
  93. # per-package directory.
  94. #
  95. # Can't use $(foreach d, $(HOST_DIR)/lib/python* $(STAGING_DIR)/usr/lib/python*, ...)
  96. # because those directories may be created in the same recipe this macro will
  97. # be expanded in.
  98. # Additionally, either or both may be missing, which would make find whine and
  99. # fail.
  100. # So we just use HOST_DIR as a starting point, and filter on the two directories
  101. # of interest.
  102. ifeq ($(BR2_PER_PACKAGE_DIRECTORIES),y)
  103. define FIXUP_PYTHON_SYSCONFIGDATA
  104. $(Q)find $(HOST_DIR) \
  105. \( -path '$(HOST_DIR)/lib/python*' \
  106. -o -path '$(STAGING_DIR)/usr/lib/python*' \
  107. \) \
  108. \( \( -name "_sysconfigdata*.pyc" -delete \) \
  109. -o \( -name "_sysconfigdata*.py" -print0 \) \
  110. \) \
  111. | xargs -0 --no-run-if-empty \
  112. $(SED) 's:$(PER_PACKAGE_DIR)/[^/]\+/:$(PER_PACKAGE_DIR)/$($(PKG)_NAME)/:g'
  113. endef
  114. endif
  115. # Functions to collect statistics about installed files
  116. # $(1): base directory to search in
  117. # $(2): suffix of file (optional)
  118. define pkg_size_before
  119. cd $(1); \
  120. LC_ALL=C find . -not -path './$(STAGING_SUBDIR)/*' \( -type f -o -type l \) -printf '%T@:%i:%#m:%y:%s,%p\n' \
  121. | LC_ALL=C sort > $($(PKG)_DIR)/.files-list$(2).before
  122. endef
  123. # $(1): base directory to search in
  124. # $(2): suffix of file (optional)
  125. define pkg_size_after
  126. cd $(1); \
  127. LC_ALL=C find . -not -path './$(STAGING_SUBDIR)/*' \( -type f -o -type l \) -printf '%T@:%i:%#m:%y:%s,%p\n' \
  128. | LC_ALL=C sort > $($(PKG)_DIR)/.files-list$(2).after
  129. LC_ALL=C comm -13 \
  130. $($(PKG)_DIR)/.files-list$(2).before \
  131. $($(PKG)_DIR)/.files-list$(2).after \
  132. | sed -r -e 's/^[^,]+/$($(PKG)_NAME)/' \
  133. > $($(PKG)_DIR)/.files-list$(2).txt
  134. rm -f $($(PKG)_DIR)/.files-list$(2).before
  135. rm -f $($(PKG)_DIR)/.files-list$(2).after
  136. endef
  137. define check_bin_arch
  138. support/scripts/check-bin-arch -p $($(PKG)_NAME) \
  139. -l $($(PKG)_DIR)/.files-list.txt \
  140. $(foreach i,$($(PKG)_BIN_ARCH_EXCLUDE),-i "$(i)") \
  141. -r $(TARGET_READELF) \
  142. -a $(BR2_READELF_ARCH_NAME)
  143. endef
  144. # Functions to remove conflicting and useless files
  145. # $1: base directory (target, staging, host)
  146. define remove-conflicting-useless-files
  147. $(if $(strip $($(PKG)_DROP_FILES_OR_DIRS)),
  148. $(Q)$(RM) -rf $(patsubst %, $(1)%, $($(PKG)_DROP_FILES_OR_DIRS)))
  149. endef
  150. define REMOVE_CONFLICTING_USELESS_FILES_IN_HOST
  151. $(call remove-conflicting-useless-files,$(HOST_DIR))
  152. endef
  153. define REMOVE_CONFLICTING_USELESS_FILES_IN_STAGING
  154. $(call remove-conflicting-useless-files,$(STAGING_DIR))
  155. endef
  156. define REMOVE_CONFLICTING_USELESS_FILES_IN_TARGET
  157. $(call remove-conflicting-useless-files,$(TARGET_DIR))
  158. endef
  159. ################################################################################
  160. # Implicit targets -- produce a stamp file for each step of a package build
  161. ################################################################################
  162. # Retrieve the archive
  163. $(BUILD_DIR)/%/.stamp_downloaded:
  164. @$(call step_start,download)
  165. $(call prepare-per-package-directory,$($(PKG)_FINAL_DOWNLOAD_DEPENDENCIES))
  166. $(foreach hook,$($(PKG)_PRE_DOWNLOAD_HOOKS),$(call $(hook))$(sep))
  167. # Only show the download message if it isn't already downloaded
  168. $(Q)for p in $($(PKG)_ALL_DOWNLOADS); do \
  169. if test ! -e $($(PKG)_DL_DIR)/`basename $$p` ; then \
  170. $(call MESSAGE,"Downloading") ; \
  171. break ; \
  172. fi ; \
  173. done
  174. $(foreach p,$($(PKG)_ALL_DOWNLOADS),$(call DOWNLOAD,$(p),$(PKG))$(sep))
  175. $(foreach hook,$($(PKG)_POST_DOWNLOAD_HOOKS),$(call $(hook))$(sep))
  176. $(Q)mkdir -p $(@D)
  177. @$(call step_end,download)
  178. $(Q)touch $@
  179. # Retrieve actual source archive, e.g. for prebuilt external toolchains
  180. $(BUILD_DIR)/%/.stamp_actual_downloaded:
  181. @$(call step_start,actual-download)
  182. $(call DOWNLOAD,$($(PKG)_ACTUAL_SOURCE_SITE)/$($(PKG)_ACTUAL_SOURCE_TARBALL),$(PKG))
  183. $(Q)mkdir -p $(@D)
  184. @$(call step_end,actual-download)
  185. $(Q)touch $@
  186. # Unpack the archive
  187. $(BUILD_DIR)/%/.stamp_extracted:
  188. @$(call step_start,extract)
  189. @$(call MESSAGE,"Extracting")
  190. $(call prepare-per-package-directory,$($(PKG)_FINAL_EXTRACT_DEPENDENCIES))
  191. $(foreach hook,$($(PKG)_PRE_EXTRACT_HOOKS),$(call $(hook))$(sep))
  192. $(Q)mkdir -p $(@D)
  193. $($(PKG)_EXTRACT_CMDS)
  194. # some packages have messed up permissions inside
  195. $(Q)chmod -R +rw $(@D)
  196. $(foreach hook,$($(PKG)_POST_EXTRACT_HOOKS),$(call $(hook))$(sep))
  197. @$(call step_end,extract)
  198. $(Q)touch $@
  199. # Rsync the source directory if the <pkg>_OVERRIDE_SRCDIR feature is
  200. # used.
  201. $(BUILD_DIR)/%/.stamp_rsynced:
  202. @$(call step_start,rsync)
  203. @$(call MESSAGE,"Syncing from source dir $(SRCDIR)")
  204. @mkdir -p $(@D)
  205. $(foreach hook,$($(PKG)_PRE_RSYNC_HOOKS),$(call $(hook))$(sep))
  206. @test -d $(SRCDIR) || (echo "ERROR: $(SRCDIR) does not exist" ; exit 1)
  207. rsync -au --chmod=u=rwX,go=rX $($(PKG)_OVERRIDE_SRCDIR_RSYNC_EXCLUSIONS) $(RSYNC_VCS_EXCLUSIONS) $(call qstrip,$(SRCDIR))/ $(@D)
  208. $(foreach hook,$($(PKG)_POST_RSYNC_HOOKS),$(call $(hook))$(sep))
  209. @$(call step_end,rsync)
  210. $(Q)touch $@
  211. # Patch
  212. #
  213. # The RAWNAME variable is the lowercased package name, which allows to
  214. # find the package directory (typically package/<pkgname>) and the
  215. # prefix of the patches
  216. #
  217. # For BR2_GLOBAL_PATCH_DIR, only generate if it is defined
  218. $(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_DIRS = $(PKGDIR)
  219. $(BUILD_DIR)/%/.stamp_patched: PATCH_BASE_DIRS += $(addsuffix /$(RAWNAME),$(call qstrip,$(BR2_GLOBAL_PATCH_DIR)))
  220. $(BUILD_DIR)/%/.stamp_patched:
  221. @$(call step_start,patch)
  222. @$(call MESSAGE,"Patching")
  223. $(foreach hook,$($(PKG)_PRE_PATCH_HOOKS),$(call $(hook))$(sep))
  224. $(foreach p,$($(PKG)_PATCH),$(APPLY_PATCHES) $(@D) $($(PKG)_DL_DIR) $(notdir $(p))$(sep))
  225. $(Q)( \
  226. for D in $(PATCH_BASE_DIRS); do \
  227. if test -d $${D}; then \
  228. if test -d $${D}/$($(PKG)_VERSION); then \
  229. $(APPLY_PATCHES) $(@D) $${D}/$($(PKG)_VERSION) \*.patch \*.patch.$(ARCH) || exit 1; \
  230. else \
  231. $(APPLY_PATCHES) $(@D) $${D} \*.patch \*.patch.$(ARCH) || exit 1; \
  232. fi; \
  233. fi; \
  234. done; \
  235. )
  236. $(foreach hook,$($(PKG)_POST_PATCH_HOOKS),$(call $(hook))$(sep))
  237. @$(call step_end,patch)
  238. $(Q)touch $@
  239. # Check that all directories specified in BR2_GLOBAL_PATCH_DIR exist.
  240. $(foreach dir,$(call qstrip,$(BR2_GLOBAL_PATCH_DIR)),\
  241. $(if $(wildcard $(dir)),,\
  242. $(error BR2_GLOBAL_PATCH_DIR contains nonexistent directory $(dir))))
  243. # Configure
  244. $(BUILD_DIR)/%/.stamp_configured:
  245. @$(call step_start,configure)
  246. @$(call MESSAGE,"Configuring")
  247. $(Q)mkdir -p $(HOST_DIR) $(TARGET_DIR) $(STAGING_DIR) $(BINARIES_DIR)
  248. $(call prepare-per-package-directory,$($(PKG)_FINAL_DEPENDENCIES))
  249. @$(call pkg_size_before,$(TARGET_DIR))
  250. @$(call pkg_size_before,$(STAGING_DIR),-staging)
  251. @$(call pkg_size_before,$(BINARIES_DIR),-images)
  252. @$(call pkg_size_before,$(HOST_DIR),-host)
  253. $(call fixup-libtool-files,$(NAME),$(HOST_DIR))
  254. $(call fixup-libtool-files,$(NAME),$(STAGING_DIR))
  255. $(foreach hook,$($(PKG)_POST_PREPARE_HOOKS),$(call $(hook))$(sep))
  256. $(foreach hook,$($(PKG)_PRE_CONFIGURE_HOOKS),$(call $(hook))$(sep))
  257. $($(PKG)_CONFIGURE_CMDS)
  258. $(foreach hook,$($(PKG)_POST_CONFIGURE_HOOKS),$(call $(hook))$(sep))
  259. @$(call step_end,configure)
  260. $(Q)touch $@
  261. # Build
  262. $(BUILD_DIR)/%/.stamp_built::
  263. @$(call step_start,build)
  264. @$(call MESSAGE,"Building")
  265. $(foreach hook,$($(PKG)_PRE_BUILD_HOOKS),$(call $(hook))$(sep))
  266. +$($(PKG)_BUILD_CMDS)
  267. $(foreach hook,$($(PKG)_POST_BUILD_HOOKS),$(call $(hook))$(sep))
  268. @$(call step_end,build)
  269. $(Q)touch $@
  270. # Install to host dir
  271. $(BUILD_DIR)/%/.stamp_host_installed:
  272. @$(call step_start,install-host)
  273. @$(call MESSAGE,"Installing to host directory")
  274. $(foreach hook,$($(PKG)_PRE_INSTALL_HOOKS),$(call $(hook))$(sep))
  275. +$($(PKG)_INSTALL_CMDS)
  276. $(foreach hook,$($(PKG)_POST_INSTALL_HOOKS),$(call $(hook))$(sep))
  277. @$(call step_end,install-host)
  278. $(Q)touch $@
  279. # Install to staging dir
  280. #
  281. # Some packages install libtool .la files alongside any installed
  282. # libraries. These .la files sometimes refer to paths relative to the
  283. # sysroot, which libtool will interpret as absolute paths to host
  284. # libraries instead of the target libraries. Since this is not what we
  285. # want, these paths are fixed by prefixing them with $(STAGING_DIR).
  286. # As we configure with --prefix=/usr, this fix needs to be applied to
  287. # any path that starts with /usr.
  288. #
  289. # To protect against the case that the output or staging directories or
  290. # the pre-installed external toolchain themselves are under /usr, we first
  291. # substitute away any occurrences of these directories with @BASE_DIR@,
  292. # @STAGING_DIR@ and @TOOLCHAIN_EXTERNAL_INSTALL_DIR@ respectively.
  293. #
  294. # Note that STAGING_DIR can be outside BASE_DIR when the user sets
  295. # BR2_HOST_DIR to a custom value. Note that TOOLCHAIN_EXTERNAL_INSTALL_DIR
  296. # can be under @BASE_DIR@ when it's a downloaded toolchain, and can be
  297. # empty when we use an internal toolchain.
  298. #
  299. $(BUILD_DIR)/%/.stamp_staging_installed:
  300. @$(call step_start,install-staging)
  301. @$(call MESSAGE,"Installing to staging directory")
  302. $(foreach hook,$($(PKG)_PRE_INSTALL_STAGING_HOOKS),$(call $(hook))$(sep))
  303. +$($(PKG)_INSTALL_STAGING_CMDS)
  304. $(foreach hook,$($(PKG)_POST_INSTALL_STAGING_HOOKS),$(call $(hook))$(sep))
  305. $(Q)if test -n "$($(PKG)_CONFIG_SCRIPTS)" ; then \
  306. $(call MESSAGE,"Fixing package configuration files") ;\
  307. $(SED) "s,$(HOST_DIR),@HOST_DIR@,g" \
  308. -e "s,$(BASE_DIR),@BASE_DIR@,g" \
  309. -e "s,^\(exec_\)\?prefix=.*,\1prefix=@STAGING_DIR@/usr,g" \
  310. -e "s,-I/usr/,-I@STAGING_DIR@/usr/,g" \
  311. -e "s,-L/usr/,-L@STAGING_DIR@/usr/,g" \
  312. -e 's,@STAGING_DIR@,$$(dirname $$(readlink -e $$0))/../..,g' \
  313. -e 's,@HOST_DIR@,$$(dirname $$(readlink -e $$0))/../../../..,g' \
  314. -e "s,@BASE_DIR@,$(BASE_DIR),g" \
  315. $(addprefix $(STAGING_DIR)/usr/bin/,$($(PKG)_CONFIG_SCRIPTS)) ;\
  316. fi
  317. @$(call MESSAGE,"Fixing libtool files")
  318. for la in $$(find $(STAGING_DIR)/usr/lib* -name "*.la"); do \
  319. cp -a "$${la}" "$${la}.fixed" && \
  320. $(SED) "s:$(BASE_DIR):@BASE_DIR@:g" \
  321. -e "s:$(STAGING_DIR):@STAGING_DIR@:g" \
  322. $(if $(TOOLCHAIN_EXTERNAL_INSTALL_DIR),\
  323. -e "s:$(TOOLCHAIN_EXTERNAL_INSTALL_DIR):@TOOLCHAIN_EXTERNAL_INSTALL_DIR@:g") \
  324. -e "s:\(['= ]\)/usr:\\1@STAGING_DIR@/usr:g" \
  325. -e "s:\(['= ]\)/lib:\\1@STAGING_DIR@/lib:g" \
  326. $(if $(TOOLCHAIN_EXTERNAL_INSTALL_DIR),\
  327. -e "s:@TOOLCHAIN_EXTERNAL_INSTALL_DIR@:$(TOOLCHAIN_EXTERNAL_INSTALL_DIR):g") \
  328. -e "s:@STAGING_DIR@:$(STAGING_DIR):g" \
  329. -e "s:@BASE_DIR@:$(BASE_DIR):g" \
  330. "$${la}.fixed" && \
  331. if cmp -s "$${la}" "$${la}.fixed"; then \
  332. rm -f "$${la}.fixed"; \
  333. else \
  334. mv "$${la}.fixed" "$${la}"; \
  335. fi || exit 1; \
  336. done
  337. @$(call step_end,install-staging)
  338. $(Q)touch $@
  339. # Install to images dir
  340. $(BUILD_DIR)/%/.stamp_images_installed:
  341. @$(call step_start,install-image)
  342. @$(call MESSAGE,"Installing to images directory")
  343. $(foreach hook,$($(PKG)_PRE_INSTALL_IMAGES_HOOKS),$(call $(hook))$(sep))
  344. +$($(PKG)_INSTALL_IMAGES_CMDS)
  345. $(foreach hook,$($(PKG)_POST_INSTALL_IMAGES_HOOKS),$(call $(hook))$(sep))
  346. @$(call step_end,install-image)
  347. $(Q)touch $@
  348. # Install to target dir
  349. $(BUILD_DIR)/%/.stamp_target_installed:
  350. @$(call step_start,install-target)
  351. @$(call MESSAGE,"Installing to target")
  352. $(foreach hook,$($(PKG)_PRE_INSTALL_TARGET_HOOKS),$(call $(hook))$(sep))
  353. +$($(PKG)_INSTALL_TARGET_CMDS)
  354. $(if $(BR2_INIT_SYSTEMD),\
  355. $($(PKG)_INSTALL_INIT_SYSTEMD))
  356. $(if $(BR2_INIT_SYSV)$(BR2_INIT_BUSYBOX),\
  357. $($(PKG)_INSTALL_INIT_SYSV))
  358. $(if $(BR2_INIT_OPENRC), \
  359. $(or $($(PKG)_INSTALL_INIT_OPENRC), \
  360. $($(PKG)_INSTALL_INIT_SYSV)))
  361. $(foreach hook,$($(PKG)_POST_INSTALL_TARGET_HOOKS),$(call $(hook))$(sep))
  362. $(Q)if test -n "$($(PKG)_CONFIG_SCRIPTS)" ; then \
  363. $(RM) -f $(addprefix $(TARGET_DIR)/usr/bin/,$($(PKG)_CONFIG_SCRIPTS)) ; \
  364. fi
  365. @$(call step_end,install-target)
  366. $(Q)touch $@
  367. # Final installation step, completed when all installation steps
  368. # (host, images, staging, target) have completed
  369. $(BUILD_DIR)/%/.stamp_installed:
  370. @$(call pkg_size_after,$(TARGET_DIR))
  371. @$(call pkg_size_after,$(STAGING_DIR),-staging)
  372. @$(call pkg_size_after,$(BINARIES_DIR),-images)
  373. @$(call pkg_size_after,$(HOST_DIR),-host)
  374. @$(call check_bin_arch)
  375. $(Q)touch $@
  376. # Remove package sources
  377. $(BUILD_DIR)/%/.stamp_dircleaned:
  378. $(if $(BR2_PER_PACKAGE_DIRECTORIES),rm -Rf $(PER_PACKAGE_DIR)/$(NAME))
  379. rm -Rf $(@D)
  380. ################################################################################
  381. # virt-provides-single -- check that provider-pkg is the declared provider for
  382. # the virtual package virt-pkg
  383. #
  384. # argument 1 is the lower-case name of the virtual package
  385. # argument 2 is the upper-case name of the virtual package
  386. # argument 3 is the lower-case name of the provider
  387. #
  388. # example:
  389. # $(call virt-provides-single,libegl,LIBEGL,rpi-userland)
  390. ################################################################################
  391. define virt-provides-single
  392. ifneq ($$(call qstrip,$$(BR2_PACKAGE_PROVIDES_$(2))),$(3))
  393. $$(error Configuration error: both "$(3)" and $$(BR2_PACKAGE_PROVIDES_$(2))\
  394. are selected as providers for virtual package "$(1)". Only one provider can\
  395. be selected at a time. Please fix your configuration)
  396. endif
  397. endef
  398. define pkg-graph-depends
  399. @$$(INSTALL) -d $$(GRAPHS_DIR)
  400. @cd "$$(CONFIG_DIR)"; \
  401. $$(TOPDIR)/support/scripts/graph-depends $$(BR2_GRAPH_DEPS_OPTS) \
  402. -p $(1) $(2) -o $$(GRAPHS_DIR)/$$(@).dot
  403. dot $$(BR2_GRAPH_DOT_OPTS) -T$$(BR_GRAPH_OUT) \
  404. -o $$(GRAPHS_DIR)/$$(@).$$(BR_GRAPH_OUT) \
  405. $$(GRAPHS_DIR)/$$(@).dot
  406. endef
  407. ################################################################################
  408. # inner-generic-package -- generates the make targets needed to build a
  409. # generic package
  410. #
  411. # argument 1 is the lowercase package name
  412. # argument 2 is the uppercase package name, including a HOST_ prefix
  413. # for host packages
  414. # argument 3 is the uppercase package name, without the HOST_ prefix
  415. # for host packages
  416. # argument 4 is the type (target or host)
  417. #
  418. # Note about variable and function references: inside all blocks that are
  419. # evaluated with $(eval), which includes all 'inner-xxx-package' blocks,
  420. # specific rules apply with respect to variable and function references.
  421. # - Numbered variables (parameters to the block) can be referenced with a single
  422. # dollar sign: $(1), $(2), $(3), etc.
  423. # - pkgdir and pkgname should be referenced with a single dollar sign too. These
  424. # functions rely on 'the most recently parsed makefile' which is supposed to
  425. # be the package .mk file. If we defer the evaluation of these functions using
  426. # double dollar signs, then they may be evaluated too late, when other
  427. # makefiles have already been parsed. One specific case is when $$(pkgdir) is
  428. # assigned to a variable using deferred evaluation with '=' and this variable
  429. # is used in a target rule outside the eval'ed inner block. In this case, the
  430. # pkgdir will be that of the last makefile parsed by buildroot, which is not
  431. # the expected value. This mechanism is for example used for the TARGET_PATCH
  432. # rule.
  433. # - All other variables should be referenced with a double dollar sign:
  434. # $$(TARGET_DIR), $$($(2)_VERSION), etc. Also all make functions should be
  435. # referenced with a double dollar sign: $$(subst), $$(call), $$(filter-out),
  436. # etc. This rule ensures that these variables and functions are only expanded
  437. # during the $(eval) step, and not earlier. Otherwise, unintuitive and
  438. # undesired behavior occurs with respect to these variables and functions.
  439. #
  440. ################################################################################
  441. define inner-generic-package
  442. # When doing a package, we're definitely not doing a rootfs, but we
  443. # may inherit it via the dependency chain, so we reset it.
  444. $(1): ROOTFS=
  445. # Ensure the package is only declared once, i.e. do not accept that a
  446. # package be re-defined by a br2-external tree
  447. ifneq ($(call strip,$(filter $(1),$(PACKAGES_ALL))),)
  448. $$(error Package '$(1)' defined a second time in '$(pkgdir)'; \
  449. previous definition was in '$$($(2)_PKGDIR)')
  450. endif
  451. PACKAGES_ALL += $(1)
  452. # Define default values for various package-related variables, if not
  453. # already defined. For some variables (version, source, site and
  454. # subdir), if they are undefined, we try to see if a variable without
  455. # the HOST_ prefix is defined. If so, we use such a variable, so that
  456. # this information has only to be specified once, for both the
  457. # target and host packages of a given .mk file.
  458. $(2)_TYPE = $(4)
  459. $(2)_NAME = $(1)
  460. $(2)_RAWNAME = $$(patsubst host-%,%,$(1))
  461. $(2)_PKGDIR = $(pkgdir)
  462. # Keep the package version that may contain forward slashes in the _DL_VERSION
  463. # variable, then replace all forward slashes ('/') by underscores ('_') to
  464. # sanitize the package version that is used in paths, directory and file names.
  465. # Forward slashes may appear in the package's version when pointing to a
  466. # version control system branch or tag, for example remotes/origin/1_10_stable.
  467. # Similar for spaces and colons (:) that may appear in date-based revisions for
  468. # CVS.
  469. ifndef $(2)_VERSION
  470. ifdef $(3)_DL_VERSION
  471. $(2)_DL_VERSION := $$($(3)_DL_VERSION)
  472. else ifdef $(3)_VERSION
  473. $(2)_DL_VERSION := $$($(3)_VERSION)
  474. endif
  475. else
  476. $(2)_DL_VERSION := $$(strip $$($(2)_VERSION))
  477. endif
  478. $(2)_VERSION := $$(call sanitize,$$($(2)_DL_VERSION))
  479. $(2)_HASH_FILE = \
  480. $$(strip \
  481. $$(if $$(wildcard $$($(2)_PKGDIR)/$$($(2)_VERSION)/$$($(2)_RAWNAME).hash),\
  482. $$($(2)_PKGDIR)/$$($(2)_VERSION)/$$($(2)_RAWNAME).hash,\
  483. $$($(2)_PKGDIR)/$$($(2)_RAWNAME).hash))
  484. ifdef $(3)_OVERRIDE_SRCDIR
  485. $(2)_OVERRIDE_SRCDIR ?= $$($(3)_OVERRIDE_SRCDIR)
  486. endif
  487. $(2)_BASENAME = $$(if $$($(2)_VERSION),$(1)-$$($(2)_VERSION),$(1))
  488. $(2)_BASENAME_RAW = $$(if $$($(2)_VERSION),$$($(2)_RAWNAME)-$$($(2)_VERSION),$$($(2)_RAWNAME))
  489. $(2)_DL_SUBDIR ?= $$($(2)_RAWNAME)
  490. $(2)_DL_DIR = $$(DL_DIR)/$$($(2)_DL_SUBDIR)
  491. $(2)_DIR = $$(BUILD_DIR)/$$($(2)_BASENAME)
  492. ifndef $(2)_SUBDIR
  493. ifdef $(3)_SUBDIR
  494. $(2)_SUBDIR = $$($(3)_SUBDIR)
  495. endif
  496. endif
  497. ifndef $(2)_STRIP_COMPONENTS
  498. ifdef $(3)_STRIP_COMPONENTS
  499. $(2)_STRIP_COMPONENTS = $$($(3)_STRIP_COMPONENTS)
  500. else
  501. $(2)_STRIP_COMPONENTS ?= 1
  502. endif
  503. endif
  504. $(2)_SRCDIR = $$($(2)_DIR)/$$($(2)_SUBDIR)
  505. $(2)_BUILDDIR ?= $$($(2)_SRCDIR)
  506. ifneq ($$($(2)_OVERRIDE_SRCDIR),)
  507. $(2)_VERSION = custom
  508. endif
  509. ifndef $(2)_SOURCE
  510. ifdef $(3)_SOURCE
  511. $(2)_SOURCE = $$($(3)_SOURCE)
  512. else ifdef $(2)_VERSION
  513. $(2)_SOURCE ?= $$($(2)_BASENAME_RAW)$$(call pkg_source_ext,$(2))
  514. endif
  515. endif
  516. # If FOO_ACTUAL_SOURCE_TARBALL is explicitly defined, it means FOO_SOURCE is
  517. # indeed a binary (e.g. external toolchain) and FOO_ACTUAL_SOURCE_TARBALL/_SITE
  518. # point to the actual sources tarball. Use the actual sources for legal-info.
  519. # For most packages the FOO_SITE/FOO_SOURCE pair points to real source code,
  520. # so these are the defaults for FOO_ACTUAL_*.
  521. $(2)_ACTUAL_SOURCE_TARBALL ?= $$($(2)_SOURCE)
  522. $(2)_ACTUAL_SOURCE_SITE ?= $$(call qstrip,$$($(2)_SITE))
  523. ifndef $(2)_PATCH
  524. ifdef $(3)_PATCH
  525. $(2)_PATCH = $$($(3)_PATCH)
  526. endif
  527. endif
  528. $(2)_ALL_DOWNLOADS = \
  529. $$(if $$($(2)_SOURCE),$$($(2)_SITE_METHOD)+$$($(2)_SITE)/$$($(2)_SOURCE)) \
  530. $$(foreach p,$$($(2)_PATCH) $$($(2)_EXTRA_DOWNLOADS),\
  531. $$(if $$(findstring ://,$$(p)),$$(p),\
  532. $$($(2)_SITE_METHOD)+$$($(2)_SITE)/$$(p)))
  533. ifndef $(2)_SITE
  534. ifdef $(3)_SITE
  535. $(2)_SITE = $$($(3)_SITE)
  536. endif
  537. endif
  538. ifndef $(2)_SITE_METHOD
  539. ifdef $(3)_SITE_METHOD
  540. $(2)_SITE_METHOD = $$($(3)_SITE_METHOD)
  541. else
  542. # Try automatic detection using the scheme part of the URI
  543. $(2)_SITE_METHOD = $$(call geturischeme,$$($(2)_SITE))
  544. endif
  545. endif
  546. ifndef $(2)_DL_OPTS
  547. ifdef $(3)_DL_OPTS
  548. $(2)_DL_OPTS = $$($(3)_DL_OPTS)
  549. endif
  550. endif
  551. ifneq ($$(filter bzr cvs hg,$$($(2)_SITE_METHOD)),)
  552. BR_NO_CHECK_HASH_FOR += $$($(2)_SOURCE)
  553. endif
  554. ifndef $(2)_GIT_SUBMODULES
  555. ifdef $(3)_GIT_SUBMODULES
  556. $(2)_GIT_SUBMODULES = $$($(3)_GIT_SUBMODULES)
  557. endif
  558. endif
  559. # Do not accept to download git submodule if not using the git method
  560. ifneq ($$($(2)_GIT_SUBMODULES),)
  561. ifneq ($$($(2)_SITE_METHOD),git)
  562. $$(error $(2) declares having git sub-modules, but does not use the \
  563. 'git' method (uses '$$($(2)_SITE_METHOD)' instead))
  564. endif
  565. endif
  566. ifeq ($$($(2)_SITE_METHOD),local)
  567. ifeq ($$($(2)_OVERRIDE_SRCDIR),)
  568. $(2)_OVERRIDE_SRCDIR = $$($(2)_SITE)
  569. endif
  570. ifeq ($$($(2)_OVERRIDE_SRCDIR),)
  571. $$(error $(1) has local site method, but `$(2)_SITE` is not defined)
  572. endif
  573. endif
  574. ifndef $(2)_LICENSE
  575. ifdef $(3)_LICENSE
  576. $(2)_LICENSE = $$($(3)_LICENSE)
  577. endif
  578. endif
  579. $(2)_LICENSE ?= unknown
  580. ifndef $(2)_LICENSE_FILES
  581. ifdef $(3)_LICENSE_FILES
  582. $(2)_LICENSE_FILES = $$($(3)_LICENSE_FILES)
  583. endif
  584. endif
  585. ifndef $(2)_REDISTRIBUTE
  586. ifdef $(3)_REDISTRIBUTE
  587. $(2)_REDISTRIBUTE = $$($(3)_REDISTRIBUTE)
  588. endif
  589. endif
  590. $(2)_REDISTRIBUTE ?= YES
  591. $(2)_REDIST_SOURCES_DIR = $$(REDIST_SOURCES_DIR_$$(call UPPERCASE,$(4)))/$$($(2)_BASENAME_RAW)
  592. # If any of the <pkg>_CPE_ID_* variables are set, we assume the CPE ID
  593. # information is valid for this package.
  594. ifneq ($$($(2)_CPE_ID_VENDOR)$$($(2)_CPE_ID_PRODUCT)$$($(2)_CPE_ID_VERSION)$$($(2)_CPE_ID_UPDATE)$$($(2)_CPE_ID_PREFIX),)
  595. $(2)_CPE_ID_VALID = YES
  596. endif
  597. # When we're a host package, make sure to use the variables of the
  598. # corresponding target package, if any.
  599. ifneq ($$($(3)_CPE_ID_VENDOR)$$($(3)_CPE_ID_PRODUCT)$$($(3)_CPE_ID_VERSION)$$($(3)_CPE_ID_UPDATE)$$($(3)_CPE_ID_PREFIX),)
  600. $(2)_CPE_ID_VALID = YES
  601. endif
  602. # If the CPE ID is valid for the target package so it is for the host
  603. # package
  604. ifndef $(2)_CPE_ID_VALID
  605. ifdef $(3)_CPE_ID_VALID
  606. $(2)_CPE_ID_VALID = $$($(3)_CPE_ID_VALID)
  607. endif
  608. endif
  609. ifeq ($$($(2)_CPE_ID_VALID),YES)
  610. # CPE_ID_VENDOR
  611. ifndef $(2)_CPE_ID_VENDOR
  612. ifdef $(3)_CPE_ID_VENDOR
  613. $(2)_CPE_ID_VENDOR = $$($(3)_CPE_ID_VENDOR)
  614. else
  615. $(2)_CPE_ID_VENDOR = $$($(2)_RAWNAME)_project
  616. endif
  617. endif
  618. # CPE_ID_PRODUCT
  619. ifndef $(2)_CPE_ID_PRODUCT
  620. ifdef $(3)_CPE_ID_PRODUCT
  621. $(2)_CPE_ID_PRODUCT = $$($(3)_CPE_ID_PRODUCT)
  622. else
  623. $(2)_CPE_ID_PRODUCT = $$($(2)_RAWNAME)
  624. endif
  625. endif
  626. # CPE_ID_VERSION
  627. ifndef $(2)_CPE_ID_VERSION
  628. ifdef $(3)_CPE_ID_VERSION
  629. $(2)_CPE_ID_VERSION = $$($(3)_CPE_ID_VERSION)
  630. else
  631. $(2)_CPE_ID_VERSION = $$($(2)_VERSION)
  632. endif
  633. endif
  634. # CPE_ID_UPDATE
  635. ifndef $(2)_CPE_ID_UPDATE
  636. ifdef $(3)_CPE_ID_UPDATE
  637. $(2)_CPE_ID_UPDATE = $$($(3)_CPE_ID_UPDATE)
  638. else
  639. $(2)_CPE_ID_UPDATE = *
  640. endif
  641. endif
  642. # CPE_ID_PREFIX
  643. ifndef $(2)_CPE_ID_PREFIX
  644. ifdef $(3)_CPE_ID_PREFIX
  645. $(2)_CPE_ID_PREFIX = $$($(3)_CPE_ID_PREFIX)
  646. else
  647. $(2)_CPE_ID_PREFIX = cpe:2.3:a
  648. endif
  649. endif
  650. # Calculate complete CPE ID
  651. $(2)_CPE_ID = $$($(2)_CPE_ID_PREFIX):$$($(2)_CPE_ID_VENDOR):$$($(2)_CPE_ID_PRODUCT):$$($(2)_CPE_ID_VERSION):$$($(2)_CPE_ID_UPDATE):*:*:*:*:*:*
  652. endif # ifeq ($$($(2)_CPE_ID_VALID),YES)
  653. # When a target package is a toolchain dependency set this variable to
  654. # 'NO' so the 'toolchain' dependency is not added to prevent a circular
  655. # dependency.
  656. # Similarly for the skeleton.
  657. $(2)_ADD_TOOLCHAIN_DEPENDENCY ?= YES
  658. $(2)_ADD_SKELETON_DEPENDENCY ?= YES
  659. ifeq ($(4),target)
  660. ifeq ($$($(2)_ADD_SKELETON_DEPENDENCY),YES)
  661. $(2)_DEPENDENCIES += skeleton
  662. endif
  663. ifeq ($$($(2)_ADD_TOOLCHAIN_DEPENDENCY),YES)
  664. $(2)_DEPENDENCIES += toolchain
  665. endif
  666. endif
  667. ifneq ($(1),host-skeleton)
  668. $(2)_DEPENDENCIES += host-skeleton
  669. endif
  670. ifneq ($$(filter cvs git svn,$$($(2)_SITE_METHOD)),)
  671. $(2)_DOWNLOAD_DEPENDENCIES += \
  672. $(BR2_GZIP_HOST_DEPENDENCY) \
  673. $(BR2_TAR_HOST_DEPENDENCY)
  674. endif
  675. ifeq ($$(filter host-tar host-skeleton host-fakedate,$(1)),)
  676. $(2)_EXTRACT_DEPENDENCIES += $$(BR2_TAR_HOST_DEPENDENCY)
  677. endif
  678. ifeq ($$(filter host-tar host-skeleton host-xz host-lzip host-fakedate,$(1)),)
  679. $(2)_EXTRACT_DEPENDENCIES += \
  680. $$(foreach dl,$$($(2)_ALL_DOWNLOADS),\
  681. $$(call extractor-pkg-dependency,$$(notdir $$(dl))))
  682. endif
  683. ifeq ($$(BR2_CCACHE),y)
  684. ifeq ($$(filter host-tar host-skeleton host-xz host-lzip host-fakedate host-ccache,$(1)),)
  685. $(2)_DEPENDENCIES += host-ccache
  686. endif
  687. endif
  688. ifeq ($$(BR2_REPRODUCIBLE),y)
  689. ifeq ($$(filter host-skeleton host-fakedate,$(1)),)
  690. $(2)_DEPENDENCIES += host-fakedate
  691. endif
  692. endif
  693. # Eliminate duplicates in dependencies
  694. $(2)_FINAL_DEPENDENCIES = $$(sort $$($(2)_DEPENDENCIES))
  695. $(2)_FINAL_DOWNLOAD_DEPENDENCIES = $$(sort $$($(2)_DOWNLOAD_DEPENDENCIES))
  696. $(2)_FINAL_EXTRACT_DEPENDENCIES = $$(sort $$($(2)_EXTRACT_DEPENDENCIES))
  697. $(2)_FINAL_PATCH_DEPENDENCIES = $$(sort $$($(2)_PATCH_DEPENDENCIES))
  698. $(2)_FINAL_ALL_DEPENDENCIES = \
  699. $$(sort \
  700. $$($(2)_FINAL_DEPENDENCIES) \
  701. $$($(2)_FINAL_DOWNLOAD_DEPENDENCIES) \
  702. $$($(2)_FINAL_EXTRACT_DEPENDENCIES) \
  703. $$($(2)_FINAL_PATCH_DEPENDENCIES))
  704. $(2)_FINAL_RECURSIVE_DEPENDENCIES = $$(sort \
  705. $$(if $$(filter undefined,$$(origin $(2)_FINAL_RECURSIVE_DEPENDENCIES__X)), \
  706. $$(eval $(2)_FINAL_RECURSIVE_DEPENDENCIES__X := \
  707. $$(foreach p, \
  708. $$($(2)_FINAL_ALL_DEPENDENCIES), \
  709. $$(p) \
  710. $$($$(call UPPERCASE,$$(p))_FINAL_RECURSIVE_DEPENDENCIES) \
  711. ) \
  712. ) \
  713. ) \
  714. $$($(2)_FINAL_RECURSIVE_DEPENDENCIES__X))
  715. $(2)_FINAL_RECURSIVE_RDEPENDENCIES = $$(sort \
  716. $$(if $$(filter undefined,$$(origin $(2)_FINAL_RECURSIVE_RDEPENDENCIES__X)), \
  717. $$(eval $(2)_FINAL_RECURSIVE_RDEPENDENCIES__X := \
  718. $$(foreach p, \
  719. $$($(2)_RDEPENDENCIES), \
  720. $$(p) \
  721. $$($$(call UPPERCASE,$$(p))_FINAL_RECURSIVE_RDEPENDENCIES) \
  722. ) \
  723. ) \
  724. ) \
  725. $$($(2)_FINAL_RECURSIVE_RDEPENDENCIES__X))
  726. # define sub-target stamps
  727. $(2)_TARGET_INSTALL = $$($(2)_DIR)/.stamp_installed
  728. $(2)_TARGET_INSTALL_TARGET = $$($(2)_DIR)/.stamp_target_installed
  729. $(2)_TARGET_INSTALL_STAGING = $$($(2)_DIR)/.stamp_staging_installed
  730. $(2)_TARGET_INSTALL_IMAGES = $$($(2)_DIR)/.stamp_images_installed
  731. $(2)_TARGET_INSTALL_HOST = $$($(2)_DIR)/.stamp_host_installed
  732. $(2)_TARGET_BUILD = $$($(2)_DIR)/.stamp_built
  733. $(2)_TARGET_CONFIGURE = $$($(2)_DIR)/.stamp_configured
  734. $(2)_TARGET_RSYNC = $$($(2)_DIR)/.stamp_rsynced
  735. $(2)_TARGET_PATCH = $$($(2)_DIR)/.stamp_patched
  736. $(2)_TARGET_EXTRACT = $$($(2)_DIR)/.stamp_extracted
  737. $(2)_TARGET_SOURCE = $$($(2)_DIR)/.stamp_downloaded
  738. $(2)_TARGET_ACTUAL_SOURCE = $$($(2)_DIR)/.stamp_actual_downloaded
  739. $(2)_TARGET_DIRCLEAN = $$($(2)_DIR)/.stamp_dircleaned
  740. # default extract command
  741. $(2)_EXTRACT_CMDS ?= \
  742. $$(if $$($(2)_SOURCE),$$(INFLATE$$(suffix $$($(2)_SOURCE))) $$($(2)_DL_DIR)/$$($(2)_SOURCE) | \
  743. $$(TAR) --strip-components=$$($(2)_STRIP_COMPONENTS) \
  744. -C $$($(2)_DIR) \
  745. $$(foreach x,$$($(2)_EXCLUDES),--exclude='$$(x)' ) \
  746. $$(TAR_OPTIONS) -)
  747. # pre/post-steps hooks
  748. $(2)_POST_PREPARE_HOOKS += FIXUP_PYTHON_SYSCONFIGDATA
  749. ifeq ($$($(2)_TYPE),target)
  750. ifneq ($$(HOST_$(2)_KCONFIG_VAR),)
  751. $$(error "Package $(1) defines host variant before target variant!")
  752. endif
  753. endif
  754. # Globaly remove following conflicting and useless files
  755. $(2)_DROP_FILES_OR_DIRS += /share/info/dir
  756. ifeq ($$($(2)_TYPE),host)
  757. $(2)_POST_INSTALL_HOOKS += REMOVE_CONFLICTING_USELESS_FILES_IN_HOST
  758. else
  759. $(2)_POST_INSTALL_STAGING_HOOKS += REMOVE_CONFLICTING_USELESS_FILES_IN_STAGING
  760. $(2)_POST_INSTALL_TARGET_HOOKS += REMOVE_CONFLICTING_USELESS_FILES_IN_TARGET
  761. endif
  762. # human-friendly targets and target sequencing
  763. $(1): $(1)-install
  764. $(1)-install: $$($(2)_TARGET_INSTALL)
  765. $$($(2)_TARGET_INSTALL): $$($(2)_TARGET_BUILD)
  766. ifeq ($$($(2)_TYPE),host)
  767. $$($(2)_TARGET_INSTALL): $$($(2)_TARGET_INSTALL_HOST)
  768. else
  769. $(2)_INSTALL_STAGING ?= NO
  770. $(2)_INSTALL_IMAGES ?= NO
  771. $(2)_INSTALL_TARGET ?= YES
  772. ifeq ($$($(2)_INSTALL_TARGET),YES)
  773. $$($(2)_TARGET_INSTALL): $$($(2)_TARGET_INSTALL_TARGET)
  774. endif
  775. ifeq ($$($(2)_INSTALL_STAGING),YES)
  776. $$($(2)_TARGET_INSTALL): $$($(2)_TARGET_INSTALL_STAGING)
  777. endif
  778. ifeq ($$($(2)_INSTALL_IMAGES),YES)
  779. $$($(2)_TARGET_INSTALL): $$($(2)_TARGET_INSTALL_IMAGES)
  780. endif
  781. endif
  782. ifeq ($$($(2)_INSTALL_TARGET),YES)
  783. $(1)-install-target: $$($(2)_TARGET_INSTALL_TARGET)
  784. $$($(2)_TARGET_INSTALL_TARGET): $$($(2)_TARGET_BUILD)
  785. else
  786. $(1)-install-target:
  787. endif
  788. ifeq ($$($(2)_INSTALL_STAGING),YES)
  789. $(1)-install-staging: $$($(2)_TARGET_INSTALL_STAGING)
  790. $$($(2)_TARGET_INSTALL_STAGING): $$($(2)_TARGET_BUILD)
  791. # Some packages use install-staging stuff for install-target
  792. $$($(2)_TARGET_INSTALL_TARGET): $$($(2)_TARGET_INSTALL_STAGING)
  793. else
  794. $(1)-install-staging:
  795. endif
  796. ifeq ($$($(2)_INSTALL_IMAGES),YES)
  797. $(1)-install-images: $$($(2)_TARGET_INSTALL_IMAGES)
  798. $$($(2)_TARGET_INSTALL_IMAGES): $$($(2)_TARGET_BUILD)
  799. else
  800. $(1)-install-images:
  801. endif
  802. $(1)-install-host: $$($(2)_TARGET_INSTALL_HOST)
  803. $$($(2)_TARGET_INSTALL_HOST): $$($(2)_TARGET_BUILD)
  804. $(1)-build: $$($(2)_TARGET_BUILD)
  805. $$($(2)_TARGET_BUILD): $$($(2)_TARGET_CONFIGURE)
  806. # Since $(2)_FINAL_DEPENDENCIES are phony targets, they are always "newer"
  807. # than $(2)_TARGET_CONFIGURE. This would force the configure step (and
  808. # therefore the other steps as well) to be re-executed with every
  809. # invocation of make. Therefore, make $(2)_FINAL_DEPENDENCIES an order-only
  810. # dependency by using |.
  811. $(1)-configure: $$($(2)_TARGET_CONFIGURE)
  812. $$($(2)_TARGET_CONFIGURE): | $$($(2)_FINAL_DEPENDENCIES)
  813. $$($(2)_TARGET_SOURCE) $$($(2)_TARGET_RSYNC): | prepare
  814. $$($(2)_TARGET_SOURCE) $$($(2)_TARGET_RSYNC): | dependencies
  815. ifeq ($$($(2)_OVERRIDE_SRCDIR),)
  816. # In the normal case (no package override), the sequence of steps is
  817. # source, by downloading
  818. # depends
  819. # extract
  820. # patch
  821. # configure
  822. $$($(2)_TARGET_CONFIGURE): $$($(2)_TARGET_PATCH)
  823. $(1)-patch: $$($(2)_TARGET_PATCH)
  824. $$($(2)_TARGET_PATCH): $$($(2)_TARGET_EXTRACT)
  825. # Order-only dependency
  826. $$($(2)_TARGET_PATCH): | $$(patsubst %,%-patch,$$($(2)_FINAL_PATCH_DEPENDENCIES))
  827. $(1)-extract: $$($(2)_TARGET_EXTRACT)
  828. $$($(2)_TARGET_EXTRACT): $$($(2)_TARGET_SOURCE)
  829. $$($(2)_TARGET_EXTRACT): | $$($(2)_FINAL_EXTRACT_DEPENDENCIES)
  830. $(1)-depends: $$($(2)_FINAL_ALL_DEPENDENCIES)
  831. $(1)-source: $$($(2)_TARGET_SOURCE)
  832. $$($(2)_TARGET_SOURCE): | $$($(2)_FINAL_DOWNLOAD_DEPENDENCIES)
  833. $(1)-all-source: $(1)-legal-source
  834. $(1)-legal-info: $(1)-legal-source
  835. $(1)-legal-source: $(1)-source
  836. # Only download the actual source if it differs from the 'main' archive
  837. ifneq ($$($(2)_ACTUAL_SOURCE_TARBALL),)
  838. ifneq ($$($(2)_ACTUAL_SOURCE_TARBALL),$$($(2)_SOURCE))
  839. $(1)-legal-source: $$($(2)_TARGET_ACTUAL_SOURCE)
  840. endif # actual sources != sources
  841. endif # actual sources != ""
  842. $(1)-external-deps:
  843. @for p in $$($(2)_SOURCE) $$($(2)_PATCH) $$($(2)_EXTRA_DOWNLOADS) ; do \
  844. echo `basename $$$$p` ; \
  845. done
  846. else
  847. # In the package override case, the sequence of steps
  848. # source, by rsyncing
  849. # depends
  850. # configure
  851. # Use an order-only dependency so the "<pkg>-clean-for-rebuild" rule
  852. # can remove the stamp file without triggering the configure step.
  853. $$($(2)_TARGET_CONFIGURE): | $$($(2)_TARGET_RSYNC)
  854. $(1)-depends: $$($(2)_FINAL_DEPENDENCIES)
  855. $(1)-patch: $(1)-rsync
  856. $(1)-extract: $(1)-rsync
  857. $(1)-rsync: $$($(2)_TARGET_RSYNC)
  858. $(1)-source:
  859. $(1)-legal-source:
  860. $(1)-external-deps:
  861. @echo "file://$$($(2)_OVERRIDE_SRCDIR)"
  862. endif
  863. $(1)-show-version:
  864. @echo $$($(2)_VERSION)
  865. $(1)-show-depends:
  866. @echo $$($(2)_FINAL_ALL_DEPENDENCIES)
  867. $(1)-show-recursive-depends:
  868. @echo $$($(2)_FINAL_RECURSIVE_DEPENDENCIES)
  869. $(1)-show-rdepends:
  870. @echo $$($(2)_RDEPENDENCIES)
  871. $(1)-show-recursive-rdepends:
  872. @echo $$($(2)_FINAL_RECURSIVE_RDEPENDENCIES)
  873. $(1)-show-build-order: $$(patsubst %,%-show-build-order,$$($(2)_FINAL_ALL_DEPENDENCIES))
  874. @:
  875. $$(info $(1))
  876. $(1)-show-info:
  877. @:
  878. $$(info $$(call clean-json,{ $$(call json-info,$(2)) }))
  879. $(1)-graph-depends: graph-depends-requirements
  880. $(call pkg-graph-depends,$(1),--direct)
  881. $(1)-graph-rdepends: graph-depends-requirements
  882. $(call pkg-graph-depends,$(1),--reverse)
  883. $(1)-all-source: $(1)-source
  884. $(1)-all-source: $$(foreach p,$$($(2)_FINAL_ALL_DEPENDENCIES),$$(p)-all-source)
  885. $(1)-all-external-deps: $(1)-external-deps
  886. $(1)-all-external-deps: $$(foreach p,$$($(2)_FINAL_ALL_DEPENDENCIES),$$(p)-all-external-deps)
  887. $(1)-all-legal-info: $(1)-legal-info
  888. $(1)-all-legal-info: $$(foreach p,$$($(2)_FINAL_ALL_DEPENDENCIES),$$(p)-all-legal-info)
  889. $(1)-dirclean: $$($(2)_TARGET_DIRCLEAN)
  890. $(1)-clean-for-reinstall:
  891. ifneq ($$($(2)_OVERRIDE_SRCDIR),)
  892. rm -f $$($(2)_TARGET_RSYNC)
  893. endif
  894. rm -f $$($(2)_TARGET_INSTALL)
  895. rm -f $$($(2)_TARGET_INSTALL_STAGING)
  896. rm -f $$($(2)_TARGET_INSTALL_TARGET)
  897. rm -f $$($(2)_TARGET_INSTALL_IMAGES)
  898. rm -f $$($(2)_TARGET_INSTALL_HOST)
  899. $(1)-reinstall: $(1)-clean-for-reinstall $(1)
  900. $(1)-clean-for-rebuild: $(1)-clean-for-reinstall
  901. rm -f $$($(2)_TARGET_BUILD)
  902. $(1)-rebuild: $(1)-clean-for-rebuild $(1)
  903. $(1)-clean-for-reconfigure: $(1)-clean-for-rebuild
  904. rm -f $$($(2)_TARGET_CONFIGURE)
  905. $(1)-reconfigure: $(1)-clean-for-reconfigure $(1)
  906. # define the PKG variable for all targets, containing the
  907. # uppercase package variable prefix
  908. $$($(2)_TARGET_INSTALL): PKG=$(2)
  909. $$($(2)_TARGET_INSTALL_TARGET): PKG=$(2)
  910. $$($(2)_TARGET_INSTALL_STAGING): PKG=$(2)
  911. $$($(2)_TARGET_INSTALL_IMAGES): PKG=$(2)
  912. $$($(2)_TARGET_INSTALL_HOST): PKG=$(2)
  913. $$($(2)_TARGET_BUILD): PKG=$(2)
  914. $$($(2)_TARGET_CONFIGURE): PKG=$(2)
  915. $$($(2)_TARGET_CONFIGURE): NAME=$(1)
  916. $$($(2)_TARGET_RSYNC): SRCDIR=$$($(2)_OVERRIDE_SRCDIR)
  917. $$($(2)_TARGET_RSYNC): PKG=$(2)
  918. $$($(2)_TARGET_PATCH): PKG=$(2)
  919. $$($(2)_TARGET_PATCH): RAWNAME=$$(patsubst host-%,%,$(1))
  920. $$($(2)_TARGET_PATCH): PKGDIR=$(pkgdir)
  921. $$($(2)_TARGET_EXTRACT): PKG=$(2)
  922. $$($(2)_TARGET_SOURCE): PKG=$(2)
  923. $$($(2)_TARGET_SOURCE): PKGDIR=$(pkgdir)
  924. $$($(2)_TARGET_ACTUAL_SOURCE): PKG=$(2)
  925. $$($(2)_TARGET_ACTUAL_SOURCE): PKGDIR=$(pkgdir)
  926. $$($(2)_TARGET_DIRCLEAN): PKG=$(2)
  927. $$($(2)_TARGET_DIRCLEAN): NAME=$(1)
  928. # Compute the name of the Kconfig option that correspond to the
  929. # package being enabled. We handle three cases: the special Linux
  930. # kernel case, the bootloaders case, and the normal packages case.
  931. # Virtual packages are handled separately (see below).
  932. ifeq ($(1),linux)
  933. $(2)_KCONFIG_VAR = BR2_LINUX_KERNEL
  934. else ifneq ($$(filter boot/% $$(foreach dir,$$(BR2_EXTERNAL_DIRS),$$(dir)/boot/%),$(pkgdir)),)
  935. $(2)_KCONFIG_VAR = BR2_TARGET_$(2)
  936. else ifneq ($$(filter toolchain/% $$(foreach dir,$$(BR2_EXTERNAL_DIRS),$$(dir)/toolchain/%),$(pkgdir)),)
  937. $(2)_KCONFIG_VAR = BR2_$(2)
  938. else
  939. $(2)_KCONFIG_VAR = BR2_PACKAGE_$(2)
  940. endif
  941. # legal-info: declare dependencies and set values used later for the manifest
  942. ifneq ($$($(2)_LICENSE_FILES),)
  943. $(2)_MANIFEST_LICENSE_FILES = $$($(2)_LICENSE_FILES)
  944. endif
  945. # We need to extract and patch a package to be able to retrieve its
  946. # license files (if any) and the list of patches applied to it (if
  947. # any).
  948. $(1)-legal-info: $(1)-patch
  949. # We only save the sources of packages we want to redistribute, that are
  950. # non-overriden (local or true override).
  951. ifeq ($$($(2)_REDISTRIBUTE),YES)
  952. ifeq ($$($(2)_OVERRIDE_SRCDIR),)
  953. # Packages that have a tarball need it downloaded beforehand
  954. $(1)-legal-info: $(1)-source $$(REDIST_SOURCES_DIR_$$(call UPPERCASE,$(4)))
  955. endif
  956. endif
  957. # legal-info: produce legally relevant info.
  958. $(1)-legal-info: PKG=$(2)
  959. $(1)-legal-info:
  960. @$$(call MESSAGE,"Collecting legal info")
  961. # Packages without a source are assumed to be part of Buildroot, skip them.
  962. $$(foreach hook,$$($(2)_PRE_LEGAL_INFO_HOOKS),$$(call $$(hook))$$(sep))
  963. ifneq ($$(call qstrip,$$($(2)_SOURCE)),)
  964. # Save license files if defined
  965. # We save the license files for any kind of package: normal, local,
  966. # overridden, or non-redistributable alike.
  967. # The reason to save license files even for no-redistribute packages
  968. # is that the license still applies to the files distributed as part
  969. # of the rootfs, even if the sources are not themselves redistributed.
  970. ifeq ($$(call qstrip,$$($(2)_LICENSE_FILES)),)
  971. $(Q)$$(call legal-warning-pkg,$$($(2)_BASENAME_RAW),cannot save license ($(2)_LICENSE_FILES not defined))
  972. else
  973. $(Q)$$(foreach F,$$($(2)_LICENSE_FILES),$$(call legal-license-file,$$($(2)_RAWNAME),$$($(2)_BASENAME_RAW),$$($(2)_HASH_FILE),$$(F),$$($(2)_DIR)/$$(F),$$(call UPPERCASE,$(4)))$$(sep))
  974. endif # license files
  975. ifeq ($$($(2)_SITE_METHOD),local)
  976. # Packages without a tarball: don't save and warn
  977. @$$(call legal-warning-nosource,$$($(2)_RAWNAME),local)
  978. else ifneq ($$($(2)_OVERRIDE_SRCDIR),)
  979. @$$(call legal-warning-nosource,$$($(2)_RAWNAME),override)
  980. else
  981. # Other packages
  982. ifeq ($$($(2)_REDISTRIBUTE),YES)
  983. # Save the source tarball and any extra downloads, but not
  984. # patches, as they are handled specially afterwards.
  985. $$(foreach e,$$($(2)_ACTUAL_SOURCE_TARBALL) $$(notdir $$($(2)_EXTRA_DOWNLOADS)),\
  986. $$(Q)support/scripts/hardlink-or-copy \
  987. $$($(2)_DL_DIR)/$$(e) \
  988. $$($(2)_REDIST_SOURCES_DIR)$$(sep))
  989. # Save patches and generate the series file
  990. $$(Q)while read f; do \
  991. support/scripts/hardlink-or-copy \
  992. $$$${f} \
  993. $$($(2)_REDIST_SOURCES_DIR) || exit 1; \
  994. printf "%s\n" "$$$${f##*/}" >>$$($(2)_REDIST_SOURCES_DIR)/series || exit 1; \
  995. done <$$($(2)_DIR)/.applied_patches_list
  996. endif # redistribute
  997. endif # other packages
  998. @$$(call legal-manifest,$$(call UPPERCASE,$(4)),$$($(2)_RAWNAME),$$($(2)_VERSION),$$(subst $$(space)$$(comma),$$(comma),$$($(2)_LICENSE)),$$($(2)_MANIFEST_LICENSE_FILES),$$($(2)_ACTUAL_SOURCE_TARBALL),$$($(2)_ACTUAL_SOURCE_SITE),$$(call legal-deps,$(1)))
  999. endif # ifneq ($$(call qstrip,$$($(2)_SOURCE)),)
  1000. $$(foreach hook,$$($(2)_POST_LEGAL_INFO_HOOKS),$$(call $$(hook))$$(sep))
  1001. # add package to the general list of targets if requested by the buildroot
  1002. # configuration
  1003. ifeq ($$($$($(2)_KCONFIG_VAR)),y)
  1004. # Ensure the calling package is the declared provider for all the virtual
  1005. # packages it claims to be an implementation of.
  1006. ifneq ($$($(2)_PROVIDES),)
  1007. $$(foreach pkg,$$($(2)_PROVIDES),\
  1008. $$(eval $$(call virt-provides-single,$$(pkg),$$(call UPPERCASE,$$(pkg)),$(1))$$(sep)))
  1009. endif
  1010. # Register package as a reverse-dependencies of all its dependencies
  1011. $$(eval $$(foreach p,$$($(2)_FINAL_ALL_DEPENDENCIES),\
  1012. $$(call UPPERCASE,$$(p))_RDEPENDENCIES += $(1)$$(sep)))
  1013. # Ensure unified variable name conventions between all packages Some
  1014. # of the variables are used by more than one infrastructure; so,
  1015. # rather than duplicating the checks in each infrastructure, we check
  1016. # all variables here in pkg-generic, even though pkg-generic should
  1017. # have no knowledge of infra-specific variables.
  1018. $(eval $(call check-deprecated-variable,$(2)_MAKE_OPT,$(2)_MAKE_OPTS))
  1019. $(eval $(call check-deprecated-variable,$(2)_INSTALL_OPT,$(2)_INSTALL_OPTS))
  1020. $(eval $(call check-deprecated-variable,$(2)_INSTALL_TARGET_OPT,$(2)_INSTALL_TARGET_OPTS))
  1021. $(eval $(call check-deprecated-variable,$(2)_INSTALL_STAGING_OPT,$(2)_INSTALL_STAGING_OPTS))
  1022. $(eval $(call check-deprecated-variable,$(2)_INSTALL_HOST_OPT,$(2)_INSTALL_HOST_OPTS))
  1023. $(eval $(call check-deprecated-variable,$(2)_AUTORECONF_OPT,$(2)_AUTORECONF_OPTS))
  1024. $(eval $(call check-deprecated-variable,$(2)_CONF_OPT,$(2)_CONF_OPTS))
  1025. $(eval $(call check-deprecated-variable,$(2)_BUILD_OPT,$(2)_BUILD_OPTS))
  1026. $(eval $(call check-deprecated-variable,$(2)_GETTEXTIZE_OPT,$(2)_GETTEXTIZE_OPTS))
  1027. $(eval $(call check-deprecated-variable,$(2)_KCONFIG_OPT,$(2)_KCONFIG_OPTS))
  1028. PACKAGES += $(1)
  1029. ifneq ($$($(2)_PERMISSIONS),)
  1030. PACKAGES_PERMISSIONS_TABLE += $$($(2)_PERMISSIONS)$$(sep)
  1031. endif
  1032. ifneq ($$($(2)_DEVICES),)
  1033. PACKAGES_DEVICES_TABLE += $$($(2)_DEVICES)$$(sep)
  1034. endif
  1035. ifneq ($$($(2)_USERS),)
  1036. PACKAGES_USERS += $$($(2)_USERS)$$(sep)
  1037. endif
  1038. ifneq ($$($(2)_LINUX_CONFIG_FIXUPS),)
  1039. PACKAGES_LINUX_CONFIG_FIXUPS += $$($(2)_LINUX_CONFIG_FIXUPS)$$(sep)
  1040. endif
  1041. TARGET_FINALIZE_HOOKS += $$($(2)_TARGET_FINALIZE_HOOKS)
  1042. ROOTFS_PRE_CMD_HOOKS += $$($(2)_ROOTFS_PRE_CMD_HOOKS)
  1043. KEEP_PYTHON_PY_FILES += $$($(2)_KEEP_PY_FILES)
  1044. ifneq ($$($(2)_SELINUX_MODULES),)
  1045. PACKAGES_SELINUX_MODULES += $$($(2)_SELINUX_MODULES)
  1046. endif
  1047. PACKAGES_SELINUX_EXTRA_MODULES_DIRS += \
  1048. $$(if $$(wildcard $$($(2)_PKGDIR)/selinux),$$($(2)_PKGDIR)/selinux)
  1049. ifeq ($$($(2)_SITE_METHOD),svn)
  1050. DL_TOOLS_DEPENDENCIES += svn
  1051. else ifeq ($$($(2)_SITE_METHOD),git)
  1052. DL_TOOLS_DEPENDENCIES += git
  1053. ifneq ($$($(2)_GIT_LFS),)
  1054. DL_TOOLS_DEPENDENCIES += git-lfs
  1055. endif
  1056. else ifeq ($$($(2)_SITE_METHOD),bzr)
  1057. DL_TOOLS_DEPENDENCIES += bzr
  1058. else ifeq ($$($(2)_SITE_METHOD),scp)
  1059. DL_TOOLS_DEPENDENCIES += scp ssh
  1060. else ifeq ($$($(2)_SITE_METHOD),hg)
  1061. DL_TOOLS_DEPENDENCIES += hg
  1062. else ifeq ($$($(2)_SITE_METHOD),cvs)
  1063. DL_TOOLS_DEPENDENCIES += cvs
  1064. endif # SITE_METHOD
  1065. DL_TOOLS_DEPENDENCIES += $$(call extractor-system-dependency,$$($(2)_SOURCE))
  1066. # Ensure all virtual targets are PHONY. Listed alphabetically.
  1067. .PHONY: $(1) \
  1068. $(1)-all-external-deps \
  1069. $(1)-all-legal-info \
  1070. $(1)-all-source \
  1071. $(1)-build \
  1072. $(1)-clean-for-rebuild \
  1073. $(1)-clean-for-reconfigure \
  1074. $(1)-clean-for-reinstall \
  1075. $(1)-configure \
  1076. $(1)-depends \
  1077. $(1)-dirclean \
  1078. $(1)-external-deps \
  1079. $(1)-extract \
  1080. $(1)-graph-depends \
  1081. $(1)-graph-rdepends \
  1082. $(1)-install \
  1083. $(1)-install-host \
  1084. $(1)-install-images \
  1085. $(1)-install-staging \
  1086. $(1)-install-target \
  1087. $(1)-legal-info \
  1088. $(1)-legal-source \
  1089. $(1)-patch \
  1090. $(1)-rebuild \
  1091. $(1)-reconfigure \
  1092. $(1)-reinstall \
  1093. $(1)-rsync \
  1094. $(1)-show-depends \
  1095. $(1)-show-info \
  1096. $(1)-show-version \
  1097. $(1)-source
  1098. ifneq ($$($(2)_SOURCE),)
  1099. ifeq ($$($(2)_SITE),)
  1100. $$(error $(2)_SITE cannot be empty when $(2)_SOURCE is not)
  1101. endif
  1102. endif
  1103. ifeq ($$(patsubst %/,ERROR,$$($(2)_SITE)),ERROR)
  1104. $$(error $(2)_SITE ($$($(2)_SITE)) cannot have a trailing slash)
  1105. endif
  1106. ifneq ($$($(2)_HELP_CMDS),)
  1107. HELP_PACKAGES += $(2)
  1108. endif
  1109. # Virtual packages are not built but it's useful to allow them to have
  1110. # permission/device/user tables and target-finalize/rootfs-pre-cmd hooks.
  1111. else ifeq ($$(BR2_PACKAGE_HAS_$(2)),y) # $(2)_KCONFIG_VAR
  1112. ifneq ($$($(2)_PERMISSIONS),)
  1113. PACKAGES_PERMISSIONS_TABLE += $$($(2)_PERMISSIONS)$$(sep)
  1114. endif
  1115. ifneq ($$($(2)_DEVICES),)
  1116. PACKAGES_DEVICES_TABLE += $$($(2)_DEVICES)$$(sep)
  1117. endif
  1118. ifneq ($$($(2)_USERS),)
  1119. PACKAGES_USERS += $$($(2)_USERS)$$(sep)
  1120. endif
  1121. TARGET_FINALIZE_HOOKS += $$($(2)_TARGET_FINALIZE_HOOKS)
  1122. ROOTFS_PRE_CMD_HOOKS += $$($(2)_ROOTFS_PRE_CMD_HOOKS)
  1123. endif # $(2)_KCONFIG_VAR
  1124. endef # inner-generic-package
  1125. ################################################################################
  1126. # generic-package -- the target generator macro for generic packages
  1127. ################################################################################
  1128. # In the case of target packages, keep the package name "pkg"
  1129. generic-package = $(call inner-generic-package,$(pkgname),$(call UPPERCASE,$(pkgname)),$(call UPPERCASE,$(pkgname)),target)
  1130. # In the case of host packages, turn the package name "pkg" into "host-pkg"
  1131. host-generic-package = $(call inner-generic-package,host-$(pkgname),$(call UPPERCASE,host-$(pkgname)),$(call UPPERCASE,$(pkgname)),host)
  1132. # :mode=makefile: