ar71xx: add a profile for PB92
[openwrt.git] / include / image.mk
1 #
2 # Copyright (C) 2006 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7
8 override TARGET_BUILD=
9 include $(INCLUDE_DIR)/prereq.mk
10 include $(INCLUDE_DIR)/kernel.mk
11 include $(INCLUDE_DIR)/host.mk
12
13 .NOTPARALLEL:
14 override MAKEFLAGS=
15 override MAKE:=$(SUBMAKE)
16 KDIR=$(KERNEL_BUILD_DIR)
17
18 ifneq ($(CONFIG_BIG_ENDIAN),y)
19 JFFS2OPTS := --pad --little-endian --squash
20 SQUASHFS_OPTS := -le
21 else
22 JFFS2OPTS := --pad --big-endian --squash
23 SQUASHFS_OPTS := -be
24 endif
25
26 ifneq ($(CONFIG_LINUX_2_4)$(CONFIG_LINUX_2_6_25),)
27 USE_SQUASHFS3 := y
28 endif
29
30 ifneq ($(USE_SQUASHFS3),)
31 MKSQUASHFS_CMD := $(STAGING_DIR_HOST)/bin/mksquashfs-lzma
32 else
33 MKSQUASHFS_CMD := $(STAGING_DIR_HOST)/bin/mksquashfs4
34 SQUASHFS_OPTS := -comp lzma -processors 1
35 endif
36
37 JFFS2_BLOCKSIZE ?= 64k 128k
38
39 define add_jffs2_mark
40 echo -ne '\xde\xad\xc0\xde' >> $(1)
41 endef
42
43 # pad to 4k, 8k, 64k, 128k and add jffs2 end-of-filesystem mark
44 define prepare_generic_squashfs
45 dd if=$(1) of=$(KDIR)/tmpfile.0 bs=4k conv=sync
46 $(call add_jffs2_mark,$(KDIR)/tmpfile.0)
47 dd if=$(KDIR)/tmpfile.0 of=$(KDIR)/tmpfile.1 bs=4k conv=sync
48 $(call add_jffs2_mark,$(KDIR)/tmpfile.1)
49 dd if=$(KDIR)/tmpfile.1 of=$(KDIR)/tmpfile.2 bs=64k conv=sync
50 $(call add_jffs2_mark,$(KDIR)/tmpfile.2)
51 dd if=$(KDIR)/tmpfile.2 of=$(1) bs=64k conv=sync
52 $(call add_jffs2_mark,$(1))
53 rm -f $(KDIR)/tmpfile.*
54 endef
55
56 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
57 ifeq ($(CONFIG_TARGET_ROOTFS_JFFS2),y)
58 define Image/mkfs/jffs2/sub
59 # FIXME: removing this line will cause strange behaviour in the foreach loop below
60 $(STAGING_DIR_HOST)/bin/mkfs.jffs2 $(JFFS2OPTS) -e $(patsubst %k,%KiB,$(1)) -o $(KDIR)/root.jffs2-$(1) -d $(TARGET_DIR)
61 $(call add_jffs2_mark,$(KDIR)/root.jffs2-$(1))
62 $(call Image/Build,jffs2-$(1))
63 endef
64 define Image/mkfs/jffs2
65 $(foreach SZ,$(JFFS2_BLOCKSIZE),$(call Image/mkfs/jffs2/sub,$(SZ)))
66 endef
67 endif
68
69 ifeq ($(CONFIG_TARGET_ROOTFS_SQUASHFS),y)
70 define Image/mkfs/squashfs
71 @mkdir -p $(TARGET_DIR)/overlay
72 $(MKSQUASHFS_CMD) $(TARGET_DIR) $(KDIR)/root.squashfs -nopad -noappend -root-owned $(SQUASHFS_OPTS)
73 $(call Image/Build,squashfs)
74 endef
75 endif
76
77 ifeq ($(CONFIG_TARGET_ROOTFS_TGZ),y)
78 define Image/mkfs/tgz
79 $(TAR) -zcf $(BIN_DIR)/openwrt-$(BOARD)-rootfs.tgz --numeric-owner --owner=0 --group=0 -C $(TARGET_DIR)/ .
80 endef
81 endif
82
83 ifeq ($(CONFIG_TARGET_ROOTFS_CPIOGZ),y)
84 define Image/mkfs/cpiogz
85 ( cd $(TARGET_DIR); find . | cpio -o -H newc | gzip -9 >$(BIN_DIR)/openwrt-$(BOARD)-rootfs.cpio.gz )
86 endef
87 endif
88 ifeq ($(CONFIG_TARGET_ROOTFS_UBIFS),y)
89 define Image/mkfs/ubifs
90 $(CP) ./ubinize.cfg $(KDIR)
91 $(STAGING_DIR_HOST)/bin/mkfs.ubifs $(UBIFS_OPTS) -o $(KDIR)/root.ubifs -d $(TARGET_DIR)
92 (cd $(KDIR); \
93 $(STAGING_DIR_HOST)/bin/ubinize $(UBINIZE_OPTS) -o $(KDIR)/root.ubi ubinize.cfg)
94 $(call Image/Build,ubi)
95 endef
96 endif
97 else
98 define Image/BuildKernel
99 cp $(KDIR)/vmlinux.elf $(BIN_DIR)/openwrt-$(BOARD)-vmlinux.elf
100 $(call Image/Build/Initramfs)
101 endef
102 endif
103
104 define Image/Checksum
105 ( cd ${BIN_DIR} ; \
106 $(FIND) -maxdepth 1 -type f \! -name 'md5sums' -printf "%P\n" | sort | xargs \
107 md5sum --binary > md5sums \
108 )
109 endef
110
111
112 ifeq ($(CONFIG_TARGET_ROOTFS_EXT2FS),y)
113 E2SIZE=$(shell echo $$(($(CONFIG_TARGET_ROOTFS_FSPART)*1024)))
114
115 define Image/mkfs/ext2
116 $(STAGING_DIR_HOST)/bin/genext2fs -U -b $(E2SIZE) -N $(CONFIG_TARGET_ROOTFS_MAXINODE) -d $(TARGET_DIR)/ $(KDIR)/root.ext2
117 $(call Image/Build,ext2)
118 endef
119 endif
120
121 ifeq ($(CONFIG_TARGET_ROOTFS_ISO),y)
122 define Image/mkfs/iso
123 $(call Image/Build,iso)
124 endef
125 endif
126
127
128 define Image/mkfs/prepare/default
129 - $(FIND) $(TARGET_DIR) -type f -not -perm +0100 -not -name 'ssh_host*' -print0 | $(XARGS) -0 chmod 0644
130 - $(FIND) $(TARGET_DIR) -type f -perm +0100 -print0 | $(XARGS) -0 chmod 0755
131 - $(FIND) $(TARGET_DIR) -type d -print0 | $(XARGS) -0 chmod 0755
132 $(INSTALL_DIR) $(TARGET_DIR)/tmp
133 chmod 0777 $(TARGET_DIR)/tmp
134 endef
135
136 define Image/mkfs/prepare
137 $(call Image/mkfs/prepare/default)
138 endef
139
140 define BuildImage
141 download:
142 prepare:
143 ifneq ($(IB),1)
144 compile: compile-targets FORCE
145 $(call Build/Compile)
146 else
147 compile:
148 endif
149
150 ifneq ($(IB),1)
151 install: compile install-targets FORCE
152 $(call Image/Prepare)
153 $(call Image/mkfs/prepare)
154 $(call Image/BuildKernel)
155 $(call Image/mkfs/jffs2)
156 $(call Image/mkfs/squashfs)
157 $(call Image/mkfs/tgz)
158 $(call Image/mkfs/cpiogz)
159 $(call Image/mkfs/ext2)
160 $(call Image/mkfs/iso)
161 $(call Image/mkfs/ubifs)
162 $(call Image/Checksum)
163 else
164 install: compile install-targets
165 $(call Image/BuildKernel)
166 $(call Image/mkfs/jffs2)
167 $(call Image/mkfs/squashfs)
168 $(call Image/mkfs/tgz)
169 $(call Image/mkfs/cpiogz)
170 $(call Image/mkfs/ext2)
171 $(call Image/mkfs/iso)
172 $(call Image/mkfs/ubifs)
173 $(call Image/Checksum)
174 endif
175
176 ifneq ($(IB),1)
177 clean: clean-targets
178 $(call Build/Clean)
179 else
180 clean:
181 endif
182
183 compile-targets:
184 install-targets:
185 clean-targets:
186 endef
187
188
This page took 0.057243 seconds and 5 git commands to generate.