Makefile 2.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980
  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. LOADADDR = 0x81000000 # RAM start + 16M
  10. KERNEL_ENTRY = 0x80101000
  11. RAMSIZE = 0x00100000 # 1MB
  12. IMAGE_COPY = 1
  13. LOADER_MAKEOPTS= \
  14. KDIR=$(KDIR) \
  15. LOADADDR=$(LOADADDR) \
  16. KERNEL_ENTRY=$(KERNEL_ENTRY) \
  17. RAMSIZE=$(RAMSIZE) \
  18. IMAGE_COPY=$(IMAGE_COPY)
  19. define Build/Clean
  20. $(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader $(LOADER_MAKEOPTS) clean
  21. endef
  22. define Image/Prepare
  23. cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
  24. $(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader $(LOADER_MAKEOPTS) clean compile
  25. ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
  26. $(STAGING_DIR_HOST)/bin/patch-cmdline $(KDIR)/vmlinux-initramfs '$(strip $(call Image/cmdline/yaffs2)) '
  27. cat $(KDIR)/vmlinux-initramfs | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux-initramfs.lzma
  28. $(MAKE) -C $(GENERIC_PLATFORM_DIR)/image/lzma-loader $(LOADER_MAKEOPTS) clean compile
  29. $(CP) $(KDIR)/loader.elf $(KDIR)/loader-initramfs.elf
  30. endif
  31. endef
  32. VMLINUX:=$(BIN_DIR)/$(IMG_PREFIX)-vmlinux-kernel
  33. define Image/BuildKernel
  34. $(CP) $(KDIR)/loader.elf $(VMLINUX)
  35. ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
  36. $(CP) $(KDIR)/loader-initramfs.elf $(BIN_DIR)/$(IMG_PREFIX)-vmlinux-initramfs
  37. endif
  38. endef
  39. define Image/cmdline/jffs2-64k
  40. block2mtd.block2mtd=/dev/sda2,65536 root=/dev/mtdblock2 rootfstype=jffs2
  41. endef
  42. define Image/cmdline/jffs2-128k
  43. block2mtd.block2mtd=/dev/sda2,131072 root=/dev/mtdblock2 rootfstype=jffs2
  44. endef
  45. define Image/cmdline/ext4
  46. root=/dev/sda2 rootfstype=ext4
  47. endef
  48. define Image/cmdline/squashfs
  49. block2mtd.block2mtd=/dev/sda2,65536,rootfs root=/dev/mtdblock2 rootfstype=squashfs
  50. endef
  51. define Image/cmdline/yaffs2
  52. root=/dev/mtdblock1 rootfstype=yaffs2
  53. endef
  54. define Image/Build/squashfs
  55. $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
  56. endef
  57. define Image/Build
  58. $(call Image/Build/$(1),$(1))
  59. $(CP) $(KDIR)/vmlinux.elf $(BIN_DIR)/$(IMG_PREFIX)-$(1).kernel
  60. $(STAGING_DIR_HOST)/bin/patch-cmdline $(BIN_DIR)/$(IMG_PREFIX)-$(1).kernel '$(strip $(call Image/cmdline/$(1))) '
  61. ./gen_image.sh $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).bin \
  62. 5 $(BIN_DIR)/$(IMG_PREFIX)-$(1).kernel \
  63. $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(KDIR)/root.$(1) \
  64. 128
  65. endef
  66. $(eval $(call BuildImage))