enable optional building of u-boot for 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 override TARGET_BUILD=
9 include $(INCLUDE_DIR)/prereq.mk
10 include $(INCLUDE_DIR)/kernel.mk
11 include $(INCLUDE_DIR)/host.mk
12
13 override MAKEFLAGS=
14 override MAKE:=$(SUBMAKE)
15 KDIR=$(KERNEL_BUILD_DIR)
16
17 ifneq ($(CONFIG_BIG_ENDIAN),y)
18 JFFS2OPTS := --pad --little-endian --squash
19 SQUASHFS_OPTS := -le
20 else
21 JFFS2OPTS := --pad --big-endian --squash
22 SQUASHFS_OPTS := -be
23 endif
24
25 JFFS2_BLOCKSIZE ?= 64k 128k
26
27 define add_jffs2_mark
28 echo -ne '\xde\xad\xc0\xde' >> $(1)
29 endef
30
31 # pad to 64k and add jffs2 end-of-filesystem mark
32 # do this twice to make sure that this works with 128k blocksize as well
33 define prepare_generic_squashfs
34 dd if=$(1) of=$(KDIR)/tmpfile.1 bs=64k conv=sync
35 $(call add_jffs2_mark,$(KDIR)/tmpfile.1)
36 dd of=$(1) if=$(KDIR)/tmpfile.1 bs=64k conv=sync
37 $(call add_jffs2_mark,$(1))
38 endef
39
40 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
41 ifeq ($(CONFIG_TARGET_ROOTFS_JFFS2),y)
42 define Image/mkfs/jffs2/sub
43 # FIXME: removing this line will cause strange behaviour in the foreach loop below
44 $(STAGING_DIR_HOST)/bin/mkfs.jffs2 $(JFFS2OPTS) -e $(patsubst %k,%KiB,$(1)) -o $(KDIR)/root.jffs2-$(1) -d $(TARGET_DIR)
45 $(call add_jffs2_mark,$(KDIR)/root.jffs2-$(1))
46 $(call Image/Build,jffs2-$(1))
47 endef
48 define Image/mkfs/jffs2
49 rm -rf $(TARGET_DIR)/jffs
50 $(foreach SZ,$(JFFS2_BLOCKSIZE),$(call Image/mkfs/jffs2/sub,$(SZ)))
51 endef
52 endif
53
54 ifeq ($(CONFIG_TARGET_ROOTFS_SQUASHFS),y)
55 define Image/mkfs/squashfs
56 @mkdir -p $(TARGET_DIR)/jffs
57 $(STAGING_DIR_HOST)/bin/mksquashfs-lzma $(TARGET_DIR) $(KDIR)/root.squashfs -nopad -noappend -root-owned $(SQUASHFS_OPTS)
58 $(call Image/Build,squashfs)
59 endef
60 endif
61
62 ifeq ($(CONFIG_TARGET_ROOTFS_TGZ),y)
63 define Image/mkfs/tgz
64 $(TAR) -zcf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-rootfs.tgz --owner=root --group=root -C $(TARGET_DIR)/ .
65 endef
66 endif
67
68 ifeq ($(CONFIG_TARGET_ROOTFS_CPIOGZ),y)
69 define Image/mkfs/cpiogz
70 ( cd $(TARGET_DIR); find . | cpio -o -H newc | gzip -9 >$(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-rootfs.cpio.gz )
71 endef
72 endif
73 else
74 define Image/BuildKernel
75 cp $(KDIR)/vmlinux.elf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux.elf
76 $(call Image/Build/Initramfs)
77 endef
78 endif
79
80
81 ifeq ($(CONFIG_TARGET_ROOTFS_EXT2FS),y)
82 E2SIZE=$(shell echo $$(($(CONFIG_TARGET_ROOTFS_FSPART)*1024)))
83
84 define Image/mkfs/ext2
85 $(STAGING_DIR_HOST)/bin/genext2fs -U -b $(E2SIZE) -I $(CONFIG_TARGET_ROOTFS_MAXINODE) -d $(TARGET_DIR)/ $(KDIR)/root.ext2
86 $(call Image/Build,ext2)
87 endef
88 endif
89
90 ifeq ($(CONFIG_TARGET_ROOTFS_ISO),y)
91 define Image/mkfs/iso
92 $(call Image/Build,iso)
93 endef
94 endif
95
96
97 define Image/mkfs/prepare/default
98 find $(TARGET_DIR) -type f -not -perm +0100 -not -name 'ssh_host*' | $(XARGS) chmod 0644
99 find $(TARGET_DIR) -type f -perm +0100 | $(XARGS) chmod 0755
100 find $(TARGET_DIR) -type d | $(XARGS) chmod 0755
101 $(INSTALL_DIR) $(TARGET_DIR)/tmp
102 chmod 0777 $(TARGET_DIR)/tmp
103 endef
104
105 define Image/mkfs/prepare
106 $(call Image/mkfs/prepare/default)
107 endef
108
109 define BuildImage
110 download:
111 prepare:
112 ifneq ($(IB),1)
113 compile: compile-targets FORCE
114 $(call Build/Compile)
115 else
116 compile:
117 endif
118
119 ifneq ($(IB),1)
120 install: compile install-targets FORCE
121 $(call Image/Prepare)
122 $(call Image/mkfs/prepare)
123 $(call Image/BuildKernel)
124 $(call Image/mkfs/jffs2)
125 $(call Image/mkfs/squashfs)
126 $(call Image/mkfs/tgz)
127 $(call Image/mkfs/cpiogz)
128 $(call Image/mkfs/ext2)
129 $(call Image/mkfs/iso)
130 else
131 install: compile install-targets
132 $(call Image/BuildKernel)
133 $(call Image/mkfs/jffs2)
134 $(call Image/mkfs/squashfs)
135 $(call Image/mkfs/tgz)
136 $(call Image/mkfs/cpiogz)
137 $(call Image/mkfs/ext2)
138 $(call Image/mkfs/iso)
139 endif
140
141 ifneq ($(IB),1)
142 clean: clean-targets
143 $(call Build/Clean)
144 else
145 clean:
146 endif
147
148 compile-targets:
149 install-targets:
150 clean-targets:
151 endef
152
153
This page took 0.055235 seconds and 5 git commands to generate.