1
0

rootfs.mk 2.8 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  1. include $(INCLUDE_DIR)/feeds.mk
  2. ifdef CONFIG_USE_MKLIBS
  3. define mklibs
  4. rm -rf $(TMP_DIR)/mklibs-progs $(TMP_DIR)/mklibs-out
  5. # first find all programs and add them to the mklibs list
  6. find $(STAGING_DIR_ROOT) -type f -perm /100 -exec \
  7. file -r -N -F '' {} + | \
  8. awk ' /executable.*dynamically/ { print $$1 }' > $(TMP_DIR)/mklibs-progs
  9. # find all loadable objects that are not regular libraries and add them to the list as well
  10. find $(STAGING_DIR_ROOT) -type f -name \*.so\* -exec \
  11. file -r -N -F '' {} + | \
  12. awk ' /shared object/ { print $$1 }' > $(TMP_DIR)/mklibs-libs
  13. mkdir -p $(TMP_DIR)/mklibs-out
  14. $(STAGING_DIR_HOST)/bin/mklibs -D \
  15. -d $(TMP_DIR)/mklibs-out \
  16. --sysroot $(STAGING_DIR_ROOT) \
  17. `cat $(TMP_DIR)/mklibs-libs | sed 's:/*[^/]\+/*$$::' | uniq | sed 's:^$(STAGING_DIR_ROOT):-L :'` \
  18. --ldlib $(patsubst $(STAGING_DIR_ROOT)/%,/%,$(firstword $(wildcard \
  19. $(foreach name,ld-uClibc.so.* ld-linux.so.* ld-*.so ld-musl-*.so.*, \
  20. $(STAGING_DIR_ROOT)/lib/$(name) \
  21. )))) \
  22. --target $(REAL_GNU_TARGET_NAME) \
  23. `cat $(TMP_DIR)/mklibs-progs $(TMP_DIR)/mklibs-libs` 2>&1
  24. $(RSTRIP) $(TMP_DIR)/mklibs-out
  25. for lib in `ls $(TMP_DIR)/mklibs-out/*.so.* 2>/dev/null`; do \
  26. LIB="$${lib##*/}"; \
  27. DEST="`ls "$(1)/lib/$$LIB" "$(1)/usr/lib/$$LIB" 2>/dev/null`"; \
  28. [ -n "$$DEST" ] || continue; \
  29. echo "Copying stripped library $$lib to $$DEST"; \
  30. cp "$$lib" "$$DEST" || exit 1; \
  31. done
  32. endef
  33. endif
  34. # where to build (and put) .ipk packages
  35. opkg = \
  36. IPKG_NO_SCRIPT=1 \
  37. IPKG_INSTROOT=$(1) \
  38. TMPDIR=$(1)/tmp \
  39. $(STAGING_DIR_HOST)/bin/opkg \
  40. --offline-root $(1) \
  41. --force-postinstall \
  42. --add-dest root:/ \
  43. --add-arch all:100 \
  44. --add-arch $(if $(ARCH_PACKAGES),$(ARCH_PACKAGES),$(BOARD)):200
  45. TARGET_DIR_ORIG := $(TARGET_ROOTFS_DIR)/root.orig-$(BOARD)
  46. define prepare_rootfs
  47. @if [ -d $(TOPDIR)/files ]; then \
  48. $(call file_copy,$(TOPDIR)/files/.,$(1)); \
  49. fi
  50. @mkdir -p $(1)/etc/rc.d
  51. @( \
  52. cd $(1); \
  53. for script in ./usr/lib/opkg/info/*.postinst; do \
  54. IPKG_INSTROOT=$(1) $$(which bash) $$script; \
  55. ret=$$?; \
  56. if [ $$ret -ne 0 ]; then \
  57. echo "postinst script $$script has failed with exit code $$ret" >&2; \
  58. exit 1; \
  59. fi; \
  60. done; \
  61. for script in ./etc/init.d/*; do \
  62. grep '#!/bin/sh /etc/rc.common' $$script >/dev/null || continue; \
  63. IPKG_INSTROOT=$(1) $$(which bash) ./etc/rc.common $$script enable; \
  64. done || true \
  65. )
  66. $(if $(SOURCE_DATE_EPOCH),sed -i "s/Installed-Time: .*/Installed-Time: $(SOURCE_DATE_EPOCH)/" $(1)/usr/lib/opkg/status)
  67. @-find $(1) -name CVS | $(XARGS) rm -rf
  68. @-find $(1) -name .svn | $(XARGS) rm -rf
  69. @-find $(1) -name .git | $(XARGS) rm -rf
  70. @-find $(1) -name '.#*' | $(XARGS) rm -f
  71. rm -f $(1)/usr/lib/opkg/lists/*
  72. rm -f $(1)/usr/lib/opkg/info/*.postinst*
  73. rm -f $(1)/usr/lib/opkg/info/*.prerm*
  74. $(if $(CONFIG_CLEAN_IPKG),rm -rf $(1)/usr/lib/opkg)
  75. $(call mklibs,$(1))
  76. endef