1
0

Makefile 7.1 KB

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