more cleanup
[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 KDIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)
11
12 ifneq ($(CONFIG_BIG_ENDIAN),y)
13 JFFS2OPTS := --pad --little-endian --squash
14 SQUASHFS_OPTS := -le
15 else
16 JFFS2OPTS := --pad --big-endian --squash
17 SQUASHFS_OPTS := -be
18 endif
19
20 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
21 ifeq ($(CONFIG_TARGET_ROOTFS_JFFS2),y)
22 define Image/mkfs/jffs2
23 rm -rf $(BUILD_DIR)/root/jffs
24
25 $(STAGING_DIR)/bin/mkfs.jffs2 $(JFFS2OPTS) -e 0x10000 -o $(KDIR)/root.jffs2-64k -d $(BUILD_DIR)/root
26 $(STAGING_DIR)/bin/mkfs.jffs2 $(JFFS2OPTS) -e 0x20000 -o $(KDIR)/root.jffs2-128k -d $(BUILD_DIR)/root
27
28 # add End-of-Filesystem markers
29 echo -ne '\xde\xad\xc0\xde' >> $(KDIR)/root.jffs2-64k
30 echo -ne '\xde\xad\xc0\xde' >> $(KDIR)/root.jffs2-128k
31
32 $(call Image/Build,jffs2-64k)
33 $(call Image/Build,jffs2-128k)
34 endef
35 endif
36
37 ifeq ($(CONFIG_TARGET_ROOTFS_SQUASHFS),y)
38 define Image/mkfs/squashfs
39 @mkdir -p $(BUILD_DIR)/root/jffs
40 $(STAGING_DIR)/bin/mksquashfs-lzma $(BUILD_DIR)/root $(KDIR)/root.squashfs -nopad -noappend -root-owned $(SQUASHFS_OPTS)
41 $(call Image/Build,squashfs)
42 endef
43 endif
44
45 ifeq ($(CONFIG_TARGET_ROOTFS_TGZ),y)
46 define Image/mkfs/tgz
47 tar -zcf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-rootfs.tgz --owner=root --group=root -C $(BUILD_DIR)/root/ .
48 endef
49 endif
50
51
52 endif
53
54
55 ifeq ($(CONFIG_TARGET_ROOTFS_EXT2FS),y)
56 E2SIZE=$(shell echo $$(($(CONFIG_TARGET_ROOTFS_FSPART)*1024)))
57
58 define Image/mkfs/ext2
59 $(STAGING_DIR)/bin/genext2fs -U -b $(E2SIZE) -I $(CONFIG_TARGET_ROOTFS_MAXINODE) -d $(BUILD_DIR)/root/ $(KDIR)/root.ext2
60 $(call Image/Build,ext2)
61 endef
62 endif
63
64
65 define Image/mkfs/prepare/default
66 find $(BUILD_DIR)/root -type f -not -perm +0100 -not -name 'ssh_host*' | xargs chmod 0644
67 find $(BUILD_DIR)/root -type f -perm +0100 | xargs chmod 0755
68 find $(BUILD_DIR)/root -type d | xargs chmod 0755
69 mkdir -p $(BUILD_DIR)/root/tmp
70 chmod 0777 $(BUILD_DIR)/root/tmp
71 endef
72
73 define Image/mkfs/prepare
74 $(call Image/mkfs/prepare/default)
75 endef
76
77 define BuildImage
78 download:
79 prepare:
80 ifneq ($(IB),1)
81 compile: compile-targets
82 $(call Build/Compile)
83 else
84 compile:
85 endif
86
87 ifneq ($(IB),1)
88 install: compile install-targets
89 $(call Image/Prepare)
90 $(call Image/mkfs/prepare)
91 $(call Image/BuildKernel)
92 $(call Image/mkfs/jffs2)
93 $(call Image/mkfs/squashfs)
94 $(call Image/mkfs/tgz)
95 $(call Image/mkfs/ext2)
96 else
97 install: compile install-targets
98 $(call Image/BuildKernel)
99 $(call Image/mkfs/jffs2)
100 $(call Image/mkfs/squashfs)
101 $(call Image/mkfs/tgz)
102 $(call Image/mkfs/ext2)
103 endif
104
105 ifneq ($(IB),1)
106 clean: clean-targets
107 $(call Build/Clean)
108 else
109 clean:
110 endif
111
112 compile-targets:
113 install-targets:
114 clean-targets:
115 endef
116
117
This page took 0.047846 seconds and 5 git commands to generate.