1# vim:set et ts=4:
2#
3# ibus - The Input Bus
4#
5# Copyright (c) 2007-2016 Peng Huang <shawn.p.huang@gmail.com>
6# Copyright (c) 2015-2021 Takao Fujiwara <takao.fujiwara1@gmail.com>
7# Copyright (c) 2007-2021 Red Hat, Inc.
8#
9# This library is free software; you can redistribute it and/or
10# modify it under the terms of the GNU Lesser General Public
11# License as published by the Free Software Foundation; either
12# version 2.1 of the License, or (at your option) any later version.
13#
14# This library is distributed in the hope that it will be useful,
15# but WITHOUT ANY WARRANTY; without even the implied warranty of
16# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
17# Lesser General Public License for more details.
18#
19# You should have received a copy of the GNU Lesser General Public
20# License along with this library; if not, write to the Free Software
21# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
22# USA
23
24
25# If ibus_released is 0, append datestamp to the version number.
26m4_define([ibus_released], [1])
27
28m4_define([ibus_major_version], [1])
29m4_define([ibus_minor_version], [5])
30m4_define([ibus_micro_version], [24])
31m4_define([ibus_abi_current], [5])
32m4_define([ibus_abi_revision],
33          [m4_eval(100 * ibus_minor_version + ibus_micro_version)])
34m4_define([ibus_abi_age], [0])
35m4_define([ibus_maybe_datestamp],
36    m4_esyscmd([test x]ibus_released[ != x1 && date +.%Y%m%d | tr -d '\n\r']))
37m4_define([ibus_version],
38    ibus_major_version.ibus_minor_version.ibus_micro_version[]ibus_maybe_datestamp)
39m4_define([ibus_api_version], [ibus_major_version.0])
40
41AC_PREFEQ([2.62])
42AC_INIT([ibus], [ibus_version],
43        [https://github.com/ibus/ibus/issues],
44        [ibus])
45
46AC_CONFIG_HEADERS([config.h])
47AC_CONFIG_MACRO_DIR([m4])
48
49m4_define([ibus_abi_current_minus_age],
50          [m4_eval(ibus_abi_current - ibus_abi_age)])
51m4_define([ibus_binary_version],
52          [ibus_major_version.ibus_abi_current_minus_age.ibus_abi_age.ibus_abi_revision])
53
54# Required versions of other packages.
55m4_define([glib_required_version], [2.46.0])
56m4_define([gtk3_required_version], [3.12.0])
57
58# VALA_TARGET_GLIB_VERSION is used by valac --ccode --target-glib .
59# VALA_TARGET_GLIB_VERSION and glib_required_version will be different
60# in the future.
61VALA_TARGET_GLIB_VERSION=2.46
62AC_SUBST(VALA_TARGET_GLIB_VERSION)
63
64# Init automake.
65AM_INIT_AUTOMAKE([1.11.1 parallel-tests])
66AM_MAINTAINER_MODE([enable])
67AC_GNU_SOURCE
68
69# Support silent build rules. Disable
70# by either passing --disable-silent-rules to configure or passing V=1
71# to make
72AM_SILENT_RULES([yes])
73
74# Define sustituted variables:
75IBUS_MAJOR_VERSION=ibus_major_version
76IBUS_MINOR_VERSION=ibus_minor_version
77IBUS_MICRO_VERSION=ibus_micro_version
78IBUS_ABI_CURRENT=ibus_abi_current
79IBUS_ABI_REVISION=ibus_abi_revision
80IBUS_ABI_AGE=ibus_abi_age
81IBUS_VERSION=ibus_version
82IBUS_API_VERSION=ibus_api_version
83IBUS_BINARY_VERSION=ibus_binary_version
84AC_SUBST(IBUS_MAJOR_VERSION)
85AC_SUBST(IBUS_MINOR_VERSION)
86AC_SUBST(IBUS_MICRO_VERSION)
87AC_SUBST(IBUS_ABI_CURRENT)
88AC_SUBST(IBUS_ABI_REVISION)
89AC_SUBST(IBUS_ABI_AGE)
90AC_SUBST(IBUS_API_VERSION)
91AC_SUBST(IBUS_VERSION)
92AC_SUBST(IBUS_BINARY_VERSION)
93
94# libtool versioning
95#
96# If LT_VERSION_INFO="lt_current:lt_revision:lt_age", libibus is
97# libibus-ibus_api_version.so.(lt_current - lt_age).lt_age.lt_revision
98# If the abi is changed, but it is compatible with last version,
99# ibus_abi_current++, ibus_abi_age++;
100# If the abi is not compatible with last version,
101# ibus_abi_current++, ibus_abi_age = 0;
102m4_define([lt_current], [ibus_abi_current])
103m4_define([lt_revision], [ibus_abi_revision])
104m4_define([lt_age], [ibus_abi_age])
105LT_VERSION_INFO="lt_current:lt_revision:lt_age"
106LT_CURRENT_MINUS_AGE=m4_eval(lt_current - lt_age)
107AC_SUBST(LT_VERSION_INFO)
108AC_SUBST(LT_CURRENT_MINUS_AGE)
109
110# Define GETTEXT_* variables.
111GETTEXT_PACKAGE=ibus10
112AC_SUBST(GETTEXT_PACKAGE)
113AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE, "$GETTEXT_PACKAGE",
114                   [The prefix for out gettext translation domains.])
115DEFINE_IBUS_LOCALEDIR
116AC_DEFINE_UNQUOTED(LOCALEDIR, "$ibus_localedir",
117                   [Define the location where the catalogs will be installed])
118
119# For dislpay date.
120m4_define(ibus_datedisplay,
121    m4_esyscmd(date '+%a %b %d %Y' | tr -d '\n\r'))
122DATE_DISPLAY="ibus_datedisplay"
123AC_SUBST(DATE_DISPLAY)
124
125
126# Check for programs.
127AC_PROG_CC
128AM_PROG_CC_C_O
129AC_PROG_CC_STDC
130AM_PROG_VALAC([0.20])
131AC_PROG_INSTALL
132AC_PROG_MAKE_SET
133
134# i18n stuff
135AM_GNU_GETTEXT_VERSION([0.19.8])
136AM_GNU_GETTEXT([external])
137
138# Define PACKAGE_VERSION_* variables.
139AM_DISABLE_STATIC
140AC_ISC_POSIX
141AC_HEADER_STDC
142LT_INIT
143
144# Check header filess.
145AC_CHECK_HEADERS([sys/prctl.h])
146
147# Check functions.
148AC_CHECK_FUNCS(daemon)
149
150# Check packages.
151# Check glib2.
152AM_PATH_GLIB_2_0
153PKG_CHECK_MODULES(GLIB2, [
154    glib-2.0 >= glib_required_version
155])
156PKG_CHECK_MODULES(GOBJECT2, [
157    gobject-2.0 >= glib_required_version
158])
159PKG_CHECK_MODULES(GIO2, [
160    gio-2.0 gio-unix-2.0 >= glib_required_version
161])
162PKG_CHECK_MODULES(GTHREAD2, [
163    gthread-2.0 >= glib_required_version
164])
165
166# --disable-tests option.
167AC_ARG_ENABLE(tests,
168    AS_HELP_STRING([--disable-tests],
169                   [Do not run tests]),
170    [enable_tests=$enableval],
171    [enable_tests=yes]
172)
173AM_CONDITIONAL([ENABLE_TESTS], [test x"$enable_tests" = x"yes"])
174if test x"$enable_tests" != x"yes"; then
175    enable_tests="no (disabled, use --enable-tests to enable)"
176fi
177
178# --disable-gtk2 option.
179AC_ARG_ENABLE(gtk2,
180    AS_HELP_STRING([--disable-gtk2],
181                   [Do not build gtk2 im module]),
182    [enable_gtk2=$enableval],
183    [enable_gtk2=yes]
184)
185AM_CONDITIONAL([ENABLE_GTK2], [test x"$enable_gtk2" = x"yes"])
186
187# --disable-gtk3 option.
188AC_ARG_ENABLE(gtk3,
189    AS_HELP_STRING([--disable-gtk3],
190                   [Do not build gtk3 im module]),
191    [enable_gtk3=$enableval],
192    [enable_gtk3=yes]
193)
194AM_CONDITIONAL([ENABLE_GTK3], [test x"$enable_gtk3" = x"yes"])
195
196# --enable-gtk4 option.
197AC_ARG_ENABLE(gtk4,
198    AS_HELP_STRING([--enable-gtk4],
199                   [Build gtk4 im module]),
200    [enable_gtk4=$enableval],
201    [enable_gtk4=no]
202)
203AM_CONDITIONAL([ENABLE_GTK4], [test x"$enable_gtk4" = x"yes"])
204
205# --disable-xim option.
206AC_ARG_ENABLE(xim,
207    AS_HELP_STRING([--disable-xim],
208                   [Do not build xim server]),
209    [enable_xim=$enableval],
210    [enable_xim=yes]
211)
212AM_CONDITIONAL([ENABLE_XIM], [test x"$enable_xim" = x"yes"])
213
214if test x"$enable_xim" = x"yes"; then
215    AC_SUBST([XIM_CLI_ARG], [--xim])
216fi
217
218# --enable-wayland option.
219AC_ARG_ENABLE(wayland,
220    AS_HELP_STRING([--enable-wayland],
221                   [Build wayland support]),
222    [enable_wayland=$enableval],
223    [enable_wayland=no]
224)
225AM_CONDITIONAL([ENABLE_WAYLAND], [test x"$enable_wayland" = x"yes"])
226
227# --enable-appindicator option.
228AC_ARG_ENABLE(appindicator,
229    AS_HELP_STRING([--enable-appindicator],
230                   [Build appindicator support]),
231    [enable_appindicator=$enableval],
232    [enable_appindicator=yes]
233)
234AM_CONDITIONAL([ENABLE_APPINDICATOR], [test x"$enable_appindicator" = x"yes"])
235
236if test x"$enable_gtk2" = x"yes"; then
237    # check for gtk2
238    PKG_CHECK_MODULES(GTK2, [
239        gtk+-2.0
240    ])
241
242    gtk2_binary_version=`$PKG_CONFIG --variable=gtk_binary_version gtk+-2.0`
243    GTK2_IM_MODULEDIR="$libdir"/gtk-2.0/$gtk2_binary_version/immodules
244else
245    enable_gtk2="no (disabled, use --enable-gtk2 to enable)"
246fi
247
248if test x"$enable_gtk3" = x"yes"; then
249    # check for gtk3
250    PKG_CHECK_MODULES(GTK3, [
251        gtk+-3.0 >= gtk3_required_version
252    ])
253    PKG_CHECK_EXISTS([gdk-wayland-3.0],
254        [enable_gdk3_wayland=yes],
255        [enable_gdk3_wayland=no]
256    )
257
258    gtk3_binary_version=`$PKG_CONFIG --variable=gtk_binary_version gtk+-3.0`
259    GTK3_IM_MODULEDIR="$libdir"/gtk-3.0/$gtk3_binary_version/immodules
260else
261    enable_gtk3="no (disabled, use --enable-gtk3 to enable)"
262    enable_gdk3_wayland=no
263fi
264if test x"$enable_gdk3_wayland" != x"yes"; then
265    enable_gdk3_wayland="no (disabled, need to install gdk-wayland-3.0.pc)"
266fi
267AM_CONDITIONAL([ENABLE_GDK3_WAYLAND], [test x"$enable_gdk3_wayland" = x"yes"])
268
269if test x"$enable_gtk4" = x"yes"; then
270    # check for gtk4
271    PKG_CHECK_MODULES(GTK4, [
272        gtk4
273    ])
274
275    gtk4_binary_version=`$PKG_CONFIG --variable=gtk_binary_version gtk4`
276    GTK4_IM_MODULEDIR="$libdir"/gtk-4.0/$gtk4_binary_version/immodules
277else
278    enable_gtk4="no (disabled, use --enable-gtk4 to enable)"
279fi
280
281if test x"$enable_xim" = x"yes"; then
282    # Check for x11
283    PKG_CHECK_MODULES(X11, [
284        x11
285    ])
286    AC_CHECK_HEADERS([X11/XKBlib.h])
287
288    # if we don't have gtk3 yet, check for gtk2
289    if test x"$enable_gtk3" != x"yes"; then
290        # check for gtk2
291        PKG_CHECK_MODULES(GTK2, [
292            gtk+-2.0
293        ])
294    fi
295else
296    enable_xim="no (disabled, use --enable-xim to enable)"
297fi
298
299if $PKG_CONFIG --exists x11; then
300    X11_PREFIX="`$PKG_CONFIG --variable=prefix x11`"
301elif test x"$prefix" != xNONE; then
302    X11_PREFIX="$prefix"
303else
304    X11_PREFIX="$ac_default_prefix"
305fi
306AC_SUBST(X11_PREFIX)
307
308if test x"$enable_wayland" = x"yes"; then
309    # Check for wayland
310    PKG_CHECK_MODULES(WAYLAND, [
311        wayland-client >= 1.2.0
312        xkbcommon
313    ])
314    m4_ifdef([WAYLAND_SCANNER_RULES],
315             [WAYLAND_PRTCLS_SUBDIR='wayland-protocols/unstable/input-method'
316              AC_SUBST(WAYLAND_PRTCLS_SUBDIR)
317              WAYLAND_SCANNER_RULES(['$(datadir)/$(WAYLAND_PRTCLS_SUBDIR)'])],
318             [AC_SUBST(wayland_scanner_rules)])
319else
320    enable_wayland="no (disabled, use --enable-wayland to enable)"
321    AC_SUBST(wayland_scanner_rules)
322fi
323
324if test x"$enable_appindicator" = x"yes"; then
325    enable_appindicator="yes (enabled, use --disable-appindicator to disable)"
326fi
327
328# GObject introspection
329GOBJECT_INTROSPECTION_CHECK([0.6.8])
330
331IBUS_GIR_SCANNERFLAGS=
332if test x"$found_introspection" = x"yes" ; then
333    IBUS_GIR_SCANNERFLAGS="--warn-all --identifier-prefix=IBus --symbol-prefix=ibus --c-include=ibus.h"
334    PKG_CHECK_EXISTS([gobject-introspection-1.0 >= 0.9.6],
335                     [gir_symbol_prefix=yes],
336                     [gir_symbol_prefix=no])
337    if test x"$gir_symbol_prefix" = x"no" ; then
338        IBUS_GIR_SCANNERFLAGS="--strip-prefix=IBus"
339    fi
340fi
341AC_SUBST(IBUS_GIR_SCANNERFLAGS)
342
343# Check vapigen.
344VAPIGEN_CHECK([0.16])
345
346# Check for gtk-doc.
347GTK_DOC_CHECK(1.9)
348if test x"$enable_gtk_doc" = x"no"; then
349    enable_gtk_doc="no (disabled, use --enable-gtk-doc to enable)"
350fi
351
352# Check for dbus.
353PKG_CHECK_MODULES(DBUS, [
354    dbus-1
355])
356
357# --enable-memconf option.
358AC_ARG_ENABLE(memconf,
359    AS_HELP_STRING([--enable-memconf],
360                   [Enable configure base on memory]),
361    [enable_memconf=$enableval],
362    [enable_memconf=no]
363)
364AM_CONDITIONAL([ENABLE_MEMCONF], [test "x$enable_memconf" = "xyes"])
365
366AC_ARG_ENABLE(dconf,
367    AS_HELP_STRING([--disable-dconf],
368                   [Disable configure base on dconf]),
369    [enable_dconf=$enableval],
370    [enable_dconf=yes]
371)
372AM_CONDITIONAL([ENABLE_DCONF], [test x"$enable_dconf" = x"yes"])
373
374if test x"$enable_dconf" = x"yes"; then
375    # check dconf
376    PKG_CHECK_MODULES(DCONF,
377        [dconf >= 0.7.5],
378    )
379    PKG_CHECK_EXISTS([dconf >= 0.13.4],
380        [AC_DEFINE(DCONF_0_13_4, TRUE, [dconf is 0.13.4 or later])],
381        [])
382    # check glib-compile-schemas
383    GLIB_GSETTINGS
384    enable_dconf="yes (enabled, use --disable-dconf to disable)"
385fi
386
387# Check env.
388AC_PATH_PROG(ENV_IBUS_TEST, env)
389AC_SUBST(ENV_IBUS_TEST)
390
391AC_ARG_ENABLE(python2,
392    AS_HELP_STRING([--disable-python2],
393                   [Do not install bindings/pygobject/gi and ibus for python2.
394                    '--disable-python2' bring '--disable-python-library'.]),
395    [enable_python2=$enableval],
396    [enable_python2=yes]
397)
398
399AC_ARG_ENABLE(python-library,
400    AS_HELP_STRING([--enable-python-library],
401                   [Use ibus python library]),
402    [enable_python_library=$enableval],
403    [enable_python_library=no]
404)
405
406AC_ARG_ENABLE(setup,
407    AS_HELP_STRING([--disable-setup],
408                   [Do not use setup ui.]),
409    [enable_setup=$enableval],
410    [enable_setup=yes]
411)
412
413# Define python version
414AC_ARG_WITH(python,
415    AS_HELP_STRING([--with-python[=PATH]],
416        [Select python2 or python3]),
417    [PYTHON=$with_python], []
418)
419
420AM_PATH_PYTHON([2.5])
421
422if test x"$enable_python2" != x"yes"; then
423    enable_python_library=no
424    PYTHON2=
425    enable_python2="no (disabled, use --enable-python2 to enable)"
426else
427    AC_PATH_PROG(PYTHON2, python2)
428
429    if test x"$PYTHON2" = x""; then
430        PYTHON2=$PYTHON
431    fi
432fi
433
434AM_CONDITIONAL([ENABLE_PYTHON2], [test x"$enable_python2" = x"yes"])
435AM_CONDITIONAL([ENABLE_PYTHON_LIBRARY], [test x"$enable_python_library" = x"yes"])
436AM_CONDITIONAL([ENABLE_SETUP], [test x"$enable_setup" = x"yes"])
437AM_CONDITIONAL([ENABLE_DAEMON], [true])
438
439PYGOBJECT_REQUIRED=3.0.0
440
441PKG_CHECK_EXISTS([pygobject-3.0 >= $PYGOBJECT_REQUIRED],
442                 [enable_pygobject=yes], [enable_pygobject=no])
443
444if test "x$enable_pygobject" = "xyes"; then
445    PKG_CHECK_MODULES(PYTHON, [pygobject-3.0 >= $PYGOBJECT_REQUIRED])
446
447    pyoverridesdir=`$PYTHON -c "import gi; print(gi._overridesdir)"`
448    AC_SUBST(pyoverridesdir)
449
450    if test x"$enable_python2" = x"yes"; then
451        py2overridesdir=`$PYTHON2 -c "import gi; print(gi._overridesdir)"`
452        AC_SUBST(py2overridesdir)
453    fi
454fi
455
456AM_CONDITIONAL(ENABLE_PYGOBJECT, test x"$enable_pygobject" = "xyes")
457
458if test x"$enable_python_library" = x"yes"; then
459    # Check python.
460    AC_PATH_PROG(PYTHON_CONFIG, python$PYTHON_VERSION-config)
461    if test x"$PYTHON_CONFIG" = x""; then
462        AC_PATH_PROG(PYTHON_CONFIG, python-config)
463    fi
464    if test x"$PYTHON_CONFIG" != x""; then
465        PYTHON_CFLAGS=`$PYTHON_CONFIG --includes`
466        PYTHON_LIBS=`$PYTHON_CONFIG --libs`
467    else
468        PYTHON_CFLAGS=`$PYTHON $srcdir/python-config.py --includes`
469        PYTHON_LIBS=`$PYTHON $srcdir/python-config.py --libs`
470    fi
471    PYTHON_INCLUDES="$PYTHON_CFLAGS"
472    AC_SUBST(PYTHON_CFLAGS)
473    AC_SUBST(PYTHON_INCLUDES)
474    AC_SUBST(PYTHON_LIBS)
475
476    PYTHON2_PREFIX=`$PYTHON2 -c "import sys; sys.stdout.write(sys.prefix)"`
477    PYTHON2_VERSION=`$PYTHON2 -c "import sys; sys.stdout.write(sys.version[[:3]])"`
478    PYTHON2_LIBDIR="$PYTHON2_PREFIX/lib/python$PYTHON2_VERSION"
479    python2dir="$PYTHON2_LIBDIR/site-packages"
480    pkgpython2dir="$python2dir/ibus"
481    AC_SUBST(pkgpython2dir)
482else
483    enable_python_library="no (disabled, use --enable-python-library to enable)"
484fi
485
486# Define gtk2 immodule dir.
487AC_ARG_WITH(gtk2-im-module-dir,
488    AS_HELP_STRING([--with-gtk2-im-module-dir[=DIR]],
489        [Select gtk2 immodule dir]),
490    GTK2_IM_MODULEDIR=$with_gtk2_im_module_dir
491)
492AC_SUBST(GTK2_IM_MODULEDIR)
493
494# Define gtk3 immodule dir.
495AC_ARG_WITH(gtk3-im-module-dir,
496    AS_HELP_STRING([--with-gtk3-im-module-dir[=DIR]],
497        [Select gtk3 immodule dir]),
498    GTK3_IM_MODULEDIR=$with_gtk3_im_module_dir
499)
500AC_SUBST(GTK3_IM_MODULEDIR)
501
502# Define gtk4 immodule dir.
503AC_ARG_WITH(gtk4-im-module-dir,
504    AS_HELP_STRING([--with-gtk4-im-module-dir[=DIR]],
505        [Select gtk4 immodule dir]),
506    GTK4_IM_MODULEDIR=$with_gtk4_im_module_dir
507)
508AC_SUBST(GTK4_IM_MODULEDIR)
509
510if test x"$enable_python" = x"yes"; then
511    # Check for dbus-python.
512    AC_ARG_ENABLE(dbus-python-check,
513        AS_HELP_STRING([--disable-dbus-python-check],
514            [Do not check dbus-python]),
515        [enable_dbus_python_check=$enableval],
516        [enable_dbus_python_check=yes]
517    )
518    PKG_CHECK_MODULES(DBUS_PYTHON,
519        [dbus-python >= 0.83.0],
520        [IBUS_HAS_DBUS_PYTHON=yes],
521        [IBUS_HAS_DBUS_PYTHON=no]
522    )
523    if test x"$IBUS_HAS_DBUS_PYTHON" != x"yes"; then
524        if test x"$enable_dbus_python_check" != x"no"; then
525            AC_MSG_ERROR([can not find dbus-python >= 0.83.0. Please install or update dbus-python.])
526        else
527            AC_MSG_WARN([can not find dbus-python >= 0.83.0. It is required.])
528        fi
529    fi
530fi
531
532# Option for always disable snooper applications.
533AC_ARG_ENABLE(key-snooper,
534    AS_HELP_STRING([--disable-key-snooper],
535        [Always disable key snooper in gtk im module]),
536    [enable_key_snooper=$enableval],
537    [enable_key_snooper=yes]
538)
539if test x"$enable_key_snooper" = x"yes"; then
540    AC_DEFINE(ENABLE_SNOOPER, TRUE, [Enable key snooper])
541else
542    AC_DEFINE(ENABLE_SNOOPER, FALSE, [Enable key snooper])
543    enable_key_snooper="no (disabled, use --enable-key-snooper to enable)"
544fi
545
546# Option for no snooper applications.
547AC_ARG_WITH(no-snooper-apps,
548    AS_HELP_STRING([--with-no-snooper-apps[=regex1,regex2]],
549        [Does not enable keyboard snooper in those applications (like: .*chrome.*,firefox.*)]),
550    NO_SNOOPER_APPS=$with_no_snooper_apps,
551    NO_SNOOPER_APPS=[firefox.*,.*chrome.*,.*chromium.*,terminator]
552)
553AC_DEFINE_UNQUOTED(NO_SNOOPER_APPS, "$NO_SNOOPER_APPS",
554    [Does not enbale keyboard snooper in those applications])
555
556# GNOME 3 uses the theme's icon.
557AC_ARG_WITH(panel-icon-keyboard,
558    AS_HELP_STRING([--with-panel-icon-keyboard[=icon_name]],
559        [Set the default panel icon (default: "ibus-keyboard")]),
560    [if test x"$with_panel_icon_keyboard" = x"yes" -o \
561             x"$with_panel_icon_keyboard" = x; then
562         with_panel_icon_keyboard="input-keyboard-symbolic"
563     fi
564     if test x"$with_panel_icon_keyboard" = x"legacy"; then
565         with_panel_icon_keyboard="ibus-keyboard"
566     fi
567     IBUS_ICON_KEYBOARD=$with_panel_icon_keyboard
568    ],
569    IBUS_ICON_KEYBOARD="ibus-keyboard"
570)
571AC_SUBST(IBUS_ICON_KEYBOARD)
572
573# --disable-surrounding-text option.
574AC_ARG_ENABLE(surrounding-text,
575    AS_HELP_STRING([--disable-surrounding-text],
576        [Enable surrounding-text support]),
577    [enable_surrounding_text=$enableval],
578    [enable_surrounding_text=yes]
579)
580if test x"$enable_surrounding_text" = x"yes"; then
581    AC_DEFINE(ENABLE_SURROUNDING, TRUE, [Enable surrounding-text support])
582else
583    enable_surrounding_text="no (disabled, use --enable-surrounding-text to enable)"
584fi
585
586# --disable-ui
587AC_ARG_ENABLE(ui,
588    AS_HELP_STRING([--disable-ui],
589                   [Disable ibus default user interface]),
590    [enable_ui=$enableval],
591    [enable_ui=yes]
592)
593AM_CONDITIONAL([ENABLE_UI], [test x"$enable_ui" = x"yes"])
594if test x"$enable_ui" = x"yes"; then
595    # Check for x11
596    PKG_CHECK_MODULES(X11, [
597        x11
598    ])
599    enable_ui="yes (enabled, use --disable-ui to disable)"
600fi
601
602# --disable-engine
603AC_ARG_ENABLE(engine,
604    AS_HELP_STRING([--disable-engine],
605                   [Disable ibus simple engine]),
606    [enable_engine=$enableval],
607    [enable_engine=yes]
608)
609AM_CONDITIONAL([ENABLE_ENGINE], [test x"$enable_engine" = x"yes"])
610if test x"$enable_engine" = x"yes"; then
611    enable_engine="yes (enabled, use --disable-engine to disable)"
612fi
613
614PKG_CHECK_MODULES(XTEST,
615    [x11 xtst],
616    [enable_xtest=yes],
617    [enable_xtest=no]
618)
619AM_CONDITIONAL([ENABLE_XTEST], [test x"$enable_xtest" = x"yes"])
620
621# --enable-install-tests
622AC_ARG_ENABLE(install-tests,
623    AS_HELP_STRING([--enable-install-tests],
624                   [Enable to install tests]),
625    [enable_install_tests=$enableval],
626    [enable_install_tests=no]
627)
628AM_CONDITIONAL([ENABLE_INSTALL_TESTS], [test x"$enable_install_tests" = x"yes"])
629if test x"$enable_install_tests" = x"no"; then
630    enable_install_tests="no (disabled, use --enable-install-tests to enable)"
631fi
632
633
634# --disable-emoji-dict option.
635AC_ARG_ENABLE(emoji-dict,
636    AS_HELP_STRING([--disable-emoji-dict],
637                   [Do not build Emoji dict files]),
638    [enable_emoji_dict=$enableval],
639    [enable_emoji_dict=yes]
640)
641AM_CONDITIONAL([ENABLE_EMOJI_DICT], [test x"$enable_emoji_dict" = x"yes"])
642
643AC_ARG_WITH(unicode-emoji-dir,
644    AS_HELP_STRING([--with-unicode-emoji-dir[=DIR]],
645        [Set the directory of Unicode Emoji.
646         (default: "/usr/share/unicode/emoji")]),
647    UNICODE_EMOJI_DIR=$with_unicode_emoji_dir,
648    UNICODE_EMOJI_DIR="/usr/share/unicode/emoji"
649)
650AC_SUBST(UNICODE_EMOJI_DIR)
651
652AC_ARG_WITH(emoji-annotation-dir,
653    AS_HELP_STRING([--with-emoji-annotation-dir[=DIR]],
654        [Set the directory of CLDR annotation files.
655         (default: "/usr/share/unicode/cldr/common/annotations")]),
656    EMOJI_ANNOTATION_DIR=$with_emoji_annotation_dir,
657    EMOJI_ANNOTATION_DIR="/usr/share/unicode/cldr/common/annotations"
658)
659AC_SUBST(EMOJI_ANNOTATION_DIR)
660
661if test x"$enable_emoji_dict" = x"yes"; then
662    if test ! -f $UNICODE_EMOJI_DIR/emoji-test.txt ; then
663        AC_MSG_ERROR(Not found $UNICODE_EMOJI_DIR/emoji-test.txt. You can get \
664the emoji files from http://www.unicode.org/Public/emoji/4.0/)
665    else
666        # POSIX SHELL has no ${FOO:0:1}
667        head=`echo "$UNICODE_EMOJI_DIR" | cut -c1`;
668        if test $head != "/" ; then
669            UNICODE_EMOJI_DIR=`realpath "$UNICODE_EMOJI_DIR"`
670        fi
671    fi
672    if test ! -f $EMOJI_ANNOTATION_DIR/en.xml ; then
673        AC_MSG_ERROR(Not found $EMOJI_ANNOTATION_DIR/en.xml. You can get \
674https://github.com/fujiwarat/cldr-emoji-annotation)
675    else
676        head=`echo "$EMOJI_ANNOTATION_DIR" | cut -c1`;
677        if test $head != "/" ; then
678            EMOJI_ANNOTATION_DIR=`realpath "$EMOJI_ANNOTATION_DIR"`
679        fi
680    fi
681    enable_emoji_dict="yes (enabled, use --disable-emoji-dict to disable)"
682fi
683
684# --disable-unicode-dict option.
685AC_ARG_ENABLE(unicode-dict,
686    AS_HELP_STRING([--disable-unicode-dict],
687                   [Do not build Unicode dict files]),
688    [enable_unicode_dict=$enableval],
689    [enable_unicode_dict=yes]
690)
691AM_CONDITIONAL([ENABLE_UNICODE_DICT], [test x"$enable_unicode_dict" = x"yes"])
692
693AC_ARG_WITH(ucd-dir,
694    AS_HELP_STRING([--with-ucd-dir[=DIR]],
695        [Set the directory of UCD (Unicode Character Database) files.
696         (default: "/usr/share/unicode/ucd")]),
697    UCD_DIR=$with_ucd_dir,
698    UCD_DIR="/usr/share/unicode/ucd"
699)
700AC_SUBST(UCD_DIR)
701
702if test x"$enable_unicode_dict" = x"yes"; then
703    if test ! -f $UCD_DIR/NamesList.txt ; then
704        AC_MSG_ERROR(Not found $UCD_DIR/NamesList.txt. You can get \
705the UCD files from https://www.unicode.org/Public/UNIDATA/)
706    elif test ! -f $UCD_DIR/Blocks.txt ; then
707        AC_MSG_ERROR(Not found $UCD_DIR/Blocks.txt. You can get \
708the UCD files from https://www.unicode.org/Public/UNIDATA/)
709    else
710        # POSIX SHELL has no ${FOO:0:1}
711        head=`echo "$UCD_DIR" | cut -c1`;
712        if test $head != "/" ; then
713            UCD_DIR=`realpath "$UCD_DIR"`
714        fi
715    fi
716    enable_unicode_dict="yes (enabled, use --disable-unicode-dict to disable)"
717fi
718
719AC_ARG_WITH(socket-dir,
720    AS_HELP_STRING([--with-socket-dir[=DIR]],
721        [Set the default socket directory to connect ibus-daemon with D-Bus
722         connections (default: "$XDG_CACHE_HOME/ibus").
723         The best practice of the socket directory would be unique per user
724         not to modify by malicious users but XDG_RUNTIME_DIR is not integrated
725         in BSD systems and the BSD's default is "/tmp".
726         XDG_RUMTIME_DIR is not useful now because XDG_RUMTIME_DIR is available
727         by login but not `su` command but ibus-daemon can be run with su.
728         "$XDG_RUMTIME_DIR", "$XDG_CACHE_HOME", "$UID" are extracted by
729         ibus-daemon.
730         ibus-daemon also runs mkdir for the socket directory since BSD
731         systems do not support abstract socket paths.
732         The socket path on a NFS mount would not be a good idea likes
733         "/home/$USER" because the directory is not sometimes accessible
734         with the network condition.]),
735    [IBUS_SOCKET_DIR=$with_socket_dir],
736    [case $host in
737         *linux*) IBUS_SOCKET_DIR='unix:tmpdir=$XDG_CACHE_HOME/ibus';;
738         *)       IBUS_SOCKET_DIR='unix:tmpdir=/tmp';;
739     esac]
740
741)
742AC_DEFINE_UNQUOTED(IBUS_SOCKET_DIR, "$IBUS_SOCKET_DIR",
743                   [The default socket directory to connect ibus-daemon.])
744
745# Check iso-codes.
746PKG_CHECK_MODULES(ISOCODES, [
747    iso-codes
748])
749ISOCODES_PREFIX=`$PKG_CONFIG iso-codes --variable=prefix`
750AC_SUBST(ISOCODES_PREFIX)
751
752PKG_CHECK_MODULES(XKBCONFIG,
753    [xkeyboard-config],
754    [XKBCONFIG_BASE=`$PKG_CONFIG xkeyboard-config --variable=xkb_base`],
755    [XKBCONFIG_BASE='$(datarootdir)/X11/xkb']
756)
757AC_SUBST(XKBCONFIG_BASE)
758
759AC_SUBST([GDBUS_CODEGEN], [`$PKG_CONFIG --variable gdbus_codegen gio-2.0`])
760
761# OUTPUT files
762AC_CONFIG_FILES([ po/Makefile.in
763Makefile
764ibus-1.0.pc
765ibus.spec
766client/Makefile
767client/gtk2/Makefile
768client/gtk3/Makefile
769client/gtk4/Makefile
770client/x11/Makefile
771client/wayland/Makefile
772src/Makefile
773src/ibusversion.h
774src/tests/Makefile
775bus/Makefile
776portal/Makefile
777engine/Makefile
778util/Makefile
779util/IMdkit/Makefile
780data/Makefile
781data/annotations/Makefile
782data/icons/Makefile
783data/its/Makefile
784data/keymaps/Makefile
785data/dconf/Makefile
786docs/Makefile
787docs/reference/Makefile
788docs/reference/ibus/ibus-docs.sgml
789docs/reference/ibus/Makefile
790m4/Makefile
791ibus/_config.py
792ibus/Makefile
793ibus/interface/Makefile
794ui/Makefile
795ui/gtk3/Makefile
796setup/Makefile
797bindings/Makefile
798bindings/pygobject/Makefile
799bindings/vala/Makefile
800conf/Makefile
801conf/dconf/Makefile
802conf/memconf/Makefile
803tools/Makefile
804])
805
806AC_OUTPUT
807AC_MSG_RESULT([
808Build options:
809  Version                       $IBUS_VERSION
810  Install prefix                $prefix
811  Build shared libs             $enable_shared
812  Build static libs             $enable_static
813  CFLAGS                        $CFLAGS
814  PYTHON                        $PYTHON
815  PYTHON2                       $PYTHON2
816  Enable python2                $enable_python2
817  Gtk2 immodule dir             $GTK2_IM_MODULEDIR
818  Gtk3 immodule dir             $GTK3_IM_MODULEDIR
819  Gtk4 immodule dir             $GTK4_IM_MODULEDIR
820  Build gtk2 immodule           $enable_gtk2
821  Build gtk3 immodule           $enable_gtk3
822  Build gtk4 immodule           $enable_gtk4
823  Build XIM agent server        $enable_xim
824  Build wayland support         $enable_wayland
825  Build gdk3 wayland support    $enable_gdk3_wayland
826  Build appindicator support    $enable_appindicator
827  Build python library          $enable_python_library
828  Build memconf modules         $enable_memconf
829  Build dconf modules           $enable_dconf
830  Build introspection           $found_introspection
831  IBus-1.0.gir scannerflags     "$IBUS_GIR_SCANNERFLAGS"
832  Build vala binding            $enable_vala
833  Build document                $enable_gtk_doc
834  Build UI                      $enable_ui
835  Build engine                  $enable_engine
836  Enable key snooper            $enable_key_snooper
837  No snooper regexes            "$NO_SNOOPER_APPS"
838  Panel icon                    "$IBUS_ICON_KEYBOARD"
839  Enable surrounding-text       $enable_surrounding_text
840  Enable Emoji dict             $enable_emoji_dict
841  Unicode Emoji directory       $UNICODE_EMOJI_DIR
842  CLDR annotation directory     $EMOJI_ANNOTATION_DIR
843  Enable Unicode dict           $enable_unicode_dict
844  UCD directory                 $UCD_DIR
845  Socket directory              "$IBUS_SOCKET_DIR"
846  Run test cases                $enable_tests
847  Install tests                 $enable_install_tests
848])
849
850