blob: 4acecf6891d0eeeacaa4d2f5296566324d680023 [file] [log] [blame]
Richard Hughescb973682018-12-19 11:44:22 +00001project('flashromutils', 'c',
Nikolai Artemiev47cb6fc2022-07-22 09:58:14 +10002 version : run_command('util/getversion.sh', '--version', check : true).stdout().strip(),
Nico Huberb417c0c2019-09-24 22:12:40 +02003 license : 'GPL-2.0',
Angel Pons30649432021-01-26 10:21:46 +01004 meson_version : '>=0.50.0',
Anastasia Klimchuk3c508432022-04-13 15:15:24 +10005 default_options : [
6 'warning_level=2',
7 'c_std=c99',
Anastasia Klimchukc676be92022-04-26 14:53:18 +10008 'werror=true',
Anastasia Klimchuk3c508432022-04-13 15:15:24 +10009 'optimization=s',
Nikolai Artemiev47cb6fc2022-07-22 09:58:14 +100010 'debug=false',
11 ],
Richard Hughescb973682018-12-19 11:44:22 +000012)
13
14# libtool versioning
15lt_current = '1'
16lt_revision = '0'
17lt_age = '0'
18lt_version = '@0@.@1@.@2@'.format(lt_current, lt_age, lt_revision)
19
Jacob Garber4a84ec22019-07-25 19:12:31 -060020# hide/enable some warnings
Richard Hughescb973682018-12-19 11:44:22 +000021warning_flags = [
Anastasia Klimchukcde70112021-10-25 13:20:26 +110022 '-Wshadow',
23 '-Wmissing-prototypes',
Jacob Garber4a84ec22019-07-25 19:12:31 -060024 '-Wwrite-strings',
Richard Hughescb973682018-12-19 11:44:22 +000025 '-Wno-unused-parameter',
Richard Hughescb973682018-12-19 11:44:22 +000026 '-Wno-address-of-packed-member',
27 '-Wno-enum-conversion',
Richard Hughescb973682018-12-19 11:44:22 +000028 '-Wno-missing-braces',
29]
30
31conf = configuration_data()
32
33cc = meson.get_compiler('c')
34add_project_arguments(cc.get_supported_arguments(warning_flags), language : 'c')
35add_project_arguments('-D_DEFAULT_SOURCE', language : 'c')
Rosen Penev566193f2020-07-18 12:50:16 -070036add_project_arguments('-D_POSIX_C_SOURCE=200809L', language : 'c') # required for fileno, nanosleep, and strndup
Richard Hughescb973682018-12-19 11:44:22 +000037add_project_arguments('-D_BSD_SOURCE', language : 'c') # required for glibc < v2.19
38add_project_arguments('-DFLASHROM_VERSION="' + meson.project_version() + '"', language : 'c')
39
40# get defaults from configure
41config_atahpt = get_option('config_atahpt')
42config_atapromise = get_option('config_atapromise')
43config_atavia = get_option('config_atavia')
44config_buspirate_spi = get_option('config_buspirate_spi')
45config_ch341a_spi = get_option('config_ch341a_spi')
46config_dediprog = get_option('config_dediprog')
47config_developerbox_spi = get_option('config_developerbox_spi')
48config_digilent_spi = get_option('config_digilent_spi')
Jean THOMASe28d8e42022-10-11 17:54:30 +020049config_dirtyjtag_spi = get_option('config_dirtyjtag_spi')
Richard Hughescb973682018-12-19 11:44:22 +000050config_drkaiser = get_option('config_drkaiser')
51config_dummy = get_option('config_dummy')
52config_ft2232_spi = get_option('config_ft2232_spi')
53config_gfxnvidia = get_option('config_gfxnvidia')
54config_internal = get_option('config_internal')
55config_it8212 = get_option('config_it8212')
Marc Schink7ec2d632020-12-08 22:20:50 +010056config_jlink_spi = get_option('config_jlink_spi')
Richard Hughescb973682018-12-19 11:44:22 +000057config_linux_mtd = get_option('config_linux_mtd')
58config_linux_spi = get_option('config_linux_spi')
59config_mstarddc_spi = get_option('config_mstarddc_spi')
60config_nic3com = get_option('config_nic3com')
61config_nicintel_eeprom = get_option('config_nicintel_eeprom')
62config_nicintel = get_option('config_nicintel')
63config_nicintel_spi = get_option('config_nicintel_spi')
64config_nicnatsemi = get_option('config_nicnatsemi')
65config_nicrealtek = get_option('config_nicrealtek')
66config_ogp_spi = get_option('config_ogp_spi')
67config_pickit2_spi = get_option('config_pickit2_spi')
68config_pony_spi = get_option('config_pony_spi')
69config_rayer_spi = get_option('config_rayer_spi')
70config_satamv = get_option('config_satamv')
71config_satasii = get_option('config_satasii')
72config_serprog = get_option('config_serprog')
73config_usbblaster_spi = get_option('config_usbblaster_spi')
Miklós Márton324929c2019-08-01 19:14:10 +020074config_stlinkv3_spi = get_option('config_stlinkv3_spi')
Thomas Heijligen84e9c912021-06-01 16:22:14 +020075config_default_programmer_name = get_option('default_programmer_name')
76config_default_programmer_args = get_option('default_programmer_args')
Daniel Campellof7a84fd2021-03-16 17:17:14 -060077config_print_wiki= get_option('print_wiki')
Richard Hughescb973682018-12-19 11:44:22 +000078
79cargs = []
80deps = []
Thomas Heijligen51208f32022-04-28 11:07:29 +020081srcs = 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'Callaghan4c76c732022-08-12 11:03:00 +100091 'helpers_fileio.c',
Thomas Heijligen51208f32022-04-28 11:07:29 +020092 'ich_descriptors.c',
93 'jedec.c',
94 'layout.c',
95 'libflashrom.c',
96 'opaque.c',
97 'print.c',
98 'programmer.c',
99 'programmer_table.c',
100 'sfdp.c',
101 'spi25.c',
102 'spi25_statusreg.c',
103 'spi95.c',
104 'spi.c',
105 'sst28sf040.c',
106 'sst49lfxxxc.c',
107 'sst_fwhub.c',
108 'stm50.c',
109 'udelay.c',
110 'w29ee011.c',
111 'w39.c',
112 'writeprotect.c',
113 'writeprotect_ranges.c',
114)
Richard Hughescb973682018-12-19 11:44:22 +0000115
Thomas Heijligen328a64a2022-04-25 14:42:17 +0200116subdir('platform')
117
Peter Marheine306c8b72022-01-21 02:07:30 +0000118host_is_x86 = ['x86', 'x86_64'].contains(host_machine.cpu_family())
119
120need_serial = [
121 config_buspirate_spi, config_pony_spi, config_serprog,
122].contains(true)
123need_bitbang_spi = [
124 config_internal, config_nicintel_spi, config_ogp_spi,
125 config_pony_spi, config_rayer_spi,
126].contains(true)
127need_raw_mem_access = [
128 config_atapromise, config_drkaiser, config_gfxnvidia, config_internal,
129 config_it8212, config_nicintel, config_nicintel_eeprom, config_nicintel_spi,
130 config_ogp_spi, config_satamv, config_satasii,
131].contains(true)
132# Internal programmer uses x86 features if the system is x86
133need_x86_msr = config_internal and host_is_x86
134need_x86_port_io = [
135 config_atahpt, config_atapromise, config_internal and host_is_x86,
136 config_nic3com, config_nicnatsemi, config_nicrealtek, config_rayer_spi,
137 config_satamv,
138].contains(true)
139need_libpci = [
140 config_atahpt, config_atapromise, config_atavia,
141 config_drkaiser, config_gfxnvidia, config_internal, config_it8212,
142 config_nic3com, config_nicintel, config_nicintel_eeprom, config_nicintel_spi,
143 config_nicnatsemi, config_nicrealtek, config_ogp_spi, config_satamv,
144 config_satasii,
145].contains(true)
146need_libusb1 = [
147 config_ch341a_spi, config_dediprog, config_developerbox_spi,
148 config_digilent_spi, config_dirtyjtag_spi, config_pickit2_spi,
149 config_stlinkv3_spi,
150].contains(true)
151need_libftdi1 = [
152 config_ft2232_spi, config_usbblaster_spi,
153].contains(true)
154need_libjaylink = config_jlink_spi
155
156if (need_x86_port_io or need_x86_msr) and not host_is_x86
157 error('one or more enabled programmer only supports x86 and target is not')
158endif
159
Richard Hughescb973682018-12-19 11:44:22 +0000160
161# check for required symbols
162if cc.has_function('clock_gettime')
163 add_project_arguments('-DHAVE_CLOCK_GETTIME=1', language : 'c')
164endif
165if cc.has_function('strnlen')
166 add_project_arguments('-DHAVE_STRNLEN=1', language : 'c')
167endif
168if cc.check_header('sys/utsname.h')
169 add_project_arguments('-DHAVE_UTSNAME=1', language : 'c')
170endif
Thomas Heijligenc02b1a92022-04-25 14:54:10 +0200171if host_machine.system() in ['cygwin', 'windows']
172 add_project_arguments('-DIS_WINDOWS=1', language : 'c')
173else
174 add_project_arguments('-DIS_WINDOWS=0', language : 'c')
175endif
Richard Hughescb973682018-12-19 11:44:22 +0000176
177# some programmers require libusb
178if get_option('usb')
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200179 srcs += files('usbdev.c')
Richard Hughescb973682018-12-19 11:44:22 +0000180 deps += dependency('libusb-1.0')
Peter Marheine306c8b72022-01-21 02:07:30 +0000181elif need_libusb1
182 error('usb is disabled but one or more enabled programmer requires USB access')
Richard Hughescb973682018-12-19 11:44:22 +0000183endif
184
185# some programmers require libpci
186if get_option('pciutils')
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200187 srcs += files('pcidev.c')
Richard Hughescb973682018-12-19 11:44:22 +0000188 deps += dependency('libpci')
Peter Marheine306c8b72022-01-21 02:07:30 +0000189elif need_libpci
190 error('pciutils is disabled but one or more enabled programmer requires PCI access')
191endif
192
193if need_libftdi1
194 deps += dependency('libftdi1')
195endif
196
197if need_libjaylink
198 deps += dependency('libjaylink')
Richard Hughescb973682018-12-19 11:44:22 +0000199endif
200
201# set defines for configured programmers
202if config_atahpt
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200203 srcs += files('atahpt.c')
Richard Hughescb973682018-12-19 11:44:22 +0000204 cargs += '-DCONFIG_ATAHPT=1'
205endif
206if config_atapromise
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200207 srcs += files('atapromise.c')
Richard Hughescb973682018-12-19 11:44:22 +0000208 cargs += '-DCONFIG_ATAPROMISE=1'
209endif
210if config_atavia
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200211 srcs += files('atavia.c')
Richard Hughescb973682018-12-19 11:44:22 +0000212 cargs += '-DCONFIG_ATAVIA=1'
213endif
214if config_buspirate_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200215 srcs += files('buspirate_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000216 cargs += '-DCONFIG_BUSPIRATE_SPI=1'
Richard Hughescb973682018-12-19 11:44:22 +0000217endif
218if config_ch341a_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200219 srcs += files('ch341a_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000220 cargs += '-DCONFIG_CH341A_SPI=1'
221endif
222if config_dediprog
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200223 srcs += files('dediprog.c')
Richard Hughescb973682018-12-19 11:44:22 +0000224 cargs += '-DCONFIG_DEDIPROG=1'
225endif
226if config_developerbox_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200227 srcs += files('developerbox_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000228 cargs += '-DCONFIG_DEVELOPERBOX_SPI=1'
229endif
230if config_digilent_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200231 srcs += files('digilent_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000232 cargs += '-DCONFIG_DIGILENT_SPI=1'
233endif
Jean THOMASe28d8e42022-10-11 17:54:30 +0200234if config_dirtyjtag_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200235 srcs += files('dirtyjtag_spi.c')
Jean THOMASe28d8e42022-10-11 17:54:30 +0200236 cargs += '-DCONFIG_DIRTYJTAG_SPI=1'
237endif
Richard Hughescb973682018-12-19 11:44:22 +0000238if config_drkaiser
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200239 srcs += files('drkaiser.c')
Richard Hughescb973682018-12-19 11:44:22 +0000240 cargs += '-DCONFIG_DRKAISER=1'
241endif
242if config_dummy
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200243 srcs += files('dummyflasher.c')
Richard Hughescb973682018-12-19 11:44:22 +0000244 cargs += '-DCONFIG_DUMMY=1'
245endif
246if config_ft2232_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200247 srcs += files('ft2232_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000248 cargs += '-DCONFIG_FT2232_SPI=1'
Richard Hughescb973682018-12-19 11:44:22 +0000249 cargs += '-DHAVE_FT232H=1'
250endif
251if config_gfxnvidia
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200252 srcs += files('gfxnvidia.c')
Richard Hughescb973682018-12-19 11:44:22 +0000253 cargs += '-DCONFIG_GFXNVIDIA=1'
254endif
255if config_internal
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200256 srcs += files(
257 'board_enable.c',
258 'cbtable.c',
259 'chipset_enable.c',
260 'internal.c',
261 'processor_enable.c',
262 )
Peter Marheine306c8b72022-01-21 02:07:30 +0000263 if host_is_x86
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200264 srcs += files(
265 'amd_imc.c',
266 'dmi.c',
267 'ichspi.c',
268 'it87spi.c',
269 'mcp6x_spi.c',
270 'sb600spi.c',
271 'wbsio_spi.c',
272 )
Richard Hughescb973682018-12-19 11:44:22 +0000273 endif
Richard Hughescb973682018-12-19 11:44:22 +0000274 cargs += '-DCONFIG_INTERNAL=1'
275 if get_option('config_internal_dmi')
276 # Use internal DMI/SMBIOS decoder by default instead of relying on dmidecode.
277 cargs += '-DCONFIG_INTERNAL_DMI=1'
278 endif
279endif
280if config_it8212
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200281 srcs += files('it8212.c')
Richard Hughescb973682018-12-19 11:44:22 +0000282 cargs += '-DCONFIG_IT8212=1'
283endif
Marc Schink7ec2d632020-12-08 22:20:50 +0100284if config_jlink_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200285 srcs += files('jlink_spi.c')
Marc Schink7ec2d632020-12-08 22:20:50 +0100286 cargs += '-DCONFIG_JLINK_SPI=1'
Marc Schink7ec2d632020-12-08 22:20:50 +0100287endif
Richard Hughescb973682018-12-19 11:44:22 +0000288if config_linux_mtd
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200289 srcs += files('linux_mtd.c')
Richard Hughescb973682018-12-19 11:44:22 +0000290 cargs += '-DCONFIG_LINUX_MTD=1'
291endif
292if config_linux_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200293 srcs += files('linux_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000294 cargs += '-DCONFIG_LINUX_SPI=1'
295endif
296if config_mstarddc_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200297 srcs += files('mstarddc_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000298 cargs += '-DCONFIG_MSTARDDC_SPI=1'
299endif
300if config_nic3com
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200301 srcs += files('nic3com.c')
Richard Hughescb973682018-12-19 11:44:22 +0000302 cargs += '-DCONFIG_NIC3COM=1'
303endif
304if config_nicintel
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200305 srcs += files('nicintel.c')
Richard Hughescb973682018-12-19 11:44:22 +0000306 cargs += '-DCONFIG_NICINTEL=1'
307endif
308if config_nicintel_eeprom
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200309 srcs += files('nicintel_eeprom.c')
Richard Hughescb973682018-12-19 11:44:22 +0000310 cargs += '-DCONFIG_NICINTEL_EEPROM=1'
311endif
312if config_nicintel_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200313 srcs += files('nicintel_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000314 cargs += '-DCONFIG_NICINTEL_SPI=1'
315endif
316if config_nicnatsemi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200317 srcs += files('nicnatsemi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000318 cargs += '-DCONFIG_NICNATSEMI=1'
319endif
320if config_nicrealtek
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200321 srcs += files('nicrealtek.c')
Richard Hughescb973682018-12-19 11:44:22 +0000322 cargs += '-DCONFIG_NICREALTEK=1'
323endif
324if config_ogp_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200325 srcs += files('ogp_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000326 cargs += '-DCONFIG_OGP_SPI=1'
327endif
328if config_pickit2_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200329 srcs += files('pickit2_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000330 cargs += '-DCONFIG_PICKIT2_SPI=1'
Richard Hughescb973682018-12-19 11:44:22 +0000331endif
332if config_pony_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200333 srcs += files('pony_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000334 cargs += '-DCONFIG_PONY_SPI=1'
335endif
336if config_rayer_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200337 srcs += files('rayer_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000338 cargs += '-DCONFIG_RAYER_SPI=1'
339endif
340if config_satamv
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200341 srcs += files('satamv.c')
Richard Hughescb973682018-12-19 11:44:22 +0000342 cargs += '-DCONFIG_SATAMV=1'
343endif
344if config_satasii
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200345 srcs += files('satasii.c')
Richard Hughescb973682018-12-19 11:44:22 +0000346 cargs += '-DCONFIG_SATASII=1'
347endif
348if config_serprog
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200349 srcs += files('serprog.c')
Richard Hughescb973682018-12-19 11:44:22 +0000350 cargs += '-DCONFIG_SERPROG=1'
Richard Hughescb973682018-12-19 11:44:22 +0000351endif
352if config_usbblaster_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200353 srcs += files('usbblaster_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000354 cargs += '-DCONFIG_USBBLASTER_SPI=1'
355endif
Miklós Márton324929c2019-08-01 19:14:10 +0200356if config_stlinkv3_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200357 srcs += files('stlinkv3_spi.c')
Miklós Márton324929c2019-08-01 19:14:10 +0200358 cargs += '-DCONFIG_STLINKV3_SPI=1'
359endif
Richard Hughescb973682018-12-19 11:44:22 +0000360
361# bitbanging SPI infrastructure
Peter Marheine306c8b72022-01-21 02:07:30 +0000362if need_bitbang_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200363 srcs += files('bitbang_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000364 cargs += '-DCONFIG_BITBANG_SPI=1'
365endif
366
Peter Marheine306c8b72022-01-21 02:07:30 +0000367if need_raw_mem_access
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200368 srcs += files('hwaccess_physmap.c')
Peter Marheine306c8b72022-01-21 02:07:30 +0000369endif
370
371if need_x86_port_io
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200372 srcs += files('hwaccess_x86_io.c')
Thomas Heijligena0655202021-12-14 16:36:05 +0100373 cargs += '-D__FLASHROM_HAVE_OUTB__=1'
Richard Hughescb973682018-12-19 11:44:22 +0000374endif
375
Peter Marheine306c8b72022-01-21 02:07:30 +0000376if need_x86_msr
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200377 srcs += files('hwaccess_x86_msr.c')
Peter Marheine306c8b72022-01-21 02:07:30 +0000378endif
379
Richard Hughescb973682018-12-19 11:44:22 +0000380# raw serial IO
381if need_serial
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200382 srcs += files('serial.c')
Thomas Heijligen140c1262021-09-27 15:12:26 +0200383 if host_machine.system() == 'linux'
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200384 srcs += files('custom_baud_linux.c')
Thomas Heijligen140c1262021-09-27 15:12:26 +0200385 else
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200386 srcs += files('custom_baud.c')
Thomas Heijligen140c1262021-09-27 15:12:26 +0200387 endif
Richard Hughescb973682018-12-19 11:44:22 +0000388endif
389
Thomas Heijligen2ae9bf22022-05-03 12:00:14 +0200390if config_print_wiki
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200391 srcs += files('print_wiki.c')
Thomas Heijligen2ae9bf22022-05-03 12:00:14 +0200392 cargs += '-DCONFIG_PRINT_WIKI=1'
393endif
394
395if config_default_programmer_name != ''
396 cargs += '-DCONFIG_DEFAULT_PROGRAMMER_NAME=&programmer_' + config_default_programmer_name
397else
398 cargs += '-DCONFIG_DEFAULT_PROGRAMMER_NAME=NULL'
399endif
400
401cargs += '-DCONFIG_DEFAULT_PROGRAMMER_ARGS="' + config_default_programmer_args + '"'
402
Richard Hughescb973682018-12-19 11:44:22 +0000403install_headers([
Thomas Heijligen58015c22022-04-14 13:50:55 +0200404 'include/libflashrom.h',
Richard Hughescb973682018-12-19 11:44:22 +0000405 ],
406)
407
Thomas Heijligen58015c22022-04-14 13:50:55 +0200408include_dir = include_directories('include')
409
Richard Hughescb973682018-12-19 11:44:22 +0000410mapfile = 'libflashrom.map'
411vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile)
Thomas Heijligenf6a273b2022-05-03 12:21:47 +0200412libflashrom = both_libraries(
Richard Hughescb973682018-12-19 11:44:22 +0000413 'flashrom',
414 sources : [
415 srcs,
416 ],
Thomas Heijligen58015c22022-04-14 13:50:55 +0200417 include_directories : include_dir,
Richard Hughescb973682018-12-19 11:44:22 +0000418 soversion : lt_current,
419 version : lt_version,
420 dependencies : [
421 deps,
422 ],
423 c_args : [
424 cargs,
425 ],
426 install : true,
427 link_args : vflag,
428 link_depends : mapfile,
429)
430
Mario Limonciellod954d5d2019-09-24 16:06:57 -0500431version = meson.project_version()
432#strip leading characters
433if version.startswith('v')
434 version = version.split('v')[1]
435endif
436if version.startswith('p')
437 version = version.split('p')[1]
438endif
439
Richard Hughescb973682018-12-19 11:44:22 +0000440pkgg = import('pkgconfig')
441pkgg.generate(
Thomas Heijligenf6a273b2022-05-03 12:21:47 +0200442 libraries : libflashrom,
Mario Limonciellod954d5d2019-09-24 16:06:57 -0500443 version : version,
Mario Limonciello2a8d4392019-10-15 13:32:19 -0500444 name : 'flashrom',
445 filebase : 'flashrom',
446 description : 'library to interact with flashrom',
Richard Hughescb973682018-12-19 11:44:22 +0000447)
448
Richard Hughesdad3a162020-02-17 09:57:01 +0000449conf.set('VERSION', version)
Nikolai Artemiev47cb6fc2022-07-22 09:58:14 +1000450conf.set('MAN_DATE', run_command('util/getversion.sh', '--man-date', check : true).stdout().strip())
Richard Hughesdad3a162020-02-17 09:57:01 +0000451configure_file(
452 input : 'flashrom.8.tmpl',
453 output : 'flashrom.8',
454 configuration : conf,
455 install: true,
Thomas Heijligen454a28c2022-05-03 11:50:16 +0200456 install_dir: join_paths(get_option('mandir'), 'man8'),
Richard Hughesdad3a162020-02-17 09:57:01 +0000457)
458
Richard Hughescb973682018-12-19 11:44:22 +0000459executable(
460 'flashrom',
Thomas Heijligenf6a273b2022-05-03 12:21:47 +0200461 files(
Richard Hughescb973682018-12-19 11:44:22 +0000462 'cli_classic.c',
463 'cli_common.c',
464 'cli_output.c',
Thomas Heijligenf6a273b2022-05-03 12:21:47 +0200465 ),
466 c_args : cargs,
Thomas Heijligen58015c22022-04-14 13:50:55 +0200467 include_directories : include_dir,
Richard Hughescb973682018-12-19 11:44:22 +0000468 install : true,
Thomas Heijligenf6a273b2022-05-03 12:21:47 +0200469 install_dir : get_option('sbindir'),
470 link_with : libflashrom.get_static_lib(), # flashrom needs internal symbols of libflashrom
Richard Hughescb973682018-12-19 11:44:22 +0000471)
472
Thomas Heijligenb7341b12022-08-13 12:21:44 +0200473if get_option('ich_descriptors_tool').auto() or get_option('ich_descriptors_tool').enabled()
474 subdir('util/ich_descriptors_tool')
475endif