1project('audacious', 'c', 'cpp',
2        version: '4.1',
3        meson_version: '>= 0.46',
4        default_options: [
5          'c_std=gnu99',
6          'cpp_std=gnu++11',
7          'warning_level=1'
8        ])
9
10
11copyright = 'Copyright (C) 2001-2021 Audacious developers and others'
12
13
14qt5 = import('qt5')
15gnome = import('gnome')
16
17
18glib_req = '>= 2.32'
19glib_dep = dependency('glib-2.0', version: glib_req, required: true)
20gmodule_dep = dependency('gmodule-2.0', version: glib_req, required: true)
21thread_dep = dependency('threads', required: true)
22
23
24if get_option('qt')
25  qt_req = '>= 5.2'
26  qt_dep = dependency('qt5', version: qt_req, required: true, modules: ['Core', 'Widgets', 'Gui'])
27endif
28
29
30if get_option('gtk')
31  gtk_req = '>= 2.24'
32  gtk_dep = dependency('gtk+-2.0', version: gtk_req, required: true)
33endif
34
35
36if get_option('libarchive')
37  libarchive_dep = dependency('libarchive', required: true)
38endif
39
40
41have_darwin = host_machine.system() == 'darwin'
42have_windows = host_machine.system() == 'windows'
43
44
45cc = meson.get_compiler('c')
46cxx = meson.get_compiler('cpp')
47
48
49if cc.get_id() in ['gcc', 'clang']
50  common_flags = [
51    '-ffast-math',
52    '-Wtype-limits',
53    '-Wno-stringop-truncation',
54    '-fvisibility=hidden'
55  ]
56
57  cxx_flags = [
58    '-Wno-non-virtual-dtor',
59    '-Woverloaded-virtual'
60  ]
61
62  check_cflags = common_flags
63  check_cxxflags = common_flags + cxx_flags
64
65  add_project_arguments(cc.get_supported_arguments(check_cflags), language: 'c')
66  add_project_arguments(cxx.get_supported_arguments(check_cxxflags), language: 'cpp')
67endif
68
69
70conf = configuration_data()
71conf.set_quoted('BUILDSTAMP', get_option('buildstamp'))
72conf.set_quoted('COPYRIGHT', copyright)
73conf.set_quoted('PACKAGE', meson.project_name())
74conf.set_quoted('VERSION', meson.project_version())
75conf.set('PACKAGE_VERSION', meson.project_version())
76if host_machine.endian() == 'big'
77  conf.set10('WORDS_BIGENDIAN', true)
78  conf.set10('BIGENDIAN', true)
79else
80  conf.set10('BIGENDIAN', false)
81endif
82
83
84# XXX - investigate to see if we can do better
85if have_windows
86  conf.set_quoted('PLUGIN_SUFFIX', '.dll')
87elif have_darwin
88  conf.set_quoted('PLUGIN_SUFFIX', '.dylib')
89else
90  conf.set_quoted('PLUGIN_SUFFIX', '.so')
91endif
92
93
94if have_windows
95  conf.set('EXPORT', '__declspec(dllexport)')
96elif cxx.has_argument('-fvisibility=default')
97  conf.set('EXPORT', '__attribute__((visibility("default")))')
98else
99  error('Could not define EXPORT keyword for public symbols.')
100endif
101
102
103# XXX - why do we have to define this manually?
104if (cxx.has_header('libintl.h'))
105  add_project_arguments('-DHAVE_GETTEXT', language: ['c', 'cpp'])
106
107  if have_darwin or have_windows
108    add_project_link_arguments('-lintl', language: ['c', 'cpp'])
109  endif
110endif
111
112
113install_bindir = get_option('bindir')
114install_datadir = join_paths(get_option('datadir'), 'audacious')
115install_plugindir = join_paths(get_option('libdir'), 'audacious')
116install_localedir = get_option('localedir')
117install_desktoppath = join_paths(get_option('datadir'), 'applications')
118install_desktopfile = join_paths(install_desktoppath, 'audacious.desktop')
119install_iconpath = join_paths(get_option('datadir'), 'icons')
120install_unscalable_iconpath = join_paths(install_iconpath, 'hicolor', '48x48', 'apps')
121install_scalable_iconpath = join_paths(install_iconpath, 'hicolor', 'scalable', 'apps')
122install_iconfile = join_paths(install_unscalable_iconpath, 'audacious.png')
123
124
125conf.set_quoted('INSTALL_BINDIR', join_paths(get_option('prefix'), install_bindir))
126conf.set_quoted('INSTALL_DATADIR', join_paths(get_option('prefix'), install_datadir))
127conf.set_quoted('INSTALL_PLUGINDIR', join_paths(get_option('prefix'), install_plugindir))
128conf.set_quoted('INSTALL_LOCALEDIR', join_paths(get_option('prefix'), install_localedir))
129conf.set_quoted('INSTALL_DESKTOPFILE', join_paths(get_option('prefix'), install_desktopfile))
130conf.set_quoted('INSTALL_ICONFILE', join_paths(get_option('prefix'), install_iconfile))
131conf.set('plugindir', install_plugindir)
132conf.set('datarootdir', get_option('datadir'))
133
134
135if get_option('dbus')
136  conf.set10('USE_DBUS', true)
137endif
138
139
140if get_option('qt')
141  conf.set10('USE_QT', true)
142endif
143
144
145if get_option('gtk')
146  conf.set10('USE_GTK', true)
147endif
148
149
150if get_option('libarchive')
151  conf.set10('USE_LIBARCHIVE', true)
152endif
153
154
155if get_option('valgrind')
156  conf.set10('VALGRIND_FRIENDLY', true)
157endif
158
159
160subdir('src')
161subdir('po')
162subdir('man')
163subdir('images')
164
165
166install_data('AUTHORS', 'COPYING')
167install_data('audacious.desktop', install_dir: install_desktoppath)
168
169
170pkg = import('pkgconfig')
171
172# When Meson fixes the utter disappointment that is
173# https://github.com/mesonbuild/meson/issues/5836,
174# use libaudcore_lib as base dependency here.
175pkg.generate(
176  libraries: ['-L${libdir} -laudcore'],
177  variables: [
178    'plugin_dir=${libdir}/audacious',
179
180    # Appease broken third-party plugin build systems.
181    'audacious_include_dir=${includedir}',
182    'include_dir=${includedir}',
183    'lib_dir=${libdir}'
184  ],
185  description: 'versatile and handy multi platform media player',
186  name: 'audacious',
187  url: 'https://audacious-media-player.org'
188)
189
190
191if meson.version().version_compare('>= 0.53')
192  summary({
193    'Prefix': get_option('prefix'),
194    'Bin dir': get_option('bindir'),
195    'Lib dir': get_option('libdir'),
196    'Data dir': get_option('datadir'),
197  }, section: 'Directories')
198
199  summary({
200    'D-Bus support': get_option('dbus'),
201    'Qt support': get_option('qt'),
202    'GTK support': get_option('gtk'),
203    'Libarchive support': get_option('libarchive'),
204    'Valgrind analysis support': get_option('valgrind'),
205    'Build stamp': get_option('buildstamp'),
206  }, section: 'Configuration')
207endif
208