meson.build 5.88 KB
Newer Older
Bastien Nocera's avatar
Bastien Nocera committed
1
project('libfprint', [ 'c', 'cpp' ],
Benjamin Berg's avatar
Benjamin Berg committed
2
    version: '1.90.4',
3
4
5
6
    license: 'LGPLv2.1+',
    default_options: [
        'buildtype=debugoptimized',
        'warning_level=1',
7
        'c_std=gnu99',
8
    ],
9
    meson_version: '>= 0.49.0')
Bastien Nocera's avatar
Bastien Nocera committed
10

11
12
gnome = import('gnome')

Bastien Nocera's avatar
Bastien Nocera committed
13
14
15
16
17
libfprint_conf = configuration_data()

cc = meson.get_compiler('c')
cpp = meson.get_compiler('cpp')
host_system = host_machine.system()
18
glib_min_version = '2.56'
Bastien Nocera's avatar
Bastien Nocera committed
19

20
21
glib_version_def = 'GLIB_VERSION_@0@_@1@'.format(
    glib_min_version.split('.')[0], glib_min_version.split('.')[1])
Bastien Nocera's avatar
Bastien Nocera committed
22
23
common_cflags = cc.get_supported_arguments([
    '-Wall',
24
25
26
27
28
29
30
31
32
33
34
35
    '-Wcast-align',
    '-Wformat-nonliteral',
    '-Wformat-security',
    '-Wformat=2',
    '-Wignored-qualifiers',
    '-Wlogical-op',
    '-Wmissing-declarations',
    '-Wmissing-format-attribute',
    '-Wmissing-include-dirs',
    '-Wmissing-noreturn',
    '-Wpointer-arith',
    '-Wshadow',
36
    '-Wtype-limits',
Bastien Nocera's avatar
Bastien Nocera committed
37
38
    '-Wundef',
    '-Wunused',
39
40
41
42
43
44
45
46
47
48
49
50
51
52
    '-Werror=address',
    '-Werror=array-bounds',
    '-Werror=empty-body',
    '-Werror=init-self',
    '-Werror=int-to-pointer-cast',
    '-Werror=main',
    '-Werror=missing-braces',
    '-Werror=nonnull',
    '-Werror=redundant-decls',
    '-Werror=return-type',
    '-Werror=sequence-point',
    '-Werror=trigraphs',
    '-Werror=write-strings',
    '-fno-strict-aliasing',
53
54
    '-DGLIB_VERSION_MIN_REQUIRED=' + glib_version_def,
    '-DGLIB_VERSION_MAX_ALLOWED=' + glib_version_def,
55
    '-D_GNU_SOURCE',
56
    '-DG_LOG_DOMAIN="@0@"'.format(meson.project_name()),
57
58
])
c_cflags = cc.get_supported_arguments([
59
60
61
62
63
64
65
    '-Wimplicit-function-declaration',
    '-Wmissing-prototypes',
    '-Wnested-externs',
    '-Wold-style-definition',
    '-Wstrict-prototypes',
    '-Werror=implicit',
    '-Werror=pointer-to-int-cast',
Bastien Nocera's avatar
Bastien Nocera committed
66
])
67
68
add_project_arguments(common_cflags + c_cflags, language: 'c')
add_project_arguments(common_cflags, language: 'cpp')
Bastien Nocera's avatar
Bastien Nocera committed
69
70
71
72

# maintaining compatibility with the previous libtool versioning
# current = binary - interface
# revision = interface
73
soversion = 2
Bastien Nocera's avatar
Bastien Nocera committed
74
75
76
current = 0
revision = 0
libversion = '@0@.@1@.@2@'.format(soversion, current, revision)
77
versioned_libname = meson.project_name() + '-' + soversion.to_string()
Bastien Nocera's avatar
Bastien Nocera committed
78
79

# Dependencies
80
81
glib_dep = dependency('glib-2.0', version: '>=' + glib_min_version)
gio_dep = dependency('gio-unix-2.0', version: '>=' + glib_min_version)
82
gobject_dep = dependency('gobject-2.0', version: '>=' + glib_min_version)
83
gusb_dep = dependency('gusb', version: '>= 0.2.0')
Bastien Nocera's avatar
Bastien Nocera committed
84
85
mathlib_dep = cc.find_library('m', required: false)

86
87
88
# The following dependencies are only used for tests
cairo_dep = dependency('cairo', required: false)

