]> git.draconx.ca Git - dxcommon.git/blob - m4/libevdev.m4
Add libevdev detection macro.
[dxcommon.git] / m4 / libevdev.m4
1 dnl Copyright © 2017 Nick Bowler
2 dnl
3 dnl License WTFPL2: Do What The Fuck You Want To Public License, version 2.
4 dnl This is free software: you are free to do what the fuck you want to.
5 dnl There is NO WARRANTY, to the extent permitted by law.
6
7 dnl DX_LIB_LIBEVDEV
8 dnl
9 dnl Search for libevdev.  This library does not expose version information
10 dnl so min-version checks are not supported.
11 dnl
12 dnl If a working library is found, appropriate compiler and linker flags are
13 dnl stored in LIBEVDEV_CFLAGS and LIBEVDEV_LIBS, respectively, and the
14 dnl action-if-ok is performed (may be empty).  If no such library is found,
15 dnl then action-if-failed is performed if non-empty; otherwise configure will
16 dnl stop with a fatal error.
17 AC_DEFUN([DX_LIB_LIBEVDEV],
18 [DX_LIB_SETUP([libevdev])dnl
19 DX_LIB_PKGCONFIG_FLAGS([libevdev])
20 AC_MSG_CHECKING([for libevdev])
21 DX_LIB_SEARCH_LINK([libevdev], [_DX_LIB_LIBEVDEV_TEST],
22   [ [[$LIBEVDEV_CFLAGS], [$LIBEVDEV_LIBS]],
23     [[$dx_cv_libevdev_pkg_cflags], [$dx_cv_libevdev_pkg_libs],
24       [test x"$dx_cv_libevdev_pkg_found" = x"yes"]],
25     [[], [-levdev]] ])
26 AS_IF([test x"$dx_cv_libevdev_lib_found" = x"yes"], [$1],
27   [m4_default([$2], [AC_MSG_FAILURE(
28 [libevdev is required.  The latest version may be found at
29 <https://www.freedesktop.org/wiki/Software/libevdev/>.
30 m4_newline([DX_LIB_USERFLAG_BLURB([libevdev])])
31 m4_newline([DX_LIB_PKGCONFIG_BLURB([libevdev])])
32 ])])])])
33
34 dnl Internal test program for libevdev.
35 m4_define([_DX_LIB_LIBEVDEV_TEST], [AC_LANG_PROGRAM(
36 [#include <libevdev/libevdev.h>
37 ],
38 [libevdev_free(libevdev_new());
39 ])])