f42c0451e8ffaa42b5811956086f11d778e714a1
[openwrt.git] / target / linux / adm5120 / image / Makefile
1 #
2 # Copyright (C) 2006,2007 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 LOADER_MAKE := $(NO_TRACE_MAKE) -C lzma-loader KDIR=$(KDIR)
11 IMGNAME := $(BIN_DIR)/openwrt-$(BOARD)
12 JFFS2BLOCK := $(KDIR)/jffs2.block
13 JFFS2MARK := $(KDIR)/jffs2.mark
14
15 define imgname
16 $(IMGNAME)-$(2)-$(patsubst jffs2-%,jffs2,$(1))
17 endef
18
19 define Build/Clean
20         $(LOADER_MAKE) clean
21 endef
22
23 define Image/Prepare
24         cat $(KDIR)/vmlinux | $(STAGING_DIR_HOST)/bin/lzma e -si -so -eos -lc1 -lp2 -pb2 > $(KDIR)/vmlinux.lzma
25         rm -f $(JFFS2BLOCK)
26         touch $(JFFS2BLOCK)
27         $(call prepare_generic_squashfs,$(JFFS2BLOCK))
28         rm -f $(JFFS2MARK)
29         touch $(JFFS2MARK)
30         $(call add_jffs2_mark,$(JFFS2MARK))
31 endef
32
33 define Image/Build/Loader
34         $(LOADER_MAKE) LOADER=loader-$(1).$(2) LOADER_DATA="" \
35                 LZMA_TEXT_START=$(3) LZMA_STARTUP_ORG=$(4) \
36                 CONFIG_PASS_KARGS=$(5) CONFIG_BOARD=$(6) \
37                 compile loader.$(2)
38 endef
39
40 define Image/Build/LZMAKernel
41         $(LOADER_MAKE) TARGET_DIR=$(BIN_DIR) \
42                 LOADER=openwrt-$(BOARD)-$(1)-ramfs.$(2) \
43                 LOADER_DATA=$(KDIR)/vmlinux.lzma \
44                 LZMA_TEXT_START=$(3) LZMA_STARTUP_ORG=$(4) \
45                 CONFIG_PASS_KARGS=$(5) CONFIG_BOARD=$(6) \
46                 compile loader.$(2)
47 endef
48
49 define Image/Build/LZMAKernel/Generic
50         $(call Image/Build/LZMAKernel,$(1),$(2),0x80500000,0)
51 endef
52
53 define Image/Build/LZMAKernel/Admboot
54         $(call Image/Build/LZMAKernel,$(1),$(2),0x80500000,0x6D8,y,$(1))
55 endef
56
57 define Image/Build/LZMAKernel/Cellvision
58         $(call Image/Build/LZMAKernel,$(1),$(3),0x80500000,0x6D8,y,$(2))
59 endef
60
61 define Image/Build/LZMAKernel/KArgs
62         $(call Image/Build/LZMAKernel,$(1),$(2),0x80500000,0,y,$(1))
63 endef
64
65 define trxalign/jffs2-128k
66 -a 0x20000 -f $(KDIR)/root.jffs2-128k
67 endef
68
69 define trxalign/jffs2-64k
70 -a 0x10000 -f $(KDIR)/root.jffs2-64k
71 endef
72
73 define trxalign/squashfs
74 -a 1024 -f $(KDIR)/root.squashfs -a 0x10000 -A $(JFFS2BLOCK)
75 endef
76
77 define Image/Build/TRX
78         $(STAGING_DIR_HOST)/bin/trx -o $(1) -f $(3) -f $(KDIR)/vmlinux.lzma \
79                 $(call trxalign/$(2))
80 endef
81
82 define Image/Build/TRXNoloader
83         $(STAGING_DIR_HOST)/bin/trx -o $(1) -f $(KDIR)/vmlinux.lzma \
84                 $(call trxalign/$(2))
85 endef
86
87 include $(SUBTARGET).mk
88
89 define Image/Build
90         $(call Image/Build/Profile/$(PROFILE),$(1))
91 endef
92
93 define Image/Build/Initramfs
94         $(call Image/Build/Profile/$(PROFILE),Initramfs)
95 endef
96
97 $(eval $(call BuildImage))