bc412a609e207c50668d6a1d867ade6d407e1300
[openwrt.git] / target / linux / adm8668 / 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 VMLINUX:=$(BIN_DIR)/$(IMG_PREFIX)-vmlinux
11 UIMAGE:=$(IMG_PREFIX)-uImage
12 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
13         VMLINUX:=$(BIN_DIR)/$(IMG_PREFIX)-vmlinux-initramfs
14         UIMAGE:=$(IMG_PREFIX)-uImage-initramfs
15 endif
16
17 define kernel_entry
18 -a 0x80002000 -e 0x80002000
19 endef
20
21
22 define CompressGzip
23         gzip -9 -c $(1) > $(2)
24 endef
25
26 define MkImage
27         mkimage -A mips -O linux -T kernel  $(call kernel_entry) -C $(1) $(2) \
28                 -n "ADM8668 Linux Kernel(2.4.31)" \
29                 -d $(3) $(4)
30 endef
31
32 define Build/Clean
33         $(MAKE) -C lzma-loader clean
34 endef
35
36 define Image/Prepare
37         cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
38         $(MAKE) -C lzma-loader \
39                 KDIR="$(KDIR)" \
40                 clean compile
41         rm -f $(KDIR)/fs_mark
42         touch $(KDIR)/fs_mark
43         $(call prepare_generic_squashfs,$(KDIR)/fs_mark)
44 endef
45
46 define Image/Build
47         ./my-mkimage $(KDIR)/loader.bin $(KDIR)/root.squashfs   \
48                 $(KDIR)/fs_mark $(BIN_DIR)/$(IMG_PREFIX)-$(1).bin
49 endef
50
51 define Image/BuildKernel
52         cp $(KDIR)/vmlinux.elf $(VMLINUX).elf
53         cp $(KDIR)/vmlinux $(VMLINUX).bin
54         $(call CompressGzip,$(KDIR)/vmlinux,$(KDIR)/vmlinux.bin.gz)
55         $(call MkImage,gzip,,$(KDIR)/vmlinux.bin.gz,$(BIN_DIR)/$(UIMAGE)-gzip.bin)
56 endef
57
58 $(eval $(call BuildImage))