Check for GNU ld and use the flags depending on the outcome
[platform/upstream/libevdev.git] / configure.ac
1 AC_PREREQ([2.64])
2
3 AC_INIT([libevdev],
4         [0.3],
5         [],
6         [libevdev],
7         [])
8
9 AC_CONFIG_HEADERS([config.h])
10 AC_CONFIG_MACRO_DIR([m4])
11 AC_USE_SYSTEM_EXTENSIONS
12
13 AM_INIT_AUTOMAKE([1.11 foreign no-dist-gzip dist-xz])
14
15 # Before making a release, the LIBEVDEV_LT_VERSION string should be
16 # modified.
17 # The string is of the form C:R:A.
18 # - If interfaces have been changed or added, but binary compatibility has
19 #   been preserved, change to C+1:0:A+1
20 # - If binary compatibility has been broken (eg removed or changed interfaces)
21 #   change to C+1:0:0
22 # - If the interface is the same as the previous version, change to C:R+1:A
23 LIBEVDEV_LT_VERSION=1:0:0
24 AC_SUBST(LIBEVDEV_LT_VERSION)
25
26
27 AM_SILENT_RULES([yes])
28
29 # Check for programs
30 AC_PROG_CC
31
32 # Initialize libtool
33 LT_PREREQ([2.2])
34 LT_INIT
35 LT_PATH_LD
36 if test "x$lt_cv_prog_gnu_ld" = "xyes"; then
37         GNU_LD_FLAGS="-Wl,--as-needed -Wl,--gc-sections -Wl,-z,relro -Wl,-z,now"
38         AC_SUBST(GNU_LD_FLAGS)
39 fi
40
41 PKG_PROG_PKG_CONFIG()
42 PKG_CHECK_MODULES(CHECK, [check], [HAVE_CHECK="yes"], [HAVE_CHECK="no"])
43 if test "x$HAVE_CHECK" != "xyes"; then
44        AC_MSG_WARN([check not found - skipping building unit tests])
45 fi
46 AM_CONDITIONAL(BUILD_TESTS, [test "x$HAVE_CHECK" = "xyes"])
47
48
49 if test "x$GCC" = "xyes"; then
50         GCC_CFLAGS="-Wall -Wextra -Wno-unused-parameter -Wstrict-prototypes -Wmissing-prototypes -fvisibility=hidden -pipe -fno-common -fno-strict-aliasing -ffunction-sections -fdata-sections -fstack-protector -fno-strict-aliasing -fdiagnostics-show-option -fno-common"
51 fi
52 AC_SUBST(GCC_CFLAGS)
53
54 AC_PATH_PROG(DOXYGEN, [doxygen])
55 if test "x$DOXYGEN" = "x"; then
56         AC_MSG_WARN([doxygen not found - required for documentation])
57 fi
58 AM_CONDITIONAL([HAVE_DOXYGEN], [test -n "$DOXYGEN"])
59
60 AC_MSG_CHECKING([whether to build with gcov])
61 AC_ARG_ENABLE([gcov],
62               [AS_HELP_STRING([--enable-gcov],
63                               [Whether to enable coverage testing (default:enabled)])]
64               [],
65               [enable_gcov=yes],
66               )
67 AS_IF([test "x$enable_gcov" != "xno"],
68       [
69        GCOV_CFLAGS="-fprofile-arcs -ftest-coverage"
70        GCOV_LDFLAGS="-fprofile-arcs -ftest-coverage"
71        enable_gcov=yes
72        ],
73 )
74
75 AM_CONDITIONAL([GCOV_ENABLED], [test "x$enable_gcov" != "xno"])
76 AC_SUBST([GCOV_CFLAGS])
77 AC_SUBST([GCOV_LDFLAGS])
78 AC_MSG_RESULT([$enable_gcov])
79
80 AC_CONFIG_FILES([Makefile
81                  libevdev/Makefile
82                  doc/Makefile
83                  doc/libevdev.doxygen
84                  tools/Makefile
85                  test/Makefile
86                  libevdev.pc])
87 AC_OUTPUT