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