add prereq checks for target/linux/* and target/image/*, check for fdisk for the...
[openwrt.git] / include / image.mk
1
2 # Copyright (C) 2006 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 include $(INCLUDE_DIR)/prereq.mk
9 include $(INCLUDE_DIR)/kernel.mk
10 KDIR:=$(BUILD_DIR)/linux-$(KERNEL)-$(BOARD)
11
12 ifneq ($(CONFIG_BIG_ENDIAN),y)
13 JFFS2OPTS     :=  --pad --little-endian --squash
14 SQUASHFS_OPTS :=  -le
15 else
16 JFFS2OPTS     :=  --pad --big-endian --squash
17 SQUASHFS_OPTS :=  -be
18 endif
19
20 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
21   ifeq ($(CONFIG_TARGET_ROOTFS_JFFS2),y)
22     define Image/mkfs/jffs2
23                 rm -rf $(BUILD_DIR)/root/jffs
24                 
25                 $(STAGING_DIR)/bin/mkfs.jffs2 $(JFFS2OPTS) -e 0x10000 -o $(KDIR)/root.jffs2-64k -d $(BUILD_DIR)/root
26                 $(STAGING_DIR)/bin/mkfs.jffs2 $(JFFS2OPTS) -e 0x20000 -o $(KDIR)/root.jffs2-128k -d $(BUILD_DIR)/root
27
28                 # add End-of-Filesystem markers
29                 echo -ne '\xde\xad\xc0\xde' >> $(KDIR)/root.jffs2-64k
30                 echo -ne '\xde\xad\xc0\xde' >> $(KDIR)/root.jffs2-128k
31         
32                 $(call Image/Build,jffs2-64k)
33                 $(call Image/Build,jffs2-128k)
34     endef
35   endif
36     
37   ifeq ($(CONFIG_TARGET_ROOTFS_SQUASHFS),y)
38     define Image/mkfs/squashfs
39                 @mkdir -p $(BUILD_DIR)/root/jffs
40                 $(STAGING_DIR)/bin/mksquashfs-lzma $(BUILD_DIR)/root $(KDIR)/root.squashfs -nopad -noappend -root-owned $(SQUASHFS_OPTS)
41                 $(call Image/Build,squashfs)
42     endef
43   endif
44     
45   ifeq ($(CONFIG_TARGET_ROOTFS_TGZ),y)
46     define Image/mkfs/tgz
47                 tar -zcf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-rootfs.tgz --owner=root --group=root -C $(BUILD_DIR)/root/ .
48     endef
49   endif
50   
51   
52 endif
53
54
55 ifeq ($(CONFIG_TARGET_ROOTFS_EXT2FS),y)
56   E2SIZE=$(shell echo $$(($(CONFIG_TARGET_ROOTFS_FSPART)*1024)))
57   
58   define Image/mkfs/ext2
59                 $(STAGING_DIR)/bin/genext2fs -q -b $(E2SIZE) -I 1500 -d $(BUILD_DIR)/root/ $(KDIR)/root.ext2
60                 $(call Image/Build,ext2)
61   endef
62 endif
63
64
65 define Image/mkfs/prepare/default
66         find $(BUILD_DIR)/root -type f -not -perm +0100 -not -name 'ssh_host*' | xargs chmod 0644
67         find $(BUILD_DIR)/root -type f -perm +0100 | xargs chmod 0755
68         find $(BUILD_DIR)/root -type d | xargs chmod 0755
69         mkdir -p $(BUILD_DIR)/root/tmp
70         chmod 0777 $(BUILD_DIR)/root/tmp
71 endef
72
73 define Image/mkfs/prepare
74         $(call Image/mkfs/prepare/default)
75 endef
76
77 define BuildImage
78 compile:
79         $(call Build/Compile)
80
81 install:
82         $(call Image/Prepare)
83         $(call Image/mkfs/prepare)
84         $(call Image/BuildKernel)
85         $(call Image/mkfs/jffs2)
86         $(call Image/mkfs/squashfs)
87         $(call Image/mkfs/tgz)
88         $(call Image/mkfs/ext2)
89         
90 clean:
91         $(call Build/Clean)
92 endef
93
94 compile-targets:
95 install-targets:
96 clean-targets:
97
98 download:
99 prepare:
100 compile: compile-targets
101 install: compile install-targets
102 clean: clean-targets