Bastien Nocera's avatar
Bastien Nocera committed
89
90
# Drivers
drivers = get_option('drivers').split(',')
91
virtual_drivers = [ 'virtual_image' ]
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
default_drivers = [
    'upektc_img',
    'vfs5011',
    'aes3500',
    'aes4000',
    'aes1610',
    'aes1660',
    'aes2660',
    'aes2501',
    'aes2550',
    'vfs101',
    'vfs301',
    'vfs0050',
    'etes603',
    'vcom5s',
    'synaptics',
    'elan',
    'uru4000',
    'upektc',
    'upeksonly',
    'upekts',
113
    'goodixmoc',
114
]
Bastien Nocera's avatar
Bastien Nocera committed
115

116
117
all_drivers = default_drivers + virtual_drivers

Bastien Nocera's avatar
Bastien Nocera committed
118
119
120
121
if drivers == [ 'all' ]
    drivers = all_drivers
endif

122
123
124
125
if drivers == [ 'default' ]
    drivers = default_drivers
endif

126
127
128
129
if drivers.length() == 0 or drivers[0] == ''
    error('Cannot build libfprint without drivers, please specify a valid value for the drivers option')
endif

130
131
nss_dep = dependency('', required: false)
imaging_dep = dependency('', required: false)
132
libfprint_conf.set10('HAVE_PIXMAN', false)
Bastien Nocera's avatar
Bastien Nocera committed
133
134
135
136
137
138
139
140
141
142
143
144
foreach driver: drivers
    if driver == 'uru4000'
        nss_dep = dependency('nss', required: false)
        if not nss_dep.found()
            error('NSS is required for the URU4000/URU4500 driver')
        endif
    endif
    if driver == 'aes3500' or driver == 'aes4000'
        imaging_dep = dependency('pixman-1', required: false)
        if not imaging_dep.found()
            error('pixman is required for imaging support')
        endif
145
146

        libfprint_conf.set10('HAVE_PIXMAN', true)
Bastien Nocera's avatar
Bastien Nocera committed
147
148
149
150
151
152
    endif
    if not all_drivers.contains(driver)
        error('Invalid driver \'' + driver + '\'')
    endif
endforeach

153
# Export the drivers' types to the core code
154
155
156
157
158
drivers_type_list = []
drivers_type_func = []
drivers_type_list += '#include <glib-object.h>'
drivers_type_list += '#include "fpi-context.h"'
drivers_type_list += ''
159
160
drivers_type_func += 'GArray *'
drivers_type_func += 'fpi_get_driver_types (void)'
161
drivers_type_func += '{'
162
drivers_type_func += '  GArray *drivers = g_array_new (TRUE, FALSE, sizeof (GType));'
163
drivers_type_func += '  GType t;'
164
drivers_type_func += ''
165
foreach driver: drivers
166
    drivers_type_list += 'extern GType (fpi_device_' + driver + '_get_type) (void);'
167
168
    drivers_type_func += '  t = fpi_device_' + driver + '_get_type ();'
    drivers_type_func += '  g_array_append_val (drivers, t);'
169
    drivers_type_func += ''
170
endforeach
171
drivers_type_list += ''
172
drivers_type_func += '  return drivers;'
173
drivers_type_func += '}'
Bastien Nocera's avatar
Bastien Nocera committed
174
175
176
177
178
179
180
181

root_inc = include_directories('.')

if get_option('udev_rules')
    udev_rules_dir = get_option('udev_rules_dir')

    if udev_rules_dir == 'auto'
        udev_dep = dependency('udev')
182
        udev_rules_dir = udev_dep.get_pkgconfig_variable('udevdir') + '/rules.d'
Bastien Nocera's avatar
Bastien Nocera committed
183
184
185
    endif
endif

186
187
188
189
190
191
192
193
194
if get_option('gtk-examples')
    gnome = import('gnome')

    gtk_dep = dependency('gtk+-3.0', required: false)
    if not gtk_dep.found()
        error('GTK+ 3.x is required for GTK+ examples')
    endif
endif

Bastien Nocera's avatar
Bastien Nocera committed
195
196
197
198
configure_file(output: 'config.h', configuration: libfprint_conf)

subdir('libfprint')
subdir('examples')
199
200
201
202
if get_option('doc')
    gnome = import('gnome')
    subdir('doc')
endif
203
204
205
if get_option('gtk-examples')
    subdir('demo')
endif
Bastien Nocera's avatar
Bastien Nocera committed
206

207
subdir('tests')
208

Bastien Nocera's avatar
Bastien Nocera committed
209
210
pkgconfig = import('pkgconfig')
pkgconfig.generate(
211
    name: versioned_libname,
212
213
214
    description: 'Generic C API for fingerprint reader access',
    version: meson.project_version(),
    libraries: libfprint,
215
    requires: [gio_dep, gobject_dep],
216
217
    subdirs: versioned_libname,
    filebase: versioned_libname,
218
)