fix targetinfo, packageinfo
[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 define add_jffs2_mark
21 echo -ne '\xde\xad\xc0\xde' >> $(1)
22 endef
23
24 # pad to 64k and add jffs2 end-of-filesystem mark
25 # do this twice to make sure that this works with 128k blocksize as well
26 define prepare_generic_squashfs
27 dd if=$(1) of=$(KDIR)/tmpfile.1 bs=64k conv=sync
28 $(call add_jffs2_mark,$(KDIR)/tmpfile.1)
29 dd of=$(1) if=$(KDIR)/tmpfile.1 bs=64k conv=sync
30 $(call add_jffs2_mark,$(1))
31 endef
32
33 ifneq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y)
34 ifeq ($(CONFIG_TARGET_ROOTFS_JFFS2),y)
35 define Image/mkfs/jffs2
36 rm -rf $(BUILD_DIR)/root/jffs
37
38 $(STAGING_DIR)/bin/mkfs.jffs2 $(JFFS2OPTS) -e 0x10000 -o $(KDIR)/root.jffs2-64k -d $(BUILD_DIR)/root
39 $(STAGING_DIR)/bin/mkfs.jffs2 $(JFFS2OPTS) -e 0x20000 -o $(KDIR)/root.jffs2-128k -d $(BUILD_DIR)/root
40
41
42 # add End-of-Filesystem markers
43 $(call add_jffs2_mark,$(KDIR)/root.jffs2-64k)
44 $(call add_jffs2_mark,$(KDIR)/root.jffs2-128k)
45
46 $(call Image/Build,jffs2-64k)
47 $(call Image/Build,jffs2-128k)
48 endef
49 endif
50
51 ifeq ($(CONFIG_TARGET_ROOTFS_SQUASHFS),y)
52 define Image/mkfs/squashfs
53 @mkdir -p $(BUILD_DIR)/root/jffs
54 $(STAGING_DIR)/bin/mksquashfs-lzma $(BUILD_DIR)/root $(KDIR)/root.squashfs -nopad -noappend -root-owned $(SQUASHFS_OPTS)
55 $(call Image/Build,squashfs)
56 endef
57 endif
58
59 ifeq ($(CONFIG_TARGET_ROOTFS_TGZ),y)
60 define Image/mkfs/tgz
61 tar -zcf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-rootfs.tgz --owner=root --group=root -C $(BUILD_DIR)/root/ .
62 endef
63 endif
64 else
65 define Image/BuildKernel
66 cp $(KDIR)/vmlinux.elf $(BIN_DIR)/openwrt-$(BOARD)-$(KERNEL)-vmlinux.elf
67 endef
68 endif
69
70
71 ifeq ($(CONFIG_TARGET_ROOTFS_EXT2FS),y)
72 E2SIZE=$(shell echo $$(($(CONFIG_TARGET_ROOTFS_FSPART)*1024)))
73
74 define Image/mkfs/ext2
75 $(STAGING_DIR)/bin/genext2fs -U -b $(E2SIZE) -I $(CONFIG_TARGET_ROOTFS_MAXINODE) -d $(BUILD_DIR)/root/ $(KDIR)/root.ext2
76 $(call Image/Build,ext2)
77 endef
78 endif
79
80
81 define Image/mkfs/prepare/default
82 find $(BUILD_DIR)/root -type f -not -perm +0100 -not -name 'ssh_host*' -exec chmod 0644 {} \;
83 find $(BUILD_DIR)/root -type f -perm +0100 -exec chmod 0755 {} \;
84 find $(BUILD_DIR)/root -type d -exec chmod 0755 {} \;
85 mkdir -p $(BUILD_DIR)/root/tmp
86 chmod 0777 $(BUILD_DIR)/root/tmp
87 endef
88
89 define Image/mkfs/prepare
90 $(call Image/mkfs/prepare/default)
91 endef
92
93 define BuildImage
94 download:
95 prepare:
96 ifneq ($(IB),1)
97 compile: compile-targets
98 $(call Build/Compile)
99 else
100 compile:
101 endif
102
103 ifneq ($(IB),1)
104 install: compile install-targets
105 $(call Image/Prepare)
106 $(call Image/mkfs/prepare)
107 $(call Image/BuildKernel)
108 $(call Image/mkfs/jffs2)
109 $(call Image/mkfs/squashfs)
110 $(call Image/mkfs/tgz)
111 $(call Image/mkfs/ext2)
112 else
113 install: compile install-targets
114 $(call Image/BuildKernel)
115 $(call Image/mkfs/jffs2)
116 $(call Image/mkfs/squashfs)
117 $(call Image/mkfs/tgz)
118 $(call Image/mkfs/ext2)
119 endif
120
121 ifneq ($(IB),1)
122 clean: clean-targets
123 $(call Build/Clean)
124 else
125 clean:
126 endif
127
128 compile-targets:
129 install-targets:
130 clean-targets:
131 endef
132
133
This page took 0.043018 seconds and 5 git commands to generate.