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