1 ################################################################################
2 # Generic package infrastructure
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).
10 # See the Buildroot documentation for details on the usage of this
13 # In terms of implementation, this generic infrastructure requires the
14 # .mk file to specify:
16 # 1. Metadata information about the package: name, version,
19 # 2. Description of the commands to be executed to configure, build
20 # and install the package
21 ################################################################################
23 ################################################################################
24 # Helper functions to catch start/end of each step
25 ################################################################################
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
31 # $1: either 'start' or 'end'
32 # $2: the name of the step
33 # $3: the name of the package
38 $(foreach hook
,$(GLOBAL_INSTRUMENTATION_HOOKS
),$(call
$(hook
),start
,$(1),$($(PKG
)_NAME
))$(sep
))
44 $(foreach hook
,$(GLOBAL_INSTRUMENTATION_HOOKS
),$(call
$(hook
),end
,$(1),$($(PKG
)_NAME
))$(sep
))
47 #######################################
52 printf
"%s:%-5.5s:%-20.20s: %s\n" \
53 "$$(date +%s)" "$(1)" "$(2)" "$(3)" \
54 >>"$(BUILD_DIR)/build-time.log"
56 GLOBAL_INSTRUMENTATION_HOOKS
+= step_time
58 # User-supplied script
59 ifneq ($(BR2_INSTRUMENTATION_SCRIPTS
),)
61 @
$(foreach user_hook
, $(BR2_INSTRUMENTATION_SCRIPTS
), \
62 $(EXTRA_ENV
) $(user_hook
) "$(1)" "$(2)" "$(3)"$(sep
))
64 GLOBAL_INSTRUMENTATION_HOOKS
+= step_user
67 ################################################################################
68 # Implicit targets -- produce a stamp file for each step of a package build
69 ################################################################################
71 # Retrieve the archive
72 $(BUILD_DIR
)/%/.stamp_downloaded
:
73 $(foreach hook
,$($(PKG
)_PRE_DOWNLOAD_HOOKS
),$(call
$(hook
))$(sep
))
74 ifeq ($(DL_MODE
),DOWNLOAD
)
75 # Only show the download message if it isn't already downloaded
76 $(Q
)if
test ! -e
$(DL_DIR
)/$($(PKG
)_SOURCE
); then \
77 $(call MESSAGE
,"Downloading") ; \
79 for p in
$($(PKG
)_PATCH
) ; do \
80 if
test ! -e
$(DL_DIR
)/$$p ; then \
81 $(call MESSAGE
,"Downloading") ; \
87 $(if
$($(PKG
)_SOURCE
),$(call DOWNLOAD
,$($(PKG
)_SITE
:/=)/$($(PKG
)_SOURCE
)))
88 $(foreach p
,$($(PKG
)_EXTRA_DOWNLOADS
),$(call DOWNLOAD
,$($(PKG
)_SITE
:/=)/$(p
))$(sep
))
89 $(foreach p
,$($(PKG
)_PATCH
),\
90 $(if
$(findstring ://,$(p
)),\
91 $(call DOWNLOAD
,$(p
)),\
92 $(call DOWNLOAD
,$($(PKG
)_SITE
:/=)/$(p
))\
95 $(foreach hook
,$($(PKG
)_POST_DOWNLOAD_HOOKS
),$(call
$(hook
))$(sep
))
96 ifeq ($(DL_MODE
),DOWNLOAD
)
102 $(BUILD_DIR
)/%/.stamp_extracted
:
103 @
$(call step_start
,extract
)
104 @
$(call MESSAGE
,"Extracting")
105 $(foreach hook
,$($(PKG
)_PRE_EXTRACT_HOOKS
),$(call
$(hook
))$(sep
))
107 $($(PKG
)_EXTRACT_CMDS
)
108 # some packages have messed up permissions inside
109 $(Q
)chmod
-R
+rw
$(@D
)
110 $(foreach hook
,$($(PKG
)_POST_EXTRACT_HOOKS
),$(call
$(hook
))$(sep
))
112 @
$(call step_end
,extract
)
114 # Rsync the source directory if the <pkg>_OVERRIDE_SRCDIR feature is
116 $(BUILD_DIR
)/%/.stamp_rsynced
:
117 @
$(call MESSAGE
,"Syncing from source dir $(SRCDIR)")
118 @
test -d
$(SRCDIR
) ||
(echo
"ERROR: $(SRCDIR) does not exist" ; exit
1)
119 $(foreach hook
,$($(PKG
)_PRE_RSYNC_HOOKS
),$(call
$(hook
))$(sep
))
120 rsync
-au
$(RSYNC_VCS_EXCLUSIONS
) $(SRCDIR
)/ $(@D
)
121 $(foreach hook
,$($(PKG
)_POST_RSYNC_HOOKS
),$(call
$(hook
))$(sep
))
124 # Handle the SOURCE_CHECK and SHOW_EXTERNAL_DEPS cases for rsynced
126 $(BUILD_DIR
)/%/.stamp_rsync_sourced
:
127 ifeq ($(DL_MODE
),SOURCE_CHECK
)
129 else ifeq ($(DL_MODE
),SHOW_EXTERNAL_DEPS
)
130 echo
"file://$(SRCDIR)"
132 @true
# Nothing to do to source a local package
137 # The RAWNAME variable is the lowercased package name, which allows to
138 # find the package directory (typically package/<pkgname>) and the
139 # prefix of the patches
141 # For BR2_GLOBAL_PATCH_DIR, only generate if it is defined
142 $(BUILD_DIR
)/%/.stamp_patched
: NAMEVER
= $(RAWNAME
)-$($(PKG
)_VERSION
)
143 $(BUILD_DIR
)/%/.stamp_patched
: PATCH_BASE_DIRS
= $(PKGDIR
)
144 $(BUILD_DIR
)/%/.stamp_patched
: PATCH_BASE_DIRS
+= $(addsuffix /$(RAWNAME
),$(call qstrip
,$(BR2_GLOBAL_PATCH_DIR
)))
145 $(BUILD_DIR
)/%/.stamp_patched
:
146 @
$(call step_start
,patch
)
147 @
$(call MESSAGE
,"Patching")
148 $(foreach hook
,$($(PKG
)_PRE_PATCH_HOOKS
),$(call
$(hook
))$(sep
))
149 $(foreach p
,$($(PKG
)_PATCH
),$(APPLY_PATCHES
) $(@D
) $(DL_DIR
) $(notdir $(p
))$(sep
))
151 for D in
$(PATCH_BASE_DIRS
); do \
152 if
test -d
$${D}; then \
153 if
test -d
$${D}/$($(PKG
)_VERSION
); then \
154 $(APPLY_PATCHES
) $(@D
) $${D}/$($(PKG
)_VERSION
) \
*.patch \
*.patch.
$(ARCH
) || exit
1; \
156 $(APPLY_PATCHES
) $(@D
) $${D} \
*.patch \
*.patch.
$(ARCH
) || exit
1; \
161 $(foreach hook
,$($(PKG
)_POST_PATCH_HOOKS
),$(call
$(hook
))$(sep
))
163 @
$(call step_end
,patch
)
165 # Check that all directories specified in BR2_GLOBAL_PATCH_DIR exist.
166 $(foreach dir,$(call qstrip
,$(BR2_GLOBAL_PATCH_DIR
)),\
167 $(if
$(wildcard $(dir)),,\
168 $(error BR2_GLOBAL_PATCH_DIR contains nonexistent directory
$(dir))))
171 $(BUILD_DIR
)/%/.stamp_configured
:
172 @
$(call step_start
,configure
)
173 @
$(call MESSAGE
,"Configuring")
174 $(foreach hook
,$($(PKG
)_PRE_CONFIGURE_HOOKS
),$(call
$(hook
))$(sep
))
175 $($(PKG
)_CONFIGURE_CMDS
)
176 $(foreach hook
,$($(PKG
)_POST_CONFIGURE_HOOKS
),$(call
$(hook
))$(sep
))
178 @
$(call step_end
,configure
)
181 $(BUILD_DIR
)/%/.stamp_built
::
182 @
$(call step_start
,build
)
183 @
$(call MESSAGE
,"Building")
184 $(foreach hook
,$($(PKG
)_PRE_BUILD_HOOKS
),$(call
$(hook
))$(sep
))
185 +$($(PKG
)_BUILD_CMDS
)
186 $(foreach hook
,$($(PKG
)_POST_BUILD_HOOKS
),$(call
$(hook
))$(sep
))
188 @
$(call step_end
,build
)
190 # Install to host dir
191 $(BUILD_DIR
)/%/.stamp_host_installed
:
192 @
$(call step_start
,install-host
)
193 @
$(call MESSAGE
,"Installing to host directory")
194 $(foreach hook
,$($(PKG
)_PRE_INSTALL_HOOKS
),$(call
$(hook
))$(sep
))
195 +$($(PKG
)_INSTALL_CMDS
)
196 $(foreach hook
,$($(PKG
)_POST_INSTALL_HOOKS
),$(call
$(hook
))$(sep
))
198 @
$(call step_end
,install-host
)
200 # Install to staging dir
201 $(BUILD_DIR
)/%/.stamp_staging_installed
:
202 @
$(call step_start
,install-staging
)
203 @
$(call MESSAGE
,"Installing to staging directory")
204 $(foreach hook
,$($(PKG
)_PRE_INSTALL_STAGING_HOOKS
),$(call
$(hook
))$(sep
))
205 +$($(PKG
)_INSTALL_STAGING_CMDS
)
206 $(foreach hook
,$($(PKG
)_POST_INSTALL_STAGING_HOOKS
),$(call
$(hook
))$(sep
))
207 $(Q
)if
test -n
"$($(PKG)_CONFIG_SCRIPTS)" ; then \
208 $(call MESSAGE
,"Fixing package configuration files") ;\
209 $(SED
) "s,$(BASE_DIR),@BASE_DIR@,g" \
210 -e
"s,$(STAGING_DIR),@STAGING_DIR@,g" \
211 -e
"s,^\(exec_\)\?prefix=.*,\1prefix=@STAGING_DIR@/usr,g" \
212 -e
"s,-I/usr/,-I@STAGING_DIR@/usr/,g" \
213 -e
"s,-L/usr/,-L@STAGING_DIR@/usr/,g" \
214 -e
"s,@STAGING_DIR@,$(STAGING_DIR),g" \
215 -e
"s,@BASE_DIR@,$(BASE_DIR),g" \
216 $(addprefix $(STAGING_DIR
)/usr
/bin
/,$($(PKG
)_CONFIG_SCRIPTS
)) ;\
219 @
$(call step_end
,install-staging
)
221 # Install to images dir
222 $(BUILD_DIR
)/%/.stamp_images_installed
:
223 @
$(call step_start
,install-image
)
224 $(foreach hook
,$($(PKG
)_PRE_INSTALL_IMAGES_HOOKS
),$(call
$(hook
))$(sep
))
225 @
$(call MESSAGE
,"Installing to images directory")
226 +$($(PKG
)_INSTALL_IMAGES_CMDS
)
227 $(foreach hook
,$($(PKG
)_POST_INSTALL_IMAGES_HOOKS
),$(call
$(hook
))$(sep
))
229 @
$(call step_end
,install-image
)
231 # Install to target dir
232 $(BUILD_DIR
)/%/.stamp_target_installed
:
233 @
$(call step_start
,install-target
)
234 @
$(call MESSAGE
,"Installing to target")
235 $(foreach hook
,$($(PKG
)_PRE_INSTALL_TARGET_HOOKS
),$(call
$(hook
))$(sep
))
236 +$($(PKG
)_INSTALL_TARGET_CMDS
)
237 $(if
$(BR2_INIT_SYSTEMD
),\
238 $($(PKG
)_INSTALL_INIT_SYSTEMD
))
239 $(if
$(BR2_INIT_SYSV
)$(BR2_INIT_BUSYBOX
),\
240 $($(PKG
)_INSTALL_INIT_SYSV
))
241 $(foreach hook
,$($(PKG
)_POST_INSTALL_TARGET_HOOKS
),$(call
$(hook
))$(sep
))
242 $(Q
)if
test -n
"$($(PKG)_CONFIG_SCRIPTS)" ; then \
243 $(RM
) -f
$(addprefix $(TARGET_DIR
)/usr
/bin
/,$($(PKG
)_CONFIG_SCRIPTS
)) ; \
246 @
$(call step_end
,install-target
)
248 # Remove package sources
249 $(BUILD_DIR
)/%/.stamp_dircleaned
:
252 ################################################################################
253 # virt-provides-single -- check that provider-pkg is the declared provider for
254 # the virtual package virt-pkg
256 # argument 1 is the lower-case name of the virtual package
257 # argument 2 is the upper-case name of the virtual package
258 # argument 3 is the lower-case name of the provider
261 # $(call virt-provides-single,libegl,LIBEGL,rpi-userland)
262 ################################################################################
263 define virt-provides-single
264 ifneq ($$(call qstrip
,$$(BR2_PACKAGE_PROVIDES_
$(2))),$(3))
265 $$(error Configuration error
: both
"$(3)" and
$$(BR2_PACKAGE_PROVIDES_
$(2))\
266 are selected
as providers for virtual package
"$(1)". Only one provider can\
267 be selected at a time. Please fix your configuration
)
271 ################################################################################
272 # inner-generic-package -- generates the make targets needed to build a
275 # argument 1 is the lowercase package name
276 # argument 2 is the uppercase package name, including a HOST_ prefix
278 # argument 3 is the uppercase package name, without the HOST_ prefix
280 # argument 4 is the type (target or host)
282 # Note about variable and function references: inside all blocks that are
283 # evaluated with $(eval), which includes all 'inner-xxx-package' blocks,
284 # specific rules apply with respect to variable and function references.
285 # - Numbered variables (parameters to the block) can be referenced with a single
286 # dollar sign: $(1), $(2), $(3), etc.
287 # - pkgdir and pkgname should be referenced with a single dollar sign too. These
288 # functions rely on 'the most recently parsed makefile' which is supposed to
289 # be the package .mk file. If we defer the evaluation of these functions using
290 # double dollar signs, then they may be evaluated too late, when other
291 # makefiles have already been parsed. One specific case is when $$(pkgdir) is
292 # assigned to a variable using deferred evaluation with '=' and this variable
293 # is used in a target rule outside the eval'ed inner block. In this case, the
294 # pkgdir will be that of the last makefile parsed by buildroot, which is not
295 # the expected value. This mechanism is for example used for the TARGET_PATCH
297 # - All other variables should be referenced with a double dollar sign:
298 # $$(TARGET_DIR), $$($(2)_VERSION), etc. Also all make functions should be
299 # referenced with a double dollar sign: $$(subst), $$(call), $$(filter-out),
300 # etc. This rule ensures that these variables and functions are only expanded
301 # during the $(eval) step, and not earlier. Otherwise, unintuitive and
302 # undesired behavior occurs with respect to these variables and functions.
304 ################################################################################
306 define inner-generic-package
308 # Define default values for various package-related variables, if not
309 # already defined. For some variables (version, source, site and
310 # subdir), if they are undefined, we try to see if a variable without
311 # the HOST_ prefix is defined. If so, we use such a variable, so that
312 # this information has only to be specified once, for both the
313 # target and host packages of a given .mk file.
317 $(2)_RAWNAME
= $$(patsubst host-
%,%,$(1))
319 # Keep the package version that may contain forward slashes in the _DL_VERSION
320 # variable, then replace all forward slashes ('/') by underscores ('_') to
321 # sanitize the package version that is used in paths, directory and file names.
322 # Forward slashes may appear in the package's version when pointing to a
323 # version control system branch or tag, for example remotes/origin/1_10_stable.
326 $(2)_DL_VERSION
:= $$(strip $$($(3)_VERSION
))
327 $(2)_VERSION
:= $$(subst /,_
,$$(strip $$($(3)_VERSION
)))
329 $(2)_VERSION
= undefined
330 $(2)_DL_VERSION
= undefined
333 $(2)_DL_VERSION
:= $$(strip $$($(2)_VERSION
))
334 $(2)_VERSION
:= $$(strip $$(subst /,_
,$$($(2)_VERSION
)))
337 $(2)_BASE_NAME
= $(1)-$$($(2)_VERSION
)
338 $(2)_DL_DIR
= $$(DL_DIR
)/$$($(2)_BASE_NAME
)
339 $(2)_DIR
= $$(BUILD_DIR
)/$$($(2)_BASE_NAME
)
343 $(2)_SUBDIR
= $$($(3)_SUBDIR
)
349 $(2)_SRCDIR
= $$($(2)_DIR
)/$$($(2)_SUBDIR
)
350 $(2)_BUILDDIR ?
= $$($(2)_SRCDIR
)
352 ifneq ($$($(2)_OVERRIDE_SRCDIR
),)
353 $(2)_VERSION
= custom
358 $(2)_SOURCE
= $$($(3)_SOURCE
)
360 $(2)_SOURCE ?
= $$($(2)_RAWNAME
)-$$($(2)_VERSION
).
tar.gz
366 $(2)_PATCH
= $$($(3)_PATCH
)
372 $(2)_SITE
= $$($(3)_SITE
)
376 ifndef $(2)_SITE_METHOD
377 ifdef $(3)_SITE_METHOD
378 $(2)_SITE_METHOD
= $$($(3)_SITE_METHOD
)
380 # Try automatic detection using the scheme part of the URI
381 $(2)_SITE_METHOD
= $$(call geturischeme
,$$($(2)_SITE
))
385 ifeq ($$($(2)_SITE_METHOD
),local
)
386 ifeq ($$($(2)_OVERRIDE_SRCDIR
),)
387 $(2)_OVERRIDE_SRCDIR
= $$($(2)_SITE
)
393 $(2)_LICENSE
= $$($(3)_LICENSE
)
397 $(2)_LICENSE ?
= unknown
399 ifndef $(2)_LICENSE_FILES
400 ifdef $(3)_LICENSE_FILES
401 $(2)_LICENSE_FILES
= $$($(3)_LICENSE_FILES
)
405 ifndef $(2)_REDISTRIBUTE
406 ifdef $(3)_REDISTRIBUTE
407 $(2)_REDISTRIBUTE
= $$($(3)_REDISTRIBUTE
)
411 $(2)_REDISTRIBUTE ?
= YES
413 # When a target package is a toolchain dependency set this variable to
414 # 'NO' so the 'toolchain' dependency is not added to prevent a circular
416 $(2)_ADD_TOOLCHAIN_DEPENDENCY ?
= YES
419 $(2)_DEPENDENCIES ?
= $$(filter-out host-toolchain
$(1),\
420 $$(patsubst host-host-
%,host-
%,$$(addprefix host-
,$$($(3)_DEPENDENCIES
))))
423 ifeq ($$($(2)_ADD_TOOLCHAIN_DEPENDENCY
),YES
)
424 $(2)_DEPENDENCIES
+= toolchain
428 # Eliminate duplicates in dependencies
429 $(2)_FINAL_DEPENDENCIES
= $$(sort $$($(2)_DEPENDENCIES
))
431 $(2)_INSTALL_STAGING ?
= NO
432 $(2)_INSTALL_IMAGES ?
= NO
433 $(2)_INSTALL_TARGET ?
= YES
435 # define sub-target stamps
436 $(2)_TARGET_INSTALL_TARGET
= $$($(2)_DIR
)/.stamp_target_installed
437 $(2)_TARGET_INSTALL_STAGING
= $$($(2)_DIR
)/.stamp_staging_installed
438 $(2)_TARGET_INSTALL_IMAGES
= $$($(2)_DIR
)/.stamp_images_installed
439 $(2)_TARGET_INSTALL_HOST
= $$($(2)_DIR
)/.stamp_host_installed
440 $(2)_TARGET_BUILD
= $$($(2)_DIR
)/.stamp_built
441 $(2)_TARGET_CONFIGURE
= $$($(2)_DIR
)/.stamp_configured
442 $(2)_TARGET_RSYNC
= $$($(2)_DIR
)/.stamp_rsynced
443 $(2)_TARGET_RSYNC_SOURCE
= $$($(2)_DIR
)/.stamp_rsync_sourced
444 $(2)_TARGET_PATCH
= $$($(2)_DIR
)/.stamp_patched
445 $(2)_TARGET_EXTRACT
= $$($(2)_DIR
)/.stamp_extracted
446 $(2)_TARGET_SOURCE
= $$($(2)_DIR
)/.stamp_downloaded
447 $(2)_TARGET_DIRCLEAN
= $$($(2)_DIR
)/.stamp_dircleaned
449 # default extract command
450 $(2)_EXTRACT_CMDS ?
= \
451 $$(if
$$($(2)_SOURCE
),$$(INFLATE
$$(suffix $$($(2)_SOURCE
))) $$(DL_DIR
)/$$($(2)_SOURCE
) | \
452 $$(TAR
) $$(TAR_STRIP_COMPONENTS
)=1 -C
$$($(2)_DIR
) $$(TAR_OPTIONS
) -)
454 # pre/post-steps hooks
455 $(2)_PRE_DOWNLOAD_HOOKS ?
=
456 $(2)_POST_DOWNLOAD_HOOKS ?
=
457 $(2)_PRE_EXTRACT_HOOKS ?
=
458 $(2)_POST_EXTRACT_HOOKS ?
=
459 $(2)_PRE_RSYNC_HOOKS ?
=
460 $(2)_POST_RSYNC_HOOKS ?
=
461 $(2)_PRE_PATCH_HOOKS ?
=
462 $(2)_POST_PATCH_HOOKS ?
=
463 $(2)_PRE_CONFIGURE_HOOKS ?
=
464 $(2)_POST_CONFIGURE_HOOKS ?
=
465 $(2)_PRE_BUILD_HOOKS ?
=
466 $(2)_POST_BUILD_HOOKS ?
=
467 $(2)_PRE_INSTALL_HOOKS ?
=
468 $(2)_POST_INSTALL_HOOKS ?
=
469 $(2)_PRE_INSTALL_STAGING_HOOKS ?
=
470 $(2)_POST_INSTALL_STAGING_HOOKS ?
=
471 $(2)_PRE_INSTALL_TARGET_HOOKS ?
=
472 $(2)_POST_INSTALL_TARGET_HOOKS ?
=
473 $(2)_PRE_INSTALL_IMAGES_HOOKS ?
=
474 $(2)_POST_INSTALL_IMAGES_HOOKS ?
=
475 $(2)_PRE_LEGAL_INFO_HOOKS ?
=
476 $(2)_POST_LEGAL_INFO_HOOKS ?
=
478 # human-friendly targets and target sequencing
481 ifeq ($$($(2)_TYPE
),host
)
482 $(1)-install: $(1)-install-host
484 $(1)-install: $(1)-install-staging
$(1)-install-target
$(1)-install-images
487 ifeq ($$($(2)_INSTALL_TARGET
),YES
)
488 $(1)-install-target
: $$($(2)_TARGET_INSTALL_TARGET
)
489 $$($(2)_TARGET_INSTALL_TARGET
): $$($(2)_TARGET_BUILD
)
494 ifeq ($$($(2)_INSTALL_STAGING
),YES
)
495 $(1)-install-staging
: $$($(2)_TARGET_INSTALL_STAGING
)
496 $$($(2)_TARGET_INSTALL_STAGING
): $$($(2)_TARGET_BUILD
)
497 # Some packages use install-staging stuff for install-target
498 $$($(2)_TARGET_INSTALL_TARGET
): $$($(2)_TARGET_INSTALL_STAGING
)
500 $(1)-install-staging
:
503 ifeq ($$($(2)_INSTALL_IMAGES
),YES
)
504 $(1)-install-images
: $$($(2)_TARGET_INSTALL_IMAGES
)
505 $$($(2)_TARGET_INSTALL_IMAGES
): $$($(2)_TARGET_BUILD
)
510 $(1)-install-host
: $$($(2)_TARGET_INSTALL_HOST
)
511 $$($(2)_TARGET_INSTALL_HOST
): $$($(2)_TARGET_BUILD
)
513 $(1)-build
: $$($(2)_TARGET_BUILD
)
514 $$($(2)_TARGET_BUILD
): $$($(2)_TARGET_CONFIGURE
)
516 # Since $(2)_FINAL_DEPENDENCIES are phony targets, they are always "newer"
517 # than $(2)_TARGET_CONFIGURE. This would force the configure step (and
518 # therefore the other steps as well) to be re-executed with every
519 # invocation of make. Therefore, make $(2)_FINAL_DEPENDENCIES an order-only
520 # dependency by using |.
522 $(1)-configure
: $$($(2)_TARGET_CONFIGURE
)
523 $$($(2)_TARGET_CONFIGURE
): |
$$($(2)_FINAL_DEPENDENCIES
)
525 $$($(2)_TARGET_SOURCE
) $$($(2)_TARGET_RSYNC
): | dirs prepare
526 ifeq ($$(filter $(1),$$(DEPENDENCIES_HOST_PREREQ
)),)
527 $$($(2)_TARGET_SOURCE
) $$($(2)_TARGET_RSYNC
): | dependencies
530 ifeq ($$($(2)_OVERRIDE_SRCDIR
),)
531 # In the normal case (no package override), the sequence of steps is
532 # source, by downloading
537 $$($(2)_TARGET_CONFIGURE
): $$($(2)_TARGET_PATCH
)
539 $(1)-patch
: $$($(2)_TARGET_PATCH
)
540 $$($(2)_TARGET_PATCH
): $$($(2)_TARGET_EXTRACT
)
542 $(1)-extract
: $$($(2)_TARGET_EXTRACT
)
543 $$($(2)_TARGET_EXTRACT
): $$($(2)_TARGET_SOURCE
)
545 $(1)-depends
: $$($(2)_FINAL_DEPENDENCIES
)
547 $(1)-source
: $$($(2)_TARGET_SOURCE
)
549 # In the package override case, the sequence of steps
550 # source, by rsyncing
554 # Use an order-only dependency so the "<pkg>-clean-for-rebuild" rule
555 # can remove the stamp file without triggering the configure step.
556 $$($(2)_TARGET_CONFIGURE
): |
$$($(2)_TARGET_RSYNC
)
558 $(1)-depends
: $$($(2)_FINAL_DEPENDENCIES
)
560 $(1)-patch
: $(1)-rsync
561 $(1)-extract
: $(1)-rsync
563 $(1)-rsync
: $$($(2)_TARGET_RSYNC
)
565 $(1)-source
: $$($(2)_TARGET_RSYNC_SOURCE
)
569 @echo
$$($(2)_FINAL_DEPENDENCIES
)
571 $(1)-graph-depends
: graph-depends-requirements
572 @
$$(INSTALL
) -d
$$(O
)/graphs
573 @cd
"$$(CONFIG_DIR)"; \
574 $$(TOPDIR
)/support
/scripts
/graph-depends
-p
$(1) $$(BR2_GRAPH_DEPS_OPTS
) \
575 |tee
$$(O
)/graphs
/$$(@
).dot \
576 |dot
$$(BR2_GRAPH_DOT_OPTS
) -T
$$(BR_GRAPH_OUT
) -o
$$(O
)/graphs
/$$(@
).
$$(BR_GRAPH_OUT
)
578 $(1)-dirclean
: $$($(2)_TARGET_DIRCLEAN
)
580 $(1)-clean-for-rebuild
:
581 ifneq ($$($(2)_OVERRIDE_SRCDIR
),)
582 rm -f
$$($(2)_TARGET_RSYNC
)
584 rm -f
$$($(2)_TARGET_BUILD
)
585 rm -f
$$($(2)_TARGET_INSTALL_STAGING
)
586 rm -f
$$($(2)_TARGET_INSTALL_TARGET
)
587 rm -f
$$($(2)_TARGET_INSTALL_IMAGES
)
588 rm -f
$$($(2)_TARGET_INSTALL_HOST
)
590 $(1)-rebuild
: $(1)-clean-for-rebuild
$(1)
592 $(1)-clean-for-reconfigure
: $(1)-clean-for-rebuild
593 rm -f
$$($(2)_TARGET_CONFIGURE
)
595 $(1)-reconfigure
: $(1)-clean-for-reconfigure
$(1)
597 # define the PKG variable for all targets, containing the
598 # uppercase package variable prefix
599 $$($(2)_TARGET_INSTALL_TARGET
): PKG
=$(2)
600 $$($(2)_TARGET_INSTALL_STAGING
): PKG
=$(2)
601 $$($(2)_TARGET_INSTALL_IMAGES
): PKG
=$(2)
602 $$($(2)_TARGET_INSTALL_HOST
): PKG
=$(2)
603 $$($(2)_TARGET_BUILD
): PKG
=$(2)
604 $$($(2)_TARGET_CONFIGURE
): PKG
=$(2)
605 $$($(2)_TARGET_RSYNC
): SRCDIR
=$$($(2)_OVERRIDE_SRCDIR
)
606 $$($(2)_TARGET_RSYNC
): PKG
=$(2)
607 $$($(2)_TARGET_RSYNC_SOURCE
): SRCDIR
=$$($(2)_OVERRIDE_SRCDIR
)
608 $$($(2)_TARGET_RSYNC_SOURCE
): PKG
=$(2)
609 $$($(2)_TARGET_PATCH
): PKG
=$(2)
610 $$($(2)_TARGET_PATCH
): RAWNAME
=$$(patsubst host-
%,%,$(1))
611 $$($(2)_TARGET_PATCH
): PKGDIR
=$(pkgdir
)
612 $$($(2)_TARGET_EXTRACT
): PKG
=$(2)
613 $$($(2)_TARGET_SOURCE
): PKG
=$(2)
614 $$($(2)_TARGET_SOURCE
): PKGDIR
=$(pkgdir
)
615 $$($(2)_TARGET_DIRCLEAN
): PKG
=$(2)
617 # Compute the name of the Kconfig option that correspond to the
618 # package being enabled. We handle three cases: the special Linux
619 # kernel case, the bootloaders case, and the normal packages case.
621 $(2)_KCONFIG_VAR
= BR2_LINUX_KERNEL
622 else ifneq ($$(filter boot
/%,$(pkgdir
)),)
623 $(2)_KCONFIG_VAR
= BR2_TARGET_
$(2)
624 else ifneq ($$(filter toolchain
/%,$(pkgdir
)),)
625 $(2)_KCONFIG_VAR
= BR2_
$(2)
627 $(2)_KCONFIG_VAR
= BR2_PACKAGE_
$(2)
630 # legal-info: declare dependencies and set values used later for the manifest
631 ifneq ($$($(2)_LICENSE_FILES
),)
632 $(2)_MANIFEST_LICENSE_FILES
= $$($(2)_LICENSE_FILES
)
634 $(2)_MANIFEST_LICENSE_FILES ?
= not saved
636 # If the package declares _LICENSE_FILES, we need to extract it,
637 # for overriden, local or normal remote packages alike, whether
638 # we want to redistribute it or not.
639 ifneq ($$($(2)_LICENSE_FILES
),)
640 $(1)-legal-info
: $(1)-patch
643 # We only save the sources of packages we want to redistribute, that are
644 # non-local, and non-overriden. So only store, in the manifest, the tarball
645 # name of those packages.
646 ifeq ($$($(2)_REDISTRIBUTE
),YES
)
647 ifneq ($$($(2)_SITE_METHOD
),local
)
648 ifneq ($$($(2)_SITE_METHOD
),override)
649 # Packages that have a tarball need it downloaded beforehand
650 $(1)-legal-info
: $(1)-source
$$(REDIST_SOURCES_DIR_
$$(call UPPERCASE
,$(4)))
651 $(2)_MANIFEST_TARBALL
= $$($(2)_SOURCE
)
652 $(2)_MANIFEST_SITE
= $$(call qstrip
,$$($(2)_SITE
))
656 $(2)_MANIFEST_TARBALL ?
= not saved
657 $(2)_MANIFEST_SITE ?
= not saved
659 # legal-info: produce legally relevant info.
661 # Packages without a source are assumed to be part of Buildroot, skip them.
662 $$(foreach hook
,$$($(2)_PRE_LEGAL_INFO_HOOKS
),$$(call
$$(hook
))$$(sep
))
663 ifneq ($$(call qstrip
,$$($(2)_SOURCE
)),)
665 # Save license files if defined
666 # We save the license files for any kind of package: normal, local,
667 # overridden, or non-redistributable alike.
668 # The reason to save license files even for no-redistribute packages
669 # is that the license still applies to the files distributed as part
670 # of the rootfs, even if the sources are not themselves redistributed.
671 ifeq ($$(call qstrip
,$$($(2)_LICENSE_FILES
)),)
672 @
$$(call legal-license-nofiles
,$$($(2)_RAWNAME
),$$(call UPPERCASE
,$(4)))
673 @
$$(call legal-warning-pkg
,$$($(2)_RAWNAME
),cannot save license
($(2)_LICENSE_FILES not defined
))
675 @
$$(foreach F
,$$($(2)_LICENSE_FILES
),$$(call legal-license-file
,$$($(2)_RAWNAME
),$$(F
),$$($(2)_DIR
)/$$(F
),$$(call UPPERCASE
,$(4)))$$(sep
))
676 endif # license files
678 ifeq ($$($(2)_SITE_METHOD
),local
)
679 # Packages without a tarball: don't save and warn
680 @
$$(call legal-warning-nosource
,$$($(2)_RAWNAME
),local
)
682 else ifneq ($$($(2)_OVERRIDE_SRCDIR
),)
683 @
$$(call legal-warning-nosource
,$$($(2)_RAWNAME
),override)
688 ifeq ($$($(2)_REDISTRIBUTE
),YES
)
689 # Copy the source tarball (just hardlink if possible)
690 @cp
-l
$$(DL_DIR
)/$$($(2)_SOURCE
) $$(REDIST_SOURCES_DIR_
$$(call UPPERCASE
,$(4))) 2>/dev
/null || \
691 cp
$$(DL_DIR
)/$$($(2)_SOURCE
) $$(REDIST_SOURCES_DIR_
$$(call UPPERCASE
,$(4)))
694 endif # other packages
695 @
$$(call legal-manifest
,$$($(2)_RAWNAME
),$$($(2)_VERSION
),$$($(2)_LICENSE
),$$($(2)_MANIFEST_LICENSE_FILES
),$$($(2)_MANIFEST_TARBALL
),$$($(2)_MANIFEST_SITE
),$$(call UPPERCASE
,$(4)))
696 endif # ifneq ($$(call qstrip,$$($(2)_SOURCE)),)
697 $$(foreach hook
,$$($(2)_POST_LEGAL_INFO_HOOKS
),$$(call
$$(hook
))$$(sep
))
699 # add package to the general list of targets if requested by the buildroot
701 ifeq ($$($$($(2)_KCONFIG_VAR
)),y
)
703 # Ensure the calling package is the declared provider for all the virtual
704 # packages it claims to be an implementation of.
705 ifneq ($$($(2)_PROVIDES
),)
706 $$(foreach pkg
,$$($(2)_PROVIDES
),\
707 $$(eval
$$(call virt-provides-single
,$$(pkg
),$$(call UPPERCASE
,$$(pkg
)),$(1))$$(sep
)))
710 # Ensure unified variable name conventions between all packages Some
711 # of the variables are used by more than one infrastructure; so,
712 # rather than duplicating the checks in each infrastructure, we check
713 # all variables here in pkg-generic, even though pkg-generic should
714 # have no knowledge of infra-specific variables.
715 $(eval
$(call check-deprecated-variable
,$(2)_MAKE_OPT
,$(2)_MAKE_OPTS
))
716 $(eval
$(call check-deprecated-variable
,$(2)_INSTALL_OPT
,$(2)_INSTALL_OPTS
))
717 $(eval
$(call check-deprecated-variable
,$(2)_INSTALL_TARGET_OPT
,$(2)_INSTALL_TARGET_OPTS
))
718 $(eval
$(call check-deprecated-variable
,$(2)_INSTALL_STAGING_OPT
,$(2)_INSTALL_STAGING_OPTS
))
719 $(eval
$(call check-deprecated-variable
,$(2)_INSTALL_HOST_OPT
,$(2)_INSTALL_HOST_OPTS
))
720 $(eval
$(call check-deprecated-variable
,$(2)_AUTORECONF_OPT
,$(2)_AUTORECONF_OPTS
))
721 $(eval
$(call check-deprecated-variable
,$(2)_CONF_OPT
,$(2)_CONF_OPTS
))
722 $(eval
$(call check-deprecated-variable
,$(2)_BUILD_OPT
,$(2)_BUILD_OPTS
))
723 $(eval
$(call check-deprecated-variable
,$(2)_GETTEXTIZE_OPT
,$(2)_GETTEXTIZE_OPTS
))
724 $(eval
$(call check-deprecated-variable
,$(2)_KCONFIG_OPT
,$(2)_KCONFIG_OPTS
))
728 ifneq ($$($(2)_PERMISSIONS
),)
729 PACKAGES_PERMISSIONS_TABLE
+= $$($(2)_PERMISSIONS
)$$(sep
)
731 ifneq ($$($(2)_DEVICES
),)
732 PACKAGES_DEVICES_TABLE
+= $$($(2)_DEVICES
)$$(sep
)
734 ifneq ($$($(2)_USERS
),)
735 PACKAGES_USERS
+= $$($(2)_USERS
)$$(sep
)
738 ifeq ($$($(2)_SITE_METHOD
),svn
)
739 DL_TOOLS_DEPENDENCIES
+= svn
740 else ifeq ($$($(2)_SITE_METHOD
),git
)
741 DL_TOOLS_DEPENDENCIES
+= git
742 else ifeq ($$($(2)_SITE_METHOD
),bzr
)
743 DL_TOOLS_DEPENDENCIES
+= bzr
744 else ifeq ($$($(2)_SITE_METHOD
),scp
)
745 DL_TOOLS_DEPENDENCIES
+= scp ssh
746 else ifeq ($$($(2)_SITE_METHOD
),hg
)
747 DL_TOOLS_DEPENDENCIES
+= hg
748 else ifeq ($$($(2)_SITE_METHOD
),cvs
)
749 DL_TOOLS_DEPENDENCIES
+= cvs
752 # $(firstword) is used here because the extractor can have arguments, like
753 # ZCAT="gzip -d -c", and to check for the dependency we only want 'gzip'.
754 # Do not add xzcat to the list of required dependencies, as it gets built
755 # automatically if it isn't found.
756 ifneq ($$(call suitable-extractor
,$$($(2)_SOURCE
)),$$(XZCAT
))
757 DL_TOOLS_DEPENDENCIES
+= $$(firstword $$(call suitable-extractor
,$$($(2)_SOURCE
)))
760 endif # $(2)_KCONFIG_VAR
761 endef # inner-generic-package
763 ################################################################################
764 # generic-package -- the target generator macro for generic packages
765 ################################################################################
767 # In the case of target packages, keep the package name "pkg"
768 generic-package
= $(call inner-generic-package
,$(pkgname
),$(call UPPERCASE
,$(pkgname
)),$(call UPPERCASE
,$(pkgname
)),target
)
769 # In the case of host packages, turn the package name "pkg" into "host-pkg"
770 host-generic-package
= $(call inner-generic-package
,host-
$(pkgname
),$(call UPPERCASE
,host-
$(pkgname
)),$(call UPPERCASE
,$(pkgname
)),host
)