|
| 1 | +project('libmodbus', 'c', version : '3.1.8') |
| 2 | + |
| 3 | +libmodbus_version = meson.project_version() |
| 4 | +ver_arr = libmodbus_version.split('.') |
| 5 | + |
| 6 | +libmodbus_version_major = ver_arr[0] |
| 7 | +libmodbus_version_minor = ver_arr[1] |
| 8 | +libmodbus_version_micro = ver_arr[2] |
| 9 | + |
| 10 | +ver_conf = configuration_data() |
| 11 | +ver_conf.set('LIBMODBUS_VERSION', libmodbus_version) |
| 12 | +ver_conf.set('LIBMODBUS_VERSION_MAJOR', libmodbus_version_major) |
| 13 | +ver_conf.set('LIBMODBUS_VERSION_MINOR', libmodbus_version_minor) |
| 14 | +ver_conf.set('LIBMODBUS_VERSION_MICRO', libmodbus_version_micro) |
| 15 | + |
| 16 | +cc = meson.get_compiler('c') |
| 17 | +cdata = configuration_data() |
| 18 | +check_headers = [ |
| 19 | + 'arpa/inet.h', |
| 20 | + 'byteswap.h', |
| 21 | + 'errno.h', |
| 22 | + 'fcntl.h', |
| 23 | + 'inttypes.h', |
| 24 | + 'limits.h', |
| 25 | + 'linux/serial.h', |
| 26 | + 'netdb.h', |
| 27 | + 'netinet/in.h', |
| 28 | + 'netinet/tcp.h', |
| 29 | + 'stdint.h', |
| 30 | + 'sys/ioctl.h', |
| 31 | + 'sys/params.h', |
| 32 | + 'sys/socket.h', |
| 33 | + 'sys/time.h', |
| 34 | + 'sys/types.h', |
| 35 | + 'termios.h', |
| 36 | + 'time.h', |
| 37 | + 'unistd.h', |
| 38 | +] |
| 39 | + |
| 40 | +foreach h : check_headers |
| 41 | + if cc.has_header(h) |
| 42 | + cdata.set('HAVE_' + h.underscorify().to_upper(), 1) |
| 43 | + endif |
| 44 | +endforeach |
| 45 | + |
| 46 | +check_functions = [ |
| 47 | + ['HAVE_ACCEPT4', 'accept4', '#include<sys/socket.h>'], |
| 48 | + ['HAVE_GETADDRINFO', 'getaddrinfo', '#include<netdb.h>'], |
| 49 | + ['HAVE_GETTIMEOFDAY', 'gettimeofday', '#include<sys/time.h>'], |
| 50 | + ['HAVE_SELECT', 'select', '#include<sys/select.h>'], |
| 51 | + ['HAVE_SOCKET', 'socket', '#include<sys/socket.h>'], |
| 52 | + ['HAVE_STRERROR', 'strerror', '#include<string.h>'], |
| 53 | + ['HAVE_STRLCPY', 'strlcpy', '#include<string.h>'], |
| 54 | +] |
| 55 | + |
| 56 | +foreach f : check_functions |
| 57 | + if cc.has_function(f.get(1), prefix : f.get(2)) |
| 58 | + cdata.set(f.get(0), 1) |
| 59 | + endif |
| 60 | +endforeach |
| 61 | + |
| 62 | +configure_file(output : 'config.h', |
| 63 | + configuration : cdata) |
| 64 | + |
| 65 | +subdir('src') |
| 66 | +subdir('tests') |
0 commit comments