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