1# vim:set et ts=4: 2# 3# ibus-anthy - The Anthy engine for IBus 4# 5# Copyright (c) 2007-2008 Peng Huang <shawn.p.huang@gmail.com> 6# Copyright (c) 2010-2019 Takao Fujiwara <takao.fujiwara1@gmail.com> 7# Copyright (c) 2007-2019 Red Hat, Inc. 8# 9# This program is free software; you can redistribute it and/or modify 10# it under the terms of the GNU General Public License as published by 11# the Free Software Foundation; either version 2 of the License, or 12# (at your option) any later version. 13# 14# This program 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 17# GNU General Public License for more details. 18# 19# You should have received a copy of the GNU General Public License along 20# with this program; if not, write to the Free Software Foundation, Inc., 21# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 22 23dnl - if not 1, append datestamp to the version number. 24m4_define([ibus_anthy_released], [1]) 25m4_define([ibus_anthy_major_version], [1]) 26m4_define([ibus_anthy_minor_version], [5]) 27m4_define([ibus_anthy_micro_version], [11]) 28m4_define([ibus_abi_current], [5]) 29m4_define([ibus_abi_revision], 30 [m4_eval(100 * ibus_anthy_minor_version + ibus_anthy_micro_version)]) 31m4_define([ibus_abi_age], [0]) 32m4_define(ibus_maybe_datestamp, 33 m4_esyscmd([if test x]ibus_anthy_released[ != x1; then date +.%Y%m%d | tr -d '\n\r'; fi])) 34 35m4_define([ibus_anthy_version], 36 ibus_anthy_major_version.ibus_anthy_minor_version.ibus_anthy_micro_version[]ibus_maybe_datestamp) 37m4_define([ibus_required_version], [1.5.0]) 38m4_define([glib_required_version], [2.26.0]) 39 40AC_INIT([ibus-anthy], [ibus_anthy_version], [https://github.com/ibus/ibus-anthy/issues],[ibus-anthy]) 41AM_INIT_AUTOMAKE([1.10]) 42AC_GNU_SOURCE 43 44AC_CONFIG_HEADERS([config.h]) 45AC_CONFIG_MACRO_DIR([m4]) 46 47dnl - define PACKAGE_VERSION_* variables 48AS_VERSION 49AS_NANO 50AM_SANITY_CHECK 51AM_MAINTAINER_MODE(enable) 52AC_DISABLE_STATIC 53AC_PROG_CC 54AM_PROG_CC_C_O 55AC_PROG_CXX 56AC_HEADER_STDC 57LT_INIT 58 59dnl - For dislpay Date 60m4_define(ibus_datedisplay, 61 m4_esyscmd(date '+%a %b %d %Y' | tr -d '\n\r')) 62DATE_DISPLAY="ibus_datedisplay" 63AC_SUBST(DATE_DISPLAY) 64 65dnl - check anthy 66PKG_CHECK_MODULES(ANTHY, [anthy-unicode], [ANTHY_PC=anthy-unicode], [ 67 PKG_CHECK_MODULES(ANTHY, [anthy], [ANTHY_PC=anthy]) 68]) 69AC_SUBST(ANTHY_PC) 70 71CFLAGS_backup="$CFLAGS" 72CFLAGS="$ANTHY_CFLAGS $CFLAGS" 73AC_CHECK_DECLS([ 74NTH_UNCONVERTED_CANDIDATE, 75NTH_KATAKANA_CANDIDATE, 76NTH_HIRAGANA_CANDIDATE, 77NTH_HALFKANA_CANDIDATE],, 78 AC_MSG_ERROR([Could not find NTH_*_CANDIDATE values in anthy.h]), 79 [[#include <anthy/anthy.h>]]) 80CFLAGS="$CFLAGS_backup" 81 82PKG_CHECK_MODULES(GOBJECT2, [ 83 gobject-2.0 >= glib_required_version 84]) 85 86dnl - GObject introspection 87GOBJECT_INTROSPECTION_REQUIRE([0.6.8]) 88 89dnl - check libanthy directory 90AC_ARG_WITH(anthygobject-libdir, 91 [AC_HELP_STRING([--with-anthygobject-libdir=PATH], 92 [file path of libanthygobject.so])], 93 [ANTHY_GOBJECT_LIBDIR="$withval"], 94 [ANTHY_GOBJECT_LIBDIR='$(libdir)']) 95AC_SUBST(ANTHY_GOBJECT_LIBDIR) 96 97dnl - check anthygir directory 98AC_ARG_WITH(anthygoject-girdir, 99 [AC_HELP_STRING([--with-anthygobject-girdir=PATH], 100 [file path of anthy.gir])], 101 [ANTHY_GOBJECT_GIRDIR="$withval"], 102 [ANTHY_GOBJECT_GIRDIR='$(datadir)/gir-1.0']) 103AC_SUBST(ANTHY_GOBJECT_GIRDIR) 104 105dnl - check anthygir directory 106AC_ARG_WITH(anthygobject-typelibsdir, 107 [AC_HELP_STRING([--with-anthygobject-typelibsdir=PATH], 108 [file path of anthy.typelibs])], 109 [ANTHY_GOBJECT_TYPELIBSDIR="$withval"], 110 [ANTHY_GOBJECT_TYPELIBSDIR='$(libdir)/girepository-1.0']) 111AC_SUBST(ANTHY_GOBJECT_TYPELIBSDIR) 112 113dnl - check env 114AC_PATH_PROG(ENV_IBUS_TEST, env) 115AC_SUBST(ENV_IBUS_TEST) 116 117dnl - define python version 118AC_ARG_WITH(python, 119 AS_HELP_STRING([--with-python[=PATH]], 120 [Select python2 or python3]), 121 [PYTHON=$with_python], [] 122) 123 124dnl export $pyexecdir using existent $PYTHON 125AM_PATH_PYTHON([2.5]) 126 127dnl Decided to separate python3 directory from python2 directory here 128dnl because engine/table.py includes unicode array so it's better to 129dnl use __future__.unicode_literals. 130dnl python3 string are always str. 131dnl In case __future__.unicode_literals is imported, all the literal 132dnl 'a' is treated as unicode and u'a' is not needed in python2. 133dnl But str is not unicode so we need to convert str to unicode in 134dnl python2 for all non-literal variables likes return values of 135dnl gettext, IBusConfig.get_value, get methods in GTK+ and so on. 136dnl It would causes to complicate python2 codes if merge python2 and 137dnl python3 in the same file. 138dnl if sys.version < '3': 139dnl return unicode(gettext(a), 'utf-8') 140dnl else: 141dnl return gettext(a) 142case "$PYTHON_VERSION" in 1433.*) 144 enable_python3=yes 145 enable_python2=no 146 ;; 147*) 148 enable_python3=no 149 enable_python2=yes 150 ;; 151esac 152 153AM_CONDITIONAL([ENABLE_PYTHON2], [test x"$enable_python2" = x"yes"]) 154AM_CONDITIONAL([ENABLE_PYTHON3], [test x"$enable_python3" = x"yes"]) 155 156dnl - check the supported ibus version 157AC_MSG_CHECKING([if your ibus version is supported]) 158IBUS_VERSION_TEST=" 159from gi.repository import IBus 160def _ibus_check_version(v): 161 major = IBus.MAJOR_VERSION 162 minor = IBus.MINOR_VERSION 163 micro = IBus.MICRO_VERSION 164 if (major, minor, micro) < tuple(map(int, (v.split('.')))): 165 raise ValueError('Required ibus %s but version of ibus is %d.%d.%d' % \ 166 (v, major, minor, micro)) 167 168_ibus_check_version('ibus_required_version') 169exit(0) 170" 171$PYTHON -c "$IBUS_VERSION_TEST" 172if test $? -eq 0; then 173AC_MSG_RESULT([yes]) 174else 175AC_MSG_ERROR([no]) 176fi 177 178dnl - engine-env 179AC_MSG_CHECKING([what are the enviroments for ibus-engine-anthy]) 180AC_ARG_WITH(engine-env, 181 [AC_HELP_STRING([--engine-env=ENVIRONMENTS], 182 [ibus-engine-anthy environments likes 183 "LD_LIBRARY_PATH=/usr/lib/anthy" for libanthy.so. 184 default is none])], 185 [engine_env="$withval"], 186 [engine_env='none']) 187AC_MSG_RESULT($engine_env) 188ENV_IBUS_ENGINE="" 189if test x"$engine_env" != xnone; then 190 ENV_IBUS_ENGINE="$ENV_IBUS_TEST $engine_env" 191fi 192AC_SUBST(ENV_IBUS_ENGINE) 193 194dnl - check pygtk2 195AC_MSG_CHECKING([whether you enable pygtk2 anthy]) 196AC_ARG_ENABLE(pygtk2-anthy, 197 AS_HELP_STRING([--enable-pygtk2-anthy=no/yes], 198 [Install pygtk2 anthy default=no]), 199 [], 200 enable_pygtk2_anthy=no) 201AC_MSG_RESULT($enable_pygtk2_anthy) 202 203if test x"$enable_pygtk2_anthy" = xyes; then 204 AM_CONDITIONAL(HAVE_PYGTK2_ANTHY, true) 205 206 dnl - check swig 207 AC_PATH_PROG(SWIG, swig) 208 if test x"$SWIG" = x""; then 209 AC_MSG_ERROR([can not find swig]) 210 fi 211 AC_SUBST(SWIG) 212 213 AC_PATH_PROG(PYTHON_CONFIG, python$PYTHON_VERSION-config) 214 if test x"$PYTHON_CONFIG" = x""; then 215 AC_PATH_PROG(PYTHON_CONFIG, python-config-$PYTHON_VERSION) 216 fi 217 if test x"$PYTHON_CONFIG" = x""; then 218 AC_PATH_PROG(PYTHON_CONFIG, python-config) 219 fi 220 if test x"$PYTHON_CONFIG" != x""; then 221 PYTHON_CFLAGS=`$PYTHON_CONFIG --includes` 222 PYTHON_LIBS=`$PYTHON_CONFIG --libs` 223 else 224 PYTHON_CFLAGS=`$PYTHON $srcdir/python-config.py --includes` 225 PYTHON_LIBS=`$PYTHON $srcdir/python-config.py --libs` 226 fi 227 AC_SUBST(PYTHON_CFLAGS) 228 AC_SUBST(PYTHON_LIBS) 229else 230 AM_CONDITIONAL(HAVE_PYGTK2_ANTHY, false) 231fi 232 233 234dnl - check file path of Anthy zipcode.t 235AC_ARG_WITH(anthy-zipcode, 236 [AC_HELP_STRING([--with-anthy-zipcode=FILE], 237 [file path of Anty zipcode.t])], 238 [ANTHY_ZIPCODE_FILE="$withval"], 239 [ANTHY_ZIPCODE_FILE="$datadir/anthy/zipcode.t"]) 240test "x$prefix" = xNONE && prefix=$ac_default_prefix 241eval ANTHY_ZIPCODE_FILE=$ANTHY_ZIPCODE_FILE 242eval ANTHY_ZIPCODE_FILE=$ANTHY_ZIPCODE_FILE 243AC_SUBST(ANTHY_ZIPCODE_FILE) 244AM_CONDITIONAL([ENABLE_ZIPCODE], [test -f "$ANTHY_ZIPCODE_FILE" ]) 245 246dnl - check file path of kasumi bin 247AC_ARG_WITH(kasumi-exec, 248 [AC_HELP_STRING([--with-kasumi-exec=FILE], 249 [file path of kasumi bin])], 250 [KASUMI_EXEC_FILE="$withval"], 251 [KASUMI_EXEC_FILE="$bindir/kasumi"]) 252AC_SUBST(KASUMI_EXEC_FILE) 253 254dnl - check file path of kasumi icon 255AC_ARG_WITH(kasumi-icon, 256 [AC_HELP_STRING([--with-kasumi-icon=FILE], 257 [file path of kasumi icon])], 258 [KASUMI_ICON_FILE="$withval"], 259 [KASUMI_ICON_FILE="$datadir/pixmaps/kasumi.png"]) 260AC_SUBST(KASUMI_ICON_FILE) 261 262dnl - check preference icon name 263# Replaced the legacy icon gtk-preferences with preferences-desktop 264# because the icon is included in gnome-icon-theme-legacy package. 265# The following fix would be needed for old non-GNOME desktops. 266# https://github.com/ibus/ibus/commit/dd6acfa5013b 267# Otherwise you can specify the preference icon for your desktop. 268AC_ARG_WITH(icon-preference, 269 [AC_HELP_STRING([--with-icon-preference=ICON_NAME], 270 [preference icon name.])], 271 [ICON_PREFERENCE="$withval"], 272 [ICON_PREFERENCE='preferences-desktop']) 273AC_SUBST(ICON_PREFERENCE) 274 275dnl - check private png 276AC_MSG_CHECKING([if you install the private png file]) 277AC_ARG_ENABLE(private-png, 278 AS_HELP_STRING([--enable-private-png=no/yes], 279 [Install ibus-anthy.png default=no]), 280 [], 281 enable_private_png=no) 282AC_MSG_RESULT($enable_private_png) 283 284if test x"$enable_private_png" = xyes; then 285 AM_CONDITIONAL(HAVE_PRIVATE_PNG, true) 286else 287 AM_CONDITIONAL(HAVE_PRIVATE_PNG, false) 288fi 289 290dnl - check on-off keys 291AC_ARG_WITH(on-off-keys, 292 [AC_HELP_STRING([--with-on-off-keys="'KEY1','KEY2',..."], 293 [Anthy default on-off keys. default=" 294 'Zenkaku_Hankaku', 'Ctrl+J'".])], 295 [ON_OFF_KEYS="$withval"], 296 [ON_OFF_KEYS="'Zenkaku_Hankaku', 'Ctrl+J'"]) 297AC_SUBST(ON_OFF_KEYS) 298 299dnl - check hotkeys for ibus-anthy which is used for ibus bridge mode. 300dnl - Normally you don't need this so could be HOTKEYS="no" 301AC_ARG_WITH(hotkeys, 302 [AC_HELP_STRING([--with-hotkeys=HOTKEYS], 303 [Use hotkeys for ibus bridge mode. (available value: yes/no/keys)])], 304 [HOTKEYS="$withval"], 305 [HOTKEYS="no"]) 306if test x"$HOTKEYS" = x"no"; then 307 HOTKEYS_XML="<!-- <hotkeys>Control+space,Zenkaku_Hankaku</hotkeys> -->" 308elif test x"$HOTKEYS" = x"yes"; then 309 HOTKEYS_XML="<hotkeys>Control+space,Zenkaku_Hankaku</hotkeys>" 310elif test x"$HOTKEYS" = x; then 311 HOTKEYS_XML="<hotkeys>Control+space,Zenkaku_Hankaku</hotkeys>" 312elif test x"$HOTKEYS" = xnull; then 313 HOTKEYS_XML="<hotkeys></hotkeys>" 314else 315 HOTKEYS_XML="<hotkeys>${HOTKEYS}</hotkeys>" 316fi 317AC_SUBST(HOTKEYS_XML) 318 319dnl - check symbol in IBus.EngineDesc 320AC_MSG_CHECKING([if IBus.EngineDesc has get_symbol]) 321SYMBOL_CHAR='あ' 322SYMBOL_CHAR_INT=0x3042 323SYMBOL_TEST="from gi.repository import IBus 324exit(not hasattr(IBus.EngineDesc, 'get_symbol')) 325" 326$PYTHON -c "$SYMBOL_TEST" 327if test $? -eq 0; then 328 SYMBOL_XML="<symbol>${SYMBOL_CHAR}</symbol>" 329 AC_MSG_RESULT([yes]) 330else 331 SYMBOL_XML="<!-- <symbol>${SYMBOL_CHAR}</symbol> -->" 332 AC_MSG_ERROR([ibus 1.4 or later supports symbol in IBus.EngineDesc]) 333fi 334AC_SUBST(SYMBOL_CHAR_INT) 335AC_SUBST(SYMBOL_XML) 336 337dnl - check symbol in IBus.Property 338AC_MSG_CHECKING([if IBus.Property has get_symbol]) 339SYMBOL_TEST="from gi.repository import IBus 340exit(not hasattr(IBus.Property, 'get_symbol')) 341" 342$PYTHON -c "$SYMBOL_TEST" 343if test $? -eq 0; then 344 AC_MSG_RESULT([yes]) 345else 346 AC_MSG_ERROR([ibus 1.5 or later supports symbol in IBus.Property]) 347fi 348 349dnl - check XKB option in IBus.EngineDesc 350AC_MSG_CHECKING([if IBus.EngineDesc has get_layout_option]) 351LAYOUT_OPTION_TEST="from gi.repository import IBus 352exit(not hasattr(IBus.EngineDesc, 'get_layout_option')) 353" 354$PYTHON -c "$LAYOUT_OPTION_TEST" 355if test $? -eq 0; then 356 AC_MSG_RESULT([yes]) 357else 358 AC_MSG_ERROR([ibus 1.5 or later supports layout_option in IBus.EngineDesc]) 359fi 360 361AC_MSG_CHECKING([if IBus.EngineDesc has get_version]) 362DESC_VERSION_TEST="from gi.repository import IBus 363exit(not hasattr(IBus.EngineDesc, 'get_version')) 364" 365$PYTHON -c "$DESC_VERSION_TEST" 366if test $? -eq 0; then 367 AC_MSG_RESULT([yes]) 368else 369 AC_MSG_ERROR([ibus 1.5 or later supports version in IBus.EngineDesc]) 370fi 371 372dnl - check icon_prop_key in IBus.EngineDesc 373AC_MSG_CHECKING([if IBus.EngineDesc has get_icon_prop_key]) 374ICON_PROP_KEY_TEST="from gi.repository import IBus 375exit(not hasattr(IBus.EngineDesc, 'get_icon_prop_key')) 376" 377$PYTHON -c "$ICON_PROP_KEY_TEST" 378if test $? -eq 0; then 379 ICON_PROP_KEY_XML="<icon_prop_key>InputMode</icon_prop_key>" 380 AC_MSG_RESULT([yes]) 381else 382 ICON_PROP_KEY_XML="<!-- <icon_prop_key>InputMode</icon_prop_key> -->" 383 AC_MSG_RESULT([ibus 1.5.11 or later supports icon-prop-key in IBus.EngineDesc]) 384fi 385AC_SUBST(ICON_PROP_KEY_XML) 386 387dnl - set ibus-anthy layout 388AC_ARG_WITH(layout, 389 [AC_HELP_STRING([--with-layout=LAYOUT], 390 [Define the layout. the default is 'jp'. 391 Probably you could set 'default'.])], 392 [LAYOUT="$withval"], 393 [LAYOUT="jp"]) 394if test x"$LAYOUT" = x; then 395 LAYOUT="jp" 396fi 397LAYOUT_XML="<layout>${LAYOUT}</layout>" 398AC_SUBST(LAYOUT) 399AC_SUBST(LAYOUT_XML) 400 401dnl libtool versioning 402dnl 403dnl If LT_VERSION_INFO="lt_current:lt_revision:lt_age", libibus is 404dnl libibus-ibus_api_version.so.(lt_current - lt_age).lt_age.lt_revision 405dnl If the abi is changed, but it is compatible with last version, 406dnl ibus_abi_current++, ibus_abi_age++; 407dnl If the abi is not compatible with last version, 408dnl ibus_abi_current++, ibus_abi_age = 0; 409m4_define([lt_current], [ibus_abi_current]) 410m4_define([lt_revision], [ibus_abi_revision]) 411m4_define([lt_age], [ibus_abi_age]) 412LT_VERSION_INFO="lt_current:lt_revision:lt_age" 413AC_SUBST(LT_VERSION_INFO) 414 415dnl - define GETTEXT_* variables 416GETTEXT_PACKAGE=ibus-anthy 417AC_SUBST(GETTEXT_PACKAGE) 418 419AC_DEFINE_UNQUOTED( 420 GETTEXT_PACKAGE, "$GETTEXT_PACKAGE", 421 [Define to the read-only architecture-independent data directory.] 422) 423 424AM_GNU_GETTEXT_VERSION([0.19.8]) 425AM_GNU_GETTEXT([external]) 426 427 428dnl - OUTPUT files 429AC_CONFIG_FILES([ 430po/Makefile.in 431Makefile 432ibus-anthy.spec 433data/Makefile 434gir/Makefile 435engine/Makefile 436engine/python2/Makefile 437engine/python2/anthy.inputMethod.xml.in 438engine/python2/default.inputMethod.xml.in 439engine/python3/Makefile 440engine/python3/anthy.inputMethod.xml.in 441engine/python3/default.inputMethod.xml.in 442setup/Makefile 443setup/python2/Makefile 444setup/python3/Makefile 445tests/Makefile 446icons/Makefile 447m4/Makefile 448]) 449 450AC_OUTPUT 451echo " 452 IBus-Anthy version ibus_anthy_version 453 454GOBJECT2_CFLAGS $GOBJECT2_CFLAGS 455GOBJECT2_LIBS $GOBJECT2_LIBS 456ANTHY_PC $ANTHY_PC 457ANTHY_CFLAGS $ANTHY_CFLAGS 458ANTHY_LIBS $ANTHY_LIBS 459ANTHY_GOBJECT_LIBDIR $ANTHY_GOBJECT_LIBDIR 460ANTHY_GOBJECT_GIRDIR $ANTHY_GOBJECT_GIRDIR 461ANTHY_GOBJECT_TYPELIBSDIR $ANTHY_GOBJECT_TYPELIBSDIR 462LT_VERSION_INFO $LT_VERSION_INFO 463ENV_IBUS_ENGINE $ENV_IBUS_ENGINE 464HAVE_PYGTK2_ANTHY $enable_pygtk2_anthy 465python $PYTHON 466Enable python2 $enable_python2 467Enable python3 $enable_python3 468python-config $PYTHON_CONFIG 469PYTHON_CFLAGS $PYTHON_CFLAGS 470PYTHON_LIBS $PYTHON_LIBS 471ANTHY_ZIPCODE_FILE $ANTHY_ZIPCODE_FILE 472KASUMI_EXEC_FILE $KASUMI_EXEC_FILE 473KASUMI_ICON_FILE $KASUMI_ICON_FILE 474ICON_PREFERENCE $ICON_PREFERENCE 475ON_OFF_KEYS $ON_OFF_KEYS 476HOTKEYS_XML $HOTKEYS_XML 477SYMBOL_XML $SYMBOL_XML 478ICON_PROP_KEY_XML $ICON_PROP_KEY_XML 479LAYOUT_XML $LAYOUT_XML 480" 481