#
# Copyright (C) 2010 OpenWrt.org
#
# This is free software, licensed under the GNU General Public License v2.
# See /LICENSE for more information.
#
include $(TOPDIR)/rules.mk
include $(INCLUDE_DIR)/image.mk
UIMAGE:=$(BIN_DIR)/$(IMG_PREFIX)-uImage
define MkuImage
mkimage -A arm -O linux -T kernel -a 0x30008000 -C none \
-e 0x30008000 -n 'Webee210 OpenWrt Linux-$(LINUX_VERSION)' \
-d $(1) $(2)
endef
define Image/Prepare
cp $(LINUX_DIR)/arch/arm/boot/zImage $(KDIR)/zImage
endef
define Image/BuildKernel
$(call MkuImage,$(KDIR)/zImage,$(UIMAGE))
cp $(KDIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-zImage
endef--------------------------------->以上这几项定义全部都是为了生成uimage,若只用到zimage可将上面的内容直接去掉。
define Image/Build
$(call Image/Build/$(1),$(1))
endef
define Image/Build/squashfs
$(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
( \
dd if=$(KDIR)/uImage bs=1024k conv=sync; \
dd if=$(KDIR)/root.$(1) bs=64k conv=sync; \
) > $(BIN_DIR)/openwrt-$(BOARD)-$(1).img
$(STAGING_DIR_HOST)/bin/mkyaffs2image-page2k $(STAGING_DIR_ROOT)/ $(BIN_DIR)/openwrt-$(BOARD)-yaffs2-128k.img
endef
#define Image/Build/yaffs2-128k
# $(STAGING_DIR_HOST)/bin/mkyaffs2image-page2k $(STAGING_DIR_ROOT)/ $(BIN_DIR)/openwrt-$(BOARD)-$(1).yaffs2
#endef
$(eval $(call BuildImage))-----BuildImage定义在include/image.mk165行,具体内容如下:
define BuildImage
166
167 download:
168 prepare:
169
170 ifeq ($(IB),)
171 compile: compile-targets FORCE
172 $(call Build/Compile)
173 else
174 compile:
175 endif
176
177 ifeq ($(IB),)
178 install: compile install-targets FORCE
179 $(call Image/Prepare)
180 $(call Image/mkfs/prepare)
181 $(call Image/BuildKernel)
182 $(call Image/mkfs/cpiogz)
183 $(call Image/mkfs/targz)
184 $(call Image/mkfs/ext4)
185 $(call Image/mkfs/iso)
186 $(call Image/mkfs/jffs2)
187 $(call Image/mkfs/squashfs)------>Image/mkfs/squashfs也定义在image.mk90行,查看知其调$(call Image/Build,squashfs)
------->又Image/Build定义如下:(在/target/linux/$(ARCH)/image/makefile中定义)
define Image/Build
$(call Image/Build/$(1),$(1))
endef
---------->故其最终调用了Image/Build/squashfs。
注:如下所示,只有CONFIG_TARGET_ROOTFS_SQUASHFS在menuconfig的Target Image的菜单中被配置了,最终才能调用Image/Build/squashfs并生成squashfs映像。
89 ifneq ($(CONFIG_TARGET_ROOTFS_SQUASHFS),)
90 define Image/mkfs/squashfs
188 $(call Image/mkfs/ubifs)
189 $(call Image/Checksum)
190 else
191 install: compile install-targets
192 $(call Image/BuildKernel)
193 $(call Image/mkfs/cpiogz)
194 $(call Image/mkfs/targz)
195 $(call Image/mkfs/ext4)
196 $(call Image/mkfs/iso)
197 $(call Image/mkfs/jffs2)
198 $(call Image/mkfs/squashfs)
199 $(call Image/mkfs/ubifs)
200 $(call Image/Checksum)
201 endif
202
203 ifeq ($(IB),)
204 clean: clean-targets
205 $(call Build/Clean)
206 else
207 clean:
208 endif
209
210 compile-targets:
211 install-targets:
212 clean-targets:
213
214 endef
阅读(2640) | 评论(0) | 转发(0) |