Makefile 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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 $(TMP_DIR)/.packagedeps
  9. $(curdir)/builddirs:=$(sort $(package-) $(package-y) $(package-m))
  10. ifeq ($(SDK),1)
  11. $(curdir)/builddirs-install:=.
  12. else
  13. $(curdir)/builddirs-default:=. $(sort $(package-y) $(package-m))
  14. $(curdir)/builddirs-prereq:=. $(sort $(prereq-y) $(prereq-m))
  15. $(curdir)/builddirs-install:=. $(sort $(package-y))
  16. endif
  17. ifneq ($(IGNORE_ERRORS),)
  18. $(curdir)/builddirs-ignore-compile:= $(if $(filter m y, $(IGNORE_ERRORS)),$(foreach m,$(IGNORE_ERRORS),$(package-$(m))),$(package-m))
  19. endif
  20. $(curdir)/opkghost: $(TMP_DIR)/.build
  21. @-$(MAKE) package/opkg/host/install
  22. $(curdir)/install:=$(curdir)/install-cleanup
  23. $(curdir)/cleanup: $(TMP_DIR)/.build
  24. - find $(STAGING_DIR_ROOT) -type d | $(XARGS) chmod 0755
  25. rm -rf $(TARGET_DIR) $(STAGING_DIR_ROOT)
  26. ifdef CONFIG_USE_MKLIBS
  27. define mklibs
  28. rm -rf $(TMP_DIR)/mklibs-progs $(TMP_DIR)/mklibs-out
  29. # first find all programs and add them to the mklibs list
  30. find $(STAGING_DIR_ROOT) -type f -perm +100 -exec \
  31. file -r -N -F '' {} + | \
  32. awk ' /executable.*dynamically/ { print $$1 }' > $(TMP_DIR)/mklibs-progs
  33. # find all loadable objects that are not regular libraries and add them to the list as well
  34. find $(STAGING_DIR_ROOT) -type f -name \*.so\* -exec \
  35. file -r -N -F '' {} + | \
  36. awk ' /shared object/ { print $$1 }' >> $(TMP_DIR)/mklibs-progs
  37. mkdir -p $(TMP_DIR)/mklibs-out
  38. $(STAGING_DIR_HOST)/bin/mklibs.py -D \
  39. -d $(TMP_DIR)/mklibs-out \
  40. --sysroot $(STAGING_DIR_ROOT) \
  41. -L /lib \
  42. -L /usr/lib \
  43. -L /usr/lib/ebtables \
  44. --ldlib $(patsubst $(STAGING_DIR_ROOT)/%,/%,$(firstword $(wildcard \
  45. $(foreach name,ld-uClibc.so.* ld-linux.so.* ld-*.so, \
  46. $(STAGING_DIR_ROOT)/lib/$(name) \
  47. )))) \
  48. --target $(REAL_GNU_TARGET_NAME) \
  49. `cat $(TMP_DIR)/mklibs-progs` 2>&1
  50. $(RSTRIP) $(TMP_DIR)/mklibs-out
  51. for lib in `ls $(TMP_DIR)/mklibs-out/*.so.* 2>/dev/null`; do \
  52. LIB="$${lib##*/}"; \
  53. DEST="`ls "$(TARGET_DIR)/lib/$$LIB" "$(TARGET_DIR)/usr/lib/$$LIB" 2>/dev/null`"; \
  54. [ -n "$$DEST" ] || continue; \
  55. echo "Copying stripped library $$lib to $$DEST"; \
  56. cp "$$lib" "$$DEST" || exit 1; \
  57. done
  58. endef
  59. endif
  60. $(curdir)/rootfs-prepare: $(TMP_DIR)/.build
  61. @-$(MAKE) package/preconfig
  62. @if [ -d $(TOPDIR)/files ]; then \
  63. $(CP) $(TOPDIR)/files/. $(TARGET_DIR); \
  64. fi
  65. @mkdir -p $(TARGET_DIR)/etc/rc.d
  66. @( \
  67. cd $(TARGET_DIR); \
  68. for script in ./etc/init.d/*; do \
  69. grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \
  70. IPKG_INSTROOT=$(TARGET_DIR) $$(which bash) ./etc/rc.common $$script enable; \
  71. done || true \
  72. )
  73. @-find $(TARGET_DIR) -name CVS | $(XARGS) rm -rf
  74. @-find $(TARGET_DIR) -name .svn | $(XARGS) rm -rf
  75. @-find $(TARGET_DIR) -name '.#*' | $(XARGS) rm -f
  76. $(if $(CONFIG_CLEAN_IPKG),rm -rf $(TARGET_DIR)/usr/lib/opkg)
  77. $(call mklibs)
  78. $(curdir)/index: FORCE
  79. @(cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . > Packages && \
  80. gzip -9c Packages > Packages.gz \
  81. )
  82. $(curdir)/flags-install:= -j1
  83. $(eval $(call stampfile,$(curdir),package,prereq,.config))
  84. $(eval $(call stampfile,$(curdir),package,cleanup))
  85. $(eval $(call stampfile,$(curdir),package,compile))
  86. $(eval $(call stampfile,$(curdir),package,opkghost))
  87. $(eval $(call stampfile,$(curdir),package,install,$(STAGING_DIR)/stamp/.package_opkghost))
  88. $(eval $(call stampfile,$(curdir),package,rootfs-prepare))
  89. $(eval $(call subdir,$(curdir)))