Makefile 3.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  1. #
  2. # Copyright (C) 2008-2011 OpenWrt.org
  3. #
  4. # This is free software, licensed under the GNU General Public License v2.
  5. # See /LICENSE for more information.
  6. #
  7. include $(TOPDIR)/rules.mk
  8. include $(INCLUDE_DIR)/image.mk
  9. KERNEL_LOADADDR = 0x80060000
  10. DEVICE_VARS += NETGEAR_KERNEL_MAGIC NETGEAR_BOARD_ID NETGEAR_HW_ID CMDLINE CONSOLE IMAGE_SIZE BOARDNAME LOADER_FLASH_OFFS LOADER_TYPE
  11. ifeq ($(SUBTARGET),generic)
  12. include ./tp-link.mk
  13. include ./ubnt.mk
  14. include ./generic.mk
  15. include ./legacy-devices.mk
  16. endif
  17. ifeq ($(SUBTARGET),nand)
  18. include ./nand.mk
  19. endif
  20. ifeq ($(SUBTARGET),mikrotik)
  21. include ./mikrotik.mk
  22. endif
  23. include ./legacy.mk
  24. define Build/netgear-squashfs
  25. rm -rf $@.fs $@.squashfs
  26. mkdir -p $@.fs/image
  27. cp $@ $@.fs/image/uImage
  28. $(STAGING_DIR_HOST)/bin/mksquashfs-lzma \
  29. $@.fs $@.squashfs \
  30. -noappend -root-owned -be -b 65536 \
  31. $(if $(SOURCE_DATE_EPOCH),-fixed-time $(SOURCE_DATE_EPOCH))
  32. dd if=/dev/zero bs=1k count=1 >> $@.squashfs
  33. mkimage \
  34. -A mips -O linux -T filesystem -C none \
  35. -M $(NETGEAR_KERNEL_MAGIC) \
  36. -a 0xbf070000 -e 0xbf070000 \
  37. -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
  38. -d $@.squashfs $@
  39. rm -rf $@.squashfs $@.fs
  40. endef
  41. define Build/netgear-uImage
  42. $(call Build/uImage,$(1) -M $(NETGEAR_KERNEL_MAGIC))
  43. endef
  44. define Build/loader-common
  45. rm -rf $@.src
  46. $(MAKE) -C lzma-loader \
  47. PKG_BUILD_DIR="$@.src" \
  48. TARGET_DIR="$(dir $@)" LOADER_NAME="$(notdir $@)" \
  49. BOARD="$(BOARDNAME)" \
  50. LZMA_TEXT_START=0x80a00000 LOADADDR=0x80060000 \
  51. $(1) compile loader.$(LOADER_TYPE)
  52. mv "$@.$(LOADER_TYPE)" "$@"
  53. rm -rf $@.src
  54. endef
  55. define Build/loader-okli-compile
  56. $(call Build/loader-common,FLASH_OFFS=$(LOADER_FLASH_OFFS) FLASH_MAX=0 KERNEL_CMDLINE="$(CMDLINE)")
  57. endef
  58. define Build/loader-kernel
  59. $(call Build/loader-common,LOADER_DATA="$@")
  60. endef
  61. define Build/loader-kernel-cmdline
  62. $(call Build/loader-common,LOADER_DATA="$@" KERNEL_CMDLINE="$(CMDLINE)")
  63. endef
  64. define Build/loader-okli
  65. dd if=$(KDIR)/loader-$(1).gz bs=7680 conv=sync of="$@.new"
  66. cat "$@" >> "$@.new"
  67. mv "$@.new" "$@"
  68. endef
  69. define Build/relocate-kernel
  70. rm -rf $@.relocate
  71. $(CP) ../../generic/image/relocate $@.relocate
  72. $(MAKE) -j1 -C $@.relocate KERNEL_ADDR=$(KERNEL_LOADADDR) CROSS_COMPILE=$(TARGET_CROSS)
  73. ( \
  74. dd if=$@.relocate/loader.bin bs=32 conv=sync && \
  75. perl -e '@s = stat("$@"); print pack("N", @s[7])' && \
  76. cat "$@" \
  77. ) > "$@.new"
  78. mv "$@.new" "$@"
  79. rm -rf $@.relocate
  80. endef
  81. define Build/copy-file
  82. cat "$(1)" > "$@"
  83. endef
  84. define Device/Default
  85. BOARDNAME :=
  86. DEVICE_PROFILE = $$(BOARDNAME)
  87. PROFILES = Default Minimal $$(DEVICE_PROFILE)
  88. MTDPARTS :=
  89. BLOCKSIZE := 64k
  90. CONSOLE = ttyS0,115200
  91. CMDLINE = $$(if $$(BOARDNAME),board=$$(BOARDNAME)) $$(if $$(MTDPARTS),mtdparts=$$(MTDPARTS)) $$(if $$(CONSOLE),console=$$(CONSOLE))
  92. KERNEL := kernel-bin | patch-cmdline | lzma | uImage lzma
  93. COMPILE :=
  94. IMAGES := sysupgrade.bin
  95. IMAGE/sysupgrade.bin = append-kernel | pad-to $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE)
  96. endef
  97. $(eval $(call BuildImage))