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