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