Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 1 | project('flashromutils', 'c', |
Nikolai Artemiev | 47cb6fc | 2022-07-22 09:58:14 +1000 | [diff] [blame] | 2 | version : run_command('util/getversion.sh', '--version', check : true).stdout().strip(), |
Nico Huber | b417c0c | 2019-09-24 22:12:40 +0200 | [diff] [blame] | 3 | license : 'GPL-2.0', |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 4 | meson_version : '>=0.53.0', |
Anastasia Klimchuk | 3c50843 | 2022-04-13 15:15:24 +1000 | [diff] [blame] | 5 | default_options : [ |
| 6 | 'warning_level=2', |
| 7 | 'c_std=c99', |
Anastasia Klimchuk | c676be9 | 2022-04-26 14:53:18 +1000 | [diff] [blame] | 8 | 'werror=true', |
Anastasia Klimchuk | 3c50843 | 2022-04-13 15:15:24 +1000 | [diff] [blame] | 9 | 'optimization=s', |
Nikolai Artemiev | 47cb6fc | 2022-07-22 09:58:14 +1000 | [diff] [blame] | 10 | 'debug=false', |
| 11 | ], |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 12 | ) |
| 13 | |
| 14 | # libtool versioning |
| 15 | lt_current = '1' |
| 16 | lt_revision = '0' |
| 17 | lt_age = '0' |
| 18 | lt_version = '@0@.@1@.@2@'.format(lt_current, lt_age, lt_revision) |
| 19 | |
Jacob Garber | 4a84ec2 | 2019-07-25 19:12:31 -0600 | [diff] [blame] | 20 | # hide/enable some warnings |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 21 | warning_flags = [ |
Anastasia Klimchuk | cde7011 | 2021-10-25 13:20:26 +1100 | [diff] [blame] | 22 | '-Wshadow', |
| 23 | '-Wmissing-prototypes', |
Jacob Garber | 4a84ec2 | 2019-07-25 19:12:31 -0600 | [diff] [blame] | 24 | '-Wwrite-strings', |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 25 | '-Wno-unused-parameter', |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 26 | '-Wno-address-of-packed-member', |
| 27 | '-Wno-enum-conversion', |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 28 | '-Wno-missing-braces', |
| 29 | ] |
| 30 | |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 31 | cc = meson.get_compiler('c') |
| 32 | add_project_arguments(cc.get_supported_arguments(warning_flags), language : 'c') |
| 33 | add_project_arguments('-D_DEFAULT_SOURCE', language : 'c') |
Rosen Penev | 566193f | 2020-07-18 12:50:16 -0700 | [diff] [blame] | 34 | add_project_arguments('-D_POSIX_C_SOURCE=200809L', language : 'c') # required for fileno, nanosleep, and strndup |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 35 | add_project_arguments('-D_BSD_SOURCE', language : 'c') # required for glibc < v2.19 |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 36 | add_project_arguments('-D__BSD_VISIBLE', language : 'c') # required for u_char, u_int, u_long on FreeBSD |
| 37 | add_project_arguments('-D__XSI_VISIBLE', language : 'c') # required for gettimeofday() on FreeBSD |
| 38 | add_project_arguments('-D_NETBSD_SOURCE', language : 'c') # required for indirect include of strings.h on NetBSD |
| 39 | add_project_arguments('-D_DARWIN_C_SOURCE', language : 'c') # required for indirect include of strings.h on MacOS |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 40 | add_project_arguments('-DFLASHROM_VERSION="' + meson.project_version() + '"', language : 'c') |
| 41 | |
| 42 | # get defaults from configure |
Thomas Heijligen | b975da1 | 2022-08-13 12:10:05 +0200 | [diff] [blame] | 43 | config_print_wiki = get_option('classic_cli_print_wiki') |
Thomas Heijligen | 84e9c91 | 2021-06-01 16:22:14 +0200 | [diff] [blame] | 44 | config_default_programmer_name = get_option('default_programmer_name') |
| 45 | config_default_programmer_args = get_option('default_programmer_args') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 46 | |
| 47 | cargs = [] |
| 48 | deps = [] |
Thomas Heijligen | 51208f3 | 2022-04-28 11:07:29 +0200 | [diff] [blame] | 49 | srcs = files( |
| 50 | '82802ab.c', |
| 51 | 'at45db.c', |
| 52 | 'bitbang_spi.c', |
| 53 | 'edi.c', |
| 54 | 'en29lv640b.c', |
| 55 | 'flashchips.c', |
| 56 | 'flashrom.c', |
| 57 | 'fmap.c', |
| 58 | 'helpers.c', |
Edward O'Callaghan | 4c76c73 | 2022-08-12 11:03:00 +1000 | [diff] [blame] | 59 | 'helpers_fileio.c', |
Thomas Heijligen | 51208f3 | 2022-04-28 11:07:29 +0200 | [diff] [blame] | 60 | 'ich_descriptors.c', |
| 61 | 'jedec.c', |
| 62 | 'layout.c', |
| 63 | 'libflashrom.c', |
| 64 | 'opaque.c', |
Edward O'Callaghan | 63f6a37 | 2022-08-12 12:56:43 +1000 | [diff] [blame] | 65 | 'parallel.c', |
Thomas Heijligen | 51208f3 | 2022-04-28 11:07:29 +0200 | [diff] [blame] | 66 | 'print.c', |
| 67 | 'programmer.c', |
| 68 | 'programmer_table.c', |
| 69 | 'sfdp.c', |
| 70 | 'spi25.c', |
| 71 | 'spi25_statusreg.c', |
| 72 | 'spi95.c', |
| 73 | 'spi.c', |
| 74 | 'sst28sf040.c', |
| 75 | 'sst49lfxxxc.c', |
| 76 | 'sst_fwhub.c', |
| 77 | 'stm50.c', |
| 78 | 'udelay.c', |
| 79 | 'w29ee011.c', |
| 80 | 'w39.c', |
| 81 | 'writeprotect.c', |
| 82 | 'writeprotect_ranges.c', |
| 83 | ) |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 84 | |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 85 | # check for required symbols |
| 86 | if cc.has_function('clock_gettime') |
| 87 | add_project_arguments('-DHAVE_CLOCK_GETTIME=1', language : 'c') |
| 88 | endif |
| 89 | if cc.has_function('strnlen') |
| 90 | add_project_arguments('-DHAVE_STRNLEN=1', language : 'c') |
| 91 | endif |
| 92 | if cc.check_header('sys/utsname.h') |
| 93 | add_project_arguments('-DHAVE_UTSNAME=1', language : 'c') |
| 94 | endif |
Thomas Heijligen | c02b1a9 | 2022-04-25 14:54:10 +0200 | [diff] [blame] | 95 | if host_machine.system() in ['cygwin', 'windows'] |
| 96 | add_project_arguments('-DIS_WINDOWS=1', language : 'c') |
| 97 | else |
| 98 | add_project_arguments('-DIS_WINDOWS=0', language : 'c') |
| 99 | endif |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 100 | |
Peter Stuge | 272b073 | 2022-12-11 03:55:02 +0100 | [diff] [blame] | 101 | if host_machine.system() == 'linux' |
| 102 | custom_baud_c = 'custom_baud_linux.c' |
Peter Stuge | b8ee2d6 | 2022-12-11 16:20:16 +0100 | [diff] [blame] | 103 | elif host_machine.system() == 'darwin' |
| 104 | custom_baud_c = 'custom_baud_darwin.c' |
Peter Stuge | 272b073 | 2022-12-11 03:55:02 +0100 | [diff] [blame] | 105 | else |
| 106 | custom_baud_c = 'custom_baud.c' |
| 107 | endif |
| 108 | |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 109 | systems_hwaccess = [ 'linux', 'openbsd', 'freebsd', 'dragonfly', 'netbsd' ] |
| 110 | systems_serial = [ 'linux', 'openbsd', 'freebsd', 'dragonfly', 'netbsd', 'darwin' ] |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 111 | |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 112 | cpus_port_io = [ 'x86', 'x86_64' ] |
Peter Marheine | 306c8b7 | 2022-01-21 02:07:30 +0000 | [diff] [blame] | 113 | |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 114 | group_ftdi = get_option('programmer').contains('group_ftdi') |
| 115 | group_pci = get_option('programmer').contains('group_pci') |
| 116 | group_usb = get_option('programmer').contains('group_usb') |
| 117 | group_i2c = get_option('programmer').contains('group_i2c') |
| 118 | group_serial = get_option('programmer').contains('group_serial') |
| 119 | group_jlink = get_option('programmer').contains('group_jlink') |
Steve Markgraf | 6189947 | 2023-01-09 23:06:52 +0100 | [diff] [blame] | 120 | group_gpiod = get_option('programmer').contains('group_gpiod') |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 121 | group_internal = get_option('programmer').contains('group_internal') |
| 122 | group_external = get_option('programmer').contains('group_external') |
Peter Marheine | 306c8b7 | 2022-01-21 02:07:30 +0000 | [diff] [blame] | 123 | |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 124 | libpci = dependency('libpci', required : group_pci, static : (host_machine.system() == 'openbsd' ? true : false)) # On openbsd a static version of libpci is needed to get also -libz |
| 125 | libusb1 = dependency('libusb-1.0', required : group_usb) |
| 126 | libftdi1 = dependency('libftdi1', required : group_ftdi) |
| 127 | libjaylink = dependency('libjaylink', required : group_jlink) |
Steve Markgraf | 6189947 | 2023-01-09 23:06:52 +0100 | [diff] [blame] | 128 | libgpiod = dependency('libgpiod', required : group_gpiod) |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 129 | |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 130 | subdir('platform') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 131 | |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 132 | if systems_hwaccess.contains(host_machine.system()) |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 133 | srcs += files('hwaccess_physmap.c') |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 134 | if ['x86', 'x86_64'].contains(host_machine.cpu_family()) |
| 135 | srcs += files('hwaccess_x86_msr.c', 'hwaccess_x86_io.c') |
Thomas Heijligen | 140c126 | 2021-09-27 15:12:26 +0200 | [diff] [blame] | 136 | endif |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 137 | endif |
| 138 | |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 139 | # Pseudo dependencies |
| 140 | linux_headers = \ |
| 141 | cc.has_header('linux/i2c.h') and \ |
| 142 | cc.has_header('linux/i2c-dev.h') and \ |
| 143 | cc.has_header('mtd/mtd-user.h') and \ |
| 144 | cc.has_header('linux/spi/spidev.h') ? declare_dependency() : dependency('', required : false) |
Thomas Heijligen | b975da1 | 2022-08-13 12:10:05 +0200 | [diff] [blame] | 145 | |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 146 | # '<programmer_name>' : { |
| 147 | # 'system' : list[string], # default: ['all'] |
| 148 | # 'cpu_families : list[string], # default: ['all'] |
| 149 | # 'deps' : list[dep], # default: [] |
| 150 | # 'groups : list[boolean], # default: [] |
| 151 | # 'srcs' : list[file], # default: [] |
| 152 | # 'flags' : list[string], # default: [] |
| 153 | # 'default' : boolean, # default: true |
| 154 | # 'active' : boolean, # added on runtime |
| 155 | # } |
| 156 | programmer = { |
| 157 | 'atahpt' : { |
| 158 | 'systems' : systems_hwaccess, |
| 159 | 'cpu_families' : cpus_port_io, |
| 160 | 'deps' : [ libpci ], |
| 161 | 'groups' : [ group_pci, group_internal ], |
| 162 | 'srcs' : files('atahpt.c', 'pcidev.c'), |
| 163 | 'flags' : [ '-DCONFIG_ATAHPT=1' ], |
| 164 | 'default' : false, # not yet working |
| 165 | }, |
| 166 | 'atapromise' : { |
| 167 | 'systems' : systems_hwaccess, |
| 168 | 'cpu_families' : cpus_port_io, |
| 169 | 'deps' : [ libpci ], |
| 170 | 'groups' : [ group_pci, group_internal ], |
| 171 | 'srcs' : files('atapromise.c', 'pcidev.c'), |
| 172 | 'flags' : [ '-DCONFIG_ATAPROMISE=1' ], |
| 173 | 'default' : false, |
| 174 | }, |
| 175 | 'atavia' : { |
| 176 | 'systems' : systems_hwaccess, |
| 177 | 'deps' : [ libpci ], |
| 178 | 'groups' : [ group_pci, group_internal ], |
| 179 | 'srcs' : files('atavia.c', 'pcidev.c'), |
| 180 | 'flags' : [ '-DCONFIG_ATAVIA=1' ], |
| 181 | }, |
| 182 | 'buspirate_spi' : { |
| 183 | 'systems' : systems_serial, |
| 184 | 'groups' : [ group_serial, group_external ], |
Peter Stuge | 272b073 | 2022-12-11 03:55:02 +0100 | [diff] [blame] | 185 | 'srcs' : files('buspirate_spi.c', 'serial.c', custom_baud_c), |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 186 | 'flags' : [ '-DCONFIG_BUSPIRATE_SPI=1' ], |
| 187 | }, |
| 188 | 'ch341a_spi' : { |
| 189 | 'deps' : [ libusb1 ], |
| 190 | 'groups' : [ group_usb, group_external ], |
| 191 | 'srcs' : files('ch341a_spi.c'), |
| 192 | 'flags' : [ '-DCONFIG_CH341A_SPI=1' ], |
| 193 | }, |
Nicholas Chin | 197b7c7 | 2022-10-23 13:10:31 -0600 | [diff] [blame] | 194 | 'ch347_spi' : { |
| 195 | 'deps' : [ libusb1 ], |
| 196 | 'groups' : [ group_usb, group_external ], |
| 197 | 'srcs' : files('ch347_spi.c'), |
| 198 | 'flags' : [ '-DCONFIG_CH347_SPI=1' ], |
| 199 | }, |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 200 | 'dediprog' : { |
| 201 | 'deps' : [ libusb1 ], |
| 202 | 'groups' : [ group_usb, group_external ], |
| 203 | 'srcs' : files('dediprog.c', 'usbdev.c'), |
| 204 | 'flags' : [ '-DCONFIG_DEDIPROG=1' ], |
| 205 | }, |
| 206 | 'developerbox_spi' : { |
| 207 | 'deps' : [ libusb1 ], |
| 208 | 'groups' : [ group_usb, group_external ], |
| 209 | 'srcs' : files('developerbox_spi.c', 'usbdev.c'), |
| 210 | 'flags' : [ '-DCONFIG_DEVELOPERBOX_SPI=1' ], |
| 211 | }, |
| 212 | 'digilent_spi' : { |
| 213 | 'deps' : [ libusb1 ], |
| 214 | 'groups' : [ group_usb, group_external ], |
| 215 | 'srcs' : files('digilent_spi.c'), |
| 216 | 'flags' : [ '-DCONFIG_DIGILENT_SPI=1' ], |
| 217 | }, |
| 218 | 'dirtyjtag_spi' : { |
| 219 | 'deps' : [ libusb1 ], |
| 220 | 'groups' : [ group_usb, group_external ], |
| 221 | 'srcs' : files('dirtyjtag_spi.c'), |
| 222 | 'flags' : [ '-DCONFIG_DIRTYJTAG_SPI=1' ], |
| 223 | }, |
| 224 | 'drkaiser' : { |
| 225 | 'systems' : systems_hwaccess, |
| 226 | 'deps' : [ libpci ], |
| 227 | 'groups' : [ group_pci, group_internal ], |
| 228 | 'srcs' : files('drkaiser.c', 'pcidev.c'), |
| 229 | 'flags' : [ '-DCONFIG_DRKAISER=1' ], |
| 230 | }, |
| 231 | 'dummy' : { |
| 232 | 'srcs' : files('dummyflasher.c'), |
| 233 | 'flags' : [ '-DCONFIG_DUMMY=1' ], |
| 234 | }, |
| 235 | 'ft2232_spi' : { |
| 236 | 'deps' : [ libftdi1 ], |
| 237 | 'groups' : [ group_ftdi, group_external ], |
| 238 | 'srcs' : files('ft2232_spi.c' ), |
| 239 | 'flags' : [ '-DCONFIG_FT2232_SPI=1' ], |
| 240 | }, |
| 241 | 'gfxnvidia' : { |
| 242 | 'systems' : systems_hwaccess, |
| 243 | 'deps' : [ libpci ], |
| 244 | 'groups' : [ group_pci, group_internal ], |
| 245 | 'srcs' : files('gfxnvidia.c', 'pcidev.c'), |
| 246 | 'flags' : [ '-DCONFIG_GFXNVIDIA=1' ], |
| 247 | }, |
| 248 | 'internal' : { |
| 249 | 'systems' : systems_hwaccess + ['linux'], |
| 250 | 'cpu_families' : (host_machine.system() == 'linux' ? [host_machine.cpu_family()] : ['x86', 'x86_64']), |
| 251 | 'deps' : [ libpci ], |
| 252 | 'groups' : [ group_internal ], |
| 253 | 'srcs' : (host_machine.cpu_family() in ['x86', 'x86_64'] ? files( |
| 254 | 'processor_enable.c', |
| 255 | 'chipset_enable.c', |
| 256 | 'board_enable.c', |
| 257 | 'cbtable.c', |
| 258 | 'internal.c', |
| 259 | 'it87spi.c', |
| 260 | 'sb600spi.c', |
| 261 | 'amd_imc.c', |
Nico Huber | 735b186 | 2023-01-29 18:28:45 +0000 | [diff] [blame] | 262 | 'amd_spi100.c', |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 263 | 'wbsio_spi.c', |
| 264 | 'mcp6x_spi.c', |
| 265 | 'ichspi.c', |
| 266 | 'dmi.c', |
| 267 | 'pcidev.c', |
| 268 | 'known_boards.c', |
| 269 | ) : files( |
| 270 | 'board_enable.c', |
| 271 | 'cbtable.c', |
| 272 | 'chipset_enable.c', |
| 273 | 'internal.c', |
| 274 | 'processor_enable.c', |
| 275 | 'pcidev.c', |
| 276 | 'known_boards.c', |
| 277 | )), |
| 278 | 'flags' : [ |
| 279 | '-DCONFIG_INTERNAL=1', |
| 280 | '-DCONFIG_INTERNAL_DMI=' + (get_option('use_internal_dmi') ? '1' : '0'), |
| 281 | ] |
| 282 | }, |
| 283 | 'it8212' : { |
| 284 | 'systems' : systems_hwaccess, |
| 285 | 'deps' : [ libpci ], |
| 286 | 'groups' : [ group_pci, group_internal ], |
| 287 | 'srcs' : files('it8212.c', 'pcidev.c'), |
| 288 | 'flags' : [ '-DCONFIG_IT8212=1' ], |
| 289 | }, |
| 290 | 'jlink_spi' : { |
| 291 | 'deps' : [ libjaylink ], |
| 292 | 'groups' : [ group_jlink, group_external ], |
| 293 | 'srcs' : files('jlink_spi.c'), |
| 294 | 'flags' : [ '-DCONFIG_JLINK_SPI=1' ], |
| 295 | 'default' : false, |
| 296 | }, |
Steve Markgraf | 6189947 | 2023-01-09 23:06:52 +0100 | [diff] [blame] | 297 | 'linux_gpio_spi' : { |
| 298 | 'systems' : [ 'linux' ], |
| 299 | 'deps' : [ libgpiod ], |
| 300 | 'groups' : [ group_gpiod, group_external ], |
| 301 | 'srcs' : files('linux_gpio_spi.c'), |
Nico Huber | aa5268d | 2023-03-09 17:15:23 +0100 | [diff] [blame] | 302 | 'flags' : [ '-DCONFIG_LINUX_GPIO_SPI=1' ], |
Steve Markgraf | 6189947 | 2023-01-09 23:06:52 +0100 | [diff] [blame] | 303 | }, |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 304 | 'linux_mtd' : { |
| 305 | 'systems' : [ 'linux' ], |
| 306 | 'deps' : [ linux_headers ], |
| 307 | 'groups' : [ group_internal ], |
| 308 | 'srcs' : files('linux_mtd.c'), |
| 309 | 'flags' : [ '-DCONFIG_LINUX_MTD=1' ], |
| 310 | }, |
| 311 | 'linux_spi' : { |
| 312 | 'systems' : [ 'linux' ], |
| 313 | 'deps' : [ linux_headers ], |
| 314 | # internal / external? |
| 315 | 'srcs' : files('linux_spi.c'), |
| 316 | 'flags' : [ '-DCONFIG_LINUX_SPI=1' ], |
| 317 | }, |
| 318 | 'mstarddc_spi' : { |
| 319 | 'systems' : [ 'linux' ], |
| 320 | 'deps' : [ linux_headers ], |
| 321 | 'groups' : [ group_i2c ], |
| 322 | 'srcs' : files('mstarddc_spi.c'), |
| 323 | 'flags' : [ '-DCONFIG_MSTARDDC_SPI=1' ], |
| 324 | 'default' : false |
| 325 | }, |
| 326 | 'nic3com' : { |
| 327 | 'systems' : systems_hwaccess, |
| 328 | 'cpu_families' : cpus_port_io, |
| 329 | 'deps' : [ libpci ], |
| 330 | 'groups' : [ group_pci, group_internal ], |
| 331 | 'srcs' : files('nic3com.c', 'pcidev.c'), |
| 332 | 'flags' : [ '-DCONFIG_NIC3COM=1' ], |
| 333 | }, |
| 334 | 'nicintel' : { |
| 335 | 'systems' : systems_hwaccess, |
| 336 | 'deps' : [ libpci ], |
| 337 | 'groups' : [ group_pci, group_internal ], |
| 338 | 'srcs' : files('nicintel.c', 'pcidev.c'), |
| 339 | 'flags' : [ '-DCONFIG_NICINTEL=1' ], |
| 340 | }, |
| 341 | 'nicintel_eeprom' : { |
| 342 | 'systems' : systems_hwaccess, |
| 343 | 'deps' : [ libpci ], |
| 344 | 'groups' : [ group_pci, group_internal ], |
| 345 | 'srcs' : files('nicintel_eeprom.c', 'pcidev.c'), |
| 346 | 'flags' : [ '-DCONFIG_NICINTEL_EEPROM=1' ], |
| 347 | }, |
| 348 | 'nicintel_spi' : { |
| 349 | 'systems' : systems_hwaccess, |
| 350 | 'deps' : [ libpci ], |
| 351 | 'groups' : [ group_pci, group_internal ], |
| 352 | 'srcs' : files('nicintel_spi.c', 'pcidev.c'), |
| 353 | 'flags' : [ '-DCONFIG_NICINTEL_SPI=1' ], |
| 354 | }, |
| 355 | 'nicnatsemi' : { |
| 356 | 'systems' : systems_hwaccess, |
| 357 | 'cpu_families' : cpus_port_io, |
| 358 | 'deps' : [ libpci ], |
| 359 | 'groups' : [ group_pci, group_internal ], |
| 360 | 'srcs' : files('nicnatsemi.c', 'pcidev.c'), |
| 361 | 'flags' : [ '-DCONFIG_NICNATSEMI=1' ], |
| 362 | 'default' : false, # not complete nor tested |
| 363 | }, |
| 364 | 'nicrealtek' : { |
| 365 | 'systems' : systems_hwaccess, |
| 366 | 'cpu_families' : cpus_port_io, |
| 367 | 'deps' : [ libpci ], |
| 368 | 'groups' : [ group_pci, group_internal ], |
| 369 | 'srcs' : files('nicrealtek.c', 'pcidev.c'), |
| 370 | 'flags' : [ '-DCONFIG_NICREALTEK=1' ], |
| 371 | }, |
| 372 | 'ogp_spi' : { |
| 373 | 'systems' : systems_hwaccess, |
| 374 | 'deps' : [ libpci ], |
| 375 | 'groups' : [ group_pci, group_internal ], |
| 376 | 'srcs' : files('ogp_spi.c', 'pcidev.c'), |
| 377 | 'flags' : [ '-DCONFIG_OGP_SPI=1' ], |
| 378 | }, |
| 379 | 'pickit2_spi' : { |
| 380 | 'deps' : [ libusb1 ], |
| 381 | 'groups' : [ group_usb, group_external ], |
| 382 | 'srcs' : files('pickit2_spi.c'), |
| 383 | 'flags' : [ '-DCONFIG_PICKIT2_SPI=1' ], |
| 384 | }, |
| 385 | 'pony_spi' : { |
| 386 | 'systems' : systems_serial, |
| 387 | 'groups' : [ group_serial, group_external ], |
Peter Stuge | 272b073 | 2022-12-11 03:55:02 +0100 | [diff] [blame] | 388 | 'srcs' : files('pony_spi.c', 'serial.c', custom_baud_c), |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 389 | 'flags' : [ '-DCONFIG_PONY_SPI=1' ], |
| 390 | }, |
| 391 | 'rayer_spi' : { |
| 392 | 'systems' : systems_hwaccess, |
| 393 | 'cpu_families' : cpus_port_io, |
| 394 | 'groups' : [ group_internal ], |
| 395 | 'srcs' : files('rayer_spi.c'), |
| 396 | 'flags' : [ '-DCONFIG_RAYER_SPI=1' ], |
| 397 | }, |
| 398 | 'satamv' : { |
| 399 | 'systems' : systems_hwaccess, |
| 400 | 'cpu_families' : cpus_port_io, |
| 401 | 'deps' : [ libpci ], |
| 402 | 'groups' : [ group_pci, group_internal ], |
| 403 | 'srcs' : files('satamv.c', 'pcidev.c'), |
| 404 | 'flags' : ['-DCONFIG_SATAMV=1'], |
| 405 | }, |
| 406 | 'satasii' : { |
| 407 | 'systems' : systems_hwaccess, |
| 408 | 'deps' : [ libpci ], |
| 409 | 'groups' : [ group_pci, group_internal ], |
| 410 | 'srcs' : files('satasii.c', 'pcidev.c'), |
| 411 | 'flags' : [ '-DCONFIG_SATASII=1' ], |
| 412 | }, |
| 413 | 'serprog' : { |
| 414 | 'systems' : systems_serial, |
| 415 | 'groups' : [ group_serial, group_external ], |
Peter Stuge | 272b073 | 2022-12-11 03:55:02 +0100 | [diff] [blame] | 416 | 'srcs' : files('serprog.c', 'serial.c', custom_baud_c), |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 417 | 'flags' : [ '-DCONFIG_SERPROG=1' ], |
| 418 | }, |
| 419 | 'stlinkv3_spi' : { |
| 420 | 'deps' : [ libusb1 ], |
| 421 | 'groups' : [ group_usb, group_external ], |
| 422 | 'srcs' : files('stlinkv3_spi.c', 'usbdev.c'), |
| 423 | 'flags' : [ '-DCONFIG_STLINKV3_SPI=1' ], |
| 424 | }, |
| 425 | 'usbblaster_spi' : { |
| 426 | 'deps' : [ libftdi1 ], |
| 427 | 'groups' : [ group_ftdi, group_external ], |
| 428 | 'srcs' : files('usbblaster_spi.c'), |
| 429 | 'flags' : [ '-DCONFIG_USBBLASTER_SPI=1' ], |
| 430 | }, |
| 431 | } |
| 432 | |
| 433 | active_programmer_count = 0 |
| 434 | foreach p_name, p_data : programmer |
| 435 | p_data += { |
| 436 | 'systems' : p_data.get('systems', ['all']), |
| 437 | 'cpu_families' : p_data.get('cpu_families', ['all']), |
| 438 | 'deps' : p_data.get('deps', []), |
| 439 | 'groups' : p_data.get('groups', []), |
| 440 | 'srcs' : p_data.get('srcs', []), |
| 441 | 'flags' : p_data.get('flags', []), |
| 442 | 'default' : p_data.get('default', true), |
| 443 | } |
| 444 | |
| 445 | active = false |
| 446 | deps_found = true |
| 447 | not_found_dep = '' |
| 448 | not_active_message = '' |
| 449 | selected_hard = p_name in get_option('programmer') |
| 450 | selected_soft = p_data.get('groups').contains(true) or \ |
| 451 | 'all' in get_option('programmer') or \ |
| 452 | 'auto' in get_option('programmer') and p_data.get('default') |
| 453 | available = (p_data.get('systems').contains('all') or p_data.get('systems').contains(host_machine.system())) \ |
| 454 | and (p_data.get('cpu_families').contains('all') or p_data.get('cpu_families').contains(host_machine.cpu_family())) |
| 455 | |
| 456 | foreach dep : p_data.get('deps') |
| 457 | if not dep.found() |
| 458 | deps_found = false |
| 459 | not_found_dep = dep.name() |
| 460 | break |
| 461 | endif |
| 462 | endforeach |
| 463 | |
| 464 | if selected_hard |
| 465 | if not available |
| 466 | error(p_name + ' selected but not supported on this platform') |
| 467 | elif not deps_found |
| 468 | error(p_name + ' selected but dependency ' + not_found_dep +'not found') |
| 469 | else |
| 470 | active = true |
| 471 | endif |
| 472 | elif selected_soft |
| 473 | if not available |
| 474 | not_active_message = 'Not available on platform' |
| 475 | elif not deps_found |
| 476 | not_active_message = 'dependency ' + not_found_dep + ' not found' |
| 477 | else |
| 478 | active = true |
| 479 | endif |
| 480 | else |
| 481 | not_active_message = 'not selected' |
| 482 | endif |
| 483 | |
| 484 | p_data += { |
| 485 | 'active' : active, |
| 486 | 'summary' : not_active_message, |
| 487 | } |
| 488 | programmer += {p_name : p_data} |
| 489 | if active |
| 490 | active_programmer_count += 1 |
| 491 | endif |
| 492 | endforeach |
| 493 | |
| 494 | if active_programmer_count == 0 |
| 495 | error('At least one programmer must be selected') |
| 496 | endif |
| 497 | |
| 498 | # add srcs, cargs & deps from active programmer to global srcs, cargs & deps |
| 499 | foreach p_name, p_data : programmer |
| 500 | if p_data.get('active') |
| 501 | srcs += p_data.get('srcs') |
| 502 | cargs += p_data.get('flags') |
| 503 | deps += p_data.get('deps') |
| 504 | endif |
| 505 | endforeach |
Thomas Heijligen | b975da1 | 2022-08-13 12:10:05 +0200 | [diff] [blame] | 506 | |
| 507 | if config_print_wiki.enabled() |
| 508 | if get_option('classic_cli').disabled() |
| 509 | error('`classic_cli_print_wiki` can not be enabled without `classic_cli`') |
| 510 | else |
| 511 | srcs += files('print_wiki.c') |
| 512 | cargs += '-DCONFIG_PRINT_WIKI=1' |
| 513 | endif |
Thomas Heijligen | 2ae9bf2 | 2022-05-03 12:00:14 +0200 | [diff] [blame] | 514 | endif |
| 515 | |
| 516 | if config_default_programmer_name != '' |
| 517 | cargs += '-DCONFIG_DEFAULT_PROGRAMMER_NAME=&programmer_' + config_default_programmer_name |
| 518 | else |
| 519 | cargs += '-DCONFIG_DEFAULT_PROGRAMMER_NAME=NULL' |
| 520 | endif |
| 521 | |
| 522 | cargs += '-DCONFIG_DEFAULT_PROGRAMMER_ARGS="' + config_default_programmer_args + '"' |
| 523 | |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 524 | install_headers([ |
Thomas Heijligen | 58015c2 | 2022-04-14 13:50:55 +0200 | [diff] [blame] | 525 | 'include/libflashrom.h', |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 526 | ], |
| 527 | ) |
| 528 | |
Thomas Heijligen | 58015c2 | 2022-04-14 13:50:55 +0200 | [diff] [blame] | 529 | include_dir = include_directories('include') |
| 530 | |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 531 | mapfile = 'libflashrom.map' |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 532 | if host_machine.system() == 'darwin' |
| 533 | vflag = '' |
| 534 | else |
| 535 | vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile) |
| 536 | endif |
Thomas Heijligen | f6a273b | 2022-05-03 12:21:47 +0200 | [diff] [blame] | 537 | libflashrom = both_libraries( |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 538 | 'flashrom', |
| 539 | sources : [ |
| 540 | srcs, |
| 541 | ], |
Thomas Heijligen | 58015c2 | 2022-04-14 13:50:55 +0200 | [diff] [blame] | 542 | include_directories : include_dir, |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 543 | soversion : lt_current, |
| 544 | version : lt_version, |
| 545 | dependencies : [ |
| 546 | deps, |
| 547 | ], |
| 548 | c_args : [ |
| 549 | cargs, |
| 550 | ], |
| 551 | install : true, |
| 552 | link_args : vflag, |
| 553 | link_depends : mapfile, |
| 554 | ) |
| 555 | |
Mario Limonciello | d954d5d | 2019-09-24 16:06:57 -0500 | [diff] [blame] | 556 | version = meson.project_version() |
| 557 | #strip leading characters |
| 558 | if version.startswith('v') |
| 559 | version = version.split('v')[1] |
| 560 | endif |
| 561 | if version.startswith('p') |
| 562 | version = version.split('p')[1] |
| 563 | endif |
| 564 | |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 565 | pkgg = import('pkgconfig') |
| 566 | pkgg.generate( |
Thomas Heijligen | f6a273b | 2022-05-03 12:21:47 +0200 | [diff] [blame] | 567 | libraries : libflashrom, |
Mario Limonciello | d954d5d | 2019-09-24 16:06:57 -0500 | [diff] [blame] | 568 | version : version, |
Mario Limonciello | 2a8d439 | 2019-10-15 13:32:19 -0500 | [diff] [blame] | 569 | name : 'flashrom', |
| 570 | filebase : 'flashrom', |
| 571 | description : 'library to interact with flashrom', |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 572 | ) |
| 573 | |
Felix Singer | 9818b3f | 2022-11-29 17:08:03 +0100 | [diff] [blame] | 574 | config_manfile = configuration_data() |
| 575 | config_manfile.set('VERSION', version) |
| 576 | config_manfile.set('MAN_DATE', run_command('util/getversion.sh', '--man-date', check : true).stdout().strip()) |
Richard Hughes | dad3a16 | 2020-02-17 09:57:01 +0000 | [diff] [blame] | 577 | configure_file( |
| 578 | input : 'flashrom.8.tmpl', |
| 579 | output : 'flashrom.8', |
Felix Singer | 9818b3f | 2022-11-29 17:08:03 +0100 | [diff] [blame] | 580 | configuration : config_manfile, |
Richard Hughes | dad3a16 | 2020-02-17 09:57:01 +0000 | [diff] [blame] | 581 | install: true, |
Thomas Heijligen | 454a28c | 2022-05-03 11:50:16 +0200 | [diff] [blame] | 582 | install_dir: join_paths(get_option('mandir'), 'man8'), |
Richard Hughes | dad3a16 | 2020-02-17 09:57:01 +0000 | [diff] [blame] | 583 | ) |
| 584 | |
Thomas Heijligen | a12e010 | 2022-08-13 12:42:05 +0200 | [diff] [blame] | 585 | if get_option('classic_cli').auto() or get_option('classic_cli').enabled() |
| 586 | executable( |
| 587 | 'flashrom', |
| 588 | files( |
| 589 | 'cli_classic.c', |
| 590 | 'cli_common.c', |
| 591 | 'cli_output.c', |
| 592 | ), |
| 593 | c_args : cargs, |
| 594 | include_directories : include_dir, |
| 595 | install : true, |
| 596 | install_dir : get_option('sbindir'), |
| 597 | link_with : libflashrom.get_static_lib(), # flashrom needs internal symbols of libflashrom |
| 598 | ) |
| 599 | endif |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 600 | |
Thomas Heijligen | b7341b1 | 2022-08-13 12:21:44 +0200 | [diff] [blame] | 601 | if get_option('ich_descriptors_tool').auto() or get_option('ich_descriptors_tool').enabled() |
| 602 | subdir('util/ich_descriptors_tool') |
| 603 | endif |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 604 | |
| 605 | programmer_names_active = [] |
| 606 | programmer_names_not_active = [] |
| 607 | foreach p_name, p_data : programmer |
| 608 | if p_data.get('active') |
| 609 | programmer_names_active += p_name |
| 610 | else |
| 611 | programmer_names_not_active += p_name + ' (' + p_data.get('summary', '') + ')' |
| 612 | endif |
| 613 | endforeach |
| 614 | |
| 615 | summary({ |
| 616 | 'active' : [programmer_names_active], |
| 617 | 'non active' : [programmer_names_not_active], |
| 618 | }, section : 'Programmer') |