fd402e20f49ac2cbc0d87004103b3cd9da68832a
[platform/upstream/libinput.git] / configure.ac
1 AC_PREREQ([2.64])
2
3 m4_define([libinput_major_version], [0])
4 m4_define([libinput_minor_version], [4])
5 m4_define([libinput_micro_version], [0])
6 m4_define([libinput_version],
7           [libinput_major_version.libinput_minor_version.libinput_micro_version])
8
9 AC_INIT([libinput],
10         [libinput_version],
11         [https://bugs.freedesktop.org/enter_bug.cgi?product=Wayland&component=libinput&version=libinput_version],
12         [libinput],
13         [http://www.freedesktop.org/wiki/Software/libinput/])
14
15 AC_SUBST([LIBINPUT_VERSION_MAJOR], [libinput_major_version])
16 AC_SUBST([LIBINPUT_VERSION_MINOR], [libinput_minor_version])
17 AC_SUBST([LIBINPUT_VERSION_MICRO], [libinput_micro_version])
18 AC_SUBST([LIBINPUT_VERSION], [libinput_version])
19
20 AC_CONFIG_HEADERS([config.h])
21 AC_CONFIG_MACRO_DIR([m4])
22
23 AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz subdir-objects])
24
25 # Before making a release, the LIBINPUT_LT_VERSION string should be
26 # modified.
27 # The string is of the form C:R:A.
28 # - If interfaces have been changed or added, but binary compatibility has
29 #   been preserved, change to C+1:0:A+1
30 # - If binary compatibility has been broken (eg removed or changed interfaces)
31 #   change to C+1:0:0
32 # - If the interface is the same as the previous version, change to C:R+1:A
33 LIBINPUT_LT_VERSION=3:0:0
34 AC_SUBST(LIBINPUT_LT_VERSION)
35
36 AM_SILENT_RULES([yes])
37
38 # Check for programs
39 AC_PROG_CC_C99
40 AC_PROG_CXX # Only used by build C++ test
41
42 # Initialize libtool
43 LT_PREREQ([2.2])
44 LT_INIT
45
46 AC_CHECK_DECL(EPOLL_CLOEXEC, [],
47               [AC_MSG_ERROR("EPOLL_CLOEXEC is needed to compile libinput")],
48               [[#include <sys/epoll.h>]])
49 AC_CHECK_DECL(TFD_CLOEXEC,[],
50               [AC_MSG_ERROR("TFD_CLOEXEC is needed to compile libinput")],
51               [[#include <sys/timerfd.h>]])
52 AC_CHECK_DECL(CLOCK_MONOTONIC,[],
53               [AC_MSG_ERROR("CLOCK_MONOTONIC is needed to compile libinput")],
54               [[#include <time.h>]])
55
56 PKG_PROG_PKG_CONFIG()
57 PKG_CHECK_MODULES(MTDEV, [mtdev >= 1.1.0])
58 PKG_CHECK_MODULES(LIBUDEV, [libudev])
59 PKG_CHECK_MODULES(LIBEVDEV, [libevdev >= 0.4])
60 AC_CHECK_LIB([m], [atan2])
61 AC_CHECK_LIB([rt], [clock_gettime])
62
63 if test "x$GCC" = "xyes"; then
64         GCC_CXXFLAGS="-Wall -Wextra -Wno-unused-parameter -g -fvisibility=hidden"
65         GCC_CFLAGS="$GCC_CXXFLAGS -Wmissing-prototypes -Wstrict-prototypes"
66 fi
67 AC_SUBST(GCC_CFLAGS)
68 AC_SUBST(GCC_CXXFLAGS)
69
70 AC_PATH_PROG(DOXYGEN, [doxygen])
71 if test "x$DOXYGEN" = "x"; then
72         AC_MSG_WARN([doxygen not found - required for documentation])
73         have_doxygen="no"
74 else
75         have_doxygen="yes"
76 fi
77 AM_CONDITIONAL([HAVE_DOXYGEN], [test "x$have_doxygen" = "xyes"])
78
79 AC_ARG_ENABLE(event-gui,
80               AS_HELP_STRING([--enable-event-gui], [Build the GUI event viewer (default=auto)]),
81               [build_eventgui="$enableval"],
82               [build_eventgui="auto"])
83 PKG_CHECK_EXISTS([cairo glib-2.0 gtk+-3.0], [HAVE_GUILIBS="yes"], [HAVE_GUILIBS="no"])
84
85 if test "x$build_eventgui" = "xauto"; then
86         build_eventgui="$HAVE_GUILIBS"
87 fi
88 if test "x$build_eventgui" = "xyes"; then
89         PKG_CHECK_MODULES(CAIRO, [cairo])
90         PKG_CHECK_MODULES(GTK, [glib-2.0 gtk+-3.0])
91 fi
92 AM_CONDITIONAL(BUILD_EVENTGUI, [test "x$build_eventgui" = "xyes"])
93
94 AC_ARG_ENABLE(tests,
95               AS_HELP_STRING([--enable-tests], [Build the tests (default=auto)]),
96               [build_tests="$enableval"],
97               [build_tests="auto"])
98
99 PKG_CHECK_MODULES(CHECK, [check >= 0.9.9], [HAVE_CHECK="yes"], [HAVE_CHECK="no"])
100
101 if test "x$build_tests" = "xauto"; then
102         build_tests="$HAVE_CHECK"
103 fi
104 if test "x$build_tests" = "xyes"; then
105         if test "x$HAVE_CHECK" = "xno"; then
106                 AC_MSG_ERROR([Cannot build tests, check is missing])
107         fi
108
109         AC_PATH_PROG(VALGRIND, [valgrind])
110 fi
111
112 AM_CONDITIONAL(HAVE_VALGRIND, [test "x$VALGRIND" != "x"])
113 AM_CONDITIONAL(BUILD_TESTS, [test "x$build_tests" = "xyes"])
114
115 AC_CONFIG_FILES([Makefile
116                  doc/Makefile
117                  doc/libinput.doxygen
118                  src/Makefile
119                  src/libinput.pc
120                  src/libinput-version.h
121                  test/Makefile
122                  tools/Makefile])
123 AC_OUTPUT
124
125 AC_MSG_RESULT([
126         Prefix                  ${prefix}
127
128         Build documentation     ${have_doxygen}
129         Build tests             ${build_tests}
130         Tests use valgrind      ${VALGRIND}
131         Build GUI event tool    ${build_eventgui}
132         ])