sunxi: respect CONFIG_TARGET_IMAGES_GZIP
[openwrt/openwrt.git] / target / linux / sunxi / 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 include $(INCLUDE_DIR)/host.mk
10
11 FAT32_BLOCK_SIZE=1024
12 FAT32_BLOCKS=$(shell echo $$(($(CONFIG_SUNXI_SD_BOOT_PARTSIZE)*1024*1024/$(FAT32_BLOCK_SIZE))))
13
14 define Image/BuildKernel
15 -mkdir -p $(KDIR_TMP)
16
17 mkimage -A arm -O linux -T kernel -C none \
18 -a 0x40008000 -e 0x40008000 \
19 -n 'ARM OpenWrt Linux-$(LINUX_VERSION)' \
20 -d $(KDIR)/zImage $(BIN_DIR)/$(IMG_PREFIX)-uImage
21
22 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
23 $(CP) $(KDIR)/zImage-initramfs $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs
24 echo -ne '\x00\x00\x00\x00' >> $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs
25 $(call Image/BuildKernel/MkuImage, \
26 none, 0x40008000, 0x40008000, \
27 $(BIN_DIR)/$(IMG_PREFIX)-zImage-initramfs, \
28 $(BIN_DIR)/$(IMG_PREFIX)-uImage-initramfs \
29 )
30 endif
31 endef
32
33 define Image/Build/SDCard
34 rm -f $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img
35 mkdosfs $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img -C $(FAT32_BLOCKS)
36
37 mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img $(KDIR)/uboot-sunxi-$(PROFILE)-boot.scr ::boot.scr
38 mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img $(DTS_DIR)/$(2).dtb ::dtb
39 mcopy -i $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img $(BIN_DIR)/$(IMG_PREFIX)-uImage ::uImage
40
41 ./gen_sunxi_sdcard_img.sh \
42 $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-sdcard-vfat-$(1).img \
43 $(KDIR_TMP)/$(IMG_PREFIX)-$(PROFILE)-boot.img \
44 $(KDIR)/root.$(1) \
45 $(CONFIG_SUNXI_SD_BOOT_PARTSIZE) \
46 $(CONFIG_TARGET_ROOTFS_PARTSIZE) \
47 $(KDIR)/uboot-sunxi-$(PROFILE)-u-boot-with-spl.bin
48
49 ifneq ($(CONFIG_TARGET_IMAGES_GZIP),)
50 gzip -f9n $(BIN_DIR)/$(IMG_PREFIX)-$(PROFILE)-sdcard-vfat-$(1).img
51 endif
52 endef
53
54 define Image/Build/Profile/A10-OLinuXino-Lime
55 $(call Image/Build/SDCard,$(1),sun4i-a10-olinuxino-lime)
56 endef
57
58 define Image/Build/Profile/A13-OLinuXino
59 $(call Image/Build/SDCard,$(1),sun5i-a13-olinuxino)
60 endef
61
62 define Image/Build/Profile/A20-OLinuXino-Lime
63 $(call Image/Build/SDCard,$(1),sun7i-a20-olinuxino-lime)
64 endef
65
66 define Image/Build/Profile/A20-OLinuXino_MICRO
67 $(call Image/Build/SDCard,$(1),sun7i-a20-olinuxino-micro)
68 endef
69
70 define Image/Build/Profile/Bananapi
71 $(call Image/Build/SDCard,$(1),sun7i-a20-bananapi)
72 endef
73
74 define Image/Build/Profile/Bananapro
75 $(call Image/Build/SDCard,$(1),sun7i-a20-bananapro)
76 endef
77
78 define Image/Build/Profile/Lamobo_R1
79 $(call Image/Build/SDCard,$(1),sun7i-a20-lamobo-r1)
80 endef
81
82 define Image/Build/Profile/Cubieboard
83 $(call Image/Build/SDCard,$(1),sun4i-a10-cubieboard)
84 endef
85
86 define Image/Build/Profile/Cubieboard2
87 $(call Image/Build/SDCard,$(1),sun7i-a20-cubieboard2)
88 endef
89
90 define Image/Build/Profile/Cubietruck
91 $(call Image/Build/SDCard,$(1),sun7i-a20-cubietruck)
92 endef
93
94 define Image/Build/Profile/OLIMEX_A13_SOM
95 $(call Image/Build/SDCard,$(1),sun5i-a13-olinuxino)
96 endef
97
98 define Image/Build/Profile/Mele_M9
99 $(call Image/Build/SDCard,$(1),sun6i-a31-hummingbird)
100 endef
101
102 define Image/Build/Profile/Linksprite_pcDuino
103 $(call Image/Build/SDCard,$(1),sun4i-a10-pcduino)
104 endef
105
106 define Image/Build/Profile/Linksprite_pcDuino3
107 $(call Image/Build/SDCard,$(1),sun7i-a20-pcduino3)
108 endef
109
110 define Image/Build
111 $(call Image/Build/$(1),$(1))
112 $(call Image/Build/Profile/$(PROFILE),$(1))
113
114 dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-root.$(1) bs=128k conv=sync
115 endef
116
117 $(eval $(call BuildImage))