| 1 | if GRUB_ARCH == 'pc'
|
|---|
| 2 | MULTIBOOT_CMD = 'multiboot'
|
|---|
| 3 | MODULE_CMD = 'module'
|
|---|
| 4 | INSMODS = [ 'insmod vbe', 'insmod vga' ]
|
|---|
| 5 | elif GRUB_ARCH == 'efi'
|
|---|
| 6 | MULTIBOOT_CMD = 'multiboot2'
|
|---|
| 7 | MODULE_CMD = 'module2'
|
|---|
| 8 | INSMODS = [ 'insmod efi_gop', 'insmod efi_uga' ]
|
|---|
| 9 | endif
|
|---|
| 10 |
|
|---|
| 11 | # TODO
|
|---|
| 12 | install_snippet = 'mkdir -p ${DIST_DIR}/`dirname @1@`; cp @0@ ${DIST_DIR}/@1@'
|
|---|
| 13 | dist_dirname = 'grub_dist'
|
|---|
| 14 |
|
|---|
| 15 | if GRUB_LOADER == 'multiboot'
|
|---|
| 16 | build_dist_text = []
|
|---|
| 17 | build_dist_deps = []
|
|---|
| 18 | foreach init : rd_init_binaries
|
|---|
| 19 | target = 'boot/' + run_command(basename, init[1], check: true).stdout().strip()
|
|---|
| 20 |
|
|---|
| 21 | build_dist_text += install_snippet.format(init[0].full_path(), target)
|
|---|
| 22 | build_dist_deps += init[0]
|
|---|
| 23 | endforeach
|
|---|
| 24 |
|
|---|
| 25 | LOADS = [ 'echo \'Loading kernel\'' ]
|
|---|
| 26 | LOADS += [ MULTIBOOT_CMD + ' /boot/kernel.elf' ]
|
|---|
| 27 |
|
|---|
| 28 | MODULES = rd_init + [ 'boot/initrd.img' ]
|
|---|
| 29 |
|
|---|
| 30 | foreach module : MODULES
|
|---|
| 31 | module = '/boot/' + run_command(basename, module, check: true).stdout().strip()
|
|---|
| 32 | LOADS += 'echo \'Loading @0@\''.format(module)
|
|---|
| 33 | LOADS += '@0@ @1@ @1@'.format(MODULE_CMD, module)
|
|---|
| 34 | endforeach
|
|---|
| 35 | endif
|
|---|
| 36 |
|
|---|
| 37 | if GRUB_LOADER == 'chainloader'
|
|---|
| 38 | # init binaries are already part of the chainloaded boot image.
|
|---|
| 39 | build_dist_text = [ install_snippet.format(boot_image.full_path(), 'boot/' + boot_image_name) ]
|
|---|
| 40 | build_dist_deps = [ boot_image ]
|
|---|
| 41 |
|
|---|
| 42 | LOADS = [
|
|---|
| 43 | 'echo \'Loading ' + boot_image_name + '\'',
|
|---|
| 44 | 'chainloader /boot/' + boot_image_name,
|
|---|
| 45 | 'boot',
|
|---|
| 46 | ]
|
|---|
| 47 | endif
|
|---|
| 48 |
|
|---|
| 49 | build_dist_sh = configure_file(
|
|---|
| 50 | input: 'build_dist.sh.in',
|
|---|
| 51 | output: 'build_dist.sh',
|
|---|
| 52 | configuration: { 'text' : '\n'.join(build_dist_text) },
|
|---|
| 53 | )
|
|---|
| 54 |
|
|---|
| 55 |
|
|---|
| 56 | grub_cfg = configure_file(
|
|---|
| 57 | input: 'grub.cfg.in',
|
|---|
| 58 | output: 'grub.cfg',
|
|---|
| 59 | configuration: {
|
|---|
| 60 | 'INSMODS' : '\n'.join(INSMODS),
|
|---|
| 61 | 'RELEASE' : HELENOS_RELEASE,
|
|---|
| 62 | 'LOADS' : '\n'.join(LOADS),
|
|---|
| 63 | },
|
|---|
| 64 | )
|
|---|
| 65 |
|
|---|
| 66 | grub_dir = meson.current_source_dir() / BARCH + '-' + GRUB_ARCH
|
|---|
| 67 |
|
|---|
| 68 | dist_dir = custom_target(dist_dirname,
|
|---|
| 69 | output: dist_dirname,
|
|---|
| 70 | input: [ build_dist_sh, grub_cfg, build_dist_deps ],
|
|---|
| 71 | command: [ sh, '@INPUT0@', '@OUTPUT@', grub_dir, '@INPUT1@' ],
|
|---|
| 72 | )
|
|---|
| 73 |
|
|---|
| 74 |
|
|---|
| 75 | # Create .iso image.
|
|---|
| 76 |
|
|---|
| 77 | grub_image = 'boot/grub' / GRUB_ARCH + '.img'
|
|---|
| 78 |
|
|---|
| 79 | if GRUB_ARCH == 'pc'
|
|---|
| 80 | genisoimage_args = [ '-eltorito-boot', grub_image, '-no-emul-boot', '-boot-info-table' ]
|
|---|
| 81 | elif GRUB_ARCH == 'efi'
|
|---|
| 82 | genisoimage_args = [ '--efi-boot', grub_image ]
|
|---|
| 83 | endif
|
|---|
| 84 |
|
|---|
| 85 | image_iso = custom_target('image.iso',
|
|---|
| 86 | output: 'image.iso',
|
|---|
| 87 | input: dist_dir,
|
|---|
| 88 | command: [
|
|---|
| 89 | genisoimage,
|
|---|
| 90 | '-J',
|
|---|
| 91 | '-r',
|
|---|
| 92 | '-input-charset', 'utf-8',
|
|---|
| 93 | '-V', 'HelenOS-CD',
|
|---|
| 94 | genisoimage_args,
|
|---|
| 95 | '-o', '@OUTPUT@',
|
|---|
| 96 | '@INPUT@',
|
|---|
| 97 | ],
|
|---|
| 98 | )
|
|---|
| 99 |
|
|---|
| 100 | POST_INPUT = image_iso
|
|---|