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 # Hooks to collect statistics about installed files
60 # This hook will be called before the target installation of a
61 # package. We store in a file named .br_filelist_before the list of
62 # files currently installed in the target. Note that the MD5 is also
63 # stored, in order to identify if the files are overwritten.
64 define step_pkg_size_start
65 (cd
$(TARGET_DIR
) ; find .
-type f
-print0 | xargs
-0 md5sum
) |
sort > \
66 $($(PKG
)_DIR
)/.br_filelist_before
69 # This hook will be called after the target installation of a
70 # package. We store in a file named .br_filelist_after the list of
71 # files (and their MD5) currently installed in the target. We then do
72 # a diff with the .br_filelist_before to compute the list of files
73 # installed by this package.
74 define step_pkg_size_end
75 (cd
$(TARGET_DIR
); find .
-type f
-print0 | xargs
-0 md5sum
) |
sort > \
76 $($(PKG
)_DIR
)/.br_filelist_after
77 comm
-13 $($(PKG
)_DIR
)/.br_filelist_before
$($(PKG
)_DIR
)/.br_filelist_after | \
78 while read hash file
; do \
79 echo
"$(1),$${file}" >> $(BUILD_DIR
)/packages-file-list.txt
; \
84 $(if
$(filter install-target
,$(2)),\
85 $(if
$(filter start
,$(1)),$(call step_pkg_size_start
,$(3))) \
86 $(if
$(filter end
,$(1)),$(call step_pkg_size_end
,$(3))))
88 GLOBAL_INSTRUMENTATION_HOOKS
+= step_pkg_size
90 # This hook checks that host packages that need libraries that we build
91 # have a proper DT_RPATH or DT_RUNPATH tag
92 define check_host_rpath
93 $(if
$(filter install-host
,$(2)),\
94 $(if
$(filter end
,$(1)),support
/scripts
/check-host-rpath
$(3) $(HOST_DIR
)))
96 GLOBAL_INSTRUMENTATION_HOOKS
+= check_host_rpath
98 # User-supplied script
99 ifneq ($(BR2_INSTRUMENTATION_SCRIPTS
),)
101 @
$(foreach user_hook
, $(BR2_INSTRUMENTATION_SCRIPTS
), \
102 $(EXTRA_ENV
) $(user_hook
) "$(1)" "$(2)" "$(3)"$(sep
))
104 GLOBAL_INSTRUMENTATION_HOOKS
+= step_user
107 ################################################################################
108 # Implicit targets -- produce a stamp file for each step of a package build
109 ################################################################################
111 # Retrieve the archive
112 $(BUILD_DIR
)/%/.stamp_downloaded
:
113 $(foreach hook
,$($(PKG
)_PRE_DOWNLOAD_HOOKS
),$(call
$(hook
))$(sep
))
114 # Only show the download message if it isn't already downloaded
115 $(Q
)for p in
$($(PKG
)_ALL_DOWNLOADS
); do \
116 if
test ! -e
$(DL_DIR
)/`basename $$p` ; then \
117 $(call MESSAGE
,"Downloading") ; \
121 $(foreach p
,$($(PKG
)_ALL_DOWNLOADS
),$(call DOWNLOAD
,$(p
))$(sep
))
122 $(foreach hook
,$($(PKG
)_POST_DOWNLOAD_HOOKS
),$(call
$(hook
))$(sep
))
126 # Retrieve actual source archive, e.g. for prebuilt external toolchains
127 $(BUILD_DIR
)/%/.stamp_actual_downloaded
:
128 $(call DOWNLOAD
,$($(PKG
)_ACTUAL_SOURCE_SITE
)/$($(PKG
)_ACTUAL_SOURCE_TARBALL
)); \
133 $(BUILD_DIR
)/%/.stamp_extracted
:
134 @
$(call step_start
,extract
)
135 @
$(call MESSAGE
,"Extracting")
136 $(foreach hook
,$($(PKG
)_PRE_EXTRACT_HOOKS
),$(call
$(hook
))$(sep
))
138 $($(PKG
)_EXTRACT_CMDS
)
139 # some packages have messed up permissions inside
140 $(Q
)chmod
-R
+rw
$(@D
)
141 $(foreach hook
,$($(PKG
)_POST_EXTRACT_HOOKS
),$(call
$(hook
))$(sep
))
142 @
$(call step_end
,extract
)
145 # Rsync the source directory if the <pkg>_OVERRIDE_SRCDIR feature is
147 $(BUILD_DIR
)/%/.stamp_rsynced
:
148 @
$(call MESSAGE
,"Syncing from source dir $(SRCDIR)")
149 @
test -d
$(SRCDIR
) ||
(echo
"ERROR: $(SRCDIR) does not exist" ; exit
1)
150 $(foreach hook
,$($(PKG
)_PRE_RSYNC_HOOKS
),$(call
$(hook
))$(sep
))
151 rsync
-au
--chmod
=u
=rwX
,go
=rX
$(RSYNC_VCS_EXCLUSIONS
) $(call qstrip
,$(SRCDIR
))/ $(@D
)
152 $(foreach hook
,$($(PKG
)_POST_RSYNC_HOOKS
),$(call
$(hook
))$(sep
))
157 # The RAWNAME variable is the lowercased package name, which allows to
158 # find the package directory (typically package/<pkgname>) and the
159 # prefix of the patches
161 # For BR2_GLOBAL_PATCH_DIR, only generate if it is defined
162 $(BUILD_DIR
)/%/.stamp_patched
: PATCH_BASE_DIRS
= $(PKGDIR
)
163 $(BUILD_DIR
)/%/.stamp_patched
: PATCH_BASE_DIRS
+= $(addsuffix /$(RAWNAME
),$(call qstrip
,$(BR2_GLOBAL_PATCH_DIR
)))
164 $(BUILD_DIR
)/%/.stamp_patched
:
165 @
$(call step_start
,patch
)
166 @
$(call MESSAGE
,"Patching")
167 $(foreach hook
,$($(PKG
)_PRE_PATCH_HOOKS
),$(call
$(hook
))$(sep
))
168 $(foreach p
,$($(PKG
)_PATCH
),$(APPLY_PATCHES
) $(@D
) $(DL_DIR
) $(notdir $(p
))$(sep
))
170 for D in
$(PATCH_BASE_DIRS
); do \
171 if
test -d
$${D}; then \
172 if
test -d
$${D}/$($(PKG
)_VERSION
); then \
173 $(APPLY_PATCHES
) $(@D
) $${D}/$($(PKG
)_VERSION
) \
*.patch \
*.patch.
$(ARCH
) || exit
1; \
175 $(APPLY_PATCHES
) $(@D
) $${D} \
*.patch \
*.patch.
$(ARCH
) || exit
1; \
180 $(foreach hook
,$($(PKG
)_POST_PATCH_HOOKS
),$(call
$(hook
))$(sep
))
181 @
$(call step_end
,patch
)
184 # Check that all directories specified in BR2_GLOBAL_PATCH_DIR exist.
185 $(foreach dir,$(call qstrip
,$(BR2_GLOBAL_PATCH_DIR
)),\
186 $(if
$(wildcard $(dir)),,\
187 $(error BR2_GLOBAL_PATCH_DIR contains nonexistent directory
$(dir))))
190 $(BUILD_DIR
)/%/.stamp_configured
:
191 @
$(call step_start
,configure
)
192 @
$(call MESSAGE
,"Configuring")
193 $(foreach hook
,$($(PKG
)_PRE_CONFIGURE_HOOKS
),$(call
$(hook
))$(sep
))
194 $($(PKG
)_CONFIGURE_CMDS
)
195 $(foreach hook
,$($(PKG
)_POST_CONFIGURE_HOOKS
),$(call
$(hook
))$(sep
))
196 @
$(call step_end
,configure
)
200 $(BUILD_DIR
)/%/.stamp_built
::
201 @
$(call step_start
,build
)
202 @
$(call MESSAGE
,"Building")
203 $(foreach hook
,$($(PKG
)_PRE_BUILD_HOOKS
),$(call
$(hook
))$(sep
))
204 +$($(PKG
)_BUILD_CMDS
)
205 $(foreach hook
,$($(PKG
)_POST_BUILD_HOOKS
),$(call
$(hook
))$(sep
))
206 @
$(call step_end
,build
)
209 # Install to host dir
210 $(BUILD_DIR
)/%/.stamp_host_installed
:
211 @
$(call step_start
,install-host
)
212 @
$(call MESSAGE
,"Installing to host directory")
213 $(foreach hook
,$($(PKG
)_PRE_INSTALL_HOOKS
),$(call
$(hook
))$(sep
))
214 +$($(PKG
)_INSTALL_CMDS
)
215 $(foreach hook
,$($(PKG
)_POST_INSTALL_HOOKS
),$(call
$(hook
))$(sep
))
216 @
$(call step_end
,install-host
)
219 # Install to staging dir
221 # Some packages install libtool .la files alongside any installed
222 # libraries. These .la files sometimes refer to paths relative to the
223 # sysroot, which libtool will interpret as absolute paths to host
224 # libraries instead of the target libraries. Since this is not what we
225 # want, these paths are fixed by prefixing them with $(STAGING_DIR).
226 # As we configure with --prefix=/usr, this fix needs to be applied to
227 # any path that starts with /usr.
229 # To protect against the case that the output or staging directories or
230 # the pre-installed external toolchain themselves are under /usr, we first
231 # substitute away any occurrences of these directories with @BASE_DIR@,
232 # @STAGING_DIR@ and @TOOLCHAIN_EXTERNAL_INSTALL_DIR@ respectively.
234 # Note that STAGING_DIR can be outside BASE_DIR when the user sets
235 # BR2_HOST_DIR to a custom value. Note that TOOLCHAIN_EXTERNAL_INSTALL_DIR
236 # can be under @BASE_DIR@ when it's a downloaded toolchain, and can be
237 # empty when we use an internal toolchain.
239 $(BUILD_DIR
)/%/.stamp_staging_installed
:
240 @
$(call step_start
,install-staging
)
241 @
$(call MESSAGE
,"Installing to staging directory")
242 $(foreach hook
,$($(PKG
)_PRE_INSTALL_STAGING_HOOKS
),$(call
$(hook
))$(sep
))
243 +$($(PKG
)_INSTALL_STAGING_CMDS
)
244 $(foreach hook
,$($(PKG
)_POST_INSTALL_STAGING_HOOKS
),$(call
$(hook
))$(sep
))
245 $(Q
)if
test -n
"$($(PKG)_CONFIG_SCRIPTS)" ; then \
246 $(call MESSAGE
,"Fixing package configuration files") ;\
247 $(SED
) "s,$(BASE_DIR),@BASE_DIR@,g" \
248 -e
"s,$(STAGING_DIR),@STAGING_DIR@,g" \
249 -e
"s,^\(exec_\)\?prefix=.*,\1prefix=@STAGING_DIR@/usr,g" \
250 -e
"s,-I/usr/,-I@STAGING_DIR@/usr/,g" \
251 -e
"s,-L/usr/,-L@STAGING_DIR@/usr/,g" \
252 -e
"s,@STAGING_DIR@,$(STAGING_DIR),g" \
253 -e
"s,@BASE_DIR@,$(BASE_DIR),g" \
254 $(addprefix $(STAGING_DIR
)/usr
/bin
/,$($(PKG
)_CONFIG_SCRIPTS
)) ;\
256 @
$(call MESSAGE
,"Fixing libtool files")
257 $(Q
)find
$(STAGING_DIR
)/usr
/lib
* -name
"*.la" | xargs
--no-run-if-empty \
258 $(SED
) "s:$(BASE_DIR):@BASE_DIR@:g" \
259 -e
"s:$(STAGING_DIR):@STAGING_DIR@:g" \
260 $(if
$(TOOLCHAIN_EXTERNAL_INSTALL_DIR
),\
261 -e
"s:$(TOOLCHAIN_EXTERNAL_INSTALL_DIR):@TOOLCHAIN_EXTERNAL_INSTALL_DIR@:g") \
262 -e
"s:\(['= ]\)/usr:\\1@STAGING_DIR@/usr:g" \
263 $(if
$(TOOLCHAIN_EXTERNAL_INSTALL_DIR
),\
264 -e
"s:@TOOLCHAIN_EXTERNAL_INSTALL_DIR@:$(TOOLCHAIN_EXTERNAL_INSTALL_DIR):g") \
265 -e
"s:@STAGING_DIR@:$(STAGING_DIR):g" \
266 -e
"s:@BASE_DIR@:$(BASE_DIR):g"
267 @
$(call step_end
,install-staging
)
270 # Install to images dir
271 $(BUILD_DIR
)/%/.stamp_images_installed
:
272 @
$(call step_start
,install-image
)
273 $(foreach hook
,$($(PKG
)_PRE_INSTALL_IMAGES_HOOKS
),$(call
$(hook
))$(sep
))
274 @
$(call MESSAGE
,"Installing to images directory")
275 +$($(PKG
)_INSTALL_IMAGES_CMDS
)
276 $(foreach hook
,$($(PKG
)_POST_INSTALL_IMAGES_HOOKS
),$(call
$(hook
))$(sep
))
277 @
$(call step_end
,install-image
)
280 # Install to target dir
281 $(BUILD_DIR
)/%/.stamp_target_installed
:
282 @
$(call step_start
,install-target
)
283 @
$(call MESSAGE
,"Installing to target")
284 $(foreach hook
,$($(PKG
)_PRE_INSTALL_TARGET_HOOKS
),$(call
$(hook
))$(sep
))
285 +$($(PKG
)_INSTALL_TARGET_CMDS
)
286 $(if
$(BR2_INIT_SYSTEMD
),\
287 $($(PKG
)_INSTALL_INIT_SYSTEMD
))
288 $(if
$(BR2_INIT_SYSV
)$(BR2_INIT_BUSYBOX
),\
289 $($(PKG
)_INSTALL_INIT_SYSV
))
290 $(foreach hook
,$($(PKG
)_POST_INSTALL_TARGET_HOOKS
),$(call
$(hook
))$(sep
))
291 $(Q
)if
test -n
"$($(PKG)_CONFIG_SCRIPTS)" ; then \
292 $(RM
) -f
$(addprefix $(TARGET_DIR
)/usr
/bin
/,$($(PKG
)_CONFIG_SCRIPTS
)) ; \
294 @
$(call step_end
,install-target
)
297 # Remove package sources
298 $(BUILD_DIR
)/%/.stamp_dircleaned
:
301 ################################################################################
302 # virt-provides-single -- check that provider-pkg is the declared provider for
303 # the virtual package virt-pkg
305 # argument 1 is the lower-case name of the virtual package
306 # argument 2 is the upper-case name of the virtual package
307 # argument 3 is the lower-case name of the provider
310 # $(call virt-provides-single,libegl,LIBEGL,rpi-userland)
311 ################################################################################
312 define virt-provides-single
313 ifneq ($$(call qstrip
,$$(BR2_PACKAGE_PROVIDES_
$(2))),$(3))
314 $$(error Configuration error
: both
"$(3)" and
$$(BR2_PACKAGE_PROVIDES_
$(2))\
315 are selected
as providers for virtual package
"$(1)". Only one provider can\
316 be selected at a time. Please fix your configuration
)
320 ################################################################################
321 # inner-generic-package -- generates the make targets needed to build a
324 # argument 1 is the lowercase package name
325 # argument 2 is the uppercase package name, including a HOST_ prefix
327 # argument 3 is the uppercase package name, without the HOST_ prefix
329 # argument 4 is the type (target or host)
331 # Note about variable and function references: inside all blocks that are
332 # evaluated with $(eval), which includes all 'inner-xxx-package' blocks,
333 # specific rules apply with respect to variable and function references.
334 # - Numbered variables (parameters to the block) can be referenced with a single
335 # dollar sign: $(1), $(2), $(3), etc.
336 # - pkgdir and pkgname should be referenced with a single dollar sign too. These
337 # functions rely on 'the most recently parsed makefile' which is supposed to
338 # be the package .mk file. If we defer the evaluation of these functions using
339 # double dollar signs, then they may be evaluated too late, when other
340 # makefiles have already been parsed. One specific case is when $$(pkgdir) is
341 # assigned to a variable using deferred evaluation with '=' and this variable
342 # is used in a target rule outside the eval'ed inner block. In this case, the
343 # pkgdir will be that of the last makefile parsed by buildroot, which is not
344 # the expected value. This mechanism is for example used for the TARGET_PATCH
346 # - All other variables should be referenced with a double dollar sign:
347 # $$(TARGET_DIR), $$($(2)_VERSION), etc. Also all make functions should be
348 # referenced with a double dollar sign: $$(subst), $$(call), $$(filter-out),
349 # etc. This rule ensures that these variables and functions are only expanded
350 # during the $(eval) step, and not earlier. Otherwise, unintuitive and
351 # undesired behavior occurs with respect to these variables and functions.
353 ################################################################################
355 define inner-generic-package
357 # Ensure the package is only declared once, i.e. do not accept that a
358 # package be re-defined by a br2-external tree
359 ifneq ($(call
strip,$(filter $(1),$(PACKAGES_ALL
))),)
360 $$(error Package
'$(1)' defined a second time in
'$(pkgdir)'; \
361 previous definition was in
'$$($(2)_PKGDIR)')
365 # Define default values for various package-related variables, if not
366 # already defined. For some variables (version, source, site and
367 # subdir), if they are undefined, we try to see if a variable without
368 # the HOST_ prefix is defined. If so, we use such a variable, so that
369 # this information has only to be specified once, for both the
370 # target and host packages of a given .mk file.
374 $(2)_RAWNAME
= $$(patsubst host-
%,%,$(1))
375 $(2)_PKGDIR
= $(pkgdir
)
377 # Keep the package version that may contain forward slashes in the _DL_VERSION
378 # variable, then replace all forward slashes ('/') by underscores ('_') to
379 # sanitize the package version that is used in paths, directory and file names.
380 # Forward slashes may appear in the package's version when pointing to a
381 # version control system branch or tag, for example remotes/origin/1_10_stable.
382 # Similar for spaces and colons (:) that may appear in date-based revisions for
385 ifdef $(3)_DL_VERSION
386 $(2)_DL_VERSION
:= $$($(3)_DL_VERSION
)
387 else ifdef $(3)_VERSION
388 $(2)_DL_VERSION
:= $$($(3)_VERSION
)
391 $(2)_DL_VERSION
:= $$(strip $$($(2)_VERSION
))
393 $(2)_VERSION
:= $$(call sanitize
,$$($(2)_DL_VERSION
))
395 ifdef $(3)_OVERRIDE_SRCDIR
396 $(2)_OVERRIDE_SRCDIR ?
= $$($(3)_OVERRIDE_SRCDIR
)
399 $(2)_BASE_NAME
= $$(if
$$($(2)_VERSION
),$(1)-$$($(2)_VERSION
),$(1))
400 $(2)_RAW_BASE_NAME
= $$(if
$$($(2)_VERSION
),$$($(2)_RAWNAME
)-$$($(2)_VERSION
),$$($(2)_RAWNAME
))
401 $(2)_DL_DIR
= $$(DL_DIR
)/$$($(2)_BASE_NAME
)
402 $(2)_DIR
= $$(BUILD_DIR
)/$$($(2)_BASE_NAME
)
406 $(2)_SUBDIR
= $$($(3)_SUBDIR
)
412 ifndef $(2)_STRIP_COMPONENTS
413 ifdef $(3)_STRIP_COMPONENTS
414 $(2)_STRIP_COMPONENTS
= $$($(3)_STRIP_COMPONENTS
)
416 $(2)_STRIP_COMPONENTS ?
= 1
420 $(2)_SRCDIR
= $$($(2)_DIR
)/$$($(2)_SUBDIR
)
421 $(2)_BUILDDIR ?
= $$($(2)_SRCDIR
)
423 ifneq ($$($(2)_OVERRIDE_SRCDIR
),)
424 $(2)_VERSION
= custom
429 $(2)_SOURCE
= $$($(3)_SOURCE
)
430 else ifdef $(2)_VERSION
431 $(2)_SOURCE ?
= $$($(2)_RAW_BASE_NAME
).
tar.gz
435 # If FOO_ACTUAL_SOURCE_TARBALL is explicitly defined, it means FOO_SOURCE is
436 # indeed a binary (e.g. external toolchain) and FOO_ACTUAL_SOURCE_TARBALL/_SITE
437 # point to the actual sources tarball. Use the actual sources for legal-info.
438 # For most packages the FOO_SITE/FOO_SOURCE pair points to real source code,
439 # so these are the defaults for FOO_ACTUAL_*.
440 $(2)_ACTUAL_SOURCE_TARBALL ?
= $$($(2)_SOURCE
)
441 $(2)_ACTUAL_SOURCE_SITE ?
= $$(call qstrip
,$$($(2)_SITE
))
445 $(2)_PATCH
= $$($(3)_PATCH
)
449 $(2)_ALL_DOWNLOADS
= \
450 $$(foreach p
,$$($(2)_SOURCE
) $$($(2)_PATCH
) $$($(2)_EXTRA_DOWNLOADS
),\
451 $$(if
$$(findstring ://,$$(p
)),$$(p
),\
452 $$($(2)_SITE
)/$$(p
)))
456 $(2)_SITE
= $$($(3)_SITE
)
460 ifndef $(2)_SITE_METHOD
461 ifdef $(3)_SITE_METHOD
462 $(2)_SITE_METHOD
= $$($(3)_SITE_METHOD
)
464 # Try automatic detection using the scheme part of the URI
465 $(2)_SITE_METHOD
= $$(call geturischeme
,$$($(2)_SITE
))
469 # Do not accept to download git submodule if not using the git method
470 ifneq ($$($(2)_GIT_SUBMODULES
),)
471 ifneq ($$($(2)_SITE_METHOD
),git
)
472 $$(error
$(2) declares having git sub-modules
, but does not use the \
473 'git' method
(uses
'$$($(2)_SITE_METHOD)' instead
))
477 ifeq ($$($(2)_SITE_METHOD
),local
)
478 ifeq ($$($(2)_OVERRIDE_SRCDIR
),)
479 $(2)_OVERRIDE_SRCDIR
= $$($(2)_SITE
)
485 $(2)_LICENSE
= $$($(3)_LICENSE
)
489 $(2)_LICENSE ?
= unknown
491 ifndef $(2)_LICENSE_FILES
492 ifdef $(3)_LICENSE_FILES
493 $(2)_LICENSE_FILES
= $$($(3)_LICENSE_FILES
)
497 ifndef $(2)_REDISTRIBUTE
498 ifdef $(3)_REDISTRIBUTE
499 $(2)_REDISTRIBUTE
= $$($(3)_REDISTRIBUTE
)
503 $(2)_REDISTRIBUTE ?
= YES
505 $(2)_REDIST_SOURCES_DIR
= $$(REDIST_SOURCES_DIR_
$$(call UPPERCASE
,$(4)))/$$($(2)_RAW_BASE_NAME
)
507 # When a target package is a toolchain dependency set this variable to
508 # 'NO' so the 'toolchain' dependency is not added to prevent a circular
510 $(2)_ADD_TOOLCHAIN_DEPENDENCY ?
= YES
513 ifneq ($(1),skeleton
)
514 $(2)_DEPENDENCIES
+= skeleton
516 ifeq ($$($(2)_ADD_TOOLCHAIN_DEPENDENCY
),YES
)
517 $(2)_DEPENDENCIES
+= toolchain
521 # Eliminate duplicates in dependencies
522 $(2)_FINAL_DEPENDENCIES
= $$(sort $$($(2)_DEPENDENCIES
))
523 $(2)_FINAL_PATCH_DEPENDENCIES
= $$(sort $$($(2)_PATCH_DEPENDENCIES
))
524 $(2)_FINAL_ALL_DEPENDENCIES
= $$(sort $$($(2)_FINAL_DEPENDENCIES
) $$($(2)_FINAL_PATCH_DEPENDENCIES
))
526 $(2)_INSTALL_STAGING ?
= NO
527 $(2)_INSTALL_IMAGES ?
= NO
528 $(2)_INSTALL_TARGET ?
= YES
530 # define sub-target stamps
531 $(2)_TARGET_INSTALL_TARGET
= $$($(2)_DIR
)/.stamp_target_installed
532 $(2)_TARGET_INSTALL_STAGING
= $$($(2)_DIR
)/.stamp_staging_installed
533 $(2)_TARGET_INSTALL_IMAGES
= $$($(2)_DIR
)/.stamp_images_installed
534 $(2)_TARGET_INSTALL_HOST
= $$($(2)_DIR
)/.stamp_host_installed
535 $(2)_TARGET_BUILD
= $$($(2)_DIR
)/.stamp_built
536 $(2)_TARGET_CONFIGURE
= $$($(2)_DIR
)/.stamp_configured
537 $(2)_TARGET_RSYNC
= $$($(2)_DIR
)/.stamp_rsynced
538 $(2)_TARGET_PATCH
= $$($(2)_DIR
)/.stamp_patched
539 $(2)_TARGET_EXTRACT
= $$($(2)_DIR
)/.stamp_extracted
540 $(2)_TARGET_SOURCE
= $$($(2)_DIR
)/.stamp_downloaded
541 $(2)_TARGET_ACTUAL_SOURCE
= $$($(2)_DIR
)/.stamp_actual_downloaded
542 $(2)_TARGET_DIRCLEAN
= $$($(2)_DIR
)/.stamp_dircleaned
544 # default extract command
545 $(2)_EXTRACT_CMDS ?
= \
546 $$(if
$$($(2)_SOURCE
),$$(INFLATE
$$(suffix $$($(2)_SOURCE
))) $$(DL_DIR
)/$$($(2)_SOURCE
) | \
547 $$(TAR
) --strip-components
=$$($(2)_STRIP_COMPONENTS
) \
549 $$(foreach x
,$$($(2)_EXCLUDES
),--exclude
='$$(x)' ) \
552 # pre/post-steps hooks
553 $(2)_PRE_DOWNLOAD_HOOKS ?
=
554 $(2)_POST_DOWNLOAD_HOOKS ?
=
555 $(2)_PRE_EXTRACT_HOOKS ?
=
556 $(2)_POST_EXTRACT_HOOKS ?
=
557 $(2)_PRE_RSYNC_HOOKS ?
=
558 $(2)_POST_RSYNC_HOOKS ?
=
559 $(2)_PRE_PATCH_HOOKS ?
=
560 $(2)_POST_PATCH_HOOKS ?
=
561 $(2)_PRE_CONFIGURE_HOOKS ?
=
562 $(2)_POST_CONFIGURE_HOOKS ?
=
563 $(2)_PRE_BUILD_HOOKS ?
=
564 $(2)_POST_BUILD_HOOKS ?
=
565 $(2)_PRE_INSTALL_HOOKS ?
=
566 $(2)_POST_INSTALL_HOOKS ?
=
567 $(2)_PRE_INSTALL_STAGING_HOOKS ?
=
568 $(2)_POST_INSTALL_STAGING_HOOKS ?
=
569 $(2)_PRE_INSTALL_TARGET_HOOKS ?
=
570 $(2)_POST_INSTALL_TARGET_HOOKS ?
=
571 $(2)_PRE_INSTALL_IMAGES_HOOKS ?
=
572 $(2)_POST_INSTALL_IMAGES_HOOKS ?
=
573 $(2)_PRE_LEGAL_INFO_HOOKS ?
=
574 $(2)_POST_LEGAL_INFO_HOOKS ?
=
575 $(2)_TARGET_FINALIZE_HOOKS ?
=
577 # human-friendly targets and target sequencing
580 ifeq ($$($(2)_TYPE
),host
)
581 $(1)-install: $(1)-install-host
583 $(1)-install: $(1)-install-staging
$(1)-install-target
$(1)-install-images
586 ifeq ($$($(2)_INSTALL_TARGET
),YES
)
587 $(1)-install-target
: $$($(2)_TARGET_INSTALL_TARGET
)
588 $$($(2)_TARGET_INSTALL_TARGET
): $$($(2)_TARGET_BUILD
)
593 ifeq ($$($(2)_INSTALL_STAGING
),YES
)
594 $(1)-install-staging
: $$($(2)_TARGET_INSTALL_STAGING
)
595 $$($(2)_TARGET_INSTALL_STAGING
): $$($(2)_TARGET_BUILD
)
596 # Some packages use install-staging stuff for install-target
597 $$($(2)_TARGET_INSTALL_TARGET
): $$($(2)_TARGET_INSTALL_STAGING
)
599 $(1)-install-staging
:
602 ifeq ($$($(2)_INSTALL_IMAGES
),YES
)
603 $(1)-install-images
: $$($(2)_TARGET_INSTALL_IMAGES
)
604 $$($(2)_TARGET_INSTALL_IMAGES
): $$($(2)_TARGET_BUILD
)
609 $(1)-install-host
: $$($(2)_TARGET_INSTALL_HOST
)
610 $$($(2)_TARGET_INSTALL_HOST
): $$($(2)_TARGET_BUILD
)
612 $(1)-build
: $$($(2)_TARGET_BUILD
)
613 $$($(2)_TARGET_BUILD
): $$($(2)_TARGET_CONFIGURE
)
615 # Since $(2)_FINAL_DEPENDENCIES are phony targets, they are always "newer"
616 # than $(2)_TARGET_CONFIGURE. This would force the configure step (and
617 # therefore the other steps as well) to be re-executed with every
618 # invocation of make. Therefore, make $(2)_FINAL_DEPENDENCIES an order-only
619 # dependency by using |.
621 $(1)-configure
: $$($(2)_TARGET_CONFIGURE
)
622 $$($(2)_TARGET_CONFIGURE
): |
$$($(2)_FINAL_DEPENDENCIES
)
624 $$($(2)_TARGET_SOURCE
) $$($(2)_TARGET_RSYNC
): | dirs prepare
625 ifeq ($$(filter $(1),$$(DEPENDENCIES_HOST_PREREQ
)),)
626 $$($(2)_TARGET_SOURCE
) $$($(2)_TARGET_RSYNC
): | dependencies
629 ifeq ($$($(2)_OVERRIDE_SRCDIR
),)
630 # In the normal case (no package override), the sequence of steps is
631 # source, by downloading
636 $$($(2)_TARGET_CONFIGURE
): $$($(2)_TARGET_PATCH
)
638 $(1)-patch
: $$($(2)_TARGET_PATCH
)
639 $$($(2)_TARGET_PATCH
): $$($(2)_TARGET_EXTRACT
)
640 # Order-only dependency
641 $$($(2)_TARGET_PATCH
): |
$$(patsubst %,%-patch
,$$($(2)_FINAL_PATCH_DEPENDENCIES
))
643 $(1)-extract
: $$($(2)_TARGET_EXTRACT
)
644 $$($(2)_TARGET_EXTRACT
): $$($(2)_TARGET_SOURCE
)
646 $(1)-depends
: $$($(2)_FINAL_DEPENDENCIES
)
648 $(1)-source
: $$($(2)_TARGET_SOURCE
)
650 $(1)-all-source
: $(1)-legal-source
651 $(1)-legal-info
: $(1)-legal-source
652 $(1)-legal-source
: $(1)-source
654 # Only download the actual source if it differs from the 'main' archive
655 ifneq ($$($(2)_ACTUAL_SOURCE_TARBALL
),)
656 ifneq ($$($(2)_ACTUAL_SOURCE_TARBALL
),$$($(2)_SOURCE
))
657 $(1)-legal-source
: $$($(2)_TARGET_ACTUAL_SOURCE
)
658 endif # actual sources != sources
659 endif # actual sources != ""
662 $$(foreach p
,$$($(2)_ALL_DOWNLOADS
),$$(call SOURCE_CHECK
,$$(p
))$$(sep
))
665 @for p in
$$($(2)_SOURCE
) $$($(2)_PATCH
) $$($(2)_EXTRA_DOWNLOADS
) ; do \
666 echo
`basename $$$$p` ; \
669 # In the package override case, the sequence of steps
670 # source, by rsyncing
674 # Use an order-only dependency so the "<pkg>-clean-for-rebuild" rule
675 # can remove the stamp file without triggering the configure step.
676 $$($(2)_TARGET_CONFIGURE
): |
$$($(2)_TARGET_RSYNC
)
678 $(1)-depends
: $$($(2)_FINAL_DEPENDENCIES
)
680 $(1)-patch
: $(1)-rsync
681 $(1)-extract
: $(1)-rsync
683 $(1)-rsync
: $$($(2)_TARGET_RSYNC
)
689 test -d
$$($(2)_OVERRIDE_SRCDIR
)
692 @echo
"file://$$($(2)_OVERRIDE_SRCDIR)"
696 @echo
$$($(2)_VERSION
)
699 @echo
$$($(2)_FINAL_ALL_DEPENDENCIES
)
701 $(1)-graph-depends
: graph-depends-requirements
702 @
$$(INSTALL
) -d
$$(GRAPHS_DIR
)
703 @cd
"$$(CONFIG_DIR)"; \
704 $$(TOPDIR
)/support
/scripts
/graph-depends
$$(BR2_GRAPH_DEPS_OPTS
) \
705 -p
$(1) -o
$$(GRAPHS_DIR
)/$$(@
).dot
706 dot
$$(BR2_GRAPH_DOT_OPTS
) -T
$$(BR_GRAPH_OUT
) \
707 -o
$$(GRAPHS_DIR
)/$$(@
).
$$(BR_GRAPH_OUT
) \
708 $$(GRAPHS_DIR
)/$$(@
).dot
710 $(1)-all-source
: $(1)-source
711 $(1)-all-source
: $$(foreach p
,$$($(2)_FINAL_ALL_DEPENDENCIES
),$$(p
)-all-source
)
713 $(1)-all-source-check
: $(1)-source-check
714 $(1)-all-source-check
: $$(foreach p
,$$($(2)_FINAL_ALL_DEPENDENCIES
),$$(p
)-all-source-check
)
716 $(1)-all-external-deps
: $(1)-external-deps
717 $(1)-all-external-deps
: $$(foreach p
,$$($(2)_FINAL_ALL_DEPENDENCIES
),$$(p
)-all-external-deps
)
719 $(1)-all-legal-info
: $(1)-legal-info
720 $(1)-all-legal-info
: $$(foreach p
,$$($(2)_FINAL_ALL_DEPENDENCIES
),$$(p
)-all-legal-info
)
722 $(1)-dirclean
: $$($(2)_TARGET_DIRCLEAN
)
724 $(1)-clean-for-reinstall
:
725 ifneq ($$($(2)_OVERRIDE_SRCDIR
),)
726 rm -f
$$($(2)_TARGET_RSYNC
)
728 rm -f
$$($(2)_TARGET_INSTALL_STAGING
)
729 rm -f
$$($(2)_TARGET_INSTALL_TARGET
)
730 rm -f
$$($(2)_TARGET_INSTALL_IMAGES
)
731 rm -f
$$($(2)_TARGET_INSTALL_HOST
)
733 $(1)-reinstall
: $(1)-clean-for-reinstall
$(1)
735 $(1)-clean-for-rebuild
: $(1)-clean-for-reinstall
736 rm -f
$$($(2)_TARGET_BUILD
)
738 $(1)-rebuild
: $(1)-clean-for-rebuild
$(1)
740 $(1)-clean-for-reconfigure
: $(1)-clean-for-rebuild
741 rm -f
$$($(2)_TARGET_CONFIGURE
)
743 $(1)-reconfigure
: $(1)-clean-for-reconfigure
$(1)
745 # define the PKG variable for all targets, containing the
746 # uppercase package variable prefix
747 $$($(2)_TARGET_INSTALL_TARGET
): PKG
=$(2)
748 $$($(2)_TARGET_INSTALL_STAGING
): PKG
=$(2)
749 $$($(2)_TARGET_INSTALL_IMAGES
): PKG
=$(2)
750 $$($(2)_TARGET_INSTALL_HOST
): PKG
=$(2)
751 $$($(2)_TARGET_BUILD
): PKG
=$(2)
752 $$($(2)_TARGET_CONFIGURE
): PKG
=$(2)
753 $$($(2)_TARGET_RSYNC
): SRCDIR
=$$($(2)_OVERRIDE_SRCDIR
)
754 $$($(2)_TARGET_RSYNC
): PKG
=$(2)
755 $$($(2)_TARGET_PATCH
): PKG
=$(2)
756 $$($(2)_TARGET_PATCH
): RAWNAME
=$$(patsubst host-
%,%,$(1))
757 $$($(2)_TARGET_PATCH
): PKGDIR
=$(pkgdir
)
758 $$($(2)_TARGET_EXTRACT
): PKG
=$(2)
759 $$($(2)_TARGET_SOURCE
): PKG
=$(2)
760 $$($(2)_TARGET_SOURCE
): PKGDIR
=$(pkgdir
)
761 $$($(2)_TARGET_ACTUAL_SOURCE
): PKG
=$(2)
762 $$($(2)_TARGET_ACTUAL_SOURCE
): PKGDIR
=$(pkgdir
)
763 $$($(2)_TARGET_DIRCLEAN
): PKG
=$(2)
765 # Compute the name of the Kconfig option that correspond to the
766 # package being enabled. We handle three cases: the special Linux
767 # kernel case, the bootloaders case, and the normal packages case.
769 $(2)_KCONFIG_VAR
= BR2_LINUX_KERNEL
770 else ifneq ($$(filter boot
/% $(BR2_EXTERNAL
)/boot
/%,$(pkgdir
)),)
771 $(2)_KCONFIG_VAR
= BR2_TARGET_
$(2)
772 else ifneq ($$(filter toolchain
/% $(BR2_EXTERNAL
)/toolchain
/%,$(pkgdir
)),)
773 $(2)_KCONFIG_VAR
= BR2_
$(2)
775 $(2)_KCONFIG_VAR
= BR2_PACKAGE_
$(2)
778 # legal-info: declare dependencies and set values used later for the manifest
779 ifneq ($$($(2)_LICENSE_FILES
),)
780 $(2)_MANIFEST_LICENSE_FILES
= $$($(2)_LICENSE_FILES
)
782 $(2)_MANIFEST_LICENSE_FILES ?
= not saved
784 # We need to extract and patch a package to be able to retrieve its
785 # license files (if any) and the list of patches applied to it (if
787 $(1)-legal-info
: $(1)-patch
789 # We only save the sources of packages we want to redistribute, that are
790 # non-overriden (local or true override).
791 ifeq ($$($(2)_REDISTRIBUTE
),YES
)
792 ifeq ($$($(2)_OVERRIDE_SRCDIR
),)
793 # Packages that have a tarball need it downloaded beforehand
794 $(1)-legal-info
: $(1)-source
$$(REDIST_SOURCES_DIR_
$$(call UPPERCASE
,$(4)))
798 # legal-info: produce legally relevant info.
800 # Packages without a source are assumed to be part of Buildroot, skip them.
801 $$(foreach hook
,$$($(2)_PRE_LEGAL_INFO_HOOKS
),$$(call
$$(hook
))$$(sep
))
802 ifneq ($$(call qstrip
,$$($(2)_SOURCE
)),)
804 # Save license files if defined
805 # We save the license files for any kind of package: normal, local,
806 # overridden, or non-redistributable alike.
807 # The reason to save license files even for no-redistribute packages
808 # is that the license still applies to the files distributed as part
809 # of the rootfs, even if the sources are not themselves redistributed.
810 ifeq ($$(call qstrip
,$$($(2)_LICENSE_FILES
)),)
811 @
$$(call legal-license-nofiles
,$$($(2)_RAW_BASE_NAME
),$$(call UPPERCASE
,$(4)))
812 @
$$(call legal-warning-pkg
,$$($(2)_RAW_BASE_NAME
),cannot save license
($(2)_LICENSE_FILES not defined
))
814 @
$$(foreach F
,$$($(2)_LICENSE_FILES
),$$(call legal-license-file
,$$($(2)_RAW_BASE_NAME
),$$(F
),$$($(2)_DIR
)/$$(F
),$$(call UPPERCASE
,$(4)))$$(sep
))
815 endif # license files
817 ifeq ($$($(2)_SITE_METHOD
),local
)
818 # Packages without a tarball: don't save and warn
819 @
$$(call legal-warning-nosource
,$$($(2)_RAWNAME
),local
)
821 else ifneq ($$($(2)_OVERRIDE_SRCDIR
),)
822 @
$$(call legal-warning-nosource
,$$($(2)_RAWNAME
),override)
827 ifeq ($$($(2)_REDISTRIBUTE
),YES
)
828 # Save the source tarball and any extra downloads, but not
829 # patches, as they are handled specially afterwards.
830 $$(foreach e
,$$($(2)_ACTUAL_SOURCE_TARBALL
) $$(notdir $$($(2)_EXTRA_DOWNLOADS
)),\
831 $$(Q
)support
/scripts
/hardlink-or-copy \
833 $$($(2)_REDIST_SOURCES_DIR
)$$(sep
))
834 # Save patches and generate the series file
835 $$(Q
)while read f
; do \
836 support
/scripts
/hardlink-or-copy \
838 $$($(2)_REDIST_SOURCES_DIR
) || exit
1; \
839 printf
"%s\n" "$$$${f##*/}" >>$$($(2)_REDIST_SOURCES_DIR
)/series || exit
1; \
840 done
<$$($(2)_DIR
)/.applied_patches_list
843 endif # other packages
844 @
$$(call legal-manifest
,$$($(2)_RAWNAME
),$$($(2)_VERSION
),$$($(2)_LICENSE
),$$($(2)_MANIFEST_LICENSE_FILES
),$$($(2)_ACTUAL_SOURCE_TARBALL
),$$($(2)_ACTUAL_SOURCE_SITE
),$$(call UPPERCASE
,$(4)))
845 endif # ifneq ($$(call qstrip,$$($(2)_SOURCE)),)
846 $$(foreach hook
,$$($(2)_POST_LEGAL_INFO_HOOKS
),$$(call
$$(hook
))$$(sep
))
848 # add package to the general list of targets if requested by the buildroot
850 ifeq ($$($$($(2)_KCONFIG_VAR
)),y
)
852 # Ensure the calling package is the declared provider for all the virtual
853 # packages it claims to be an implementation of.
854 ifneq ($$($(2)_PROVIDES
),)
855 $$(foreach pkg
,$$($(2)_PROVIDES
),\
856 $$(eval
$$(call virt-provides-single
,$$(pkg
),$$(call UPPERCASE
,$$(pkg
)),$(1))$$(sep
)))
859 # Ensure unified variable name conventions between all packages Some
860 # of the variables are used by more than one infrastructure; so,
861 # rather than duplicating the checks in each infrastructure, we check
862 # all variables here in pkg-generic, even though pkg-generic should
863 # have no knowledge of infra-specific variables.
864 $(eval
$(call check-deprecated-variable
,$(2)_MAKE_OPT
,$(2)_MAKE_OPTS
))
865 $(eval
$(call check-deprecated-variable
,$(2)_INSTALL_OPT
,$(2)_INSTALL_OPTS
))
866 $(eval
$(call check-deprecated-variable
,$(2)_INSTALL_TARGET_OPT
,$(2)_INSTALL_TARGET_OPTS
))
867 $(eval
$(call check-deprecated-variable
,$(2)_INSTALL_STAGING_OPT
,$(2)_INSTALL_STAGING_OPTS
))
868 $(eval
$(call check-deprecated-variable
,$(2)_INSTALL_HOST_OPT
,$(2)_INSTALL_HOST_OPTS
))
869 $(eval
$(call check-deprecated-variable
,$(2)_AUTORECONF_OPT
,$(2)_AUTORECONF_OPTS
))
870 $(eval
$(call check-deprecated-variable
,$(2)_CONF_OPT
,$(2)_CONF_OPTS
))
871 $(eval
$(call check-deprecated-variable
,$(2)_BUILD_OPT
,$(2)_BUILD_OPTS
))
872 $(eval
$(call check-deprecated-variable
,$(2)_GETTEXTIZE_OPT
,$(2)_GETTEXTIZE_OPTS
))
873 $(eval
$(call check-deprecated-variable
,$(2)_KCONFIG_OPT
,$(2)_KCONFIG_OPTS
))
877 ifneq ($$($(2)_PERMISSIONS
),)
878 PACKAGES_PERMISSIONS_TABLE
+= $$($(2)_PERMISSIONS
)$$(sep
)
880 ifneq ($$($(2)_DEVICES
),)
881 PACKAGES_DEVICES_TABLE
+= $$($(2)_DEVICES
)$$(sep
)
883 ifneq ($$($(2)_USERS
),)
884 PACKAGES_USERS
+= $$($(2)_USERS
)$$(sep
)
886 TARGET_FINALIZE_HOOKS
+= $$($(2)_TARGET_FINALIZE_HOOKS
)
888 ifeq ($$($(2)_SITE_METHOD
),svn
)
889 DL_TOOLS_DEPENDENCIES
+= svn
890 else ifeq ($$($(2)_SITE_METHOD
),git
)
891 DL_TOOLS_DEPENDENCIES
+= git
892 else ifeq ($$($(2)_SITE_METHOD
),bzr
)
893 DL_TOOLS_DEPENDENCIES
+= bzr
894 else ifeq ($$($(2)_SITE_METHOD
),scp
)
895 DL_TOOLS_DEPENDENCIES
+= scp ssh
896 else ifeq ($$($(2)_SITE_METHOD
),hg
)
897 DL_TOOLS_DEPENDENCIES
+= hg
898 else ifeq ($$($(2)_SITE_METHOD
),cvs
)
899 DL_TOOLS_DEPENDENCIES
+= cvs
902 # $(firstword) is used here because the extractor can have arguments, like
903 # ZCAT="gzip -d -c", and to check for the dependency we only want 'gzip'.
904 # Do not add xzcat to the list of required dependencies, as it gets built
905 # automatically if it isn't found.
906 ifneq ($$(call suitable-extractor
,$$($(2)_SOURCE
)),$$(XZCAT
))
907 DL_TOOLS_DEPENDENCIES
+= $$(firstword $$(call suitable-extractor
,$$($(2)_SOURCE
)))
910 # Ensure all virtual targets are PHONY. Listed alphabetically.
912 $(1)-all-external-deps \
913 $(1)-all-legal-info \
915 $(1)-all-source-check \
917 $(1)-clean-for-rebuild \
918 $(1)-clean-for-reconfigure \
919 $(1)-clean-for-reinstall \
928 $(1)-install-images \
929 $(1)-install-staging \
930 $(1)-install-target \
943 ifneq ($$($(2)_SOURCE
),)
944 ifeq ($$($(2)_SITE
),)
945 $$(error
$(2)_SITE cannot be empty when
$(2)_SOURCE is not
)
949 ifeq ($$(patsubst %/,ERROR
,$$($(2)_SITE
)),ERROR
)
950 $$(error
$(2)_SITE
($$($(2)_SITE
)) cannot have a trailing slash
)
953 ifneq ($$($(2)_HELP_CMDS
),)
954 HELP_PACKAGES
+= $(2)
957 endif # $(2)_KCONFIG_VAR
958 endef # inner-generic-package
960 ################################################################################
961 # generic-package -- the target generator macro for generic packages
962 ################################################################################
964 # In the case of target packages, keep the package name "pkg"
965 generic-package
= $(call inner-generic-package
,$(pkgname
),$(call UPPERCASE
,$(pkgname
)),$(call UPPERCASE
,$(pkgname
)),target
)
966 # In the case of host packages, turn the package name "pkg" into "host-pkg"
967 host-generic-package
= $(call inner-generic-package
,host-
$(pkgname
),$(call UPPERCASE
,host-
$(pkgname
)),$(call UPPERCASE
,$(pkgname
)),host
)