|
| 1 | +project( |
| 2 | + 'libserialport', |
| 3 | + 'c', |
| 4 | + version: '0.1.2', |
| 5 | + license: 'LGPL-3.0-or-later', |
| 6 | + meson_version: '>= 0.49.0', |
| 7 | +) |
| 8 | + |
| 9 | +libserialport_includes = include_directories(['.']) |
| 10 | + |
| 11 | +libserialport_headers = files('libserialport.h') |
| 12 | + |
| 13 | +libserialport_sources = files('serialport.c', 'timing.c') |
| 14 | + |
| 15 | +libserialport_cflags = [] |
| 16 | +libserialport_ldflags = [] |
| 17 | + |
| 18 | +cdata = configuration_data( |
| 19 | + { |
| 20 | + 'SP_API': '__attribute__((visibility("default")))', |
| 21 | + 'SP_PRIV': '__attribute__((visibility("hidden")))', |
| 22 | + }, |
| 23 | +) |
| 24 | + |
| 25 | +if host_machine.system() == 'linux' |
| 26 | + libserialport_sources += files('linux.c', 'linux_termios.c') |
| 27 | + libserialport_cflags += '-DLIBSERIALPORT_ATBUILD' |
| 28 | +elif host_machine.system() == 'windows' |
| 29 | + libserialport_sources += files('windows.c') |
| 30 | + libserialport_cflags += '-DLIBSERIALPORT_MSBUILD' |
| 31 | + libserialport_ldflags += '-lsetupapi' |
| 32 | +elif host_machine.system() == 'darwin' |
| 33 | + libserialport_sources += files('macosx.c') |
| 34 | + libserialport_cflags += '-DLIBSERIALPORT_ATBUILD' |
| 35 | + libserialport_ldflags += '-framework IOKit -framework CoreFoundation' |
| 36 | +elif host_machine.system() == 'freebsd' |
| 37 | + libserialport_sources += files('freebsd.c') |
| 38 | + libserialport_cflags += '-DLIBSERIALPORT_ATBUILD' |
| 39 | +endif |
| 40 | + |
| 41 | +configure_file( |
| 42 | + output: 'config.h', |
| 43 | + configuration: cdata, |
| 44 | +) |
| 45 | + |
| 46 | +libserialport_lib = library( |
| 47 | + 'libserialport', |
| 48 | + libserialport_sources, |
| 49 | + c_args: libserialport_cflags, |
| 50 | + link_args: libserialport_ldflags, |
| 51 | + include_directories: libserialport_includes, |
| 52 | + version: '0.1.0', |
| 53 | + install: true, |
| 54 | +) |
| 55 | + |
| 56 | +install_headers(libserialport_headers) |
| 57 | + |
| 58 | +libserialport_dep = declare_dependency( |
| 59 | + include_directories: libserialport_includes, |
| 60 | + link_with: libserialport_lib, |
| 61 | +) |
0 commit comments