Makefile 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109
  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)/rootfs.mk
  9. -include $(TMP_DIR)/.packagedeps
  10. $(curdir)/autoremove:=1
  11. $(curdir)/builddirs:=$(sort $(package-) $(package-y) $(package-m))
  12. $(curdir)/builddirs-default:=. $(sort $(package-y) $(package-m))
  13. $(curdir)/builddirs-prereq:=. $(sort $(prereq-y) $(prereq-m))
  14. ifdef CHECK_ALL
  15. $(curdir)/builddirs-check:=$($(curdir)/builddirs)
  16. $(curdir)/builddirs-download:=$($(curdir)/builddirs)
  17. endif
  18. ifneq ($(IGNORE_ERRORS),)
  19. package-y-filter := $(package-y)
  20. package-m-filter := $(filter-out $(package-y),$(package-m))
  21. package-n-filter := $(filter-out $(package-y) $(package-m),$(package-))
  22. package-ignore-errors := $(filter n m y,$(IGNORE_ERRORS))
  23. package-ignore-errors := $(if $(package-ignore-errors),$(package-ignore-errors),n m)
  24. package-ignore-subdirs := $(sort $(foreach m,$(package-ignore-errors),$(package-$(m)-filter)))
  25. $(curdir)/builddirs-ignore-download := $(package-ignore-subdirs)
  26. $(curdir)/builddirs-ignore-compile := $(package-ignore-subdirs)
  27. $(curdir)/builddirs-ignore-host-download := $(package-ignore-subdirs)
  28. $(curdir)/builddirs-ignore-host-compile := $(package-ignore-subdirs)
  29. endif
  30. PACKAGE_INSTALL_FILES:= \
  31. $(foreach pkg,$(sort $(package-y)), \
  32. $(foreach variant, \
  33. $(if $(strip $(package/$(pkg)/variants)), \
  34. $(package/$(pkg)/variants), \
  35. $(if $(package/$(pkg)/default-variant), \
  36. $(package/$(pkg)/default-variant), \
  37. default \
  38. ) \
  39. ), \
  40. $(PKG_INFO_DIR)/$(lastword $(subst /,$(space),$(pkg))).$(variant).install \
  41. ) \
  42. )
  43. $(curdir)/cleanup: $(TMP_DIR)/.build
  44. rm -rf $(STAGING_DIR_ROOT)
  45. $(curdir)/merge:
  46. rm -rf $(PACKAGE_DIR_ALL)
  47. mkdir -p $(PACKAGE_DIR_ALL)
  48. -$(foreach pdir,$(PACKAGE_SUBDIRS),$(if $(wildcard $(pdir)/*.ipk),ln -s $(pdir)/*.ipk $(PACKAGE_DIR_ALL);))
  49. $(curdir)/merge-index: $(curdir)/merge
  50. (cd $(PACKAGE_DIR_ALL) && $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages; )
  51. ifndef SDK
  52. $(curdir)/compile: $(curdir)/system/opkg/host/compile
  53. endif
  54. $(curdir)/install: $(TMP_DIR)/.build $(curdir)/merge $(if $(CONFIG_TARGET_PER_DEVICE_ROOTFS),$(curdir)/merge-index)
  55. - find $(STAGING_DIR_ROOT) -type d | $(XARGS) chmod 0755
  56. rm -rf $(TARGET_DIR) $(TARGET_DIR_ORIG)
  57. mkdir -p $(TARGET_DIR)/tmp
  58. $(call opkg,$(TARGET_DIR)) install \
  59. $(call opkg_package_files,$(shell cat $(PACKAGE_INSTALL_FILES) 2>/dev/null))
  60. @for file in $(PACKAGE_INSTALL_FILES); do \
  61. [ -s $$file.flags ] || continue; \
  62. for flag in `cat $$file.flags`; do \
  63. $(call opkg,$(TARGET_DIR)) flag $$flag `cat $$file`; \
  64. done; \
  65. done || true
  66. @-$(MAKE) package/preconfig
  67. $(CP) $(TARGET_DIR) $(TARGET_DIR_ORIG)
  68. $(call prepare_rootfs,$(TARGET_DIR))
  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|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)/preconfig:
  87. $(curdir)/flags-install:= -j1
  88. $(eval $(call stampfile,$(curdir),package,prereq,.config))
  89. $(eval $(call stampfile,$(curdir),package,cleanup,$(TMP_DIR)/.build))
  90. $(eval $(call stampfile,$(curdir),package,compile,$(TMP_DIR)/.build))
  91. $(eval $(call stampfile,$(curdir),package,install,$(TMP_DIR)/.build))
  92. $(eval $(call stampfile,$(curdir),package,check,$(TMP_DIR)/.build))
  93. $(eval $(call subdir,$(curdir)))