pkg-generic.mk 41 KB

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