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