ext2root.mk 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146
  1. #############################################################
  2. #
  3. # genext2fs to build to target ext2 filesystems
  4. #
  5. #############################################################
  6. GENEXT2_VERSION=1.4
  7. GENEXT2_DIR=$(BUILD_DIR)/genext2fs-$(GENEXT2_VERSION)
  8. GENEXT2_SOURCE=genext2fs-$(GENEXT2_VERSION).tar.gz
  9. GENEXT2_SITE:=http://$(BR2_SOURCEFORGE_MIRROR).dl.sourceforge.net/sourceforge/genext2fs
  10. $(DL_DIR)/$(GENEXT2_SOURCE):
  11. $(call DOWNLOAD,$(GENEXT2_SITE),$(GENEXT2_SOURCE))
  12. $(GENEXT2_DIR)/.unpacked: $(DL_DIR)/$(GENEXT2_SOURCE)
  13. $(ZCAT) $(DL_DIR)/$(GENEXT2_SOURCE) | tar -C $(BUILD_DIR) -xvf -
  14. toolchain/patch-kernel.sh $(GENEXT2_DIR) target/ext2/ genext2fs\*.patch
  15. touch $@
  16. $(GENEXT2_DIR)/.configured: $(GENEXT2_DIR)/.unpacked
  17. chmod a+x $(GENEXT2_DIR)/configure
  18. (cd $(GENEXT2_DIR); rm -rf config.cache; \
  19. ./configure $(QUIET) \
  20. CC="$(HOSTCC)" \
  21. --prefix=$(STAGING_DIR) \
  22. )
  23. touch $@
  24. $(GENEXT2_DIR)/genext2fs: $(GENEXT2_DIR)/.configured
  25. $(MAKE) CFLAGS="-Wall -O2 -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE \
  26. -D_FILE_OFFSET_BITS=64" -C $(GENEXT2_DIR)
  27. touch -c $@
  28. genext2fs: $(GENEXT2_DIR)/genext2fs
  29. #############################################################
  30. #
  31. # Build the ext2 root filesystem image
  32. #
  33. #############################################################
  34. EXT2_OPTS :=
  35. ifeq ($(BR2_TARGET_ROOTFS_EXT2_SQUASH),y)
  36. EXT2_OPTS += -U
  37. endif
  38. ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)),0)
  39. EXT2_OPTS += -b $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)
  40. endif
  41. ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_INODES)),0)
  42. EXT2_OPTS += -N $(BR2_TARGET_ROOTFS_EXT2_INODES)
  43. endif
  44. ifneq ($(strip $(BR2_TARGET_ROOTFS_EXT2_RESBLKS)),)
  45. EXT2_OPTS += -m $(BR2_TARGET_ROOTFS_EXT2_RESBLKS)
  46. endif
  47. EXT2_BASE := $(call qstrip,$(BR2_TARGET_ROOTFS_EXT2_OUTPUT))
  48. EXT2_ROOTFS_COMPRESSOR:=
  49. EXT2_ROOTFS_COMPRESSOR_EXT:=
  50. EXT2_ROOTFS_COMPRESSOR_PREREQ:=
  51. ifeq ($(BR2_TARGET_ROOTFS_EXT2_GZIP),y)
  52. EXT2_ROOTFS_COMPRESSOR:=gzip -9 -c
  53. EXT2_ROOTFS_COMPRESSOR_EXT:=gz
  54. #EXT2_ROOTFS_COMPRESSOR_PREREQ:= gzip-host
  55. endif
  56. ifeq ($(BR2_TARGET_ROOTFS_EXT2_BZIP2),y)
  57. EXT2_ROOTFS_COMPRESSOR:=bzip2 -9 -c
  58. EXT2_ROOTFS_COMPRESSOR_EXT:=bz2
  59. #EXT2_ROOTFS_COMPRESSOR_PREREQ:= bzip2-host
  60. endif
  61. ifeq ($(BR2_TARGET_ROOTFS_EXT2_LZMA),y)
  62. EXT2_ROOTFS_COMPRESSOR:=lzma -9 -c
  63. EXT2_ROOTFS_COMPRESSOR_EXT:=lzma
  64. EXT2_ROOTFS_COMPRESSOR_PREREQ:= lzma-host
  65. endif
  66. ifneq ($(EXT2_ROOTFS_COMPRESSOR),)
  67. EXT2_TARGET := $(EXT2_BASE).$(EXT2_ROOTFS_COMPRESSOR_EXT)
  68. else
  69. EXT2_TARGET := $(EXT2_BASE)
  70. endif
  71. $(EXT2_BASE): host-fakeroot makedevs genext2fs
  72. # Use fakeroot to pretend all target binaries are owned by root
  73. rm -f $(BUILD_DIR)/_fakeroot.$(notdir $(EXT2_TARGET))
  74. touch $(BUILD_DIR)/.fakeroot.00000
  75. cat $(BUILD_DIR)/.fakeroot* > $(BUILD_DIR)/_fakeroot.$(notdir $(EXT2_TARGET))
  76. echo "chown -R 0:0 $(TARGET_DIR)" >> $(BUILD_DIR)/_fakeroot.$(notdir $(EXT2_TARGET))
  77. ifneq ($(TARGET_DEVICE_TABLE),)
  78. # Use fakeroot to pretend to create all needed device nodes
  79. echo "$(HOST_DIR)/usr/bin/makedevs -d $(TARGET_DEVICE_TABLE) $(TARGET_DIR)" \
  80. >> $(BUILD_DIR)/_fakeroot.$(notdir $(EXT2_TARGET))
  81. endif
  82. # Use fakeroot so genext2fs believes the previous fakery
  83. ifeq ($(strip $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)),0)
  84. GENEXT2_REALSIZE=`LC_ALL=C du -s -c -k $(TARGET_DIR) | grep total | sed -e "s/total//"`; \
  85. GENEXT2_ADDTOROOTSIZE=`if [ $$GENEXT2_REALSIZE -ge 20000 ]; then echo 16384; else echo 2400; fi`; \
  86. GENEXT2_SIZE=`expr $$GENEXT2_REALSIZE + $$GENEXT2_ADDTOROOTSIZE`; \
  87. GENEXT2_ADDTOINODESIZE=`find $(TARGET_DIR) | wc -l`; \
  88. GENEXT2_INODES=`expr $$GENEXT2_ADDTOINODESIZE + 400`; \
  89. set -x; \
  90. echo "$(GENEXT2_DIR)/genext2fs -b $$GENEXT2_SIZE " \
  91. "-N $$GENEXT2_INODES -d $(TARGET_DIR) " \
  92. "$(EXT2_OPTS) $(EXT2_BASE)" >> $(BUILD_DIR)/_fakeroot.$(notdir $(EXT2_TARGET))
  93. else
  94. echo "$(GENEXT2_DIR)/genext2fs -d $(TARGET_DIR) " \
  95. "$(EXT2_OPTS) $(EXT2_BASE)" >> $(BUILD_DIR)/_fakeroot.$(notdir $(EXT2_TARGET))
  96. endif
  97. chmod a+x $(BUILD_DIR)/_fakeroot.$(notdir $(EXT2_TARGET))
  98. $(HOST_DIR)/usr/bin/fakeroot -- $(BUILD_DIR)/_fakeroot.$(notdir $(EXT2_TARGET))
  99. -@rm -f $(BUILD_DIR)/_fakeroot.$(notdir $(EXT2_TARGET))
  100. ifneq ($(EXT2_ROOTFS_COMPRESSOR),)
  101. $(EXT2_BASE).$(EXT2_ROOTFS_COMPRESSOR_EXT): $(EXT2_ROOTFS_COMPRESSOR_PREREQ) $(EXT2_BASE)
  102. $(EXT2_ROOTFS_COMPRESSOR) $(EXT2_BASE) > $(EXT2_TARGET)
  103. endif
  104. EXT2_COPYTO := $(call qstrip,$(BR2_TARGET_ROOTFS_EXT2_COPYTO))
  105. ext2root: $(EXT2_TARGET)
  106. @ls -l $(EXT2_TARGET)
  107. ifneq ($(EXT2_COPYTO),)
  108. @cp -f $(EXT2_TARGET) $(EXT2_COPYTO)
  109. endif
  110. ext2root-source: $(DL_DIR)/$(GENEXT2_SOURCE)
  111. ext2root-clean:
  112. -$(MAKE) -C $(GENEXT2_DIR) clean
  113. ext2root-dirclean:
  114. rm -rf $(GENEXT2_DIR)
  115. #############################################################
  116. #
  117. # Toplevel Makefile options
  118. #
  119. #############################################################
  120. ifeq ($(BR2_TARGET_ROOTFS_EXT2),y)
  121. TARGETS+=ext2root
  122. endif