1
0

Makefile 6.9 KB

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