Makefile 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  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. $(curdir)/autoremove:=1
  12. $(curdir)/builddirs:=$(sort $(package-) $(package-y) $(package-m))
  13. $(curdir)/builddirs-default:=. $(sort $(package-y) $(package-m))
  14. $(curdir)/builddirs-prereq:=. $(sort $(prereq-y) $(prereq-m))
  15. ifdef CHECK_ALL
  16. $(curdir)/builddirs-check:=$($(curdir)/builddirs)
  17. $(curdir)/builddirs-download:=$($(curdir)/builddirs)
  18. endif
  19. ifneq ($(IGNORE_ERRORS),)
  20. package-y-filter := $(package-y)
  21. package-m-filter := $(filter-out $(package-y),$(package-m))
  22. package-n-filter := $(filter-out $(package-y) $(package-m),$(package-))
  23. package-ignore-errors := $(filter n m y,$(IGNORE_ERRORS))
  24. package-ignore-errors := $(if $(package-ignore-errors),$(package-ignore-errors),n m)
  25. package-ignore-subdirs := $(sort $(foreach m,$(package-ignore-errors),$(package-$(m)-filter)))
  26. $(curdir)/builddirs-ignore-download := $(package-ignore-subdirs)
  27. $(curdir)/builddirs-ignore-compile := $(package-ignore-subdirs)
  28. $(curdir)/builddirs-ignore-host-download := $(package-ignore-subdirs)
  29. $(curdir)/builddirs-ignore-host-compile := $(package-ignore-subdirs)
  30. endif
  31. PACKAGE_INSTALL_FILES:= \
  32. $(foreach pkg,$(sort $(package-y)), \
  33. $(foreach variant, \
  34. $(if $(strip $(package/$(pkg)/variants)), \
  35. $(package/$(pkg)/variants), \
  36. $(if $(package/$(pkg)/default-variant), \
  37. $(package/$(pkg)/default-variant), \
  38. default \
  39. ) \
  40. ), \
  41. $(PKG_INFO_DIR)/$(lastword $(subst /,$(space),$(pkg))).$(variant).install \
  42. ) \
  43. )
  44. $(curdir)/cleanup: $(TMP_DIR)/.build
  45. rm -rf $(STAGING_DIR_ROOT)
  46. $(curdir)/merge:
  47. rm -rf $(PACKAGE_DIR_ALL)
  48. mkdir -p $(PACKAGE_DIR_ALL)
  49. -$(foreach pdir,$(PACKAGE_SUBDIRS),$(if $(wildcard $(pdir)/*.ipk),ln -s $(pdir)/*.ipk $(PACKAGE_DIR_ALL);))
  50. $(curdir)/merge-index: $(curdir)/merge
  51. (cd $(PACKAGE_DIR_ALL) && $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages; )
  52. ifndef SDK
  53. $(curdir)/compile: $(curdir)/system/opkg/host/compile
  54. endif
  55. $(curdir)/install: $(TMP_DIR)/.build $(curdir)/merge $(if $(CONFIG_TARGET_PER_DEVICE_ROOTFS),$(curdir)/merge-index)
  56. - find $(STAGING_DIR_ROOT) -type d | $(XARGS) chmod 0755
  57. rm -rf $(TARGET_DIR) $(TARGET_DIR_ORIG)
  58. mkdir -p $(TARGET_DIR)/tmp
  59. $(call opkg,$(TARGET_DIR)) install \
  60. $(call opkg_package_files,$(foreach pkg,$(shell cat $(PACKAGE_INSTALL_FILES) 2>/dev/null),$(pkg)$(call GetABISuffix,$(pkg))))
  61. @for file in $(PACKAGE_INSTALL_FILES); do \
  62. [ -s $$file.flags ] || continue; \
  63. for flag in `cat $$file.flags`; do \
  64. $(call opkg,$(TARGET_DIR)) flag $$flag `cat $$file`; \
  65. done; \
  66. done || true
  67. $(CP) $(TARGET_DIR) $(TARGET_DIR_ORIG)
  68. $(call prepare_rootfs,$(TARGET_DIR),$(TOPDIR)/files)
  69. $(curdir)/index: FORCE
  70. @echo Generating package index...
  71. @for d in $(PACKAGE_SUBDIRS); do ( \
  72. mkdir -p $$d; \
  73. cd $$d || continue; \
  74. $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages.manifest; \
  75. grep -vE '^(Maintainer|LicenseFiles|Source|SourceName|Require)' Packages.manifest > Packages && \
  76. gzip -9nc Packages > Packages.gz; \
  77. ); done
  78. ifdef CONFIG_SIGNED_PACKAGES
  79. @echo Signing package index...
  80. @for d in $(PACKAGE_SUBDIRS); do ( \
  81. [ -d $$d ] && \
  82. cd $$d || continue; \
  83. $(STAGING_DIR_HOST)/bin/usign -S -m Packages -s $(BUILD_KEY); \
  84. ); done
  85. endif
  86. $(curdir)/flags-install:= -j1
  87. $(eval $(call stampfile,$(curdir),package,prereq,.config))
  88. $(eval $(call stampfile,$(curdir),package,cleanup,$(TMP_DIR)/.build))
  89. $(eval $(call stampfile,$(curdir),package,compile,$(TMP_DIR)/.build))
  90. $(eval $(call stampfile,$(curdir),package,install,$(TMP_DIR)/.build))
  91. $(eval $(call stampfile,$(curdir),package,check,$(TMP_DIR)/.build))
  92. $(eval $(call subdir,$(curdir)))