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 # Only show the download message if it isn't already downloaded
75 $(Q
)for p in
$($(PKG
)_ALL_DOWNLOADS
); do \
76 if
test ! -e
$(DL_DIR
)/`basename $$p` ; then \
77 $(call MESSAGE
,"Downloading") ; \
81 $(foreach p
,$($(PKG
)_ALL_DOWNLOADS
),$(call DOWNLOAD
,$(p
))$(sep
))
82 $(foreach hook
,$($(PKG
)_POST_DOWNLOAD_HOOKS
),$(call
$(hook
))$(sep
))
87 $(BUILD_DIR
)/%/.stamp_extracted
:
88 @
$(call step_start
,extract
)
89 @
$(call MESSAGE
,"Extracting")
90 $(foreach hook
,$($(PKG
)_PRE_EXTRACT_HOOKS
),$(call
$(hook
))$(sep
))
92 $($(PKG
)_EXTRACT_CMDS
)
93 # some packages have messed up permissions inside
94 $(Q
)chmod
-R
+rw
$(@D
)
95 $(foreach hook
,$($(PKG
)_POST_EXTRACT_HOOKS
),$(call
$(hook
))$(sep
))
97 @
$(call step_end
,extract
)
99 # Rsync the source directory if the <pkg>_OVERRIDE_SRCDIR feature is
101 $(BUILD_DIR
)/%/.stamp_rsynced
:
102 @
$(call MESSAGE
,"Syncing from source dir $(SRCDIR)")
103 @
test -d
$(SRCDIR
) ||
(echo
"ERROR: $(SRCDIR) does not exist" ; exit
1)
104 $(foreach hook
,$($(PKG
)_PRE_RSYNC_HOOKS
),$(call
$(hook
))$(sep
))
105 rsync
-au
--chmod
=u
=rwX
,go
=rX
$(RSYNC_VCS_EXCLUSIONS
) $(call qstrip
,$(SRCDIR
))/ $(@D
)
106 $(foreach hook
,$($(PKG
)_POST_RSYNC_HOOKS
),$(call
$(hook
))$(sep
))
111 # The RAWNAME variable is the lowercased package name, which allows to
112 # find the package directory (typically package/<pkgname>) and the
113 # prefix of the patches
115 # For BR2_GLOBAL_PATCH_DIR, only generate if it is defined
116 $(BUILD_DIR
)/%/.stamp_patched
: NAMEVER
= $(RAWNAME
)-$($(PKG
)_VERSION
)
117 $(BUILD_DIR
)/%/.stamp_patched
: PATCH_BASE_DIRS
= $(PKGDIR
)
118 $(BUILD_DIR
)/%/.stamp_patched
: PATCH_BASE_DIRS
+= $(addsuffix /$(RAWNAME
),$(call qstrip
,$(BR2_GLOBAL_PATCH_DIR
)))
119 $(BUILD_DIR
)/%/.stamp_patched
:
120 @
$(call step_start
,patch
)
121 @
$(call MESSAGE
,"Patching")
122 $(foreach hook
,$($(PKG
)_PRE_PATCH_HOOKS
),$(call
$(hook
))$(sep
))
123 $(foreach p
,$($(PKG
)_PATCH
),$(APPLY_PATCHES
) $(@D
) $(DL_DIR
) $(notdir $(p
))$(sep
))
125 for D in
$(PATCH_BASE_DIRS
); do \
126 if
test -d
$${D}; then \
127 if
test -d
$${D}/$($(PKG
)_VERSION
); then \
128 $(APPLY_PATCHES
) $(@D
) $${D}/$($(PKG
)_VERSION
) \
*.patch \
*.patch.
$(ARCH
) || exit
1; \
130 $(APPLY_PATCHES
) $(@D
) $${D} \
*.patch \
*.patch.
$(ARCH
) || exit
1; \
135 $(foreach hook
,$($(PKG
)_POST_PATCH_HOOKS
),$(call
$(hook
))$(sep
))
137 @
$(call step_end
,patch
)
139 # Check that all directories specified in BR2_GLOBAL_PATCH_DIR exist.
140 $(foreach dir,$(call qstrip
,$(BR2_GLOBAL_PATCH_DIR
)),\
141 $(if
$(wildcard $(dir)),,\
142 $(error BR2_GLOBAL_PATCH_DIR contains nonexistent directory
$(dir))))
145 $(BUILD_DIR
)/%/.stamp_configured
:
146 @
$(call step_start
,configure
)
147 @
$(call MESSAGE
,"Configuring")
148 $(foreach hook
,$($(PKG
)_PRE_CONFIGURE_HOOKS
),$(call
$(hook
))$(sep
))
149 $($(PKG
)_CONFIGURE_CMDS
)
150 $(foreach hook
,$($(PKG
)_POST_CONFIGURE_HOOKS
),$(call
$(hook
))$(sep
))
152 @
$(call step_end
,configure
)
155 $(BUILD_DIR
)/%/.stamp_built
::
156 @
$(call step_start
,build
)
157 @
$(call MESSAGE
,"Building")
158 $(foreach hook
,$($(PKG
)_PRE_BUILD_HOOKS
),$(call
$(hook
))$(sep
))
159 +$($(PKG
)_BUILD_CMDS
)
160 $(foreach hook
,$($(PKG
)_POST_BUILD_HOOKS
),$(call
$(hook
))$(sep
))
162 @
$(call step_end
,build
)
164 # Install to host dir
165 $(BUILD_DIR
)/%/.stamp_host_installed
:
166 @
$(call step_start
,install-host
)
167 @
$(call MESSAGE
,"Installing to host directory")
168 $(foreach hook
,$($(PKG
)_PRE_INSTALL_HOOKS
),$(call
$(hook
))$(sep
))
169 +$($(PKG
)_INSTALL_CMDS
)
170 $(foreach hook
,$($(PKG
)_POST_INSTALL_HOOKS
),$(call
$(hook
))$(sep
))
172 @
$(call step_end
,install-host
)
174 # Install to staging dir
176 # Some packages install libtool .la files alongside any installed
177 # libraries. These .la files sometimes refer to paths relative to the
178 # sysroot, which libtool will interpret as absolute paths to host
179 # libraries instead of the target libraries. Since this is not what we
180 # want, these paths are fixed by prefixing them with $(STAGING_DIR).
181 # As we configure with --prefix=/usr, this fix needs to be applied to
182 # any path that starts with /usr.
184 # To protect against the case that the output or staging directories or
185 # the pre-installed external toolchain themselves are under /usr, we first
186 # substitute away any occurrences of these directories with @BASE_DIR@,
187 # @STAGING_DIR@ and @TOOLCHAIN_EXTERNAL_INSTALL_DIR@ respectively.
189 # Note that STAGING_DIR can be outside BASE_DIR when the user sets
190 # BR2_HOST_DIR to a custom value. Note that TOOLCHAIN_EXTERNAL_INSTALL_DIR
191 # can be under @BASE_DIR@ when it's a downloaded toolchain, and can be
192 # empty when we use an internal toolchain.
194 $(BUILD_DIR
)/%/.stamp_staging_installed
:
195 @
$(call step_start
,install-staging
)
196 @
$(call MESSAGE
,"Installing to staging directory")
197 $(foreach hook
,$($(PKG
)_PRE_INSTALL_STAGING_HOOKS
),$(call
$(hook
))$(sep
))
198 +$($(PKG
)_INSTALL_STAGING_CMDS
)
199 $(foreach hook
,$($(PKG
)_POST_INSTALL_STAGING_HOOKS
),$(call
$(hook
))$(sep
))
200 $(Q
)if
test -n
"$($(PKG)_CONFIG_SCRIPTS)" ; then \
201 $(call MESSAGE
,"Fixing package configuration files") ;\
202 $(SED
) "s,$(BASE_DIR),@BASE_DIR@,g" \
203 -e
"s,$(STAGING_DIR),@STAGING_DIR@,g" \
204 -e
"s,^\(exec_\)\?prefix=.*,\1prefix=@STAGING_DIR@/usr,g" \
205 -e
"s,-I/usr/,-I@STAGING_DIR@/usr/,g" \
206 -e
"s,-L/usr/,-L@STAGING_DIR@/usr/,g" \
207 -e
"s,@STAGING_DIR@,$(STAGING_DIR),g" \
208 -e
"s,@BASE_DIR@,$(BASE_DIR),g" \
209 $(addprefix $(STAGING_DIR
)/usr
/bin
/,$($(PKG
)_CONFIG_SCRIPTS
)) ;\
211 @
$(call MESSAGE
,"Fixing libtool files")
212 $(Q
)find
$(STAGING_DIR
)/usr
/lib
* -name
"*.la" | xargs
--no-run-if-empty \
213 $(SED
) "s:$(BASE_DIR):@BASE_DIR@:g" \
214 -e
"s:$(STAGING_DIR):@STAGING_DIR@:g" \
215 $(if
$(TOOLCHAIN_EXTERNAL_INSTALL_DIR
),\
216 -e
"s:$(TOOLCHAIN_EXTERNAL_INSTALL_DIR):@TOOLCHAIN_EXTERNAL_INSTALL_DIR@:g") \
217 -e
"s:\(['= ]\)/usr:\\1@STAGING_DIR@/usr:g" \
218 $(if
$(TOOLCHAIN_EXTERNAL_INSTALL_DIR
),\
219 -e
"s:@TOOLCHAIN_EXTERNAL_INSTALL_DIR@:$(TOOLCHAIN_EXTERNAL_INSTALL_DIR):g") \
220 -e
"s:@STAGING_DIR@:$(STAGING_DIR):g" \
221 -e
"s:@BASE_DIR@:$(BASE_DIR):g"
223 @
$(call step_end
,install-staging
)
225 # Install to images dir
226 $(BUILD_DIR
)/%/.stamp_images_installed
:
227 @
$(call step_start
,install-image
)
228 $(foreach hook
,$($(PKG
)_PRE_INSTALL_IMAGES_HOOKS
),$(call
$(hook
))$(sep
))
229 @
$(call MESSAGE
,"Installing to images directory")
230 +$($(PKG
)_INSTALL_IMAGES_CMDS
)
231 $(foreach hook
,$($(PKG
)_POST_INSTALL_IMAGES_HOOKS
),$(call
$(hook
))$(sep
))
233 @
$(call step_end
,install-image
)
235 # Install to target dir
236 $(BUILD_DIR
)/%/.stamp_target_installed
:
237 @
$(call step_start
,install-target
)
238 @
$(call MESSAGE
,"Installing to target")
239 $(foreach hook
,$($(PKG
)_PRE_INSTALL_TARGET_HOOKS
),$(call
$(hook
))$(sep
))
240 +$($(PKG
)_INSTALL_TARGET_CMDS
)
241 $(if
$(BR2_INIT_SYSTEMD
),\
242 $($(PKG
)_INSTALL_INIT_SYSTEMD
))
243 $(if
$(BR2_INIT_SYSV
)$(BR2_INIT_BUSYBOX
),\
244 $($(PKG
)_INSTALL_INIT_SYSV
))
245 $(foreach hook
,$($(PKG
)_POST_INSTALL_TARGET_HOOKS
),$(call
$(hook
))$(sep
))
246 $(Q
)if
test -n
"$($(PKG)_CONFIG_SCRIPTS)" ; then \
247 $(RM
) -f
$(addprefix $(TARGET_DIR
)/usr
/bin
/,$($(PKG
)_CONFIG_SCRIPTS
)) ; \
250 @
$(call step_end
,install-target
)
252 # Remove package sources
253 $(BUILD_DIR
)/%/.stamp_dircleaned
:
256 ################################################################################
257 # virt-provides-single -- check that provider-pkg is the declared provider for
258 # the virtual package virt-pkg
260 # argument 1 is the lower-case name of the virtual package
261 # argument 2 is the upper-case name of the virtual package
262 # argument 3 is the lower-case name of the provider
265 # $(call virt-provides-single,libegl,LIBEGL,rpi-userland)
266 ################################################################################
267 define virt-provides-single
268 ifneq ($$(call qstrip
,$$(BR2_PACKAGE_PROVIDES_
$(2))),$(3))
269 $$(error Configuration error
: both
"$(3)" and
$$(BR2_PACKAGE_PROVIDES_
$(2))\
270 are selected
as providers for virtual package
"$(1)". Only one provider can\
271 be selected at a time. Please fix your configuration
)
275 ################################################################################
276 # inner-generic-package -- generates the make targets needed to build a
279 # argument 1 is the lowercase package name
280 # argument 2 is the uppercase package name, including a HOST_ prefix
282 # argument 3 is the uppercase package name, without the HOST_ prefix
284 # argument 4 is the type (target or host)
286 # Note about variable and function references: inside all blocks that are
287 # evaluated with $(eval), which includes all 'inner-xxx-package' blocks,
288 # specific rules apply with respect to variable and function references.
289 # - Numbered variables (parameters to the block) can be referenced with a single
290 # dollar sign: $(1), $(2), $(3), etc.
291 # - pkgdir and pkgname should be referenced with a single dollar sign too. These
292 # functions rely on 'the most recently parsed makefile' which is supposed to
293 # be the package .mk file. If we defer the evaluation of these functions using
294 # double dollar signs, then they may be evaluated too late, when other
295 # makefiles have already been parsed. One specific case is when $$(pkgdir) is
296 # assigned to a variable using deferred evaluation with '=' and this variable
297 # is used in a target rule outside the eval'ed inner block. In this case, the
298 # pkgdir will be that of the last makefile parsed by buildroot, which is not
299 # the expected value. This mechanism is for example used for the TARGET_PATCH
301 # - All other variables should be referenced with a double dollar sign:
302 # $$(TARGET_DIR), $$($(2)_VERSION), etc. Also all make functions should be
303 # referenced with a double dollar sign: $$(subst), $$(call), $$(filter-out),
304 # etc. This rule ensures that these variables and functions are only expanded
305 # during the $(eval) step, and not earlier. Otherwise, unintuitive and
306 # undesired behavior occurs with respect to these variables and functions.
308 ################################################################################
310 define inner-generic-package
312 # Define default values for various package-related variables, if not
313 # already defined. For some variables (version, source, site and
314 # subdir), if they are undefined, we try to see if a variable without
315 # the HOST_ prefix is defined. If so, we use such a variable, so that
316 # this information has only to be specified once, for both the
317 # target and host packages of a given .mk file.
321 $(2)_RAWNAME
= $$(patsubst host-
%,%,$(1))
323 # Keep the package version that may contain forward slashes in the _DL_VERSION
324 # variable, then replace all forward slashes ('/') by underscores ('_') to
325 # sanitize the package version that is used in paths, directory and file names.
326 # Forward slashes may appear in the package's version when pointing to a
327 # version control system branch or tag, for example remotes/origin/1_10_stable.
328 # Similar for spaces and colons (:) that may appear in date-based revisions for
331 ifdef $(3)_DL_VERSION
332 $(2)_DL_VERSION
:= $$($(3)_DL_VERSION
)
333 else ifdef $(3)_VERSION
334 $(2)_DL_VERSION
:= $$($(3)_VERSION
)
336 $(2)_DL_VERSION
= undefined
339 $(2)_DL_VERSION
:= $$(strip $$($(2)_VERSION
))
341 $(2)_VERSION
:= $$(call sanitize
,$$($(2)_DL_VERSION
))
343 ifdef $(3)_OVERRIDE_SRCDIR
344 $(2)_OVERRIDE_SRCDIR ?
= $$($(3)_OVERRIDE_SRCDIR
)
347 $(2)_BASE_NAME
= $(1)-$$($(2)_VERSION
)
348 $(2)_DL_DIR
= $$(DL_DIR
)/$$($(2)_BASE_NAME
)
349 $(2)_DIR
= $$(BUILD_DIR
)/$$($(2)_BASE_NAME
)
353 $(2)_SUBDIR
= $$($(3)_SUBDIR
)
359 ifndef $(2)_STRIP_COMPONENTS
360 ifdef $(3)_STRIP_COMPONENTS
361 $(2)_STRIP_COMPONENTS
= $$($(3)_STRIP_COMPONENTS
)
363 $(2)_STRIP_COMPONENTS ?
= 1
367 $(2)_SRCDIR
= $$($(2)_DIR
)/$$($(2)_SUBDIR
)
368 $(2)_BUILDDIR ?
= $$($(2)_SRCDIR
)
370 ifneq ($$($(2)_OVERRIDE_SRCDIR
),)
371 $(2)_VERSION
= custom
376 $(2)_SOURCE
= $$($(3)_SOURCE
)
378 $(2)_SOURCE ?
= $$($(2)_RAWNAME
)-$$($(2)_VERSION
).
tar.gz
384 $(2)_PATCH
= $$($(3)_PATCH
)
388 $(2)_ALL_DOWNLOADS
= \
389 $$(foreach p
,$$($(2)_SOURCE
) $$($(2)_PATCH
) $$($(2)_EXTRA_DOWNLOADS
),\
390 $$(if
$$(findstring ://,$$(p
)),$$(p
),\
391 $$($(2)_SITE
:/=)/$$(p
)))
395 $(2)_SITE
= $$($(3)_SITE
)
399 ifndef $(2)_SITE_METHOD
400 ifdef $(3)_SITE_METHOD
401 $(2)_SITE_METHOD
= $$($(3)_SITE_METHOD
)
403 # Try automatic detection using the scheme part of the URI
404 $(2)_SITE_METHOD
= $$(call geturischeme
,$$($(2)_SITE
))
408 ifeq ($$($(2)_SITE_METHOD
),local
)
409 ifeq ($$($(2)_OVERRIDE_SRCDIR
),)
410 $(2)_OVERRIDE_SRCDIR
= $$($(2)_SITE
)
416 $(2)_LICENSE
= $$($(3)_LICENSE
)
420 $(2)_LICENSE ?
= unknown
422 ifndef $(2)_LICENSE_FILES
423 ifdef $(3)_LICENSE_FILES
424 $(2)_LICENSE_FILES
= $$($(3)_LICENSE_FILES
)
428 ifndef $(2)_REDISTRIBUTE
429 ifdef $(3)_REDISTRIBUTE
430 $(2)_REDISTRIBUTE
= $$($(3)_REDISTRIBUTE
)
434 $(2)_REDISTRIBUTE ?
= YES
436 # When a target package is a toolchain dependency set this variable to
437 # 'NO' so the 'toolchain' dependency is not added to prevent a circular
439 $(2)_ADD_TOOLCHAIN_DEPENDENCY ?
= YES
442 $(2)_DEPENDENCIES ?
= $$(filter-out host-skeleton host-toolchain
$(1),\
443 $$(patsubst host-host-
%,host-
%,$$(addprefix host-
,$$($(3)_DEPENDENCIES
))))
446 ifneq ($(1),skeleton
)
447 $(2)_DEPENDENCIES
+= skeleton
449 ifeq ($$($(2)_ADD_TOOLCHAIN_DEPENDENCY
),YES
)
450 $(2)_DEPENDENCIES
+= toolchain
454 # Eliminate duplicates in dependencies
455 $(2)_FINAL_DEPENDENCIES
= $$(sort $$($(2)_DEPENDENCIES
))
456 $(2)_FINAL_PATCH_DEPENDENCIES
= $$(sort $$($(2)_PATCH_DEPENDENCIES
))
457 $(2)_FINAL_ALL_DEPENDENCIES
= $$(sort $$($(2)_FINAL_DEPENDENCIES
) $$($(2)_FINAL_PATCH_DEPENDENCIES
))
459 $(2)_INSTALL_STAGING ?
= NO
460 $(2)_INSTALL_IMAGES ?
= NO
461 $(2)_INSTALL_TARGET ?
= YES
463 # define sub-target stamps
464 $(2)_TARGET_INSTALL_TARGET
= $$($(2)_DIR
)/.stamp_target_installed
465 $(2)_TARGET_INSTALL_STAGING
= $$($(2)_DIR
)/.stamp_staging_installed
466 $(2)_TARGET_INSTALL_IMAGES
= $$($(2)_DIR
)/.stamp_images_installed
467 $(2)_TARGET_INSTALL_HOST
= $$($(2)_DIR
)/.stamp_host_installed
468 $(2)_TARGET_BUILD
= $$($(2)_DIR
)/.stamp_built
469 $(2)_TARGET_CONFIGURE
= $$($(2)_DIR
)/.stamp_configured
470 $(2)_TARGET_RSYNC
= $$($(2)_DIR
)/.stamp_rsynced
471 $(2)_TARGET_PATCH
= $$($(2)_DIR
)/.stamp_patched
472 $(2)_TARGET_EXTRACT
= $$($(2)_DIR
)/.stamp_extracted
473 $(2)_TARGET_SOURCE
= $$($(2)_DIR
)/.stamp_downloaded
474 $(2)_TARGET_DIRCLEAN
= $$($(2)_DIR
)/.stamp_dircleaned
476 # default extract command
477 $(2)_EXTRACT_CMDS ?
= \
478 $$(if
$$($(2)_SOURCE
),$$(INFLATE
$$(suffix $$($(2)_SOURCE
))) $$(DL_DIR
)/$$($(2)_SOURCE
) | \
479 $$(TAR
) --strip-components
=$$($(2)_STRIP_COMPONENTS
) -C
$$($(2)_DIR
) $$(TAR_OPTIONS
) -)
481 # pre/post-steps hooks
482 $(2)_PRE_DOWNLOAD_HOOKS ?
=
483 $(2)_POST_DOWNLOAD_HOOKS ?
=
484 $(2)_PRE_EXTRACT_HOOKS ?
=
485 $(2)_POST_EXTRACT_HOOKS ?
=
486 $(2)_PRE_RSYNC_HOOKS ?
=
487 $(2)_POST_RSYNC_HOOKS ?
=
488 $(2)_PRE_PATCH_HOOKS ?
=
489 $(2)_POST_PATCH_HOOKS ?
=
490 $(2)_PRE_CONFIGURE_HOOKS ?
=
491 $(2)_POST_CONFIGURE_HOOKS ?
=
492 $(2)_PRE_BUILD_HOOKS ?
=
493 $(2)_POST_BUILD_HOOKS ?
=
494 $(2)_PRE_INSTALL_HOOKS ?
=
495 $(2)_POST_INSTALL_HOOKS ?
=
496 $(2)_PRE_INSTALL_STAGING_HOOKS ?
=
497 $(2)_POST_INSTALL_STAGING_HOOKS ?
=
498 $(2)_PRE_INSTALL_TARGET_HOOKS ?
=
499 $(2)_POST_INSTALL_TARGET_HOOKS ?
=
500 $(2)_PRE_INSTALL_IMAGES_HOOKS ?
=
501 $(2)_POST_INSTALL_IMAGES_HOOKS ?
=
502 $(2)_PRE_LEGAL_INFO_HOOKS ?
=
503 $(2)_POST_LEGAL_INFO_HOOKS ?
=
505 # human-friendly targets and target sequencing
508 ifeq ($$($(2)_TYPE
),host
)
509 $(1)-install: $(1)-install-host
511 $(1)-install: $(1)-install-staging
$(1)-install-target
$(1)-install-images
514 ifeq ($$($(2)_INSTALL_TARGET
),YES
)
515 $(1)-install-target
: $$($(2)_TARGET_INSTALL_TARGET
)
516 $$($(2)_TARGET_INSTALL_TARGET
): $$($(2)_TARGET_BUILD
)
521 ifeq ($$($(2)_INSTALL_STAGING
),YES
)
522 $(1)-install-staging
: $$($(2)_TARGET_INSTALL_STAGING
)
523 $$($(2)_TARGET_INSTALL_STAGING
): $$($(2)_TARGET_BUILD
)
524 # Some packages use install-staging stuff for install-target
525 $$($(2)_TARGET_INSTALL_TARGET
): $$($(2)_TARGET_INSTALL_STAGING
)
527 $(1)-install-staging
:
530 ifeq ($$($(2)_INSTALL_IMAGES
),YES
)
531 $(1)-install-images
: $$($(2)_TARGET_INSTALL_IMAGES
)
532 $$($(2)_TARGET_INSTALL_IMAGES
): $$($(2)_TARGET_BUILD
)
537 $(1)-install-host
: $$($(2)_TARGET_INSTALL_HOST
)
538 $$($(2)_TARGET_INSTALL_HOST
): $$($(2)_TARGET_BUILD
)
540 $(1)-build
: $$($(2)_TARGET_BUILD
)
541 $$($(2)_TARGET_BUILD
): $$($(2)_TARGET_CONFIGURE
)
543 # Since $(2)_FINAL_DEPENDENCIES are phony targets, they are always "newer"
544 # than $(2)_TARGET_CONFIGURE. This would force the configure step (and
545 # therefore the other steps as well) to be re-executed with every
546 # invocation of make. Therefore, make $(2)_FINAL_DEPENDENCIES an order-only
547 # dependency by using |.
549 $(1)-configure
: $$($(2)_TARGET_CONFIGURE
)
550 $$($(2)_TARGET_CONFIGURE
): |
$$($(2)_FINAL_DEPENDENCIES
)
552 $$($(2)_TARGET_SOURCE
) $$($(2)_TARGET_RSYNC
): | dirs prepare
553 ifeq ($$(filter $(1),$$(DEPENDENCIES_HOST_PREREQ
)),)
554 $$($(2)_TARGET_SOURCE
) $$($(2)_TARGET_RSYNC
): | dependencies
557 ifeq ($$($(2)_OVERRIDE_SRCDIR
),)
558 # In the normal case (no package override), the sequence of steps is
559 # source, by downloading
564 $$($(2)_TARGET_CONFIGURE
): $$($(2)_TARGET_PATCH
)
566 $(1)-patch
: $$($(2)_TARGET_PATCH
)
567 $$($(2)_TARGET_PATCH
): $$($(2)_TARGET_EXTRACT
)
568 # Order-only dependency
569 $$($(2)_TARGET_PATCH
): |
$$(patsubst %,%-patch
,$$($(2)_FINAL_PATCH_DEPENDENCIES
))
571 $(1)-extract
: $$($(2)_TARGET_EXTRACT
)
572 $$($(2)_TARGET_EXTRACT
): $$($(2)_TARGET_SOURCE
)
574 $(1)-depends
: $$($(2)_FINAL_DEPENDENCIES
)
576 $(1)-source
: $$($(2)_TARGET_SOURCE
)
579 $$(foreach p
,$$($(2)_ALL_DOWNLOADS
),$$(call SOURCE_CHECK
,$$(p
))$$(sep
))
582 @for p in
$$($(2)_SOURCE
) $$($(2)_PATCH
) $$($(2)_EXTRA_DOWNLOADS
) ; do \
583 echo
`basename $$$$p` ; \
586 # In the package override case, the sequence of steps
587 # source, by rsyncing
591 # Use an order-only dependency so the "<pkg>-clean-for-rebuild" rule
592 # can remove the stamp file without triggering the configure step.
593 $$($(2)_TARGET_CONFIGURE
): |
$$($(2)_TARGET_RSYNC
)
595 $(1)-depends
: $$($(2)_FINAL_DEPENDENCIES
)
597 $(1)-patch
: $(1)-rsync
598 $(1)-extract
: $(1)-rsync
600 $(1)-rsync
: $$($(2)_TARGET_RSYNC
)
605 test -d
$$($(2)_OVERRIDE_SRCDIR
)
608 @echo
"file://$$($(2)_OVERRIDE_SRCDIR)"
612 @echo
$$($(2)_VERSION
)
615 @echo
$$($(2)_FINAL_ALL_DEPENDENCIES
)
617 $(1)-graph-depends
: graph-depends-requirements
618 @
$$(INSTALL
) -d
$$(GRAPHS_DIR
)
619 @cd
"$$(CONFIG_DIR)"; \
620 $$(TOPDIR
)/support
/scripts
/graph-depends
-p
$(1) $$(BR2_GRAPH_DEPS_OPTS
) \
621 |tee
$$(GRAPHS_DIR
)/$$(@
).dot \
622 |dot
$$(BR2_GRAPH_DOT_OPTS
) -T
$$(BR_GRAPH_OUT
) -o
$$(GRAPHS_DIR
)/$$(@
).
$$(BR_GRAPH_OUT
)
624 $(1)-all-source
: $(1)-source
625 $(1)-all-source
: $$(foreach p
,$$($(2)_FINAL_ALL_DEPENDENCIES
),$$(p
)-all-source
)
627 $(1)-all-source-check
: $(1)-source-check
628 $(1)-all-source-check
: $$(foreach p
,$$($(2)_FINAL_ALL_DEPENDENCIES
),$$(p
)-all-source-check
)
630 $(1)-all-external-deps
: $(1)-external-deps
631 $(1)-all-external-deps
: $$(foreach p
,$$($(2)_FINAL_ALL_DEPENDENCIES
),$$(p
)-all-external-deps
)
633 $(1)-all-legal-info
: $(1)-legal-info
634 $(1)-all-legal-info
: $$(foreach p
,$$($(2)_FINAL_ALL_DEPENDENCIES
),$$(p
)-all-legal-info
)
636 $(1)-dirclean
: $$($(2)_TARGET_DIRCLEAN
)
638 $(1)-clean-for-reinstall
:
639 ifneq ($$($(2)_OVERRIDE_SRCDIR
),)
640 rm -f
$$($(2)_TARGET_RSYNC
)
642 rm -f
$$($(2)_TARGET_INSTALL_STAGING
)
643 rm -f
$$($(2)_TARGET_INSTALL_TARGET
)
644 rm -f
$$($(2)_TARGET_INSTALL_IMAGES
)
645 rm -f
$$($(2)_TARGET_INSTALL_HOST
)
647 $(1)-reinstall
: $(1)-clean-for-reinstall
$(1)
649 $(1)-clean-for-rebuild
: $(1)-clean-for-reinstall
650 rm -f
$$($(2)_TARGET_BUILD
)
652 $(1)-rebuild
: $(1)-clean-for-rebuild
$(1)
654 $(1)-clean-for-reconfigure
: $(1)-clean-for-rebuild
655 rm -f
$$($(2)_TARGET_CONFIGURE
)
657 $(1)-reconfigure
: $(1)-clean-for-reconfigure
$(1)
659 # define the PKG variable for all targets, containing the
660 # uppercase package variable prefix
661 $$($(2)_TARGET_INSTALL_TARGET
): PKG
=$(2)
662 $$($(2)_TARGET_INSTALL_STAGING
): PKG
=$(2)
663 $$($(2)_TARGET_INSTALL_IMAGES
): PKG
=$(2)
664 $$($(2)_TARGET_INSTALL_HOST
): PKG
=$(2)
665 $$($(2)_TARGET_BUILD
): PKG
=$(2)
666 $$($(2)_TARGET_CONFIGURE
): PKG
=$(2)
667 $$($(2)_TARGET_RSYNC
): SRCDIR
=$$($(2)_OVERRIDE_SRCDIR
)
668 $$($(2)_TARGET_RSYNC
): PKG
=$(2)
669 $$($(2)_TARGET_PATCH
): PKG
=$(2)
670 $$($(2)_TARGET_PATCH
): RAWNAME
=$$(patsubst host-
%,%,$(1))
671 $$($(2)_TARGET_PATCH
): PKGDIR
=$(pkgdir
)
672 $$($(2)_TARGET_EXTRACT
): PKG
=$(2)
673 $$($(2)_TARGET_SOURCE
): PKG
=$(2)
674 $$($(2)_TARGET_SOURCE
): PKGDIR
=$(pkgdir
)
675 $$($(2)_TARGET_DIRCLEAN
): PKG
=$(2)
677 # Compute the name of the Kconfig option that correspond to the
678 # package being enabled. We handle three cases: the special Linux
679 # kernel case, the bootloaders case, and the normal packages case.
681 $(2)_KCONFIG_VAR
= BR2_LINUX_KERNEL
682 else ifneq ($$(filter boot
/% $(BR2_EXTERNAL
)/boot
/%,$(pkgdir
)),)
683 $(2)_KCONFIG_VAR
= BR2_TARGET_
$(2)
684 else ifneq ($$(filter toolchain
/% $(BR2_EXTERNAL
)/toolchain
/%,$(pkgdir
)),)
685 $(2)_KCONFIG_VAR
= BR2_
$(2)
687 $(2)_KCONFIG_VAR
= BR2_PACKAGE_
$(2)
690 # legal-info: declare dependencies and set values used later for the manifest
691 ifneq ($$($(2)_LICENSE_FILES
),)
692 $(2)_MANIFEST_LICENSE_FILES
= $$($(2)_LICENSE_FILES
)
694 $(2)_MANIFEST_LICENSE_FILES ?
= not saved
696 # If the package declares _LICENSE_FILES, we need to extract it,
697 # for overriden, local or normal remote packages alike, whether
698 # we want to redistribute it or not.
699 ifneq ($$($(2)_LICENSE_FILES
),)
700 $(1)-legal-info
: $(1)-patch
703 # We only save the sources of packages we want to redistribute, that are
704 # non-local, and non-overriden. So only store, in the manifest, the tarball
705 # name of those packages.
706 ifeq ($$($(2)_REDISTRIBUTE
),YES
)
707 ifneq ($$($(2)_SITE_METHOD
),local
)
708 ifneq ($$($(2)_SITE_METHOD
),override)
709 # Packages that have a tarball need it downloaded beforehand
710 $(1)-legal-info
: $(1)-source
$$(REDIST_SOURCES_DIR_
$$(call UPPERCASE
,$(4)))
711 $(2)_MANIFEST_TARBALL
= $$($(2)_SOURCE
)
712 $(2)_MANIFEST_SITE
= $$(call qstrip
,$$($(2)_SITE
))
717 # legal-info: produce legally relevant info.
719 # Packages without a source are assumed to be part of Buildroot, skip them.
720 $$(foreach hook
,$$($(2)_PRE_LEGAL_INFO_HOOKS
),$$(call
$$(hook
))$$(sep
))
721 ifneq ($$(call qstrip
,$$($(2)_SOURCE
)),)
723 # Save license files if defined
724 # We save the license files for any kind of package: normal, local,
725 # overridden, or non-redistributable alike.
726 # The reason to save license files even for no-redistribute packages
727 # is that the license still applies to the files distributed as part
728 # of the rootfs, even if the sources are not themselves redistributed.
729 ifeq ($$(call qstrip
,$$($(2)_LICENSE_FILES
)),)
730 @
$$(call legal-license-nofiles
,$$($(2)_RAWNAME
),$$(call UPPERCASE
,$(4)))
731 @
$$(call legal-warning-pkg
,$$($(2)_RAWNAME
),cannot save license
($(2)_LICENSE_FILES not defined
))
733 @
$$(foreach F
,$$($(2)_LICENSE_FILES
),$$(call legal-license-file
,$$($(2)_RAWNAME
),$$(F
),$$($(2)_DIR
)/$$(F
),$$(call UPPERCASE
,$(4)))$$(sep
))
734 endif # license files
736 ifeq ($$($(2)_SITE_METHOD
),local
)
737 # Packages without a tarball: don't save and warn
738 @
$$(call legal-warning-nosource
,$$($(2)_RAWNAME
),local
)
740 else ifneq ($$($(2)_OVERRIDE_SRCDIR
),)
741 @
$$(call legal-warning-nosource
,$$($(2)_RAWNAME
),override)
746 ifeq ($$($(2)_REDISTRIBUTE
),YES
)
747 # Copy the source tarball (just hardlink if possible)
748 @cp
-l
$$(DL_DIR
)/$$($(2)_SOURCE
) $$(REDIST_SOURCES_DIR_
$$(call UPPERCASE
,$(4))) 2>/dev
/null || \
749 cp
$$(DL_DIR
)/$$($(2)_SOURCE
) $$(REDIST_SOURCES_DIR_
$$(call UPPERCASE
,$(4)))
752 endif # other packages
753 @
$$(call legal-manifest
,$$($(2)_RAWNAME
),$$($(2)_VERSION
),$$($(2)_LICENSE
),$$($(2)_MANIFEST_LICENSE_FILES
),$$($(2)_MANIFEST_TARBALL
),$$($(2)_MANIFEST_SITE
),$$(call UPPERCASE
,$(4)))
754 endif # ifneq ($$(call qstrip,$$($(2)_SOURCE)),)
755 $$(foreach hook
,$$($(2)_POST_LEGAL_INFO_HOOKS
),$$(call
$$(hook
))$$(sep
))
757 # add package to the general list of targets if requested by the buildroot
759 ifeq ($$($$($(2)_KCONFIG_VAR
)),y
)
761 # Ensure the calling package is the declared provider for all the virtual
762 # packages it claims to be an implementation of.
763 ifneq ($$($(2)_PROVIDES
),)
764 $$(foreach pkg
,$$($(2)_PROVIDES
),\
765 $$(eval
$$(call virt-provides-single
,$$(pkg
),$$(call UPPERCASE
,$$(pkg
)),$(1))$$(sep
)))
768 # Ensure unified variable name conventions between all packages Some
769 # of the variables are used by more than one infrastructure; so,
770 # rather than duplicating the checks in each infrastructure, we check
771 # all variables here in pkg-generic, even though pkg-generic should
772 # have no knowledge of infra-specific variables.
773 $(eval
$(call check-deprecated-variable
,$(2)_MAKE_OPT
,$(2)_MAKE_OPTS
))
774 $(eval
$(call check-deprecated-variable
,$(2)_INSTALL_OPT
,$(2)_INSTALL_OPTS
))
775 $(eval
$(call check-deprecated-variable
,$(2)_INSTALL_TARGET_OPT
,$(2)_INSTALL_TARGET_OPTS
))
776 $(eval
$(call check-deprecated-variable
,$(2)_INSTALL_STAGING_OPT
,$(2)_INSTALL_STAGING_OPTS
))
777 $(eval
$(call check-deprecated-variable
,$(2)_INSTALL_HOST_OPT
,$(2)_INSTALL_HOST_OPTS
))
778 $(eval
$(call check-deprecated-variable
,$(2)_AUTORECONF_OPT
,$(2)_AUTORECONF_OPTS
))
779 $(eval
$(call check-deprecated-variable
,$(2)_CONF_OPT
,$(2)_CONF_OPTS
))
780 $(eval
$(call check-deprecated-variable
,$(2)_BUILD_OPT
,$(2)_BUILD_OPTS
))
781 $(eval
$(call check-deprecated-variable
,$(2)_GETTEXTIZE_OPT
,$(2)_GETTEXTIZE_OPTS
))
782 $(eval
$(call check-deprecated-variable
,$(2)_KCONFIG_OPT
,$(2)_KCONFIG_OPTS
))
786 ifneq ($$($(2)_PERMISSIONS
),)
787 PACKAGES_PERMISSIONS_TABLE
+= $$($(2)_PERMISSIONS
)$$(sep
)
789 ifneq ($$($(2)_DEVICES
),)
790 PACKAGES_DEVICES_TABLE
+= $$($(2)_DEVICES
)$$(sep
)
792 ifneq ($$($(2)_USERS
),)
793 PACKAGES_USERS
+= $$($(2)_USERS
)$$(sep
)
796 ifeq ($$($(2)_SITE_METHOD
),svn
)
797 DL_TOOLS_DEPENDENCIES
+= svn
798 else ifeq ($$($(2)_SITE_METHOD
),git
)
799 DL_TOOLS_DEPENDENCIES
+= git
800 else ifeq ($$($(2)_SITE_METHOD
),bzr
)
801 DL_TOOLS_DEPENDENCIES
+= bzr
802 else ifeq ($$($(2)_SITE_METHOD
),scp
)
803 DL_TOOLS_DEPENDENCIES
+= scp ssh
804 else ifeq ($$($(2)_SITE_METHOD
),hg
)
805 DL_TOOLS_DEPENDENCIES
+= hg
806 else ifeq ($$($(2)_SITE_METHOD
),cvs
)
807 DL_TOOLS_DEPENDENCIES
+= cvs
810 # $(firstword) is used here because the extractor can have arguments, like
811 # ZCAT="gzip -d -c", and to check for the dependency we only want 'gzip'.
812 # Do not add xzcat to the list of required dependencies, as it gets built
813 # automatically if it isn't found.
814 ifneq ($$(call suitable-extractor
,$$($(2)_SOURCE
)),$$(XZCAT
))
815 DL_TOOLS_DEPENDENCIES
+= $$(firstword $$(call suitable-extractor
,$$($(2)_SOURCE
)))
818 # Ensure all virtual targets are PHONY. Listed alphabetically.
820 $(1)-all-external-deps \
821 $(1)-all-legal-info \
823 $(1)-all-source-check \
825 $(1)-clean-for-rebuild \
826 $(1)-clean-for-reconfigure \
827 $(1)-clean-for-reinstall \
836 $(1)-install-images \
837 $(1)-install-staging \
838 $(1)-install-target \
850 endif # $(2)_KCONFIG_VAR
851 endef # inner-generic-package
853 ################################################################################
854 # generic-package -- the target generator macro for generic packages
855 ################################################################################
857 # In the case of target packages, keep the package name "pkg"
858 generic-package
= $(call inner-generic-package
,$(pkgname
),$(call UPPERCASE
,$(pkgname
)),$(call UPPERCASE
,$(pkgname
)),target
)
859 # In the case of host packages, turn the package name "pkg" into "host-pkg"
860 host-generic-package
= $(call inner-generic-package
,host-
$(pkgname
),$(call UPPERCASE
,host-
$(pkgname
)),$(call UPPERCASE
,$(pkgname
)),host
)