[package] ncurses: enable C++ bindings (#9442)
[openwrt.git] / include / image.mk
1 #
2 # Copyright (C) 2006-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
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 IMG_PREFIX:=openwrt-$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))
19
20 ifneq ($(CONFIG_BIG_ENDIAN),)
21 JFFS2OPTS := --pad --big-endian --squash -v
22 else
23 JFFS2OPTS := --pad --little-endian --squash -v
24 endif
25
26 ifeq ($(CONFIG_JFFS2_RTIME),y)
27 JFFS2OPTS += -X rtime
28 endif
29 ifeq ($(CONFIG_JFFS2_ZLIB),y)
30 JFFS2OPTS += -X zlib
31 endif
32 ifeq ($(CONFIG_JFFS2_LZMA),y)
33 JFFS2OPTS += -X lzma --compression-mode=size
34 endif
35 ifneq ($(CONFIG_JFFS2_RTIME),y)
36 JFFS2OPTS += -x rtime
37 endif
38 ifneq ($(CONFIG_JFFS2_ZLIB),y)
39 JFFS2OPTS += -x zlib
40 endif
41 ifneq ($(CONFIG_JFFS2_LZMA),y)
42 JFFS2OPTS += -x lzma
43 endif
44
45 LZMA_XZ_OPTIONS := -Xpreset 9 -Xe -Xlc 0 -Xlp 2 -Xpb 2
46 ifeq ($(CONFIG_SQUASHFS_LZMA),y)
47 SQUASHFSCOMP := lzma $(LZMA_XZ_OPTIONS)
48 endif
49 ifeq ($(CONFIG_SQUASHFS_XZ),y)
50 SQUASHFSCOMP := xz $(LZMA_XZ_OPTIONS)
51 endif
52
53 JFFS2_BLOCKSIZE ?= 64k 128k
54
55 define add_jffs2_mark
56 echo -ne '\xde\xad\xc0\xde' >> $(1)
57 endef
58
59 # pad to 4k, 8k, 64k, 128k and add jffs2 end-of-filesystem mark
60 define prepare_generic_squashfs
61 dd if=$(1) of=$(KDIR)/tmpfile.0 bs=4k conv=sync
62 $(call add_jffs2_mark,$(KDIR)/tmpfile.0)
63 dd if=$(KDIR)/tmpfile.0 of=$(KDIR)/tmpfile.1 bs=4k conv=sync
64 $(call add_jffs2_mark,$(KDIR)/tmpfile.1)
65 dd if=$(KDIR)/tmpfile.1 of=$(KDIR)/tmpfile.2 bs=64k conv=sync
66 $(call add_jffs2_mark,$(KDIR)/tmpfile.2)
67 dd if=$(KDIR)/tmpfile.2 of=$(1) bs=64k conv=sync
68 $(call add_jffs2_mark,$(1))
69 rm -f $(KDIR)/tmpfile.*
70 endef
71
72
73 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
74
75 define Image/BuildKernel
76 cp $(KDIR)/vmlinux.elf $(BIN_DIR)/$(IMG_PREFIX)-vmlinux.elf
77 $(call Image/Build/Initramfs)
78 endef
79
80 else
81
82 ifneq ($(CONFIG_TARGET_ROOTFS_JFFS2),)
83 define Image/mkfs/jffs2/sub
84 # FIXME: removing this line will cause strange behaviour in the foreach loop below
85 $(STAGING_DIR_HOST)/bin/mkfs.jffs2 $(JFFS2OPTS) -e $(patsubst %k,%KiB,$(1)) -o $(KDIR)/root.jffs2-$(1) -d $(TARGET_DIR) -v 2>&1 1>/dev/null | awk '/^.+$$$$/'
86 $(call add_jffs2_mark,$(KDIR)/root.jffs2-$(1))
87 $(call Image/Build,jffs2-$(1))
88 endef
89 define Image/mkfs/jffs2
90 $(foreach SZ,$(JFFS2_BLOCKSIZE),$(call Image/mkfs/jffs2/sub,$(SZ)))
91 endef
92 endif
93
94 ifneq ($(CONFIG_TARGET_ROOTFS_SQUASHFS),)
95 define Image/mkfs/squashfs
96 @mkdir -p $(TARGET_DIR)/overlay
97 $(STAGING_DIR_HOST)/bin/mksquashfs4 $(TARGET_DIR) $(KDIR)/root.squashfs -nopad -noappend -root-owned -comp $(SQUASHFSCOMP) -processors 1
98 $(call Image/Build,squashfs)
99 endef
100 endif
101
102 ifneq ($(CONFIG_TARGET_ROOTFS_UBIFS),)
103 define Image/mkfs/ubifs
104 $(CP) ./ubinize.cfg $(KDIR)
105 $(STAGING_DIR_HOST)/bin/mkfs.ubifs $(UBIFS_OPTS) -o $(KDIR)/root.ubifs -d $(TARGET_DIR)
106 (cd $(KDIR); \
107 $(STAGING_DIR_HOST)/bin/ubinize $(UBINIZE_OPTS) -o $(KDIR)/root.ubi ubinize.cfg)
108 $(call Image/Build,ubi)
109 endef
110 endif
111
112 endif
113
114 ifneq ($(CONFIG_TARGET_ROOTFS_CPIOGZ),)
115 define Image/mkfs/cpiogz
116 ( cd $(TARGET_DIR); find . | cpio -o -H newc | gzip -9 >$(BIN_DIR)/$(IMG_PREFIX)-rootfs.cpio.gz )
117 endef
118 endif
119
120 ifneq ($(CONFIG_TARGET_ROOTFS_TARGZ),)
121 define Image/mkfs/targz
122 # Preserve permissions (-p) when building as non-root user
123 $(TAR) -czpf $(BIN_DIR)/$(IMG_PREFIX)-rootfs.tar.gz --numeric-owner --owner=0 --group=0 -C $(TARGET_DIR)/ .
124 endef
125 endif
126
127 ifneq ($(CONFIG_TARGET_ROOTFS_EXT4FS),)
128 E2SIZE=$(shell echo $$(($(CONFIG_TARGET_ROOTFS_PARTSIZE)*1024)))
129
130 define Image/mkfs/ext4
131 # generate an ext2 fs
132 $(STAGING_DIR_HOST)/bin/genext2fs -U -b $(E2SIZE) -N $(CONFIG_TARGET_ROOTFS_MAXINODE) -d $(TARGET_DIR)/ $(KDIR)/root.ext4
133 # convert it to ext4
134 $(STAGING_DIR_HOST)/bin/tune2fs -O extents,uninit_bg,dir_index $(KDIR)/root.ext4
135 # fix it up
136 $(STAGING_DIR_HOST)/bin/e2fsck -fy $(KDIR)/root.ext4
137 $(call Image/Build,ext4)
138 endef
139 endif
140
141 ifneq ($(CONFIG_TARGET_ROOTFS_ISO),)
142 define Image/mkfs/iso
143 $(call Image/Build,iso)
144 endef
145 endif
146
147
148 define Image/mkfs/prepare/default
149 # Use symbolic permissions to avoid clobbering SUID/SGID/sticky bits
150 - $(FIND) $(TARGET_DIR) -type f -not -perm +0100 -not -name 'ssh_host*' -print0 | $(XARGS) -0 chmod u+rw,g+r,o+r
151 - $(FIND) $(TARGET_DIR) -type f -perm +0100 -print0 | $(XARGS) -0 chmod u+rwx,g+rx,o+rx
152 - $(FIND) $(TARGET_DIR) -type d -print0 | $(XARGS) -0 chmod u+rwx,g+rx,o+rx
153 $(INSTALL_DIR) $(TARGET_DIR)/tmp
154 chmod 0777 $(TARGET_DIR)/tmp
155 endef
156
157 define Image/mkfs/prepare
158 $(call Image/mkfs/prepare/default)
159 endef
160
161
162 define Image/Checksum
163 ( cd ${BIN_DIR} ; \
164 $(FIND) -maxdepth 1 -type f \! -name 'md5sums' -printf "%P\n" | sort | xargs \
165 md5sum --binary > md5sums \
166 )
167 endef
168
169
170 define BuildImage
171
172 download:
173 prepare:
174
175 ifeq ($(IB),)
176 compile: compile-targets FORCE
177 $(call Build/Compile)
178 else
179 compile:
180 endif
181
182 ifeq ($(IB),)
183 install: compile install-targets FORCE
184 $(call Image/Prepare)
185 $(call Image/mkfs/prepare)
186 $(call Image/BuildKernel)
187 $(call Image/mkfs/cpiogz)
188 $(call Image/mkfs/targz)
189 $(call Image/mkfs/ext4)
190 $(call Image/mkfs/iso)
191 $(call Image/mkfs/jffs2)
192 $(call Image/mkfs/squashfs)
193 $(call Image/mkfs/ubifs)
194 $(call Image/Checksum)
195 else
196 install: compile install-targets
197 $(call Image/BuildKernel)
198 $(call Image/mkfs/cpiogz)
199 $(call Image/mkfs/targz)
200 $(call Image/mkfs/ext4)
201 $(call Image/mkfs/iso)
202 $(call Image/mkfs/jffs2)
203 $(call Image/mkfs/squashfs)
204 $(call Image/mkfs/ubifs)
205 $(call Image/Checksum)
206 endif
207
208 ifeq ($(IB),)
209 clean: clean-targets
210 $(call Build/Clean)
211 else
212 clean:
213 endif
214
215 compile-targets:
216 install-targets:
217 clean-targets:
218
219 endef
This page took 0.048282 seconds and 5 git commands to generate.