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