source: mainline/boot/grub/meson.build@ 1a1271d

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since 1a1271d was c21d4d6, checked in by Jiří Zárevúcky <zarevucky.jiri@…>, 6 years ago

Add copyright headers for new files

Most are a copy of the headers that were present in original Makefiles.

  • Property mode set to 100644
File size: 3.8 KB
Line 
1#
2# Copyright (c) 2019 Jiří Zárevúcky
3# All rights reserved.
4#
5# Redistribution and use in source and binary forms, with or without
6# modification, are permitted provided that the following conditions
7# are met:
8#
9# - Redistributions of source code must retain the above copyright
10# notice, this list of conditions and the following disclaimer.
11# - Redistributions in binary form must reproduce the above copyright
12# notice, this list of conditions and the following disclaimer in the
13# documentation and/or other materials provided with the distribution.
14# - The name of the author may not be used to endorse or promote products
15# derived from this software without specific prior written permission.
16#
17# THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18# IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20# IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22# NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23# DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24# THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25# (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26# THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27#
28
29if GRUB_ARCH == 'pc'
30 MULTIBOOT_CMD = 'multiboot'
31 MODULE_CMD = 'module'
32 INSMODS = [ 'insmod vbe', 'insmod vga' ]
33elif GRUB_ARCH == 'efi'
34 MULTIBOOT_CMD = 'multiboot2'
35 MODULE_CMD = 'module2'
36 INSMODS = [ 'insmod efi_gop', 'insmod efi_uga' ]
37endif
38
39# TODO
40install_snippet = 'mkdir -p ${DIST_DIR}/`dirname @1@`; cp @0@ ${DIST_DIR}/@1@'
41dist_dirname = 'grub_dist'
42
43if GRUB_LOADER == 'multiboot'
44 build_dist_text = []
45 build_dist_deps = []
46 foreach init : rd_init_binaries
47 target = 'boot/' + run_command(basename, init[1], check: true).stdout().strip()
48
49 build_dist_text += install_snippet.format(init[0].full_path(), target)
50 build_dist_deps += init[0]
51 endforeach
52
53 LOADS = [ 'echo \'Loading kernel\'' ]
54 LOADS += [ MULTIBOOT_CMD + ' /boot/kernel.elf' ]
55
56 MODULES = rd_init + [ 'boot/initrd.img' ]
57
58 foreach module : MODULES
59 module = '/boot/' + run_command(basename, module, check: true).stdout().strip()
60 LOADS += 'echo \'Loading @0@\''.format(module)
61 LOADS += '@0@ @1@ @1@'.format(MODULE_CMD, module)
62 endforeach
63endif
64
65if GRUB_LOADER == 'chainloader'
66 # init binaries are already part of the chainloaded boot image.
67 build_dist_text = [ install_snippet.format(boot_image.full_path(), 'boot/' + boot_image_name) ]
68 build_dist_deps = [ boot_image ]
69
70 LOADS = [
71 'echo \'Loading ' + boot_image_name + '\'',
72 'chainloader /boot/' + boot_image_name,
73 'boot',
74 ]
75endif
76
77build_dist_sh = configure_file(
78 input: 'build_dist.sh.in',
79 output: 'build_dist.sh',
80 configuration: { 'text' : '\n'.join(build_dist_text) },
81)
82
83
84grub_cfg = configure_file(
85 input: 'grub.cfg.in',
86 output: 'grub.cfg',
87 configuration: {
88 'INSMODS' : '\n'.join(INSMODS),
89 'RELEASE' : HELENOS_RELEASE,
90 'LOADS' : '\n'.join(LOADS),
91 },
92)
93
94grub_dir = meson.current_source_dir() / BARCH + '-' + GRUB_ARCH
95
96dist_dir = custom_target(dist_dirname,
97 output: dist_dirname,
98 input: [ build_dist_sh, grub_cfg, build_dist_deps ],
99 command: [ sh, '@INPUT0@', '@OUTPUT@', grub_dir, '@INPUT1@' ],
100)
101
102
103# Create .iso image.
104
105grub_image = 'boot/grub' / GRUB_ARCH + '.img'
106
107if GRUB_ARCH == 'pc'
108 genisoimage_args = [ '-eltorito-boot', grub_image, '-no-emul-boot', '-boot-info-table' ]
109elif GRUB_ARCH == 'efi'
110 genisoimage_args = [ '--efi-boot', grub_image ]
111endif
112
113image_iso = custom_target('image.iso',
114 output: 'image.iso',
115 input: dist_dir,
116 command: [
117 genisoimage,
118 '-J',
119 '-r',
120 '-input-charset', 'utf-8',
121 '-V', 'HelenOS-CD',
122 genisoimage_args,
123 '-o', '@OUTPUT@',
124 '@INPUT@',
125 ],
126)
127
128POST_INPUT = image_iso
Note: See TracBrowser for help on using the repository browser.