Makefile 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102
  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. JFFS2_BLOCKSIZE = 64k 128k 256k
  8. include $(TOPDIR)/rules.mk
  9. include $(INCLUDE_DIR)/image.mk
  10. IMAGE_PROFILE:=$(if $(PROFILE),$(PROFILE),Default)
  11. KERNEL_LOADADDR = 0x80060000
  12. DEVICE_VARS += NETGEAR_KERNEL_MAGIC NETGEAR_BOARD_ID NETGEAR_HW_ID CMDLINE CONSOLE IMAGE_SIZE BOARDNAME LOADER_FLASH_OFFS LOADER_TYPE
  13. ifeq ($(SUBTARGET),generic)
  14. include ./tp-link.mk
  15. include ./ubnt.mk
  16. include ./generic.mk
  17. endif
  18. ifeq ($(SUBTARGET),nand)
  19. include ./nand.mk
  20. endif
  21. include ./legacy.mk
  22. define Build/netgear-squashfs
  23. rm -rf $@.fs $@.squashfs
  24. mkdir -p $@.fs/image
  25. cp $@ $@.fs/image/uImage
  26. $(STAGING_DIR_HOST)/bin/mksquashfs-lzma \
  27. $@.fs $@.squashfs \
  28. -noappend -root-owned -be -b 65536 \
  29. $(if $(SOURCE_DATE_EPOCH),-fixed-time $(SOURCE_DATE_EPOCH))
  30. dd if=/dev/zero bs=1k count=1 >> $@.squashfs
  31. mkimage \
  32. -A mips -O linux -T filesystem -C none \
  33. -M $(NETGEAR_KERNEL_MAGIC) \
  34. -a 0xbf070000 -e 0xbf070000 \
  35. -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
  36. -d $@.squashfs $@
  37. rm -rf $@.squashfs $@.fs
  38. endef
  39. define Build/netgear-uImage
  40. $(call Build/uImage,$(1) -M $(NETGEAR_KERNEL_MAGIC))
  41. endef
  42. define Build/loader-common
  43. rm -rf $@.src
  44. $(MAKE) -C lzma-loader \
  45. PKG_BUILD_DIR="$@.src" \
  46. TARGET_DIR="$(dir $@)" LOADER_NAME="$(notdir $@)" \
  47. BOARD="$(BOARDNAME)" \
  48. LZMA_TEXT_START=0x80a00000 LOADADDR=0x80060000 \
  49. $(1) compile loader.$(LOADER_TYPE)
  50. mv "$@.$(LOADER_TYPE)" "$@"
  51. rm -rf $@.src
  52. endef
  53. define Build/loader-okli-compile
  54. $(call Build/loader-common,FLASH_OFFS=$(LOADER_FLASH_OFFS) FLASH_MAX=0 KERNEL_CMDLINE="$(CMDLINE)")
  55. endef
  56. define Build/loader-kernel
  57. $(call Build/loader-common,LOADER_DATA="$@")
  58. endef
  59. define Build/loader-kernel-cmdline
  60. $(call Build/loader-common,LOADER_DATA="$@" KERNEL_CMDLINE="$(CMDLINE)")
  61. endef
  62. define Build/loader-okli
  63. dd if=$(KDIR)/loader-$(1).gz bs=7680 conv=sync of="$@.new"
  64. cat "$@" >> "$@.new"
  65. mv "$@.new" "$@"
  66. endef
  67. define Build/copy-file
  68. cat "$(1)" > "$@"
  69. endef
  70. define Device/Default
  71. BOARDNAME :=
  72. DEVICE_PROFILE = $$(BOARDNAME)
  73. PROFILES = Default Minimal $$(DEVICE_PROFILE)
  74. MTDPARTS :=
  75. IMAGES := sysupgrade.bin
  76. BLOCKSIZE := 64k
  77. FILESYSTEMS = $(filter-out jffs2-%,$(TARGET_FILESYSTEMS)) jffs2-$$(BLOCKSIZE)
  78. CONSOLE = ttyS0,115200
  79. CMDLINE = $$(if $$(BOARDNAME),board=$$(BOARDNAME)) $$(if $$(MTDPARTS),mtdparts=$$(MTDPARTS)) $$(if $$(CONSOLE),console=$$(CONSOLE))
  80. KERNEL := kernel-bin | patch-cmdline | lzma | uImage lzma
  81. COMPILE :=
  82. IMAGES := sysupgrade.bin
  83. IMAGE/sysupgrade.bin = append-kernel $$$$(BLOCKSIZE) | append-rootfs | pad-rootfs | check-size $$$$(IMAGE_SIZE)
  84. endef
  85. $(eval $(call BuildImage))