Makefile 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168
  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 +g 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. endif
  106. ifeq ($(ADK_TARGET_FS),initramfs)
  107. imageinstall: $(FW_DIR)/$(INITRAMFS)
  108. @cp $(KERNEL) $(FW_DIR)/$(TARGET_KERNEL)
  109. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  110. @echo 'The initramfs image is: ${FW_DIR}/${INITRAMFS}'
  111. ifneq ($(ADK_HARDWARE_QEMU),)
  112. @echo "Start qemu with following command line:"
  113. @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}'
  114. endif
  115. endif
  116. ifeq ($(ADK_TARGET_FS),initramfs-piggyback)
  117. imageinstall: createinitramfs
  118. @cp $(KERNEL) $(FW_DIR)/$(TARGET_KERNEL)
  119. @echo 'The kernel+initramfs file is: $(FW_DIR)/${TARGET_KERNEL}'
  120. ifneq ($(ADK_HARDWARE_QEMU),)
  121. @echo "Start qemu with following command line:"
  122. @echo 'qemu-system-${CPU_ARCH} -nographic -M malta -device e1000,netdev=adk0 -netdev user,id=adk0 -kernel $(FW_DIR)/$(TARGET_KERNEL)'
  123. endif
  124. endif
  125. ifeq ($(ADK_TARGET_FS),usb)
  126. imageinstall: $(FW_DIR)/$(ROOTFSTARBALL)
  127. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSTARBALL)"
  128. ifeq ($(ADK_TARGET_SYSTEM_LEMOTE_YEELONG),y)
  129. @echo "Startup the netbook and type del to enter PMON:"
  130. @echo "PMON> load /dev/fs/ext2@usb0/boot/kernel"
  131. @echo "PMON> g root=/dev/sdc1"
  132. endif
  133. endif
  134. ifeq ($(ADK_TARGET_FS),cf)
  135. imageinstall: kernel-install $(FW_DIR)/$(ROOTFSUSERTARBALL)
  136. @cp $(BUILD_DIR)/$(TARGET_KERNEL) $(FW_DIR)/$(TARGET_KERNEL)
  137. @echo 'The kernel file is: $(FW_DIR)/${TARGET_KERNEL}'
  138. @echo "The RootFS tarball is: $(FW_DIR)/$(ROOTFSUSERTARBALL)"
  139. @echo "Boot the board via network (tftp+nfsroot) and use adkinstall."
  140. @echo "If you just want to update, use adkupdate."
  141. endif
  142. ifeq ($(ADK_TARGET_FS),squashfs)
  143. imageinstall: kernel-install ${BUILD_DIR}/${ROOTFSSQUASHFS}
  144. @if [ $$($(STATCMD) ${BUILD_DIR}/${ROOTFSSQUASHFS}) -gt 3801088 ];then \
  145. echo 'Image is too big!'; \
  146. else \
  147. ${CP} ${BUILD_DIR}/${ROOTFSSQUASHFS} ${FW_DIR}/${ROOTFSSQUASHFS}; \
  148. echo The image file is $(ROOTFSSQUASHFS); \
  149. fi
  150. ifeq ($(ADK_TARGET_SYSTEM_FON_FON2100),y)
  151. @echo The kernel file is $(TARGET_KERNEL)
  152. endif
  153. ifeq ($(ADK_TARGET_SYSTEM_BROADCOM_BCM47XX),y)
  154. @echo 'You can flash the image via tftp:'
  155. @echo 'tftp 192.168.1.1'
  156. @echo 'tftp> binary'
  157. @echo "tftp> put $(ROOTFSSQUASHFS) upgrade_code.bin"
  158. endif
  159. endif