1# Copyright © 2013 Red Hat, Inc.
2#
3# Permission to use, copy, modify, distribute, and sell this software and its
4# documentation for any purpose is hereby granted without fee, provided that
5# the above copyright notice appear in all copies and that both that copyright
6# notice and this permission notice appear in supporting documentation, and
7# that the name of the copyright holders not be used in advertising or
8# publicity pertaining to distribution of the software without specific,
9# written prior permission.  The copyright holders make no representations
10# about the suitability of this software for any purpose.  It is provided "as
11# is" without express or implied warranty.
12#
13# THE COPYRIGHT HOLDERS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
14# INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
15# EVENT SHALL THE COPYRIGHT HOLDERS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
16# CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
17# DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE
19# OF THIS SOFTWARE.
20
21AC_PREREQ([2.62])
22
23AC_INIT([libevdev],
24        [1.5.9],
25        [https://bugs.freedesktop.org/enter_bug.cgi?product=libevdev],
26        [libevdev],
27        [http://freedesktop.org/wiki/Software/libevdev/])
28
29AC_CONFIG_SRCDIR([libevdev/libevdev.c])
30AC_CONFIG_HEADERS([config.h])
31AC_CONFIG_MACRO_DIR([m4])
32AC_CONFIG_AUX_DIR([build-aux])
33AC_USE_SYSTEM_EXTENSIONS
34
35AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz subdir-objects])
36
37# Before making a release, the LIBEVDEV_LT_VERSION string should be
38# modified.
39# The string is of the form C:R:A.
40# - If interfaces have been changed or added, but binary compatibility has
41#   been preserved, change to C+1:0:A+1
42# - If binary compatibility has been broken (eg removed or changed interfaces)
43#   change to C+1:0:0
44# - If the interface is the same as the previous version, change to C:R+1:A
45LIBEVDEV_LT_VERSION=3:21:1
46AC_SUBST(LIBEVDEV_LT_VERSION)
47
48
49AM_SILENT_RULES([yes])
50
51# Check for programs
52AC_PROG_CC_C99
53
54# Initialize libtool
55LT_PREREQ([2.2])
56LT_INIT
57LT_PATH_LD
58
59with_ldflags=""
60if test "x$lt_cv_prog_gnu_ld" = "xyes"; then
61	CC_CHECK_FLAGS_APPEND([with_ldflags], [LDFLAGS], [\
62				-Wl,--as-needed \
63				-Wl,--gc-sections \
64				-Wl,-z,relro \
65				-Wl,-z,now])
66fi
67AC_SUBST([GNU_LD_FLAGS], $with_ldflags)
68
69AC_CHECK_LIB([m], [round])
70
71PKG_PROG_PKG_CONFIG()
72PKG_CHECK_MODULES(CHECK, [check >= 0.9.9], [HAVE_CHECK="yes"], [HAVE_CHECK="no"])
73if test "x$HAVE_CHECK" = "xyes"; then
74	AC_PATH_PROG(VALGRIND, [valgrind])
75else
76	AC_MSG_WARN([check not found - skipping building unit tests])
77fi
78AM_CONDITIONAL(HAVE_VALGRIND, [test "x$VALGRIND" != "x"])
79AM_CONDITIONAL(ENABLE_RUNTIME_TESTS, [test "x$HAVE_CHECK" = "xyes"])
80AM_CONDITIONAL(ENABLE_STATIC_LINK_TEST, [test "x$enable_static" = "xyes"])
81
82AC_ARG_ENABLE([test-run],
83	       AS_HELP_STRING([--enable-test-run], [For internal use only]),
84	       [run_tests="$enableval"], [run_tests="yes"])
85AM_CONDITIONAL(RUN_TESTS, [test "x$run_tests" = "xyes"])
86
87with_cflags=""
88if test "x$GCC" = "xyes"; then
89	CC_CHECK_FLAGS_APPEND([with_cflags], [CFLAGS], [\
90				-Wall \
91				-Wextra \
92				-Wno-unused-parameter \
93				-Wstrict-prototypes \
94				-Wmissing-prototypes \
95				-fvisibility=hidden \
96				-pipe \
97				-fno-strict-aliasing \
98				-ffunction-sections \
99				-fdata-sections \
100				-fno-strict-aliasing \
101				-fdiagnostics-show-option \
102				-fno-common])
103fi
104AC_SUBST([GCC_CFLAGS], $with_cflags)
105
106AC_PATH_PROG(DOXYGEN, [doxygen])
107if test "x$DOXYGEN" = "x"; then
108	AC_MSG_WARN([doxygen not found - required for documentation])
109	have_doxygen="no"
110else
111	have_doxygen="yes"
112fi
113AM_CONDITIONAL([HAVE_DOXYGEN], [test "x$have_doxygen" = "xyes"])
114
115AC_MSG_CHECKING([whether to build with gcov])
116AC_ARG_ENABLE([gcov],
117	      [AS_HELP_STRING([--enable-gcov],
118			      [Whether to enable coverage testing (default:disabled)])],
119	      [],
120	      [enable_gcov=no],
121	      )
122AS_IF([test "x$enable_gcov" != "xno"],
123      [
124       GCOV_CFLAGS="-fprofile-arcs -ftest-coverage"
125       GCOV_LDFLAGS="-fprofile-arcs -ftest-coverage"
126       enable_gcov=yes
127       ],
128)
129AM_CONDITIONAL([GCOV_ENABLED], [test "x$enable_gcov" != "xno"])
130AC_SUBST([GCOV_CFLAGS])
131AC_SUBST([GCOV_LDFLAGS])
132AC_MSG_RESULT([$enable_gcov])
133
134AM_PATH_PYTHON([2.6])
135AC_PATH_PROG(CAT, [cat])
136
137# nm to check for leaking symbols in the static library
138AC_PATH_PROG(NM, [nm])
139AM_CONDITIONAL(HAVE_NM, [test "x$NM" != "x"])
140if test "x$enable_static" = "xno"; then
141	static_symbol_leaks_test="no - static build disabled"
142else
143	if test "x$NM" = "x"; then
144		AC_MSG_WARN([nm not found - skipping symbol leak test])
145		have_nm="no"
146		static_symbol_leaks_test="no - nm not found"
147	else
148		have_nm="yes"
149		static_symbol_leaks_test="yes"
150	fi
151fi
152
153AM_CONDITIONAL(ENABLE_STATIC_SYMBOL_LEAKS_TEST, [test "x$static_symbol_leaks_test" = "xyes"])
154
155AC_CONFIG_FILES([Makefile
156		 libevdev/Makefile
157		 doc/Makefile
158		 doc/libevdev.doxygen
159		 doc/libevdev.man
160		 tools/Makefile
161		 test/Makefile
162		 libevdev.pc])
163AC_OUTPUT
164
165AC_MSG_RESULT([
166	       Prefix				${prefix}
167	       Libdir				${libdir}
168
169	       Build documentation		${have_doxygen}
170	       Enable unit-tests		${HAVE_CHECK}
171	       Run unit-tests			${run_tests}
172	       Enable profiling			${enable_gcov}
173	       Static library symbol check	${static_symbol_leaks_test}
174	       ])
175