blob: 03ffbc989e355f08a47180c728793541a6451480 [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',
91 'ich_descriptors.c',
92 'jedec.c',
93 'layout.c',
94 'libflashrom.c',
95 'opaque.c',
96 'print.c',
97 'programmer.c',
98 'programmer_table.c',
99 'sfdp.c',
100 'spi25.c',
101 'spi25_statusreg.c',
102 'spi95.c',
103 'spi.c',
104 'sst28sf040.c',
105 'sst49lfxxxc.c',
106 'sst_fwhub.c',
107 'stm50.c',
108 'udelay.c',
109 'w29ee011.c',
110 'w39.c',
111 'writeprotect.c',
112 'writeprotect_ranges.c',
113)
Richard Hughescb973682018-12-19 11:44:22 +0000114
Thomas Heijligen328a64a2022-04-25 14:42:17 +0200115subdir('platform')
116
Peter Marheine306c8b72022-01-21 02:07:30 +0000117host_is_x86 = ['x86', 'x86_64'].contains(host_machine.cpu_family())
118
119need_serial = [
120 config_buspirate_spi, config_pony_spi, config_serprog,
121].contains(true)
122need_bitbang_spi = [
123 config_internal, config_nicintel_spi, config_ogp_spi,
124 config_pony_spi, config_rayer_spi,
125].contains(true)
126need_raw_mem_access = [
127 config_atapromise, config_drkaiser, config_gfxnvidia, config_internal,
128 config_it8212, config_nicintel, config_nicintel_eeprom, config_nicintel_spi,
129 config_ogp_spi, config_satamv, config_satasii,
130].contains(true)
131# Internal programmer uses x86 features if the system is x86
132need_x86_msr = config_internal and host_is_x86
133need_x86_port_io = [
134 config_atahpt, config_atapromise, config_internal and host_is_x86,
135 config_nic3com, config_nicnatsemi, config_nicrealtek, config_rayer_spi,
136 config_satamv,
137].contains(true)
138need_libpci = [
139 config_atahpt, config_atapromise, config_atavia,
140 config_drkaiser, config_gfxnvidia, config_internal, config_it8212,
141 config_nic3com, config_nicintel, config_nicintel_eeprom, config_nicintel_spi,
142 config_nicnatsemi, config_nicrealtek, config_ogp_spi, config_satamv,
143 config_satasii,
144].contains(true)
145need_libusb1 = [
146 config_ch341a_spi, config_dediprog, config_developerbox_spi,
147 config_digilent_spi, config_dirtyjtag_spi, config_pickit2_spi,
148 config_stlinkv3_spi,
149].contains(true)
150need_libftdi1 = [
151 config_ft2232_spi, config_usbblaster_spi,
152].contains(true)
153need_libjaylink = config_jlink_spi
154
155if (need_x86_port_io or need_x86_msr) and not host_is_x86
156 error('one or more enabled programmer only supports x86 and target is not')
157endif
158
Richard Hughescb973682018-12-19 11:44:22 +0000159
160# check for required symbols
161if cc.has_function('clock_gettime')
162 add_project_arguments('-DHAVE_CLOCK_GETTIME=1', language : 'c')
163endif
164if cc.has_function('strnlen')
165 add_project_arguments('-DHAVE_STRNLEN=1', language : 'c')
166endif
167if cc.check_header('sys/utsname.h')
168 add_project_arguments('-DHAVE_UTSNAME=1', language : 'c')
169endif
Thomas Heijligenc02b1a92022-04-25 14:54:10 +0200170if host_machine.system() in ['cygwin', 'windows']
171 add_project_arguments('-DIS_WINDOWS=1', language : 'c')
172else
173 add_project_arguments('-DIS_WINDOWS=0', language : 'c')
174endif
Richard Hughescb973682018-12-19 11:44:22 +0000175
176# some programmers require libusb
177if get_option('usb')
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200178 srcs += files('usbdev.c')
Richard Hughescb973682018-12-19 11:44:22 +0000179 deps += dependency('libusb-1.0')
Peter Marheine306c8b72022-01-21 02:07:30 +0000180elif need_libusb1
181 error('usb is disabled but one or more enabled programmer requires USB access')
Richard Hughescb973682018-12-19 11:44:22 +0000182endif
183
184# some programmers require libpci
185if get_option('pciutils')
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200186 srcs += files('pcidev.c')
Richard Hughescb973682018-12-19 11:44:22 +0000187 deps += dependency('libpci')
Peter Marheine306c8b72022-01-21 02:07:30 +0000188elif need_libpci
189 error('pciutils is disabled but one or more enabled programmer requires PCI access')
190endif
191
192if need_libftdi1
193 deps += dependency('libftdi1')
194endif
195
196if need_libjaylink
197 deps += dependency('libjaylink')
Richard Hughescb973682018-12-19 11:44:22 +0000198endif
199
200# set defines for configured programmers
201if config_atahpt
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200202 srcs += files('atahpt.c')
Richard Hughescb973682018-12-19 11:44:22 +0000203 cargs += '-DCONFIG_ATAHPT=1'
204endif
205if config_atapromise
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200206 srcs += files('atapromise.c')
Richard Hughescb973682018-12-19 11:44:22 +0000207 cargs += '-DCONFIG_ATAPROMISE=1'
208endif
209if config_atavia
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200210 srcs += files('atavia.c')
Richard Hughescb973682018-12-19 11:44:22 +0000211 cargs += '-DCONFIG_ATAVIA=1'
212endif
213if config_buspirate_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200214 srcs += files('buspirate_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000215 cargs += '-DCONFIG_BUSPIRATE_SPI=1'
Richard Hughescb973682018-12-19 11:44:22 +0000216endif
217if config_ch341a_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200218 srcs += files('ch341a_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000219 cargs += '-DCONFIG_CH341A_SPI=1'
220endif
221if config_dediprog
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200222 srcs += files('dediprog.c')
Richard Hughescb973682018-12-19 11:44:22 +0000223 cargs += '-DCONFIG_DEDIPROG=1'
224endif
225if config_developerbox_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200226 srcs += files('developerbox_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000227 cargs += '-DCONFIG_DEVELOPERBOX_SPI=1'
228endif
229if config_digilent_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200230 srcs += files('digilent_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000231 cargs += '-DCONFIG_DIGILENT_SPI=1'
232endif
Jean THOMASe28d8e42022-10-11 17:54:30 +0200233if config_dirtyjtag_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200234 srcs += files('dirtyjtag_spi.c')
Jean THOMASe28d8e42022-10-11 17:54:30 +0200235 cargs += '-DCONFIG_DIRTYJTAG_SPI=1'
236endif
Richard Hughescb973682018-12-19 11:44:22 +0000237if config_drkaiser
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200238 srcs += files('drkaiser.c')
Richard Hughescb973682018-12-19 11:44:22 +0000239 cargs += '-DCONFIG_DRKAISER=1'
240endif
241if config_dummy
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200242 srcs += files('dummyflasher.c')
Richard Hughescb973682018-12-19 11:44:22 +0000243 cargs += '-DCONFIG_DUMMY=1'
244endif
245if config_ft2232_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200246 srcs += files('ft2232_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000247 cargs += '-DCONFIG_FT2232_SPI=1'
Richard Hughescb973682018-12-19 11:44:22 +0000248 cargs += '-DHAVE_FT232H=1'
249endif
250if config_gfxnvidia
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200251 srcs += files('gfxnvidia.c')
Richard Hughescb973682018-12-19 11:44:22 +0000252 cargs += '-DCONFIG_GFXNVIDIA=1'
253endif
254if config_internal
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200255 srcs += files(
256 'board_enable.c',
257 'cbtable.c',
258 'chipset_enable.c',
259 'internal.c',
260 'processor_enable.c',
261 )
Peter Marheine306c8b72022-01-21 02:07:30 +0000262 if host_is_x86
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200263 srcs += files(
264 'amd_imc.c',
265 'dmi.c',
266 'ichspi.c',
267 'it87spi.c',
268 'mcp6x_spi.c',
269 'sb600spi.c',
270 'wbsio_spi.c',
271 )
Richard Hughescb973682018-12-19 11:44:22 +0000272 endif
Richard Hughescb973682018-12-19 11:44:22 +0000273 cargs += '-DCONFIG_INTERNAL=1'
274 if get_option('config_internal_dmi')
275 # Use internal DMI/SMBIOS decoder by default instead of relying on dmidecode.
276 cargs += '-DCONFIG_INTERNAL_DMI=1'
277 endif
278endif
279if config_it8212
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200280 srcs += files('it8212.c')
Richard Hughescb973682018-12-19 11:44:22 +0000281 cargs += '-DCONFIG_IT8212=1'
282endif
Marc Schink7ec2d632020-12-08 22:20:50 +0100283if config_jlink_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200284 srcs += files('jlink_spi.c')
Marc Schink7ec2d632020-12-08 22:20:50 +0100285 cargs += '-DCONFIG_JLINK_SPI=1'
Marc Schink7ec2d632020-12-08 22:20:50 +0100286endif
Richard Hughescb973682018-12-19 11:44:22 +0000287if config_linux_mtd
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200288 srcs += files('linux_mtd.c')
Richard Hughescb973682018-12-19 11:44:22 +0000289 cargs += '-DCONFIG_LINUX_MTD=1'
290endif
291if config_linux_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200292 srcs += files('linux_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000293 cargs += '-DCONFIG_LINUX_SPI=1'
294endif
295if config_mstarddc_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200296 srcs += files('mstarddc_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000297 cargs += '-DCONFIG_MSTARDDC_SPI=1'
298endif
299if config_nic3com
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200300 srcs += files('nic3com.c')
Richard Hughescb973682018-12-19 11:44:22 +0000301 cargs += '-DCONFIG_NIC3COM=1'
302endif
303if config_nicintel
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200304 srcs += files('nicintel.c')
Richard Hughescb973682018-12-19 11:44:22 +0000305 cargs += '-DCONFIG_NICINTEL=1'
306endif
307if config_nicintel_eeprom
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200308 srcs += files('nicintel_eeprom.c')
Richard Hughescb973682018-12-19 11:44:22 +0000309 cargs += '-DCONFIG_NICINTEL_EEPROM=1'
310endif
311if config_nicintel_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200312 srcs += files('nicintel_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000313 cargs += '-DCONFIG_NICINTEL_SPI=1'
314endif
315if config_nicnatsemi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200316 srcs += files('nicnatsemi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000317 cargs += '-DCONFIG_NICNATSEMI=1'
318endif
319if config_nicrealtek
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200320 srcs += files('nicrealtek.c')
Richard Hughescb973682018-12-19 11:44:22 +0000321 cargs += '-DCONFIG_NICREALTEK=1'
322endif
323if config_ogp_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200324 srcs += files('ogp_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000325 cargs += '-DCONFIG_OGP_SPI=1'
326endif
327if config_pickit2_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200328 srcs += files('pickit2_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000329 cargs += '-DCONFIG_PICKIT2_SPI=1'
Richard Hughescb973682018-12-19 11:44:22 +0000330endif
331if config_pony_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200332 srcs += files('pony_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000333 cargs += '-DCONFIG_PONY_SPI=1'
334endif
335if config_rayer_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200336 srcs += files('rayer_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000337 cargs += '-DCONFIG_RAYER_SPI=1'
338endif
339if config_satamv
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200340 srcs += files('satamv.c')
Richard Hughescb973682018-12-19 11:44:22 +0000341 cargs += '-DCONFIG_SATAMV=1'
342endif
343if config_satasii
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200344 srcs += files('satasii.c')
Richard Hughescb973682018-12-19 11:44:22 +0000345 cargs += '-DCONFIG_SATASII=1'
346endif
347if config_serprog
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200348 srcs += files('serprog.c')
Richard Hughescb973682018-12-19 11:44:22 +0000349 cargs += '-DCONFIG_SERPROG=1'
Richard Hughescb973682018-12-19 11:44:22 +0000350endif
351if config_usbblaster_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200352 srcs += files('usbblaster_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000353 cargs += '-DCONFIG_USBBLASTER_SPI=1'
354endif
Miklós Márton324929c2019-08-01 19:14:10 +0200355if config_stlinkv3_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200356 srcs += files('stlinkv3_spi.c')
Miklós Márton324929c2019-08-01 19:14:10 +0200357 cargs += '-DCONFIG_STLINKV3_SPI=1'
358endif
Richard Hughescb973682018-12-19 11:44:22 +0000359
360# bitbanging SPI infrastructure
Peter Marheine306c8b72022-01-21 02:07:30 +0000361if need_bitbang_spi
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200362 srcs += files('bitbang_spi.c')
Richard Hughescb973682018-12-19 11:44:22 +0000363 cargs += '-DCONFIG_BITBANG_SPI=1'
364endif
365
Peter Marheine306c8b72022-01-21 02:07:30 +0000366if need_raw_mem_access
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200367 srcs += files('hwaccess_physmap.c')
Peter Marheine306c8b72022-01-21 02:07:30 +0000368endif
369
370if need_x86_port_io
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200371 srcs += files('hwaccess_x86_io.c')
Thomas Heijligena0655202021-12-14 16:36:05 +0100372 cargs += '-D__FLASHROM_HAVE_OUTB__=1'
Richard Hughescb973682018-12-19 11:44:22 +0000373endif
374
Peter Marheine306c8b72022-01-21 02:07:30 +0000375if need_x86_msr
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200376 srcs += files('hwaccess_x86_msr.c')
Peter Marheine306c8b72022-01-21 02:07:30 +0000377endif
378
Richard Hughescb973682018-12-19 11:44:22 +0000379# raw serial IO
380if need_serial
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200381 srcs += files('serial.c')
Thomas Heijligen140c1262021-09-27 15:12:26 +0200382 if host_machine.system() == 'linux'
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200383 srcs += files('custom_baud_linux.c')
Thomas Heijligen140c1262021-09-27 15:12:26 +0200384 else
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200385 srcs += files('custom_baud.c')
Thomas Heijligen140c1262021-09-27 15:12:26 +0200386 endif
Richard Hughescb973682018-12-19 11:44:22 +0000387endif
388
Thomas Heijligen2ae9bf22022-05-03 12:00:14 +0200389if config_print_wiki
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200390 srcs += files('print_wiki.c')
Thomas Heijligen2ae9bf22022-05-03 12:00:14 +0200391 cargs += '-DCONFIG_PRINT_WIKI=1'
392endif
393
394if config_default_programmer_name != ''
395 cargs += '-DCONFIG_DEFAULT_PROGRAMMER_NAME=&programmer_' + config_default_programmer_name
396else
397 cargs += '-DCONFIG_DEFAULT_PROGRAMMER_NAME=NULL'
398endif
399
400cargs += '-DCONFIG_DEFAULT_PROGRAMMER_ARGS="' + config_default_programmer_args + '"'
401
Richard Hughescb973682018-12-19 11:44:22 +0000402install_headers([
Thomas Heijligen58015c22022-04-14 13:50:55 +0200403 'include/libflashrom.h',
Richard Hughescb973682018-12-19 11:44:22 +0000404 ],
405)
406
Thomas Heijligen58015c22022-04-14 13:50:55 +0200407include_dir = include_directories('include')
408
Richard Hughescb973682018-12-19 11:44:22 +0000409mapfile = 'libflashrom.map'
410vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile)
Thomas Heijligenf6a273b2022-05-03 12:21:47 +0200411libflashrom = both_libraries(
Richard Hughescb973682018-12-19 11:44:22 +0000412 'flashrom',
413 sources : [
414 srcs,
415 ],
Thomas Heijligen58015c22022-04-14 13:50:55 +0200416 include_directories : include_dir,
Richard Hughescb973682018-12-19 11:44:22 +0000417 soversion : lt_current,
418 version : lt_version,
419 dependencies : [
420 deps,
421 ],
422 c_args : [
423 cargs,
424 ],
425 install : true,
426 link_args : vflag,
427 link_depends : mapfile,
428)
429
Mario Limonciellod954d5d2019-09-24 16:06:57 -0500430version = meson.project_version()
431#strip leading characters
432if version.startswith('v')
433 version = version.split('v')[1]
434endif
435if version.startswith('p')
436 version = version.split('p')[1]
437endif
438
Richard Hughescb973682018-12-19 11:44:22 +0000439pkgg = import('pkgconfig')
440pkgg.generate(
Thomas Heijligenf6a273b2022-05-03 12:21:47 +0200441 libraries : libflashrom,
Mario Limonciellod954d5d2019-09-24 16:06:57 -0500442 version : version,
Mario Limonciello2a8d4392019-10-15 13:32:19 -0500443 name : 'flashrom',
444 filebase : 'flashrom',
445 description : 'library to interact with flashrom',
Richard Hughescb973682018-12-19 11:44:22 +0000446)
447
Richard Hughesdad3a162020-02-17 09:57:01 +0000448conf.set('VERSION', version)
Nikolai Artemiev47cb6fc2022-07-22 09:58:14 +1000449conf.set('MAN_DATE', run_command('util/getversion.sh', '--man-date', check : true).stdout().strip())
Richard Hughesdad3a162020-02-17 09:57:01 +0000450configure_file(
451 input : 'flashrom.8.tmpl',
452 output : 'flashrom.8',
453 configuration : conf,
454 install: true,
Thomas Heijligen454a28c2022-05-03 11:50:16 +0200455 install_dir: join_paths(get_option('mandir'), 'man8'),
Richard Hughesdad3a162020-02-17 09:57:01 +0000456)
457
Richard Hughescb973682018-12-19 11:44:22 +0000458executable(
459 'flashrom',
Thomas Heijligenf6a273b2022-05-03 12:21:47 +0200460 files(
Richard Hughescb973682018-12-19 11:44:22 +0000461 'cli_classic.c',
462 'cli_common.c',
463 'cli_output.c',
Thomas Heijligenf6a273b2022-05-03 12:21:47 +0200464 ),
465 c_args : cargs,
Thomas Heijligen58015c22022-04-14 13:50:55 +0200466 include_directories : include_dir,
Richard Hughescb973682018-12-19 11:44:22 +0000467 install : true,
Thomas Heijligenf6a273b2022-05-03 12:21:47 +0200468 install_dir : get_option('sbindir'),
469 link_with : libflashrom.get_static_lib(), # flashrom needs internal symbols of libflashrom
Richard Hughescb973682018-12-19 11:44:22 +0000470)
471
472subdir('util')