blob: 7a9130094fe45ddf1be8da935c247f72698a25a6 [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
Peter Stuge272b0732022-12-11 03:55:02 +0100101if host_machine.system() == 'linux'
102 custom_baud_c = 'custom_baud_linux.c'
103else
104 custom_baud_c = 'custom_baud.c'
105endif
106
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200107systems_hwaccess = [ 'linux', 'openbsd', 'freebsd', 'dragonfly', 'netbsd' ]
108systems_serial = [ 'linux', 'openbsd', 'freebsd', 'dragonfly', 'netbsd', 'darwin' ]
Richard Hughescb973682018-12-19 11:44:22 +0000109
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200110cpus_port_io = [ 'x86', 'x86_64' ]
Peter Marheine306c8b72022-01-21 02:07:30 +0000111
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200112group_ftdi = get_option('programmer').contains('group_ftdi')
113group_pci = get_option('programmer').contains('group_pci')
114group_usb = get_option('programmer').contains('group_usb')
115group_i2c = get_option('programmer').contains('group_i2c')
116group_serial = get_option('programmer').contains('group_serial')
117group_jlink = get_option('programmer').contains('group_jlink')
Steve Markgraf61899472023-01-09 23:06:52 +0100118group_gpiod = get_option('programmer').contains('group_gpiod')
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200119group_internal = get_option('programmer').contains('group_internal')
120group_external = get_option('programmer').contains('group_external')
Peter Marheine306c8b72022-01-21 02:07:30 +0000121
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200122libpci = 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
123libusb1 = dependency('libusb-1.0', required : group_usb)
124libftdi1 = dependency('libftdi1', required : group_ftdi)
125libjaylink = dependency('libjaylink', required : group_jlink)
Steve Markgraf61899472023-01-09 23:06:52 +0100126libgpiod = dependency('libgpiod', required : group_gpiod)
Richard Hughescb973682018-12-19 11:44:22 +0000127
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200128subdir('platform')
Richard Hughescb973682018-12-19 11:44:22 +0000129
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200130if systems_hwaccess.contains(host_machine.system())
Thomas Heijligen4bd966c2022-05-16 10:56:55 +0200131 srcs += files('hwaccess_physmap.c')
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200132 if ['x86', 'x86_64'].contains(host_machine.cpu_family())
133 srcs += files('hwaccess_x86_msr.c', 'hwaccess_x86_io.c')
Thomas Heijligen140c1262021-09-27 15:12:26 +0200134 endif
Richard Hughescb973682018-12-19 11:44:22 +0000135endif
136
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200137# Pseudo dependencies
138linux_headers = \
139 cc.has_header('linux/i2c.h') and \
140 cc.has_header('linux/i2c-dev.h') and \
141 cc.has_header('mtd/mtd-user.h') and \
142 cc.has_header('linux/spi/spidev.h') ? declare_dependency() : dependency('', required : false)
Thomas Heijligenb975da12022-08-13 12:10:05 +0200143
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200144# '<programmer_name>' : {
145# 'system' : list[string], # default: ['all']
146# 'cpu_families : list[string], # default: ['all']
147# 'deps' : list[dep], # default: []
148# 'groups : list[boolean], # default: []
149# 'srcs' : list[file], # default: []
150# 'flags' : list[string], # default: []
151# 'default' : boolean, # default: true
152# 'active' : boolean, # added on runtime
153# }
154programmer = {
155 'atahpt' : {
156 'systems' : systems_hwaccess,
157 'cpu_families' : cpus_port_io,
158 'deps' : [ libpci ],
159 'groups' : [ group_pci, group_internal ],
160 'srcs' : files('atahpt.c', 'pcidev.c'),
161 'flags' : [ '-DCONFIG_ATAHPT=1' ],
162 'default' : false, # not yet working
163 },
164 'atapromise' : {
165 'systems' : systems_hwaccess,
166 'cpu_families' : cpus_port_io,
167 'deps' : [ libpci ],
168 'groups' : [ group_pci, group_internal ],
169 'srcs' : files('atapromise.c', 'pcidev.c'),
170 'flags' : [ '-DCONFIG_ATAPROMISE=1' ],
171 'default' : false,
172 },
173 'atavia' : {
174 'systems' : systems_hwaccess,
175 'deps' : [ libpci ],
176 'groups' : [ group_pci, group_internal ],
177 'srcs' : files('atavia.c', 'pcidev.c'),
178 'flags' : [ '-DCONFIG_ATAVIA=1' ],
179 },
180 'buspirate_spi' : {
181 'systems' : systems_serial,
182 'groups' : [ group_serial, group_external ],
Peter Stuge272b0732022-12-11 03:55:02 +0100183 'srcs' : files('buspirate_spi.c', 'serial.c', custom_baud_c),
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200184 'flags' : [ '-DCONFIG_BUSPIRATE_SPI=1' ],
185 },
186 'ch341a_spi' : {
187 'deps' : [ libusb1 ],
188 'groups' : [ group_usb, group_external ],
189 'srcs' : files('ch341a_spi.c'),
190 'flags' : [ '-DCONFIG_CH341A_SPI=1' ],
191 },
Nicholas Chin197b7c72022-10-23 13:10:31 -0600192 'ch347_spi' : {
193 'deps' : [ libusb1 ],
194 'groups' : [ group_usb, group_external ],
195 'srcs' : files('ch347_spi.c'),
196 'flags' : [ '-DCONFIG_CH347_SPI=1' ],
197 },
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200198 'dediprog' : {
199 'deps' : [ libusb1 ],
200 'groups' : [ group_usb, group_external ],
201 'srcs' : files('dediprog.c', 'usbdev.c'),
202 'flags' : [ '-DCONFIG_DEDIPROG=1' ],
203 },
204 'developerbox_spi' : {
205 'deps' : [ libusb1 ],
206 'groups' : [ group_usb, group_external ],
207 'srcs' : files('developerbox_spi.c', 'usbdev.c'),
208 'flags' : [ '-DCONFIG_DEVELOPERBOX_SPI=1' ],
209 },
210 'digilent_spi' : {
211 'deps' : [ libusb1 ],
212 'groups' : [ group_usb, group_external ],
213 'srcs' : files('digilent_spi.c'),
214 'flags' : [ '-DCONFIG_DIGILENT_SPI=1' ],
215 },
216 'dirtyjtag_spi' : {
217 'deps' : [ libusb1 ],
218 'groups' : [ group_usb, group_external ],
219 'srcs' : files('dirtyjtag_spi.c'),
220 'flags' : [ '-DCONFIG_DIRTYJTAG_SPI=1' ],
221 },
222 'drkaiser' : {
223 'systems' : systems_hwaccess,
224 'deps' : [ libpci ],
225 'groups' : [ group_pci, group_internal ],
226 'srcs' : files('drkaiser.c', 'pcidev.c'),
227 'flags' : [ '-DCONFIG_DRKAISER=1' ],
228 },
229 'dummy' : {
230 'srcs' : files('dummyflasher.c'),
231 'flags' : [ '-DCONFIG_DUMMY=1' ],
232 },
233 'ft2232_spi' : {
234 'deps' : [ libftdi1 ],
235 'groups' : [ group_ftdi, group_external ],
236 'srcs' : files('ft2232_spi.c' ),
237 'flags' : [ '-DCONFIG_FT2232_SPI=1' ],
238 },
239 'gfxnvidia' : {
240 'systems' : systems_hwaccess,
241 'deps' : [ libpci ],
242 'groups' : [ group_pci, group_internal ],
243 'srcs' : files('gfxnvidia.c', 'pcidev.c'),
244 'flags' : [ '-DCONFIG_GFXNVIDIA=1' ],
245 },
246 'internal' : {
247 'systems' : systems_hwaccess + ['linux'],
248 'cpu_families' : (host_machine.system() == 'linux' ? [host_machine.cpu_family()] : ['x86', 'x86_64']),
249 'deps' : [ libpci ],
250 'groups' : [ group_internal ],
251 'srcs' : (host_machine.cpu_family() in ['x86', 'x86_64'] ? files(
252 'processor_enable.c',
253 'chipset_enable.c',
254 'board_enable.c',
255 'cbtable.c',
256 'internal.c',
257 'it87spi.c',
258 'sb600spi.c',
259 'amd_imc.c',
Nico Huber735b1862023-01-29 18:28:45 +0000260 'amd_spi100.c',
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200261 'wbsio_spi.c',
262 'mcp6x_spi.c',
263 'ichspi.c',
264 'dmi.c',
265 'pcidev.c',
266 'known_boards.c',
267 ) : files(
268 'board_enable.c',
269 'cbtable.c',
270 'chipset_enable.c',
271 'internal.c',
272 'processor_enable.c',
273 'pcidev.c',
274 'known_boards.c',
275 )),
276 'flags' : [
277 '-DCONFIG_INTERNAL=1',
278 '-DCONFIG_INTERNAL_DMI=' + (get_option('use_internal_dmi') ? '1' : '0'),
279 ]
280 },
281 'it8212' : {
282 'systems' : systems_hwaccess,
283 'deps' : [ libpci ],
284 'groups' : [ group_pci, group_internal ],
285 'srcs' : files('it8212.c', 'pcidev.c'),
286 'flags' : [ '-DCONFIG_IT8212=1' ],
287 },
288 'jlink_spi' : {
289 'deps' : [ libjaylink ],
290 'groups' : [ group_jlink, group_external ],
291 'srcs' : files('jlink_spi.c'),
292 'flags' : [ '-DCONFIG_JLINK_SPI=1' ],
293 'default' : false,
294 },
Steve Markgraf61899472023-01-09 23:06:52 +0100295 'linux_gpio_spi' : {
296 'systems' : [ 'linux' ],
297 'deps' : [ libgpiod ],
298 'groups' : [ group_gpiod, group_external ],
299 'srcs' : files('linux_gpio_spi.c'),
300 'flags' : [ '-DCONFIG_LINUX_GPIOD=1' ],
301 },
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200302 'linux_mtd' : {
303 'systems' : [ 'linux' ],
304 'deps' : [ linux_headers ],
305 'groups' : [ group_internal ],
306 'srcs' : files('linux_mtd.c'),
307 'flags' : [ '-DCONFIG_LINUX_MTD=1' ],
308 },
309 'linux_spi' : {
310 'systems' : [ 'linux' ],
311 'deps' : [ linux_headers ],
312 # internal / external?
313 'srcs' : files('linux_spi.c'),
314 'flags' : [ '-DCONFIG_LINUX_SPI=1' ],
315 },
316 'mstarddc_spi' : {
317 'systems' : [ 'linux' ],
318 'deps' : [ linux_headers ],
319 'groups' : [ group_i2c ],
320 'srcs' : files('mstarddc_spi.c'),
321 'flags' : [ '-DCONFIG_MSTARDDC_SPI=1' ],
322 'default' : false
323 },
324 'nic3com' : {
325 'systems' : systems_hwaccess,
326 'cpu_families' : cpus_port_io,
327 'deps' : [ libpci ],
328 'groups' : [ group_pci, group_internal ],
329 'srcs' : files('nic3com.c', 'pcidev.c'),
330 'flags' : [ '-DCONFIG_NIC3COM=1' ],
331 },
332 'nicintel' : {
333 'systems' : systems_hwaccess,
334 'deps' : [ libpci ],
335 'groups' : [ group_pci, group_internal ],
336 'srcs' : files('nicintel.c', 'pcidev.c'),
337 'flags' : [ '-DCONFIG_NICINTEL=1' ],
338 },
339 'nicintel_eeprom' : {
340 'systems' : systems_hwaccess,
341 'deps' : [ libpci ],
342 'groups' : [ group_pci, group_internal ],
343 'srcs' : files('nicintel_eeprom.c', 'pcidev.c'),
344 'flags' : [ '-DCONFIG_NICINTEL_EEPROM=1' ],
345 },
346 'nicintel_spi' : {
347 'systems' : systems_hwaccess,
348 'deps' : [ libpci ],
349 'groups' : [ group_pci, group_internal ],
350 'srcs' : files('nicintel_spi.c', 'pcidev.c'),
351 'flags' : [ '-DCONFIG_NICINTEL_SPI=1' ],
352 },
353 'nicnatsemi' : {
354 'systems' : systems_hwaccess,
355 'cpu_families' : cpus_port_io,
356 'deps' : [ libpci ],
357 'groups' : [ group_pci, group_internal ],
358 'srcs' : files('nicnatsemi.c', 'pcidev.c'),
359 'flags' : [ '-DCONFIG_NICNATSEMI=1' ],
360 'default' : false, # not complete nor tested
361 },
362 'nicrealtek' : {
363 'systems' : systems_hwaccess,
364 'cpu_families' : cpus_port_io,
365 'deps' : [ libpci ],
366 'groups' : [ group_pci, group_internal ],
367 'srcs' : files('nicrealtek.c', 'pcidev.c'),
368 'flags' : [ '-DCONFIG_NICREALTEK=1' ],
369 },
370 'ogp_spi' : {
371 'systems' : systems_hwaccess,
372 'deps' : [ libpci ],
373 'groups' : [ group_pci, group_internal ],
374 'srcs' : files('ogp_spi.c', 'pcidev.c'),
375 'flags' : [ '-DCONFIG_OGP_SPI=1' ],
376 },
377 'pickit2_spi' : {
378 'deps' : [ libusb1 ],
379 'groups' : [ group_usb, group_external ],
380 'srcs' : files('pickit2_spi.c'),
381 'flags' : [ '-DCONFIG_PICKIT2_SPI=1' ],
382 },
383 'pony_spi' : {
384 'systems' : systems_serial,
385 'groups' : [ group_serial, group_external ],
Peter Stuge272b0732022-12-11 03:55:02 +0100386 'srcs' : files('pony_spi.c', 'serial.c', custom_baud_c),
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200387 'flags' : [ '-DCONFIG_PONY_SPI=1' ],
388 },
389 'rayer_spi' : {
390 'systems' : systems_hwaccess,
391 'cpu_families' : cpus_port_io,
392 'groups' : [ group_internal ],
393 'srcs' : files('rayer_spi.c'),
394 'flags' : [ '-DCONFIG_RAYER_SPI=1' ],
395 },
396 'satamv' : {
397 'systems' : systems_hwaccess,
398 'cpu_families' : cpus_port_io,
399 'deps' : [ libpci ],
400 'groups' : [ group_pci, group_internal ],
401 'srcs' : files('satamv.c', 'pcidev.c'),
402 'flags' : ['-DCONFIG_SATAMV=1'],
403 },
404 'satasii' : {
405 'systems' : systems_hwaccess,
406 'deps' : [ libpci ],
407 'groups' : [ group_pci, group_internal ],
408 'srcs' : files('satasii.c', 'pcidev.c'),
409 'flags' : [ '-DCONFIG_SATASII=1' ],
410 },
411 'serprog' : {
412 'systems' : systems_serial,
413 'groups' : [ group_serial, group_external ],
Peter Stuge272b0732022-12-11 03:55:02 +0100414 'srcs' : files('serprog.c', 'serial.c', custom_baud_c),
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200415 'flags' : [ '-DCONFIG_SERPROG=1' ],
416 },
417 'stlinkv3_spi' : {
418 'deps' : [ libusb1 ],
419 'groups' : [ group_usb, group_external ],
420 'srcs' : files('stlinkv3_spi.c', 'usbdev.c'),
421 'flags' : [ '-DCONFIG_STLINKV3_SPI=1' ],
422 },
423 'usbblaster_spi' : {
424 'deps' : [ libftdi1 ],
425 'groups' : [ group_ftdi, group_external ],
426 'srcs' : files('usbblaster_spi.c'),
427 'flags' : [ '-DCONFIG_USBBLASTER_SPI=1' ],
428 },
429}
430
431active_programmer_count = 0
432foreach p_name, p_data : programmer
433 p_data += {
434 'systems' : p_data.get('systems', ['all']),
435 'cpu_families' : p_data.get('cpu_families', ['all']),
436 'deps' : p_data.get('deps', []),
437 'groups' : p_data.get('groups', []),
438 'srcs' : p_data.get('srcs', []),
439 'flags' : p_data.get('flags', []),
440 'default' : p_data.get('default', true),
441 }
442
443 active = false
444 deps_found = true
445 not_found_dep = ''
446 not_active_message = ''
447 selected_hard = p_name in get_option('programmer')
448 selected_soft = p_data.get('groups').contains(true) or \
449 'all' in get_option('programmer') or \
450 'auto' in get_option('programmer') and p_data.get('default')
451 available = (p_data.get('systems').contains('all') or p_data.get('systems').contains(host_machine.system())) \
452 and (p_data.get('cpu_families').contains('all') or p_data.get('cpu_families').contains(host_machine.cpu_family()))
453
454 foreach dep : p_data.get('deps')
455 if not dep.found()
456 deps_found = false
457 not_found_dep = dep.name()
458 break
459 endif
460 endforeach
461
462 if selected_hard
463 if not available
464 error(p_name + ' selected but not supported on this platform')
465 elif not deps_found
466 error(p_name + ' selected but dependency ' + not_found_dep +'not found')
467 else
468 active = true
469 endif
470 elif selected_soft
471 if not available
472 not_active_message = 'Not available on platform'
473 elif not deps_found
474 not_active_message = 'dependency ' + not_found_dep + ' not found'
475 else
476 active = true
477 endif
478 else
479 not_active_message = 'not selected'
480 endif
481
482 p_data += {
483 'active' : active,
484 'summary' : not_active_message,
485 }
486 programmer += {p_name : p_data}
487 if active
488 active_programmer_count += 1
489 endif
490endforeach
491
492if active_programmer_count == 0
493 error('At least one programmer must be selected')
494endif
495
496# add srcs, cargs & deps from active programmer to global srcs, cargs & deps
497foreach p_name, p_data : programmer
498 if p_data.get('active')
499 srcs += p_data.get('srcs')
500 cargs += p_data.get('flags')
501 deps += p_data.get('deps')
502 endif
503endforeach
Thomas Heijligenb975da12022-08-13 12:10:05 +0200504
505if config_print_wiki.enabled()
506 if get_option('classic_cli').disabled()
507 error('`classic_cli_print_wiki` can not be enabled without `classic_cli`')
508 else
509 srcs += files('print_wiki.c')
510 cargs += '-DCONFIG_PRINT_WIKI=1'
511 endif
Thomas Heijligen2ae9bf22022-05-03 12:00:14 +0200512endif
513
514if config_default_programmer_name != ''
515 cargs += '-DCONFIG_DEFAULT_PROGRAMMER_NAME=&programmer_' + config_default_programmer_name
516else
517 cargs += '-DCONFIG_DEFAULT_PROGRAMMER_NAME=NULL'
518endif
519
520cargs += '-DCONFIG_DEFAULT_PROGRAMMER_ARGS="' + config_default_programmer_args + '"'
521
Richard Hughescb973682018-12-19 11:44:22 +0000522install_headers([
Thomas Heijligen58015c22022-04-14 13:50:55 +0200523 'include/libflashrom.h',
Richard Hughescb973682018-12-19 11:44:22 +0000524 ],
525)
526
Thomas Heijligen58015c22022-04-14 13:50:55 +0200527include_dir = include_directories('include')
528
Richard Hughescb973682018-12-19 11:44:22 +0000529mapfile = 'libflashrom.map'
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200530if host_machine.system() == 'darwin'
531 vflag = ''
532else
533 vflag = '-Wl,--version-script,@0@/@1@'.format(meson.current_source_dir(), mapfile)
534endif
Thomas Heijligenf6a273b2022-05-03 12:21:47 +0200535libflashrom = both_libraries(
Richard Hughescb973682018-12-19 11:44:22 +0000536 'flashrom',
537 sources : [
538 srcs,
539 ],
Thomas Heijligen58015c22022-04-14 13:50:55 +0200540 include_directories : include_dir,
Richard Hughescb973682018-12-19 11:44:22 +0000541 soversion : lt_current,
542 version : lt_version,
543 dependencies : [
544 deps,
545 ],
546 c_args : [
547 cargs,
548 ],
549 install : true,
550 link_args : vflag,
551 link_depends : mapfile,
552)
553
Mario Limonciellod954d5d2019-09-24 16:06:57 -0500554version = meson.project_version()
555#strip leading characters
556if version.startswith('v')
557 version = version.split('v')[1]
558endif
559if version.startswith('p')
560 version = version.split('p')[1]
561endif
562
Richard Hughescb973682018-12-19 11:44:22 +0000563pkgg = import('pkgconfig')
564pkgg.generate(
Thomas Heijligenf6a273b2022-05-03 12:21:47 +0200565 libraries : libflashrom,
Mario Limonciellod954d5d2019-09-24 16:06:57 -0500566 version : version,
Mario Limonciello2a8d4392019-10-15 13:32:19 -0500567 name : 'flashrom',
568 filebase : 'flashrom',
569 description : 'library to interact with flashrom',
Richard Hughescb973682018-12-19 11:44:22 +0000570)
571
Felix Singer9818b3f2022-11-29 17:08:03 +0100572config_manfile = configuration_data()
573config_manfile.set('VERSION', version)
574config_manfile.set('MAN_DATE', run_command('util/getversion.sh', '--man-date', check : true).stdout().strip())
Richard Hughesdad3a162020-02-17 09:57:01 +0000575configure_file(
576 input : 'flashrom.8.tmpl',
577 output : 'flashrom.8',
Felix Singer9818b3f2022-11-29 17:08:03 +0100578 configuration : config_manfile,
Richard Hughesdad3a162020-02-17 09:57:01 +0000579 install: true,
Thomas Heijligen454a28c2022-05-03 11:50:16 +0200580 install_dir: join_paths(get_option('mandir'), 'man8'),
Richard Hughesdad3a162020-02-17 09:57:01 +0000581)
582
Thomas Heijligena12e0102022-08-13 12:42:05 +0200583if get_option('classic_cli').auto() or get_option('classic_cli').enabled()
584 executable(
585 'flashrom',
586 files(
587 'cli_classic.c',
588 'cli_common.c',
589 'cli_output.c',
590 ),
591 c_args : cargs,
592 include_directories : include_dir,
593 install : true,
594 install_dir : get_option('sbindir'),
595 link_with : libflashrom.get_static_lib(), # flashrom needs internal symbols of libflashrom
596 )
597endif
Richard Hughescb973682018-12-19 11:44:22 +0000598
Thomas Heijligenb7341b12022-08-13 12:21:44 +0200599if get_option('ich_descriptors_tool').auto() or get_option('ich_descriptors_tool').enabled()
600 subdir('util/ich_descriptors_tool')
601endif
Thomas Heijligen3ecf0b62022-08-18 12:16:29 +0200602
603programmer_names_active = []
604programmer_names_not_active = []
605foreach p_name, p_data : programmer
606 if p_data.get('active')
607 programmer_names_active += p_name
608 else
609 programmer_names_not_active += p_name + ' (' + p_data.get('summary', '') + ')'
610 endif
611endforeach
612
613summary({
614 'active' : [programmer_names_active],
615 'non active' : [programmer_names_not_active],
616}, section : 'Programmer')