ext2root.mk 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120
  1. #############################################################
  2. #
  3. # genext2fs to build to target ext2 filesystems
  4. #
  5. #############################################################
  6. GENEXT2_DIR=$(BUILD_DIR)/genext2fs-1.3
  7. GENEXT2_SOURCE=genext2fs_1.3.orig.tar.gz
  8. GENEXT2_SITE=http://ftp.debian.org/debian/pool/main/g/genext2fs
  9. $(DL_DIR)/$(GENEXT2_SOURCE):
  10. $(WGET) -P $(DL_DIR) $(GENEXT2_SITE)/$(GENEXT2_SOURCE)
  11. $(GENEXT2_DIR)/.unpacked: $(DL_DIR)/$(GENEXT2_SOURCE)
  12. zcat $(DL_DIR)/$(GENEXT2_SOURCE) | tar -C $(BUILD_DIR) -xvf -
  13. mv $(GENEXT2_DIR).orig $(GENEXT2_DIR)
  14. toolchain/patch-kernel.sh $(GENEXT2_DIR) target/ext2/ genext2fs*.patch
  15. touch $(GENEXT2_DIR)/.unpacked
  16. $(GENEXT2_DIR)/.configured: $(GENEXT2_DIR)/.unpacked
  17. chmod a+x $(GENEXT2_DIR)/configure
  18. (cd $(GENEXT2_DIR); rm -rf config.cache; \
  19. ./configure \
  20. --prefix=$(STAGING_DIR) \
  21. );
  22. touch $(GENEXT2_DIR)/.configured
  23. $(GENEXT2_DIR)/genext2fs: $(GENEXT2_DIR)/.configured
  24. $(MAKE) CFLAGS="-Wall -O2 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE \
  25. -D_FILE_OFFSET_BITS=64" -C $(GENEXT2_DIR);
  26. touch -c $(GENEXT2_DIR)/genext2fs
  27. genext2fs: $(GENEXT2_DIR)/genext2fs
  28. #############################################################
  29. #
  30. # Build the ext2 root filesystem image
  31. #
  32. #############################################################
  33. EXT2_OPTS :=
  34. ifeq ($(strip $(BR2_TARGET_ROOTFS_EXT2_SQUASH)),y)
  35. EXT2_OPTS += -U
  36. endif
  37. ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)),0)
  38. EXT2_OPTS += -b $(strip $(BR2_TARGET_ROOTFS_EXT2_BLOCKS))
  39. endif
  40. ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_INODES)),0)
  41. EXT2_OPTS += -i $(strip $(BR2_TARGET_ROOTFS_EXT2_INODES))
  42. endif
  43. ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_RESBLKS)),0)
  44. EXT2_OPTS += -r $(strip $(BR2_TARGET_ROOTFS_EXT2_RESBLKS))
  45. endif
  46. EXT2_BASE := $(subst ",,$(BR2_TARGET_ROOTFS_EXT2_OUTPUT))
  47. ifeq ($(strip $(BR2_TARGET_ROOTFS_EXT2_GZ)),y)
  48. EXT2_TARGET := $(EXT2_BASE).gz
  49. else
  50. EXT2_TARGET := $(EXT2_BASE)
  51. endif
  52. $(EXT2_BASE): genext2fs
  53. -@find $(TARGET_DIR) -type f -perm +111 | xargs $(STRIP) 2>/dev/null || true;
  54. @rm -rf $(TARGET_DIR)/usr/man
  55. @rm -rf $(TARGET_DIR)/usr/share/man
  56. @rm -rf $(TARGET_DIR)/usr/info
  57. ifeq ($(strip $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)),0)
  58. GENEXT2_REALSIZE=`LANG=C du -l -s -c -k $(TARGET_DIR) | grep total | sed -e "s/total//"`; \
  59. GENEXT2_ADDTOROOTSIZE=`if [ $$GENEXT2_REALSIZE -ge 20000 ] ; then echo 16384; else echo 2400; fi`; \
  60. GENEXT2_SIZE=`expr $$GENEXT2_REALSIZE + $$GENEXT2_ADDTOROOTSIZE`; \
  61. GENEXT2_ADDTOINODESIZE=`find $(TARGET_DIR) | wc -l`; \
  62. GENEXT2_INODES=`expr $$GENEXT2_ADDTOINODESIZE + 400`; \
  63. set -x; \
  64. $(GENEXT2_DIR)/genext2fs \
  65. -b $$GENEXT2_SIZE \
  66. -i $$GENEXT2_INODES \
  67. -d $(TARGET_DIR) \
  68. -D $(TARGET_DEVICE_TABLE) \
  69. $(EXT2_OPTS) $(EXT2_BASE)
  70. else
  71. $(GENEXT2_DIR)/genext2fs \
  72. -d $(TARGET_DIR) \
  73. -D $(TARGET_DEVICE_TABLE) \
  74. $(EXT2_OPTS) \
  75. $(EXT2_BASE)
  76. endif
  77. $(EXT2_BASE).gz: $(EXT2_BASE)
  78. @gzip --best -fv $(EXT2_BASE)
  79. EXT2_COPYTO := $(strip $(subst ",,$(BR2_TARGET_ROOTFS_EXT2_COPYTO)))
  80. ext2root: $(EXT2_TARGET)
  81. @ls -l $(EXT2_TARGET)
  82. ifneq ($(EXT2_COPYTO),)
  83. @cp -f $(EXT2_TARGET) $(EXT2_COPYTO)
  84. endif
  85. ext2root-source: $(DL_DIR)/$(GENEXT2_SOURCE)
  86. ext2root-clean:
  87. -$(MAKE) -C $(GENEXT2_DIR) clean
  88. ext2root-dirclean:
  89. rm -rf $(GENEXT2_DIR)
  90. #############################################################
  91. #
  92. # Toplevel Makefile options
  93. #
  94. #############################################################
  95. ifeq ($(strip $(BR2_TARGET_ROOTFS_EXT2)),y)
  96. TARGETS+=ext2root
  97. endif