724fe0d36129c9605b89b6c70e7b962d6a9b08c1
[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.60])
25 AC_INIT([libxkbcommon], [0.1.0],
26     [https://bugs.freedesktop.org/enter_bug.cgi?product=xorg])
27 AC_CONFIG_SRCDIR([Makefile.am])
28 AC_CONFIG_HEADERS([src/config.h])
29 AC_CONFIG_MACRO_DIR([m4])
30
31 # Initialize Automake
32 AM_INIT_AUTOMAKE([foreign dist-bzip2])
33 AM_MAINTAINER_MODE
34
35 # Initialize libtool
36 AC_PROG_LIBTOOL
37
38 # Require xorg-macros minimum of 1.8 for AM_SILENT_RULES
39 m4_ifndef([XORG_MACROS_VERSION],
40           [m4_fatal([must install xorg-macros 1.8 or later before running autoconf/autogen])])
41 XORG_MACROS_VERSION(1.8)
42 XORG_DEFAULT_OPTIONS
43 XORG_CHECK_MALLOC_ZERO
44
45 # Check for programs
46 AC_PROG_LEX
47 AC_PROG_YACC
48 AC_PATH_PROG([YACC_INST], $YACC)
49 if test ! -f "src/xkbcomp/xkbparse.c"; then
50    if test -z "$YACC_INST"; then
51       AC_MSG_ERROR([yacc not found - unable to compile src/xkbcomp/xkbparse.y])
52    fi
53 fi
54
55 # Checks for library functions.
56 AC_CHECK_FUNCS([strcasecmp strncasecmp])
57 if test "x$ac_cv_func_strcasecmp" = xno || \
58    test "x$ac_cv_func_strncasecmp" = xno; then
59     AC_MSG_ERROR([C library does not support strcasecmp/strncasecmp])
60 fi
61
62 # Build native compiler needed for makekeys
63 AC_ARG_VAR([CC_FOR_BUILD], [Build native C compiler program])
64 if test "x$CC_FOR_BUILD" = x; then
65     if test "$cross_compiling" != no; then
66         AC_PATH_PROGS([CC_FOR_BUILD], [gcc cc], [cc])
67     else
68         CC_FOR_BUILD="$CC"
69     fi
70 fi
71
72 if  test "x$GCC" = xyes ; then
73   CFLAGS="$CFLAGS -fvisibility=hidden"
74 fi
75
76 # Obtain protocols headers include directives
77 PKG_CHECK_MODULES([X11], [xproto kbproto >= 1.0.4])
78
79 # Obtain the path to the X Window System Core Protocol
80 AC_MSG_CHECKING([for X11 includedir])
81 includex11dir="`$PKG_CONFIG --variable=includex11dir xproto`"
82 AC_MSG_RESULT([$includex11dir])
83
84 AC_MSG_CHECKING([keysym definitions])
85 KEYSYMDEFDIR=`$PKG_CONFIG --variable=includedir xproto`/X11
86 FILES="keysymdef.h XF86keysym.h Sunkeysym.h DECkeysym.h HPkeysym.h"
87 for i in $FILES; do
88     if test -f "$KEYSYMDEFDIR/$i"; then
89             KEYSYMDEFS="$KEYSYMDEFS $KEYSYMDEFDIR/$i"
90     elif test "x$i" = "xkeysymdef.h"; then
91             AC_MSG_ERROR([Cannot find keysymdef.h])
92     fi
93 done
94 AC_MSG_RESULT([$KEYSYMDEFS])
95 AC_SUBST(KEYSYMDEFS)
96
97 # Define a configuration option for the XKB config root
98 xkb_base=`$PKG_CONFIG --variable=xkb_base xkeyboard-config`
99 AC_ARG_WITH([xkb_config_root],
100     [AS_HELP_STRING([--with-xkb-config-root=<paths>],
101         [Set default XKB config root (default: ${datadir}/X11/xkb)])],
102     [XKBCONFIGROOT="$withval"],
103     [XKBCONFIGROOT="$xkb_base"])
104 AC_SUBST([XKBCONFIGROOT])
105
106 AC_CONFIG_FILES([
107         Makefile
108         xkbcommon.pc
109         include/Makefile
110         makekeys/Makefile
111         src/Makefile
112         src/xkbcomp/Makefile
113         test/Makefile])
114 AC_OUTPUT