build: move mkits.sh script to more common place
[openwrt/svn-archive/archive.git] / target / linux / imx6 / image / Makefile
1 #
2 # Copyright (C) 2013 OpenWrt.org
3 #
4 # This is free software, licensed under the GNU General Public License v2.
5 # See /LICENSE for more information.
6 #
7 include $(TOPDIR)/rules.mk
8 include $(INCLUDE_DIR)/image.mk
9
10 BOARDS := \
11 imx6dl-wandboard \
12 imx6q-gw5400-a
13
14 # emit FIT images, DTB's and generic zImage
15 define Image/BuildKernel
16 $(foreach board,$(BOARDS),
17 cp $(LINUX_DIR)/arch/arm/boot/dts/$(board).dtb $(BIN_DIR)/$(IMG_PREFIX)-$(board).dtb
18
19 $(call Image/BuildKernel/MkFIT,$(board),$(KDIR)/zImage,$(BIN_DIR)/$(IMG_PREFIX)-$(board).dtb,none,0x10008000,0x10008000)
20 cp $(KDIR)/fit-$(board).itb $(BIN_DIR)/$(IMG_PREFIX)-$(board)-uImage.itb
21
22 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
23 $(call Image/BuildKernel/MkFIT,$(board),$(KDIR)/zImage-initramfs,$(BIN_DIR)/$(IMG_PREFIX)-$(board).dtb,none,0x10008000,0x10008000,-initramfs)
24 cp $(KDIR)/fit-$(board)-initramfs.itb $(BIN_DIR)/$(IMG_PREFIX)-$(board)-uImage-initramfs.itb
25 endif
26 )
27
28 cp $(KDIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-zImage
29
30 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
31 cp $(KDIR)/zImage-initramfs $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs
32 endif
33 endef
34
35 # board-specific sysupgrade image
36 define BuildFirmware/Generic
37 dd if=$(BIN_DIR)/openwrt-$(1)-uImage.itb of=$(KDIR)/uImage.pad bs=64k conv=sync; \
38 dd if=$(KDIR)/root.$(2) of=$(KDIR)/root.$(2).pad bs=128k conv=sync; \
39 sh $(TOPDIR)/scripts/combined-image.sh \
40 $(KDIR)/uImage.pad \
41 $(KDIR)/root.$(2).pad \
42 $(BIN_DIR)/$(IMG_PREFIX)-$(patsubst jffs2-%,jffs2,$(patsubst squashfs-%,squashfs,$(1)))-sysupgrade.bin
43 endef
44
45 define Image/Build
46 $(call Image/Build/$(1),$(1))
47 $(foreach board,$(BOARDS),
48 $(call BuildFirmware/Generic,$(board),$(1))
49 )
50 endef
51
52 # rootfs and board-specific combined kernel+rootfs for convenience
53 define Image/Build/squashfs
54 $(call prepare_generic_squashfs,$(KDIR)/root.$(1))
55 dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/openwrt-$(BOARD)-$(1).img bs=128k conv=sync
56 $(foreach board,$(BOARDS),
57 ( \
58 dd if=$(BIN_DIR)/openwrt-$(board)-uImage.itb bs=2048k conv=sync; \
59 dd if=$(KDIR)/root.$(1) bs=64k conv=sync; \
60 ) > $(BIN_DIR)/$(IMG_PREFIX)-$(board)-$(1).bin
61 )
62 endef
63
64 $(eval $(call BuildImage))