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