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 | |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 101 | systems_hwaccess = [ 'linux', 'openbsd', 'freebsd', 'dragonfly', 'netbsd' ] |
| 102 | systems_serial = [ 'linux', 'openbsd', 'freebsd', 'dragonfly', 'netbsd', 'darwin' ] |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 103 | |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 104 | cpus_port_io = [ 'x86', 'x86_64' ] |
Peter Marheine | 306c8b7 | 2022-01-21 02:07:30 +0000 | [diff] [blame] | 105 | |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 106 | group_ftdi = get_option('programmer').contains('group_ftdi') |
| 107 | group_pci = get_option('programmer').contains('group_pci') |
| 108 | group_usb = get_option('programmer').contains('group_usb') |
| 109 | group_i2c = get_option('programmer').contains('group_i2c') |
| 110 | group_serial = get_option('programmer').contains('group_serial') |
| 111 | group_jlink = get_option('programmer').contains('group_jlink') |
| 112 | group_internal = get_option('programmer').contains('group_internal') |
| 113 | group_external = get_option('programmer').contains('group_external') |
Peter Marheine | 306c8b7 | 2022-01-21 02:07:30 +0000 | [diff] [blame] | 114 | |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 115 | 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 |
| 116 | libusb1 = dependency('libusb-1.0', required : group_usb) |
| 117 | libftdi1 = dependency('libftdi1', required : group_ftdi) |
| 118 | libjaylink = dependency('libjaylink', required : group_jlink) |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 119 | |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 120 | subdir('platform') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 121 | |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 122 | if systems_hwaccess.contains(host_machine.system()) |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 123 | srcs += files('hwaccess_physmap.c') |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 124 | if ['x86', 'x86_64'].contains(host_machine.cpu_family()) |
| 125 | srcs += files('hwaccess_x86_msr.c', 'hwaccess_x86_io.c') |
Thomas Heijligen | 140c126 | 2021-09-27 15:12:26 +0200 | [diff] [blame] | 126 | endif |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 127 | endif |
| 128 | |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 129 | # Pseudo dependencies |
| 130 | linux_headers = \ |
| 131 | cc.has_header('linux/i2c.h') and \ |
| 132 | cc.has_header('linux/i2c-dev.h') and \ |
| 133 | cc.has_header('mtd/mtd-user.h') and \ |
| 134 | cc.has_header('linux/spi/spidev.h') ? declare_dependency() : dependency('', required : false) |
Thomas Heijligen | b975da1 | 2022-08-13 12:10:05 +0200 | [diff] [blame] | 135 | |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 136 | # '<programmer_name>' : { |
| 137 | # 'system' : list[string], # default: ['all'] |
| 138 | # 'cpu_families : list[string], # default: ['all'] |
| 139 | # 'deps' : list[dep], # default: [] |
| 140 | # 'groups : list[boolean], # default: [] |
| 141 | # 'srcs' : list[file], # default: [] |
| 142 | # 'flags' : list[string], # default: [] |
| 143 | # 'default' : boolean, # default: true |
| 144 | # 'active' : boolean, # added on runtime |
| 145 | # } |
| 146 | programmer = { |
| 147 | 'atahpt' : { |
| 148 | 'systems' : systems_hwaccess, |
| 149 | 'cpu_families' : cpus_port_io, |
| 150 | 'deps' : [ libpci ], |
| 151 | 'groups' : [ group_pci, group_internal ], |
| 152 | 'srcs' : files('atahpt.c', 'pcidev.c'), |
| 153 | 'flags' : [ '-DCONFIG_ATAHPT=1' ], |
| 154 | 'default' : false, # not yet working |
| 155 | }, |
| 156 | 'atapromise' : { |
| 157 | 'systems' : systems_hwaccess, |
| 158 | 'cpu_families' : cpus_port_io, |
| 159 | 'deps' : [ libpci ], |
| 160 | 'groups' : [ group_pci, group_internal ], |
| 161 | 'srcs' : files('atapromise.c', 'pcidev.c'), |
| 162 | 'flags' : [ '-DCONFIG_ATAPROMISE=1' ], |
| 163 | 'default' : false, |
| 164 | }, |
| 165 | 'atavia' : { |
| 166 | 'systems' : systems_hwaccess, |
| 167 | 'deps' : [ libpci ], |
| 168 | 'groups' : [ group_pci, group_internal ], |
| 169 | 'srcs' : files('atavia.c', 'pcidev.c'), |
| 170 | 'flags' : [ '-DCONFIG_ATAVIA=1' ], |
| 171 | }, |
| 172 | 'buspirate_spi' : { |
| 173 | 'systems' : systems_serial, |
| 174 | 'groups' : [ group_serial, group_external ], |
| 175 | 'srcs' : files('buspirate_spi.c', 'serial.c', (host_machine.system() == 'linux' ? 'custom_baud_linux.c' : 'custom_baud.c')), |
| 176 | 'flags' : [ '-DCONFIG_BUSPIRATE_SPI=1' ], |
| 177 | }, |
| 178 | 'ch341a_spi' : { |
| 179 | 'deps' : [ libusb1 ], |
| 180 | 'groups' : [ group_usb, group_external ], |
| 181 | 'srcs' : files('ch341a_spi.c'), |
| 182 | 'flags' : [ '-DCONFIG_CH341A_SPI=1' ], |
| 183 | }, |
Nicholas Chin | 197b7c7 | 2022-10-23 13:10:31 -0600 | [diff] [blame] | 184 | 'ch347_spi' : { |
| 185 | 'deps' : [ libusb1 ], |
| 186 | 'groups' : [ group_usb, group_external ], |
| 187 | 'srcs' : files('ch347_spi.c'), |
| 188 | 'flags' : [ '-DCONFIG_CH347_SPI=1' ], |
| 189 | }, |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 190 | 'dediprog' : { |
| 191 | 'deps' : [ libusb1 ], |
| 192 | 'groups' : [ group_usb, group_external ], |
| 193 | 'srcs' : files('dediprog.c', 'usbdev.c'), |
| 194 | 'flags' : [ '-DCONFIG_DEDIPROG=1' ], |
| 195 | }, |
| 196 | 'developerbox_spi' : { |
| 197 | 'deps' : [ libusb1 ], |
| 198 | 'groups' : [ group_usb, group_external ], |
| 199 | 'srcs' : files('developerbox_spi.c', 'usbdev.c'), |
| 200 | 'flags' : [ '-DCONFIG_DEVELOPERBOX_SPI=1' ], |
| 201 | }, |
| 202 | 'digilent_spi' : { |
| 203 | 'deps' : [ libusb1 ], |
| 204 | 'groups' : [ group_usb, group_external ], |
| 205 | 'srcs' : files('digilent_spi.c'), |
| 206 | 'flags' : [ '-DCONFIG_DIGILENT_SPI=1' ], |
| 207 | }, |
| 208 | 'dirtyjtag_spi' : { |
| 209 | 'deps' : [ libusb1 ], |
| 210 | 'groups' : [ group_usb, group_external ], |
| 211 | 'srcs' : files('dirtyjtag_spi.c'), |
| 212 | 'flags' : [ '-DCONFIG_DIRTYJTAG_SPI=1' ], |
| 213 | }, |
| 214 | 'drkaiser' : { |
| 215 | 'systems' : systems_hwaccess, |
| 216 | 'deps' : [ libpci ], |
| 217 | 'groups' : [ group_pci, group_internal ], |
| 218 | 'srcs' : files('drkaiser.c', 'pcidev.c'), |
| 219 | 'flags' : [ '-DCONFIG_DRKAISER=1' ], |
| 220 | }, |
| 221 | 'dummy' : { |
| 222 | 'srcs' : files('dummyflasher.c'), |
| 223 | 'flags' : [ '-DCONFIG_DUMMY=1' ], |
| 224 | }, |
| 225 | 'ft2232_spi' : { |
| 226 | 'deps' : [ libftdi1 ], |
| 227 | 'groups' : [ group_ftdi, group_external ], |
| 228 | 'srcs' : files('ft2232_spi.c' ), |
| 229 | 'flags' : [ '-DCONFIG_FT2232_SPI=1' ], |
| 230 | }, |
| 231 | 'gfxnvidia' : { |
| 232 | 'systems' : systems_hwaccess, |
| 233 | 'deps' : [ libpci ], |
| 234 | 'groups' : [ group_pci, group_internal ], |
| 235 | 'srcs' : files('gfxnvidia.c', 'pcidev.c'), |
| 236 | 'flags' : [ '-DCONFIG_GFXNVIDIA=1' ], |
| 237 | }, |
| 238 | 'internal' : { |
| 239 | 'systems' : systems_hwaccess + ['linux'], |
| 240 | 'cpu_families' : (host_machine.system() == 'linux' ? [host_machine.cpu_family()] : ['x86', 'x86_64']), |
| 241 | 'deps' : [ libpci ], |
| 242 | 'groups' : [ group_internal ], |
| 243 | 'srcs' : (host_machine.cpu_family() in ['x86', 'x86_64'] ? files( |
| 244 | 'processor_enable.c', |
| 245 | 'chipset_enable.c', |
| 246 | 'board_enable.c', |
| 247 | 'cbtable.c', |
| 248 | 'internal.c', |
| 249 | 'it87spi.c', |
| 250 | 'sb600spi.c', |
| 251 | 'amd_imc.c', |
Nico Huber | 735b186 | 2023-01-29 18:28:45 +0000 | [diff] [blame] | 252 | 'amd_spi100.c', |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 253 | 'wbsio_spi.c', |
| 254 | 'mcp6x_spi.c', |
| 255 | 'ichspi.c', |
| 256 | 'dmi.c', |
| 257 | 'pcidev.c', |
| 258 | 'known_boards.c', |
| 259 | ) : files( |
| 260 | 'board_enable.c', |
| 261 | 'cbtable.c', |
| 262 | 'chipset_enable.c', |
| 263 | 'internal.c', |
| 264 | 'processor_enable.c', |
| 265 | 'pcidev.c', |
| 266 | 'known_boards.c', |
| 267 | )), |
| 268 | 'flags' : [ |
| 269 | '-DCONFIG_INTERNAL=1', |
| 270 | '-DCONFIG_INTERNAL_DMI=' + (get_option('use_internal_dmi') ? '1' : '0'), |
| 271 | ] |
| 272 | }, |
| 273 | 'it8212' : { |
| 274 | 'systems' : systems_hwaccess, |
| 275 | 'deps' : [ libpci ], |
| 276 | 'groups' : [ group_pci, group_internal ], |
| 277 | 'srcs' : files('it8212.c', 'pcidev.c'), |
| 278 | 'flags' : [ '-DCONFIG_IT8212=1' ], |
| 279 | }, |
| 280 | 'jlink_spi' : { |
| 281 | 'deps' : [ libjaylink ], |
| 282 | 'groups' : [ group_jlink, group_external ], |
| 283 | 'srcs' : files('jlink_spi.c'), |
| 284 | 'flags' : [ '-DCONFIG_JLINK_SPI=1' ], |
| 285 | 'default' : false, |
| 286 | }, |
| 287 | 'linux_mtd' : { |
| 288 | 'systems' : [ 'linux' ], |
| 289 | 'deps' : [ linux_headers ], |
| 290 | 'groups' : [ group_internal ], |
| 291 | 'srcs' : files('linux_mtd.c'), |
| 292 | 'flags' : [ '-DCONFIG_LINUX_MTD=1' ], |
| 293 | }, |
| 294 | 'linux_spi' : { |
| 295 | 'systems' : [ 'linux' ], |
| 296 | 'deps' : [ linux_headers ], |
| 297 | # internal / external? |
| 298 | 'srcs' : files('linux_spi.c'), |
| 299 | 'flags' : [ '-DCONFIG_LINUX_SPI=1' ], |
| 300 | }, |
| 301 | 'mstarddc_spi' : { |
| 302 | 'systems' : [ 'linux' ], |
| 303 | 'deps' : [ linux_headers ], |
| 304 | 'groups' : [ group_i2c ], |
| 305 | 'srcs' : files('mstarddc_spi.c'), |
| 306 | 'flags' : [ '-DCONFIG_MSTARDDC_SPI=1' ], |
| 307 | 'default' : false |
| 308 | }, |
| 309 | 'nic3com' : { |
| 310 | 'systems' : systems_hwaccess, |
| 311 | 'cpu_families' : cpus_port_io, |
| 312 | 'deps' : [ libpci ], |
| 313 | 'groups' : [ group_pci, group_internal ], |
| 314 | 'srcs' : files('nic3com.c', 'pcidev.c'), |
| 315 | 'flags' : [ '-DCONFIG_NIC3COM=1' ], |
| 316 | }, |
| 317 | 'nicintel' : { |
| 318 | 'systems' : systems_hwaccess, |
| 319 | 'deps' : [ libpci ], |
| 320 | 'groups' : [ group_pci, group_internal ], |
| 321 | 'srcs' : files('nicintel.c', 'pcidev.c'), |
| 322 | 'flags' : [ '-DCONFIG_NICINTEL=1' ], |
| 323 | }, |
| 324 | 'nicintel_eeprom' : { |
| 325 | 'systems' : systems_hwaccess, |
| 326 | 'deps' : [ libpci ], |
| 327 | 'groups' : [ group_pci, group_internal ], |
| 328 | 'srcs' : files('nicintel_eeprom.c', 'pcidev.c'), |
| 329 | 'flags' : [ '-DCONFIG_NICINTEL_EEPROM=1' ], |
| 330 | }, |
| 331 | 'nicintel_spi' : { |
| 332 | 'systems' : systems_hwaccess, |
| 333 | 'deps' : [ libpci ], |
| 334 | 'groups' : [ group_pci, group_internal ], |
| 335 | 'srcs' : files('nicintel_spi.c', 'pcidev.c'), |
| 336 | 'flags' : [ '-DCONFIG_NICINTEL_SPI=1' ], |
| 337 | }, |
| 338 | 'nicnatsemi' : { |
| 339 | 'systems' : systems_hwaccess, |
| 340 | 'cpu_families' : cpus_port_io, |
| 341 | 'deps' : [ libpci ], |
| 342 | 'groups' : [ group_pci, group_internal ], |
| 343 | 'srcs' : files('nicnatsemi.c', 'pcidev.c'), |
| 344 | 'flags' : [ '-DCONFIG_NICNATSEMI=1' ], |
| 345 | 'default' : false, # not complete nor tested |
| 346 | }, |
| 347 | 'nicrealtek' : { |
| 348 | 'systems' : systems_hwaccess, |
| 349 | 'cpu_families' : cpus_port_io, |
| 350 | 'deps' : [ libpci ], |
| 351 | 'groups' : [ group_pci, group_internal ], |
| 352 | 'srcs' : files('nicrealtek.c', 'pcidev.c'), |
| 353 | 'flags' : [ '-DCONFIG_NICREALTEK=1' ], |
| 354 | }, |
| 355 | 'ogp_spi' : { |
| 356 | 'systems' : systems_hwaccess, |
| 357 | 'deps' : [ libpci ], |
| 358 | 'groups' : [ group_pci, group_internal ], |
| 359 | 'srcs' : files('ogp_spi.c', 'pcidev.c'), |
| 360 | 'flags' : [ '-DCONFIG_OGP_SPI=1' ], |
| 361 | }, |
| 362 | 'pickit2_spi' : { |
| 363 | 'deps' : [ libusb1 ], |
| 364 | 'groups' : [ group_usb, group_external ], |
| 365 | 'srcs' : files('pickit2_spi.c'), |
| 366 | 'flags' : [ '-DCONFIG_PICKIT2_SPI=1' ], |
| 367 | }, |
| 368 | 'pony_spi' : { |
| 369 | 'systems' : systems_serial, |
| 370 | 'groups' : [ group_serial, group_external ], |
| 371 | 'srcs' : files('pony_spi.c', 'serial.c', (host_machine.system() == 'linux' ? 'custom_baud_linux.c' : 'custom_baud.c')), |
| 372 | 'flags' : [ '-DCONFIG_PONY_SPI=1' ], |
| 373 | }, |
| 374 | 'rayer_spi' : { |
| 375 | 'systems' : systems_hwaccess, |
| 376 | 'cpu_families' : cpus_port_io, |
| 377 | 'groups' : [ group_internal ], |
| 378 | 'srcs' : files('rayer_spi.c'), |
| 379 | 'flags' : [ '-DCONFIG_RAYER_SPI=1' ], |
| 380 | }, |
| 381 | 'satamv' : { |
| 382 | 'systems' : systems_hwaccess, |
| 383 | 'cpu_families' : cpus_port_io, |
| 384 | 'deps' : [ libpci ], |
| 385 | 'groups' : [ group_pci, group_internal ], |
| 386 | 'srcs' : files('satamv.c', 'pcidev.c'), |
| 387 | 'flags' : ['-DCONFIG_SATAMV=1'], |
| 388 | }, |
| 389 | 'satasii' : { |
| 390 | 'systems' : systems_hwaccess, |
| 391 | 'deps' : [ libpci ], |
| 392 | 'groups' : [ group_pci, group_internal ], |
| 393 | 'srcs' : files('satasii.c', 'pcidev.c'), |
| 394 | 'flags' : [ '-DCONFIG_SATASII=1' ], |
| 395 | }, |
| 396 | 'serprog' : { |
| 397 | 'systems' : systems_serial, |
| 398 | 'groups' : [ group_serial, group_external ], |
| 399 | 'srcs' : files('serprog.c', 'serial.c', (host_machine.system() == 'linux' ? 'custom_baud_linux.c' : 'custom_baud.c')), |
| 400 | 'flags' : [ '-DCONFIG_SERPROG=1' ], |
| 401 | }, |
| 402 | 'stlinkv3_spi' : { |
| 403 | 'deps' : [ libusb1 ], |
| 404 | 'groups' : [ group_usb, group_external ], |
| 405 | 'srcs' : files('stlinkv3_spi.c', 'usbdev.c'), |
| 406 | 'flags' : [ '-DCONFIG_STLINKV3_SPI=1' ], |
| 407 | }, |
| 408 | 'usbblaster_spi' : { |
| 409 | 'deps' : [ libftdi1 ], |
| 410 | 'groups' : [ group_ftdi, group_external ], |
| 411 | 'srcs' : files('usbblaster_spi.c'), |
| 412 | 'flags' : [ '-DCONFIG_USBBLASTER_SPI=1' ], |
| 413 | }, |
| 414 | } |
| 415 | |
| 416 | active_programmer_count = 0 |
| 417 | foreach p_name, p_data : programmer |
| 418 | p_data += { |
| 419 | 'systems' : p_data.get('systems', ['all']), |
| 420 | 'cpu_families' : p_data.get('cpu_families', ['all']), |
| 421 | 'deps' : p_data.get('deps', []), |
| 422 | 'groups' : p_data.get('groups', []), |
| 423 | 'srcs' : p_data.get('srcs', []), |
| 424 | 'flags' : p_data.get('flags', []), |
| 425 | 'default' : p_data.get('default', true), |
| 426 | } |
| 427 | |
| 428 | active = false |
| 429 | deps_found = true |
| 430 | not_found_dep = '' |
| 431 | not_active_message = '' |
| 432 | selected_hard = p_name in get_option('programmer') |
| 433 | selected_soft = p_data.get('groups').contains(true) or \ |
| 434 | 'all' in get_option('programmer') or \ |
| 435 | 'auto' in get_option('programmer') and p_data.get('default') |
| 436 | available = (p_data.get('systems').contains('all') or p_data.get('systems').contains(host_machine.system())) \ |
| 437 | and (p_data.get('cpu_families').contains('all') or p_data.get('cpu_families').contains(host_machine.cpu_family())) |
| 438 | |
| 439 | foreach dep : p_data.get('deps') |
| 440 | if not dep.found() |
| 441 | deps_found = false |
| 442 | not_found_dep = dep.name() |
| 443 | break |
| 444 | endif |
| 445 | endforeach |
| 446 | |
| 447 | if selected_hard |
| 448 | if not available |
| 449 | error(p_name + ' selected but not supported on this platform') |
| 450 | elif not deps_found |
| 451 | error(p_name + ' selected but dependency ' + not_found_dep +'not found') |
| 452 | else |
| 453 | active = true |
| 454 | endif |
| 455 | elif selected_soft |
| 456 | if not available |
| 457 | not_active_message = 'Not available on platform' |
| 458 | elif not deps_found |
| 459 | not_active_message = 'dependency ' + not_found_dep + ' not found' |
| 460 | else |
| 461 | active = true |
| 462 | endif |
| 463 | else |
| 464 | not_active_message = 'not selected' |
| 465 | endif |
| 466 | |
| 467 | p_data += { |
| 468 | 'active' : active, |
| 469 | 'summary' : not_active_message, |
| 470 | } |
| 471 | programmer += {p_name : p_data} |
| 472 | if active |
| 473 | active_programmer_count += 1 |
| 474 | endif |
| 475 | endforeach |
| 476 | |
| 477 | if active_programmer_count == 0 |
| 478 | error('At least one programmer must be selected') |
| 479 | endif |
| 480 | |
| 481 | # add srcs, cargs & deps from active programmer to global srcs, cargs & deps |
| 482 | foreach p_name, p_data : programmer |
| 483 | if p_data.get('active') |
| 484 | srcs += p_data.get('srcs') |
| 485 | cargs += p_data.get('flags') |
| 486 | deps += p_data.get('deps') |
| 487 | endif |
| 488 | endforeach |
Thomas Heijligen | b975da1 | 2022-08-13 12:10:05 +0200 | [diff] [blame] | 489 | |
| 490 | if config_print_wiki.enabled() |
| 491 | if get_option('classic_cli').disabled() |
| 492 | error('`classic_cli_print_wiki` can not be enabled without `classic_cli`') |
| 493 | else |
| 494 | srcs += files('print_wiki.c') |
| 495 | cargs += '-DCONFIG_PRINT_WIKI=1' |
| 496 | endif |
Thomas Heijligen | 2ae9bf2 | 2022-05-03 12:00:14 +0200 | [diff] [blame] | 497 | endif |
| 498 | |
| 499 | if config_default_programmer_name != '' |
| 500 | cargs += '-DCONFIG_DEFAULT_PROGRAMMER_NAME=&programmer_' + config_default_programmer_name |
| 501 | else |
| 502 | cargs += '-DCONFIG_DEFAULT_PROGRAMMER_NAME=NULL' |
| 503 | endif |
| 504 | |
| 505 | cargs += '-DCONFIG_DEFAULT_PROGRAMMER_ARGS="' + config_default_programmer_args + '"' |
| 506 | |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 507 | install_headers([ |
Thomas Heijligen | 58015c2 | 2022-04-14 13:50:55 +0200 | [diff] [blame] | 508 | 'include/libflashrom.h', |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 509 | ], |
| 510 | ) |
| 511 | |
Thomas Heijligen | 58015c2 | 2022-04-14 13:50:55 +0200 | [diff] [blame] | 512 | include_dir = include_directories('include') |
| 513 | |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 514 | mapfile = 'libflashrom.map' |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 515 | if host_machine.system() == 'darwin' |
| 516 | vflag = '' |
| 517 | else |
| 518 | vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile) |
| 519 | endif |
Thomas Heijligen | f6a273b | 2022-05-03 12:21:47 +0200 | [diff] [blame] | 520 | libflashrom = both_libraries( |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 521 | 'flashrom', |
| 522 | sources : [ |
| 523 | srcs, |
| 524 | ], |
Thomas Heijligen | 58015c2 | 2022-04-14 13:50:55 +0200 | [diff] [blame] | 525 | include_directories : include_dir, |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 526 | soversion : lt_current, |
| 527 | version : lt_version, |
| 528 | dependencies : [ |
| 529 | deps, |
| 530 | ], |
| 531 | c_args : [ |
| 532 | cargs, |
| 533 | ], |
| 534 | install : true, |
| 535 | link_args : vflag, |
| 536 | link_depends : mapfile, |
| 537 | ) |
| 538 | |
Mario Limonciello | d954d5d | 2019-09-24 16:06:57 -0500 | [diff] [blame] | 539 | version = meson.project_version() |
| 540 | #strip leading characters |
| 541 | if version.startswith('v') |
| 542 | version = version.split('v')[1] |
| 543 | endif |
| 544 | if version.startswith('p') |
| 545 | version = version.split('p')[1] |
| 546 | endif |
| 547 | |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 548 | pkgg = import('pkgconfig') |
| 549 | pkgg.generate( |
Thomas Heijligen | f6a273b | 2022-05-03 12:21:47 +0200 | [diff] [blame] | 550 | libraries : libflashrom, |
Mario Limonciello | d954d5d | 2019-09-24 16:06:57 -0500 | [diff] [blame] | 551 | version : version, |
Mario Limonciello | 2a8d439 | 2019-10-15 13:32:19 -0500 | [diff] [blame] | 552 | name : 'flashrom', |
| 553 | filebase : 'flashrom', |
| 554 | description : 'library to interact with flashrom', |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 555 | ) |
| 556 | |
Felix Singer | 9818b3f | 2022-11-29 17:08:03 +0100 | [diff] [blame] | 557 | config_manfile = configuration_data() |
| 558 | config_manfile.set('VERSION', version) |
| 559 | 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] | 560 | configure_file( |
| 561 | input : 'flashrom.8.tmpl', |
| 562 | output : 'flashrom.8', |
Felix Singer | 9818b3f | 2022-11-29 17:08:03 +0100 | [diff] [blame] | 563 | configuration : config_manfile, |
Richard Hughes | dad3a16 | 2020-02-17 09:57:01 +0000 | [diff] [blame] | 564 | install: true, |
Thomas Heijligen | 454a28c | 2022-05-03 11:50:16 +0200 | [diff] [blame] | 565 | install_dir: join_paths(get_option('mandir'), 'man8'), |
Richard Hughes | dad3a16 | 2020-02-17 09:57:01 +0000 | [diff] [blame] | 566 | ) |
| 567 | |
Thomas Heijligen | a12e010 | 2022-08-13 12:42:05 +0200 | [diff] [blame] | 568 | if get_option('classic_cli').auto() or get_option('classic_cli').enabled() |
| 569 | executable( |
| 570 | 'flashrom', |
| 571 | files( |
| 572 | 'cli_classic.c', |
| 573 | 'cli_common.c', |
| 574 | 'cli_output.c', |
| 575 | ), |
| 576 | c_args : cargs, |
| 577 | include_directories : include_dir, |
| 578 | install : true, |
| 579 | install_dir : get_option('sbindir'), |
| 580 | link_with : libflashrom.get_static_lib(), # flashrom needs internal symbols of libflashrom |
| 581 | ) |
| 582 | endif |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 583 | |
Thomas Heijligen | b7341b1 | 2022-08-13 12:21:44 +0200 | [diff] [blame] | 584 | if get_option('ich_descriptors_tool').auto() or get_option('ich_descriptors_tool').enabled() |
| 585 | subdir('util/ich_descriptors_tool') |
| 586 | endif |
Thomas Heijligen | 3ecf0b6 | 2022-08-18 12:16:29 +0200 | [diff] [blame] | 587 | |
| 588 | programmer_names_active = [] |
| 589 | programmer_names_not_active = [] |
| 590 | foreach p_name, p_data : programmer |
| 591 | if p_data.get('active') |
| 592 | programmer_names_active += p_name |
| 593 | else |
| 594 | programmer_names_not_active += p_name + ' (' + p_data.get('summary', '') + ')' |
| 595 | endif |
| 596 | endforeach |
| 597 | |
| 598 | summary({ |
| 599 | 'active' : [programmer_names_active], |
| 600 | 'non active' : [programmer_names_not_active], |
| 601 | }, section : 'Programmer') |