ubifs: enable building modular images
[openwrt.git] / target / linux / kirkwood / image / Makefile
1 #
2 # Copyright (C) 2009-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 NAND_BLOCKSIZE := 2048:128k
11
12 define Image/BuildKernel
13         $(CP) $(KDIR)/uImage $(BIN_DIR)/$(IMG_PREFIX)-uImage
14
15 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),)
16         $(CP) $(KDIR)/uImage-initramfs $(BIN_DIR)/$(IMG_PREFIX)-uImage-initramfs
17 endif
18
19  $(foreach board,$(BOARDS),
20         $(LINUX_DIR)/scripts/dtc/dtc \
21           -O dtb -o $(BIN_DIR)/$(IMG_PREFIX)-$(board).dtb \
22           -I dts $(LINUX_DIR)/arch/arm/boot/dts/kirkwood-$(board).dts
23  )
24 endef
25
26 define Image/InstallKernel
27  
28  ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_KERNEL),)
29         $(INSTALL_DIR) $(TARGET_DIR)/boot
30         $(CP) $(KDIR)/uImage $(TARGET_DIR)/boot/
31  endif
32
33  ifneq ($(CONFIG_TARGET_ROOTFS_INCLUDE_DTB),)
34         $(INSTALL_DIR) $(TARGET_DIR)/boot
35         $(foreach board,$(BOARDS),
36           $(CP) $(BIN_DIR)/$(IMG_PREFIX)-$(board).dtb $(TARGET_DIR)/boot/
37         )
38  endif
39 endef
40
41 define Image/Build
42         $(if $(Image/Build/$(1)), \
43                 $(call Image/Build/$(1),$(1)), \
44                 $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1).img \
45         )
46 endef
47
48 define Image/Build/jffs2-nand-2048-128k
49         dd if=$(KDIR)/root.$(1) of=$(BIN_DIR)/$(IMG_PREFIX)-$(1).img \
50                 bs=2048 conv=sync
51 endef
52
53 define Image/Build/squashfs
54         $(call prepare_generic_squashfs,$(KDIR)/root.squashfs)
55         ( \
56                 dd if=$(KDIR)/uImage bs=4096k conv=sync; \
57                 dd if=$(KDIR)/root.$(1) bs=128k conv=sync; \
58         ) > $(BIN_DIR)/$(IMG_PREFIX)-$(1).img
59 endef
60
61 define Image/Build/ubifs
62
63  ifdef UBIFS_OPTS
64         $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-$(1).img
65  endif
66 endef
67
68 define Image/Build/ubi
69
70  ifdef UBI_OPTS
71         $(call Image/Build/ubifs,$(1))
72  endif
73 endef
74
75 $(eval $(call BuildImage))