OpenWrt – Blame information for rev 3
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | office | 1 | # |
2 | # Copyright (C) 2006-2012 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 | export PATH=$(TARGET_PATH):/sbin |
||
11 | |||
3 | office | 12 | GRUB2_MODULES = biosdisk boot chain configfile ext2 linux ls part_msdos reboot serial vga |
13 | GRUB2_MODULES_ISO = biosdisk boot chain configfile iso9660 linux ls part_msdos reboot serial vga |
||
1 | office | 14 | GRUB_TERMINALS = |
15 | GRUB_SERIAL_CONFIG = |
||
16 | GRUB_TERMINAL_CONFIG = |
||
17 | GRUB_CONSOLE_CMDLINE = |
||
3 | office | 18 | GRUB_ROOT = hd0,msdos1 |
1 | office | 19 | |
20 | USE_ATKBD = generic 64 |
||
21 | |||
22 | ifneq ($(strip $(foreach subtarget,$(USE_ATKBD),$(CONFIG_TARGET_x86_$(subtarget)))),) |
||
23 | GRUB2_MODULES += at_keyboard |
||
24 | GRUB2_MODULES_ISO += at_keyboard |
||
25 | endif |
||
26 | |||
27 | ifneq ($(CONFIG_GRUB_CONSOLE),) |
||
28 | GRUB_CONSOLE_CMDLINE += console=tty0 |
||
29 | GRUB_TERMINALS += console |
||
30 | endif |
||
31 | |||
32 | GRUB_SERIAL:=$(call qstrip,$(CONFIG_GRUB_SERIAL)) |
||
33 | |||
34 | ifneq ($(GRUB_SERIAL),) |
||
35 | GRUB_CONSOLE_CMDLINE += console=$(GRUB_SERIAL),$(CONFIG_GRUB_BAUDRATE)n8$(if $(CONFIG_GRUB_FLOWCONTROL),r,) |
||
36 | GRUB_SERIAL_CONFIG := serial --unit=0 --speed=$(CONFIG_GRUB_BAUDRATE) --word=8 --parity=no --stop=1 --rtscts=$(if $(CONFIG_GRUB_FLOWCONTROL),on,off) |
||
37 | GRUB_TERMINALS += serial |
||
38 | endif |
||
39 | |||
40 | ifneq ($(GRUB_TERMINALS),) |
||
41 | GRUB_TERMINAL_CONFIG := terminal_input $(GRUB_TERMINALS); terminal_output $(GRUB_TERMINALS) |
||
42 | endif |
||
43 | |||
44 | SIGNATURE:=$(shell perl -e 'printf("%08x", rand(0xFFFFFFFF))') |
||
45 | ROOTPART:=$(call qstrip,$(CONFIG_TARGET_ROOTFS_PARTNAME)) |
||
46 | ROOTPART:=$(if $(ROOTPART),$(ROOTPART),PARTUUID=$(SIGNATURE)-02) |
||
47 | |||
48 | GRUB_TIMEOUT:=$(call qstrip,$(CONFIG_GRUB_TIMEOUT)) |
||
49 | |||
3 | office | 50 | ifneq ($(CONFIG_TARGET_x86_xen_domu),) |
51 | GRUB_ROOT = xen/xvda,msdos1 |
||
52 | endif |
||
53 | |||
1 | office | 54 | ifneq ($(CONFIG_GRUB_IMAGES),) |
55 | |||
56 | BOOTOPTS:=$(call qstrip,$(CONFIG_GRUB_BOOTOPTS)) |
||
57 | |||
58 | define Image/cmdline/ext4 |
||
59 | root=$(ROOTPART) rootfstype=ext4 rootwait |
||
60 | endef |
||
61 | |||
62 | define Image/cmdline/squashfs |
||
63 | root=$(ROOTPART) rootfstype=squashfs rootwait |
||
64 | endef |
||
65 | |||
66 | define Image/Build/grub2 |
||
67 | # left here because the image builder doesnt need these |
||
68 | $(INSTALL_DIR) $(KDIR)/root.grub/boot/grub $(KDIR)/grub2 |
||
69 | $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz |
||
70 | grub-mkimage \ |
||
71 | -p /boot/grub \ |
||
72 | -d $(STAGING_DIR_HOST)/lib/grub/i386-pc \ |
||
73 | -o $(KDIR)/grub2/core.img \ |
||
74 | -O i386-pc \ |
||
75 | -c ./grub-early.cfg \ |
||
76 | $(GRUB2_MODULES) |
||
77 | $(CP) $(STAGING_DIR_HOST)/lib/grub/i386-pc/*.img $(KDIR)/grub2/ |
||
78 | echo '(hd0) $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img' > $(KDIR)/grub2/device.map |
||
79 | sed \ |
||
80 | -e 's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \ |
||
81 | -e 's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \ |
||
82 | -e 's#@CMDLINE@#$(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \ |
||
83 | -e 's#@TIMEOUT@#$(GRUB_TIMEOUT)#g' \ |
||
3 | office | 84 | -e 's#@ROOT@#$(GRUB_ROOT)#g' \ |
1 | office | 85 | ./grub.cfg > $(KDIR)/root.grub/boot/grub/grub.cfg |
86 | PADDING="$(CONFIG_TARGET_IMAGES_PAD)" SIGNATURE="$(SIGNATURE)" PATH="$(TARGET_PATH)" $(SCRIPT_DIR)/gen_image_generic.sh \ |
||
87 | $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img \ |
||
88 | $(CONFIG_TARGET_KERNEL_PARTSIZE) $(KDIR)/root.grub \ |
||
89 | $(CONFIG_TARGET_ROOTFS_PARTSIZE) $(KDIR)/root.$(1) \ |
||
90 | 256 |
||
91 | grub-bios-setup \ |
||
92 | --device-map="$(KDIR)/grub2/device.map" \ |
||
93 | -d "$(KDIR)/grub2" \ |
||
94 | -r "hd0,msdos1" \ |
||
95 | "$(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img" |
||
96 | endef |
||
97 | endif |
||
98 | |||
99 | define Image/Build/squashfs |
||
100 | dd if=/dev/zero bs=128k count=1 >> $(KDIR)/root.squashfs |
||
101 | endef |
||
102 | |||
103 | define Image/Build/iso |
||
104 | $(INSTALL_DIR) $(KDIR)/root.grub/boot/grub $(KDIR)/grub2 |
||
105 | $(CP) $(KDIR)/bzImage $(KDIR)/root.grub/boot/vmlinuz |
||
106 | grub-mkimage \ |
||
107 | -p /boot/grub \ |
||
108 | -d $(STAGING_DIR_HOST)/lib/grub/i386-pc \ |
||
109 | -o $(KDIR)/grub2/eltorito.img \ |
||
110 | -O i386-pc \ |
||
111 | -c ./grub-early.cfg \ |
||
112 | $(GRUB2_MODULES_ISO) |
||
113 | cat \ |
||
114 | $(STAGING_DIR_HOST)/lib/grub/i386-pc/cdboot.img \ |
||
115 | $(KDIR)/grub2/eltorito.img \ |
||
116 | > $(KDIR)/root.grub/boot/grub/eltorito.img |
||
117 | sed \ |
||
118 | -e 's#@SERIAL_CONFIG@#$(strip $(GRUB_SERIAL_CONFIG))#g' \ |
||
119 | -e 's#@TERMINAL_CONFIG@#$(strip $(GRUB_TERMINAL_CONFIG))#g' \ |
||
120 | -e 's#@CMDLINE@#root=/dev/sr0 rootfstype=iso9660 rootwait $(strip $(call Image/cmdline/$(1)) $(BOOTOPTS) $(GRUB_CONSOLE_CMDLINE))#g' \ |
||
121 | -e 's#@TIMEOUT@#$(GRUB_TIMEOUT)#g' \ |
||
122 | ./grub-iso.cfg > $(KDIR)/root.grub/boot/grub/grub.cfg |
||
123 | mkisofs -R -b boot/grub/eltorito.img -no-emul-boot -boot-info-table \ |
||
124 | -o $(KDIR)/root.iso $(KDIR)/root.grub $(TARGET_DIR) |
||
125 | endef |
||
126 | |||
127 | ifneq ($(CONFIG_VDI_IMAGES),) |
||
128 | define Image/Build/vdi |
||
129 | rm $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).vdi || true |
||
130 | qemu-img convert -f raw -O vdi \ |
||
131 | $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img \ |
||
132 | $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).vdi |
||
3 | office | 133 | # XXX: VBoxManage insists on setting perms to 0600 |
134 | chmod 0644 $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).vdi |
||
1 | office | 135 | endef |
136 | endif |
||
137 | |||
138 | ifneq ($(CONFIG_VMDK_IMAGES),) |
||
139 | define Image/Build/vmdk |
||
140 | rm $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).vmdk || true |
||
141 | qemu-img convert -f raw -O vmdk \ |
||
142 | $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img \ |
||
143 | $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).vmdk |
||
144 | endef |
||
145 | endif |
||
146 | |||
147 | define Image/Build/gzip |
||
148 | gzip -f9n $(BIN_DIR)/$(IMG_PREFIX)-combined-$(1).img |
||
149 | gzip -f9n $(BIN_DIR)/$(IMG_PREFIX)-rootfs-$(1).img |
||
150 | endef |
||
151 | |||
152 | ifneq ($(CONFIG_TARGET_IMAGES_GZIP),) |
||
153 | define Image/Build/gzip/ext4 |
||
154 | $(call Image/Build/gzip,ext4) |
||
155 | endef |
||
156 | define Image/Build/gzip/squashfs |
||
157 | $(call Image/Build/gzip,squashfs) |
||
158 | endef |
||
159 | endif |
||
160 | |||
161 | define Image/BuildKernel |
||
162 | $(CP) $(KDIR)/bzImage $(BIN_DIR)/$(IMG_PREFIX)-vmlinuz |
||
163 | endef |
||
164 | |||
165 | define Image/Prepare |
||
166 | $(call Image/Prepare/grub2) |
||
167 | endef |
||
168 | |||
169 | define Image/Build/Initramfs |
||
170 | $(CP) $(KDIR)/bzImage-initramfs $(BIN_DIR)/$(IMG_PREFIX)-ramfs.bzImage |
||
171 | endef |
||
172 | |||
173 | define Image/Build |
||
174 | $(call Image/Build/$(1)) |
||
175 | ifneq ($(1),iso) |
||
176 | $(call Image/Build/grub2,$(1)) |
||
177 | $(call Image/Build/vdi,$(1)) |
||
178 | $(call Image/Build/vmdk,$(1)) |
||
179 | $(CP) $(KDIR)/root.$(1) $(BIN_DIR)/$(IMG_PREFIX)-rootfs-$(1).img |
||
180 | else |
||
181 | $(CP) $(KDIR)/root.iso $(BIN_DIR)/$(IMG_PREFIX).iso |
||
182 | endif |
||
183 | $(CP) $(KDIR)/bzImage $(BIN_DIR)/$(IMG_PREFIX)-vmlinuz |
||
184 | $(call Image/Build/gzip/$(1)) |
||
185 | ifeq ($(CONFIG_TARGET_ROOTFS_INITRAMFS),y) |
||
186 | $(call Image/Build/Initramfs) |
||
187 | endif |
||
188 | endef |
||
189 | |||
190 | $(eval $(call BuildImage)) |