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_6_30
),)
30 ifneq ($(USE_SQUASHFS4
),)
31 MKSQUASHFS_CMD
:= $(STAGING_DIR_HOST
)/bin
/mksquashfs4
32 SQUASHFS_OPTS
:= -lzma
-processors
1
34 MKSQUASHFS_CMD
:= $(STAGING_DIR_HOST
)/bin
/mksquashfs-lzma
37 JFFS2_BLOCKSIZE ?
= 64k
128k
40 echo
-ne
'\xde\xad\xc0\xde' >> $(1)
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))
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))
60 define Image
/mkfs
/jffs2
61 rm -rf
$(TARGET_DIR
)/jffs
62 $(foreach SZ
,$(JFFS2_BLOCKSIZE
),$(call Image
/mkfs
/jffs2
/sub
,$(SZ
)))
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
)
74 ifeq ($(CONFIG_TARGET_ROOTFS_TGZ
),y
)
76 $(TAR
) -zcf
$(BIN_DIR
)/openwrt-
$(BOARD
)-rootfs.tgz
--numeric-owner
--owner
=0 --group
=0 -C
$(TARGET_DIR
)/ .
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
)
86 define Image
/BuildKernel
87 cp
$(KDIR
)/vmlinux.elf
$(BIN_DIR
)/openwrt-
$(BOARD
)-vmlinux.elf
88 $(call Image
/Build
/Initramfs
)
94 $(FIND
) -maxdepth
1 -type f \
! -name
'md5sums' -printf
"%P\n" | xargs \
95 md5sum
--binary
> md5sums \
100 ifeq ($(CONFIG_TARGET_ROOTFS_EXT2FS
),y
)
101 E2SIZE
=$(shell echo
$$(($(CONFIG_TARGET_ROOTFS_FSPART
)*1024)))
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
)
109 ifeq ($(CONFIG_TARGET_ROOTFS_ISO
),y
)
110 define Image
/mkfs
/iso
111 $(call Image
/Build
,iso
)
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
124 define Image
/mkfs
/prepare
125 $(call Image
/mkfs
/prepare
/default
)
132 compile
: compile-targets FORCE
133 $(call Build
/Compile
)
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
)
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
)