Makefile 3.7 KB

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