]>
Commit | Line | Data |
---|---|---|
db9ecf05 | 1 | # SPDX-License-Identifier: LGPL-2.1-or-later |
3a726fcd | 2 | |
776fabbc ZJS |
3 | efi_config_h_dir = meson.current_build_dir() |
4 | ||
dfca5587 | 5 | if conf.get('ENABLE_BOOTLOADER') != 1 |
9cf75222 JJ |
6 | subdir_done() |
7 | endif | |
8 | ||
9cf75222 | 9 | efi_conf = configuration_data() |
9cf75222 JJ |
10 | efi_conf.set10('ENABLE_TPM', get_option('tpm')) |
11 | ||
12 | foreach ctype : ['color-normal', 'color-entry', 'color-highlight', 'color-edit'] | |
13 | c = get_option('efi-' + ctype).split(',') | |
14 | efi_conf.set(ctype.underscorify().to_upper(), 'EFI_TEXT_ATTR(@0@, @1@)'.format( | |
15 | 'EFI_' + c[0].strip().underscorify().to_upper(), | |
16 | 'EFI_' + c[1].strip().underscorify().to_upper())) | |
17 | endforeach | |
18 | ||
252b6b1b JJ |
19 | if meson.is_cross_build() and get_option('sbat-distro') == 'auto' |
20 | warning('Auto detection of SBAT information not supported when cross-building, disabling SBAT.') | |
21 | elif get_option('sbat-distro') != '' | |
9cf75222 JJ |
22 | efi_conf.set_quoted('SBAT_PROJECT', meson.project_name()) |
23 | efi_conf.set_quoted('PROJECT_VERSION', meson.project_version()) | |
24 | efi_conf.set('PROJECT_URL', conf.get('PROJECT_URL')) | |
25 | if get_option('sbat-distro-generation') < 1 | |
26 | error('SBAT Distro Generation must be a positive integer') | |
df7cacae | 27 | endif |
9cf75222 JJ |
28 | efi_conf.set('SBAT_DISTRO_GENERATION', get_option('sbat-distro-generation')) |
29 | foreach sbatvar : [['sbat-distro', 'ID'], | |
30 | ['sbat-distro-summary', 'NAME'], | |
31 | ['sbat-distro-url', 'BUG_REPORT_URL']] | |
32 | value = get_option(sbatvar[0]) | |
252b6b1b | 33 | if (value == '' or value == 'auto') and not meson.is_cross_build() |
9cf75222 | 34 | cmd = 'if [ -e /etc/os-release ]; then . /etc/os-release; else . /usr/lib/os-release; fi; echo $@0@'.format(sbatvar[1]) |
68a06b3c | 35 | value = run_command(sh, '-c', cmd, check: true).stdout().strip() |
4b4ee0f7 | 36 | endif |
9cf75222 JJ |
37 | if value == '' |
38 | error('Required @0@ option not set and autodetection failed'.format(sbatvar[0])) | |
53f69d67 | 39 | endif |
9cf75222 | 40 | efi_conf.set_quoted(sbatvar[0].underscorify().to_upper(), value) |
e313e934 JJ |
41 | endforeach |
42 | ||
9cf75222 JJ |
43 | pkgname = get_option('sbat-distro-pkgname') |
44 | if pkgname == '' | |
45 | pkgname = meson.project_name() | |
9137c03c | 46 | endif |
9cf75222 | 47 | efi_conf.set_quoted('SBAT_DISTRO_PKGNAME', pkgname) |
9137c03c | 48 | |
9cf75222 JJ |
49 | pkgver = get_option('sbat-distro-version') |
50 | if pkgver == '' | |
51 | efi_conf.set('SBAT_DISTRO_VERSION', 'GIT_VERSION') | |
e4e44a01 ZJS |
52 | # This is determined during build, not configuration, so we can't display it yet. |
53 | sbat_distro_version_display = '(git version)' | |
9cf75222 JJ |
54 | else |
55 | efi_conf.set_quoted('SBAT_DISTRO_VERSION', pkgver) | |
e4e44a01 | 56 | sbat_distro_version_display = pkgver |
37efbbd8 | 57 | endif |
ce4121c6 | 58 | endif |
37efbbd8 | 59 | |
dfca5587 JJ |
60 | summary({'UEFI architecture' : efi_arch}, |
61 | section : 'UEFI') | |
3f871f12 | 62 | |
e4e44a01 ZJS |
63 | if efi_conf.get('SBAT_DISTRO', '') != '' |
64 | summary({ | |
65 | 'SBAT distro': efi_conf.get('SBAT_DISTRO'), | |
66 | 'SBAT distro generation': efi_conf.get('SBAT_DISTRO_GENERATION'), | |
67 | 'SBAT distro version': sbat_distro_version_display, | |
68 | 'SBAT distro summary': efi_conf.get('SBAT_DISTRO_SUMMARY'), | |
69 | 'SBAT distro URL': efi_conf.get('SBAT_DISTRO_URL')}, | |
dfca5587 | 70 | section : 'UEFI') |
e4e44a01 ZJS |
71 | endif |
72 | ||
dfca5587 JJ |
73 | configure_file( |
74 | output : 'efi_config.h', | |
75 | configuration : efi_conf) | |
65dcf9f9 | 76 | |
dfca5587 | 77 | ############################################################ |
65dcf9f9 | 78 | |
dfca5587 | 79 | libefi_sources = files( |
e6b0cfad | 80 | 'console.c', |
e6d7dc9a | 81 | 'device-path-util.c', |
65dcf9f9 | 82 | 'devicetree.c', |
ba279392 | 83 | 'drivers.c', |
9080ffd4 | 84 | 'efi-string.c', |
65dcf9f9 | 85 | 'graphics.c', |
46ce6cf7 | 86 | 'initrd.c', |
c2c62035 | 87 | 'log.c', |
65dcf9f9 | 88 | 'measure.c', |
0a1d8ac7 | 89 | 'part-discovery.c', |
65dcf9f9 | 90 | 'pe.c', |
0a1d8ac7 | 91 | 'random-seed.c', |
65dcf9f9 | 92 | 'secure-boot.c', |
1e66a233 | 93 | 'ticks.c', |
b3c5a707 | 94 | 'util.c', |
ba279392 | 95 | 'vmm.c', |
b3c5a707 | 96 | ) |
65dcf9f9 | 97 | |
b3c5a707 | 98 | systemd_boot_sources = files( |
65dcf9f9 | 99 | 'boot.c', |
65dcf9f9 | 100 | 'shim.c', |
b3c5a707 | 101 | ) |
65dcf9f9 | 102 | |
b3c5a707 | 103 | stub_sources = files( |
65dcf9f9 | 104 | 'cpio.c', |
ba2a105c | 105 | 'linux.c', |
65dcf9f9 | 106 | 'splash.c', |
b3c5a707 JJ |
107 | 'stub.c', |
108 | ) | |
65dcf9f9 | 109 | |
dfca5587 | 110 | if host_machine.cpu_family() in ['x86', 'x86_64'] |
b3c5a707 | 111 | stub_sources += files('linux_x86.c') |
65dcf9f9 ZJS |
112 | endif |
113 | ||
9080ffd4 | 114 | tests += [ |
822cd3ff JJ |
115 | { |
116 | 'sources' : files( | |
117 | 'test-efi-string.c', | |
118 | 'efi-string.c', | |
119 | ) | |
120 | }, | |
9080ffd4 JJ |
121 | ] |
122 | ||
77fcf28c | 123 | # BCD parser only makes sense on arches that Windows supports. |
dfca5587 | 124 | if host_machine.cpu_family() in ['aarch64', 'arm', 'x86_64', 'x86'] |
b3c5a707 | 125 | systemd_boot_sources += files('bcd.c') |
77fcf28c | 126 | tests += [ |
822cd3ff JJ |
127 | { |
128 | 'sources' : files( | |
129 | 'test-bcd.c', | |
130 | 'efi-string.c', | |
131 | ), | |
132 | 'dependencies' : libzstd, | |
133 | 'condition' : 'HAVE_ZSTD', | |
134 | }, | |
77fcf28c | 135 | ] |
4b65fc87 | 136 | fuzzers += [ |
2ed35b2f JJ |
137 | { |
138 | 'sources' : files( | |
139 | 'fuzz-bcd.c', | |
140 | 'bcd.c', | |
141 | 'efi-string.c' | |
142 | ), | |
143 | }, | |
144 | { | |
145 | 'sources' : files( | |
146 | 'fuzz-efi-string.c', | |
147 | 'efi-string.c' | |
148 | ), | |
149 | }, | |
150 | { | |
151 | 'sources' : files( | |
152 | 'fuzz-efi-printf.c', | |
153 | 'efi-string.c' | |
154 | ), | |
155 | }, | |
4b65fc87 | 156 | ] |
77fcf28c | 157 | endif |