1 ################################################################################
3 # This file contains various utility functions used by the package
4 # infrastructure, or by the packages themselves.
6 ################################################################################
9 # Manipulation of .config files based on the Kconfig
10 # infrastructure. Used by the BusyBox package, the Linux kernel
14 define KCONFIG_ENABLE_OPT # (option, file)
15 $(SED) "/\\<$(1)\\>/d" $(2)
19 define KCONFIG_SET_OPT # (option, value, file)
20 $(SED) "/\\<$(1)\\>/d" $(3)
21 echo '$(1)=$(2)' >> $(3)
24 define KCONFIG_DISABLE_OPT # (option, file)
25 $(SED) "/\\<$(1)\\>/d" $(2)
26 echo '# $(1) is not set' >> $(2)
29 # Helper functions to determine the name of a package and its
30 # directory from its makefile directory, using the $(MAKEFILE_LIST)
31 # variable provided by make. This is used by the *-package macros to
32 # automagically find where the package is located.
33 pkgdir = $(dir $(lastword $(MAKEFILE_LIST)))
34 pkgname = $(lastword $(subst /, ,$(pkgdir)))
36 # Define extractors for different archive suffixes
37 INFLATE.bz2 = $(BZCAT)
40 INFLATE.lzma = $(XZCAT)
41 INFLATE.tbz = $(BZCAT)
42 INFLATE.tbz2 = $(BZCAT)
46 # suitable-extractor(filename): returns extractor based on suffix
47 suitable-extractor = $(INFLATE$(suffix $(1)))
49 # extractor-dependency(filename): returns extractor for 'filename' if the
50 # extractor is a dependency. If we build the extractor return nothing.
51 # $(firstword) is used here because the extractor can have arguments, like
52 # ZCAT="gzip -d -c", and to check for the dependency we only want 'gzip'.
53 extractor-dependency = $(firstword $(INFLATE$(filter-out \
54 $(EXTRACTOR_DEPENDENCY_PRECHECKED_EXTENSIONS),$(suffix $(1)))))
56 # check-deprecated-variable -- throw an error on deprecated variables
58 # $(eval $(call check-deprecated-variable,FOO_MAKE_OPT,FOO_MAKE_OPTS))
59 define check-deprecated-variable # (deprecated var, new var)
60 ifneq ($$(origin $(1)),undefined)
61 $$(error Package error: use $(2) instead of $(1). Please fix your .mk file)
66 # legal-info helper functions
68 LEGAL_INFO_SEPARATOR = "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
70 define legal-warning # text
71 echo "WARNING: $(1)" >>$(LEGAL_WARNINGS)
74 define legal-warning-pkg # pkg, text
75 echo "WARNING: $(1): $(2)" >>$(LEGAL_WARNINGS)
78 define legal-warning-nosource # pkg, {local|override}
79 $(call legal-warning-pkg,$(1),sources not saved ($(2) packages not handled))
82 define legal-manifest # pkg, version, license, license-files, source, url, {HOST|TARGET}
83 echo '"$(1)","$(2)","$(3)","$(4)","$(5)","$(6)"' >>$(LEGAL_MANIFEST_CSV_$(7))
86 define legal-license-file # pkgname, pkgname-pkgver, pkgdir, filename, file-fullpath, {HOST|TARGET}
87 mkdir -p $(LICENSE_FILES_DIR_$(6))/$(2)/$(dir $(4)) && \
89 if [ -f $(3)/$($(PKG)_VERSION)/$(1).hash ]; then \
90 support/download/check-hash $(3)/$($(PKG)_VERSION)/$(1).hash $(5) $(4); \
92 support/download/check-hash $(3)/$(1).hash $(5) $(4); \
94 case $${?} in (0|3) ;; (*) exit 1;; esac; \
96 cp $(5) $(LICENSE_FILES_DIR_$(6))/$(2)/$(4)