ext2root.mk 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148
  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 \
  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 := $(subst ",,$(BR2_TARGET_ROOTFS_EXT2_OUTPUT))
  48. #")
  49. EXT2_ROOTFS_COMPRESSOR:=
  50. EXT2_ROOTFS_COMPRESSOR_EXT:=
  51. EXT2_ROOTFS_COMPRESSOR_PREREQ:=
  52. ifeq ($(BR2_TARGET_ROOTFS_EXT2_GZIP),y)
  53. EXT2_ROOTFS_COMPRESSOR:=gzip -9 -c
  54. EXT2_ROOTFS_COMPRESSOR_EXT:=gz
  55. #EXT2_ROOTFS_COMPRESSOR_PREREQ:= gzip-host
  56. endif
  57. ifeq ($(BR2_TARGET_ROOTFS_EXT2_BZIP2),y)
  58. EXT2_ROOTFS_COMPRESSOR:=bzip2 -9 -c
  59. EXT2_ROOTFS_COMPRESSOR_EXT:=bz2
  60. #EXT2_ROOTFS_COMPRESSOR_PREREQ:= bzip2-host
  61. endif
  62. ifeq ($(BR2_TARGET_ROOTFS_EXT2_LZMA),y)
  63. EXT2_ROOTFS_COMPRESSOR:=lzma -9 -c
  64. EXT2_ROOTFS_COMPRESSOR_EXT:=lzma
  65. EXT2_ROOTFS_COMPRESSOR_PREREQ:= lzma-host
  66. endif
  67. ifneq ($(EXT2_ROOTFS_COMPRESSOR),)
  68. EXT2_TARGET := $(EXT2_BASE).$(EXT2_ROOTFS_COMPRESSOR_EXT)
  69. else
  70. EXT2_TARGET := $(EXT2_BASE)
  71. endif
  72. $(EXT2_BASE): host-fakeroot makedevs genext2fs
  73. # Use fakeroot to pretend all target binaries are owned by root
  74. rm -f $(PROJECT_BUILD_DIR)/_fakeroot.$(notdir $(EXT2_TARGET))
  75. touch $(PROJECT_BUILD_DIR)/.fakeroot.00000
  76. cat $(PROJECT_BUILD_DIR)/.fakeroot* > $(PROJECT_BUILD_DIR)/_fakeroot.$(notdir $(EXT2_TARGET))
  77. echo "chown -R 0:0 $(TARGET_DIR)" >> $(PROJECT_BUILD_DIR)/_fakeroot.$(notdir $(EXT2_TARGET))
  78. ifneq ($(TARGET_DEVICE_TABLE),)
  79. # Use fakeroot to pretend to create all needed device nodes
  80. echo "$(HOST_DIR)/usr/bin/makedevs -d $(TARGET_DEVICE_TABLE) $(TARGET_DIR)" \
  81. >> $(PROJECT_BUILD_DIR)/_fakeroot.$(notdir $(EXT2_TARGET))
  82. endif
  83. # Use fakeroot so genext2fs believes the previous fakery
  84. ifeq ($(strip $(BR2_TARGET_ROOTFS_EXT2_BLOCKS)),0)
  85. GENEXT2_REALSIZE=`LC_ALL=C du -s -c -k $(TARGET_DIR) | grep total | sed -e "s/total//"`; \
  86. GENEXT2_ADDTOROOTSIZE=`if [ $$GENEXT2_REALSIZE -ge 20000 ]; then echo 16384; else echo 2400; fi`; \
  87. GENEXT2_SIZE=`expr $$GENEXT2_REALSIZE + $$GENEXT2_ADDTOROOTSIZE`; \
  88. GENEXT2_ADDTOINODESIZE=`find $(TARGET_DIR) | wc -l`; \
  89. GENEXT2_INODES=`expr $$GENEXT2_ADDTOINODESIZE + 400`; \
  90. set -x; \
  91. echo "$(GENEXT2_DIR)/genext2fs -b $$GENEXT2_SIZE " \
  92. "-N $$GENEXT2_INODES -d $(TARGET_DIR) " \
  93. "$(EXT2_OPTS) $(EXT2_BASE)" >> $(PROJECT_BUILD_DIR)/_fakeroot.$(notdir $(EXT2_TARGET))
  94. else
  95. echo "$(GENEXT2_DIR)/genext2fs -d $(TARGET_DIR) " \
  96. "$(EXT2_OPTS) $(EXT2_BASE)" >> $(PROJECT_BUILD_DIR)/_fakeroot.$(notdir $(EXT2_TARGET))
  97. endif
  98. chmod a+x $(PROJECT_BUILD_DIR)/_fakeroot.$(notdir $(EXT2_TARGET))
  99. $(HOST_DIR)/usr/bin/fakeroot -- $(PROJECT_BUILD_DIR)/_fakeroot.$(notdir $(EXT2_TARGET))
  100. -@rm -f $(PROJECT_BUILD_DIR)/_fakeroot.$(notdir $(EXT2_TARGET))
  101. ifneq ($(EXT2_ROOTFS_COMPRESSOR),)
  102. $(EXT2_BASE).$(EXT2_ROOTFS_COMPRESSOR_EXT): $(EXT2_ROOTFS_COMPRESSOR_PREREQ) $(EXT2_BASE)
  103. $(EXT2_ROOTFS_COMPRESSOR) $(EXT2_BASE) > $(EXT2_TARGET)
  104. endif
  105. EXT2_COPYTO := $(strip $(subst ",,$(BR2_TARGET_ROOTFS_EXT2_COPYTO)))
  106. # "))
  107. ext2root: $(EXT2_TARGET)
  108. @ls -l $(EXT2_TARGET)
  109. ifneq ($(EXT2_COPYTO),)
  110. @cp -f $(EXT2_TARGET) $(EXT2_COPYTO)
  111. endif
  112. ext2root-source: $(DL_DIR)/$(GENEXT2_SOURCE)
  113. ext2root-clean:
  114. -$(MAKE) -C $(GENEXT2_DIR) clean
  115. ext2root-dirclean:
  116. rm -rf $(GENEXT2_DIR)
  117. #############################################################
  118. #
  119. # Toplevel Makefile options
  120. #
  121. #############################################################
  122. ifeq ($(BR2_TARGET_ROOTFS_EXT2),y)
  123. TARGETS+=ext2root
  124. endif