1# vim:set et ts=4:
2#
3# ibus-libpinyin - Intelligent Pinyin engine based on libpinyin for IBus
4#
5# Copyright (c) 2008-2010 Peng Huang <shawn.p.huang@gmail.com>
6#
7# This program is free software; you can redistribute it and/or modify
8# it under the terms of the GNU General Public License as published by
9# the Free Software Foundation; either version 2, or (at your option)
10# any later version.
11#
12# This program is distributed in the hope that it will be useful,
13# but WITHOUT ANY WARRANTY; without even the implied warranty of
14# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
15# GNU General Public License for more details.
16#
17# You should have received a copy of the GNU General Public License
18# along with this program; if not, write to the Free Software
19# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
20
21# if not 1, append datestamp to the version number.
22m4_define([ibus_released], [1])
23m4_define([ibus_major_version], [1])
24m4_define([ibus_minor_version], [11])
25m4_define([ibus_micro_version], [1])
26m4_define(ibus_maybe_datestamp,
27    m4_esyscmd([if test x]ibus_released[ != x1; then date +.%Y%m%d | tr -d '\n\r'; fi]))
28
29m4_define([ibus_version],
30    ibus_major_version.ibus_minor_version.ibus_micro_version[]ibus_maybe_datestamp)
31
32AC_INIT([ibus-libpinyin], [ibus_version], [https://github.com/libpinyin/ibus-libpinyin/issues/new],[ibus-libpinyin])
33AM_INIT_AUTOMAKE([1.10])
34AC_GNU_SOURCE
35
36AC_CONFIG_HEADERS([config.h])
37AC_CONFIG_MACRO_DIR([m4])
38m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
39
40# define PACKAGE_VERSION_* variables
41AS_VERSION
42AS_NANO
43AM_SANITY_CHECK
44AM_MAINTAINER_MODE
45AM_DISABLE_STATIC
46AC_PROG_CC
47AC_PROG_CXX
48AM_PROG_CC_C_O
49AC_ISC_POSIX
50AC_HEADER_STDC
51AM_PROG_LIBTOOL
52AC_PROG_SED
53
54# check ibus
55PKG_CHECK_MODULES(IBUS, [
56    ibus-1.0 >= 1.5.11
57])
58
59# check sqlite
60PKG_CHECK_MODULES(SQLITE, [
61    sqlite3
62])
63
64AC_PATH_PROG(SQLITE3, sqlite3)
65if test -z "$SQLITE3"; then
66    AC_MSG_ERROR([could not find sqlite3 tool.])
67fi
68
69PKG_CHECK_MODULES(LIBPINYIN, [
70    libpinyin >= 2.2.1
71], [enable_libpinyin=yes])
72
73LIBPINYIN_DATADIR=`$PKG_CONFIG --variable=pkgdatadir libpinyin`
74
75AC_SUBST(LIBPINYIN_DATADIR)
76
77# check if ibus_config_get_values, which is available in ibus-1.3.99+ (git master)
78save_CFLAGS="$CFLAGS"
79save_LIBS="$LIBS"
80CFLAGS="$CFLAGS $IBUS_CFLAGS"
81LIBS="$LIBS $IBUS_LIBS"
82AC_CHECK_FUNCS([ibus_config_get_values])
83CFLAGS="$save_CFLAGS"
84LIBS="$save_LIBS"
85
86
87# check env
88AC_PATH_PROG(ENV, env)
89AC_SUBST(ENV)
90
91# check python
92AC_ARG_WITH(python,
93    AS_HELP_STRING([--with-python[=PATH]],
94        [Select python2 or python3]),
95    [PYTHON=$with_python], []
96)
97AM_PATH_PYTHON([2.5])
98
99# check icon_prop_key in IBus.EngineDesc
100AC_MSG_CHECKING([if IBus.EngineDesc has get_icon_prop_key])
101ICON_PROP_KEY_TEST="import gi
102gi.require_version('IBus', '1.0')
103from gi.repository import IBus
104exit(not hasattr(IBus.EngineDesc, 'get_icon_prop_key'))
105"
106$PYTHON -c "$ICON_PROP_KEY_TEST"
107if test $? -eq 0; then
108    ICON_PROP_KEY_XML="<icon_prop_key>InputMode</icon_prop_key>"
109    AC_MSG_RESULT([yes])
110else
111    ICON_PROP_KEY_XML="<!-- <icon_prop_key>InputMode</icon_prop_key> -->"
112    AC_MSG_RESULT([ibus 1.5.11 or later supports icon-prop-key in IBus.EngineDesc])
113fi
114AC_SUBST(ICON_PROP_KEY_XML)
115
116# --enable-boost
117AC_ARG_ENABLE(boost,
118    AC_HELP_STRING([--enable-boost],
119        [Use boost to replace stdc++0x.]),
120        [enable_boost=$enableval],
121        [enable_boost=no]
122)
123if test x"$enable_boost" = x"yes"; then
124    # check boost
125    BOOST_REQUIRE([1.39])
126    BOOST_FIND_HEADER([boost/bind.hpp])
127    BOOST_FIND_HEADER([boost/signals2.hpp])
128fi
129AM_CONDITIONAL(HAVE_BOOST, test x"$enable_boost" = x"yes")
130
131# --enable-opencc
132AC_ARG_ENABLE(opencc,
133    AC_HELP_STRING([--enable-opencc],
134        [Use opencc for simplified and traditional Chinese conversion]),
135        [enable_opencc=$enableval],
136        [enable_opencc=no]
137)
138if test x"$enable_opencc" = x"yes"; then
139    # check opencc
140    PKG_CHECK_MODULES(OPENCC, [opencc >= 1.0.0], [
141        AC_DEFINE(HAVE_OPENCC, 1, [Define if found opencc])
142    ])
143fi
144
145# define GETTEXT_* variables
146GETTEXT_PACKAGE=ibus-libpinyin
147AC_SUBST(GETTEXT_PACKAGE)
148AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package])
149
150AM_GNU_GETTEXT_VERSION([0.19.7])
151AM_GNU_GETTEXT([external])
152
153# Checks for GSettings.
154PKG_CHECK_MODULES(GIO2, [gio-2.0 >= 2.26.0])
155
156GLIB_GSETTINGS
157
158# --disable-lua-extension
159AC_ARG_ENABLE(lua-extension,
160    AS_HELP_STRING([--disable-lua-extension],
161         [do not build lua extension]),
162    [enable_lua_extension=$enableval],
163    [enable_lua_extension=yes]
164)
165
166# check lua
167PKG_CHECK_MODULES(LUA, [
168    lua >= 5.1
169], [],
170[has_lua_extension=no]
171)
172
173if test x"$has_lua_extension" = x"no";
174then
175    PKG_CHECK_MODULES(LUA, [
176        lua5.1
177    ], [],
178    [enable_lua_extension=no]
179    );
180fi
181
182AM_CONDITIONAL(IBUS_BUILD_LUA_EXTENSION, [test x"$enable_lua_extension" = x"yes"])
183
184# --disable-english-input-mode
185AC_ARG_ENABLE(english-input-mode,
186    AS_HELP_STRING([--disable-english-input-mode],
187    [do not build english input mode]),
188    [enable_english_input_mode=$enableval],
189    [enable_english_input_mode=yes]
190)
191
192AM_CONDITIONAL(IBUS_BUILD_ENGLISH_INPUT_MODE, [test x"$enable_english_input_mode" = x"yes"])
193
194# --disable-stroke-input-mode
195AC_ARG_ENABLE(stroke-input-mode,
196        AS_HELP_STRING([--disable-stroke-input-mode],
197        [do not build stroke input mode]),
198        [enable_stroke_input_mode=$enableval],
199        [enable_stroke_input_mode=yes]
200)
201
202AM_CONDITIONAL(IBUS_BUILD_STROKE_INPUT_MODE, [test x"$enable_stroke_input_mode" = x"yes"])
203
204# OUTPUT files
205AC_CONFIG_FILES([ po/Makefile.in
206Makefile
207ibus-libpinyin.spec
208lua/Makefile
209src/Makefile
210src/libpinyin.xml.in
211setup/Makefile
212setup/ibus-setup-libpinyin
213setup/config.py
214data/Makefile
215data/icons/Makefile
216m4/Makefile
217])
218
219AC_OUTPUT
220
221AC_MSG_RESULT([
222Build options:
223    Version                     $VERSION
224    Install prefix              $prefix
225    Use boost                   $enable_boost
226    Use opencc                  $enable_opencc
227    Use libpinyin               $enable_libpinyin
228    Build lua extension         $enable_lua_extension
229    Build stroke input mode     $enable_stroke_input_mode
230    Build english input mode    $enable_english_input_mode
231])
232
233