Makefile 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106
  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-install:=.
  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. $(curdir)/install: $(TMP_DIR)/.build $(curdir)/system/opkg/host/compile $(curdir)/merge $(if $(CONFIG_TARGET_PER_DEVICE_ROOTFS),$(curdir)/merge-index)
  53. - find $(STAGING_DIR_ROOT) -type d | $(XARGS) chmod 0755
  54. rm -rf $(TARGET_DIR) $(TARGET_DIR_ORIG)
  55. [ -d $(TARGET_DIR)/tmp ] || mkdir -p $(TARGET_DIR)/tmp
  56. $(call opkg,$(TARGET_DIR)) install \
  57. $(call opkg_package_files,$(shell cat $(PACKAGE_INSTALL_FILES) 2>/dev/null))
  58. @for file in $(PACKAGE_INSTALL_FILES); do \
  59. [ -s $$file.flags ] || continue; \
  60. for flag in `cat $$file.flags`; do \
  61. $(call opkg,$(TARGET_DIR)) flag $$flag `cat $$file`; \
  62. done; \
  63. done || true
  64. @-$(MAKE) package/preconfig
  65. $(CP) $(TARGET_DIR) $(TARGET_DIR_ORIG)
  66. $(call prepare_rootfs,$(TARGET_DIR))
  67. $(curdir)/index: FORCE
  68. @echo Generating package index...
  69. @for d in $(PACKAGE_SUBDIRS); do ( \
  70. mkdir -p $$d; \
  71. cd $$d || continue; \
  72. $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages.manifest; \
  73. grep -vE '^(Maintainer|LicenseFiles|Source|Require)' Packages.manifest > Packages && \
  74. gzip -9nc Packages > Packages.gz; \
  75. ); done
  76. ifdef CONFIG_SIGNED_PACKAGES
  77. @echo Signing package index...
  78. @for d in $(PACKAGE_SUBDIRS); do ( \
  79. [ -d $$d ] && \
  80. cd $$d || continue; \
  81. $(STAGING_DIR_HOST)/bin/usign -S -m Packages -s $(BUILD_KEY); \
  82. ); done
  83. endif
  84. $(curdir)/preconfig:
  85. $(curdir)/flags-install:= -j1
  86. $(eval $(call stampfile,$(curdir),package,prereq,.config))
  87. $(eval $(call stampfile,$(curdir),package,cleanup,$(TMP_DIR)/.build))
  88. $(eval $(call stampfile,$(curdir),package,compile,$(TMP_DIR)/.build))
  89. $(eval $(call stampfile,$(curdir),package,install,$(TMP_DIR)/.build))
  90. $(eval $(call stampfile,$(curdir),package,check,$(TMP_DIR)/.build))
  91. $(eval $(call subdir,$(curdir)))