363e9e2ecde5d945fbe990b7cf30767730f43c8d
[openwrt/openwrt.git] / target / linux / ramips / image / Makefile
1 #
2 # Copyright (C) 2008 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 IMGNAME:=$(BIN_DIR)/openwrt-$(BOARD)
11
12 define imgname
13 $(IMGNAME)-$(2)-$(patsubst jffs2-%,jffs2,$(1))
14 endef
15
16 VMLINUX:=$(IMGNAME)-vmlinux
17 UIMAGE:=$(IMGNAME)-uImage
18 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
19 VMLINUX:=$(IMGNAME)-vmlinux-initramfs
20 UIMAGE:=$(IMGNAME)-uImage-initramfs
21 endif
22
23 ifeq ($(CONFIG_RALINK_RT305X),y)
24 define kernel_entry
25 -a 0x80000000 -e 0x80000000
26 endef
27 else
28 define kernel_entry
29 -a 0x88000000 -e 0x88000000
30 endef
31 endif
32
33 define Image/BuildKernel
34 cp $(KDIR)/vmlinux.elf $(VMLINUX).elf
35 cp $(KDIR)/vmlinux $(VMLINUX).bin
36 $(STAGING_DIR_HOST)/bin/lzma e $(KDIR)/vmlinux -lc1 -lp2 -pb2 $(KDIR)/vmlinux.lzma
37 mkimage -A mips -O linux -T kernel -C lzma $(call kernel_entry) \
38 -n 'MIPS OpenWrt Linux-$(LINUX_VERSION)' \
39 -d $(KDIR)/vmlinux.lzma $(KDIR)/uImage.lzma
40 cp $(KDIR)/uImage.lzma $(UIMAGE).bin
41 endef
42
43 define Image/Build/squashfs
44 $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
45 endef
46
47 define Image/Build
48 $(call Image/Build/$(1))
49 ( \
50 dd if=$(KDIR)/uImage.lzma bs=1024k conv=sync; \
51 dd if=$(KDIR)/root.$(1) bs=65536 conv=sync; \
52 ) > $(BIN_DIR)/openwrt-$(BOARD)-$(1).img
53 endef
54
55 $(eval $(call BuildImage))