Makefile 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. #
  2. # Copyright (C) 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 get_kernel_entry
  10. 0x$(shell $(TARGET_CROSS)nm $(1) 2>/dev/null | grep " kernel_entry" | cut -f1 -d ' ')
  11. endef
  12. define CompressLzma
  13. $(STAGING_DIR_HOST)/bin/lzma e $(1) -lc1 -lp2 -pb2 $(2)
  14. endef
  15. define CompressGzip
  16. gzip -9 -c $(1) > $(2)
  17. endef
  18. define MkuImage
  19. mkimage -A mips -O linux -T kernel -a 0x80100000 -C $(1) $(2) \
  20. -e $(call get_kernel_entry,$(KDIR)/vmlinux.debug) -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
  21. -d $(3) $(4)
  22. endef
  23. define Image/Prepare
  24. cp $(KDIR)/vmlinux.elf $(BIN_DIR)/$(IMG_PREFIX)-vmlinux.elf
  25. $(call CompressLzma,$(KDIR)/vmlinux,$(KDIR)/vmlinux.bin.lzma)
  26. $(call MkuImage,lzma,,$(KDIR)/vmlinux.bin.lzma,$(KDIR)/uImage.lzma)
  27. $(call CompressGzip,$(KDIR)/vmlinux,$(KDIR)/vmlinux.bin.gz)
  28. $(call MkuImage,gzip,,$(KDIR)/vmlinux.bin.gz,$(KDIR)/uImage.gz)
  29. endef
  30. define Image/BuildKernel
  31. cp $(KDIR)/uImage.lzma $(BIN_DIR)/$(IMG_PREFIX)-uImage-lzma
  32. cp $(KDIR)/uImage.gz $(BIN_DIR)/$(IMG_PREFIX)-uImage-gzip
  33. endef
  34. define Image/Build/squashfs
  35. $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
  36. endef
  37. define Image/Build/Initramfs
  38. cp $(KDIR)/vmlinux-initramfs.elf $(BIN_DIR)/$(IMG_PREFIX)-vmlinux-initramfs.elf
  39. cp $(KDIR)/vmlinux-initramfs $(BIN_DIR)/$(IMG_PREFIX)-vmlinux-initramfs.bin
  40. endef
  41. define Image/Build
  42. $(call Image/Build/$(1))
  43. dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
  44. endef
  45. $(eval $(call BuildImage))