output: add _get_plugin()
[libmpdclient.git] / meson.build
blobe788134e6b62b2afe5c596475043de19cb78ad47
1 project('libmpdclient', 'c', version: '2.14',
2   default_options: [
3     'c_std=c99',
4   ],
5   license: 'BSD',
8 cc = meson.get_compiler('c')
10 conf = configuration_data()
11 conf.set_quoted('PACKAGE', meson.project_name())
12 conf.set_quoted('VERSION', meson.project_version())
14 if host_machine.system() != 'windows'
15   conf.set_quoted('DEFAULT_SOCKET', get_option('default_socket'))
16 endif
18 conf.set_quoted('DEFAULT_HOST', get_option('default_host'))
19 conf.set('DEFAULT_PORT', get_option('default_port'))
21 if get_option('tcp')
22   conf.set('ENABLE_TCP', true)
23   conf.set('HAVE_GETADDRINFO', cc.has_function('getaddrinfo'))
24 endif
26 configure_file(output: 'config.h', configuration: conf)
28 version_conf = configuration_data()
29 splitted_version = meson.project_version().split('.')
30 version_conf.set('MAJOR_VERSION', splitted_version[0])
31 version_conf.set('MINOR_VERSION', splitted_version[1])
32 if splitted_version.length() >= 3
33   version_conf.set('PATCH_VERSION', splitted_version[2])
34 else
35   version_conf.set('PATCH_VERSION', '0')
36 endif
37 configure_file(input: 'include/mpd/version.h.in', output: 'version.h', configuration: version_conf)
39 common_cflags = [
40   # for strdup() with glibc
41   '-D_GNU_SOURCE',
44 test_cflags = [
45   '-Wall',
46   '-Wextra',
47   '-Wno-deprecated-declarations',
48   '-Wmissing-prototypes',
49   '-Wshadow',
50   '-Wpointer-arith',
51   '-Wstrict-prototypes',
52   '-Wcast-qual',
53   '-Wwrite-strings',
56 foreach f: test_cflags
57   if cc.has_argument(f)
58     common_cflags += [ f ]
59   endif
60 endforeach
62 add_global_arguments(common_cflags, language: 'c')
64 common_ldflags = []
66 test_ldflags = [
69 if host_machine.system() == 'linux'
70   test_ldflags += [ '-Wl,--version-script=' + join_paths(meson.source_root(), 'libmpdclient.ld') ]
71 endif
73 foreach f: test_ldflags
74   if cc.has_argument(f)
75     common_ldflags += [ f ]
76   endif
77 endforeach
79 platform_deps = []
80 if host_machine.system() == 'windows'
81   platform_deps = [cc.find_library('ws2_32')]
82 endif
84 inc = include_directories(
85   'src',
86   'include',
88   # for the generated config.h
89   '.',
92 libmpdclient = library('mpdclient',
93   'src/async.c',
94   'src/ierror.c',
95   'src/resolver.c',
96   'src/capabilities.c',
97   'src/connection.c',
98   'src/database.c',
99   'src/directory.c',
100   'src/rdirectory.c',
101   'src/error.c',
102   'src/fd_util.c',
103   'src/output.c',
104   'src/coutput.c',
105   'src/entity.c',
106   'src/idle.c',
107   'src/iso8601.c',
108   'src/list.c',
109   'src/mixer.c',
110   'src/parser.c',
111   'src/password.c',
112   'src/player.c',
113   'src/playlist.c',
114   'src/player.c',
115   'src/rplaylist.c',
116   'src/cplaylist.c',
117   'src/queue.c',
118   'src/quote.c',
119   'src/recv.c',
120   'src/response.c',
121   'src/run.c',
122   'src/search.c',
123   'src/send.c',
124   'src/socket.c',
125   'src/song.c',
126   'src/status.c',
127   'src/cstatus.c',
128   'src/stats.c',
129   'src/cstats.c',
130   'src/sync.c',
131   'src/tag.c',
132   'src/sticker.c',
133   'src/settings.c',
134   'src/message.c',
135   'src/cmessage.c',
136   link_depends: [
137     'libmpdclient.ld'
138   ],
139   include_directories: inc,
140   dependencies: [
141     platform_deps,
142   ],
143   link_args: common_ldflags,
144   version: meson.project_version(),
145   soversion: splitted_version[0],
146   install: true
148 libmpdclient_dep = declare_dependency(link_with: libmpdclient)
150 executable('example',
151   'src/example.c',
152   include_directories: inc,
153   dependencies: [
154     libmpdclient_dep,
155   ])
157 install_headers(
158   'include/mpd/async.h',
159   'include/mpd/audio_format.h',
160   'include/mpd/client.h',
161   'include/mpd/capabilities.h',
162   'include/mpd/compiler.h',
163   'include/mpd/connection.h',
164   'include/mpd/database.h',
165   'include/mpd/directory.h',
166   'include/mpd/entity.h',
167   'include/mpd/error.h',
168   'include/mpd/idle.h',
169   'include/mpd/list.h',
170   'include/mpd/mixer.h',
171   'include/mpd/parser.h',
172   'include/mpd/password.h',
173   'include/mpd/player.h',
174   'include/mpd/playlist.h',
175   'include/mpd/protocol.h',
176   'include/mpd/queue.h',
177   'include/mpd/recv.h',
178   'include/mpd/response.h',
179   'include/mpd/send.h',
180   'include/mpd/status.h',
181   'include/mpd/stats.h',
182   'include/mpd/tag.h',
183   'include/mpd/output.h',
184   'include/mpd/pair.h',
185   'include/mpd/search.h',
186   'include/mpd/socket.h',
187   'include/mpd/song.h',
188   'include/mpd/sticker.h',
189   'include/mpd/settings.h',
190   'include/mpd/message.h',
191   join_paths(meson.build_root(), 'version.h'),
192   subdir: 'mpd')
194 docdir = join_paths(get_option('datadir'), 'doc', meson.project_name())
195 install_data('AUTHORS', 'COPYING', 'NEWS', 'README.rst',
196   install_dir: docdir)
198 install_data('vapi/libmpdclient.vapi',
199   install_dir : join_paths(get_option('datadir'), 'vala', 'vapi'))
201 pkg_mod = import('pkgconfig')
202 pkg_mod.generate(
203   libraries: libmpdclient,
204   version: meson.project_version(),
205   name: 'libmpdclient',
206   description: 'Music Player Daemon client library',
209 if get_option('documentation')
210   doxygen = find_program('doxygen', required: false)
211   if doxygen.found()
212     subdir('doc')
213   endif
214 endif
216 if get_option('test')
217   check_dep = dependency('check')
218   subdir('test')
219 endif