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.
9 include $(INCLUDE_DIR
)/prereq.mk
10 include $(INCLUDE_DIR
)/kernel.mk
11 include $(INCLUDE_DIR
)/host.mk
15 override MAKE
:=$(SUBMAKE
)
16 KDIR
=$(KERNEL_BUILD_DIR
)
18 ifneq ($(CONFIG_BIG_ENDIAN
),y
)
19 JFFS2OPTS
:= --pad
--little-endian
--squash
22 JFFS2OPTS
:= --pad
--big-endian
--squash
26 ifneq ($(CONFIG_LINUX_2_4
)$(CONFIG_LINUX_2_6_25
),)
30 ifneq ($(USE_SQUASHFS3
),)
31 MKSQUASHFS_CMD
:= $(STAGING_DIR_HOST
)/bin
/mksquashfs-lzma
33 MKSQUASHFS_CMD
:= $(STAGING_DIR_HOST
)/bin
/mksquashfs4
34 SQUASHFS_OPTS
:= -comp lzma
-processors
1
37 JFFS2_BLOCKSIZE ?
= 64k
128k
40 echo
-ne
'\xde\xad\xc0\xde' >> $(1)
43 # pad to 4k, 8k, 64k, 128k and add jffs2 end-of-filesystem mark
44 define prepare_generic_squashfs
45 dd if
=$(1) of
=$(KDIR
)/tmpfile
.0 bs
=4k conv
=sync
46 $(call add_jffs2_mark
,$(KDIR
)/tmpfile
.0)
47 dd if
=$(KDIR
)/tmpfile
.0 of
=$(KDIR
)/tmpfile
.1 bs
=4k conv
=sync
48 $(call add_jffs2_mark
,$(KDIR
)/tmpfile
.1)
49 dd if
=$(KDIR
)/tmpfile
.1 of
=$(KDIR
)/tmpfile
.2 bs
=64k conv
=sync
50 $(call add_jffs2_mark
,$(KDIR
)/tmpfile
.2)
51 dd if
=$(KDIR
)/tmpfile
.2 of
=$(1) bs
=64k conv
=sync
52 $(call add_jffs2_mark
,$(1))
53 rm -f
$(KDIR
)/tmpfile.
*
56 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS
),y
)
57 ifeq ($(CONFIG_TARGET_ROOTFS_JFFS2
),y
)
58 define Image
/mkfs
/jffs2
/sub
59 # FIXME: removing this line will cause strange behaviour in the foreach loop below
60 $(STAGING_DIR_HOST
)/bin
/mkfs.jffs2
$(JFFS2OPTS
) -e
$(patsubst %k
,%KiB
,$(1)) -o
$(KDIR
)/root.jffs2-
$(1) -d
$(TARGET_DIR
)
61 $(call add_jffs2_mark
,$(KDIR
)/root.jffs2-
$(1))
62 $(call Image
/Build
,jffs2-
$(1))
64 define Image
/mkfs
/jffs2
65 rm -rf
$(TARGET_DIR
)/jffs
66 $(foreach SZ
,$(JFFS2_BLOCKSIZE
),$(call Image
/mkfs
/jffs2
/sub
,$(SZ
)))
70 ifeq ($(CONFIG_TARGET_ROOTFS_SQUASHFS
),y
)
71 define Image
/mkfs
/squashfs
72 @mkdir
-p
$(TARGET_DIR
)/jffs
73 $(MKSQUASHFS_CMD
) $(TARGET_DIR
) $(KDIR
)/root.squashfs
-nopad
-noappend
-root-owned
$(SQUASHFS_OPTS
)
74 $(call Image
/Build
,squashfs
)
78 ifeq ($(CONFIG_TARGET_ROOTFS_TGZ
),y
)
80 $(TAR
) -zcf
$(BIN_DIR
)/openwrt-
$(BOARD
)-rootfs.tgz
--numeric-owner
--owner
=0 --group
=0 -C
$(TARGET_DIR
)/ .
84 ifeq ($(CONFIG_TARGET_ROOTFS_CPIOGZ
),y
)
85 define Image
/mkfs
/cpiogz
86 ( cd
$(TARGET_DIR
); find . | cpio
-o
-H newc | gzip
-9 >$(BIN_DIR
)/openwrt-
$(BOARD
)-rootfs.cpio.gz
)
89 ifeq ($(CONFIG_TARGET_ROOTFS_UBIFS
),y
)
90 define Image
/mkfs
/ubifs
91 $(CP
) .
/ubinize.cfg
$(KDIR
)
92 $(STAGING_DIR_HOST
)/bin
/mkfs.ubifs
$(UBIFS_OPTS
) -o
$(KDIR
)/root.ubifs
-d
$(TARGET_DIR
)
94 $(STAGING_DIR_HOST
)/bin
/ubinize
$(UBINIZE_OPTS
) -o
$(KDIR
)/root.ubi ubinize.cfg
)
95 $(call Image
/Build
,ubi
)
99 define Image
/BuildKernel
100 cp
$(KDIR
)/vmlinux.elf
$(BIN_DIR
)/openwrt-
$(BOARD
)-vmlinux.elf
101 $(call Image
/Build
/Initramfs
)
105 define Image
/Checksum
107 $(FIND
) -maxdepth
1 -type f \
! -name
'md5sums' -printf
"%P\n" | xargs \
108 md5sum
--binary
> md5sums \
113 ifeq ($(CONFIG_TARGET_ROOTFS_EXT2FS
),y
)
114 E2SIZE
=$(shell echo
$$(($(CONFIG_TARGET_ROOTFS_FSPART
)*1024)))
116 define Image
/mkfs
/ext2
117 $(STAGING_DIR_HOST
)/bin
/genext2fs
-U
-b
$(E2SIZE
) -N
$(CONFIG_TARGET_ROOTFS_MAXINODE
) -d
$(TARGET_DIR
)/ $(KDIR
)/root.ext2
118 $(call Image
/Build
,ext2
)
122 ifeq ($(CONFIG_TARGET_ROOTFS_ISO
),y
)
123 define Image
/mkfs
/iso
124 $(call Image
/Build
,iso
)
129 define Image
/mkfs
/prepare
/default
130 - $(FIND
) $(TARGET_DIR
) -type f
-not
-perm
+0100 -not
-name
'ssh_host*' -print0 |
$(XARGS
) -0 chmod
0644
131 - $(FIND
) $(TARGET_DIR
) -type f
-perm
+0100 -print0 |
$(XARGS
) -0 chmod
0755
132 - $(FIND
) $(TARGET_DIR
) -type d
-print0 |
$(XARGS
) -0 chmod
0755
133 $(INSTALL_DIR
) $(TARGET_DIR
)/tmp
134 chmod
0777 $(TARGET_DIR
)/tmp
137 define Image
/mkfs
/prepare
138 $(call Image
/mkfs
/prepare
/default
)
145 compile
: compile-targets FORCE
146 $(call Build
/Compile
)
152 install: compile install-targets FORCE
153 $(call Image
/Prepare
)
154 $(call Image
/mkfs
/prepare
)
155 $(call Image
/BuildKernel
)
156 $(call Image
/mkfs
/jffs2
)
157 $(call Image
/mkfs
/squashfs
)
158 $(call Image
/mkfs
/tgz
)
159 $(call Image
/mkfs
/cpiogz
)
160 $(call Image
/mkfs
/ext2
)
161 $(call Image
/mkfs
/iso
)
162 $(call Image
/mkfs
/ubifs
)
163 $(call Image
/Checksum
)
165 install: compile install-targets
166 $(call Image
/BuildKernel
)
167 $(call Image
/mkfs
/jffs2
)
168 $(call Image
/mkfs
/squashfs
)
169 $(call Image
/mkfs
/tgz
)
170 $(call Image
/mkfs
/cpiogz
)
171 $(call Image
/mkfs
/ext2
)
172 $(call Image
/mkfs
/iso
)
173 $(call Image
/mkfs
/ubifs
)
174 $(call Image
/Checksum
)