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