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