summaryrefslogtreecommitdiff
path: root/meson.build
blob: a9b223a5ed886f28ed173678f95b2e7dc78252ff (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
project('gvc', 'c',
  meson_version: '>= 0.38.0',
  default_options: 'default_library=static'
)

if not meson.is_subproject()
  error('This project is only intended to be used as a subproject!')
endif

gnome = import('gnome')

pkglibdir = get_option('pkglibdir')
pkgdatadir = get_option('pkgdatadir')

cdata = configuration_data()
cdata.set_quoted('GETTEXT_PACKAGE', get_option('package_name'))
cdata.set_quoted('PACKAGE_VERSION', get_option('package_version'))

libgvc_inc = include_directories('.')

libgvc_gir_headers = [
  'gvc-channel-map.h',
  'gvc-mixer-card.h',
  'gvc-mixer-control.h',
  'gvc-mixer-event-role.h',
  'gvc-mixer-sink.h',
  'gvc-mixer-sink-input.h',
  'gvc-mixer-source.h',
  'gvc-mixer-source-output.h',
  'gvc-mixer-stream.h',
  'gvc-mixer-ui-device.h'
]

libgvc_gir_sources = [
  'gvc-channel-map.c',
  'gvc-mixer-card.c',
  'gvc-mixer-control.c',
  'gvc-mixer-event-role.c',
  'gvc-mixer-sink.c',
  'gvc-mixer-sink-input.c',
  'gvc-mixer-source.c',
  'gvc-mixer-source-output.c',
  'gvc-mixer-stream.c',
  'gvc-mixer-ui-device.c'
]

libgvc_no_gir_sources = [
  'gvc-mixer-card-private.h',
  'gvc-mixer-stream-private.h',
  'gvc-channel-map-private.h',
  'gvc-mixer-control-private.h',
  'gvc-pulseaudio-fake.h'
]

libgvc_deps = [
  dependency('gio-2.0'),
  dependency('gobject-2.0'),
  dependency('libpulse', version: '>= 2.0'),
  dependency('libpulse-mainloop-glib')
]

enable_alsa = get_option('alsa')
if enable_alsa
  libgvc_deps += dependency('alsa')
endif
cdata.set('HAVE_ALSA', enable_alsa)

static = get_option('default_library') == 'static'
enable_introspection = get_option('introspection')

if not static and pkglibdir == ''
  error('Installing shared library, but pkglibdir is unset!')
endif

if static and enable_introspection
  error('Currently meson requires a shared library for building girs.')
endif

c_args = ['-DG_LOG_DOMAIN="Gvc"']

if enable_introspection
  c_args += '-DWITH_INTROSPECTION'
endif

libgvc = library('gvc',
  sources: libgvc_gir_sources + libgvc_no_gir_sources,
  include_directories: libgvc_inc,
  dependencies: libgvc_deps,
  c_args: c_args,
  install_rpath: pkgdatadir,
  install_dir: pkglibdir,
  install: not static
)

if enable_introspection
  if pkgdatadir == ''
    error('Installing introspection, but pkgdatadir is unset!')
  elif (pkglibdir == '')
    error('Installing introspection, but pkglibdir is unset!')
  endif

  libgvc_gir = gnome.generate_gir(libgvc,
    sources: libgvc_gir_sources + libgvc_gir_headers,
    nsversion: '1.0',
    namespace: 'Gvc',
    includes: ['Gio-2.0', 'GObject-2.0'],
    extra_args: ['-DWITH_INTROSPECTION', '--quiet'],
    install_dir_gir: pkgdatadir,
    install_dir_typelib: pkglibdir,
    install: true
  )
endif

if enable_alsa
  executable('test-audio-device-selection',
    sources: 'test-audio-device-selection.c',
    link_with: libgvc,
    dependencies: libgvc_deps,
    c_args: c_args
  )
endif

libgvc_dep = declare_dependency(
  link_with: libgvc,
  include_directories: libgvc_inc,
  dependencies: libgvc_deps
)

config = configure_file(
  input: 'config.h.meson',
  output: 'config.h',
  configuration: cdata
)