16586fc10SMatt Johnstonproject( 26586fc10SMatt Johnston 'libmctp', 'c', 36586fc10SMatt Johnston meson_version: '>= 1.1', 46586fc10SMatt Johnston version: '0.11', 56586fc10SMatt Johnston default_options: [ 66586fc10SMatt Johnston 'debug=true', 76586fc10SMatt Johnston 'optimization=g', 86586fc10SMatt Johnston 'warning_level=2', 96586fc10SMatt Johnston 'werror=true', 106586fc10SMatt Johnston 'tests=' + (meson.is_subproject() ? 'disabled' : 'enabled'), 116586fc10SMatt Johnston ], 126586fc10SMatt Johnston) 136586fc10SMatt Johnston 146586fc10SMatt Johnstonsources = [ 156586fc10SMatt Johnston 'core.c', 166586fc10SMatt Johnston 'alloc.c', 176586fc10SMatt Johnston 'log.c', 186586fc10SMatt Johnston] 196586fc10SMatt Johnston 206586fc10SMatt Johnstonheaders = [ 216586fc10SMatt Johnston 'libmctp.h', 226586fc10SMatt Johnston] 236586fc10SMatt Johnston 246586fc10SMatt Johnstonserial_sources = [ 256586fc10SMatt Johnston 'serial.c', 266586fc10SMatt Johnston 'crc-16-ccitt.c', 276586fc10SMatt Johnston] 286586fc10SMatt Johnston 296586fc10SMatt Johnstonserial_headers = [ 306586fc10SMatt Johnston 'libmctp-serial.h' 316586fc10SMatt Johnston] 326586fc10SMatt Johnston 336586fc10SMatt Johnstonastlpc_sources = [ 346586fc10SMatt Johnston 'astlpc.c', 356586fc10SMatt Johnston 'crc32.c', 366586fc10SMatt Johnston] 376586fc10SMatt Johnston 386586fc10SMatt Johnstonastlpc_headers = [ 396586fc10SMatt Johnston 'libmctp-astlpc.h', 406586fc10SMatt Johnston] 416586fc10SMatt Johnston 426586fc10SMatt Johnstonlibmctp_sources = sources 436586fc10SMatt Johnstonlibmctp_headers = headers 446586fc10SMatt Johnston 456586fc10SMatt Johnstonif get_option('bindings').contains('serial') 466586fc10SMatt Johnston libmctp_sources += serial_sources 476586fc10SMatt Johnston libmctp_headers += serial_headers 486586fc10SMatt Johnstonendif 496586fc10SMatt Johnstonif get_option('bindings').contains('astlpc') 506586fc10SMatt Johnston libmctp_sources += astlpc_sources 516586fc10SMatt Johnston libmctp_headers += astlpc_headers 526586fc10SMatt Johnstonendif 536586fc10SMatt Johnston 546586fc10SMatt Johnstoncompiler = meson.get_compiler('c') 556586fc10SMatt Johnston 56*bbfcc6e1SMatt Johnstonif not get_option('custom_alloc') and get_option('default_alloc').require( 576586fc10SMatt Johnston compiler.links(''' 586586fc10SMatt Johnston #include <stdlib.h> 596586fc10SMatt Johnston void main() 606586fc10SMatt Johnston { 616586fc10SMatt Johnston free(malloc(4096)); 626586fc10SMatt Johnston } 636586fc10SMatt Johnston ''')).allowed() 646586fc10SMatt Johnston add_project_arguments('-DMCTP_DEFAULT_ALLOC', language : 'c') 656586fc10SMatt Johnstonendif 666586fc10SMatt Johnston 67*bbfcc6e1SMatt Johnstonif get_option('custom_alloc') 68*bbfcc6e1SMatt Johnston add_project_arguments('-DMCTP_CUSTOM_ALLOC', language : 'c') 69*bbfcc6e1SMatt Johnstonendif 70*bbfcc6e1SMatt Johnston 7163338a2eSMatt Johnstonfeat_fileio = get_option('fileio').require( 7263338a2eSMatt Johnston compiler.links(''' 7363338a2eSMatt Johnston #include <poll.h> 7463338a2eSMatt Johnston #include <unistd.h> 7563338a2eSMatt Johnston void main() 7663338a2eSMatt Johnston { 7763338a2eSMatt Johnston poll(NULL, 0, -1); 7863338a2eSMatt Johnston } 7963338a2eSMatt Johnston ''')) 8063338a2eSMatt Johnstonif feat_fileio.allowed() 816586fc10SMatt Johnston add_project_arguments('-DMCTP_HAVE_FILEIO', language : 'c') 826586fc10SMatt Johnstonendif 836586fc10SMatt Johnston 846586fc10SMatt Johnstonif get_option('syslog').require( 856586fc10SMatt Johnston compiler.links(''' 866586fc10SMatt Johnston #include <stdarg.h> 876586fc10SMatt Johnston #include <syslog.h> 886586fc10SMatt Johnston void check_vsyslog(int level, const char *fmt, ...) 896586fc10SMatt Johnston { 906586fc10SMatt Johnston va_list ap; 916586fc10SMatt Johnston va_start(ap, fmt); 926586fc10SMatt Johnston vsyslog(0, fmt, ap); 936586fc10SMatt Johnston va_end(ap); 946586fc10SMatt Johnston } 956586fc10SMatt Johnston void main() 966586fc10SMatt Johnston { 976586fc10SMatt Johnston check_vsyslog(0, "\n"); 986586fc10SMatt Johnston } 996586fc10SMatt Johnston ''')).allowed() 1006586fc10SMatt Johnston add_project_arguments('-DMCTP_HAVE_SYSLOG', language : 'c') 1016586fc10SMatt Johnstonendif 1026586fc10SMatt Johnston 1036586fc10SMatt Johnstonif get_option('stdio').require( 1046586fc10SMatt Johnston compiler.links(''' 1056586fc10SMatt Johnston #include <stdarg.h> 1066586fc10SMatt Johnston #include <stdio.h> 1076586fc10SMatt Johnston void check_vsyslog(const char *fmt, ...) 1086586fc10SMatt Johnston { 1096586fc10SMatt Johnston va_list ap; 1106586fc10SMatt Johnston va_start(ap, fmt); 1116586fc10SMatt Johnston vprintf(fmt, ap); 1126586fc10SMatt Johnston va_end(ap); 1136586fc10SMatt Johnston } 1146586fc10SMatt Johnston void main() 1156586fc10SMatt Johnston { 1166586fc10SMatt Johnston check_vsyslog("\n"); 1176586fc10SMatt Johnston } 1186586fc10SMatt Johnston ''')).allowed() 1196586fc10SMatt Johnston add_project_arguments('-DMCTP_HAVE_STDIO', language : 'c') 1206586fc10SMatt Johnstonendif 1216586fc10SMatt Johnston 1226586fc10SMatt Johnston# pcap is necessary for mctp-demux-daemon to be functional 1236586fc10SMatt Johnstonpcap_dep = dependency('libpcap', required: false) 1246586fc10SMatt Johnston 1256586fc10SMatt Johnstonsystemd_dep = dependency('systemd', required: false) 1266586fc10SMatt Johnstonlibsystemd_dep = dependency('libsystemd', required: false) 1276586fc10SMatt Johnston 1286586fc10SMatt Johnstonlibmctp_include_dir = include_directories('.', is_system: true) 1296586fc10SMatt Johnstonlibmctp = library('mctp', 1306586fc10SMatt Johnston libmctp_sources, 1316586fc10SMatt Johnston include_directories: libmctp_include_dir, 1326586fc10SMatt Johnston version: meson.project_version(), 1336586fc10SMatt Johnston install: true, 1346586fc10SMatt Johnston) 1356586fc10SMatt Johnstoninstall_headers(libmctp_headers) 1366586fc10SMatt Johnston 1376586fc10SMatt Johnstonif systemd_dep.found() 1386586fc10SMatt Johnston unitdir = systemd_dep.get_variable(pkgconfig: 'systemdsystemunitdir') 1396586fc10SMatt Johnston install_data('systemd/system/mctp-demux.service', install_dir: unitdir) 1406586fc10SMatt Johnston install_data('systemd/system/mctp-demux.socket', install_dir: unitdir) 1416586fc10SMatt Johnstonendif 1426586fc10SMatt Johnston 1436586fc10SMatt Johnstonimport('pkgconfig').generate(libmctp, 1446586fc10SMatt Johnston name: 'libmctp', 1456586fc10SMatt Johnston description: 'MCTP protocol implementation', 1466586fc10SMatt Johnston version: meson.project_version(), 1476586fc10SMatt Johnston) 1486586fc10SMatt Johnston 1496586fc10SMatt Johnstonlibmctp_dep = declare_dependency( 1506586fc10SMatt Johnston include_directories: libmctp_include_dir, 1516586fc10SMatt Johnston link_with: libmctp, 1526586fc10SMatt Johnston) 1536586fc10SMatt Johnston 15463338a2eSMatt Johnstonif feat_fileio.allowed() 1556586fc10SMatt Johnston subdir('utils') 15663338a2eSMatt Johnstonendif 1576586fc10SMatt Johnston 1586586fc10SMatt Johnstonif get_option('tests').allowed() 1596586fc10SMatt Johnston subdir('tests') 1606586fc10SMatt Johnstonendif 161