rename version.py to config.py
[platform/upstream/ibus-libpinyin.git] / configure.ac
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.
22 m4_define([ibus_released], [1])
23 m4_define([ibus_major_version], [1])
24 m4_define([ibus_minor_version], [5])
25 m4_define([ibus_micro_version], [91])
26 m4_define(ibus_maybe_datestamp,
27     m4_esyscmd([if test x]ibus_released[ != x1; then date +.%Y%m%d | tr -d '\n\r'; fi]))
28
29 m4_define([ibus_version],
30     ibus_major_version.ibus_minor_version.ibus_micro_version[]ibus_maybe_datestamp)
31
32 AC_INIT([ibus-libpinyin], [ibus_version], [https://github.com/libpinyin/ibus-libpinyin/issues/new],[ibus-libpinyin])
33 AM_INIT_AUTOMAKE([1.10])
34 AC_GNU_SOURCE
35
36 AC_CONFIG_HEADERS([config.h])
37 AC_CONFIG_MACRO_DIR([m4])
38 m4_ifdef([AM_SILENT_RULES],[AM_SILENT_RULES([yes])])
39
40 # define PACKAGE_VERSION_* variables
41 AS_VERSION
42 AS_NANO
43 AM_SANITY_CHECK
44 AM_MAINTAINER_MODE
45 AM_DISABLE_STATIC
46 AC_PROG_CC
47 AC_PROG_CXX
48 AM_PROG_CC_C_O
49 AC_ISC_POSIX
50 AC_HEADER_STDC
51 IT_PROG_INTLTOOL([0.35.0])
52 AM_PROG_LIBTOOL
53
54 # check ibus
55 PKG_CHECK_MODULES(IBUS, [
56     ibus-1.0 >= 1.3.99
57 ])
58
59 # check sqlite
60 PKG_CHECK_MODULES(SQLITE, [
61     sqlite3
62 ])
63 AC_PATH_PROG(SQLITE3, sqlite3)
64
65 PKG_CHECK_MODULES(LIBPINYIN, [
66     libpinyin >= 0.8.91
67 ], [enable_libpinyin=yes])
68
69 AM_CONDITIONAL(IBUS_BUILD_LIBPINYIN, [test x"$enable_libpinyin" = x"yes"])
70
71 LIBPINYIN_DATADIR=`$PKG_CONFIG --variable=pkgdatadir libpinyin`
72
73 AC_SUBST(LIBPINYIN_DATADIR)
74
75 # check uuid
76 AC_CHECK_FUNCS([uuid_create], [], [
77     PKG_CHECK_MODULES(LIBUUID, uuid, [
78         # uuid.pc exist
79         AC_DEFINE(HAVE_LIBUUID, 1, [Define if found libuuid])
80         HAVE_LIBUUID=yes
81     ], [
82         # uuid.pc does not exist
83         uuid_old_LIBS=$LIBS
84         AC_CHECK_HEADERS(uuid/uuid.h, [
85             AC_SEARCH_LIBS(uuid_generate, uuid, [
86                 test x"$ac_cv_search_uuid_generate" != x"none required" && LIBUUID_LIBS=$ac_cv_search_uuid_generate
87                 AC_DEFINE(HAVE_LIBUUID, 1, [Define if found libuuid])
88                 HAVE_LIBUUID=yes
89             ], [
90                 AC_MSG_ERROR([Can not find uuid_create and uuid_generate in libc or libuuid])
91             ])
92         ], [
93             AC_MSG_ERROR([Can not find uuid_create and uuid_generate in libc or libuuid])
94         ])
95         LIBS=$uuid_old_LIBS
96     ])
97 ])
98
99 AM_CONDITIONAL(HAVE_LIBUUID, test x"$HAVE_LIBUUID" = x"yes")
100
101 # check if ibus_config_get_values, which is available in ibus-1.3.99+ (git master)
102 save_CFLAGS="$CFLAGS"
103 save_LIBS="$LIBS"
104 CFLAGS="$CFLAGS $IBUS_CFLAGS"
105 LIBS="$LIBS $IBUS_LIBS"
106 AC_CHECK_FUNCS([ibus_config_get_values])
107 CFLAGS="$save_CFLAGS"
108 LIBS="$save_LIBS"
109
110
111 # check env
112 AC_PATH_PROG(ENV, env)
113 AC_SUBST(ENV)
114
115 # check python
116 AM_PATH_PYTHON([2.5])
117
118 # --enable-boost
119 AC_ARG_ENABLE(boost,
120     AC_HELP_STRING([--enable-boost],
121         [Use boost to replace stdc++0x.]),
122         [enable_boost=$enableval],
123         [enable_boost=no]
124 )
125 if test x"$enable_boost" = x"yes"; then
126     # check boost
127     BOOST_REQUIRE([1.39])
128     BOOST_FIND_HEADER([boost/bind.hpp])
129     BOOST_FIND_HEADER([boost/signals2.hpp])
130 fi
131 AM_CONDITIONAL(HAVE_BOOST, test x"$enable_boost" = x"yes")
132
133 # --enable-opencc
134 AC_ARG_ENABLE(opencc,
135     AC_HELP_STRING([--enable-opencc],
136         [Use opencc for simplified and traditional Chinese conversion]),
137         [enable_opencc=$enableval],
138         [enable_opencc=no]
139 )
140 if test x"$enable_opencc" = x"yes"; then
141     # check opencc
142     PKG_CHECK_MODULES(OPENCC, [opencc], [
143         AC_DEFINE(HAVE_OPENCC, 1, [Define if found opencc])
144     ])
145 fi
146
147 # define GETTEXT_* variables
148 GETTEXT_PACKAGE=ibus-libpinyin
149 AC_SUBST(GETTEXT_PACKAGE)
150 AC_DEFINE_UNQUOTED(GETTEXT_PACKAGE,"$GETTEXT_PACKAGE", [Gettext package])
151
152 AM_GLIB_GNU_GETTEXT
153
154 # --disable-lua-extension
155 AC_ARG_ENABLE(lua-extension,
156     AS_HELP_STRING([--disable-lua-extension],
157          [do not build lua extension]),
158     [enable_lua_extension=$enableval],
159     [enable_lua_extension=yes]
160 )
161
162 # check lua
163 PKG_CHECK_MODULES(LUA, [
164     lua >= 5.1
165 ], [],
166 [has_lua_extension=no]
167 )
168
169 if test x"$has_lua_extension" = x"no";
170 then
171     PKG_CHECK_MODULES(LUA, [
172         lua5.1
173     ], [],
174     [enable_lua_extension=no]
175     );
176 fi
177
178 AM_CONDITIONAL(IBUS_BUILD_LUA_EXTENSION, [test x"$enable_lua_extension" = x"yes"])
179
180 # --disable-english-input-mode
181 AC_ARG_ENABLE(english-input-mode,
182     AS_HELP_STRING([--disable-english-input-mode],
183     [do not build english input mode]),
184     [enable_english_input_mode=$enableval],
185     [enable_english_input_mode=yes]
186 )
187
188 AM_CONDITIONAL(IBUS_BUILD_ENGLISH_INPUT_MODE, [test x"$enable_english_input_mode" = x"yes"])
189
190 # --disable-stroke-input-mode
191 AC_ARG_ENABLE(stroke-input-mode,
192         AS_HELP_STRING([--disable-stroke-input-mode],
193         [do not build stroke input mode]),
194         [enable_stroke_input_mode=$enableval],
195         [enable_stroke_input_mode=yes]
196 )
197
198 AM_CONDITIONAL(IBUS_BUILD_STROKE_INPUT_MODE, [test x"$enable_stroke_input_mode" = x"yes"])
199
200 # OUTPUT files
201 AC_CONFIG_FILES([ po/Makefile.in
202 Makefile
203 ibus-libpinyin.spec
204 lua/Makefile
205 src/Makefile
206 src/libpinyin.xml.in
207 setup/Makefile
208 setup/ibus-setup-libpinyin
209 setup/config.py
210 data/Makefile
211 data/icons/Makefile
212 m4/Makefile
213 ])
214
215 AC_OUTPUT
216
217 AC_MSG_RESULT([
218 Build options:
219     Version                     $VERSION
220     Install prefix              $prefix
221     Use boost                   $enable_boost
222     Use opencc                  $enable_opencc
223     Use libpinyin               $enable_libpinyin
224     Build lua extension         $enable_lua_extension
225     Build stroke input mode     $enable_stroke_input_mode
226     Build english input mode    $enable_english_input_mode
227 ])
228