Makefile 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #
  2. # Copyright (C) 2006-2008 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)/install:=$(curdir)/install-cleanup
  21. $(curdir)/cleanup: $(TMP_DIR)/.build
  22. rm -rf $(TARGET_DIR) $(STAGING_DIR_ROOT)
  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-progs
  34. mkdir -p $(TMP_DIR)/mklibs-out
  35. $(STAGING_DIR_HOST)/bin/mklibs.py -D \
  36. -d $(TMP_DIR)/mklibs-out \
  37. --sysroot $(STAGING_DIR_ROOT) \
  38. -L /lib \
  39. -L /usr/lib \
  40. --ldlib $(patsubst $(STAGING_DIR_ROOT)/%,/%,$(firstword $(wildcard \
  41. $(foreach name,ld-uClibc.so.* ld-linux.so.*, \
  42. $(STAGING_DIR_ROOT)/lib/$(name) \
  43. )))) \
  44. --target $(REAL_GNU_TARGET_NAME) \
  45. `cat $(TMP_DIR)/mklibs-progs` 2>&1
  46. $(RSTRIP) $(TMP_DIR)/mklibs-out
  47. for lib in `ls $(TMP_DIR)/mklibs-out/*.so.* 2>/dev/null`; do \
  48. LIB="$${lib##*/}"; \
  49. DEST="`ls "$(TARGET_DIR)/lib/$$LIB" "$(TARGET_DIR)/usr/lib/$$LIB" 2>/dev/null`"; \
  50. [ -n "$$DEST" ] || continue; \
  51. echo "Copying stripped library $$lib to $$DEST"; \
  52. cp "$$lib" "$$DEST" || exit 1; \
  53. done
  54. endef
  55. endif
  56. $(curdir)/rootfs-prepare: $(TMP_DIR)/.build
  57. @-$(MAKE) package/preconfig
  58. @if [ -d $(TOPDIR)/files ]; then \
  59. $(CP) $(TOPDIR)/files/. $(TARGET_DIR); \
  60. fi
  61. @mkdir -p $(TARGET_DIR)/etc/rc.d
  62. @( \
  63. cd $(TARGET_DIR); \
  64. for script in ./etc/init.d/*; do \
  65. grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \
  66. IPKG_INSTROOT=$(TARGET_DIR) $$(which bash) ./etc/rc.common $$script enable; \
  67. done || true \
  68. )
  69. @-find $(TARGET_DIR) -name CVS | $(XARGS) rm -rf
  70. @-find $(TARGET_DIR) -name .svn | $(XARGS) rm -rf
  71. @-find $(TARGET_DIR) -name '.#*' | $(XARGS) rm -f
  72. $(if $(CONFIG_CLEAN_IPKG),rm -rf $(TARGET_DIR)/usr/lib/opkg)
  73. $(call mklibs)
  74. $(curdir)/index: FORCE
  75. @(cd $(PACKAGE_DIR); $(SCRIPT_DIR)/ipkg-make-index.sh . > Packages && \
  76. gzip -9c Packages > Packages.gz \
  77. )
  78. $(curdir)/flags-install:= -j1
  79. $(eval $(call stampfile,$(curdir),package,prereq,.config))
  80. $(eval $(call stampfile,$(curdir),package,cleanup,$(TMP_DIR)/.build))
  81. $(eval $(call stampfile,$(curdir),package,compile,$(TMP_DIR)/.build))
  82. $(eval $(call stampfile,$(curdir),package,install,$(TMP_DIR)/.build))
  83. $(eval $(call stampfile,$(curdir),package,rootfs-prepare,$(TMP_DIR)/.build))
  84. $(eval $(call subdir,$(curdir)))