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

add_project_arguments([ '-D_GNU_SOURCE' ], language: 'c')
12
add_project_arguments([ '-DG_LOG_DOMAIN="libfprint"' ], language: 'c')
Bastien Nocera's avatar
Bastien Nocera committed
13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29

libfprint_conf = configuration_data()

cc = meson.get_compiler('c')
cpp = meson.get_compiler('cpp')
host_system = host_machine.system()

common_cflags = cc.get_supported_arguments([
    '-fgnu89-inline',
    '-fvisibility=hidden',
    '-std=gnu99',
    '-Wall',
    '-Wundef',
    '-Wunused',
    '-Wstrict-prototypes',
    '-Werror-implicit-function-declaration',
    '-Wno-pointer-sign',
30 31 32
    '-Wshadow',
    '-DGLIB_VERSION_MIN_REQUIRED=GLIB_VERSION_2_50',
    '-DGLIB_VERSION_MAX_ALLOWED=GLIB_VERSION_2_50',
Bastien Nocera's avatar
Bastien Nocera committed
33 34 35 36 37 38 39 40 41 42 43
])

# maintaining compatibility with the previous libtool versioning
# current = binary - interface
# revision = interface
soversion = 0
current = 0
revision = 0
libversion = '@0@.@1@.@2@'.format(soversion, current, revision)

# Dependencies
44
glib_dep = dependency('glib-2.0', version: '>= 2.50')
Bastien Nocera's avatar
Bastien Nocera committed
45 46 47 48 49 50
libusb_dep = dependency('libusb-1.0', version: '>= 0.9.1')
mathlib_dep = cc.find_library('m', required: false)

# Drivers
drivers = get_option('drivers').split(',')
all_drivers = [ 'upekts', 'upektc', 'upeksonly', 'vcom5s', 'uru4000', 'aes1610', 'aes1660', 'aes2501', 'aes2550', 'aes2660', 'aes3500', 'aes4000', 'vfs101', 'vfs301', 'vfs5011', 'upektc_img', 'etes603', 'vfs0050', 'elan' ]
51
primitive_drivers = [ 'upekts' ]
Bastien Nocera's avatar
Bastien Nocera committed
52 53 54 55 56

if drivers == [ 'all' ]
    drivers = all_drivers
endif

57 58 59 60
if drivers.length() == 0 or drivers[0] == ''
    error('Cannot build libfprint without drivers, please specify a valid value for the drivers option')
endif

61 62
nss_dep = dependency('', required: false)
imaging_dep = dependency('', required: false)
Bastien Nocera's avatar
Bastien Nocera committed
63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80
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
    endif
    if not all_drivers.contains(driver)
        error('Invalid driver \'' + driver + '\'')
    endif
endforeach

81 82 83 84 85 86 87 88 89 90 91 92 93 94 95
# Export the drivers' structures to the core code
drivers_struct_list = ''
drivers_img_array = 'static struct fp_img_driver * const img_drivers[] = {\n'
drivers_primitive_array = 'static struct fp_driver * const primitive_drivers[] = {\n'
foreach driver: drivers
    if primitive_drivers.contains(driver)
        drivers_struct_list += 'extern struct fp_driver ' + driver + '_driver;\n'
        drivers_primitive_array += '	&' + driver + '_driver,\n'
    else
        drivers_struct_list += 'extern struct fp_img_driver ' + driver + '_driver;\n'
        drivers_img_array += '	&' + driver + '_driver,\n'
    endif
endforeach
drivers_img_array += '};'
drivers_primitive_array += '};'
Bastien Nocera's avatar
Bastien Nocera committed
96 97 98 99 100 101 102 103

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')
104
        udev_rules_dir = udev_dep.get_pkgconfig_variable('udevdir') + '/rules.d'
Bastien Nocera's avatar
Bastien Nocera committed
105 106 107 108 109 110 111 112 113 114 115
    endif
endif

if get_option('x11-examples')
    x11_dep = cc.find_library('X11')
    xv_dep = dependency('xv', required: false)
    if not xv_dep.found()
        error('XV is required for X11 examples')
    endif
endif

116 117 118 119 120 121 122 123 124
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
125 126 127 128 129
libfprint_conf.set('API_EXPORTED', '__attribute__((visibility("default")))')
configure_file(output: 'config.h', configuration: libfprint_conf)

subdir('libfprint')
subdir('examples')
130 131 132 133
if get_option('doc')
    gnome = import('gnome')
    subdir('doc')
endif
134 135 136
if get_option('gtk-examples')
    subdir('demo')
endif
Bastien Nocera's avatar
Bastien Nocera committed
137 138 139 140 141 142 143 144 145 146 147

pkgconfig = import('pkgconfig')
pkgconfig.generate(
  name: 'libfprint',
  description: 'Generic C API for fingerprint reader access',
  version: meson.project_version(),
  libraries: libfprint,
  subdirs: 'libfprint',
  filebase: 'libfprint',
  install_dir: join_paths(get_option('libdir'), 'pkgconfig'),
)