1*6586fc10SMatt Johnstonproject( 2*6586fc10SMatt Johnston 'libmctp', 'c', 3*6586fc10SMatt Johnston meson_version: '>= 1.1', 4*6586fc10SMatt Johnston version: '0.11', 5*6586fc10SMatt Johnston default_options: [ 6*6586fc10SMatt Johnston 'debug=true', 7*6586fc10SMatt Johnston 'optimization=g', 8*6586fc10SMatt Johnston 'warning_level=2', 9*6586fc10SMatt Johnston 'werror=true', 10*6586fc10SMatt Johnston 'tests=' + (meson.is_subproject() ? 'disabled' : 'enabled'), 11*6586fc10SMatt Johnston ], 12*6586fc10SMatt Johnston) 13*6586fc10SMatt Johnston 14*6586fc10SMatt Johnstonsources = [ 15*6586fc10SMatt Johnston 'core.c', 16*6586fc10SMatt Johnston 'alloc.c', 17*6586fc10SMatt Johnston 'log.c', 18*6586fc10SMatt Johnston] 19*6586fc10SMatt Johnston 20*6586fc10SMatt Johnstonheaders = [ 21*6586fc10SMatt Johnston 'libmctp.h', 22*6586fc10SMatt Johnston] 23*6586fc10SMatt Johnston 24*6586fc10SMatt Johnstonserial_sources = [ 25*6586fc10SMatt Johnston 'serial.c', 26*6586fc10SMatt Johnston 'crc-16-ccitt.c', 27*6586fc10SMatt Johnston] 28*6586fc10SMatt Johnston 29*6586fc10SMatt Johnstonserial_headers = [ 30*6586fc10SMatt Johnston 'libmctp-serial.h' 31*6586fc10SMatt Johnston] 32*6586fc10SMatt Johnston 33*6586fc10SMatt Johnstonastlpc_sources = [ 34*6586fc10SMatt Johnston 'astlpc.c', 35*6586fc10SMatt Johnston 'crc32.c', 36*6586fc10SMatt Johnston] 37*6586fc10SMatt Johnston 38*6586fc10SMatt Johnstonastlpc_headers = [ 39*6586fc10SMatt Johnston 'libmctp-astlpc.h', 40*6586fc10SMatt Johnston] 41*6586fc10SMatt Johnston 42*6586fc10SMatt Johnstonlibmctp_sources = sources 43*6586fc10SMatt Johnstonlibmctp_headers = headers 44*6586fc10SMatt Johnston 45*6586fc10SMatt Johnstonif get_option('bindings').contains('serial') 46*6586fc10SMatt Johnston libmctp_sources += serial_sources 47*6586fc10SMatt Johnston libmctp_headers += serial_headers 48*6586fc10SMatt Johnstonendif 49*6586fc10SMatt Johnstonif get_option('bindings').contains('astlpc') 50*6586fc10SMatt Johnston libmctp_sources += astlpc_sources 51*6586fc10SMatt Johnston libmctp_headers += astlpc_headers 52*6586fc10SMatt Johnstonendif 53*6586fc10SMatt Johnston 54*6586fc10SMatt Johnstoncompiler = meson.get_compiler('c') 55*6586fc10SMatt Johnston 56*6586fc10SMatt Johnstonif get_option('default_alloc').require( 57*6586fc10SMatt Johnston compiler.links(''' 58*6586fc10SMatt Johnston #include <stdlib.h> 59*6586fc10SMatt Johnston void main() 60*6586fc10SMatt Johnston { 61*6586fc10SMatt Johnston free(malloc(4096)); 62*6586fc10SMatt Johnston } 63*6586fc10SMatt Johnston ''')).allowed() 64*6586fc10SMatt Johnston add_project_arguments('-DMCTP_DEFAULT_ALLOC', language : 'c') 65*6586fc10SMatt Johnstonendif 66*6586fc10SMatt Johnston 67*6586fc10SMatt Johnstonif get_option('fileio').require( 68*6586fc10SMatt Johnston compiler.check_header('unistd.h') and compiler.check_header('fcntl.h') 69*6586fc10SMatt Johnston ).allowed() 70*6586fc10SMatt Johnston add_project_arguments('-DMCTP_HAVE_FILEIO', language : 'c') 71*6586fc10SMatt Johnstonendif 72*6586fc10SMatt Johnston 73*6586fc10SMatt Johnstonif get_option('syslog').require( 74*6586fc10SMatt Johnston compiler.links(''' 75*6586fc10SMatt Johnston #include <stdarg.h> 76*6586fc10SMatt Johnston #include <syslog.h> 77*6586fc10SMatt Johnston void check_vsyslog(int level, const char *fmt, ...) 78*6586fc10SMatt Johnston { 79*6586fc10SMatt Johnston va_list ap; 80*6586fc10SMatt Johnston va_start(ap, fmt); 81*6586fc10SMatt Johnston vsyslog(0, fmt, ap); 82*6586fc10SMatt Johnston va_end(ap); 83*6586fc10SMatt Johnston } 84*6586fc10SMatt Johnston void main() 85*6586fc10SMatt Johnston { 86*6586fc10SMatt Johnston check_vsyslog(0, "\n"); 87*6586fc10SMatt Johnston } 88*6586fc10SMatt Johnston ''')).allowed() 89*6586fc10SMatt Johnston add_project_arguments('-DMCTP_HAVE_SYSLOG', language : 'c') 90*6586fc10SMatt Johnstonendif 91*6586fc10SMatt Johnston 92*6586fc10SMatt Johnstonif get_option('stdio').require( 93*6586fc10SMatt Johnston compiler.links(''' 94*6586fc10SMatt Johnston #include <stdarg.h> 95*6586fc10SMatt Johnston #include <stdio.h> 96*6586fc10SMatt Johnston void check_vsyslog(const char *fmt, ...) 97*6586fc10SMatt Johnston { 98*6586fc10SMatt Johnston va_list ap; 99*6586fc10SMatt Johnston va_start(ap, fmt); 100*6586fc10SMatt Johnston vprintf(fmt, ap); 101*6586fc10SMatt Johnston va_end(ap); 102*6586fc10SMatt Johnston } 103*6586fc10SMatt Johnston void main() 104*6586fc10SMatt Johnston { 105*6586fc10SMatt Johnston check_vsyslog("\n"); 106*6586fc10SMatt Johnston } 107*6586fc10SMatt Johnston ''')).allowed() 108*6586fc10SMatt Johnston add_project_arguments('-DMCTP_HAVE_STDIO', language : 'c') 109*6586fc10SMatt Johnstonendif 110*6586fc10SMatt Johnston 111*6586fc10SMatt Johnston# pcap is necessary for mctp-demux-daemon to be functional 112*6586fc10SMatt Johnstonpcap_dep = dependency('libpcap', required: false) 113*6586fc10SMatt Johnston 114*6586fc10SMatt Johnstonsystemd_dep = dependency('systemd', required: false) 115*6586fc10SMatt Johnstonlibsystemd_dep = dependency('libsystemd', required: false) 116*6586fc10SMatt Johnston 117*6586fc10SMatt Johnstonlibmctp_include_dir = include_directories('.', is_system: true) 118*6586fc10SMatt Johnstonlibmctp = library('mctp', 119*6586fc10SMatt Johnston libmctp_sources, 120*6586fc10SMatt Johnston include_directories: libmctp_include_dir, 121*6586fc10SMatt Johnston version: meson.project_version(), 122*6586fc10SMatt Johnston install: true, 123*6586fc10SMatt Johnston) 124*6586fc10SMatt Johnstoninstall_headers(libmctp_headers) 125*6586fc10SMatt Johnston 126*6586fc10SMatt Johnstonif systemd_dep.found() 127*6586fc10SMatt Johnston unitdir = systemd_dep.get_variable(pkgconfig: 'systemdsystemunitdir') 128*6586fc10SMatt Johnston install_data('systemd/system/mctp-demux.service', install_dir: unitdir) 129*6586fc10SMatt Johnston install_data('systemd/system/mctp-demux.socket', install_dir: unitdir) 130*6586fc10SMatt Johnstonendif 131*6586fc10SMatt Johnston 132*6586fc10SMatt Johnstonimport('pkgconfig').generate(libmctp, 133*6586fc10SMatt Johnston name: 'libmctp', 134*6586fc10SMatt Johnston description: 'MCTP protocol implementation', 135*6586fc10SMatt Johnston version: meson.project_version(), 136*6586fc10SMatt Johnston) 137*6586fc10SMatt Johnston 138*6586fc10SMatt Johnstonlibmctp_dep = declare_dependency( 139*6586fc10SMatt Johnston include_directories: libmctp_include_dir, 140*6586fc10SMatt Johnston link_with: libmctp, 141*6586fc10SMatt Johnston) 142*6586fc10SMatt Johnston 143*6586fc10SMatt Johnstonsubdir('utils') 144*6586fc10SMatt Johnston 145*6586fc10SMatt Johnstonif get_option('tests').allowed() 146*6586fc10SMatt Johnston subdir('tests') 147*6586fc10SMatt Johnstonendif 148