Fix make rpm errors
[platform/upstream/ibus.git] / configure.ac
1 # vim:set et ts=4:
2 #
3 # ibus - The Input Bus
4 #
5 # Copyright (c) 2007-2010 Peng Huang <shawn.p.huang@gmail.com>
6 # Copyright (c) 2007-2010 Red Hat, Inc.
7 #
8 # This library is free software; you can redistribute it and/or
9 # modify it under the terms of the GNU Lesser General Public
10 # License as published by the Free Software Foundation; either
11 # version 2 of the License, or (at your option) any later version.
12 #
13 # This library is distributed in the hope that it will be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU Lesser General Public License for more details.
17 #
18 # You should have received a copy of the GNU Lesser General Public
19 # License along with this program; if not, write to the
20 # Free Software Foundation, Inc., 59 Temple Place, Suite 330,
21 # Boston, MA  02111-1307  USA
22 AC_PREFEQ([2.62])
23
24 AC_CONFIG_HEADERS([config.h])
25 AC_CONFIG_MACRO_DIR([m4])
26
27
28 # if not 1, append datestamp to the version number.
29 m4_define([ibus_released], [0])
30 m4_define([ibus_major_version], [1])
31 m4_define([ibus_minor_version], [3])
32 m4_define([ibus_micro_version], [99])
33 m4_define(ibus_maybe_datestamp,
34     m4_esyscmd([if test x]ibus_released[ != x1; then date +.%Y%m%d | tr -d '\n\r'; fi]))
35 m4_define([ibus_version],
36     ibus_major_version.ibus_minor_version.ibus_micro_version[]ibus_maybe_datestamp)
37 # This is the X.Y used in -libus-X.Y
38 m4_define([ibus_api_version], [1.0])
39
40
41 # Required versions of other packages
42 m4_define([glib_required_version], [2.26.0])
43
44
45 AC_INIT([ibus], [ibus_version],
46         [http://code.google.com/p/ibus/issues/entry],
47         [ibus])
48
49 # Init automake
50 AM_INIT_AUTOMAKE([1.10])
51 AM_MAINTAINER_MODE([enable])
52 AC_GNU_SOURCE
53
54 # Support silent build
55 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
56
57 # Define sustituted variables:
58 IBUS_MAJOR_VERSION=ibus_major_version
59 IBUS_MINOR_VERSION=ibus_minor_version
60 IBUS_MICRO_VERSION=ibus_micro_version
61 IBUS_API_VERSION=ibus_api_version
62 AC_SUBST(IBUS_MAJOR_VERSION)
63 AC_SUBST(IBUS_MINOR_VERSION)
64 AC_SUBST(IBUS_MICRO_VERSION)
65 AC_SUBST(IBUS_API_VERSION)
66
67 # Check for programs
68 AC_PROG_CC
69 AM_PROG_CC_C_O
70 AC_PROG_CC_STDC
71 AC_PROG_INSTALL
72 AC_PROG_CXX
73
74 # define PACKAGE_VERSION_* variables
75 AM_DISABLE_STATIC
76 AC_ISC_POSIX
77 AC_HEADER_STDC
78 AM_PROG_LIBTOOL
79 IT_PROG_INTLTOOL([0.35.0])
80
81 # For dislpay Date
82 m4_define(ibus_datedisplay,
83     m4_esyscmd(date '+%a %b %d %Y' | tr -d '\n\r'))
84 DATE_DISPLAY="ibus_datedisplay"
85 AC_SUBST(DATE_DISPLAY)
86
87 # If only source code changed, lt_revision + 1
88 # If any interface added, lt_age + 1
89 # If any interfaces changed or removed, lt_current + 1, lt_revision = 0, lt_age = 0
90 m4_define([lt_current], [0])
91 m4_define([lt_revision], [0])
92 m4_define([lt_age], [0])
93 LT_VERSION_INFO="lt_current:lt_revision:lt_age"
94 AC_SUBST(LT_VERSION_INFO)
95
96 # check funcs
97 AC_CHECK_FUNCS(daemon)
98
99 # check glib2
100 AM_PATH_GLIB_2_0
101 PKG_CHECK_MODULES(GLIB2, [
102     glib-2.0 >= glib_required_version
103 ])
104 PKG_CHECK_MODULES(GOBJECT2, [
105     gobject-2.0 >= glib_required_version
106 ])
107 PKG_CHECK_MODULES(GIO2, [
108     gio-2.0 >= glib_required_version
109 ])
110 PKG_CHECK_MODULES(GTHREAD2, [
111     gthread-2.0 >= glib_required_version
112 ])
113
114 AC_ARG_ENABLE(gtk2,
115     AS_HELP_STRING([--disable-gtk2],
116                    [Do not build gtk2 im module]),
117     [enable_gtk2=$enableval],
118     [enable_gtk2=yes]
119 )
120 AM_CONDITIONAL([ENABLE_GTK2], [test x"$enable_gtk2" = x"yes"])
121
122 AC_ARG_ENABLE(gtk3,
123     AS_HELP_STRING([--enable-gtk3],
124                    [Build gtk3 im module]),
125     [enable_gtk3=$enableval],
126     [enable_gtk3=no]
127 )
128 AM_CONDITIONAL([ENABLE_GTK3], [test x"$enable_gtk3" = x"yes"])
129
130 AC_ARG_ENABLE(xim,
131     AS_HELP_STRING([--disable-xim],
132                    [Do not build xim server]),
133     [enable_xim=$enableval],
134     [enable_xim=yes]
135 )
136 AM_CONDITIONAL([ENABLE_XIM], [test x"$enable_xim" = x"yes"])
137
138 AC_ARG_ENABLE(vala,
139     AS_HELP_STRING([--disable-vala],
140                    [Do not build ibus vala binding]),
141     [enable_vala=$enableval],
142     [enable_vala=yes]
143 )
144 AM_CONDITIONAL([ENABLE_VALA], [test x"$enable_vala" = x"yes"])
145 if test x"$enable_vala" != x"yes"; then
146     enable_vala="no (disabled, use --enable-vala to enable)"
147 fi
148
149 if test x"$enable_gtk2" = x"yes" -o x"$enable_xim" = x"yes" ; then
150     # check for gtk2
151     PKG_CHECK_MODULES(GTK2, [
152         gtk+-2.0
153     ])
154 fi
155
156 if test x"$enable_gtk2" = x"yes"; then
157     # check for gdk2
158     gtk2_binary_version=`$PKG_CONFIG --variable=gtk_binary_version gtk+-2.0`
159     GTK2_IM_MODULEDIR="$libdir"/gtk-2.0/$gtk2_binary_version/immodules
160
161     PKG_CHECK_MODULES(GDK2, [
162         gdk-2.0
163     ])
164 else
165     enable_gtk2="no (disabled, use --enable-gtk2 to enable)"
166 fi
167
168 if test x"$enable_gtk3" = x"yes"; then
169     # check for gtk3, gdk3
170     PKG_CHECK_MODULES(GTK3, [
171         gtk+-3.0
172     ])
173
174     gtk3_binary_version=`$PKG_CONFIG --variable=gtk_binary_version gtk+-3.0`
175     GTK3_IM_MODULEDIR="$libdir"/gtk-3.0/$gtk3_binary_version/immodules
176
177     PKG_CHECK_MODULES(GDK3, [
178         gdk-3.0
179     ])
180 else
181     enable_gtk3="no (disabled, use --enable-gtk3 to enable)"
182 fi
183
184 if test x"$enable_xim" = x"yes"; then
185     # Check for x11
186     PKG_CHECK_MODULES(X11, [
187         x11
188     ])
189     AC_CHECK_HEADERS([X11/XKBlib.h])
190 else
191     enable_xim="no (disabled, use --enable-xim to enable)"
192 fi
193
194 # GObject introspection
195 GOBJECT_INTROSPECTION_CHECK([0.6.8])
196
197 IBUS_GIR_SCANNERFLAGS=
198 if test x"$found_introspection" = x"yes" ; then
199     IBUS_GIR_SCANNERFLAGS="--identifier-prefix=IBus --symbol-prefix=ibus"
200     PKG_CHECK_EXISTS([gobject-introspection-1.0 >= 0.9.6],
201                      [gir_symbol_prefix=yes],
202                      [gir_symbol_prefix=no])
203     if test x"$gir_symbol_prefix" = x"no" ; then
204         IBUS_GIR_SCANNERFLAGS="--strip-prefix=IBus"
205     fi
206 fi
207 AC_SUBST(IBUS_GIR_SCANNERFLAGS)
208
209 # check for gtk-doc
210 GTK_DOC_CHECK(1.9)
211 if test x"$enable_gtk_doc" = x"no"; then
212     enable_gtk_doc="no (disabled, use --enable-gtk-doc to enable)"
213 fi
214
215 # check for dbus
216 PKG_CHECK_MODULES(DBUS, [
217     dbus-1
218 ])
219
220 AC_ARG_ENABLE(gconf,
221     AS_HELP_STRING([--disable-gconf],
222                    [Do not use GConf code]),
223     [enable_gconf=$enableval],
224     [enable_gconf=yes]
225 )
226 AM_CONDITIONAL([ENABLE_GCONF], [test x"$enable_gconf" = x"yes"])
227
228 if test x"$enable_gconf" = x"yes"; then
229     # check gconf
230     PKG_CHECK_MODULES(GCONF,
231         [gconf-2.0 >= 2.12],
232     )
233
234     AC_PATH_PROG(GCONFTOOL, gconftool-2, no)
235     if test x"$GCONFTOOL" = xno; then
236         AC_MSG_ERROR([gconftool-2 executable not found in your path - should be installed with GConf])
237     fi
238
239     AM_GCONF_SOURCE_2
240     # GCONF_SCHEMAS_INSTALL should be set in macro AM_GCONF_SOURCE_2
241 else
242     AM_CONDITIONAL([GCONF_SCHEMAS_INSTALL], [false])
243     enable_gconf="no (disabled, use --enable-gconf to enable)"
244 fi
245
246 AC_ARG_ENABLE(memconf,
247     AS_HELP_STRING([--enable-memconf],
248                    [Enable configure base on memory]),
249     [enable_memconf=$enableval],
250     [enable_memconf=no]
251 )
252 AM_CONDITIONAL([ENABLE_MEMCONF], [test "x$enable_memconf" = "xyes"])
253
254 AC_ARG_ENABLE(dconf,
255     AS_HELP_STRING([--enable-dconf],
256                    [Enable configure base on dconf]),
257     [enable_dconf=$enableval],
258     [enable_dconf=no]
259 )
260
261 if test x"$enable_dconf" = x"yes"; then
262     # check dconf
263     PKG_CHECK_MODULES(DCONF,
264         [dconf >= 0.7.5], ,
265         enable_dconf=no
266     )
267     # check glib-compile-schemas
268     GLIB_GSETTINGS
269 fi
270 AM_CONDITIONAL([ENABLE_DCONF], [test x"$enable_dconf" = x"yes"])
271
272 # check env
273 AC_PATH_PROG(ENV_IBUS_TEST, env)
274 AC_SUBST(ENV_IBUS_TEST)
275
276 AC_ARG_ENABLE(python,
277     AS_HELP_STRING([--disable-python],
278                    [Do not use Python code]),
279     [enable_python=$enableval],
280     [enable_python=yes]
281 )
282
283 AM_CONDITIONAL([ENABLE_PYTHON], [test x"$enable_python" = x"yes"])
284 AM_CONDITIONAL([ENABLE_DAEMON], [true])
285
286 if test x"$enable_python" = x"yes"; then
287     # check python
288     AM_PATH_PYTHON([2.5])
289     AC_PATH_PROG(PYTHON_CONFIG, python$PYTHON_VERSION-config)
290     if test x"$PYTHON_CONFIG" = x""; then
291         AC_PATH_PROG(PYTHON_CONFIG, python-config)
292     fi
293     if test x"$PYTHON_CONFIG" != x""; then
294         PYTHON_CFLAGS=`$PYTHON_CONFIG --includes`
295         PYTHON_LIBS=`$PYTHON_CONFIG --libs`
296     else
297         PYTHON_CFLAGS=`$PYTHON $srcdir/python-config.py --includes`
298         PYTHON_LIBS=`$PYTHON $srcdir/python-config.py --libs`
299     fi
300     PYTHON_INCLUDES="$PYTHON_CFLAGS"
301     AC_SUBST(PYTHON_CFLAGS)
302     AC_SUBST(PYTHON_INCLUDES)
303     AC_SUBST(PYTHON_LIBS)
304 else
305     enable_python="no (disabled, use --enable-python to enable)"
306 fi
307
308 #
309 # REBUILD = \#
310 # AC_SUBST(REBUILD)
311
312 # define GETTEXT_* variables
313 GETTEXT_PACKAGE=ibus10
314 AC_SUBST(GETTEXT_PACKAGE)
315 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package])
316
317 AM_GLIB_GNU_GETTEXT
318
319 # define gtk2 immodule dir
320 AC_ARG_WITH(gtk2-im-module-dir,
321     AS_HELP_STRING([--with-gtk2-im-module-dir[=DIR]],
322         [Select gtk2 immodule dir]),
323     GTK2_IM_MODULEDIR=$with_gtk2_im_module_dir
324 )
325 AC_SUBST(GTK2_IM_MODULEDIR)
326
327 # define gtk3 immodule dir
328 AC_ARG_WITH(gtk3-im-module-dir,
329     AS_HELP_STRING([--with-gtk3-im-module-dir[=DIR]],
330         [Select gtk3 immodule dir]),
331     GTK3_IM_MODULEDIR=$with_gtk3_im_module_dir
332 )
333 AC_SUBST(GTK3_IM_MODULEDIR)
334
335 if test x"$enable_python" = x"yes"; then
336     # check for dbus-python
337     AC_ARG_ENABLE(dbus-python-check,
338         AS_HELP_STRING([--disable-dbus-python-check],
339             [Do not check dbus-python]),
340         [enable_dbus_python_check=$enableval],
341         [enable_dbus_python_check=yes]
342     )
343     PKG_CHECK_MODULES(DBUS_PYTHON,
344         [dbus-python >= 0.83.0],
345         [IBUS_HAS_DBUS_PYTHON=yes],
346         [IBUS_HAS_DBUS_PYTHON=no]
347     )
348     if test x"$IBUS_HAS_DBUS_PYTHON" != x"yes"; then
349         if test x"$enable_dbus_python_check" != x"no"; then
350             AC_MSG_ERROR([can not find dbus-python >= 0.83.0. Please install or update dbus-python.])
351         else
352             AC_MSG_WARN([can not find dbus-python >= 0.83.0. It is required.])
353         fi
354     fi
355 fi
356
357 # option for always disable snooper applications
358 AC_ARG_ENABLE(key-snooper,
359     AS_HELP_STRING([--disable-key-snooper],
360         [Always disable key snooper in gtk im module]),
361     [enable_key_snooper=$enableval],
362     [enable_key_snooper=yes]
363 )
364 if test x"$enable_key_snooper" = x"yes"; then
365     AC_DEFINE(ENABLE_SNOOPER, TRUE, [Enable key snooper])
366 else
367     AC_DEFINE(ENABLE_SNOOPER, FALSE, [Enable key snooper])
368     enable_key_snooper="no (disabled, use --enable-key-snooper to enable)"
369 fi
370
371 # option for no snooper applications
372 AC_ARG_WITH(no-snooper-apps,
373     AS_HELP_STRING([--with-no-snooper-apps[=regex1,regex2]],
374         [Does not enable keyboard snooper in those applications (like: .*chrome.*,firefox.*)]),
375     NO_SNOOPER_APPS=$with_no_snooper_apps,
376     NO_SNOOPER_APPS=[.*chrome.*,.*chromium.*,firefox.*,Do.*]
377 )
378 AC_DEFINE_UNQUOTED(NO_SNOOPER_APPS, "$NO_SNOOPER_APPS",
379     [Does not enbale keyboard snooper in those applications])
380
381 # GNOME 3 uses the theme's icon
382 AC_ARG_WITH(panel-icon-keyboard,
383     AS_HELP_STRING([--with-panel-icon-keyboard[=icon_name]],
384         [Set the default panel icon (default: "input-keyboard-symbolic")]),
385     [if test x"$with_panel_icon_keyboard" = x"yes" -o \
386              x"$with_panel_icon_keyboard" = x; then
387          with_panel_icon_keyboard="input-keyboard-symbolic"
388      fi
389      if test x"$with_panel_icon_keyboard" = x"legacy"; then
390          with_panel_icon_keyboard="ibus-keyboard"
391      fi
392      IBUS_ICON_KEYBOARD=$with_panel_icon_keyboard
393     ],
394     IBUS_ICON_KEYBOARD="input-keyboard-symbolic"
395 )
396 AC_SUBST(IBUS_ICON_KEYBOARD)
397
398 # option for enable surrounding-text
399 AC_ARG_ENABLE(surrounding-text,
400     AS_HELP_STRING([--enable-surrounding-text],
401         [Enable surrounding-text support]),
402     [enable_surrounding_text=$enableval],
403     [enable_surrounding_text=no]
404 )
405 if test x"$enable_surrounding_text" = x"yes"; then
406     AC_DEFINE(ENABLE_SURROUNDING, TRUE, [Enable surrounding-text support])
407 else
408     enable_surrounding_text="no (disabled, use --enable-surrounding-text to enable)"
409 fi
410
411 # check iso-codes
412 PKG_CHECK_MODULES(ISOCODES, [
413     iso-codes
414 ])
415 ISOCODES_PREFIX=`pkg-config iso-codes --variable=prefix`
416 AC_SUBST(ISOCODES_PREFIX)
417
418 # OUTPUT files
419 AC_CONFIG_FILES([ po/Makefile.in
420 Makefile
421 ibus-1.0.pc
422 ibus.spec
423 xinput-ibus
424 memconf/Makefile
425 memconf/memconf.xml.in
426 client/Makefile
427 client/gtk2/Makefile
428 client/gtk3/Makefile
429 client/x11/Makefile
430 src/Makefile
431 src/ibusversion.h
432 src/tests/Makefile
433 bus/Makefile
434 util/Makefile
435 util/IMdkit/Makefile
436 data/Makefile
437 data/icons/Makefile
438 data/keymaps/Makefile
439 data/dconf/Makefile
440 docs/Makefile
441 docs/reference/Makefile
442 docs/reference/ibus/ibus-docs.sgml
443 docs/reference/ibus/Makefile
444 m4/Makefile
445 ibus/_config.py
446 ibus/Makefile
447 ibus/interface/Makefile
448 ui/Makefile
449 ui/gtk/Makefile
450 ui/gtk/ibus-ui-gtk
451 ui/gtk/gtkpanel.xml.in
452 setup/Makefile
453 setup/ibus-setup
454 gconf/Makefile
455 gconf/gconf.xml.in
456 bindings/Makefile
457 bindings/vala/Makefile
458 dconf/Makefile
459 dconf/dconf.xml.in
460 ])
461
462 AC_OUTPUT
463 AC_MSG_RESULT([
464 Build options:
465   Version                   $VERSION
466   Install prefix            $prefix
467   Build shared libs         $enable_shared
468   Build static libs         $enable_static
469   CFLAGS                    $CFLAGS
470   Gtk2 immodule dir         $GTK2_IM_MODULEDIR
471   Gtk3 immodule dir         $GTK3_IM_MODULEDIR
472   Build gtk2 immodule       $enable_gtk2
473   Build gtk3 immodule       $enable_gtk3
474   Build XIM agent server    $enable_xim
475   Build python modules      $enable_python
476   Build gconf modules       $enable_gconf
477   Build memconf modules     $enable_memconf
478   Build dconf modules       $enable_dconf
479   Build introspection       $found_introspection
480   IBus-1.0.gir scannerflags "$IBUS_GIR_SCANNERFLAGS"
481   Build vala binding        $enable_vala
482   Build document            $enable_gtk_doc
483   Enable key snooper        $enable_key_snooper
484   No snooper regexes        "$NO_SNOOPER_APPS"
485   Panel icon                "$IBUS_ICON_KEYBOARD"
486   Enable surrounding-text   $enable_surrounding_text
487 ])
488