Makefile 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174
  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 $(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. $(curdir)/builddirs-ignore-download := $(foreach m,$(package-ignore-errors),$(package-$(m)-filter))
  21. $(curdir)/builddirs-ignore-compile := $(foreach m,$(package-ignore-errors),$(package-$(m)-filter))
  22. endif
  23. ifdef CONFIG_USE_MKLIBS
  24. define mklibs
  25. rm -rf $(TMP_DIR)/mklibs-progs $(TMP_DIR)/mklibs-out
  26. # first find all programs and add them to the mklibs list
  27. find $(STAGING_DIR_ROOT) -type f -perm /100 -exec \
  28. file -r -N -F '' {} + | \
  29. awk ' /executable.*dynamically/ { print $$1 }' > $(TMP_DIR)/mklibs-progs
  30. # find all loadable objects that are not regular libraries and add them to the list as well
  31. find $(STAGING_DIR_ROOT) -type f -name \*.so\* -exec \
  32. file -r -N -F '' {} + | \
  33. awk ' /shared object/ { print $$1 }' > $(TMP_DIR)/mklibs-libs
  34. mkdir -p $(TMP_DIR)/mklibs-out
  35. $(STAGING_DIR_HOST)/bin/mklibs -D \
  36. -d $(TMP_DIR)/mklibs-out \
  37. --sysroot $(STAGING_DIR_ROOT) \
  38. `cat $(TMP_DIR)/mklibs-libs | sed 's:/*[^/]\+/*$$::' | uniq | sed 's:^$(STAGING_DIR_ROOT):-L :'` \
  39. --ldlib $(patsubst $(STAGING_DIR_ROOT)/%,/%,$(firstword $(wildcard \
  40. $(foreach name,ld-uClibc.so.* ld-linux.so.* ld-*.so, \
  41. $(STAGING_DIR_ROOT)/lib/$(name) \
  42. )))) \
  43. --target $(REAL_GNU_TARGET_NAME) \
  44. `cat $(TMP_DIR)/mklibs-progs $(TMP_DIR)/mklibs-libs` 2>&1
  45. $(RSTRIP) $(TMP_DIR)/mklibs-out
  46. for lib in `ls $(TMP_DIR)/mklibs-out/*.so.* 2>/dev/null`; do \
  47. LIB="$${lib##*/}"; \
  48. DEST="`ls "$(TARGET_DIR)/lib/$$LIB" "$(TARGET_DIR)/usr/lib/$$LIB" 2>/dev/null`"; \
  49. [ -n "$$DEST" ] || continue; \
  50. echo "Copying stripped library $$lib to $$DEST"; \
  51. cp "$$lib" "$$DEST" || exit 1; \
  52. done
  53. endef
  54. endif
  55. # where to build (and put) .ipk packages
  56. OPKG:= \
  57. IPKG_NO_SCRIPT=1 \
  58. IPKG_TMP=$(TMP_DIR)/ipkg \
  59. IPKG_INSTROOT=$(TARGET_DIR) \
  60. IPKG_CONF_DIR=$(STAGING_DIR)/etc \
  61. IPKG_OFFLINE_ROOT=$(TARGET_DIR) \
  62. $(XARGS) $(STAGING_DIR_HOST)/bin/opkg \
  63. --offline-root $(TARGET_DIR) \
  64. --force-depends \
  65. --force-overwrite \
  66. --force-postinstall \
  67. --force-maintainer \
  68. --add-dest root:/ \
  69. --add-arch all:100 \
  70. --add-arch $(if $(ARCH_PACKAGES),$(ARCH_PACKAGES),$(BOARD)):200
  71. PACKAGE_INSTALL_FILES:= \
  72. $(foreach pkg,$(sort $(package-y)), \
  73. $(foreach variant, \
  74. $(if $(strip $(package/$(pkg)/variants)), \
  75. $(package/$(pkg)/variants), \
  76. $(if $(package/$(pkg)/default-variant), \
  77. $(package/$(pkg)/default-variant), \
  78. default \
  79. ) \
  80. ), \
  81. $(PKG_INFO_DIR)/$(lastword $(subst /,$(space),$(pkg))).$(variant).install \
  82. ) \
  83. )
  84. $(curdir)/cleanup: $(TMP_DIR)/.build
  85. rm -rf $(STAGING_DIR_ROOT)
  86. $(curdir)/install: $(TMP_DIR)/.build
  87. - find $(STAGING_DIR_ROOT) -type d | $(XARGS) chmod 0755
  88. rm -rf $(TARGET_DIR)
  89. [ -d $(TARGET_DIR)/tmp ] || mkdir -p $(TARGET_DIR)/tmp
  90. @$(FIND) `sed -e 's|.*|$(PACKAGE_DIR)$(if $(CONFIG_PER_FEED_REPO),/*)/&_*.ipk|' $(PACKAGE_INSTALL_FILES)` | sort -u | $(OPKG) install
  91. @for file in $(PACKAGE_INSTALL_FILES); do \
  92. [ -s $$file.flags ] || continue; \
  93. for flag in `cat $$file.flags`; do \
  94. $(OPKG) flag $$flag < $$file; \
  95. done; \
  96. done || true
  97. @-$(MAKE) package/preconfig
  98. @if [ -d $(TOPDIR)/files ]; then \
  99. $(call file_copy,$(TOPDIR)/files/.,$(TARGET_DIR)); \
  100. fi
  101. @mkdir -p $(TARGET_DIR)/etc/rc.d
  102. @( \
  103. cd $(TARGET_DIR); \
  104. for script in ./usr/lib/opkg/info/*.postinst; do \
  105. IPKG_INSTROOT=$(TARGET_DIR) $$(which bash) $$script; \
  106. done || true \
  107. )
  108. @-find $(TARGET_DIR) -name CVS | $(XARGS) rm -rf
  109. @-find $(TARGET_DIR) -name .svn | $(XARGS) rm -rf
  110. @-find $(TARGET_DIR) -name '.#*' | $(XARGS) rm -f
  111. rm -f $(TARGET_DIR)/usr/lib/opkg/info/*.postinst*
  112. rm -f $(TARGET_DIR)/usr/lib/opkg/info/*.prerm*
  113. $(if $(CONFIG_CLEAN_IPKG),rm -rf $(TARGET_DIR)/usr/lib/opkg)
  114. $(call mklibs)
  115. PASSOPT=""
  116. PASSARG=""
  117. ifndef CONFIG_OPKGSMIME_PASSPHRASE
  118. ifneq ($(call qstrip,$(CONFIG_OPKGSMIME_PASSFILE)),)
  119. PASSOPT="-passin"
  120. PASSARG="file:$(call qstrip,$(CONFIG_OPKGSMIME_PASSFILE))"
  121. endif
  122. endif
  123. PACKAGE_SUBDIRS=.
  124. ifneq ($(CONFIG_PER_FEED_REPO),)
  125. PACKAGE_SUBDIRS=base $(FEEDS_ENABLED)
  126. endif
  127. $(curdir)/index: FORCE
  128. @echo Generating package index...
  129. @for d in $(PACKAGE_SUBDIRS); do ( \
  130. [ -d $(PACKAGE_DIR)/$$d ] && \
  131. cd $(PACKAGE_DIR)/$$d || continue; \
  132. $(SCRIPT_DIR)/ipkg-make-index.sh . 2>&1 > Packages && \
  133. gzip -9c Packages > Packages.gz; \
  134. ); done
  135. ifeq ($(call qstrip,$(CONFIG_OPKGSMIME_KEY)),)
  136. @echo Signing key has not been configured
  137. else
  138. ifeq ($(call qstrip,$(CONFIG_OPKGSMIME_CERT)),)
  139. @echo Certificate has not been configured
  140. else
  141. @echo Signing package index...
  142. @for d in $(PACKAGE_SUBDIRS); do ( \
  143. [ -d $(PACKAGE_DIR)/$$d ] && \
  144. cd $(PACKAGE_DIR)/$$d || continue; \
  145. openssl smime -binary -in Packages.gz \
  146. -out Packages.sig -outform PEM -sign \
  147. -signer $(CONFIG_OPKGSMIME_CERT) \
  148. -inkey $(CONFIG_OPKGSMIME_KEY) \
  149. $(PASSOPT) $(PASSARG); \
  150. ); done
  151. endif
  152. endif
  153. $(curdir)/preconfig:
  154. $(curdir)/flags-install:= -j1
  155. $(eval $(call stampfile,$(curdir),package,prereq,.config))
  156. $(eval $(call stampfile,$(curdir),package,cleanup,$(TMP_DIR)/.build))
  157. $(eval $(call stampfile,$(curdir),package,compile,$(TMP_DIR)/.build))
  158. $(eval $(call stampfile,$(curdir),package,install,$(TMP_DIR)/.build))
  159. $(eval $(call subdir,$(curdir)))