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
60 $(if
$(BR2_INIT_BUSYBOX
), \
62 $(if
$(BR2_INIT_SYSV
), \
64 $(if
$(BR2_INIT_SYSTEMD
), \
66 $(if
$(BR2_INIT_NONE
), \
68 >"$(BUILD_DIR)/build-sysinit.log"
70 GLOBAL_INSTRUMENTATION_HOOKS
+= step_initsys
72 # Hooks to collect statistics about installed files
74 # This hook will be called before the target installation of a
75 # package. We store in a file named .br_filelist_before the list of
76 # files currently installed in the target. Note that the MD5 is also
77 # stored, in order to identify if the files are overwritten.
78 define step_pkg_size_start
79 (cd
$(TARGET_DIR
) ; find .
-type f
) |
sort > \
80 $($(PKG
)_DIR
)/.br_filelist_before
83 # This hook will be called after the target installation of a
84 # package. We store in a file named .br_filelist_after the list of
85 # files (and their MD5) currently installed in the target. We then do
86 # a diff with the .br_filelist_before to compute the list of files
87 # installed by this package.
88 define step_pkg_size_end
89 (cd
$(TARGET_DIR
); find .
-type f
) |
sort > \
90 $($(PKG
)_DIR
)/.br_filelist_after
91 comm
-13 $($(PKG
)_DIR
)/.br_filelist_before
$($(PKG
)_DIR
)/.br_filelist_after | \
92 while read file
; do \
93 echo
"$(1),$${file}" >> $(BUILD_DIR
)/packages-file-list.txt
; \
98 $(if
$(filter install-target
,$(2)),\
99 $(if
$(filter start
,$(1)),$(call step_pkg_size_start
,$(3))) \
100 $(if
$(filter end
,$(1)),$(call step_pkg_size_end
,$(3))))
102 GLOBAL_INSTRUMENTATION_HOOKS
+= step_pkg_size
104 # Relies on step_pkg_size, so must be after
105 define check_bin_arch
106 $(if
$(filter end-install-target
,$(1)-$(2)),\
107 support
/scripts
/check-bin-arch
-p
$(3) \
108 -l
$(BUILD_DIR
)/packages-file-list.txt \
109 -r
$(TARGET_READELF
) \
110 -a
$(BR2_READELF_ARCH_NAME
))
113 #GLOBAL_INSTRUMENTATION_HOOKS += check_bin_arch
115 define step_check_build_dir_one
116 if
[ -d
$(2) ]; then \
117 printf
"%s: installs files in %s\n" $(1) $(2) >&2; \
122 define step_check_build_dir
123 $(if
$(filter install-staging
,$(2)),\
124 $(if
$(filter end
,$(1)),$(call step_check_build_dir_one
,$(3),$(STAGING_DIR
)/$(O
))))
125 $(if
$(filter install-target
,$(2)),\
126 $(if
$(filter end
,$(1)),$(call step_check_build_dir_one
,$(3),$(TARGET_DIR
)/$(O
))))
128 GLOBAL_INSTRUMENTATION_HOOKS
+= step_check_build_dir
130 # User-supplied script
131 ifneq ($(BR2_INSTRUMENTATION_SCRIPTS
),)
133 @
$(foreach user_hook
, $(BR2_INSTRUMENTATION_SCRIPTS
), \
134 $(EXTRA_ENV
) $(user_hook
) "$(1)" "$(2)" "$(3)"$(sep
))
136 GLOBAL_INSTRUMENTATION_HOOKS
+= step_user
139 ################################################################################
140 # Implicit targets -- produce a stamp file for each step of a package build
141 ################################################################################
143 # Retrieve the archive
144 $(BUILD_DIR
)/%/.stamp_downloaded
:
145 $(foreach hook
,$($(PKG
)_PRE_DOWNLOAD_HOOKS
),$(call
$(hook
))$(sep
))
146 # Only show the download message if it isn't already downloaded
147 $(Q
)for p in
$($(PKG
)_ALL_DOWNLOADS
); do \
148 if
test ! -e
$(DL_DIR
)/`basename $$p` ; then \
149 $(call MESSAGE
,"Downloading") ; \
153 $(foreach p
,$($(PKG
)_ALL_DOWNLOADS
),$(call DOWNLOAD
,$(p
))$(sep
))
154 $(foreach hook
,$($(PKG
)_POST_DOWNLOAD_HOOKS
),$(call
$(hook
))$(sep
))
158 # Retrieve actual source archive, e.g. for prebuilt external toolchains
159 $(BUILD_DIR
)/%/.stamp_actual_downloaded
:
160 $(call DOWNLOAD
,$($(PKG
)_ACTUAL_SOURCE_SITE
)/$($(PKG
)_ACTUAL_SOURCE_TARBALL
)); \
165 $(BUILD_DIR
)/%/.stamp_extracted
:
166 @
$(call step_start
,extract
)
167 @
$(call MESSAGE
,"Extracting")
168 $(foreach hook
,$($(PKG
)_PRE_EXTRACT_HOOKS
),$(call
$(hook
))$(sep
))
170 $($(PKG
)_EXTRACT_CMDS
)
171 # some packages have messed up permissions inside
172 $(Q
)chmod
-R
+rw
$(@D
)
173 $(foreach hook
,$($(PKG
)_POST_EXTRACT_HOOKS
),$(call
$(hook
))$(sep
))
174 @
$(call step_end
,extract
)
177 # Rsync the source directory if the <pkg>_OVERRIDE_SRCDIR feature is
179 $(BUILD_DIR
)/%/.stamp_rsynced
:
180 @
$(call MESSAGE
,"Syncing from source dir $(SRCDIR)")
181 $(foreach hook
,$($(PKG
)_PRE_RSYNC_HOOKS
),$(call
$(hook
))$(sep
))
182 @
test -d
$(SRCDIR
) ||
(echo
"ERROR: $(SRCDIR) does not exist" ; exit
1)
183 rsync
-au
--chmod
=u
=rwX
,go
=rX
$(RSYNC_VCS_EXCLUSIONS
) $(call qstrip
,$(SRCDIR
))/ $(@D
)
184 $(foreach hook
,$($(PKG
)_POST_RSYNC_HOOKS
),$(call
$(hook
))$(sep
))
189 # The RAWNAME variable is the lowercased package name, which allows to
190 # find the package directory (typically package/<pkgname>) and the
191 # prefix of the patches
193 # For BR2_GLOBAL_PATCH_DIR, only generate if it is defined
194 $(BUILD_DIR
)/%/.stamp_patched
: PATCH_BASE_DIRS
= $(PKGDIR
)
195 $(BUILD_DIR
)/%/.stamp_patched
: PATCH_BASE_DIRS
+= $(addsuffix /$(RAWNAME
),$(call qstrip
,$(BR2_GLOBAL_PATCH_DIR
)))
196 $(BUILD_DIR
)/%/.stamp_patched
:
197 @
$(call step_start
,patch
)
198 @
$(call MESSAGE
,"Patching")
199 $(foreach hook
,$($(PKG
)_PRE_PATCH_HOOKS
),$(call
$(hook
))$(sep
))
200 $(foreach p
,$($(PKG
)_PATCH
),$(APPLY_PATCHES
) $(@D
) $(DL_DIR
) $(notdir $(p
))$(sep
))
202 for D in
$(PATCH_BASE_DIRS
); do \
203 if
test -d
$${D}; then \
204 if
test -d
$${D}/$($(PKG
)_VERSION
); then \
205 $(APPLY_PATCHES
) $(@D
) $${D}/$($(PKG
)_VERSION
) \
*.patch \
*.patch.
$(ARCH
) || exit
1; \
207 $(APPLY_PATCHES
) $(@D
) $${D} \
*.patch \
*.patch.
$(ARCH
) || exit
1; \
212 $(foreach hook
,$($(PKG
)_POST_PATCH_HOOKS
),$(call
$(hook
))$(sep
))
213 @
$(call step_end
,patch
)
216 # Check that all directories specified in BR2_GLOBAL_PATCH_DIR exist.
217 $(foreach dir,$(call qstrip
,$(BR2_GLOBAL_PATCH_DIR
)),\
218 $(if
$(wildcard $(dir)),,\
219 $(error BR2_GLOBAL_PATCH_DIR contains nonexistent directory
$(dir))))
222 $(BUILD_DIR
)/%/.stamp_configured
:
223 @
$(call step_start
,configure
)
224 @
$(call MESSAGE
,"Configuring")
225 $(foreach hook
,$($(PKG
)_PRE_CONFIGURE_HOOKS
),$(call
$(hook
))$(sep
))
226 $($(PKG
)_CONFIGURE_CMDS
)
227 $(foreach hook
,$($(PKG
)_POST_CONFIGURE_HOOKS
),$(call
$(hook
))$(sep
))
228 @
$(call step_end
,configure
)
232 $(BUILD_DIR
)/%/.stamp_built
::
233 @
$(call step_start
,build
)
234 @
$(call MESSAGE
,"Building")
235 $(foreach hook
,$($(PKG
)_PRE_BUILD_HOOKS
),$(call
$(hook
))$(sep
))
236 +$($(PKG
)_BUILD_CMDS
)
237 $(foreach hook
,$($(PKG
)_POST_BUILD_HOOKS
),$(call
$(hook
))$(sep
))
238 @
$(call step_end
,build
)
241 # Install to host dir
242 $(BUILD_DIR
)/%/.stamp_host_installed
:
243 @
$(call step_start
,install-host
)
244 @
$(call MESSAGE
,"Installing to host directory")
245 $(foreach hook
,$($(PKG
)_PRE_INSTALL_HOOKS
),$(call
$(hook
))$(sep
))
246 +$($(PKG
)_INSTALL_CMDS
)
247 $(foreach hook
,$($(PKG
)_POST_INSTALL_HOOKS
),$(call
$(hook
))$(sep
))
248 @
$(call step_end
,install-host
)
251 # Install to staging dir
253 # Some packages install libtool .la files alongside any installed
254 # libraries. These .la files sometimes refer to paths relative to the
255 # sysroot, which libtool will interpret as absolute paths to host
256 # libraries instead of the target libraries. Since this is not what we
257 # want, these paths are fixed by prefixing them with $(STAGING_DIR).
258 # As we configure with --prefix=/usr, this fix needs to be applied to
259 # any path that starts with /usr.
261 # To protect against the case that the output or staging directories or
262 # the pre-installed external toolchain themselves are under /usr, we first
263 # substitute away any occurrences of these directories with @BASE_DIR@,
264 # @STAGING_DIR@ and @TOOLCHAIN_EXTERNAL_INSTALL_DIR@ respectively.
266 # Note that STAGING_DIR can be outside BASE_DIR when the user sets
267 # BR2_HOST_DIR to a custom value. Note that TOOLCHAIN_EXTERNAL_INSTALL_DIR
268 # can be under @BASE_DIR@ when it's a downloaded toolchain, and can be
269 # empty when we use an internal toolchain.
271 $(BUILD_DIR
)/%/.stamp_staging_installed
:
272 @
$(call step_start
,install-staging
)
273 @
$(call MESSAGE
,"not installing to staging directory")
274 @
$(call step_end
,install-staging
)
277 # Install to images dir
278 $(BUILD_DIR
)/%/.stamp_images_installed
:
279 @
$(call step_start
,install-image
)
280 $(foreach hook
,$($(PKG
)_PRE_INSTALL_IMAGES_HOOKS
),$(call
$(hook
))$(sep
))
281 @
$(call MESSAGE
,"Installing to images directory")
282 +$($(PKG
)_INSTALL_IMAGES_CMDS
)
283 $(foreach hook
,$($(PKG
)_POST_INSTALL_IMAGES_HOOKS
),$(call
$(hook
))$(sep
))
284 @
$(call step_end
,install-image
)
287 # Install to target dir
288 $(BUILD_DIR
)/%/.stamp_target_installed
:
289 @
$(call step_start
,install-target
)
290 @
$(call MESSAGE
,"Installing to target")
291 $(foreach hook
,$($(PKG
)_PRE_INSTALL_TARGET_HOOKS
),$(call
$(hook
))$(sep
))
292 $(if
$($(PKG
)_USERS
),$(call PRINTF
,$($(PKG
)_USERS
)) > _scripts
/$($(PKG
)_NAME
).users
)
293 $(Q
)echo
-n
> _scripts
/$($(PKG
)_NAME
).deps
294 $(foreach e
,$($(PKG
)_DEPENDENCIES
), \
295 $(Q
)support
/scripts
/echodep \
296 $($(PKG
)_NAME
) $(e
)$(sep
))
297 $(Q
)support
/scripts
/echorev
$($(PKG
)_NAME
)
298 +$($(PKG
)_INSTALL_TARGET_CMDS
)
299 $(if
$(BR2_INIT_SYSTEMD
),\
300 $($(PKG
)_INSTALL_INIT_SYSTEMD
))
301 $(if
$(BR2_INIT_SYSV
)$(BR2_INIT_BUSYBOX
),\
302 $($(PKG
)_INSTALL_INIT_SYSV
))
303 # $(foreach hook,$($(PKG)_POST_INSTALL_TARGET_HOOKS),$(call $(hook))$(sep))
304 $(Q
)echo NAME
=$($(PKG
)_NAME
) > $(BUILD_DIR
)/.package_source
305 $(Q
)echo VERSION
=$($(PKG
)_VERSION
) >> $(BUILD_DIR
)/.package_source
306 $(Q
)echo SOURCE_DIR
=$(@D
) >> $(BUILD_DIR
)/.package_source
307 $(Q
)support
/scripts
/procpkg
$(BUILD_DIR
)/.package_source
308 @
$(call step_end
,install-target
)
311 # Remove package sources
312 $(BUILD_DIR
)/%/.stamp_dircleaned
:
315 ################################################################################
316 # virt-provides-single -- check that provider-pkg is the declared provider for
317 # the virtual package virt-pkg
319 # argument 1 is the lower-case name of the virtual package
320 # argument 2 is the upper-case name of the virtual package
321 # argument 3 is the lower-case name of the provider
324 # $(call virt-provides-single,libegl,LIBEGL,rpi-userland)
325 ################################################################################
326 define virt-provides-single
327 ifneq ($$(call qstrip
,$$(BR2_PACKAGE_PROVIDES_
$(2))),$(3))
328 $$(error Configuration error
: both
"$(3)" and
$$(BR2_PACKAGE_PROVIDES_
$(2))\
329 are selected
as providers for virtual package
"$(1)". Only one provider can\
330 be selected at a time. Please fix your configuration
)
334 define pkg-graph-depends
335 @
$$(INSTALL
) -d
$$(GRAPHS_DIR
)
336 @cd
"$$(CONFIG_DIR)"; \
337 $$(TOPDIR
)/support
/scripts
/graph-depends
$$(BR2_GRAPH_DEPS_OPTS
) \
338 -p
$(1) $(2) -o
$$(GRAPHS_DIR
)/$$(@
).dot
339 dot
$$(BR2_GRAPH_DOT_OPTS
) -T
$$(BR_GRAPH_OUT
) \
340 -o
$$(GRAPHS_DIR
)/$$(@
).
$$(BR_GRAPH_OUT
) \
341 $$(GRAPHS_DIR
)/$$(@
).dot
344 ################################################################################
345 # inner-generic-package -- generates the make targets needed to build a
348 # argument 1 is the lowercase package name
349 # argument 2 is the uppercase package name, including a HOST_ prefix
351 # argument 3 is the uppercase package name, without the HOST_ prefix
353 # argument 4 is the type (target or host)
355 # Note about variable and function references: inside all blocks that are
356 # evaluated with $(eval), which includes all 'inner-xxx-package' blocks,
357 # specific rules apply with respect to variable and function references.
358 # - Numbered variables (parameters to the block) can be referenced with a single
359 # dollar sign: $(1), $(2), $(3), etc.
360 # - pkgdir and pkgname should be referenced with a single dollar sign too. These
361 # functions rely on 'the most recently parsed makefile' which is supposed to
362 # be the package .mk file. If we defer the evaluation of these functions using
363 # double dollar signs, then they may be evaluated too late, when other
364 # makefiles have already been parsed. One specific case is when $$(pkgdir) is
365 # assigned to a variable using deferred evaluation with '=' and this variable
366 # is used in a target rule outside the eval'ed inner block. In this case, the
367 # pkgdir will be that of the last makefile parsed by buildroot, which is not
368 # the expected value. This mechanism is for example used for the TARGET_PATCH
370 # - All other variables should be referenced with a double dollar sign:
371 # $$(TARGET_DIR), $$($(2)_VERSION), etc. Also all make functions should be
372 # referenced with a double dollar sign: $$(subst), $$(call), $$(filter-out),
373 # etc. This rule ensures that these variables and functions are only expanded
374 # during the $(eval) step, and not earlier. Otherwise, unintuitive and
375 # undesired behavior occurs with respect to these variables and functions.
377 ################################################################################
379 define inner-generic-package
381 # Ensure the package is only declared once, i.e. do not accept that a
382 # package be re-defined by a br2-external tree
383 ifneq ($(call
strip,$(filter $(1),$(PACKAGES_ALL
))),)
384 $$(error Package
'$(1)' defined a second time in
'$(pkgdir)'; \
385 previous definition was in
'$$($(2)_PKGDIR)')
389 # Define default values for various package-related variables, if not
390 # already defined. For some variables (version, source, site and
391 # subdir), if they are undefined, we try to see if a variable without
392 # the HOST_ prefix is defined. If so, we use such a variable, so that
393 # this information has only to be specified once, for both the
394 # target and host packages of a given .mk file.
398 $(2)_RAWNAME
= $$(patsubst host-
%,%,$(1))
399 $(2)_PKGDIR
= $(pkgdir
)
401 # Keep the package version that may contain forward slashes in the _DL_VERSION
402 # variable, then replace all forward slashes ('/') by underscores ('_') to
403 # sanitize the package version that is used in paths, directory and file names.
404 # Forward slashes may appear in the package's version when pointing to a
405 # version control system branch or tag, for example remotes/origin/1_10_stable.
406 # Similar for spaces and colons (:) that may appear in date-based revisions for
409 ifdef $(3)_DL_VERSION
410 $(2)_DL_VERSION
:= $$($(3)_DL_VERSION
)
411 else ifdef $(3)_VERSION
412 $(2)_DL_VERSION
:= $$($(3)_VERSION
)
415 $(2)_DL_VERSION
:= $$(strip $$($(2)_VERSION
))
417 $(2)_VERSION
:= $$(call sanitize
,$$($(2)_DL_VERSION
))
419 ifdef $(3)_OVERRIDE_SRCDIR
420 $(2)_OVERRIDE_SRCDIR ?
= $$($(3)_OVERRIDE_SRCDIR
)
423 $(2)_BASE_NAME
= $$(if
$$($(2)_VERSION
),$(1)-$$($(2)_VERSION
),$(1))
424 $(2)_RAW_BASE_NAME
= $$(if
$$($(2)_VERSION
),$$($(2)_RAWNAME
)-$$($(2)_VERSION
),$$($(2)_RAWNAME
))
425 $(2)_DL_DIR
= $$(DL_DIR
)/$$($(2)_BASE_NAME
)
426 $(2)_DIR
= $$(BUILD_DIR
)/$$($(2)_BASE_NAME
)
430 $(2)_SUBDIR
= $$($(3)_SUBDIR
)
436 ifndef $(2)_STRIP_COMPONENTS
437 ifdef $(3)_STRIP_COMPONENTS
438 $(2)_STRIP_COMPONENTS
= $$($(3)_STRIP_COMPONENTS
)
440 $(2)_STRIP_COMPONENTS ?
= 1
444 $(2)_SRCDIR
= $$($(2)_DIR
)/$$($(2)_SUBDIR
)
445 $(2)_BUILDDIR ?
= $$($(2)_SRCDIR
)
447 ifneq ($$($(2)_OVERRIDE_SRCDIR
),)
448 $(2)_VERSION
= custom
453 $(2)_SOURCE
= $$($(3)_SOURCE
)
454 else ifdef $(2)_VERSION
455 $(2)_SOURCE ?
= $$($(2)_RAW_BASE_NAME
).
tar.gz
459 # If FOO_ACTUAL_SOURCE_TARBALL is explicitly defined, it means FOO_SOURCE is
460 # indeed a binary (e.g. external toolchain) and FOO_ACTUAL_SOURCE_TARBALL/_SITE
461 # point to the actual sources tarball. Use the actual sources for legal-info.
462 # For most packages the FOO_SITE/FOO_SOURCE pair points to real source code,
463 # so these are the defaults for FOO_ACTUAL_*.
464 $(2)_ACTUAL_SOURCE_TARBALL ?
= $$($(2)_SOURCE
)
465 $(2)_ACTUAL_SOURCE_SITE ?
= $$(call qstrip
,$$($(2)_SITE
))
469 $(2)_PATCH
= $$($(3)_PATCH
)
473 $(2)_ALL_DOWNLOADS
= \
474 $$(foreach p
,$$($(2)_SOURCE
) $$($(2)_PATCH
) $$($(2)_EXTRA_DOWNLOADS
),\
475 $$(if
$$(findstring ://,$$(p
)),$$(p
),\
476 $$($(2)_SITE
)/$$(p
)))
480 $(2)_SITE
= $$($(3)_SITE
)
484 ifndef $(2)_SITE_METHOD
485 ifdef $(3)_SITE_METHOD
486 $(2)_SITE_METHOD
= $$($(3)_SITE_METHOD
)
488 # Try automatic detection using the scheme part of the URI
489 $(2)_SITE_METHOD
= $$(call geturischeme
,$$($(2)_SITE
))
493 # Do not accept to download git submodule if not using the git method
494 ifneq ($$($(2)_GIT_SUBMODULES
),)
495 ifneq ($$($(2)_SITE_METHOD
),git
)
496 $$(error
$(2) declares having git sub-modules
, but does not use the \
497 'git' method
(uses
'$$($(2)_SITE_METHOD)' instead
))
501 ifeq ($$($(2)_SITE_METHOD
),local
)
502 ifeq ($$($(2)_OVERRIDE_SRCDIR
),)
503 $(2)_OVERRIDE_SRCDIR
= $$($(2)_SITE
)
509 $(2)_LICENSE
= $$($(3)_LICENSE
)
513 $(2)_LICENSE ?
= unknown
515 ifndef $(2)_LICENSE_FILES
516 ifdef $(3)_LICENSE_FILES
517 $(2)_LICENSE_FILES
= $$($(3)_LICENSE_FILES
)
521 ifndef $(2)_REDISTRIBUTE
522 ifdef $(3)_REDISTRIBUTE
523 $(2)_REDISTRIBUTE
= $$($(3)_REDISTRIBUTE
)
527 $(2)_REDISTRIBUTE ?
= YES
529 $(2)_REDIST_SOURCES_DIR
= $$(REDIST_SOURCES_DIR_
$$(call UPPERCASE
,$(4)))/$$($(2)_RAW_BASE_NAME
)
531 # When a target package is a toolchain dependency set this variable to
532 # 'NO' so the 'toolchain' dependency is not added to prevent a circular
534 $(2)_ADD_TOOLCHAIN_DEPENDENCY ?
= YES
537 ifneq ($(1),skeleton
)
538 $(2)_DEPENDENCIES
+= skeleton
540 ifeq ($$($(2)_ADD_TOOLCHAIN_DEPENDENCY
),YES
)
541 $(2)_DEPENDENCIES
+= toolchain
545 # Eliminate duplicates in dependencies
546 $(2)_FINAL_DEPENDENCIES
= $$(sort $$($(2)_DEPENDENCIES
))
547 $(2)_FINAL_PATCH_DEPENDENCIES
= $$(sort $$($(2)_PATCH_DEPENDENCIES
))
548 $(2)_FINAL_ALL_DEPENDENCIES
= $$(sort $$($(2)_FINAL_DEPENDENCIES
) $$($(2)_FINAL_PATCH_DEPENDENCIES
))
550 $(2)_INSTALL_STAGING ?
= NO
551 $(2)_INSTALL_IMAGES ?
= NO
552 $(2)_INSTALL_TARGET ?
= YES
554 # define sub-target stamps
555 $(2)_TARGET_INSTALL_TARGET
= $$($(2)_DIR
)/.stamp_target_installed
556 $(2)_TARGET_INSTALL_STAGING
= $$($(2)_DIR
)/.stamp_staging_installed
557 $(2)_TARGET_INSTALL_IMAGES
= $$($(2)_DIR
)/.stamp_images_installed
558 $(2)_TARGET_INSTALL_HOST
= $$($(2)_DIR
)/.stamp_host_installed
559 $(2)_TARGET_BUILD
= $$($(2)_DIR
)/.stamp_built
560 $(2)_TARGET_CONFIGURE
= $$($(2)_DIR
)/.stamp_configured
561 $(2)_TARGET_RSYNC
= $$($(2)_DIR
)/.stamp_rsynced
562 $(2)_TARGET_PATCH
= $$($(2)_DIR
)/.stamp_patched
563 $(2)_TARGET_EXTRACT
= $$($(2)_DIR
)/.stamp_extracted
564 $(2)_TARGET_SOURCE
= $$($(2)_DIR
)/.stamp_downloaded
565 $(2)_TARGET_ACTUAL_SOURCE
= $$($(2)_DIR
)/.stamp_actual_downloaded
566 $(2)_TARGET_DIRCLEAN
= $$($(2)_DIR
)/.stamp_dircleaned
568 # default extract command
569 $(2)_EXTRACT_CMDS ?
= \
570 $$(if
$$($(2)_SOURCE
),$$(INFLATE
$$(suffix $$($(2)_SOURCE
))) $$(DL_DIR
)/$$($(2)_SOURCE
) | \
571 $$(TAR
) --strip-components
=$$($(2)_STRIP_COMPONENTS
) \
573 $$(foreach x
,$$($(2)_EXCLUDES
),--exclude
='$$(x)' ) \
576 # pre/post-steps hooks
577 $(2)_PRE_DOWNLOAD_HOOKS ?
=
578 $(2)_POST_DOWNLOAD_HOOKS ?
=
579 $(2)_PRE_EXTRACT_HOOKS ?
=
580 $(2)_POST_EXTRACT_HOOKS ?
=
581 $(2)_PRE_RSYNC_HOOKS ?
=
582 $(2)_POST_RSYNC_HOOKS ?
=
583 $(2)_PRE_PATCH_HOOKS ?
=
584 $(2)_POST_PATCH_HOOKS ?
=
585 $(2)_PRE_CONFIGURE_HOOKS ?
=
586 $(2)_POST_CONFIGURE_HOOKS ?
=
587 $(2)_PRE_BUILD_HOOKS ?
=
588 $(2)_POST_BUILD_HOOKS ?
=
589 $(2)_PRE_INSTALL_HOOKS ?
=
590 $(2)_POST_INSTALL_HOOKS ?
=
591 $(2)_PRE_INSTALL_STAGING_HOOKS ?
=
592 $(2)_POST_INSTALL_STAGING_HOOKS ?
=
593 $(2)_PRE_INSTALL_TARGET_HOOKS ?
=
594 $(2)_POST_INSTALL_TARGET_HOOKS ?
=
595 $(2)_PRE_INSTALL_IMAGES_HOOKS ?
=
596 $(2)_POST_INSTALL_IMAGES_HOOKS ?
=
597 $(2)_PRE_LEGAL_INFO_HOOKS ?
=
598 $(2)_POST_LEGAL_INFO_HOOKS ?
=
599 $(2)_TARGET_FINALIZE_HOOKS ?
=
601 # human-friendly targets and target sequencing
604 ifeq ($$($(2)_TYPE
),host
)
605 $(1)-install: $(1)-install-host
607 $(1)-install: $(1)-install-staging
$(1)-install-target
$(1)-install-images
610 ifeq ($$($(2)_INSTALL_TARGET
),YES
)
611 $(1)-install-target
: $$($(2)_TARGET_INSTALL_TARGET
)
612 $$($(2)_TARGET_INSTALL_TARGET
): $$($(2)_TARGET_BUILD
)
617 ifeq ($$($(2)_INSTALL_STAGING
),YES
)
618 $(1)-install-staging
: $$($(2)_TARGET_INSTALL_STAGING
)
619 $$($(2)_TARGET_INSTALL_STAGING
): $$($(2)_TARGET_BUILD
)
620 # Some packages use install-staging stuff for install-target
621 $$($(2)_TARGET_INSTALL_TARGET
): $$($(2)_TARGET_INSTALL_STAGING
)
623 $(1)-install-staging
:
626 ifeq ($$($(2)_INSTALL_IMAGES
),YES
)
627 $(1)-install-images
: $$($(2)_TARGET_INSTALL_IMAGES
)
628 $$($(2)_TARGET_INSTALL_IMAGES
): $$($(2)_TARGET_BUILD
)
633 $(1)-install-host
: $$($(2)_TARGET_INSTALL_HOST
)
634 $$($(2)_TARGET_INSTALL_HOST
): $$($(2)_TARGET_BUILD
)
636 $(1)-build
: $$($(2)_TARGET_BUILD
)
637 $$($(2)_TARGET_BUILD
): $$($(2)_TARGET_CONFIGURE
)
639 # Since $(2)_FINAL_DEPENDENCIES are phony targets, they are always "newer"
640 # than $(2)_TARGET_CONFIGURE. This would force the configure step (and
641 # therefore the other steps as well) to be re-executed with every
642 # invocation of make. Therefore, make $(2)_FINAL_DEPENDENCIES an order-only
643 # dependency by using |.
645 $(1)-configure
: $$($(2)_TARGET_CONFIGURE
)
646 $$($(2)_TARGET_CONFIGURE
): |
$$($(2)_FINAL_DEPENDENCIES
)
648 $$($(2)_TARGET_SOURCE
) $$($(2)_TARGET_RSYNC
): | dirs prepare
649 ifeq ($$(filter $(1),$$(DEPENDENCIES_HOST_PREREQ
)),)
650 $$($(2)_TARGET_SOURCE
) $$($(2)_TARGET_RSYNC
): | dependencies
653 ifeq ($$($(2)_OVERRIDE_SRCDIR
),)
654 # In the normal case (no package override), the sequence of steps is
655 # source, by downloading
660 $$($(2)_TARGET_CONFIGURE
): $$($(2)_TARGET_PATCH
)
662 $(1)-patch
: $$($(2)_TARGET_PATCH
)
663 $$($(2)_TARGET_PATCH
): $$($(2)_TARGET_EXTRACT
)
664 # Order-only dependency
665 $$($(2)_TARGET_PATCH
): |
$$(patsubst %,%-patch
,$$($(2)_FINAL_PATCH_DEPENDENCIES
))
667 $(1)-extract
: $$($(2)_TARGET_EXTRACT
)
668 $$($(2)_TARGET_EXTRACT
): $$($(2)_TARGET_SOURCE
)
670 $(1)-depends
: $$($(2)_FINAL_DEPENDENCIES
)
672 $(1)-source
: $$($(2)_TARGET_SOURCE
)
674 $(1)-all-source
: $(1)-legal-source
675 $(1)-legal-info
: $(1)-legal-source
676 $(1)-legal-source
: $(1)-source
678 # Only download the actual source if it differs from the 'main' archive
679 ifneq ($$($(2)_ACTUAL_SOURCE_TARBALL
),)
680 ifneq ($$($(2)_ACTUAL_SOURCE_TARBALL
),$$($(2)_SOURCE
))
681 $(1)-legal-source
: $$($(2)_TARGET_ACTUAL_SOURCE
)
682 endif # actual sources != sources
683 endif # actual sources != ""
685 $(1)-source-check
: PKG
=$(2)
687 $$(foreach p
,$$($(2)_ALL_DOWNLOADS
),$$(call SOURCE_CHECK
,$$(p
))$$(sep
))
690 @for p in
$$($(2)_SOURCE
) $$($(2)_PATCH
) $$($(2)_EXTRA_DOWNLOADS
) ; do \
691 echo
`basename $$$$p` ; \
694 # In the package override case, the sequence of steps
695 # source, by rsyncing
699 # Use an order-only dependency so the "<pkg>-clean-for-rebuild" rule
700 # can remove the stamp file without triggering the configure step.
701 $$($(2)_TARGET_CONFIGURE
): |
$$($(2)_TARGET_RSYNC
)
703 $(1)-depends
: $$($(2)_FINAL_DEPENDENCIES
)
705 $(1)-patch
: $(1)-rsync
706 $(1)-extract
: $(1)-rsync
708 $(1)-rsync
: $$($(2)_TARGET_RSYNC
)
714 test -d
$$($(2)_OVERRIDE_SRCDIR
)
717 @echo
"file://$$($(2)_OVERRIDE_SRCDIR)"
721 @echo
$$($(2)_VERSION
)
724 @echo
$$($(2)_FINAL_ALL_DEPENDENCIES
)
727 @echo
$$($(2)_RDEPENDENCIES
)
729 $(1)-show-build-order
: $$(patsubst %,%-show-build-order
,$$($(2)_FINAL_ALL_DEPENDENCIES
))
732 $(1)-graph-depends
: graph-depends-requirements
733 $(call pkg-graph-depends
,$(1),--direct
)
735 $(1)-graph-rdepends
: graph-depends-requirements
736 $(call pkg-graph-depends
,$(1),--reverse
)
738 $(1)-all-source
: $(1)-source
739 $(1)-all-source
: $$(foreach p
,$$($(2)_FINAL_ALL_DEPENDENCIES
),$$(p
)-all-source
)
741 $(1)-all-source-check
: $(1)-source-check
742 $(1)-all-source-check
: $$(foreach p
,$$($(2)_FINAL_ALL_DEPENDENCIES
),$$(p
)-all-source-check
)
744 $(1)-all-external-deps
: $(1)-external-deps
745 $(1)-all-external-deps
: $$(foreach p
,$$($(2)_FINAL_ALL_DEPENDENCIES
),$$(p
)-all-external-deps
)
747 $(1)-all-legal-info
: $(1)-legal-info
748 $(1)-all-legal-info
: $$(foreach p
,$$($(2)_FINAL_ALL_DEPENDENCIES
),$$(p
)-all-legal-info
)
750 $(1)-dirclean
: $$($(2)_TARGET_DIRCLEAN
)
752 $(1)-clean-for-reinstall
:
753 ifneq ($$($(2)_OVERRIDE_SRCDIR
),)
754 rm -f
$$($(2)_TARGET_RSYNC
)
756 rm -f
$$($(2)_TARGET_INSTALL_STAGING
)
757 rm -f
$$($(2)_TARGET_INSTALL_TARGET
)
758 rm -f
$$($(2)_TARGET_INSTALL_IMAGES
)
759 rm -f
$$($(2)_TARGET_INSTALL_HOST
)
761 $(1)-reinstall
: $(1)-clean-for-reinstall
$(1)
763 $(1)-clean-for-rebuild
: $(1)-clean-for-reinstall
764 rm -f
$$($(2)_TARGET_BUILD
)
766 $(1)-rebuild
: $(1)-clean-for-rebuild
$(1)
768 $(1)-clean-for-reconfigure
: $(1)-clean-for-rebuild
769 rm -f
$$($(2)_TARGET_CONFIGURE
)
771 $(1)-reconfigure
: $(1)-clean-for-reconfigure
$(1)
773 # define the PKG variable for all targets, containing the
774 # uppercase package variable prefix
775 $$($(2)_TARGET_INSTALL_TARGET
): PKG
=$(2)
776 $$($(2)_TARGET_INSTALL_STAGING
): PKG
=$(2)
777 $$($(2)_TARGET_INSTALL_IMAGES
): PKG
=$(2)
778 $$($(2)_TARGET_INSTALL_HOST
): PKG
=$(2)
779 $$($(2)_TARGET_BUILD
): PKG
=$(2)
780 $$($(2)_TARGET_CONFIGURE
): PKG
=$(2)
781 $$($(2)_TARGET_RSYNC
): SRCDIR
=$$($(2)_OVERRIDE_SRCDIR
)
782 $$($(2)_TARGET_RSYNC
): PKG
=$(2)
783 $$($(2)_TARGET_PATCH
): PKG
=$(2)
784 $$($(2)_TARGET_PATCH
): RAWNAME
=$$(patsubst host-
%,%,$(1))
785 $$($(2)_TARGET_PATCH
): PKGDIR
=$(pkgdir
)
786 $$($(2)_TARGET_EXTRACT
): PKG
=$(2)
787 $$($(2)_TARGET_SOURCE
): PKG
=$(2)
788 $$($(2)_TARGET_SOURCE
): PKGDIR
=$(pkgdir
)
789 $$($(2)_TARGET_ACTUAL_SOURCE
): PKG
=$(2)
790 $$($(2)_TARGET_ACTUAL_SOURCE
): PKGDIR
=$(pkgdir
)
791 $$($(2)_TARGET_DIRCLEAN
): PKG
=$(2)
793 # Compute the name of the Kconfig option that correspond to the
794 # package being enabled. We handle three cases: the special Linux
795 # kernel case, the bootloaders case, and the normal packages case.
797 $(2)_KCONFIG_VAR
= BR2_LINUX_KERNEL
798 else ifneq ($$(filter boot
/% $$(foreach dir,$$(BR2_EXTERNAL_DIRS
),$$(dir)/boot
/%),$(pkgdir
)),)
799 $(2)_KCONFIG_VAR
= BR2_TARGET_
$(2)
800 else ifneq ($$(filter toolchain
/% $$(foreach dir,$$(BR2_EXTERNAL_DIRS
),$$(dir)/toolchain
/%),$(pkgdir
)),)
801 $(2)_KCONFIG_VAR
= BR2_
$(2)
803 $(2)_KCONFIG_VAR
= BR2_PACKAGE_
$(2)
806 # legal-info: declare dependencies and set values used later for the manifest
807 ifneq ($$($(2)_LICENSE_FILES
),)
808 $(2)_MANIFEST_LICENSE_FILES
= $$($(2)_LICENSE_FILES
)
811 # We need to extract and patch a package to be able to retrieve its
812 # license files (if any) and the list of patches applied to it (if
814 $(1)-legal-info
: $(1)-patch
816 # We only save the sources of packages we want to redistribute, that are
817 # non-overriden (local or true override).
818 ifeq ($$($(2)_REDISTRIBUTE
),YES
)
819 ifeq ($$($(2)_OVERRIDE_SRCDIR
),)
820 # Packages that have a tarball need it downloaded beforehand
821 $(1)-legal-info
: $(1)-source
$$(REDIST_SOURCES_DIR_
$$(call UPPERCASE
,$(4)))
825 # legal-info: produce legally relevant info.
827 # Packages without a source are assumed to be part of Buildroot, skip them.
828 $$(foreach hook
,$$($(2)_PRE_LEGAL_INFO_HOOKS
),$$(call
$$(hook
))$$(sep
))
829 ifneq ($$(call qstrip
,$$($(2)_SOURCE
)),)
831 # Save license files if defined
832 # We save the license files for any kind of package: normal, local,
833 # overridden, or non-redistributable alike.
834 # The reason to save license files even for no-redistribute packages
835 # is that the license still applies to the files distributed as part
836 # of the rootfs, even if the sources are not themselves redistributed.
837 ifeq ($$(call qstrip
,$$($(2)_LICENSE_FILES
)),)
838 @
$$(call legal-warning-pkg
,$$($(2)_RAW_BASE_NAME
),cannot save license
($(2)_LICENSE_FILES not defined
))
840 @
$$(foreach F
,$$($(2)_LICENSE_FILES
),$$(call legal-license-file
,$$($(2)_RAW_BASE_NAME
),$$(F
),$$($(2)_DIR
)/$$(F
),$$(call UPPERCASE
,$(4)))$$(sep
))
841 endif # license files
843 ifeq ($$($(2)_SITE_METHOD
),local
)
844 # Packages without a tarball: don't save and warn
845 @
$$(call legal-warning-nosource
,$$($(2)_RAWNAME
),local
)
847 else ifneq ($$($(2)_OVERRIDE_SRCDIR
),)
848 @
$$(call legal-warning-nosource
,$$($(2)_RAWNAME
),override)
853 ifeq ($$($(2)_REDISTRIBUTE
),YES
)
854 # Save the source tarball and any extra downloads, but not
855 # patches, as they are handled specially afterwards.
856 $$(foreach e
,$$($(2)_ACTUAL_SOURCE_TARBALL
) $$(notdir $$($(2)_EXTRA_DOWNLOADS
)),\
857 $$(Q
)support
/scripts
/hardlink-or-copy \
859 $$($(2)_REDIST_SOURCES_DIR
)$$(sep
))
860 # Save patches and generate the series file
861 $$(Q
)while read f
; do \
862 support
/scripts
/hardlink-or-copy \
864 $$($(2)_REDIST_SOURCES_DIR
) || exit
1; \
865 printf
"%s\n" "$$$${f##*/}" >>$$($(2)_REDIST_SOURCES_DIR
)/series || exit
1; \
866 done
<$$($(2)_DIR
)/.applied_patches_list
869 endif # other packages
870 @
$$(call legal-manifest
,$$($(2)_RAWNAME
),$$($(2)_VERSION
),$$($(2)_LICENSE
),$$($(2)_MANIFEST_LICENSE_FILES
),$$($(2)_ACTUAL_SOURCE_TARBALL
),$$($(2)_ACTUAL_SOURCE_SITE
),$$(call UPPERCASE
,$(4)))
871 endif # ifneq ($$(call qstrip,$$($(2)_SOURCE)),)
872 $$(foreach hook
,$$($(2)_POST_LEGAL_INFO_HOOKS
),$$(call
$$(hook
))$$(sep
))
874 # add package to the general list of targets if requested by the buildroot
876 ifeq ($$($$($(2)_KCONFIG_VAR
)),y
)
878 # Ensure the calling package is the declared provider for all the virtual
879 # packages it claims to be an implementation of.
880 ifneq ($$($(2)_PROVIDES
),)
881 $$(foreach pkg
,$$($(2)_PROVIDES
),\
882 $$(eval
$$(call virt-provides-single
,$$(pkg
),$$(call UPPERCASE
,$$(pkg
)),$(1))$$(sep
)))
885 # Register package as a reverse-dependencies of all its dependencies
886 $$(eval
$$(foreach p
,$$($(2)_FINAL_ALL_DEPENDENCIES
),\
887 $$(call UPPERCASE
,$$(p
))_RDEPENDENCIES
+= $(1)$$(sep
)))
889 # Ensure unified variable name conventions between all packages Some
890 # of the variables are used by more than one infrastructure; so,
891 # rather than duplicating the checks in each infrastructure, we check
892 # all variables here in pkg-generic, even though pkg-generic should
893 # have no knowledge of infra-specific variables.
894 $(eval
$(call check-deprecated-variable
,$(2)_MAKE_OPT
,$(2)_MAKE_OPTS
))
895 $(eval
$(call check-deprecated-variable
,$(2)_INSTALL_OPT
,$(2)_INSTALL_OPTS
))
896 $(eval
$(call check-deprecated-variable
,$(2)_INSTALL_TARGET_OPT
,$(2)_INSTALL_TARGET_OPTS
))
897 $(eval
$(call check-deprecated-variable
,$(2)_INSTALL_STAGING_OPT
,$(2)_INSTALL_STAGING_OPTS
))
898 $(eval
$(call check-deprecated-variable
,$(2)_INSTALL_HOST_OPT
,$(2)_INSTALL_HOST_OPTS
))
899 $(eval
$(call check-deprecated-variable
,$(2)_AUTORECONF_OPT
,$(2)_AUTORECONF_OPTS
))
900 $(eval
$(call check-deprecated-variable
,$(2)_CONF_OPT
,$(2)_CONF_OPTS
))
901 $(eval
$(call check-deprecated-variable
,$(2)_BUILD_OPT
,$(2)_BUILD_OPTS
))
902 $(eval
$(call check-deprecated-variable
,$(2)_GETTEXTIZE_OPT
,$(2)_GETTEXTIZE_OPTS
))
903 $(eval
$(call check-deprecated-variable
,$(2)_KCONFIG_OPT
,$(2)_KCONFIG_OPTS
))
907 ifneq ($$($(2)_PERMISSIONS
),)
908 PACKAGES_PERMISSIONS_TABLE
+= $$($(2)_PERMISSIONS
)$$(sep
)
910 ifneq ($$($(2)_DEVICES
),)
911 PACKAGES_DEVICES_TABLE
+= $$($(2)_DEVICES
)$$(sep
)
913 ifneq ($$($(2)_USERS
),)
914 PACKAGES_USERS
+= $$($(2)_USERS
)$$(sep
)
916 TARGET_FINALIZE_HOOKS
+= $$($(2)_TARGET_FINALIZE_HOOKS
)
918 ifeq ($$($(2)_SITE_METHOD
),svn
)
919 DL_TOOLS_DEPENDENCIES
+= svn
920 else ifeq ($$($(2)_SITE_METHOD
),git
)
921 DL_TOOLS_DEPENDENCIES
+= git
922 else ifeq ($$($(2)_SITE_METHOD
),bzr
)
923 DL_TOOLS_DEPENDENCIES
+= bzr
924 else ifeq ($$($(2)_SITE_METHOD
),scp
)
925 DL_TOOLS_DEPENDENCIES
+= scp ssh
926 else ifeq ($$($(2)_SITE_METHOD
),hg
)
927 DL_TOOLS_DEPENDENCIES
+= hg
928 else ifeq ($$($(2)_SITE_METHOD
),cvs
)
929 DL_TOOLS_DEPENDENCIES
+= cvs
932 DL_TOOLS_DEPENDENCIES
+= $$(call extractor-dependency
,$$($(2)_SOURCE
))
934 # Ensure all virtual targets are PHONY. Listed alphabetically.
936 $(1)-all-external-deps \
937 $(1)-all-legal-info \
939 $(1)-all-source-check \
941 $(1)-clean-for-rebuild \
942 $(1)-clean-for-reconfigure \
943 $(1)-clean-for-reinstall \
952 $(1)-install-images \
953 $(1)-install-staging \
954 $(1)-install-target \
967 ifneq ($$($(2)_SOURCE
),)
968 ifeq ($$($(2)_SITE
),)
969 $$(error
$(2)_SITE cannot be empty when
$(2)_SOURCE is not
)
973 ifeq ($$(patsubst %/,ERROR
,$$($(2)_SITE
)),ERROR
)
974 $$(error
$(2)_SITE
($$($(2)_SITE
)) cannot have a trailing slash
)
977 ifneq ($$($(2)_HELP_CMDS
),)
978 HELP_PACKAGES
+= $(2)
981 endif # $(2)_KCONFIG_VAR
982 endef # inner-generic-package
984 ################################################################################
985 # generic-package -- the target generator macro for generic packages
986 ################################################################################
988 # In the case of target packages, keep the package name "pkg"
989 generic-package
= $(call inner-generic-package
,$(pkgname
),$(call UPPERCASE
,$(pkgname
)),$(call UPPERCASE
,$(pkgname
)),target
)
990 # In the case of host packages, turn the package name "pkg" into "host-pkg"
991 host-generic-package
= $(call inner-generic-package
,host-
$(pkgname
),$(call UPPERCASE
,host-
$(pkgname
)),$(call UPPERCASE
,$(pkgname
)),host
)