keymap: share LevelsSameSyms()
[platform/upstream/libxkbcommon.git] / configure.ac
1 dnl  Copyright © 2008 Dan Nicholson
2 dnl
3 dnl  Permission to use, copy, modify, distribute, and sell this software and its
4 dnl  documentation for any purpose is hereby granted without fee, provided that
5 dnl  the above copyright notice appear in all copies and that both that
6 dnl  copyright notice and this permission notice appear in supporting
7 dnl  documentation, and that the name of Keith Packard not be used in
8 dnl  advertising or publicity pertaining to distribution of the software without
9 dnl  specific, written prior permission.  Keith Packard makes no
10 dnl  representations about the suitability of this software for any purpose.  It
11 dnl  is provided "as is" without express or implied warranty.
12 dnl
13 dnl  DAN NICHOLSON DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
14 dnl  INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
15 dnl  EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
16 dnl  CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
17 dnl  DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
18 dnl  TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
19 dnl  PERFORMANCE OF THIS SOFTWARE.
20 dnl
21 dnl Process this file with autoconf to create configure.
22
23 # Initialize Autoconf
24 AC_PREREQ([2.62])
25 AC_INIT([libxkbcommon], [0.5.0],
26         [https://bugs.freedesktop.org/enter_bug.cgi?product=libxkbcommon],
27         [libxkbcommon], [http://xkbcommon.org])
28 AC_CONFIG_SRCDIR([Makefile.am])
29 AC_CONFIG_HEADERS([src/config.h])
30 AC_CONFIG_MACRO_DIR([m4])
31 AC_CONFIG_AUX_DIR([build-aux])
32
33 # Initialize Automake
34 AM_INIT_AUTOMAKE([foreign dist-xz no-dist-gzip subdir-objects color-tests parallel-tests check-news])
35 AM_MAINTAINER_MODE([enable])
36
37 # Get _GNU_SOURCE and friends
38 AC_USE_SYSTEM_EXTENSIONS
39
40 # Initialize libtool
41 LT_INIT
42
43 # Add xorg-macros stuff
44 m4_ifndef([XORG_MACROS_VERSION],
45           [m4_fatal([must install xorg-macros 1.16 or later before running autoconf/autogen])])
46 XORG_MACROS_VERSION(1.16)
47 XORG_DEFAULT_OPTIONS
48 XORG_MEMORY_CHECK_FLAGS
49 XORG_ENABLE_DOCS
50 XORG_WITH_DOXYGEN
51
52 # Needed in older Automakes for subdir-objects
53 AM_PROG_CC_C_O
54
55 # Check for compiler features
56 AC_C_INLINE
57
58 # Check for programs
59 AC_PROG_MKDIR_P
60 PKG_PROG_PKG_CONFIG
61
62 # Note: we use some yacc extensions, which work with either GNU bison
63 # (preferred) or byacc. Other yacc's may or may not work.
64 AC_PROG_YACC
65 AC_PATH_PROG([YACC_INST], [$YACC])
66 AS_IF([test ! -f "src/xkbcomp/parser.c" -a "x$YACC_INST" = x], [
67     AC_MSG_ERROR([yacc not found - unable to compile src/xkbcomp/parser.y])
68 ])
69
70 # Checks for library functions.
71 AC_CHECK_FUNCS([strcasecmp strncasecmp])
72 AS_IF([test "x$ac_cv_func_strcasecmp" = xno -o \
73             "x$ac_cv_func_strncasecmp" = xno], [
74     AC_MSG_ERROR([C library does not support strcasecmp/strncasecmp])
75 ])
76
77 AC_CHECK_FUNCS([eaccess euidaccess mmap])
78
79 AC_CHECK_FUNCS([secure_getenv __secure_getenv])
80 AS_IF([test "x$ac_cv_func_secure_getenv" = xno -a \
81             "x$ac_cv_func___secure_getenv" = xno], [
82     AC_MSG_WARN([C library does not support secure_getenv, using getenv instead])
83 ])
84
85 AX_GCC_BUILTIN(__builtin_expect)
86
87 # Some tests use Linux-specific headers
88 AC_CHECK_HEADER([linux/input.h])
89 AM_CONDITIONAL(BUILD_LINUX_TESTS, [test "x$ac_cv_header_linux_input_h" = xyes])
90
91 XORG_TESTSET_CFLAG([BASE_CFLAGS], [-fvisibility=hidden])
92 XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wextra -Wno-unused-parameter -Wno-missing-field-initializers])
93 XORG_TESTSET_CFLAG([BASE_CFLAGS], [-Wdocumentation])
94
95 # OpenBSD does not have DT_NEEDED entries for libc by design
96 # so when these flags are passed to ld via libtool the checks will fail
97 case "$host_os" in
98 openbsd*)
99     ;;
100 *)
101     XORG_CHECK_LINKER_FLAGS([-Wl,--no-undefined], [have_no_undefined=yes]) ;;
102 esac
103 AM_CONDITIONAL([HAVE_NO_UNDEFINED], [test "x$have_no_undefined" = xyes])
104
105 XORG_CHECK_LINKER_FLAGS([-Wl,--version-script="$srcdir/xkbcommon.map"], [have_version_script=yes])
106 AM_CONDITIONAL([HAVE_VERSION_SCRIPT], [test "x$have_version_script" = xyes])
107
108 AC_CHECK_LIB(rt, clock_gettime,
109     [AC_SUBST(RT_LIBS, "-lrt")],
110     [AC_SUBST(RT_LIBS, "")],
111     [-lrt])
112 AC_CHECK_FUNCS([clock_gettime])
113
114 # Define a configuration option for the XKB config root
115 xkb_base=`$PKG_CONFIG --variable=xkb_base xkeyboard-config`
116 AS_IF([test "x$xkb_base" = x], [
117     xkb_base="$datadir/X11/xkb"
118 ])
119 AC_ARG_WITH([xkb_config_root],
120     [AS_HELP_STRING([--with-xkb-config-root=<path>],
121         [Set default XKB config root (default: xkeyboard-config install path)])],
122     [XKBCONFIGROOT="$withval"],
123     [XKBCONFIGROOT="$xkb_base"])
124 AC_SUBST([XKBCONFIGROOT])
125
126 # Define a configuration option for the X locale directory for compose
127 AC_ARG_WITH([x_locale_root],
128     [AS_HELP_STRING([--with-x-locale-root=<path>],
129         [Set X locale root (default: $datadir/X11/locale)])],
130     [XLOCALEDIR="$withval"],
131     [XLOCALEDIR="$datadir/X11/locale"])
132 AC_SUBST([XLOCALEDIR])
133
134 AC_ARG_WITH([default_rules],
135     [AS_HELP_STRING([--with-default-rules=<path>],
136         [Default XKB ruleset (default: evdev)])],
137     [DEFAULT_XKB_RULES="$withval"],
138     [DEFAULT_XKB_RULES="evdev"])
139 AC_DEFINE_UNQUOTED([DEFAULT_XKB_RULES], ["$DEFAULT_XKB_RULES"],
140                    [Default XKB ruleset])
141
142 AC_ARG_WITH([default_model],
143     [AS_HELP_STRING([--with-default-model=<path>],
144         [Default XKB model (default: pc105)])],
145     [DEFAULT_XKB_MODEL="$withval"],
146     [DEFAULT_XKB_MODEL="pc105"])
147 AC_DEFINE_UNQUOTED([DEFAULT_XKB_MODEL], ["$DEFAULT_XKB_MODEL"],
148                    [Default XKB model])
149
150 AC_ARG_WITH([default_layout],
151     [AS_HELP_STRING([--with-default-layout=<path>],
152         [Default XKB layout (default: us)])],
153     [DEFAULT_XKB_LAYOUT="$withval"],
154     [DEFAULT_XKB_LAYOUT="us"])
155 AC_DEFINE_UNQUOTED([DEFAULT_XKB_LAYOUT], ["$DEFAULT_XKB_LAYOUT"],
156                    [Default XKB layout])
157
158 AC_ARG_WITH([default_variant],
159     [AS_HELP_STRING([--with-default-variant=<path>],
160         [Default XKB variant (default: (none))])],
161     [DEFAULT_XKB_VARIANT="$withval"],
162     [DEFAULT_XKB_VARIANT=])
163 AS_IF([test "x$DEFAULT_XKB_VARIANT" != x], [
164     AC_DEFINE_UNQUOTED([DEFAULT_XKB_VARIANT], ["$DEFAULT_XKB_VARIANT"],
165                        [Default XKB variant])
166 ])
167
168 AC_ARG_WITH([default_options],
169     [AS_HELP_STRING([--with-default-options=<path>],
170         [Default XKB options (default: (none))])],
171     [DEFAULT_XKB_OPTIONS="$withval"],
172     [DEFAULT_XKB_OPTIONS=])
173 AS_IF([test "x$DEFAULT_XKB_OPTIONS" != x], [
174     AC_DEFINE_UNQUOTED([DEFAULT_XKB_OPTIONS], ["$DEFAULT_XKB_OPTIONS"],
175                        [Default XKB options])
176 ])
177
178 AC_ARG_ENABLE([x11],
179     [AS_HELP_STRING([--disable-x11],
180         [Disable support for creating keymaps with the X11 protocol (default: enabled)])],
181     [], [enable_x11=yes])
182 AS_IF([test "x$enable_x11" = xyes], [
183     PKG_CHECK_MODULES([XCB_XKB], [xcb xcb-xkb >= 1.10], [],
184         [AC_MSG_ERROR([xkbcommon-x11 requires xcb-xkb >= 1.10 which was not found. \
185 You can disable X11 support with --disable-x11.])])
186 ], [enable_x11=no])
187 AM_CONDITIONAL([ENABLE_X11], [test "x$enable_x11" = xyes])
188
189 AC_CONFIG_FILES([
190     Makefile
191     xkbcommon-uninstalled.pc
192     xkbcommon.pc
193     xkbcommon-x11.pc
194     xkbcommon-x11-uninstalled.pc
195     doc/Doxyfile
196 ])
197 AC_OUTPUT
198
199 AC_MSG_RESULT([
200         $PACKAGE_NAME $VERSION
201
202         libxkbcommon:            yes
203         libxkbcommon-x11:        ${enable_x11}
204         documentation:           ${build_docs}
205
206         default XKB rules:       ${DEFAULT_XKB_RULES}
207         default XKB model:       ${DEFAULT_XKB_MODEL}
208         default XKB layout:      ${DEFAULT_XKB_LAYOUT}
209         default XKB variant:     ${DEFAULT_XKB_VARIANT}
210         default XKB options:     ${DEFAULT_XKB_OPTIONS}
211
212         prefix:                  ${prefix}
213         includedir:              ${includedir}
214         lib dir:                 ${libdir}
215         datarootdir:             ${datarootdir}
216         XKB config root:         ${XKBCONFIGROOT}
217         X11 locale root:         ${XLOCALEDIR}
218 ])