2 # Copyright (C) 2006 OpenWrt.org
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
8 include $(INCLUDE_DIR
)/prereq.mk
9 include $(INCLUDE_DIR
)/kernel.mk
10 KDIR
:=$(BUILD_DIR
)/linux-
$(KERNEL
)-$(BOARD
)
12 ifneq ($(CONFIG_BIG_ENDIAN
),y
)
13 JFFS2OPTS
:= --pad
--little-endian
--squash
16 JFFS2OPTS
:= --pad
--big-endian
--squash
21 echo
-ne
'\xde\xad\xc0\xde' >> $(1)
24 # pad to 64k and add jffs2 end-of-filesystem mark
25 # do this twice to make sure that this works with 128k blocksize as well
26 define prepare_generic_squashfs
27 dd if
=$(1) of
=$(KDIR
)/tmpfile
.1 bs
=64k conv
=sync
28 $(call add_jffs2_mark
,$(KDIR
)/tmpfile
.1)
29 dd of
=$(1) if
=$(KDIR
)/tmpfile
.1 bs
=64k conv
=sync
30 $(call add_jffs2_mark
,$(1))
33 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS
),y
)
34 ifeq ($(CONFIG_TARGET_ROOTFS_JFFS2
),y
)
35 define Image
/mkfs
/jffs2
36 rm -rf
$(BUILD_DIR
)/root
/jffs
38 $(STAGING_DIR
)/bin
/mkfs.jffs2
$(JFFS2OPTS
) -e
0x10000 -o
$(KDIR
)/root.jffs2-64k
-d
$(BUILD_DIR
)/root
39 $(STAGING_DIR
)/bin
/mkfs.jffs2
$(JFFS2OPTS
) -e
0x20000 -o
$(KDIR
)/root.jffs2-128k
-d
$(BUILD_DIR
)/root
42 # add End-of-Filesystem markers
43 $(call add_jffs2_mark
,$(KDIR
)/root.jffs2-64k
)
44 $(call add_jffs2_mark
,$(KDIR
)/root.jffs2-128k
)
46 $(call Image
/Build
,jffs2-64k
)
47 $(call Image
/Build
,jffs2-128k
)
51 ifeq ($(CONFIG_TARGET_ROOTFS_SQUASHFS
),y
)
52 define Image
/mkfs
/squashfs
53 @mkdir
-p
$(BUILD_DIR
)/root
/jffs
54 $(STAGING_DIR
)/bin
/mksquashfs-lzma
$(BUILD_DIR
)/root
$(KDIR
)/root.squashfs
-nopad
-noappend
-root-owned
$(SQUASHFS_OPTS
)
55 $(call Image
/Build
,squashfs
)
59 ifeq ($(CONFIG_TARGET_ROOTFS_TGZ
),y
)
61 tar -zcf
$(BIN_DIR
)/openwrt-
$(BOARD
)-$(KERNEL
)-rootfs.tgz
--owner
=root
--group
=root
-C
$(BUILD_DIR
)/root
/ .
65 define Image
/BuildKernel
66 cp
$(KDIR
)/vmlinux.elf
$(BIN_DIR
)/openwrt-
$(BOARD
)-$(KERNEL
)-vmlinux.elf
71 ifeq ($(CONFIG_TARGET_ROOTFS_EXT2FS
),y
)
72 E2SIZE
=$(shell echo
$$(($(CONFIG_TARGET_ROOTFS_FSPART
)*1024)))
74 define Image
/mkfs
/ext2
75 $(STAGING_DIR
)/bin
/genext2fs
-U
-b
$(E2SIZE
) -I
$(CONFIG_TARGET_ROOTFS_MAXINODE
) -d
$(BUILD_DIR
)/root
/ $(KDIR
)/root.ext2
76 $(call Image
/Build
,ext2
)
81 define Image
/mkfs
/prepare
/default
82 find
$(BUILD_DIR
)/root
-type f
-not
-perm
+0100 -not
-name
'ssh_host*' | xargs chmod
0644
83 find
$(BUILD_DIR
)/root
-type f
-perm
+0100 | xargs chmod
0755
84 find
$(BUILD_DIR
)/root
-type d | xargs chmod
0755
85 mkdir
-p
$(BUILD_DIR
)/root
/tmp
86 chmod
0777 $(BUILD_DIR
)/root
/tmp
89 define Image
/mkfs
/prepare
90 $(call Image
/mkfs
/prepare
/default
)
97 compile
: compile-targets
104 install: compile install-targets
105 $(call Image
/Prepare
)
106 $(call Image
/mkfs
/prepare
)
107 $(call Image
/BuildKernel
)
108 $(call Image
/mkfs
/jffs2
)
109 $(call Image
/mkfs
/squashfs
)
110 $(call Image
/mkfs
/tgz
)
111 $(call Image
/mkfs
/ext2
)
113 install: compile install-targets
114 $(call Image
/BuildKernel
)
115 $(call Image
/mkfs
/jffs2
)
116 $(call Image
/mkfs
/squashfs
)
117 $(call Image
/mkfs
/tgz
)
118 $(call Image
/mkfs
/ext2
)