1
0

Makefile 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127
  1. #
  2. # Copyright (C) 2006-2010 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. curdir:=package
  8. include $(INCLUDE_DIR)/feeds.mk
  9. include $(INCLUDE_DIR)/rootfs.mk
  10. -include $(TMP_DIR)/.packagedeps
  11. package-y += kernel/linux
  12. $(curdir)/autoremove:=1
  13. $(curdir)/builddirs:=$(sort $(package-) $(package-y) $(package-m))
  14. $(curdir)/builddirs-default:=. $(sort $(package-y) $(package-m))
  15. $(curdir)/builddirs-prereq:=. $(sort $(prereq-y) $(prereq-m))
  16. ifdef CHECK_ALL
  17. $(curdir)/builddirs-check:=$($(curdir)/builddirs)
  18. $(curdir)/builddirs-download:=$($(curdir)/builddirs)
  19. endif
  20. ifneq ($(IGNORE_ERRORS),)
  21. package-y-filter := $(package-y)
  22. package-m-filter := $(filter-out $(package-y),$(package-m))
  23. package-n-filter := $(filter-out $(package-y) $(package-m),$(package-))
  24. package-ignore-errors := $(filter n m y,$(IGNORE_ERRORS))
  25. package-ignore-errors := $(if $(package-ignore-errors),$(package-ignore-errors),n m)
  26. package-ignore-subdirs := $(sort $(foreach m,$(package-ignore-errors),$(package-$(m)-filter)))
  27. $(curdir)/builddirs-ignore-download := $(package-ignore-subdirs)
  28. $(curdir)/builddirs-ignore-compile := $(package-ignore-subdirs)
  29. $(curdir)/builddirs-ignore-host-download := $(package-ignore-subdirs)
  30. $(curdir)/builddirs-ignore-host-compile := $(package-ignore-subdirs)
  31. endif
  32. PACKAGE_INSTALL_FILES:= \
  33. $(foreach pkg,$(sort $(package-y)), \
  34. $(foreach variant, \
  35. $(if $(strip $(package/$(pkg)/variants)), \
  36. $(package/$(pkg)/variants), \
  37. $(if $(package/$(pkg)/default-variant), \
  38. $(package/$(pkg)/default-variant), \
  39. default \
  40. ) \
  41. ), \
  42. $(PKG_INFO_DIR)/$(lastword $(subst /,$(space),$(pkg))).$(variant).install \
  43. ) \
  44. )
  45. $(curdir)/cleanup: $(TMP_DIR)/.build
  46. rm -rf $(STAGING_DIR_ROOT)
  47. $(curdir)/merge:
  48. rm -rf $(PACKAGE_DIR_ALL)
  49. mkdir -p $(PACKAGE_DIR_ALL)
  50. -$(foreach pdir,$(PACKAGE_SUBDIRS),$(if $(wildcard $(pdir)/*.ipk),ln -s $(pdir)/*.ipk $(PACKAGE_DIR_ALL);))
  51. $(curdir)/merge-index: $(curdir)/merge
  52. (cd $(PACKAGE_DIR_ALL) && $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages; )
  53. ifndef SDK
  54. $(curdir)//compile = $(STAGING_DIR)/.prepared $(BIN_DIR)
  55. $(curdir)/compile: $(curdir)/system/opkg/host/compile
  56. endif
  57. $(curdir)/install: $(TMP_DIR)/.build $(curdir)/merge $(if $(CONFIG_TARGET_PER_DEVICE_ROOTFS),$(curdir)/merge-index)
  58. - find $(STAGING_DIR_ROOT) -type d | $(XARGS) chmod 0755
  59. rm -rf $(TARGET_DIR) $(TARGET_DIR_ORIG)
  60. mkdir -p $(TARGET_DIR)/tmp
  61. $(file >$(TMP_DIR)/opkg_install_list,\
  62. $(call opkg_package_files,\
  63. $(foreach pkg,$(shell cat $(PACKAGE_INSTALL_FILES) 2>/dev/null),$(pkg)$(call GetABISuffix,$(pkg)))))
  64. $(call opkg,$(TARGET_DIR)) install $$(cat $(TMP_DIR)/opkg_install_list)
  65. @for file in $(PACKAGE_INSTALL_FILES); do \
  66. [ -s $$file.flags ] || continue; \
  67. for flag in `cat $$file.flags`; do \
  68. $(call opkg,$(TARGET_DIR)) flag $$flag `cat $$file`; \
  69. done; \
  70. done || true
  71. $(CP) $(TARGET_DIR) $(TARGET_DIR_ORIG)
  72. $(call prepare_rootfs,$(TARGET_DIR),$(TOPDIR)/files)
  73. $(curdir)/index: FORCE
  74. @echo Generating package index...
  75. @for d in $(PACKAGE_SUBDIRS); do ( \
  76. mkdir -p $$d; \
  77. cd $$d || continue; \
  78. $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages.manifest; \
  79. grep -vE '^(Maintainer|LicenseFiles|Source|SourceName|Require|SourceDateEpoch)' Packages.manifest > Packages; \
  80. case "$$(((64 + $$(stat -L -c%s Packages)) % 128))" in 110|111) \
  81. $(call ERROR_MESSAGE,WARNING: Applying padding in $$d/Packages to workaround usign SHA-512 bug!); \
  82. { echo ""; echo ""; } >> Packages;; \
  83. esac; \
  84. echo -n '{"architecture": "$(ARCH_PACKAGES)", "packages":{' > index.json; \
  85. sed -n -e 's/^Package: \(.*\)$$/"\1":/p' -e 's/^Version: \(.*\)$$/"\1",/p' Packages | tr '\n' ' ' >> index.json; \
  86. echo '}}' >> index.json; \
  87. sed -i 's/, }}/}}/' index.json; \
  88. gzip -9nc Packages > Packages.gz; \
  89. ); done
  90. ifdef CONFIG_SIGNED_PACKAGES
  91. @echo Signing package index...
  92. @for d in $(PACKAGE_SUBDIRS); do ( \
  93. [ -d $$d ] && \
  94. cd $$d || continue; \
  95. $(STAGING_DIR_HOST)/bin/usign -S -m Packages -s $(BUILD_KEY); \
  96. ); done
  97. endif
  98. ifdef CONFIG_JSON_CYCLONEDX_SBOM
  99. @echo Creating CycloneDX package SBOMs...
  100. @for d in $(PACKAGE_SUBDIRS); do ( \
  101. [ -d $$d ] && \
  102. cd $$d || continue; \
  103. $(SCRIPT_DIR)/package-metadata.pl pkgcyclonedxsbom Packages.manifest > Packages.bom.cdx.json || true; \
  104. ); done
  105. endif
  106. $(curdir)/flags-install:= -j1
  107. $(eval $(call stampfile,$(curdir),package,prereq,.config))
  108. $(eval $(call stampfile,$(curdir),package,cleanup,$(TMP_DIR)/.build))
  109. $(eval $(call stampfile,$(curdir),package,compile,$(TMP_DIR)/.build))
  110. $(eval $(call stampfile,$(curdir),package,install,$(TMP_DIR)/.build))
  111. $(eval $(call stampfile,$(curdir),package,check,$(TMP_DIR)/.build))
  112. $(eval $(call subdir,$(curdir)))