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