Makefile 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. #
  2. # Copyright (C) 2009-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. define Image/Prepare
  10. # Workaround pre-SDK-1.9.0 u-boot versions not handling the .notes section
  11. $(TARGET_CROSS)strip -R .notes $(KDIR)/vmlinux.elf -o $(KDIR)/vmlinux.elf.stripped
  12. endef
  13. define Image/BuildKernel/Template
  14. $(CP) $(KDIR)/vmlinux.elf.stripped $(BIN_DIR)/$(IMG_PREFIX)-$(1)-vmlinux.64
  15. $(STAGING_DIR_HOST)/bin/patch-cmdline $(BIN_DIR)/$(IMG_PREFIX)-$(1)-vmlinux.64 '$(strip $(2))'
  16. md5sum $(BIN_DIR)/$(IMG_PREFIX)-$(1)-vmlinux.64 | cut -d " " -f 1 | tee $(BIN_DIR)/$(IMG_PREFIX)-$(1)-vmlinux.64.md5
  17. endef
  18. define Image/BuildKernel/Initramfs/Template
  19. $(TARGET_CROSS)strip -R .notes $(KDIR)/vmlinux-initramfs.elf -o $(BIN_DIR)/$(IMG_PREFIX)-$(1)-vmlinux-initramfs.elf
  20. $(STAGING_DIR_HOST)/bin/patch-cmdline $(BIN_DIR)/$(IMG_PREFIX)-$(1)-vmlinux-initramfs.elf '$(strip $(2))'
  21. endef
  22. ER_CMDLINE:=-mtdparts=phys_mapped_flash:640k(boot0)ro,640k(boot1)ro,64k(eeprom)ro block2mtd.block2mtd=/dev/mmcblk0p2,65536,rootfs,5 root=/dev/mtdblock3 rootfstype=squashfs rootwait
  23. ERLITE_CMDLINE:=-mtdparts=phys_mapped_flash:512k(boot0),512k(boot1),64k@1024k(eeprom) block2mtd.block2mtd=/dev/sda2,65536,rootfs,5 root=/dev/mtdblock3 rootfstype=squashfs rootwait
  24. define Image/BuildKernel
  25. $(call Image/BuildKernel/Template,generic,)
  26. $(call Image/BuildKernel/Template,er,$(ER_CMDLINE))
  27. $(call Image/BuildKernel/Template,erlite,$(ERLITE_CMDLINE))
  28. endef
  29. define Image/BuildKernel/Initramfs
  30. $(call Image/BuildKernel/Initramfs/Template,generic,)
  31. $(call Image/BuildKernel/Initramfs/Template,er,$(ER_CMDLINE))
  32. $(call Image/BuildKernel/Initramfs/Template,erlite,$(ERLITE_CMDLINE))
  33. endef
  34. define Image/Build/sysupgrade
  35. mkdir -p $(KDIR)/sysupgrade-$(1)/
  36. echo "BOARD=$(1)" > $(KDIR)/sysupgrade-$(1)/CONTROL
  37. $(CP) $(BIN_DIR)/$(IMG_PREFIX)-$(2)-vmlinux.64 $(KDIR)/sysupgrade-$(1)/kernel
  38. $(CP) $(KDIR)/root.$(3) $(KDIR)/sysupgrade-$(1)/root
  39. (cd $(KDIR); $(TAR) cvf \
  40. $(BIN_DIR)/$(IMG_PREFIX)-$(1)-$(3)-sysupgrade.tar sysupgrade-$(1))
  41. endef
  42. define Image/Build/ext4
  43. $(call Image/Build/sysupgrade,erlite,generic,ext4)
  44. endef
  45. define Image/Build/squashfs
  46. $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
  47. $(call Image/Build/sysupgrade,er,er,squashfs)
  48. $(call Image/Build/sysupgrade,erlite,erlite,squashfs)
  49. endef
  50. define Image/Build
  51. $(call Image/Build/$(1))
  52. dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
  53. endef
  54. $(eval $(call BuildImage))