ar71xx: reset the phy in the ethernet init on ar724x
[openwrt.git] / include / image.mk
1 #
2 # Copyright (C) 2006-2010 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 .NOTPARALLEL:
14 override MAKEFLAGS=
15 override MAKE:=$(SUBMAKE)
16 KDIR=$(KERNEL_BUILD_DIR)
17
18 IMG_PREFIX:=openwrt-$(BOARD)$(if $(SUBTARGET),-$(SUBTARGET))
19
20 ifneq ($(CONFIG_BIG_ENDIAN),)
21 JFFS2OPTS := --pad --big-endian --squash -v
22 else
23 JFFS2OPTS := --pad --little-endian --squash -v
24 endif
25
26 ifeq ($(CONFIG_JFFS2_RTIME),y)
27 JFFS2OPTS += -X rtime
28 endif
29 ifeq ($(CONFIG_JFFS2_ZLIB),y)
30 JFFS2OPTS += -X zlib
31 endif
32 ifeq ($(CONFIG_JFFS2_LZMA),y)
33 JFFS2OPTS += -X lzma --compression-mode=size
34 endif
35 ifneq ($(CONFIG_JFFS2_RTIME),y)
36 JFFS2OPTS += -x rtime
37 endif
38 ifneq ($(CONFIG_JFFS2_ZLIB),y)
39 JFFS2OPTS += -x zlib
40 endif
41 ifneq ($(CONFIG_JFFS2_LZMA),y)
42 JFFS2OPTS += -x lzma
43 endif
44
45 LZMA_XZ_OPTIONS := -Xpreset 9 -Xe -Xlc 0 -Xlp 2 -Xpb 2
46 ifeq ($(CONFIG_SQUASHFS_LZMA),y)
47 SQUASHFSCOMP := lzma $(LZMA_XZ_OPTIONS)
48 endif
49 ifeq ($(CONFIG_SQUASHFS_XZ),y)
50 SQUASHFSCOMP := xz $(LZMA_XZ_OPTIONS)
51 endif
52
53 JFFS2_BLOCKSIZE ?= 64k 128k
54
55 define add_jffs2_mark
56 echo -ne '\xde\xad\xc0\xde' >> $(1)
57 endef
58
59 # pad to 4k, 8k, 64k, 128k 256k and add jffs2 end-of-filesystem mark
60 define prepare_generic_squashfs
61 $(STAGING_DIR_HOST)/bin/padjffs2 $(1) 4 8 64 128 256
62 endef
63
64
65 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
66
67 define Image/BuildKernel
68 cp $(KDIR)/vmlinux.elf $(BIN_DIR)/$(IMG_PREFIX)-vmlinux.elf
69 $(call Image/Build/Initramfs)
70 endef
71
72 else
73
74 ifneq ($(CONFIG_TARGET_ROOTFS_JFFS2),)
75 define Image/mkfs/jffs2/sub
76 # FIXME: removing this line will cause strange behaviour in the foreach loop below
77 $(STAGING_DIR_HOST)/bin/mkfs.jffs2 $(JFFS2OPTS) -e $(patsubst %k,%KiB,$(1)) -o $(KDIR)/root.jffs2-$(1) -d $(TARGET_DIR) -v 2>&1 1>/dev/null | awk '/^.+$$$$/'
78 $(call add_jffs2_mark,$(KDIR)/root.jffs2-$(1))
79 $(call Image/Build,jffs2-$(1))
80 endef
81 define Image/mkfs/jffs2
82 $(foreach SZ,$(JFFS2_BLOCKSIZE),$(call Image/mkfs/jffs2/sub,$(SZ)))
83 endef
84 endif
85
86 ifneq ($(CONFIG_TARGET_ROOTFS_SQUASHFS),)
87 define Image/mkfs/squashfs
88 @mkdir -p $(TARGET_DIR)/overlay
89 $(STAGING_DIR_HOST)/bin/mksquashfs4 $(TARGET_DIR) $(KDIR)/root.squashfs -nopad -noappend -root-owned -comp $(SQUASHFSCOMP) -processors 1
90 $(call Image/Build,squashfs)
91 endef
92 endif
93
94 ifneq ($(CONFIG_TARGET_ROOTFS_UBIFS),)
95 define Image/mkfs/ubifs
96 $(CP) ./ubinize.cfg $(KDIR)
97 $(STAGING_DIR_HOST)/bin/mkfs.ubifs $(UBIFS_OPTS) -o $(KDIR)/root.ubifs -d $(TARGET_DIR)
98 (cd $(KDIR); \
99 $(STAGING_DIR_HOST)/bin/ubinize $(UBINIZE_OPTS) -o $(KDIR)/root.ubi ubinize.cfg)
100 $(call Image/Build,ubi)
101 endef
102 endif
103
104 endif
105
106 ifneq ($(CONFIG_TARGET_ROOTFS_CPIOGZ),)
107 define Image/mkfs/cpiogz
108 ( cd $(TARGET_DIR); find . | cpio -o -H newc | gzip -9 >$(BIN_DIR)/$(IMG_PREFIX)-rootfs.cpio.gz )
109 endef
110 endif
111
112 ifneq ($(CONFIG_TARGET_ROOTFS_TARGZ),)
113 define Image/mkfs/targz
114 # Preserve permissions (-p) when building as non-root user
115 $(TAR) -czpf $(BIN_DIR)/$(IMG_PREFIX)-rootfs.tar.gz --numeric-owner --owner=0 --group=0 -C $(TARGET_DIR)/ .
116 endef
117 endif
118
119 ifneq ($(CONFIG_TARGET_ROOTFS_EXT4FS),)
120 E2SIZE=$(shell echo $$(($(CONFIG_TARGET_ROOTFS_PARTSIZE)*1024)))
121
122 define Image/mkfs/ext4
123 # generate an ext2 fs
124 $(STAGING_DIR_HOST)/bin/genext2fs -U -b $(E2SIZE) -N $(CONFIG_TARGET_ROOTFS_MAXINODE) -d $(TARGET_DIR)/ $(KDIR)/root.ext4
125 # convert it to ext4
126 $(STAGING_DIR_HOST)/bin/tune2fs -O extents,uninit_bg,dir_index $(KDIR)/root.ext4
127 # fix it up
128 $(STAGING_DIR_HOST)/bin/e2fsck -fy $(KDIR)/root.ext4
129 $(call Image/Build,ext4)
130 endef
131 endif
132
133 ifneq ($(CONFIG_TARGET_ROOTFS_ISO),)
134 define Image/mkfs/iso
135 $(call Image/Build,iso)
136 endef
137 endif
138
139
140 define Image/mkfs/prepare/default
141 # Use symbolic permissions to avoid clobbering SUID/SGID/sticky bits
142 - $(FIND) $(TARGET_DIR) -type f -not -perm +0100 -not -name 'ssh_host*' -print0 | $(XARGS) -0 chmod u+rw,g+r,o+r
143 - $(FIND) $(TARGET_DIR) -type f -perm +0100 -print0 | $(XARGS) -0 chmod u+rwx,g+rx,o+rx
144 - $(FIND) $(TARGET_DIR) -type d -print0 | $(XARGS) -0 chmod u+rwx,g+rx,o+rx
145 $(INSTALL_DIR) $(TARGET_DIR)/tmp
146 chmod 0777 $(TARGET_DIR)/tmp
147 endef
148
149 define Image/mkfs/prepare
150 $(call Image/mkfs/prepare/default)
151 endef
152
153
154 define Image/Checksum
155 ( cd ${BIN_DIR} ; \
156 $(FIND) -maxdepth 1 -type f \! -name 'md5sums' -printf "%P\n" | sort | xargs \
157 md5sum --binary > md5sums \
158 )
159 endef
160
161
162 define BuildImage
163
164 download:
165 prepare:
166
167 ifeq ($(IB),)
168 compile: compile-targets FORCE
169 $(call Build/Compile)
170 else
171 compile:
172 endif
173
174 ifeq ($(IB),)
175 install: compile install-targets FORCE
176 $(call Image/Prepare)
177 $(call Image/mkfs/prepare)
178 $(call Image/BuildKernel)
179 $(call Image/mkfs/cpiogz)
180 $(call Image/mkfs/targz)
181 $(call Image/mkfs/ext4)
182 $(call Image/mkfs/iso)
183 $(call Image/mkfs/jffs2)
184 $(call Image/mkfs/squashfs)
185 $(call Image/mkfs/ubifs)
186 $(call Image/Checksum)
187 else
188 install: compile install-targets
189 $(call Image/BuildKernel)
190 $(call Image/mkfs/cpiogz)
191 $(call Image/mkfs/targz)
192 $(call Image/mkfs/ext4)
193 $(call Image/mkfs/iso)
194 $(call Image/mkfs/jffs2)
195 $(call Image/mkfs/squashfs)
196 $(call Image/mkfs/ubifs)
197 $(call Image/Checksum)
198 endif
199
200 ifeq ($(IB),)
201 clean: clean-targets
202 $(call Build/Clean)
203 else
204 clean:
205 endif
206
207 compile-targets:
208 install-targets:
209 clean-targets:
210
211 endef
This page took 0.059662 seconds and 5 git commands to generate.