blob: 8d7228b7849a4c473a2dfbaa28bb70565a21a075 [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',
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +02004 meson_version : '>=0.53.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
Richard Hughescb973682018-12-19 11:44:22 +000031cc = meson.get_compiler('c')
32add_project_arguments(cc.get_supported_arguments(warning_flags), language : 'c')
33add_project_arguments('-D_DEFAULT_SOURCE', language : 'c')
Rosen Penev566193f2020-07-18 12:50:16 -070034add_project_arguments('-D_POSIX_C_SOURCE=200809L', language : 'c') # required for fileno, nanosleep, and strndup
Richard Hughescb973682018-12-19 11:44:22 +000035add_project_arguments('-D_BSD_SOURCE', language : 'c') # required for glibc < v2.19
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +020036add_project_arguments('-D__BSD_VISIBLE', language : 'c') # required for u_char, u_int, u_long on FreeBSD
37add_project_arguments('-D__XSI_VISIBLE', language : 'c') # required for gettimeofday() on FreeBSD
38add_project_arguments('-D_NETBSD_SOURCE', language : 'c') # required for indirect include of strings.h on NetBSD
39add_project_arguments('-D_DARWIN_C_SOURCE', language : 'c') # required for indirect include of strings.h on MacOS
Richard Hughescb973682018-12-19 11:44:22 +000040add_project_arguments('-DFLASHROM_VERSION="' + meson.project_version() + '"', language : 'c')
41
42# get defaults from configure
Thomas Heijligenb975da12022-08-13 12:10:05 +020043config_print_wiki = get_option('classic_cli_print_wiki')
Thomas Heijligen84e9c912021-06-01 16:22:14 +020044config_default_programmer_name = get_option('default_programmer_name')
45config_default_programmer_args = get_option('default_programmer_args')
Richard Hughescb973682018-12-19 11:44:22 +000046
47cargs = []
48deps = []
Thomas Heijligen51208f32022-04-28 11:07:29 +020049srcs = files(
50 '82802ab.c',
51 'at45db.c',
52 'bitbang_spi.c',
53 'edi.c',
54 'en29lv640b.c',
55 'flashchips.c',
56 'flashrom.c',
57 'fmap.c',
58 'helpers.c',
Edward O'Callaghan4c76c732022-08-12 11:03:00 +100059 'helpers_fileio.c',
Thomas Heijligen51208f32022-04-28 11:07:29 +020060 'ich_descriptors.c',
61 'jedec.c',
62 'layout.c',
63 'libflashrom.c',
64 'opaque.c',
Edward O'Callaghan63f6a372022-08-12 12:56:43 +100065 'parallel.c',
Thomas Heijligen51208f32022-04-28 11:07:29 +020066 'print.c',
67 'programmer.c',
68 'programmer_table.c',
69 'sfdp.c',
70 'spi25.c',
71 'spi25_statusreg.c',
72 'spi95.c',
73 'spi.c',
74 'sst28sf040.c',
75 'sst49lfxxxc.c',
76 'sst_fwhub.c',
77 'stm50.c',
78 'udelay.c',
79 'w29ee011.c',
80 'w39.c',
81 'writeprotect.c',
82 'writeprotect_ranges.c',
83)
Richard Hughescb973682018-12-19 11:44:22 +000084
Richard Hughescb973682018-12-19 11:44:22 +000085# check for required symbols
86if cc.has_function('clock_gettime')
87 add_project_arguments('-DHAVE_CLOCK_GETTIME=1', language : 'c')
88endif
89if cc.has_function('strnlen')
90 add_project_arguments('-DHAVE_STRNLEN=1', language : 'c')
91endif
92if cc.check_header('sys/utsname.h')
93 add_project_arguments('-DHAVE_UTSNAME=1', language : 'c')
94endif
Thomas Heijligenc02b1a92022-04-25 14:54:10 +020095if host_machine.system() in ['cygwin', 'windows']
96 add_project_arguments('-DIS_WINDOWS=1', language : 'c')
97else
98 add_project_arguments('-DIS_WINDOWS=0', language : 'c')
99endif
Richard Hughescb973682018-12-19 11:44:22 +0000100
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200101systems_hwaccess = [ 'linux', 'openbsd', 'freebsd', 'dragonfly', 'netbsd' ]
102systems_serial = [ 'linux', 'openbsd', 'freebsd', 'dragonfly', 'netbsd', 'darwin' ]
Richard Hughescb973682018-12-19 11:44:22 +0000103
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200104cpus_port_io = [ 'x86', 'x86_64' ]
Peter Marheine306c8b72022-01-21 02:07:30 +0000105
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200106group_ftdi = get_option('programmer').contains('group_ftdi')
107group_pci = get_option('programmer').contains('group_pci')
108group_usb = get_option('programmer').contains('group_usb')
109group_i2c = get_option('programmer').contains('group_i2c')
110group_serial = get_option('programmer').contains('group_serial')
111group_jlink = get_option('programmer').contains('group_jlink')
112group_internal = get_option('programmer').contains('group_internal')
113group_external = get_option('programmer').contains('group_external')
Peter Marheine306c8b72022-01-21 02:07:30 +0000114
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200115libpci = dependency('libpci', required : group_pci, static : (host_machine.system() == 'openbsd' ? true : false)) # On openbsd a static version of libpci is needed to get also -libz
116libusb1 = dependency('libusb-1.0', required : group_usb)
117libftdi1 = dependency('libftdi1', required : group_ftdi)
118libjaylink = dependency('libjaylink', required : group_jlink)
Richard Hughescb973682018-12-19 11:44:22 +0000119
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200120subdir('platform')
Richard Hughescb973682018-12-19 11:44:22 +0000121
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200122if systems_hwaccess.contains(host_machine.system())
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200123 srcs += files('hwaccess_physmap.c')
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200124 if ['x86', 'x86_64'].contains(host_machine.cpu_family())
125 srcs += files('hwaccess_x86_msr.c', 'hwaccess_x86_io.c')
Thomas Heijligen140c1262021-09-27 15:12:26 +0200126 endif
Richard Hughescb973682018-12-19 11:44:22 +0000127endif
128
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200129# Pseudo dependencies
130linux_headers = \
131 cc.has_header('linux/i2c.h') and \
132 cc.has_header('linux/i2c-dev.h') and \
133 cc.has_header('mtd/mtd-user.h') and \
134 cc.has_header('linux/spi/spidev.h') ? declare_dependency() : dependency('', required : false)
Thomas Heijligenb975da12022-08-13 12:10:05 +0200135
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200136# '<programmer_name>' : {
137# 'system' : list[string], # default: ['all']
138# 'cpu_families : list[string], # default: ['all']
139# 'deps' : list[dep], # default: []
140# 'groups : list[boolean], # default: []
141# 'srcs' : list[file], # default: []
142# 'flags' : list[string], # default: []
143# 'default' : boolean, # default: true
144# 'active' : boolean, # added on runtime
145# }
146programmer = {
147 'atahpt' : {
148 'systems' : systems_hwaccess,
149 'cpu_families' : cpus_port_io,
150 'deps' : [ libpci ],
151 'groups' : [ group_pci, group_internal ],
152 'srcs' : files('atahpt.c', 'pcidev.c'),
153 'flags' : [ '-DCONFIG_ATAHPT=1' ],
154 'default' : false, # not yet working
155 },
156 'atapromise' : {
157 'systems' : systems_hwaccess,
158 'cpu_families' : cpus_port_io,
159 'deps' : [ libpci ],
160 'groups' : [ group_pci, group_internal ],
161 'srcs' : files('atapromise.c', 'pcidev.c'),
162 'flags' : [ '-DCONFIG_ATAPROMISE=1' ],
163 'default' : false,
164 },
165 'atavia' : {
166 'systems' : systems_hwaccess,
167 'deps' : [ libpci ],
168 'groups' : [ group_pci, group_internal ],
169 'srcs' : files('atavia.c', 'pcidev.c'),
170 'flags' : [ '-DCONFIG_ATAVIA=1' ],
171 },
172 'buspirate_spi' : {
173 'systems' : systems_serial,
174 'groups' : [ group_serial, group_external ],
175 'srcs' : files('buspirate_spi.c', 'serial.c', (host_machine.system() == 'linux' ? 'custom_baud_linux.c' : 'custom_baud.c')),
176 'flags' : [ '-DCONFIG_BUSPIRATE_SPI=1' ],
177 },
178 'ch341a_spi' : {
179 'deps' : [ libusb1 ],
180 'groups' : [ group_usb, group_external ],
181 'srcs' : files('ch341a_spi.c'),
182 'flags' : [ '-DCONFIG_CH341A_SPI=1' ],
183 },
184 'dediprog' : {
185 'deps' : [ libusb1 ],
186 'groups' : [ group_usb, group_external ],
187 'srcs' : files('dediprog.c', 'usbdev.c'),
188 'flags' : [ '-DCONFIG_DEDIPROG=1' ],
189 },
190 'developerbox_spi' : {
191 'deps' : [ libusb1 ],
192 'groups' : [ group_usb, group_external ],
193 'srcs' : files('developerbox_spi.c', 'usbdev.c'),
194 'flags' : [ '-DCONFIG_DEVELOPERBOX_SPI=1' ],
195 },
196 'digilent_spi' : {
197 'deps' : [ libusb1 ],
198 'groups' : [ group_usb, group_external ],
199 'srcs' : files('digilent_spi.c'),
200 'flags' : [ '-DCONFIG_DIGILENT_SPI=1' ],
201 },
202 'dirtyjtag_spi' : {
203 'deps' : [ libusb1 ],
204 'groups' : [ group_usb, group_external ],
205 'srcs' : files('dirtyjtag_spi.c'),
206 'flags' : [ '-DCONFIG_DIRTYJTAG_SPI=1' ],
207 },
208 'drkaiser' : {
209 'systems' : systems_hwaccess,
210 'deps' : [ libpci ],
211 'groups' : [ group_pci, group_internal ],
212 'srcs' : files('drkaiser.c', 'pcidev.c'),
213 'flags' : [ '-DCONFIG_DRKAISER=1' ],
214 },
215 'dummy' : {
216 'srcs' : files('dummyflasher.c'),
217 'flags' : [ '-DCONFIG_DUMMY=1' ],
218 },
219 'ft2232_spi' : {
220 'deps' : [ libftdi1 ],
221 'groups' : [ group_ftdi, group_external ],
222 'srcs' : files('ft2232_spi.c' ),
223 'flags' : [ '-DCONFIG_FT2232_SPI=1' ],
224 },
225 'gfxnvidia' : {
226 'systems' : systems_hwaccess,
227 'deps' : [ libpci ],
228 'groups' : [ group_pci, group_internal ],
229 'srcs' : files('gfxnvidia.c', 'pcidev.c'),
230 'flags' : [ '-DCONFIG_GFXNVIDIA=1' ],
231 },
232 'internal' : {
233 'systems' : systems_hwaccess + ['linux'],
234 'cpu_families' : (host_machine.system() == 'linux' ? [host_machine.cpu_family()] : ['x86', 'x86_64']),
235 'deps' : [ libpci ],
236 'groups' : [ group_internal ],
237 'srcs' : (host_machine.cpu_family() in ['x86', 'x86_64'] ? files(
238 'processor_enable.c',
239 'chipset_enable.c',
240 'board_enable.c',
241 'cbtable.c',
242 'internal.c',
243 'it87spi.c',
244 'sb600spi.c',
245 'amd_imc.c',
246 'wbsio_spi.c',
247 'mcp6x_spi.c',
248 'ichspi.c',
249 'dmi.c',
250 'pcidev.c',
251 'known_boards.c',
252 ) : files(
253 'board_enable.c',
254 'cbtable.c',
255 'chipset_enable.c',
256 'internal.c',
257 'processor_enable.c',
258 'pcidev.c',
259 'known_boards.c',
260 )),
261 'flags' : [
262 '-DCONFIG_INTERNAL=1',
263 '-DCONFIG_INTERNAL_DMI=' + (get_option('use_internal_dmi') ? '1' : '0'),
264 ]
265 },
266 'it8212' : {
267 'systems' : systems_hwaccess,
268 'deps' : [ libpci ],
269 'groups' : [ group_pci, group_internal ],
270 'srcs' : files('it8212.c', 'pcidev.c'),
271 'flags' : [ '-DCONFIG_IT8212=1' ],
272 },
273 'jlink_spi' : {
274 'deps' : [ libjaylink ],
275 'groups' : [ group_jlink, group_external ],
276 'srcs' : files('jlink_spi.c'),
277 'flags' : [ '-DCONFIG_JLINK_SPI=1' ],
278 'default' : false,
279 },
280 'linux_mtd' : {
281 'systems' : [ 'linux' ],
282 'deps' : [ linux_headers ],
283 'groups' : [ group_internal ],
284 'srcs' : files('linux_mtd.c'),
285 'flags' : [ '-DCONFIG_LINUX_MTD=1' ],
286 },
287 'linux_spi' : {
288 'systems' : [ 'linux' ],
289 'deps' : [ linux_headers ],
290 # internal / external?
291 'srcs' : files('linux_spi.c'),
292 'flags' : [ '-DCONFIG_LINUX_SPI=1' ],
293 },
294 'mstarddc_spi' : {
295 'systems' : [ 'linux' ],
296 'deps' : [ linux_headers ],
297 'groups' : [ group_i2c ],
298 'srcs' : files('mstarddc_spi.c'),
299 'flags' : [ '-DCONFIG_MSTARDDC_SPI=1' ],
300 'default' : false
301 },
302 'nic3com' : {
303 'systems' : systems_hwaccess,
304 'cpu_families' : cpus_port_io,
305 'deps' : [ libpci ],
306 'groups' : [ group_pci, group_internal ],
307 'srcs' : files('nic3com.c', 'pcidev.c'),
308 'flags' : [ '-DCONFIG_NIC3COM=1' ],
309 },
310 'nicintel' : {
311 'systems' : systems_hwaccess,
312 'deps' : [ libpci ],
313 'groups' : [ group_pci, group_internal ],
314 'srcs' : files('nicintel.c', 'pcidev.c'),
315 'flags' : [ '-DCONFIG_NICINTEL=1' ],
316 },
317 'nicintel_eeprom' : {
318 'systems' : systems_hwaccess,
319 'deps' : [ libpci ],
320 'groups' : [ group_pci, group_internal ],
321 'srcs' : files('nicintel_eeprom.c', 'pcidev.c'),
322 'flags' : [ '-DCONFIG_NICINTEL_EEPROM=1' ],
323 },
324 'nicintel_spi' : {
325 'systems' : systems_hwaccess,
326 'deps' : [ libpci ],
327 'groups' : [ group_pci, group_internal ],
328 'srcs' : files('nicintel_spi.c', 'pcidev.c'),
329 'flags' : [ '-DCONFIG_NICINTEL_SPI=1' ],
330 },
331 'nicnatsemi' : {
332 'systems' : systems_hwaccess,
333 'cpu_families' : cpus_port_io,
334 'deps' : [ libpci ],
335 'groups' : [ group_pci, group_internal ],
336 'srcs' : files('nicnatsemi.c', 'pcidev.c'),
337 'flags' : [ '-DCONFIG_NICNATSEMI=1' ],
338 'default' : false, # not complete nor tested
339 },
340 'nicrealtek' : {
341 'systems' : systems_hwaccess,
342 'cpu_families' : cpus_port_io,
343 'deps' : [ libpci ],
344 'groups' : [ group_pci, group_internal ],
345 'srcs' : files('nicrealtek.c', 'pcidev.c'),
346 'flags' : [ '-DCONFIG_NICREALTEK=1' ],
347 },
348 'ogp_spi' : {
349 'systems' : systems_hwaccess,
350 'deps' : [ libpci ],
351 'groups' : [ group_pci, group_internal ],
352 'srcs' : files('ogp_spi.c', 'pcidev.c'),
353 'flags' : [ '-DCONFIG_OGP_SPI=1' ],
354 },
355 'pickit2_spi' : {
356 'deps' : [ libusb1 ],
357 'groups' : [ group_usb, group_external ],
358 'srcs' : files('pickit2_spi.c'),
359 'flags' : [ '-DCONFIG_PICKIT2_SPI=1' ],
360 },
361 'pony_spi' : {
362 'systems' : systems_serial,
363 'groups' : [ group_serial, group_external ],
364 'srcs' : files('pony_spi.c', 'serial.c', (host_machine.system() == 'linux' ? 'custom_baud_linux.c' : 'custom_baud.c')),
365 'flags' : [ '-DCONFIG_PONY_SPI=1' ],
366 },
367 'rayer_spi' : {
368 'systems' : systems_hwaccess,
369 'cpu_families' : cpus_port_io,
370 'groups' : [ group_internal ],
371 'srcs' : files('rayer_spi.c'),
372 'flags' : [ '-DCONFIG_RAYER_SPI=1' ],
373 },
374 'satamv' : {
375 'systems' : systems_hwaccess,
376 'cpu_families' : cpus_port_io,
377 'deps' : [ libpci ],
378 'groups' : [ group_pci, group_internal ],
379 'srcs' : files('satamv.c', 'pcidev.c'),
380 'flags' : ['-DCONFIG_SATAMV=1'],
381 },
382 'satasii' : {
383 'systems' : systems_hwaccess,
384 'deps' : [ libpci ],
385 'groups' : [ group_pci, group_internal ],
386 'srcs' : files('satasii.c', 'pcidev.c'),
387 'flags' : [ '-DCONFIG_SATASII=1' ],
388 },
389 'serprog' : {
390 'systems' : systems_serial,
391 'groups' : [ group_serial, group_external ],
392 'srcs' : files('serprog.c', 'serial.c', (host_machine.system() == 'linux' ? 'custom_baud_linux.c' : 'custom_baud.c')),
393 'flags' : [ '-DCONFIG_SERPROG=1' ],
394 },
395 'stlinkv3_spi' : {
396 'deps' : [ libusb1 ],
397 'groups' : [ group_usb, group_external ],
398 'srcs' : files('stlinkv3_spi.c', 'usbdev.c'),
399 'flags' : [ '-DCONFIG_STLINKV3_SPI=1' ],
400 },
401 'usbblaster_spi' : {
402 'deps' : [ libftdi1 ],
403 'groups' : [ group_ftdi, group_external ],
404 'srcs' : files('usbblaster_spi.c'),
405 'flags' : [ '-DCONFIG_USBBLASTER_SPI=1' ],
406 },
407}
408
409active_programmer_count = 0
410foreach p_name, p_data : programmer
411 p_data += {
412 'systems' : p_data.get('systems', ['all']),
413 'cpu_families' : p_data.get('cpu_families', ['all']),
414 'deps' : p_data.get('deps', []),
415 'groups' : p_data.get('groups', []),
416 'srcs' : p_data.get('srcs', []),
417 'flags' : p_data.get('flags', []),
418 'default' : p_data.get('default', true),
419 }
420
421 active = false
422 deps_found = true
423 not_found_dep = ''
424 not_active_message = ''
425 selected_hard = p_name in get_option('programmer')
426 selected_soft = p_data.get('groups').contains(true) or \
427 'all' in get_option('programmer') or \
428 'auto' in get_option('programmer') and p_data.get('default')
429 available = (p_data.get('systems').contains('all') or p_data.get('systems').contains(host_machine.system())) \
430 and (p_data.get('cpu_families').contains('all') or p_data.get('cpu_families').contains(host_machine.cpu_family()))
431
432 foreach dep : p_data.get('deps')
433 if not dep.found()
434 deps_found = false
435 not_found_dep = dep.name()
436 break
437 endif
438 endforeach
439
440 if selected_hard
441 if not available
442 error(p_name + ' selected but not supported on this platform')
443 elif not deps_found
444 error(p_name + ' selected but dependency ' + not_found_dep +'not found')
445 else
446 active = true
447 endif
448 elif selected_soft
449 if not available
450 not_active_message = 'Not available on platform'
451 elif not deps_found
452 not_active_message = 'dependency ' + not_found_dep + ' not found'
453 else
454 active = true
455 endif
456 else
457 not_active_message = 'not selected'
458 endif
459
460 p_data += {
461 'active' : active,
462 'summary' : not_active_message,
463 }
464 programmer += {p_name : p_data}
465 if active
466 active_programmer_count += 1
467 endif
468endforeach
469
470if active_programmer_count == 0
471 error('At least one programmer must be selected')
472endif
473
474# add srcs, cargs & deps from active programmer to global srcs, cargs & deps
475foreach p_name, p_data : programmer
476 if p_data.get('active')
477 srcs += p_data.get('srcs')
478 cargs += p_data.get('flags')
479 deps += p_data.get('deps')
480 endif
481endforeach
Thomas Heijligenb975da12022-08-13 12:10:05 +0200482
483if config_print_wiki.enabled()
484 if get_option('classic_cli').disabled()
485 error('`classic_cli_print_wiki` can not be enabled without `classic_cli`')
486 else
487 srcs += files('print_wiki.c')
488 cargs += '-DCONFIG_PRINT_WIKI=1'
489 endif
Thomas Heijligen2ae9bf22022-05-03 12:00:14 +0200490endif
491
492if config_default_programmer_name != ''
493 cargs += '-DCONFIG_DEFAULT_PROGRAMMER_NAME=&programmer_' + config_default_programmer_name
494else
495 cargs += '-DCONFIG_DEFAULT_PROGRAMMER_NAME=NULL'
496endif
497
498cargs += '-DCONFIG_DEFAULT_PROGRAMMER_ARGS="' + config_default_programmer_args + '"'
499
Richard Hughescb973682018-12-19 11:44:22 +0000500install_headers([
Thomas Heijligen58015c22022-04-14 13:50:55 +0200501 'include/libflashrom.h',
Richard Hughescb973682018-12-19 11:44:22 +0000502 ],
503)
504
Thomas Heijligen58015c22022-04-14 13:50:55 +0200505include_dir = include_directories('include')
506
Richard Hughescb973682018-12-19 11:44:22 +0000507mapfile = 'libflashrom.map'
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200508if host_machine.system() == 'darwin'
509 vflag = ''
510else
511 vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile)
512endif
Thomas Heijligenf6a273b2022-05-03 12:21:47 +0200513libflashrom = both_libraries(
Richard Hughescb973682018-12-19 11:44:22 +0000514 'flashrom',
515 sources : [
516 srcs,
517 ],
Thomas Heijligen58015c22022-04-14 13:50:55 +0200518 include_directories : include_dir,
Richard Hughescb973682018-12-19 11:44:22 +0000519 soversion : lt_current,
520 version : lt_version,
521 dependencies : [
522 deps,
523 ],
524 c_args : [
525 cargs,
526 ],
527 install : true,
528 link_args : vflag,
529 link_depends : mapfile,
530)
531
Mario Limonciellod954d5d2019-09-24 16:06:57 -0500532version = meson.project_version()
533#strip leading characters
534if version.startswith('v')
535 version = version.split('v')[1]
536endif
537if version.startswith('p')
538 version = version.split('p')[1]
539endif
540
Richard Hughescb973682018-12-19 11:44:22 +0000541pkgg = import('pkgconfig')
542pkgg.generate(
Thomas Heijligenf6a273b2022-05-03 12:21:47 +0200543 libraries : libflashrom,
Mario Limonciellod954d5d2019-09-24 16:06:57 -0500544 version : version,
Mario Limonciello2a8d4392019-10-15 13:32:19 -0500545 name : 'flashrom',
546 filebase : 'flashrom',
547 description : 'library to interact with flashrom',
Richard Hughescb973682018-12-19 11:44:22 +0000548)
549
Felix Singer9818b3f2022-11-29 17:08:03 +0100550config_manfile = configuration_data()
551config_manfile.set('VERSION', version)
552config_manfile.set('MAN_DATE', run_command('util/getversion.sh', '--man-date', check : true).stdout().strip())
Richard Hughesdad3a162020-02-17 09:57:01 +0000553configure_file(
554 input : 'flashrom.8.tmpl',
555 output : 'flashrom.8',
Felix Singer9818b3f2022-11-29 17:08:03 +0100556 configuration : config_manfile,
Richard Hughesdad3a162020-02-17 09:57:01 +0000557 install: true,
Thomas Heijligen454a28c2022-05-03 11:50:16 +0200558 install_dir: join_paths(get_option('mandir'), 'man8'),
Richard Hughesdad3a162020-02-17 09:57:01 +0000559)
560
Thomas Heijligena12e0102022-08-13 12:42:05 +0200561if get_option('classic_cli').auto() or get_option('classic_cli').enabled()
562 executable(
563 'flashrom',
564 files(
565 'cli_classic.c',
566 'cli_common.c',
567 'cli_output.c',
568 ),
569 c_args : cargs,
570 include_directories : include_dir,
571 install : true,
572 install_dir : get_option('sbindir'),
573 link_with : libflashrom.get_static_lib(), # flashrom needs internal symbols of libflashrom
574 )
575endif
Richard Hughescb973682018-12-19 11:44:22 +0000576
Thomas Heijligenb7341b12022-08-13 12:21:44 +0200577if get_option('ich_descriptors_tool').auto() or get_option('ich_descriptors_tool').enabled()
578 subdir('util/ich_descriptors_tool')
579endif
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200580
581programmer_names_active = []
582programmer_names_not_active = []
583foreach p_name, p_data : programmer
584 if p_data.get('active')
585 programmer_names_active += p_name
586 else
587 programmer_names_not_active += p_name + ' (' + p_data.get('summary', '') + ')'
588 endif
589endforeach
590
591summary({
592 'active' : [programmer_names_active],
593 'non active' : [programmer_names_not_active],
594}, section : 'Programmer')