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', |
Angel Pons | 3064943 | 2021-01-26 10:21:46 +0100 | [diff] [blame] | 4 | meson_version : '>=0.50.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 | |
| 31 | conf = configuration_data() |
| 32 | |
| 33 | cc = meson.get_compiler('c') |
| 34 | add_project_arguments(cc.get_supported_arguments(warning_flags), language : 'c') |
| 35 | add_project_arguments('-D_DEFAULT_SOURCE', language : 'c') |
Rosen Penev | 566193f | 2020-07-18 12:50:16 -0700 | [diff] [blame] | 36 | 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] | 37 | add_project_arguments('-D_BSD_SOURCE', language : 'c') # required for glibc < v2.19 |
| 38 | add_project_arguments('-DFLASHROM_VERSION="' + meson.project_version() + '"', language : 'c') |
| 39 | |
| 40 | # get defaults from configure |
| 41 | config_atahpt = get_option('config_atahpt') |
| 42 | config_atapromise = get_option('config_atapromise') |
| 43 | config_atavia = get_option('config_atavia') |
| 44 | config_buspirate_spi = get_option('config_buspirate_spi') |
| 45 | config_ch341a_spi = get_option('config_ch341a_spi') |
| 46 | config_dediprog = get_option('config_dediprog') |
| 47 | config_developerbox_spi = get_option('config_developerbox_spi') |
| 48 | config_digilent_spi = get_option('config_digilent_spi') |
Jean THOMAS | e28d8e4 | 2022-10-11 17:54:30 +0200 | [diff] [blame] | 49 | config_dirtyjtag_spi = get_option('config_dirtyjtag_spi') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 50 | config_drkaiser = get_option('config_drkaiser') |
| 51 | config_dummy = get_option('config_dummy') |
| 52 | config_ft2232_spi = get_option('config_ft2232_spi') |
| 53 | config_gfxnvidia = get_option('config_gfxnvidia') |
| 54 | config_internal = get_option('config_internal') |
| 55 | config_it8212 = get_option('config_it8212') |
Marc Schink | 7ec2d63 | 2020-12-08 22:20:50 +0100 | [diff] [blame] | 56 | config_jlink_spi = get_option('config_jlink_spi') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 57 | config_linux_mtd = get_option('config_linux_mtd') |
| 58 | config_linux_spi = get_option('config_linux_spi') |
| 59 | config_mstarddc_spi = get_option('config_mstarddc_spi') |
| 60 | config_nic3com = get_option('config_nic3com') |
| 61 | config_nicintel_eeprom = get_option('config_nicintel_eeprom') |
| 62 | config_nicintel = get_option('config_nicintel') |
| 63 | config_nicintel_spi = get_option('config_nicintel_spi') |
| 64 | config_nicnatsemi = get_option('config_nicnatsemi') |
| 65 | config_nicrealtek = get_option('config_nicrealtek') |
| 66 | config_ogp_spi = get_option('config_ogp_spi') |
| 67 | config_pickit2_spi = get_option('config_pickit2_spi') |
| 68 | config_pony_spi = get_option('config_pony_spi') |
| 69 | config_rayer_spi = get_option('config_rayer_spi') |
| 70 | config_satamv = get_option('config_satamv') |
| 71 | config_satasii = get_option('config_satasii') |
| 72 | config_serprog = get_option('config_serprog') |
| 73 | config_usbblaster_spi = get_option('config_usbblaster_spi') |
Miklós Márton | 324929c | 2019-08-01 19:14:10 +0200 | [diff] [blame] | 74 | config_stlinkv3_spi = get_option('config_stlinkv3_spi') |
Thomas Heijligen | 84e9c91 | 2021-06-01 16:22:14 +0200 | [diff] [blame] | 75 | config_default_programmer_name = get_option('default_programmer_name') |
| 76 | config_default_programmer_args = get_option('default_programmer_args') |
Daniel Campello | f7a84fd | 2021-03-16 17:17:14 -0600 | [diff] [blame] | 77 | config_print_wiki= get_option('print_wiki') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 78 | |
| 79 | cargs = [] |
| 80 | deps = [] |
Thomas Heijligen | 51208f3 | 2022-04-28 11:07:29 +0200 | [diff] [blame] | 81 | srcs = files( |
| 82 | '82802ab.c', |
| 83 | 'at45db.c', |
| 84 | 'bitbang_spi.c', |
| 85 | 'edi.c', |
| 86 | 'en29lv640b.c', |
| 87 | 'flashchips.c', |
| 88 | 'flashrom.c', |
| 89 | 'fmap.c', |
| 90 | 'helpers.c', |
Edward O'Callaghan | 4c76c73 | 2022-08-12 11:03:00 +1000 | [diff] [blame] | 91 | 'helpers_fileio.c', |
Thomas Heijligen | 51208f3 | 2022-04-28 11:07:29 +0200 | [diff] [blame] | 92 | 'ich_descriptors.c', |
| 93 | 'jedec.c', |
| 94 | 'layout.c', |
| 95 | 'libflashrom.c', |
| 96 | 'opaque.c', |
Edward O'Callaghan | 63f6a37 | 2022-08-12 12:56:43 +1000 | [diff] [blame^] | 97 | 'parallel.c', |
Thomas Heijligen | 51208f3 | 2022-04-28 11:07:29 +0200 | [diff] [blame] | 98 | 'print.c', |
| 99 | 'programmer.c', |
| 100 | 'programmer_table.c', |
| 101 | 'sfdp.c', |
| 102 | 'spi25.c', |
| 103 | 'spi25_statusreg.c', |
| 104 | 'spi95.c', |
| 105 | 'spi.c', |
| 106 | 'sst28sf040.c', |
| 107 | 'sst49lfxxxc.c', |
| 108 | 'sst_fwhub.c', |
| 109 | 'stm50.c', |
| 110 | 'udelay.c', |
| 111 | 'w29ee011.c', |
| 112 | 'w39.c', |
| 113 | 'writeprotect.c', |
| 114 | 'writeprotect_ranges.c', |
| 115 | ) |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 116 | |
Thomas Heijligen | 328a64a | 2022-04-25 14:42:17 +0200 | [diff] [blame] | 117 | subdir('platform') |
| 118 | |
Peter Marheine | 306c8b7 | 2022-01-21 02:07:30 +0000 | [diff] [blame] | 119 | host_is_x86 = ['x86', 'x86_64'].contains(host_machine.cpu_family()) |
| 120 | |
| 121 | need_serial = [ |
| 122 | config_buspirate_spi, config_pony_spi, config_serprog, |
| 123 | ].contains(true) |
| 124 | need_bitbang_spi = [ |
| 125 | config_internal, config_nicintel_spi, config_ogp_spi, |
| 126 | config_pony_spi, config_rayer_spi, |
| 127 | ].contains(true) |
| 128 | need_raw_mem_access = [ |
| 129 | config_atapromise, config_drkaiser, config_gfxnvidia, config_internal, |
| 130 | config_it8212, config_nicintel, config_nicintel_eeprom, config_nicintel_spi, |
| 131 | config_ogp_spi, config_satamv, config_satasii, |
| 132 | ].contains(true) |
| 133 | # Internal programmer uses x86 features if the system is x86 |
| 134 | need_x86_msr = config_internal and host_is_x86 |
| 135 | need_x86_port_io = [ |
| 136 | config_atahpt, config_atapromise, config_internal and host_is_x86, |
| 137 | config_nic3com, config_nicnatsemi, config_nicrealtek, config_rayer_spi, |
| 138 | config_satamv, |
| 139 | ].contains(true) |
| 140 | need_libpci = [ |
| 141 | config_atahpt, config_atapromise, config_atavia, |
| 142 | config_drkaiser, config_gfxnvidia, config_internal, config_it8212, |
| 143 | config_nic3com, config_nicintel, config_nicintel_eeprom, config_nicintel_spi, |
| 144 | config_nicnatsemi, config_nicrealtek, config_ogp_spi, config_satamv, |
| 145 | config_satasii, |
| 146 | ].contains(true) |
| 147 | need_libusb1 = [ |
| 148 | config_ch341a_spi, config_dediprog, config_developerbox_spi, |
| 149 | config_digilent_spi, config_dirtyjtag_spi, config_pickit2_spi, |
| 150 | config_stlinkv3_spi, |
| 151 | ].contains(true) |
| 152 | need_libftdi1 = [ |
| 153 | config_ft2232_spi, config_usbblaster_spi, |
| 154 | ].contains(true) |
| 155 | need_libjaylink = config_jlink_spi |
| 156 | |
| 157 | if (need_x86_port_io or need_x86_msr) and not host_is_x86 |
| 158 | error('one or more enabled programmer only supports x86 and target is not') |
| 159 | endif |
| 160 | |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 161 | |
| 162 | # check for required symbols |
| 163 | if cc.has_function('clock_gettime') |
| 164 | add_project_arguments('-DHAVE_CLOCK_GETTIME=1', language : 'c') |
| 165 | endif |
| 166 | if cc.has_function('strnlen') |
| 167 | add_project_arguments('-DHAVE_STRNLEN=1', language : 'c') |
| 168 | endif |
| 169 | if cc.check_header('sys/utsname.h') |
| 170 | add_project_arguments('-DHAVE_UTSNAME=1', language : 'c') |
| 171 | endif |
Thomas Heijligen | c02b1a9 | 2022-04-25 14:54:10 +0200 | [diff] [blame] | 172 | if host_machine.system() in ['cygwin', 'windows'] |
| 173 | add_project_arguments('-DIS_WINDOWS=1', language : 'c') |
| 174 | else |
| 175 | add_project_arguments('-DIS_WINDOWS=0', language : 'c') |
| 176 | endif |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 177 | |
| 178 | # some programmers require libusb |
| 179 | if get_option('usb') |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 180 | srcs += files('usbdev.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 181 | deps += dependency('libusb-1.0') |
Peter Marheine | 306c8b7 | 2022-01-21 02:07:30 +0000 | [diff] [blame] | 182 | elif need_libusb1 |
| 183 | error('usb is disabled but one or more enabled programmer requires USB access') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 184 | endif |
| 185 | |
| 186 | # some programmers require libpci |
| 187 | if get_option('pciutils') |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 188 | srcs += files('pcidev.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 189 | deps += dependency('libpci') |
Peter Marheine | 306c8b7 | 2022-01-21 02:07:30 +0000 | [diff] [blame] | 190 | elif need_libpci |
| 191 | error('pciutils is disabled but one or more enabled programmer requires PCI access') |
| 192 | endif |
| 193 | |
| 194 | if need_libftdi1 |
| 195 | deps += dependency('libftdi1') |
| 196 | endif |
| 197 | |
| 198 | if need_libjaylink |
| 199 | deps += dependency('libjaylink') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 200 | endif |
| 201 | |
| 202 | # set defines for configured programmers |
| 203 | if config_atahpt |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 204 | srcs += files('atahpt.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 205 | cargs += '-DCONFIG_ATAHPT=1' |
| 206 | endif |
| 207 | if config_atapromise |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 208 | srcs += files('atapromise.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 209 | cargs += '-DCONFIG_ATAPROMISE=1' |
| 210 | endif |
| 211 | if config_atavia |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 212 | srcs += files('atavia.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 213 | cargs += '-DCONFIG_ATAVIA=1' |
| 214 | endif |
| 215 | if config_buspirate_spi |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 216 | srcs += files('buspirate_spi.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 217 | cargs += '-DCONFIG_BUSPIRATE_SPI=1' |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 218 | endif |
| 219 | if config_ch341a_spi |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 220 | srcs += files('ch341a_spi.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 221 | cargs += '-DCONFIG_CH341A_SPI=1' |
| 222 | endif |
| 223 | if config_dediprog |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 224 | srcs += files('dediprog.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 225 | cargs += '-DCONFIG_DEDIPROG=1' |
| 226 | endif |
| 227 | if config_developerbox_spi |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 228 | srcs += files('developerbox_spi.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 229 | cargs += '-DCONFIG_DEVELOPERBOX_SPI=1' |
| 230 | endif |
| 231 | if config_digilent_spi |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 232 | srcs += files('digilent_spi.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 233 | cargs += '-DCONFIG_DIGILENT_SPI=1' |
| 234 | endif |
Jean THOMAS | e28d8e4 | 2022-10-11 17:54:30 +0200 | [diff] [blame] | 235 | if config_dirtyjtag_spi |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 236 | srcs += files('dirtyjtag_spi.c') |
Jean THOMAS | e28d8e4 | 2022-10-11 17:54:30 +0200 | [diff] [blame] | 237 | cargs += '-DCONFIG_DIRTYJTAG_SPI=1' |
| 238 | endif |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 239 | if config_drkaiser |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 240 | srcs += files('drkaiser.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 241 | cargs += '-DCONFIG_DRKAISER=1' |
| 242 | endif |
| 243 | if config_dummy |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 244 | srcs += files('dummyflasher.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 245 | cargs += '-DCONFIG_DUMMY=1' |
| 246 | endif |
| 247 | if config_ft2232_spi |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 248 | srcs += files('ft2232_spi.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 249 | cargs += '-DCONFIG_FT2232_SPI=1' |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 250 | cargs += '-DHAVE_FT232H=1' |
| 251 | endif |
| 252 | if config_gfxnvidia |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 253 | srcs += files('gfxnvidia.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 254 | cargs += '-DCONFIG_GFXNVIDIA=1' |
| 255 | endif |
| 256 | if config_internal |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 257 | srcs += files( |
| 258 | 'board_enable.c', |
| 259 | 'cbtable.c', |
| 260 | 'chipset_enable.c', |
| 261 | 'internal.c', |
| 262 | 'processor_enable.c', |
| 263 | ) |
Peter Marheine | 306c8b7 | 2022-01-21 02:07:30 +0000 | [diff] [blame] | 264 | if host_is_x86 |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 265 | srcs += files( |
| 266 | 'amd_imc.c', |
| 267 | 'dmi.c', |
| 268 | 'ichspi.c', |
| 269 | 'it87spi.c', |
| 270 | 'mcp6x_spi.c', |
| 271 | 'sb600spi.c', |
| 272 | 'wbsio_spi.c', |
| 273 | ) |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 274 | endif |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 275 | cargs += '-DCONFIG_INTERNAL=1' |
| 276 | if get_option('config_internal_dmi') |
| 277 | # Use internal DMI/SMBIOS decoder by default instead of relying on dmidecode. |
| 278 | cargs += '-DCONFIG_INTERNAL_DMI=1' |
| 279 | endif |
| 280 | endif |
| 281 | if config_it8212 |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 282 | srcs += files('it8212.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 283 | cargs += '-DCONFIG_IT8212=1' |
| 284 | endif |
Marc Schink | 7ec2d63 | 2020-12-08 22:20:50 +0100 | [diff] [blame] | 285 | if config_jlink_spi |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 286 | srcs += files('jlink_spi.c') |
Marc Schink | 7ec2d63 | 2020-12-08 22:20:50 +0100 | [diff] [blame] | 287 | cargs += '-DCONFIG_JLINK_SPI=1' |
Marc Schink | 7ec2d63 | 2020-12-08 22:20:50 +0100 | [diff] [blame] | 288 | endif |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 289 | if config_linux_mtd |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 290 | srcs += files('linux_mtd.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 291 | cargs += '-DCONFIG_LINUX_MTD=1' |
| 292 | endif |
| 293 | if config_linux_spi |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 294 | srcs += files('linux_spi.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 295 | cargs += '-DCONFIG_LINUX_SPI=1' |
| 296 | endif |
| 297 | if config_mstarddc_spi |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 298 | srcs += files('mstarddc_spi.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 299 | cargs += '-DCONFIG_MSTARDDC_SPI=1' |
| 300 | endif |
| 301 | if config_nic3com |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 302 | srcs += files('nic3com.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 303 | cargs += '-DCONFIG_NIC3COM=1' |
| 304 | endif |
| 305 | if config_nicintel |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 306 | srcs += files('nicintel.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 307 | cargs += '-DCONFIG_NICINTEL=1' |
| 308 | endif |
| 309 | if config_nicintel_eeprom |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 310 | srcs += files('nicintel_eeprom.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 311 | cargs += '-DCONFIG_NICINTEL_EEPROM=1' |
| 312 | endif |
| 313 | if config_nicintel_spi |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 314 | srcs += files('nicintel_spi.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 315 | cargs += '-DCONFIG_NICINTEL_SPI=1' |
| 316 | endif |
| 317 | if config_nicnatsemi |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 318 | srcs += files('nicnatsemi.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 319 | cargs += '-DCONFIG_NICNATSEMI=1' |
| 320 | endif |
| 321 | if config_nicrealtek |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 322 | srcs += files('nicrealtek.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 323 | cargs += '-DCONFIG_NICREALTEK=1' |
| 324 | endif |
| 325 | if config_ogp_spi |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 326 | srcs += files('ogp_spi.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 327 | cargs += '-DCONFIG_OGP_SPI=1' |
| 328 | endif |
| 329 | if config_pickit2_spi |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 330 | srcs += files('pickit2_spi.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 331 | cargs += '-DCONFIG_PICKIT2_SPI=1' |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 332 | endif |
| 333 | if config_pony_spi |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 334 | srcs += files('pony_spi.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 335 | cargs += '-DCONFIG_PONY_SPI=1' |
| 336 | endif |
| 337 | if config_rayer_spi |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 338 | srcs += files('rayer_spi.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 339 | cargs += '-DCONFIG_RAYER_SPI=1' |
| 340 | endif |
| 341 | if config_satamv |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 342 | srcs += files('satamv.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 343 | cargs += '-DCONFIG_SATAMV=1' |
| 344 | endif |
| 345 | if config_satasii |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 346 | srcs += files('satasii.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 347 | cargs += '-DCONFIG_SATASII=1' |
| 348 | endif |
| 349 | if config_serprog |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 350 | srcs += files('serprog.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 351 | cargs += '-DCONFIG_SERPROG=1' |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 352 | endif |
| 353 | if config_usbblaster_spi |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 354 | srcs += files('usbblaster_spi.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 355 | cargs += '-DCONFIG_USBBLASTER_SPI=1' |
| 356 | endif |
Miklós Márton | 324929c | 2019-08-01 19:14:10 +0200 | [diff] [blame] | 357 | if config_stlinkv3_spi |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 358 | srcs += files('stlinkv3_spi.c') |
Miklós Márton | 324929c | 2019-08-01 19:14:10 +0200 | [diff] [blame] | 359 | cargs += '-DCONFIG_STLINKV3_SPI=1' |
| 360 | endif |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 361 | |
| 362 | # bitbanging SPI infrastructure |
Peter Marheine | 306c8b7 | 2022-01-21 02:07:30 +0000 | [diff] [blame] | 363 | if need_bitbang_spi |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 364 | srcs += files('bitbang_spi.c') |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 365 | cargs += '-DCONFIG_BITBANG_SPI=1' |
| 366 | endif |
| 367 | |
Peter Marheine | 306c8b7 | 2022-01-21 02:07:30 +0000 | [diff] [blame] | 368 | if need_raw_mem_access |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 369 | srcs += files('hwaccess_physmap.c') |
Peter Marheine | 306c8b7 | 2022-01-21 02:07:30 +0000 | [diff] [blame] | 370 | endif |
| 371 | |
| 372 | if need_x86_port_io |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 373 | srcs += files('hwaccess_x86_io.c') |
Thomas Heijligen | a065520 | 2021-12-14 16:36:05 +0100 | [diff] [blame] | 374 | cargs += '-D__FLASHROM_HAVE_OUTB__=1' |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 375 | endif |
| 376 | |
Peter Marheine | 306c8b7 | 2022-01-21 02:07:30 +0000 | [diff] [blame] | 377 | if need_x86_msr |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 378 | srcs += files('hwaccess_x86_msr.c') |
Peter Marheine | 306c8b7 | 2022-01-21 02:07:30 +0000 | [diff] [blame] | 379 | endif |
| 380 | |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 381 | # raw serial IO |
| 382 | if need_serial |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 383 | srcs += files('serial.c') |
Thomas Heijligen | 140c126 | 2021-09-27 15:12:26 +0200 | [diff] [blame] | 384 | if host_machine.system() == 'linux' |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 385 | srcs += files('custom_baud_linux.c') |
Thomas Heijligen | 140c126 | 2021-09-27 15:12:26 +0200 | [diff] [blame] | 386 | else |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 387 | srcs += files('custom_baud.c') |
Thomas Heijligen | 140c126 | 2021-09-27 15:12:26 +0200 | [diff] [blame] | 388 | endif |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 389 | endif |
| 390 | |
Thomas Heijligen | 2ae9bf2 | 2022-05-03 12:00:14 +0200 | [diff] [blame] | 391 | if config_print_wiki |
Thomas Heijligen | 4bd966c | 2022-05-16 10:56:55 +0200 | [diff] [blame] | 392 | srcs += files('print_wiki.c') |
Thomas Heijligen | 2ae9bf2 | 2022-05-03 12:00:14 +0200 | [diff] [blame] | 393 | cargs += '-DCONFIG_PRINT_WIKI=1' |
| 394 | endif |
| 395 | |
| 396 | if config_default_programmer_name != '' |
| 397 | cargs += '-DCONFIG_DEFAULT_PROGRAMMER_NAME=&programmer_' + config_default_programmer_name |
| 398 | else |
| 399 | cargs += '-DCONFIG_DEFAULT_PROGRAMMER_NAME=NULL' |
| 400 | endif |
| 401 | |
| 402 | cargs += '-DCONFIG_DEFAULT_PROGRAMMER_ARGS="' + config_default_programmer_args + '"' |
| 403 | |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 404 | install_headers([ |
Thomas Heijligen | 58015c2 | 2022-04-14 13:50:55 +0200 | [diff] [blame] | 405 | 'include/libflashrom.h', |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 406 | ], |
| 407 | ) |
| 408 | |
Thomas Heijligen | 58015c2 | 2022-04-14 13:50:55 +0200 | [diff] [blame] | 409 | include_dir = include_directories('include') |
| 410 | |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 411 | mapfile = 'libflashrom.map' |
| 412 | vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile) |
Thomas Heijligen | f6a273b | 2022-05-03 12:21:47 +0200 | [diff] [blame] | 413 | libflashrom = both_libraries( |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 414 | 'flashrom', |
| 415 | sources : [ |
| 416 | srcs, |
| 417 | ], |
Thomas Heijligen | 58015c2 | 2022-04-14 13:50:55 +0200 | [diff] [blame] | 418 | include_directories : include_dir, |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 419 | soversion : lt_current, |
| 420 | version : lt_version, |
| 421 | dependencies : [ |
| 422 | deps, |
| 423 | ], |
| 424 | c_args : [ |
| 425 | cargs, |
| 426 | ], |
| 427 | install : true, |
| 428 | link_args : vflag, |
| 429 | link_depends : mapfile, |
| 430 | ) |
| 431 | |
Mario Limonciello | d954d5d | 2019-09-24 16:06:57 -0500 | [diff] [blame] | 432 | version = meson.project_version() |
| 433 | #strip leading characters |
| 434 | if version.startswith('v') |
| 435 | version = version.split('v')[1] |
| 436 | endif |
| 437 | if version.startswith('p') |
| 438 | version = version.split('p')[1] |
| 439 | endif |
| 440 | |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 441 | pkgg = import('pkgconfig') |
| 442 | pkgg.generate( |
Thomas Heijligen | f6a273b | 2022-05-03 12:21:47 +0200 | [diff] [blame] | 443 | libraries : libflashrom, |
Mario Limonciello | d954d5d | 2019-09-24 16:06:57 -0500 | [diff] [blame] | 444 | version : version, |
Mario Limonciello | 2a8d439 | 2019-10-15 13:32:19 -0500 | [diff] [blame] | 445 | name : 'flashrom', |
| 446 | filebase : 'flashrom', |
| 447 | description : 'library to interact with flashrom', |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 448 | ) |
| 449 | |
Richard Hughes | dad3a16 | 2020-02-17 09:57:01 +0000 | [diff] [blame] | 450 | conf.set('VERSION', version) |
Nikolai Artemiev | 47cb6fc | 2022-07-22 09:58:14 +1000 | [diff] [blame] | 451 | conf.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] | 452 | configure_file( |
| 453 | input : 'flashrom.8.tmpl', |
| 454 | output : 'flashrom.8', |
| 455 | configuration : conf, |
| 456 | install: true, |
Thomas Heijligen | 454a28c | 2022-05-03 11:50:16 +0200 | [diff] [blame] | 457 | install_dir: join_paths(get_option('mandir'), 'man8'), |
Richard Hughes | dad3a16 | 2020-02-17 09:57:01 +0000 | [diff] [blame] | 458 | ) |
| 459 | |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 460 | executable( |
| 461 | 'flashrom', |
Thomas Heijligen | f6a273b | 2022-05-03 12:21:47 +0200 | [diff] [blame] | 462 | files( |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 463 | 'cli_classic.c', |
| 464 | 'cli_common.c', |
| 465 | 'cli_output.c', |
Thomas Heijligen | f6a273b | 2022-05-03 12:21:47 +0200 | [diff] [blame] | 466 | ), |
| 467 | c_args : cargs, |
Thomas Heijligen | 58015c2 | 2022-04-14 13:50:55 +0200 | [diff] [blame] | 468 | include_directories : include_dir, |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 469 | install : true, |
Thomas Heijligen | f6a273b | 2022-05-03 12:21:47 +0200 | [diff] [blame] | 470 | install_dir : get_option('sbindir'), |
| 471 | link_with : libflashrom.get_static_lib(), # flashrom needs internal symbols of libflashrom |
Richard Hughes | cb97368 | 2018-12-19 11:44:22 +0000 | [diff] [blame] | 472 | ) |
| 473 | |
Thomas Heijligen | b7341b1 | 2022-08-13 12:21:44 +0200 | [diff] [blame] | 474 | if get_option('ich_descriptors_tool').auto() or get_option('ich_descriptors_tool').enabled() |
| 475 | subdir('util/ich_descriptors_tool') |
| 476 | endif |