Makefile 7.2 KB

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