add high-speed usb serial fix from Junxion (closes: #2274)
[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 include $(INCLUDE_DIR)/prereq.mk
9 include $(INCLUDE_DIR)/kernel.mk
10 include $(INCLUDE_DIR)/host.mk
11
12 override MAKEFLAGS=
13 override MAKE:=$(SUBMAKE)
14 KDIR=$(KERNEL_BUILD_DIR)
15
16 ifneq ($(CONFIG_BIG_ENDIAN),y)
17 JFFS2OPTS := --pad --little-endian --squash
18 SQUASHFS_OPTS := -le
19 else
20 JFFS2OPTS := --pad --big-endian --squash
21 SQUASHFS_OPTS := -be
22 endif
23
24 JFFS2_BLOCKSIZE ?= 64k 128k
25
26 define add_jffs2_mark
27 echo -ne '\xde\xad\xc0\xde' >> $(1)
28 endef
29
30 # pad to 64k and add jffs2 end-of-filesystem mark
31 # do this twice to make sure that this works with 128k blocksize as well
32 define prepare_generic_squashfs
33 dd if=$(1) of=$(KDIR)/tmpfile.1 bs=64k conv=sync
34 $(call add_jffs2_mark,$(KDIR)/tmpfile.1)
35 dd of=$(1) if=$(KDIR)/tmpfile.1 bs=64k conv=sync
36 $(call add_jffs2_mark,$(1))
37 endef
38
39 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
40 ifeq ($(CONFIG_TARGET_ROOTFS_JFFS2),y)
41 define Image/mkfs/jffs2/sub
42 # FIXME: removing this line will cause strange behaviour in the foreach loop below
43 $(STAGING_DIR_HOST)/bin/mkfs.jffs2 $(JFFS2OPTS) -e $(patsubst %k,%KiB,$(1)) -o $(KDIR)/root.jffs2-$(1) -d $(TARGET_DIR)
44 $(call add_jffs2_mark,$(KDIR)/root.jffs2-$(1))
45 $(call Image/Build,jffs2-$(1))
46 endef
47 define Image/mkfs/jffs2
48 rm -rf $(TARGET_DIR)/jffs
49 $(foreach SZ,$(JFFS2_BLOCKSIZE),$(call Image/mkfs/jffs2/sub,$(SZ)))
50 endef
51 endif
52
53 ifeq ($(CONFIG_TARGET_ROOTFS_SQUASHFS),y)
54 define Image/mkfs/squashfs
55 @mkdir -p $(TARGET_DIR)/jffs
56 $(STAGING_DIR_HOST)/bin/mksquashfs-lzma $(TARGET_DIR) $(KDIR)/root.squashfs -nopad -noappend -root-owned $(SQUASHFS_OPTS)
57 $(call Image/Build,squashfs)
58 endef
59 endif
60
61 ifeq ($(CONFIG_TARGET_ROOTFS_TGZ),y)
62 define Image/mkfs/tgz
63 $(TAR) -zcf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-rootfs.tgz --owner=root --group=root -C $(TARGET_DIR)/ .
64 endef
65 endif
66 else
67 define Image/BuildKernel
68 cp $(KDIR)/vmlinux.elf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux.elf
69 $(call Image/Build/Initramfs)
70 endef
71 endif
72
73
74 ifeq ($(CONFIG_TARGET_ROOTFS_EXT2FS),y)
75 E2SIZE=$(shell echo $$(($(CONFIG_TARGET_ROOTFS_FSPART)*1024)))
76
77 define Image/mkfs/ext2
78 $(STAGING_DIR_HOST)/bin/genext2fs -U -b $(E2SIZE) -I $(CONFIG_TARGET_ROOTFS_MAXINODE) -d $(TARGET_DIR)/ $(KDIR)/root.ext2
79 $(call Image/Build,ext2)
80 endef
81 endif
82
83
84 define Image/mkfs/prepare/default
85 find $(TARGET_DIR) -type f -not -perm +0100 -not -name 'ssh_host*' | $(XARGS) chmod 0644
86 find $(TARGET_DIR) -type f -perm +0100 | $(XARGS) chmod 0755
87 find $(TARGET_DIR) -type d | $(XARGS) chmod 0755
88 $(INSTALL_DIR) $(TARGET_DIR)/tmp
89 chmod 0777 $(TARGET_DIR)/tmp
90 endef
91
92 define Image/mkfs/prepare
93 $(call Image/mkfs/prepare/default)
94 endef
95
96 define BuildImage
97 download:
98 prepare:
99 ifneq ($(IB),1)
100 compile: compile-targets FORCE
101 $(call Build/Compile)
102 else
103 compile:
104 endif
105
106 ifneq ($(IB),1)
107 install: compile install-targets FORCE
108 $(call Image/Prepare)
109 $(call Image/mkfs/prepare)
110 $(call Image/BuildKernel)
111 $(call Image/mkfs/jffs2)
112 $(call Image/mkfs/squashfs)
113 $(call Image/mkfs/tgz)
114 $(call Image/mkfs/ext2)
115 else
116 install: compile install-targets
117 $(call Image/BuildKernel)
118 $(call Image/mkfs/jffs2)
119 $(call Image/mkfs/squashfs)
120 $(call Image/mkfs/tgz)
121 $(call Image/mkfs/ext2)
122 endif
123
124 ifneq ($(IB),1)
125 clean: clean-targets
126 $(call Build/Clean)
127 else
128 clean:
129 endif
130
131 compile-targets:
132 install-targets:
133 clean-targets:
134 endef
135
136
This page took 0.049261 seconds and 5 git commands to generate.