Makefile 5.0 KB

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