ar71xx: use modules for LED triggers
[openwrt.git] / target / linux / cns21xx / 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
9 JFFS2_BLOCKSIZE:=64k
10
11 include $(INCLUDE_DIR)/image.mk
12
13 INITRAMFS_SUFFIX:=
14
15 ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
16 INITRAMFS_SUFFIX:=-initramfs
17 endif
18
19 define zimage_name
20 $(IMG_PREFIX)-$(1)-zImage$(INITRAMFS_SUFFIX)
21 endef
22
23 define uimage_name
24 $(IMG_PREFIX)-$(1)-uImage$(INITRAMFS_SUFFIX)
25 endef
26
27 define imgname
28 $(BIN_DIR)/$(IMG_PREFIX)-$(2)-$(patsubst jffs2-%,jffs2,$(patsubst squashfs-%,squashfs,$(1)))
29 endef
30
31 define rootfsname
32 $(BIN_DIR)/$(IMG_PREFIX)-$(2)-root.$(patsubst jffs2-%,jffs2,$(patsubst squashfs-%,squashfs,$(1)))
33 endef
34
35 define build_squashfs
36 dd if=$(KDIR)/root.squashfs of=$(KDIR)/root.squashfs-$(1) bs=$(1) conv=sync
37 $(call add_jffs2_mark,$(KDIR)/root.squashfs-$(1))
38 dd if=$(KDIR)/root.squashfs-$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.squashfs-$(1) bs=$(1) conv=sync
39 endef
40
41 define prepare_zimage
42 echo -en "\x$(2)\x1c\xa0\xe3\x$(3)\x10\x81\xe3" > $(KDIR)/$(call zimage_name,$(1))
43 cat $(LINUX_DIR)/arch/arm/boot/zImage >> $(KDIR)/$(call zimage_name,$(1))
44 endef
45
46 define prepare_uimage
47 $(call prepare_zimage,$(1),$(2),$(3))
48 mkimage -A arm -O linux -T kernel -a 0x100000 -e 0x100000 -C none \
49 -n 'OpenWrt Linux-$(LINUX_VERSION)' \
50 -d $(KDIR)/$(call zimage_name,$(1)) \
51 $(KDIR)/$(call uimage_name,$(1))
52 endef
53
54 define Image/Prepare
55 # NSB3AST : mach id 2917 (0xb65)
56 $(call prepare_zimage,nsb3ast,0b,65)
57 # NS-K330 : mach id 3108 (0xc24)
58 $(call prepare_uimage,ns-k330,0c,24)
59 endef
60
61 define Image/BuildKernel
62 cat $(KDIR)/$(call zimage_name,nsb3ast) > $(BIN_DIR)/$(call zimage_name,nsb3ast)
63 cat $(KDIR)/$(call zimage_name,ns-k330) > $(BIN_DIR)/$(call zimage_name,ns-k330)
64 cat $(KDIR)/$(call uimage_name,ns-k330) > $(BIN_DIR)/$(call uimage_name,ns-k330)
65 endef
66
67 define Image/Build/Generic
68 if [ `stat -c%s "$(KDIR)/$(call zimage_name,$(2))"` -gt 1048576 ]; then \
69 echo "Warning: $(KDIR)/$(call zimage_name,$(2)) is too big"; \
70 else if [ `stat -c%s $(KDIR)/root.$(1)` -gt $(3) ]; then \
71 echo "Warning: of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) is too big"; \
72 else \
73 cat $(KDIR)/root.$(1) > $(call rootfsname,$(1),$(2)); \
74 ( \
75 dd if=$(KDIR)/$(call zimage_name,$(2)) bs=1024k conv=sync; \
76 dd if=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) \
77 ) > $(call imgname,$(1),$(2)).img; \
78 fi; fi
79 endef
80
81 define Image/Build/uImage
82 if [ `stat -c%s "$(KDIR)/$(call uimage_name,$(2))"` -gt 1048576 ]; then \
83 echo "Warning: $(KDIR)/$(call uimage_name,$(2)) is too big"; \
84 else if [ `stat -c%s $(KDIR)/root.$(1)` -gt $(3) ]; then \
85 echo "Warning: of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) is too big"; \
86 else \
87 cat $(KDIR)/root.$(1) > $(call rootfsname,$(1),$(2)); \
88 ( \
89 dd if=$(KDIR)/$(call uimage_name,$(2)) bs=1024k conv=sync; \
90 dd if=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) \
91 ) > $(call imgname,$(1),$(2))-uImage.img; \
92 fi; fi
93 endef
94
95 define Image/Build/NSB3AST
96 $(call Image/Build/Generic,$(1),nsb3ast,7077888)
97 endef
98
99 define Image/Build/NSK330
100 $(call Image/Build/Generic,$(1),ns-k330,2686976)
101 $(call Image/Build/uImage,$(1),ns-k330,2686976)
102 endef
103
104 define Image/Build/squashfs
105 $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
106
107 $(call build_squashfs,64k)
108 $(call Image/Build/NSB3AST,squashfs-64k)
109 $(call Image/Build/NSK330,squashfs-64k)
110 endef
111
112 define Image/Build/jffs2-64k
113 dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=64k conv=sync
114 endef
115
116 define Image/Build
117 $(call Image/Build/$(1),$(1))
118 endef
119
120 $(eval $(call BuildImage))
This page took 0.044699 seconds and 5 git commands to generate.