Makefile 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121
  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. include $(TOPDIR)/rules.mk
  4. include $(TOPDIR)/mk/kernel.mk
  5. include $(TOPDIR)/mk/modules.mk
  6. include $(TOPDIR)/mk/kernel-build.mk
  7. ifeq (${ADK_KERNEL_BCM47XX},y)
  8. CUSTOM_ROOTFSSQUASHFS_BUILD=1
  9. endif
  10. include $(TOPDIR)/mk/image.mk
  11. KERNEL:=$(LINUX_DIR)/vmlinux
  12. OSTRIP:=-R .reginfo -R .notes -R .note -R .comment -R .mdebug -R .note.gnu.build-id
  13. tools-compile:
  14. $(MAKE) -C ../tools/trx all
  15. $(MAKE) -C ../tools/addpattern all
  16. $(MAKE) -C ../tools/srec2bin all
  17. $(MAKE) -C ../tools/squashfs all
  18. ifeq ($(ADK_KERNEL_BCM47XX),y)
  19. kernel-install: tools-compile
  20. ${TARGET_CROSS}objcopy ${OSTRIP} -S ${LINUX_DIR}/vmlinuz.elf \
  21. ${BUILD_DIR}/${TARGET_KERNEL}
  22. ${BUILD_DIR}/${ROOTFSSQUASHFS}: ${BUILD_DIR}/root.squashfs
  23. ${TARGET_CROSS}objcopy -O binary ${BUILD_DIR}/${TARGET_KERNEL} \
  24. ${BUILD_DIR}/${TARGET_KERNEL}.bin
  25. gzip -n9 <${BUILD_DIR}/${TARGET_KERNEL}.bin \
  26. >${BUILD_DIR}/${TARGET_KERNEL}.bin.gz
  27. printf '\0' >>${BUILD_DIR}/${TARGET_KERNEL}.bin.gz
  28. PATH='${TARGET_PATH}' trx -o $@~ -f ${BUILD_DIR}/${TARGET_KERNEL}.bin.gz -a 1024 -f ${BUILD_DIR}/root.squashfs
  29. PATH='${TARGET_PATH}' addpattern -4 ${ADK_TOOLS_ADDPATTERN_ARGS} -g -i $@~ -o $@
  30. endif
  31. ifeq ($(ADK_TARGET_SYSTEM_LINKSYS_AG241),y)
  32. kernel-install: tools-compile
  33. ${TARGET_CROSS}objcopy -S -O srec $(KERNEL) $(LINUX_DIR)/vmlinux.srec
  34. PATH='${TARGET_PATH}' srec2bin $(LINUX_DIR)/vmlinux.srec $(LINUX_DIR)/vmlinux.bin
  35. (dd if=/dev/zero bs=16 count=1; cat $(LINUX_DIR)/vmlinux.bin) > $(LINUX_DIR)/vmlinux.tmp
  36. PATH='${TARGET_PATH}' addpattern -p AG3B -b -r 2.0 -i $(LINUX_DIR)/vmlinux.tmp \
  37. -o $(BUILD_DIR)/$(TARGET_KERNEL) 2>/dev/null
  38. endif
  39. ifeq ($(ADK_TARGET_SYSTEM_MIKROTIK_RB532),y)
  40. kernel-install:
  41. $(TARGET_CROSS)objcopy $(OSTRIP) -S $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL)
  42. endif
  43. ifeq ($(ADK_TARGET_FS),cf)
  44. imageinstall: kernel-install $(BIN_DIR)/$(ROOTFSUSERTARBALL)
  45. @cp $(BUILD_DIR)/$(TARGET_KERNEL) $(BIN_DIR)/$(TARGET_KERNEL)
  46. @echo 'The kernel file is: $(BIN_DIR)/${TARGET_KERNEL}'
  47. @echo "The RootFS tarball is: $(BIN_DIR)/$(ROOTFSUSERTARBALL)"
  48. @echo "Boot the board via network (tftp+nfsroot) and use adkinstall."
  49. @echo "If you just want to update, use adkupdate."
  50. endif
  51. ifeq ($(ADK_TARGET_FS),squashfs)
  52. imageinstall: kernel-install ${BUILD_DIR}/${ROOTFSSQUASHFS}
  53. @if [ $$($(STATCMD) ${BUILD_DIR}/${ROOTFSSQUASHFS}) -gt 3801088 ];then \
  54. echo 'Image is too big!'; \
  55. else \
  56. ${CP} ${BUILD_DIR}/${ROOTFSSQUASHFS} ${BIN_DIR}/${ROOTFSSQUASHFS}; \
  57. echo The image file is $(ROOTFSSQUASHFS); \
  58. echo 'You can flash the image via tftp:'; \
  59. echo 'tftp 192.168.1.1'; \
  60. echo 'tftp> binary'; \
  61. echo "tftp> put $(ROOTFSSQUASHFS) upgrade_code.bin"; \
  62. fi
  63. endif
  64. ifeq ($(ADK_TARGET_FS),nfsroot)
  65. imageinstall: kernel-install $(BIN_DIR)/$(ROOTFSUSERTARBALL)
  66. @cp $(BUILD_DIR)/$(TARGET_KERNEL) $(BIN_DIR)/$(TARGET_KERNEL)
  67. @echo 'The kernel file is: $(BIN_DIR)/${TARGET_KERNEL}'
  68. @echo 'The nfs root tarball is: ${BIN_DIR}/${ROOTFSUSERTARBALL}'
  69. ifeq ($(ADK_TARGET_SYSTEM_LINKSYS_AG241),y)
  70. @echo 'You can flash the kernel via tftp:'
  71. @echo 'tftp 192.168.1.1'
  72. @echo 'tftp> binary'
  73. @echo 'tftp> put $(BIN_DIR)/${TARGET_KERNEL} upgrade_code.bin'
  74. endif
  75. ifeq ($(ADK_KERNEL_BCM47XX),y)
  76. @echo 'Type following on the CFE prompt to boot the kernel:'
  77. @echo 'CFE> boot -elf -tftp 192.168.1.254:$(BIN_DIR)/${TARGET_KERNEL}'
  78. endif
  79. endif
  80. ifeq ($(ADK_TARGET_FS),archive)
  81. imageinstall: $(BIN_DIR)/$(ROOTFSTARBALL)
  82. @cp $(KERNEL) $(BIN_DIR)/$(TARGET_KERNEL)
  83. @echo 'The kernel file is: $(BIN_DIR)/${TARGET_KERNEL}'
  84. @echo "The RootFS tarball is: $(BIN_DIR)/$(ROOTFSTARBALL)"
  85. @echo "Use following command to create a QEMU Image:"
  86. @echo "sudo ./scripts/create-image.sh -f $(ADK_TARGET_ROOTFS) qemu-${CPU_ARCH}.img $(BIN_DIR)/$(ROOTFSTARBALL)"
  87. @echo "Be sure to change permissions after image creation."
  88. @echo "Start qemu with following options:"
  89. @echo 'qemu-system-mipsel -nographic -M malta -kernel $(BIN_DIR)/$(TARGET_KERNEL) qemu-${CPU_ARCH}.img'
  90. endif
  91. ifeq ($(ADK_TARGET_FS),initramfs)
  92. imageinstall: $(BIN_DIR)/$(INITRAMFS)
  93. @cp $(KERNEL) $(BIN_DIR)/$(TARGET_KERNEL)
  94. @echo 'The kernel file is: $(BIN_DIR)/${TARGET_KERNEL}'
  95. @echo 'The initramfs image is: ${BIN_DIR}/${INITRAMFS}'
  96. @echo 'qemu-system-mipsel -nographic -M malta -kernel $(BIN_DIR)/$(TARGET_KERNEL) -initrd ${BIN_DIR}/${INITRAMFS}'
  97. endif
  98. ifeq ($(ADK_TARGET_FS),initramfs-piggyback)
  99. imageinstall: ${BUILD_DIR}/${INITRAMFS_PIGGYBACK} createinitramfs
  100. @cp $(KERNEL) $(BIN_DIR)/$(TARGET_KERNEL)
  101. @echo 'The kernel+initramfs file is: $(BIN_DIR)/${TARGET_KERNEL}'
  102. @echo "Start qemu with following command line:"
  103. @echo 'qemu-system-mipsel -nographic -M malta -kernel $(BIN_DIR)/$(TARGET_KERNEL)'
  104. endif
  105. ifeq ($(ADK_TARGET_FS),yaffs)
  106. imageinstall: kernel-install $(BIN_DIR)/$(ROOTFSTARBALL)
  107. @echo "The RootFS tarball is:"
  108. @echo "$(BIN_DIR)/$(ROOTFSTARBALL)"
  109. @echo "Boot the board via network (tftp/nfsroot) and use adkinstall."
  110. @echo "If you just want to update, use adkupdate."
  111. endif