Makefile 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112
  1. #
  2. # Copyright (C) 2006-2010 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. LOADER_MAKE := $(NO_TRACE_MAKE) -C lzma-loader KDIR=$(KDIR)
  10. JFFS2BLOCK := $(KDIR)/jffs2.block
  11. JFFS2MARK := $(KDIR)/jffs2.mark
  12. define imgname
  13. $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(patsubst jffs2-%,jffs2,$(1))
  14. endef
  15. VMLINUX:=$(BIN_DIR)/$(IMG_PREFIX)-vmlinux
  16. fs_squash:=squashfs-only
  17. fs_all:=all
  18. fs_4k:=4k
  19. fs_64k:=64k
  20. fs_128k:=128k
  21. define Build/Clean
  22. $(LOADER_MAKE) clean
  23. endef
  24. define Image/Prepare
  25. cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
  26. rm -f $(JFFS2BLOCK)
  27. touch $(JFFS2BLOCK)
  28. $(call prepare_generic_squashfs,$(JFFS2BLOCK))
  29. rm -f $(JFFS2MARK)
  30. touch $(JFFS2MARK)
  31. $(call add_jffs2_mark,$(JFFS2MARK))
  32. endef
  33. define Image/Build/Loader
  34. $(LOADER_MAKE) LOADER=loader-$(1).$(2) LOADER_DATA="" \
  35. LZMA_TEXT_START=$(3) LZMA_STARTUP_ORG=$(4) \
  36. CONFIG_PASS_KARGS=$(5) CONFIG_BOARD=$(6) \
  37. compile loader.$(2)
  38. endef
  39. define Image/Build/LZMAKernel
  40. $(LOADER_MAKE) TARGET_DIR=$(BIN_DIR) \
  41. LOADER=$(BIN_DIR)/$(IMG_PREFIX)-$(1)-ramfs.$(2) \
  42. LOADER_DATA=$(KDIR)/vmlinux.lzma \
  43. LZMA_TEXT_START=$(3) LZMA_STARTUP_ORG=$(4) \
  44. CONFIG_PASS_KARGS=$(5) CONFIG_BOARD=$(6) \
  45. compile loader.$(2)
  46. endef
  47. define Image/Build/LZMAKernel/Generic
  48. $(call Image/Build/LZMAKernel,$(1),$(2),0x80500000,0)
  49. endef
  50. define Image/Build/LZMAKernel/Admboot
  51. $(call Image/Build/LZMAKernel,$(1),$(2),0x80500000,0x6D8,y,$(1))
  52. endef
  53. define Image/Build/LZMAKernel/Cellvision
  54. $(call Image/Build/LZMAKernel,$(1),$(3),0x80500000,0x6D8,y,$(2))
  55. endef
  56. define Image/Build/LZMAKernel/KArgs
  57. $(call Image/Build/LZMAKernel,$(1),$(2),0x80500000,0,y,$(1))
  58. endef
  59. define trxalign/jffs2-128k
  60. -a 0x20000 -f $(KDIR)/root.jffs2-128k
  61. endef
  62. define trxalign/jffs2-64k
  63. -a 0x10000 -f $(KDIR)/root.jffs2-64k
  64. endef
  65. define trxalign/squashfs
  66. -a 1024 -f $(KDIR)/root.squashfs -a 0x10000 -A $(JFFS2BLOCK)
  67. endef
  68. define Image/Build/TRX
  69. $(STAGING_DIR_HOST)/bin/trx -o $(1) -f $(3) -f $(KDIR)/vmlinux.lzma \
  70. $(call trxalign/$(2))
  71. endef
  72. define Image/Build/TRXNoloader
  73. $(STAGING_DIR_HOST)/bin/trx -o $(1) -f $(KDIR)/vmlinux.lzma \
  74. $(call trxalign/$(2))
  75. endef
  76. include $(SUBTARGET).mk
  77. define Image/Build
  78. $(call Image/Build/Profile/$(PROFILE),$(1))
  79. endef
  80. define Image/Build/Initramfs
  81. $(call Image/Build/Profile/$(PROFILE),Initramfs)
  82. endef
  83. define Image/BuildKernel
  84. cp $(KDIR)/vmlinux.elf $(VMLINUX).elf
  85. cp $(KDIR)/vmlinux $(VMLINUX).bin
  86. ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
  87. cp $(KDIR)/vmlinux-initramfs.elf $(VMLINUX)-initramfs.elf
  88. cp $(KDIR)/vmlinux $(VMLINUX)-initramfs.bin
  89. endif
  90. endef
  91. $(eval $(call BuildImage))