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