Makefile 4.1 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)/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. ifneq ($(IGNORE_ERRORS),)
  15. package-y-filter := $(package-y)
  16. package-m-filter := $(filter-out $(package-y),$(package-m))
  17. package-n-filter := $(filter-out $(package-y) $(package-m),$(package-))
  18. package-ignore-errors := $(filter n m y,$(IGNORE_ERRORS))
  19. package-ignore-errors := $(if $(package-ignore-errors),$(package-ignore-errors),n m)
  20. package-ignore-subdirs := $(sort $(foreach m,$(package-ignore-errors),$(package-$(m)-filter)))
  21. $(curdir)/builddirs-ignore-download := $(package-ignore-subdirs)
  22. $(curdir)/builddirs-ignore-compile := $(package-ignore-subdirs)
  23. $(curdir)/builddirs-ignore-host-download := $(package-ignore-subdirs)
  24. $(curdir)/builddirs-ignore-host-compile := $(package-ignore-subdirs)
  25. endif
  26. PACKAGE_INSTALL_FILES:= \
  27. $(foreach pkg,$(sort $(package-y)), \
  28. $(foreach variant, \
  29. $(if $(strip $(package/$(pkg)/variants)), \
  30. $(package/$(pkg)/variants), \
  31. $(if $(package/$(pkg)/default-variant), \
  32. $(package/$(pkg)/default-variant), \
  33. default \
  34. ) \
  35. ), \
  36. $(PKG_INFO_DIR)/$(lastword $(subst /,$(space),$(pkg))).$(variant).install \
  37. ) \
  38. )
  39. $(curdir)/cleanup: $(TMP_DIR)/.build
  40. rm -rf $(STAGING_DIR_ROOT)
  41. $(curdir)/merge:
  42. rm -rf $(PACKAGE_DIR_ALL)
  43. mkdir -p $(PACKAGE_DIR_ALL)
  44. -$(foreach pdir,$(PACKAGE_SUBDIRS),$(if $(wildcard $(pdir)/*.ipk),ln -s $(pdir)/*.ipk $(PACKAGE_DIR_ALL);))
  45. $(curdir)/merge-index: $(curdir)/merge
  46. (cd $(PACKAGE_DIR_ALL) && $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages; )
  47. $(curdir)/install: $(TMP_DIR)/.build $(curdir)/system/opkg/host/install $(curdir)/merge $(if $(CONFIG_TARGET_PER_DEVICE_ROOTFS),$(curdir)/merge-index)
  48. - find $(STAGING_DIR_ROOT) -type d | $(XARGS) chmod 0755
  49. rm -rf $(TARGET_DIR) $(TARGET_DIR_ORIG)
  50. [ -d $(TARGET_DIR)/tmp ] || mkdir -p $(TARGET_DIR)/tmp
  51. $(call opkg,$(TARGET_DIR)) install \
  52. $(call opkg_package_files,$(shell cat $(PACKAGE_INSTALL_FILES) 2>/dev/null))
  53. @for file in $(PACKAGE_INSTALL_FILES); do \
  54. [ -s $$file.flags ] || continue; \
  55. for flag in `cat $$file.flags`; do \
  56. $(call opkg,$(TARGET_DIR)) flag $$flag `cat $$file`; \
  57. done; \
  58. done || true
  59. @-$(MAKE) package/preconfig
  60. $(CP) $(TARGET_DIR) $(TARGET_DIR_ORIG)
  61. $(call prepare_rootfs,$(TARGET_DIR))
  62. PASSOPT=""
  63. PASSARG=""
  64. ifndef CONFIG_OPKGSMIME_PASSPHRASE
  65. ifneq ($(call qstrip,$(CONFIG_OPKGSMIME_PASSFILE)),)
  66. PASSOPT="-passin"
  67. PASSARG="file:$(call qstrip,$(CONFIG_OPKGSMIME_PASSFILE))"
  68. endif
  69. endif
  70. $(curdir)/index: FORCE
  71. @echo Generating package index...
  72. @for d in $(PACKAGE_SUBDIRS); do ( \
  73. mkdir -p $$d; \
  74. cd $$d || continue; \
  75. $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > 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. else
  86. ifeq ($(call qstrip,$(CONFIG_OPKGSMIME_KEY)),)
  87. @echo Signing key has not been configured
  88. else
  89. ifeq ($(call qstrip,$(CONFIG_OPKGSMIME_CERT)),)
  90. @echo Certificate has not been configured
  91. else
  92. @echo Signing package index...
  93. @for d in $(PACKAGE_SUBDIRS); do ( \
  94. [ -d $$d ] && \
  95. cd $$d || continue; \
  96. openssl smime -binary -in Packages.gz \
  97. -out Packages.sig -outform PEM -sign \
  98. -signer $(CONFIG_OPKGSMIME_CERT) \
  99. -inkey $(CONFIG_OPKGSMIME_KEY) \
  100. $(PASSOPT) $(PASSARG); \
  101. ); done
  102. endif
  103. endif
  104. endif
  105. $(curdir)/preconfig:
  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 subdir,$(curdir)))