]> rtime.felk.cvut.cz Git - coffee/buildroot.git/blob - package/pkg-generic.mk
pkg-infra: add <pkg>-extract and <pkg>-patch targets to OVERRIDE support
[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 informations 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 # Implicit targets -- produce a stamp file for each step of a package build
25 ################################################################################
26
27 # Retrieve the archive
28 $(BUILD_DIR)/%/.stamp_downloaded:
29 ifeq ($(DL_MODE),DOWNLOAD)
30 # Only show the download message if it isn't already downloaded
31         $(Q)(test -e $(DL_DIR)/$($(PKG)_SOURCE) && \
32                 (test -z $($(PKG)_PATCH) || test -e $(DL_DIR)$($(PKG)_PATCH))) || \
33                 $(call MESSAGE,"Downloading")
34 endif
35         $(if $($(PKG)_SOURCE),$(call DOWNLOAD,$($(PKG)_SITE)/$($(PKG)_SOURCE)))
36         $(if $($(PKG)_PATCH),$(call DOWNLOAD,$($(PKG)_SITE)/$($(PKG)_PATCH)))
37         $(foreach hook,$($(PKG)_POST_DOWNLOAD_HOOKS),$(call $(hook))$(sep))
38 ifeq ($(DL_MODE),DOWNLOAD)
39         $(Q)mkdir -p $(@D)
40         $(Q)touch $@
41 endif
42
43 # Unpack the archive
44 $(BUILD_DIR)/%/.stamp_extracted:
45         @$(call MESSAGE,"Extracting")
46         $(Q)mkdir -p $(@D)
47         $($(PKG)_EXTRACT_CMDS)
48 # some packages have messed up permissions inside
49         $(Q)chmod -R +rw $(@D)
50         $(foreach hook,$($(PKG)_POST_EXTRACT_HOOKS),$(call $(hook))$(sep))
51         $(Q)touch $@
52
53 # Rsync the source directory if the <pkg>_OVERRIDE_SRCDIR feature is
54 # used.
55 $(BUILD_DIR)/%/.stamp_rsynced:
56         @$(call MESSAGE,"Syncing from source dir $(SRCDIR)")
57         @test -d $(SRCDIR) || (echo "ERROR: $(SRCDIR) does not exist" ; exit 1)
58         rsync -au $(SRCDIR)/ $(@D)
59         $(Q)touch $@
60
61 # Handle the SOURCE_CHECK and SHOW_EXTERNAL_DEPS cases for rsynced
62 # packages
63 $(BUILD_DIR)/%/.stamp_rsync_sourced:
64 ifeq ($(DL_MODE),SOURCE_CHECK)
65         test -d $(SRCDIR)
66 else ifeq ($(DL_MODE),SHOW_EXTERNAL_DEPS)
67         echo "file://$(SRCDIR)"
68 else
69         @true # Nothing to do to source a local package
70 endif
71
72 # Patch
73 #
74 # The RAWNAME variable is the lowercased package name, which allows to
75 # find the package directory (typically package/<pkgname>) and the
76 # prefix of the patches
77 $(BUILD_DIR)/%/.stamp_patched: NAMEVER = $(RAWNAME)-$($(PKG)_VERSION)
78 $(BUILD_DIR)/%/.stamp_patched:
79         @$(call MESSAGE,"Patching $($(PKG)_DIR_PREFIX)/$(RAWNAME)")
80         $(foreach hook,$($(PKG)_PRE_PATCH_HOOKS),$(call $(hook))$(sep))
81         $(if $($(PKG)_PATCH),support/scripts/apply-patches.sh $(@D) $(DL_DIR) $($(PKG)_PATCH))
82         $(Q)( \
83         if test -d $($(PKG)_DIR_PREFIX)/$(RAWNAME); then \
84           if test "$(wildcard $($(PKG)_DIR_PREFIX)/$(RAWNAME)/$(NAMEVER)*.patch*)"; then \
85             support/scripts/apply-patches.sh $(@D) $($(PKG)_DIR_PREFIX)/$(RAWNAME) $(NAMEVER)\*.patch $(NAMEVER)\*.patch.$(ARCH) || exit 1; \
86           else \
87             support/scripts/apply-patches.sh $(@D) $($(PKG)_DIR_PREFIX)/$(RAWNAME) $(RAWNAME)\*.patch $(RAWNAME)\*.patch.$(ARCH) || exit 1; \
88             if test -d $($(PKG)_DIR_PREFIX)/$(RAWNAME)/$(NAMEVER); then \
89               support/scripts/apply-patches.sh $(@D) $($(PKG)_DIR_PREFIX)/$(RAWNAME)/$(NAMEVER) \*.patch \*.patch.$(ARCH) || exit 1; \
90             fi; \
91           fi; \
92         fi; \
93         )
94         $(foreach hook,$($(PKG)_POST_PATCH_HOOKS),$(call $(hook))$(sep))
95         $(Q)touch $@
96
97 # Configure
98 $(BUILD_DIR)/%/.stamp_configured:
99         $(foreach hook,$($(PKG)_PRE_CONFIGURE_HOOKS),$(call $(hook))$(sep))
100         @$(call MESSAGE,"Configuring")
101         $($(PKG)_CONFIGURE_CMDS)
102         $(foreach hook,$($(PKG)_POST_CONFIGURE_HOOKS),$(call $(hook))$(sep))
103         $(Q)touch $@
104
105 # Build
106 $(BUILD_DIR)/%/.stamp_built::
107         @$(call MESSAGE,"Building")
108         $($(PKG)_BUILD_CMDS)
109         $(foreach hook,$($(PKG)_POST_BUILD_HOOKS),$(call $(hook))$(sep))
110         $(Q)touch $@
111
112 # Install to host dir
113 $(BUILD_DIR)/%/.stamp_host_installed:
114         @$(call MESSAGE,"Installing to host directory")
115         $($(PKG)_INSTALL_CMDS)
116         $(foreach hook,$($(PKG)_POST_INSTALL_HOOKS),$(call $(hook))$(sep))
117         $(Q)touch $@
118
119 # Install to staging dir
120 $(BUILD_DIR)/%/.stamp_staging_installed:
121         @$(call MESSAGE,"Installing to staging directory")
122         $($(PKG)_INSTALL_STAGING_CMDS)
123         $(foreach hook,$($(PKG)_POST_INSTALL_STAGING_HOOKS),$(call $(hook))$(sep))
124         $(Q)touch $@
125
126 # Install to images dir
127 $(BUILD_DIR)/%/.stamp_images_installed:
128         @$(call MESSAGE,"Installing to images directory")
129         $($(PKG)_INSTALL_IMAGES_CMDS)
130         $(foreach hook,$($(PKG)_POST_INSTALL_IMAGES_HOOKS),$(call $(hook))$(sep))
131         $(Q)touch $@
132
133 # Install to target dir
134 $(BUILD_DIR)/%/.stamp_target_installed:
135         @$(call MESSAGE,"Installing to target")
136         $(if $(BR2_INIT_SYSTEMD),\
137                 $($(PKG)_INSTALL_INIT_SYSTEMD))
138         $(if $(BR2_INIT_SYSV)$(BR2_INIT_BUSYBOX),\
139                 $($(PKG)_INSTALL_INIT_SYSV))
140         $($(PKG)_INSTALL_TARGET_CMDS)
141         $(foreach hook,$($(PKG)_POST_INSTALL_TARGET_HOOKS),$(call $(hook))$(sep))
142         $(Q)touch $@
143
144 # Clean package
145 $(BUILD_DIR)/%/.stamp_cleaned:
146         @$(call MESSAGE,"Cleaning up")
147         $($(PKG)_CLEAN_CMDS)
148         rm -f $(@D)/.stamp_built
149
150 # Uninstall package from target and staging
151 # Uninstall commands tend to fail, so remove the stamp files first
152 $(BUILD_DIR)/%/.stamp_uninstalled:
153         @$(call MESSAGE,"Uninstalling")
154         rm -f $($(PKG)_TARGET_INSTALL_STAGING)
155         rm -f $($(PKG)_TARGET_INSTALL_TARGET)
156         $($(PKG)_UNINSTALL_STAGING_CMDS)
157         $($(PKG)_UNINSTALL_TARGET_CMDS)
158         $(if $(BR2_INIT_SYSTEMD),\
159                 $($(PKG)_UNINSTALL_INIT_SYSTEMD))
160         $(if $(BR2_INIT_SYSV)$(BR2_INIT_BUSYBOX),\
161                 $($(PKG)_UNINSTALL_INIT_SYSV))
162
163 # Remove package sources
164 $(BUILD_DIR)/%/.stamp_dircleaned:
165         rm -Rf $(@D)
166
167 ################################################################################
168 # inner-generic-package -- generates the make targets needed to build a
169 # generic package
170 #
171 #  argument 1 is the lowercase package name
172 #  argument 2 is the uppercase package name, including an HOST_ prefix
173 #             for host packages
174 #  argument 3 is the uppercase package name, without the HOST_ prefix
175 #             for host packages
176 #  argument 4 is the package directory prefix
177 #  argument 5 is the type (target or host)
178 ################################################################################
179
180 define inner-generic-package
181
182 # Define default values for various package-related variables, if not
183 # already defined. For some variables (version, source, site and
184 # subdir), if they are undefined, we try to see if a variable without
185 # the HOST_ prefix is defined. If so, we use such a variable, so that
186 # these informations have only to be specified once, for both the
187 # target and host packages of a given .mk file.
188
189 $(2)_TYPE                       =  $(5)
190 $(2)_NAME                       =  $(1)
191 $(2)_RAWNAME                    =  $(patsubst host-%,%,$(1))
192
193 # Keep the package version that may contain forward slashes in the _DL_VERSION
194 # variable, then replace all forward slashes ('/') by underscores ('_') to
195 # sanitize the package version that is used in paths, directory and file names.
196 # Forward slashes may appear in the package's version when pointing to a
197 # version control system branch or tag, for example remotes/origin/1_10_stable.
198 ifndef $(2)_VERSION
199  ifdef $(3)_VERSION
200   $(2)_DL_VERSION = $($(3)_VERSION)
201   $(2)_VERSION = $(subst /,_,$($(3)_VERSION))
202  else
203   $(2)_VERSION = undefined
204   $(2)_DL_VERSION = undefined
205  endif
206 else
207   $(2)_DL_VERSION = $($(2)_VERSION)
208   $(2)_VERSION = $(subst /,_,$($(2)_VERSION))
209 endif
210
211 $(2)_BASE_NAME  =  $(1)-$$($(2)_VERSION)
212 $(2)_DL_DIR     =  $$(DL_DIR)/$$($(2)_BASE_NAME)
213 $(2)_DIR        =  $$(BUILD_DIR)/$$($(2)_BASE_NAME)
214
215 ifndef $(2)_SUBDIR
216  ifdef $(3)_SUBDIR
217   $(2)_SUBDIR = $$($(3)_SUBDIR)
218  else
219   $(2)_SUBDIR ?=
220  endif
221 endif
222
223 $(2)_SRCDIR                    = $$($(2)_DIR)/$$($(2)_SUBDIR)
224 $(2)_BUILDDIR                  ?= $$($(2)_SRCDIR)
225
226 ifneq ($$($(2)_OVERRIDE_SRCDIR),)
227 $(2)_VERSION = custom
228 endif
229
230 ifndef $(2)_SOURCE
231  ifdef $(3)_SOURCE
232   $(2)_SOURCE = $($(3)_SOURCE)
233  else
234   $(2)_SOURCE                   ?= $$($(2)_RAWNAME)-$$($(2)_VERSION).tar.gz
235  endif
236 endif
237
238 ifndef $(2)_PATCH
239  ifdef $(3)_PATCH
240   $(2)_PATCH = $($(3)_PATCH)
241  endif
242 endif
243
244 ifndef $(2)_SITE
245  ifdef $(3)_SITE
246   $(2)_SITE = $($(3)_SITE)
247  endif
248 endif
249
250 ifndef $(2)_SITE_METHOD
251  ifdef $(3)_SITE_METHOD
252   $(2)_SITE_METHOD = $($(3)_SITE_METHOD)
253  else
254         # Try automatic detection using the scheme part of the URI
255         $(2)_SITE_METHOD = $(firstword $(subst ://, ,$(call qstrip,$($(2)_SITE))))
256  endif
257 endif
258
259 ifeq ($$($(2)_SITE_METHOD),local)
260 ifeq ($$($(2)_OVERRIDE_SRCDIR),)
261 $(2)_OVERRIDE_SRCDIR = $($(2)_SITE)
262 endif
263 endif
264
265 ifndef $(2)_LICENSE
266  ifdef $(3)_LICENSE
267   $(2)_LICENSE = $($(3)_LICENSE)
268  endif
269 endif
270
271 $(2)_LICENSE                    ?= unknown
272
273 ifndef $(2)_LICENSE_FILES
274  ifdef $(3)_LICENSE_FILES
275   $(2)_LICENSE_FILES = $($(3)_LICENSE_FILES)
276  endif
277 endif
278
279 ifndef $(2)_REDISTRIBUTE
280  ifdef $(3)_REDISTRIBUTE
281   $(2)_REDISTRIBUTE = $($(3)_REDISTRIBUTE)
282  endif
283 endif
284
285 $(2)_REDISTRIBUTE               ?= YES
286
287
288 $(2)_DEPENDENCIES ?= $(filter-out $(1),$(patsubst host-host-%,host-%,$(addprefix host-,$($(3)_DEPENDENCIES))))
289
290 $(2)_INSTALL_STAGING            ?= NO
291 $(2)_INSTALL_IMAGES             ?= NO
292 $(2)_INSTALL_TARGET             ?= YES
293 $(2)_DIR_PREFIX                 = $(if $(4),$(4),$(TOP_SRCDIR)/package)
294
295 # define sub-target stamps
296 $(2)_TARGET_INSTALL_TARGET =    $$($(2)_DIR)/.stamp_target_installed
297 $(2)_TARGET_INSTALL_STAGING =   $$($(2)_DIR)/.stamp_staging_installed
298 $(2)_TARGET_INSTALL_IMAGES =    $$($(2)_DIR)/.stamp_images_installed
299 $(2)_TARGET_INSTALL_HOST =      $$($(2)_DIR)/.stamp_host_installed
300 $(2)_TARGET_BUILD =             $$($(2)_DIR)/.stamp_built
301 $(2)_TARGET_CONFIGURE =         $$($(2)_DIR)/.stamp_configured
302 $(2)_TARGET_RSYNC =             $$($(2)_DIR)/.stamp_rsynced
303 $(2)_TARGET_RSYNC_SOURCE =      $$($(2)_DIR)/.stamp_rsync_sourced
304 $(2)_TARGET_PATCH =             $$($(2)_DIR)/.stamp_patched
305 $(2)_TARGET_EXTRACT =           $$($(2)_DIR)/.stamp_extracted
306 $(2)_TARGET_SOURCE =            $$($(2)_DIR)/.stamp_downloaded
307 $(2)_TARGET_UNINSTALL =         $$($(2)_DIR)/.stamp_uninstalled
308 $(2)_TARGET_CLEAN =             $$($(2)_DIR)/.stamp_cleaned
309 $(2)_TARGET_DIRCLEAN =          $$($(2)_DIR)/.stamp_dircleaned
310
311 # default extract command
312 $(2)_EXTRACT_CMDS ?= \
313         $$(if $$($(2)_SOURCE),$$(INFLATE$$(suffix $$($(2)_SOURCE))) $(DL_DIR)/$$($(2)_SOURCE) | \
314         $(TAR) $(TAR_STRIP_COMPONENTS)=1 -C $$($(2)_DIR) $(TAR_OPTIONS) -)
315
316 # post-steps hooks
317 $(2)_POST_DOWNLOAD_HOOKS        ?=
318 $(2)_POST_EXTRACT_HOOKS         ?=
319 $(2)_PRE_PATCH_HOOKS            ?=
320 $(2)_POST_PATCH_HOOKS           ?=
321 $(2)_PRE_CONFIGURE_HOOKS        ?=
322 $(2)_POST_CONFIGURE_HOOKS       ?=
323 $(2)_POST_BUILD_HOOKS           ?=
324 $(2)_POST_INSTALL_HOOKS         ?=
325 $(2)_POST_INSTALL_STAGING_HOOKS ?=
326 $(2)_POST_INSTALL_TARGET_HOOKS  ?=
327 $(2)_POST_INSTALL_IMAGES_HOOKS  ?=
328 $(2)_POST_LEGAL_INFO_HOOKS      ?=
329
330 # human-friendly targets and target sequencing
331 $(1):                   $(1)-install
332
333 ifeq ($$($(2)_TYPE),host)
334 $(1)-install:           $(1)-install-host
335 else
336 $(1)-install:           $(1)-install-staging $(1)-install-target $(1)-install-images
337 endif
338
339 ifeq ($$($(2)_INSTALL_TARGET),YES)
340 $(1)-install-target:    $(1)-build \
341                         $$($(2)_TARGET_INSTALL_TARGET)
342 else
343 $(1)-install-target:
344 endif
345
346 ifeq ($$($(2)_INSTALL_STAGING),YES)
347 $(1)-install-staging:   $(1)-build \
348                         $$($(2)_TARGET_INSTALL_STAGING)
349 else
350 $(1)-install-staging:
351 endif
352
353 ifeq ($$($(2)_INSTALL_IMAGES),YES)
354 $(1)-install-images:    $(1)-build \
355                         $$($(2)_TARGET_INSTALL_IMAGES)
356 else
357 $(1)-install-images:
358 endif
359
360 $(1)-install-host:      $(1)-build $$($(2)_TARGET_INSTALL_HOST)
361
362 $(1)-build:             $(1)-configure \
363                         $$($(2)_TARGET_BUILD)
364
365 ifeq ($$($(2)_OVERRIDE_SRCDIR),)
366 # In the normal case (no package override), the sequence of steps is
367 #  source, by downloading
368 #  depends
369 #  extract
370 #  patch
371 #  configure
372 $(1)-configure:         $(1)-patch $(1)-depends \
373                         $$($(2)_TARGET_CONFIGURE)
374
375 $(1)-patch:             $(1)-extract $$($(2)_TARGET_PATCH)
376
377 $(1)-extract:           $(1)-source \
378                         $$($(2)_TARGET_EXTRACT)
379
380 $(1)-depends:           $$($(2)_DEPENDENCIES)
381
382 $(1)-source:            $$($(2)_TARGET_SOURCE)
383 else
384 # In the package override case, the sequence of steps
385 #  source, by rsyncing
386 #  depends
387 #  configure
388 $(1)-configure:         $(1)-depends \
389                         $$($(2)_TARGET_CONFIGURE)
390
391 $(1)-depends:           $(1)-rsync $$($(2)_DEPENDENCIES)
392
393 $(1)-patch:             $(1)-rsync
394 $(1)-extract:           $(1)-rsync
395
396 $(1)-rsync:             $$($(2)_TARGET_RSYNC)
397
398 $(1)-source:            $$($(2)_TARGET_RSYNC_SOURCE)
399 endif
400
401 $(1)-show-depends:
402                         @echo $$($(2)_DEPENDENCIES)
403
404 $(1)-uninstall:         $(1)-configure $$($(2)_TARGET_UNINSTALL)
405
406 $(1)-clean:             $(1)-uninstall \
407                         $$($(2)_TARGET_CLEAN)
408
409 $(1)-dirclean:          $$($(2)_TARGET_DIRCLEAN)
410
411 $(1)-clean-for-rebuild:
412 ifneq ($$($(2)_OVERRIDE_SRCDIR),)
413                         rm -f $$($(2)_TARGET_RSYNC)
414 endif
415                         rm -f $$($(2)_TARGET_BUILD)
416                         rm -f $$($(2)_TARGET_INSTALL_STAGING)
417                         rm -f $$($(2)_TARGET_INSTALL_TARGET)
418                         rm -f $$($(2)_TARGET_INSTALL_IMAGES)
419                         rm -f $$($(2)_TARGET_INSTALL_HOST)
420
421 $(1)-rebuild:           $(1)-clean-for-rebuild all
422
423 $(1)-clean-for-reconfigure: $(1)-clean-for-rebuild
424                         rm -f $$($(2)_TARGET_CONFIGURE)
425
426 $(1)-reconfigure:       $(1)-clean-for-reconfigure all
427
428 # define the PKG variable for all targets, containing the
429 # uppercase package variable prefix
430 $$($(2)_TARGET_INSTALL_TARGET):         PKG=$(2)
431 $$($(2)_TARGET_INSTALL_STAGING):        PKG=$(2)
432 $$($(2)_TARGET_INSTALL_IMAGES):         PKG=$(2)
433 $$($(2)_TARGET_INSTALL_HOST):           PKG=$(2)
434 $$($(2)_TARGET_BUILD):                  PKG=$(2)
435 $$($(2)_TARGET_CONFIGURE):              PKG=$(2)
436 $$($(2)_TARGET_RSYNC):                  SRCDIR=$$($(2)_OVERRIDE_SRCDIR)
437 $$($(2)_TARGET_RSYNC):                  PKG=$(2)
438 $$($(2)_TARGET_RSYNC_SOURCE):           SRCDIR=$$($(2)_OVERRIDE_SRCDIR)
439 $$($(2)_TARGET_RSYNC_SOURCE):           PKG=$(2)
440 $$($(2)_TARGET_PATCH):                  PKG=$(2)
441 $$($(2)_TARGET_PATCH):                  RAWNAME=$(patsubst host-%,%,$(1))
442 $$($(2)_TARGET_EXTRACT):                PKG=$(2)
443 $$($(2)_TARGET_SOURCE):                 PKG=$(2)
444 $$($(2)_TARGET_UNINSTALL):              PKG=$(2)
445 $$($(2)_TARGET_CLEAN):                  PKG=$(2)
446 $$($(2)_TARGET_DIRCLEAN):               PKG=$(2)
447
448 # Compute the name of the Kconfig option that correspond to the
449 # package being enabled. We handle three cases: the special Linux
450 # kernel case, the bootloaders case, and the normal packages case.
451 ifeq ($(1),linux)
452 $(2)_KCONFIG_VAR = BR2_LINUX_KERNEL
453 else ifeq ($(4),boot/)
454 $(2)_KCONFIG_VAR = BR2_TARGET_$(2)
455 else
456 $(2)_KCONFIG_VAR = BR2_PACKAGE_$(2)
457 endif
458
459 # legal-info: declare dependencies and set values used later for the manifest
460 ifneq ($$($(2)_LICENSE_FILES),)
461 $(2)_MANIFEST_LICENSE_FILES = $$($(2)_LICENSE_FILES)
462 endif
463 $(2)_MANIFEST_LICENSE_FILES ?= not saved
464
465 ifeq ($$($(2)_REDISTRIBUTE),YES)
466 ifneq ($$($(2)_SITE_METHOD),local)
467 ifneq ($$($(2)_SITE_METHOD),override)
468 # Packages that have a tarball need it downloaded and extracted beforehand
469 $(1)-legal-info: $(1)-extract $(REDIST_SOURCES_DIR)
470 $(2)_MANIFEST_TARBALL = $$($(2)_SOURCE)
471 endif
472 endif
473 endif
474 $(2)_MANIFEST_TARBALL ?= not saved
475
476 # legal-info: produce legally relevant info.
477 $(1)-legal-info:
478 # Packages without a source are assumed to be part of Buildroot, skip them.
479 ifneq ($(call qstrip,$$($(2)_SOURCE)),)
480 ifeq ($$($(2)_SITE_METHOD),local)
481 # Packages without a tarball: don't save and warn
482         @$(call legal-warning-pkg-savednothing,$$($(2)_RAWNAME),local)
483 else ifneq ($$($(2)_OVERRIDE_SRCDIR),)
484         @$(call legal-warning-pkg-savednothing,$$($(2)_RAWNAME),override)
485 else
486 # Other packages
487 # Save license files if defined
488 ifeq ($(call qstrip,$$($(2)_LICENSE_FILES)),)
489         @$(call legal-license-nofiles,$$($(2)_RAWNAME))
490         @$(call legal-warning-pkg,$$($(2)_RAWNAME),cannot save license ($(2)_LICENSE_FILES not defined))
491 else
492         @for F in $$($(2)_LICENSE_FILES); do \
493                 $(call legal-license-file,$$($(2)_RAWNAME),$$$${F},$$($(2)_DIR)/$$$${F}); \
494                 done
495 endif
496 ifeq ($$($(2)_REDISTRIBUTE),YES)
497 # Copy the source tarball (just hardlink if possible)
498         @cp -l $(DL_DIR)/$$($(2)_SOURCE) $(REDIST_SOURCES_DIR) 2>/dev/null || \
499            cp $(DL_DIR)/$$($(2)_SOURCE) $(REDIST_SOURCES_DIR)
500 endif
501 endif
502         @$(call legal-manifest,$$($(2)_RAWNAME),$$($(2)_VERSION),$$($(2)_LICENSE),$$($(2)_MANIFEST_LICENSE_FILES),$$($(2)_MANIFEST_TARBALL))
503 endif # ifneq ($(call qstrip,$$($(2)_SOURCE)),)
504         $(foreach hook,$($(2)_POST_LEGAL_INFO_HOOKS),$(call $(hook))$(sep))
505
506 # add package to the general list of targets if requested by the buildroot
507 # configuration
508 ifeq ($$($$($(2)_KCONFIG_VAR)),y)
509
510 TARGETS += $(1)
511 PACKAGES_PERMISSIONS_TABLE += $$($(2)_PERMISSIONS)$$(sep)
512 PACKAGES_DEVICES_TABLE += $$($(2)_DEVICES)$$(sep)
513
514 ifeq ($$($(2)_SITE_METHOD),svn)
515 DL_TOOLS_DEPENDENCIES += svn
516 else ifeq ($$($(2)_SITE_METHOD),git)
517 DL_TOOLS_DEPENDENCIES += git
518 else ifeq ($$($(2)_SITE_METHOD),bzr)
519 DL_TOOLS_DEPENDENCIES += bzr
520 else ifeq ($$($(2)_SITE_METHOD),scp)
521 DL_TOOLS_DEPENDENCIES += scp ssh
522 else ifeq ($$($(2)_SITE_METHOD),hg)
523 DL_TOOLS_DEPENDENCIES += hg
524 endif # SITE_METHOD
525
526 DL_TOOLS_DEPENDENCIES += $(firstword $(INFLATE$(suffix $($(2)_SOURCE))))
527
528 endif # $(2)_KCONFIG_VAR
529 endef # inner-generic-package
530
531 ################################################################################
532 # generic-package -- the target generator macro for generic packages
533 ################################################################################
534
535 # In the case of target packages, keep the package name "pkg"
536 generic-package = $(call inner-generic-package,$(call pkgname),$(call UPPERCASE,$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),target)
537 # In the case of host packages, turn the package name "pkg" into "host-pkg"
538 host-generic-package = $(call inner-generic-package,host-$(call pkgname),$(call UPPERCASE,host-$(call pkgname)),$(call UPPERCASE,$(call pkgname)),$(call pkgparentdir),host)
539
540 # :mode=makefile: