pkg-utils.mk 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081
  1. ################################################################################
  2. #
  3. # This file contains various utility functions used by the package
  4. # infrastructure, or by the packages themselves.
  5. #
  6. ################################################################################
  7. #
  8. # Manipulation of .config files based on the Kconfig
  9. # infrastructure. Used by the BusyBox package, the Linux kernel
  10. # package, and more.
  11. #
  12. define KCONFIG_ENABLE_OPT # (option, file)
  13. $(SED) "/\\<$(1)\\>/d" $(2)
  14. echo '$(1)=y' >> $(2)
  15. endef
  16. define KCONFIG_SET_OPT # (option, value, file)
  17. $(SED) "/\\<$(1)\\>/d" $(3)
  18. echo '$(1)=$(2)' >> $(3)
  19. endef
  20. define KCONFIG_DISABLE_OPT # (option, file)
  21. $(SED) "/\\<$(1)\\>/d" $(2)
  22. echo '# $(1) is not set' >> $(2)
  23. endef
  24. # Helper functions to determine the name of a package and its
  25. # directory from its makefile directory, using the $(MAKEFILE_LIST)
  26. # variable provided by make. This is used by the *-package macros to
  27. # automagically find where the package is located.
  28. pkgdir = $(dir $(lastword $(MAKEFILE_LIST)))
  29. pkgname = $(lastword $(subst /, ,$(pkgdir)))
  30. # Define extractors for different archive suffixes
  31. INFLATE.bz2 = $(BZCAT)
  32. INFLATE.gz = $(ZCAT)
  33. INFLATE.lzma = $(XZCAT)
  34. INFLATE.tbz = $(BZCAT)
  35. INFLATE.tbz2 = $(BZCAT)
  36. INFLATE.tgz = $(ZCAT)
  37. INFLATE.xz = $(XZCAT)
  38. INFLATE.tar = cat
  39. # suitable-extractor(filename): returns extractor based on suffix
  40. suitable-extractor = $(INFLATE$(suffix $(1)))
  41. # check-deprecated-variable -- throw an error on deprecated variables
  42. # example:
  43. # $(eval $(call check-deprecated-variable,FOO_MAKE_OPT,FOO_MAKE_OPTS))
  44. define check-deprecated-variable # (deprecated var, new var)
  45. ifneq ($$(origin $(1)),undefined)
  46. $$(error Package error: use $(2) instead of $(1). Please fix your .mk file)
  47. endif
  48. endef
  49. #
  50. # legal-info helper functions
  51. #
  52. LEGAL_INFO_SEPARATOR = "::::::::::::::::::::::::::::::::::::::::::::::::::::::::::::"
  53. define legal-warning # text
  54. echo "WARNING: $(1)" >>$(LEGAL_WARNINGS)
  55. endef
  56. define legal-warning-pkg # pkg, text
  57. echo "WARNING: $(1): $(2)" >>$(LEGAL_WARNINGS)
  58. endef
  59. define legal-warning-nosource # pkg, {local|override}
  60. $(call legal-warning-pkg,$(1),sources not saved ($(2) packages not handled))
  61. endef
  62. define legal-manifest # pkg, version, license, license-files, source, url, {HOST|TARGET}
  63. echo '"$(1)","$(2)","$(3)","$(4)","$(5)","$(6)"' >>$(LEGAL_MANIFEST_CSV_$(7))
  64. endef
  65. define legal-license-file # pkg, filename, file-fullpath, {HOST|TARGET}
  66. mkdir -p $(LICENSE_FILES_DIR_$(4))/$(1)/$(dir $(2)) && \
  67. cp $(3) $(LICENSE_FILES_DIR_$(4))/$(1)/$(2)
  68. endef