Makefile 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171
  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. ifeq ($(ADK_TARGET_SYSTEM_BROADCOM_BCM47XX),y)
  22. kernel-install: tools-compile
  23. ${TARGET_CROSS}objcopy ${OSTRIP} -S ${LINUX_DIR}/vmlinuz.elf \
  24. ${BUILD_DIR}/${TARGET_KERNEL}
  25. ${BUILD_DIR}/${ROOTFSSQUASHFS}: ${BUILD_DIR}/root.squashfs
  26. ${TARGET_CROSS}objcopy -O binary ${BUILD_DIR}/${TARGET_KERNEL} \
  27. ${BUILD_DIR}/${TARGET_KERNEL}.bin
  28. gzip -n9 <${BUILD_DIR}/${TARGET_KERNEL}.bin \
  29. >${BUILD_DIR}/${TARGET_KERNEL}.bin.gz
  30. printf '\0' >>${BUILD_DIR}/${TARGET_KERNEL}.bin.gz
  31. PATH='${TARGET_PATH}' trx -o $@~ -f ${BUILD_DIR}/${TARGET_KERNEL}.bin.gz -a 1024 -f ${BUILD_DIR}/root.squashfs
  32. PATH='${TARGET_PATH}' addpattern -4 ${ADK_TOOLS_ADDPATTERN_ARGS} -g -i $@~ -o $@
  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. @cp $(KERNEL) $(BIN_DIR)/$(TARGET_KERNEL)
  98. @echo 'The kernel file is: $(BIN_DIR)/${TARGET_KERNEL}'
  99. @echo "The RootFS tarball is: $(BIN_DIR)/$(ROOTFSTARBALL)"
  100. ifneq ($(ADK_HARDWARE_QEMU),)
  101. @echo "Use following command to create a QEMU Image:"
  102. @echo "sudo ./scripts/create-image.sh -f $(ADK_TARGET_ROOTFS) qemu-${CPU_ARCH}.img $(BIN_DIR)/$(ROOTFSTARBALL)"
  103. @echo "Start qemu with following options:"
  104. @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'
  105. endif
  106. endif
  107. ifeq ($(ADK_TARGET_FS),initramfs)
  108. imageinstall: $(BIN_DIR)/$(INITRAMFS)
  109. @cp $(KERNEL) $(BIN_DIR)/$(TARGET_KERNEL)
  110. @echo 'The kernel file is: $(BIN_DIR)/${TARGET_KERNEL}'
  111. @echo 'The initramfs image is: ${BIN_DIR}/${INITRAMFS}'
  112. ifneq ($(ADK_HARDWARE_QEMU),)
  113. @echo "Start qemu with following command line:"
  114. @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}'
  115. endif
  116. endif
  117. ifeq ($(ADK_TARGET_FS),initramfs-piggyback)
  118. imageinstall: ${BUILD_DIR}/${INITRAMFS_PIGGYBACK} createinitramfs
  119. @cp $(KERNEL) $(BIN_DIR)/$(TARGET_KERNEL)
  120. @echo 'The kernel+initramfs file is: $(BIN_DIR)/${TARGET_KERNEL}'
  121. ifneq ($(ADK_HARDWARE_QEMU),)
  122. @echo "Start qemu with following command line:"
  123. @echo 'qemu-system-${CPU_ARCH} -nographic -M malta -net user,hostfwd=tcp::2222-:22 -net nic,model=pcnet -kernel $(BIN_DIR)/$(TARGET_KERNEL)'
  124. endif
  125. endif
  126. ifeq ($(ADK_TARGET_FS),usb)
  127. imageinstall: $(BIN_DIR)/$(ROOTFSTARBALL)
  128. @echo "The RootFS tarball is: $(BIN_DIR)/$(ROOTFSTARBALL)"
  129. ifeq ($(ADK_TARGET_SYSTEM_LEMOTE_YEELONG),y)
  130. @echo "Startup the netbook and type del to enter PMON:"
  131. @echo "PMON> load /dev/fs/ext2@usb0/boot/kernel"
  132. @echo "PMON> g root=/dev/sdc1"
  133. @echo "The root parameter have to be changed."
  134. endif
  135. endif
  136. ifeq ($(ADK_TARGET_FS),cf)
  137. imageinstall: kernel-install $(BIN_DIR)/$(ROOTFSUSERTARBALL)
  138. @cp $(BUILD_DIR)/$(TARGET_KERNEL) $(BIN_DIR)/$(TARGET_KERNEL)
  139. @echo 'The kernel file is: $(BIN_DIR)/${TARGET_KERNEL}'
  140. @echo "The RootFS tarball is: $(BIN_DIR)/$(ROOTFSUSERTARBALL)"
  141. @echo "Boot the board via network (tftp+nfsroot) and use adkinstall."
  142. @echo "If you just want to update, use adkupdate."
  143. endif
  144. ifeq ($(ADK_TARGET_FS),squashfs)
  145. imageinstall: kernel-install ${BUILD_DIR}/${ROOTFSSQUASHFS}
  146. @if [ $$($(STATCMD) ${BUILD_DIR}/${ROOTFSSQUASHFS}) -gt 3801088 ];then \
  147. echo 'Image is too big!'; \
  148. else \
  149. ${CP} ${BUILD_DIR}/${ROOTFSSQUASHFS} ${BIN_DIR}/${ROOTFSSQUASHFS}; \
  150. echo The image file is $(ROOTFSSQUASHFS); \
  151. fi
  152. ifeq ($(ADK_TARGET_SYSTEM_FON_FON2100),y)
  153. echo The kernel file is $(TARGET_KERNEL)
  154. endif
  155. ifeq ($(ADK_TARGET_SYSTEM_BROADCOM_BCM47XX),y)
  156. echo 'You can flash the image via tftp:'
  157. echo 'tftp 192.168.1.1'
  158. echo 'tftp> binary'
  159. echo "tftp> put $(ROOTFSSQUASHFS) upgrade_code.bin"
  160. endif
  161. endif