[tools] firmware-utils: add a file {en,de}cryption tool, based on the PC1 encryption...
[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_6_29)$(CONFIG_LINUX_2_6_30),)
27 USE_SQUASHFS4 := y
28 endif
29
30 ifneq ($(USE_SQUASHFS4),)
31 MKSQUASHFS_CMD := $(STAGING_DIR_HOST)/bin/mksquashfs4
32 SQUASHFS_OPTS := -lzma
33 else
34 MKSQUASHFS_CMD := $(STAGING_DIR_HOST)/bin/mksquashfs-lzma
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 64k and add jffs2 end-of-filesystem mark
44 # do this twice to make sure that this works with 128k blocksize as well
45 define prepare_generic_squashfs
46 dd if=$(1) of=$(KDIR)/tmpfile.1 bs=64k conv=sync
47 $(call add_jffs2_mark,$(KDIR)/tmpfile.1)
48 dd of=$(1) if=$(KDIR)/tmpfile.1 bs=64k conv=sync
49 $(call add_jffs2_mark,$(1))
50 endef
51
52 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
53 ifeq ($(CONFIG_TARGET_ROOTFS_JFFS2),y)
54 define Image/mkfs/jffs2/sub
55 # FIXME: removing this line will cause strange behaviour in the foreach loop below
56 $(STAGING_DIR_HOST)/bin/mkfs.jffs2 $(JFFS2OPTS) -e $(patsubst %k,%KiB,$(1)) -o $(KDIR)/root.jffs2-$(1) -d $(TARGET_DIR)
57 $(call add_jffs2_mark,$(KDIR)/root.jffs2-$(1))
58 $(call Image/Build,jffs2-$(1))
59 endef
60 define Image/mkfs/jffs2
61 rm -rf $(TARGET_DIR)/jffs
62 $(foreach SZ,$(JFFS2_BLOCKSIZE),$(call Image/mkfs/jffs2/sub,$(SZ)))
63 endef
64 endif
65
66 ifeq ($(CONFIG_TARGET_ROOTFS_SQUASHFS),y)
67 define Image/mkfs/squashfs
68 @mkdir -p $(TARGET_DIR)/jffs
69 $(MKSQUASHFS_CMD) $(TARGET_DIR) $(KDIR)/root.squashfs -nopad -noappend -root-owned $(SQUASHFS_OPTS)
70 $(call Image/Build,squashfs)
71 endef
72 endif
73
74 ifeq ($(CONFIG_TARGET_ROOTFS_TGZ),y)
75 define Image/mkfs/tgz
76 $(TAR) -zcf $(BIN_DIR)/openwrt-$(BOARD)-rootfs.tgz --numeric-owner --owner=0 --group=0 -C $(TARGET_DIR)/ .
77 endef
78 endif
79
80 ifeq ($(CONFIG_TARGET_ROOTFS_CPIOGZ),y)
81 define Image/mkfs/cpiogz
82 ( cd $(TARGET_DIR); find . | cpio -o -H newc | gzip -9 >$(BIN_DIR)/openwrt-$(BOARD)-rootfs.cpio.gz )
83 endef
84 endif
85 else
86 define Image/BuildKernel
87 cp $(KDIR)/vmlinux.elf $(BIN_DIR)/openwrt-$(BOARD)-vmlinux.elf
88 $(call Image/Build/Initramfs)
89 endef
90 endif
91
92 define Image/Checksum
93 ( cd ${BIN_DIR} ; \
94 $(FIND) -maxdepth 1 -type f \! -name 'md5sums' -printf "%P\n" | xargs \
95 md5sum > md5sums \
96 )
97 endef
98
99
100 ifeq ($(CONFIG_TARGET_ROOTFS_EXT2FS),y)
101 E2SIZE=$(shell echo $$(($(CONFIG_TARGET_ROOTFS_FSPART)*1024)))
102
103 define Image/mkfs/ext2
104 $(STAGING_DIR_HOST)/bin/genext2fs -U -b $(E2SIZE) -N $(CONFIG_TARGET_ROOTFS_MAXINODE) -d $(TARGET_DIR)/ $(KDIR)/root.ext2
105 $(call Image/Build,ext2)
106 endef
107 endif
108
109 ifeq ($(CONFIG_TARGET_ROOTFS_ISO),y)
110 define Image/mkfs/iso
111 $(call Image/Build,iso)
112 endef
113 endif
114
115
116 define Image/mkfs/prepare/default
117 - find $(TARGET_DIR) -type f -not -perm +0100 -not -name 'ssh_host*' | $(XARGS) chmod 0644
118 - find $(TARGET_DIR) -type f -perm +0100 | $(XARGS) chmod 0755
119 - find $(TARGET_DIR) -type d | $(XARGS) chmod 0755
120 $(INSTALL_DIR) $(TARGET_DIR)/tmp
121 chmod 0777 $(TARGET_DIR)/tmp
122 endef
123
124 define Image/mkfs/prepare
125 $(call Image/mkfs/prepare/default)
126 endef
127
128 define BuildImage
129 download:
130 prepare:
131 ifneq ($(IB),1)
132 compile: compile-targets FORCE
133 $(call Build/Compile)
134 else
135 compile:
136 endif
137
138 ifneq ($(IB),1)
139 install: compile install-targets FORCE
140 $(call Image/Prepare)
141 $(call Image/mkfs/prepare)
142 $(call Image/BuildKernel)
143 $(call Image/mkfs/jffs2)
144 $(call Image/mkfs/squashfs)
145 $(call Image/mkfs/tgz)
146 $(call Image/mkfs/cpiogz)
147 $(call Image/mkfs/ext2)
148 $(call Image/mkfs/iso)
149 $(call Image/Checksum)
150 else
151 install: compile install-targets
152 $(call Image/BuildKernel)
153 $(call Image/mkfs/jffs2)
154 $(call Image/mkfs/squashfs)
155 $(call Image/mkfs/tgz)
156 $(call Image/mkfs/cpiogz)
157 $(call Image/mkfs/ext2)
158 $(call Image/mkfs/iso)
159 $(call Image/Checksum)
160 endif
161
162 ifneq ($(IB),1)
163 clean: clean-targets
164 $(call Build/Clean)
165 else
166 clean:
167 endif
168
169 compile-targets:
170 install-targets:
171 clean-targets:
172 endef
173
174
This page took 0.058819 seconds and 5 git commands to generate.