image.mk 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384
  1. # This file is part of the OpenADK project. OpenADK is copyrighted
  2. # material, please see the LICENCE file in the top-level directory.
  3. imageprepare: image-prepare-post extra-install
  4. # if an extra directory exist in TOPDIR, copy all content over the
  5. # root directory, do the same if make extra=/dir/to/extra is used
  6. extra-install:
  7. @if [ -d $(TOPDIR)/extra ];then $(CP) $(TOPDIR)/extra/* ${TARGET_DIR};fi
  8. @if [ ! -z $(extra) ];then $(CP) $(extra)/* ${TARGET_DIR};fi
  9. image-prepare-post:
  10. rng=/dev/arandom; test -e $$rng || rng=/dev/urandom; \
  11. dd if=$$rng bs=512 count=1 >>${TARGET_DIR}/etc/.rnd 2>/dev/null; \
  12. chmod 600 ${TARGET_DIR}/etc/.rnd
  13. chmod 4511 ${TARGET_DIR}/bin/busybox
  14. chmod 1777 ${TARGET_DIR}/tmp
  15. @if [ -d ${TARGET_DIR}/usr/share/fonts/X11 ];then \
  16. for i in $$(ls ${TARGET_DIR}/usr/share/fonts/X11/);do \
  17. mkfontdir ${TARGET_DIR}/usr/share/fonts/X11/$${i}; \
  18. done; \
  19. fi
  20. KERNEL_PKGDIR:=$(LINUX_BUILD_DIR)/kernel-pkg
  21. KERNEL_PKG:=$(PACKAGE_DIR)/kernel_$(KERNEL_VERSION)_$(CPU_ARCH).$(PKG_SUFFIX)
  22. kernel-package: $(KERNEL)
  23. $(TRACE) target/$(ADK_TARGET_ARCH)-create-kernel-package
  24. rm -rf $(KERNEL_PKGDIR)
  25. @mkdir -p $(KERNEL_PKGDIR)/boot
  26. cp $(KERNEL) $(KERNEL_PKGDIR)/boot/kernel
  27. @${BASH} ${SCRIPT_DIR}/make-ipkg-dir.sh ${KERNEL_PKGDIR} \
  28. ../linux/kernel.control ${KERNEL_VERSION} ${CPU_ARCH}
  29. $(PKG_BUILD) $(KERNEL_PKGDIR) $(PACKAGE_DIR) $(MAKE_TRACE)
  30. $(TRACE) target/$(ADK_TARGET_ARCH)-install-kernel-package
  31. $(PKG_INSTALL) $(KERNEL_PKG) $(MAKE_TRACE)
  32. TARGET_KERNEL= ${ADK_TARGET_SYSTEM}-${ADK_TARGET_ARCH}-${ADK_TARGET_FS}-kernel
  33. INITRAMFS= ${ADK_TARGET_SYSTEM}-${ADK_TARGET_ARCH}-${ADK_TARGET_LIBC}-${ADK_TARGET_FS}
  34. ROOTFSSQUASHFS= ${ADK_TARGET_SYSTEM}-${ADK_TARGET_ARCH}-${ADK_TARGET_LIBC}-${ADK_TARGET_FS}.img
  35. ROOTFSTARBALL= ${ADK_TARGET_SYSTEM}-${ADK_TARGET_ARCH}-${ADK_TARGET_LIBC}-${ADK_TARGET_FS}+kernel.tar.gz
  36. ROOTFSUSERTARBALL= ${ADK_TARGET_SYSTEM}-${ADK_TARGET_ARCH}-${ADK_TARGET_LIBC}-${ADK_TARGET_FS}.tar.gz
  37. INITRAMFS_PIGGYBACK= ${ADK_TARGET_SYSTEM}-${ADK_TARGET_ARCH}-${ADK_TARGET_LIBC}-${ADK_TARGET_FS}.cpio
  38. ${BIN_DIR}/${ROOTFSTARBALL}: ${TARGET_DIR} kernel-package
  39. cd ${TARGET_DIR}; find . | sed -n '/^\.\//s///p' | \
  40. sed "s#\(.*\)#:0:0::::::\1#" | sort | \
  41. ${TOOLS_DIR}/cpio -o -Hustar -P | gzip -n9 >$@
  42. ${BIN_DIR}/${ROOTFSUSERTARBALL}: ${TARGET_DIR}
  43. cd ${TARGET_DIR}; find . | grep -v ./boot/ | sed -n '/^\.\//s///p' | \
  44. sed "s#\(.*\)#:0:0::::::\1#" | sort | \
  45. ${TOOLS_DIR}/cpio -o -Hustar -P | gzip -n9 >$@
  46. ${BIN_DIR}/${INITRAMFS}: ${TARGET_DIR}
  47. cd ${TARGET_DIR}; find . | sed -n '/^\.\//s///p' | \
  48. sed "s#\(.*\)#:0:0::::::\1#" | sort | \
  49. ${TOOLS_DIR}/cpio -o -C512 -Hnewc -P | \
  50. lzma -9 >$@ 2>/dev/null
  51. ${BUILD_DIR}/${INITRAMFS_PIGGYBACK}: ${TARGET_DIR}
  52. $(SED) 's#^CONFIG_INITRAMFS_SOURCE.*#CONFIG_INITRAMFS_SOURCE="${BUILD_DIR}/${INITRAMFS_PIGGYBACK}"#' \
  53. $(LINUX_DIR)/.config
  54. cd ${TARGET_DIR}; find . | sed -n '/^\.\//s///p' | \
  55. sed "s#\(.*\)#:0:0::::::\1#" | sort | \
  56. ${TOOLS_DIR}/cpio -o -C512 -Hnewc -P >$@ 2>/dev/null
  57. ${BIN_DIR}/${ROOTFSSQUASHFS}: ${TARGET_DIR}
  58. ${STAGING_HOST_DIR}/bin/mksquashfs ${TARGET_DIR} \
  59. ${BUILD_DIR}/root.squashfs \
  60. -nopad -noappend -root-owned $(MAKE_TRACE)
  61. cat ${BUILD_DIR}/${TARGET_KERNEL} ${BUILD_DIR}/root.squashfs > \
  62. ${BUILD_DIR}/${ROOTFSSQUASHFS}
  63. createinitramfs:
  64. @-rm $(LINUX_DIR)/usr/initramfs_data.cpio* $(MAKE_TRACE)
  65. echo N | \
  66. $(MAKE) -C $(LINUX_DIR) V=1 CROSS_COMPILE="$(TARGET_CROSS)" \
  67. ARCH=$(ARCH) CC="$(TARGET_CC)" oldconfig $(MAKE_TRACE)
  68. $(MAKE) -C $(LINUX_DIR) V=1 CROSS_COMPILE="$(TARGET_CROSS)" \
  69. ARCH=$(ARCH) CC="$(TARGET_CC)" $(MAKE_TRACE)
  70. imageclean:
  71. rm -f $(BIN_DIR)/$(ADK_TARGET_SYSTEM)-* ${BUILD_DIR}/$(ADK_TARGET_SYSTEM)-*