Makefile 7.2 KB

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