Makefile 1.4 KB

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