we don't need bluetooth on avr32 for now
[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 KDIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)
12
13 ifneq ($(CONFIG_BIG_ENDIAN),y)
14 JFFS2OPTS := --pad --little-endian --squash
15 SQUASHFS_OPTS := -le
16 else
17 JFFS2OPTS := --pad --big-endian --squash
18 SQUASHFS_OPTS := -be
19 endif
20
21 define add_jffs2_mark
22 echo -ne '\xde\xad\xc0\xde' >> $(1)
23 endef
24
25 # pad to 64k and add jffs2 end-of-filesystem mark
26 # do this twice to make sure that this works with 128k blocksize as well
27 define prepare_generic_squashfs
28 dd if=$(1) of=$(KDIR)/tmpfile.1 bs=64k conv=sync
29 $(call add_jffs2_mark,$(KDIR)/tmpfile.1)
30 dd of=$(1) if=$(KDIR)/tmpfile.1 bs=64k conv=sync
31 $(call add_jffs2_mark,$(1))
32 endef
33
34 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
35 ifeq ($(CONFIG_TARGET_ROOTFS_JFFS2),y)
36 define Image/mkfs/jffs2
37 rm -rf $(BUILD_DIR)/root/jffs
38
39 $(STAGING_DIR)/bin/mkfs.jffs2 $(JFFS2OPTS) -e 0x10000 -o $(KDIR)/root.jffs2-64k -d $(BUILD_DIR)/root
40 $(STAGING_DIR)/bin/mkfs.jffs2 $(JFFS2OPTS) -e 0x20000 -o $(KDIR)/root.jffs2-128k -d $(BUILD_DIR)/root
41 $(STAGING_DIR)/bin/mkfs.jffs2 $(JFFS2OPTS) -e 0x40000 -o $(KDIR)/root.jffs2-256k -d $(BUILD_DIR)/root
42
43
44 # add End-of-Filesystem markers
45 $(call add_jffs2_mark,$(KDIR)/root.jffs2-64k)
46 $(call add_jffs2_mark,$(KDIR)/root.jffs2-128k)
47 $(call add_jffs2_mark,$(KDIR)/root.jffs2-256k)
48
49 $(call Image/Build,jffs2-64k)
50 $(call Image/Build,jffs2-128k)
51 $(call Image/Build,jffs2-256k)
52 endef
53 endif
54
55 ifeq ($(CONFIG_TARGET_ROOTFS_SQUASHFS),y)
56 define Image/mkfs/squashfs
57 @mkdir -p $(BUILD_DIR)/root/jffs
58 $(STAGING_DIR)/bin/mksquashfs-lzma $(BUILD_DIR)/root $(KDIR)/root.squashfs -nopad -noappend -root-owned $(SQUASHFS_OPTS)
59 $(call Image/Build,squashfs)
60 endef
61 endif
62
63 ifeq ($(CONFIG_TARGET_ROOTFS_TGZ),y)
64 define Image/mkfs/tgz
65 tar -zcf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-rootfs.tgz --owner=root --group=root -C $(BUILD_DIR)/root/ .
66 endef
67 endif
68 else
69 define Image/BuildKernel
70 cp $(KDIR)/vmlinux.elf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux.elf
71 $(call Image/Build/Initramfs)
72 endef
73 endif
74
75
76 ifeq ($(CONFIG_TARGET_ROOTFS_EXT2FS),y)
77 E2SIZE=$(shell echo $$(($(CONFIG_TARGET_ROOTFS_FSPART)*1024)))
78
79 define Image/mkfs/ext2
80 $(STAGING_DIR)/bin/genext2fs -U -b $(E2SIZE) -I $(CONFIG_TARGET_ROOTFS_MAXINODE) -d $(BUILD_DIR)/root/ $(KDIR)/root.ext2
81 $(call Image/Build,ext2)
82 endef
83 endif
84
85
86 define Image/mkfs/prepare/default
87 find $(BUILD_DIR)/root -type f -not -perm +0100 -not -name 'ssh_host*' | $(XARGS) chmod 0644
88 find $(BUILD_DIR)/root -type f -perm +0100 | $(XARGS) chmod 0755
89 find $(BUILD_DIR)/root -type d | $(XARGS) chmod 0755
90 mkdir -p $(BUILD_DIR)/root/tmp
91 chmod 0777 $(BUILD_DIR)/root/tmp
92 endef
93
94 define Image/mkfs/prepare
95 $(call Image/mkfs/prepare/default)
96 endef
97
98 define BuildImage
99 download:
100 prepare:
101 ifneq ($(IB),1)
102 compile: compile-targets
103 $(call Build/Compile)
104 else
105 compile:
106 endif
107
108 ifneq ($(IB),1)
109 install: compile install-targets
110 $(call Image/Prepare)
111 $(call Image/mkfs/prepare)
112 $(call Image/BuildKernel)
113 $(call Image/mkfs/jffs2)
114 $(call Image/mkfs/squashfs)
115 $(call Image/mkfs/tgz)
116 $(call Image/mkfs/ext2)
117 else
118 install: compile install-targets
119 $(call Image/BuildKernel)
120 $(call Image/mkfs/jffs2)
121 $(call Image/mkfs/squashfs)
122 $(call Image/mkfs/tgz)
123 $(call Image/mkfs/ext2)
124 endif
125
126 ifneq ($(IB),1)
127 clean: clean-targets
128 $(call Build/Clean)
129 else
130 clean:
131 endif
132
133 compile-targets:
134 install-targets:
135 clean-targets:
136 endef
137
138
This page took 0.048759 seconds and 5 git commands to generate.