Makefile 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167
  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. include $(TOPDIR)/mk/image.mk
  8. ifeq ($(ADK_TARGET_SYSTEM_LEMOTE_YEELONG),y)
  9. KERNEL:=$(LINUX_DIR)/vmlinuz
  10. else ifeq ($(ADK_TARGET_SYSTEM_FON_FON2100),y)
  11. KERNEL:=$(LINUX_DIR)/vmlinuz
  12. else
  13. KERNEL:=$(LINUX_DIR)/vmlinux
  14. endif
  15. OSTRIP:=-R .reginfo -R .notes -R .note -R .comment -R .mdebug -R .note.gnu.build-id
  16. tools-compile:
  17. $(MAKE) -C ../tools/trx all
  18. $(MAKE) -C ../tools/addpattern all
  19. $(MAKE) -C ../tools/srec2bin all
  20. $(MAKE) -C ../tools/squashfs all
  21. ifeq ($(ADK_TARGET_SYSTEM_BROADCOM_BCM47XX),y)
  22. kernel-install: tools-compile
  23. ${TARGET_CROSS}objcopy ${OSTRIP} -S ${LINUX_DIR}/vmlinuz.elf \
  24. ${BUILD_DIR}/${TARGET_KERNEL}
  25. ${BUILD_DIR}/${ROOTFSSQUASHFS}: ${BUILD_DIR}/root.squashfs
  26. ${TARGET_CROSS}objcopy -O binary ${BUILD_DIR}/${TARGET_KERNEL} \
  27. ${BUILD_DIR}/${TARGET_KERNEL}.bin
  28. gzip -n9 <${BUILD_DIR}/${TARGET_KERNEL}.bin \
  29. >${BUILD_DIR}/${TARGET_KERNEL}.bin.gz
  30. printf '\0' >>${BUILD_DIR}/${TARGET_KERNEL}.bin.gz
  31. PATH='${TARGET_PATH}' trx -o $@~ -f ${BUILD_DIR}/${TARGET_KERNEL}.bin.gz -a 1024 -f ${BUILD_DIR}/root.squashfs
  32. PATH='${TARGET_PATH}' addpattern -4 ${ADK_TOOLS_ADDPATTERN_ARGS} -g -i $@~ -o $@
  33. endif
  34. ifeq ($(ADK_TARGET_SYSTEM_LINKSYS_AG241),y)
  35. kernel-install: tools-compile
  36. ${TARGET_CROSS}objcopy -S -O srec $(KERNEL) $(LINUX_DIR)/vmlinux.srec
  37. PATH='${TARGET_PATH}' srec2bin $(LINUX_DIR)/vmlinux.srec $(LINUX_DIR)/vmlinux.bin
  38. (dd if=/dev/zero bs=16 count=1; cat $(LINUX_DIR)/vmlinux.bin) > $(LINUX_DIR)/vmlinux.tmp
  39. PATH='${TARGET_PATH}' addpattern -p AG3B -b -r 2.0 -i $(LINUX_DIR)/vmlinux.tmp \
  40. -o $(BUILD_DIR)/$(TARGET_KERNEL) 2>/dev/null
  41. endif
  42. ifeq ($(ADK_TARGET_SYSTEM_MIKROTIK_RB532),y)
  43. kernel-install:
  44. $(TARGET_CROSS)objcopy $(OSTRIP) -S $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL)
  45. endif
  46. ifeq ($(ADK_TARGET_SYSTEM_MIKROTIK_RB411),y)
  47. kernel-install:
  48. $(TARGET_CROSS)objcopy $(OSTRIP) -S $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL)
  49. endif
  50. ifeq ($(ADK_TARGET_SYSTEM_MIKROTIK_RB433),y)
  51. kernel-install:
  52. $(TARGET_CROSS)objcopy $(OSTRIP) -S $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL)
  53. endif
  54. ifeq ($(ADK_TARGET_SYSTEM_FON_FON2100),y)
  55. kernel-install: tools-compile
  56. $(TARGET_CROSS)objcopy $(OSTRIP) -S $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL)
  57. ${BUILD_DIR}/${ROOTFSSQUASHFS}: ${BUILD_DIR}/root.squashfs
  58. $(TARGET_CROSS)objcopy $(OSTRIP) -S $(LINUX_DIR)/vmlinux $(BUILD_DIR)/vmlinux.strip
  59. dd if=$(BUILD_DIR)/vmlinux.strip of=${BUILD_DIR}/vmlinux bs=65536 conv=sync
  60. lzma -9efzc ${BUILD_DIR}/vmlinux > $(BIN_DIR)/${TARGET_KERNEL}
  61. cp ${BUILD_DIR}/root.squashfs ${BUILD_DIR}/${ROOTFSSQUASHFS}
  62. endif
  63. ifeq ($(ADK_TARGET_SYSTEM_LEMOTE_YEELONG),y)
  64. kernel-install:
  65. $(TARGET_CROSS)objcopy $(OSTRIP) -S $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL)
  66. endif
  67. ifeq ($(ADK_TARGET_SYSTEM_QEMU_MIPS),y)
  68. kernel-install:
  69. $(TARGET_CROSS)objcopy $(OSTRIP) -S $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL)
  70. endif
  71. ifeq ($(ADK_TARGET_SYSTEM_QEMU_MIPSEL),y)
  72. kernel-install:
  73. $(TARGET_CROSS)objcopy $(OSTRIP) -S $(KERNEL) $(BUILD_DIR)/$(TARGET_KERNEL)
  74. endif
  75. ifeq ($(ADK_TARGET_FS),nfsroot)
  76. imageinstall: kernel-install $(BIN_DIR)/$(ROOTFSUSERTARBALL)
  77. @cp $(BUILD_DIR)/$(TARGET_KERNEL) $(BIN_DIR)/${TARGET_KERNEL}
  78. @echo 'The kernel file is: $(BIN_DIR)/${TARGET_KERNEL}'
  79. @echo 'The nfs root tarball is: ${BIN_DIR}/${ROOTFSUSERTARBALL}'
  80. ifeq ($(ADK_TARGET_SYSTEM_FON_FON2100),y)
  81. @echo 'Type the following in Redboot:'
  82. @echo 'RedBoot> load $(TARGET_KERNEL)'
  83. @echo 'RedBoot> go'
  84. endif
  85. endif
  86. ifeq ($(ADK_TARGET_FS),yaffs)
  87. imageinstall: kernel-install $(BIN_DIR)/$(ROOTFSTARBALL)
  88. @echo 'The root tarball is: ${BIN_DIR}/${ROOTFSTARBALL}'
  89. @echo 'Format your NAND with Routerboot, boot via NFS and'
  90. @echo 'then install kernel and filesystem via:'
  91. @echo 'adkinstall ${ROOTFSTARBALL}'
  92. endif
  93. ifeq ($(ADK_TARGET_FS),archive)
  94. imageinstall: $(BIN_DIR)/$(ROOTFSTARBALL)
  95. @echo "The RootFS tarball is: $(BIN_DIR)/$(ROOTFSTARBALL)"
  96. ifneq ($(ADK_HARDWARE_QEMU),)
  97. @echo "Use following command to create a QEMU Image:"
  98. @echo "sudo ./scripts/create-image.sh -f $(ADK_TARGET_ROOTFS) qemu-${CPU_ARCH}.img $(BIN_DIR)/$(ROOTFSTARBALL)"
  99. @echo "Start qemu with following options:"
  100. @echo 'qemu-system-${CPU_ARCH} -nographic -M malta -kernel $(BIN_DIR)/$(TARGET_KERNEL) qemu-${CPU_ARCH}.img'
  101. endif
  102. endif
  103. ifeq ($(ADK_TARGET_FS),initramfs)
  104. imageinstall: $(BIN_DIR)/$(INITRAMFS)
  105. @cp $(KERNEL) $(BIN_DIR)/$(TARGET_KERNEL)
  106. @echo 'The kernel file is: $(BIN_DIR)/${TARGET_KERNEL}'
  107. @echo 'The initramfs image is: ${BIN_DIR}/${INITRAMFS}'
  108. ifneq ($(ADK_HARDWARE_QEMU),)
  109. @echo "Start qemu with following command line:"
  110. @echo 'qemu-system-${CPU_ARCH} -nographic -M malta -kernel $(BIN_DIR)/$(TARGET_KERNEL) -initrd ${BIN_DIR}/${INITRAMFS}'
  111. endif
  112. endif
  113. ifeq ($(ADK_TARGET_FS),initramfs-piggyback)
  114. imageinstall: ${BUILD_DIR}/${INITRAMFS_PIGGYBACK} createinitramfs
  115. @cp $(KERNEL) $(BIN_DIR)/$(TARGET_KERNEL)
  116. @echo 'The kernel+initramfs file is: $(BIN_DIR)/${TARGET_KERNEL}'
  117. ifneq ($(ADK_HARDWARE_QEMU),)
  118. @echo "Start qemu with following command line:"
  119. @echo 'qemu-system-${CPU_ARCH} -nographic -M malta -kernel $(BIN_DIR)/$(TARGET_KERNEL)'
  120. endif
  121. endif
  122. ifeq ($(ADK_TARGET_FS),usb)
  123. imageinstall: $(BIN_DIR)/$(ROOTFSTARBALL)
  124. @echo "The RootFS tarball is: $(BIN_DIR)/$(ROOTFSTARBALL)"
  125. ifeq ($(ADK_TARGET_SYSTEM_LEMOTE_YEELONG),y)
  126. @echo "Startup the netbook and type del to enter PMON:"
  127. @echo "PMON> load /dev/fs/ext2@usb0/boot/kernel"
  128. @echo "PMON> g root=/dev/sdc1"
  129. @echo "The root parameter have to be changed."
  130. endif
  131. endif
  132. ifeq ($(ADK_TARGET_FS),cf)
  133. imageinstall: kernel-install $(BIN_DIR)/$(ROOTFSUSERTARBALL)
  134. @cp $(BUILD_DIR)/$(TARGET_KERNEL) $(BIN_DIR)/$(TARGET_KERNEL)
  135. @echo 'The kernel file is: $(BIN_DIR)/${TARGET_KERNEL}'
  136. @echo "The RootFS tarball is: $(BIN_DIR)/$(ROOTFSUSERTARBALL)"
  137. @echo "Boot the board via network (tftp+nfsroot) and use adkinstall."
  138. @echo "If you just want to update, use adkupdate."
  139. endif
  140. ifeq ($(ADK_TARGET_FS),squashfs)
  141. imageinstall: kernel-install ${BUILD_DIR}/${ROOTFSSQUASHFS}
  142. @if [ $$($(STATCMD) ${BUILD_DIR}/${ROOTFSSQUASHFS}) -gt 3801088 ];then \
  143. echo 'Image is too big!'; \
  144. else \
  145. ${CP} ${BUILD_DIR}/${ROOTFSSQUASHFS} ${BIN_DIR}/${ROOTFSSQUASHFS}; \
  146. echo The image file is $(ROOTFSSQUASHFS); \
  147. fi
  148. ifeq ($(ADK_TARGET_SYSTEM_FON_FON2100),y)
  149. echo The kernel file is $(TARGET_KERNEL)
  150. endif
  151. ifeq ($(ADK_TARGET_SYSTEM_BROADCOM_BCM47XX),y)
  152. echo 'You can flash the image via tftp:'
  153. echo 'tftp 192.168.1.1'
  154. echo 'tftp> binary'
  155. echo "tftp> put $(ROOTFSSQUASHFS) upgrade_code.bin"
  156. endif
  157. endif