2
0

Makefile 1.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  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,$(LINUX_DIR)/vmlinux) -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
  21. -d $(3) $(4)
  22. endef
  23. define Image/BuildKernel
  24. cp $(KDIR)/vmlinux.elf $(BIN_DIR)/$(IMG_PREFIX)-vmlinux.elf
  25. ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
  26. cp $(KDIR)/vmlinux-initramfs.elf $(BIN_DIR)/$(IMG_PREFIX)-vmlinux-initramfs.elf
  27. endif
  28. $(call CompressLzma,$(KDIR)/vmlinux,$(KDIR)/vmlinux.bin.lzma)
  29. $(call MkuImage,lzma,,$(KDIR)/vmlinux.bin.lzma,$(BIN_DIR)/$(IMG_PREFIX)-uImage-lzma)
  30. $(call CompressGzip,$(KDIR)/vmlinux,$(KDIR)/vmlinux.bin.gz)
  31. $(call MkuImage,gzip,,$(KDIR)/vmlinux.bin.gz,$(BIN_DIR)/$(IMG_PREFIX)-uImage-gzip)
  32. endef
  33. define Image/Build/squashfs
  34. $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
  35. endef
  36. define Image/Build
  37. $(call Image/Build/$(1))
  38. dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
  39. endef
  40. $(eval $(call BuildImage))