summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfujiwarat <takao.fujiwara1@gmail.com>2012-03-23 18:12:28 +0900
committerfujiwarat <takao.fujiwara1@gmail.com>2012-03-23 18:12:28 +0900
commitc7edf10e2d76c798ce305ca85dcff16e18c40f86 (patch)
tree600c54dafade1f1270c334d69f24e6d302591cbb
parent85e1b094985d6f8f61d324f45cf893c7c63c38b5 (diff)
downloadibus-anthy-c7edf10e2d76c798ce305ca85dcff16e18c40f86.tar.gz
Fixed to detect python2 under the mixed python2 and python3.
-rw-r--r--configure.ac57
1 files changed, 55 insertions, 2 deletions
diff --git a/configure.ac b/configure.ac
index 442d5aa..2057b92 100644
--- a/configure.ac
+++ b/configure.ac
@@ -82,10 +82,62 @@ AC_PATH_PROG(ENV_IBUS_TEST, env)
AC_SUBST(ENV_IBUS_TEST)
dnl - check python
-AM_PATH_PYTHON([2.5])
+dnl ibus-anthy and pygobject3 uses python2
+dnl but AM_PATH_PYTHON does not check if python3 is used
+dnl so I created IBUS_PYTHON_CHECK_VERSION2 from AM_PYTHON_CHECK_VERSION
+dnl to check both the python minimum version and 3.
+
+dnl from python.m4
+IBUS_PYTHON_MIN_VERSION=2.5
+IBUS_PYTHON_CHECK_VERSION2() {
+ ARGS="import sys
+# split strings by '.' and convert to numeric. Append some zeros
+# because we need at least 4 digits for the hex conversion.
+# map returns an iterator in Python 3.0 and a list in 2.x
+minver = list(map(int, '$2'.split('.')))
+if [len](minver) < 4:
+ for i in list(range(0, 4 - [len](minver))): minver.append(0)
+minverhex = 0
+# xrange is not present in Python 3.0 and range returns an iterator
+for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[[i]]
+threever = [[3, 0, 0, 0]]
+threeverhex = 0
+for i in list(range(0, 4)): threeverhex = (threeverhex << 8) + threever[[i]]
+sys.exit(not (sys.hexversion >= minverhex and \\
+ sys.hexversion < threeverhex))"
+ PROG="$1"
+ PYTHON_VERSION2=`"$PROG" -c "import sys; sys.stdout.write(sys.version[[:3]])"`
+ "$PROG" -c "$ARGS"
+ return $?
+}
+
+AC_MSG_CHECKING([whether you have python2])
+HAS_PYTHON2=no
+IBUS_PYTHON_INTERPRETER_LIST='
+python python2 python2.7 python2.6 pythhon2.5
+'
+for PYTHON2 in $IBUS_PYTHON_INTERPRETER_LIST ; do
+ IBUS_PYTHON_CHECK_VERSION2 $PYTHON2 $IBUS_PYTHON_MIN_VERSION
+ if test $? -eq 0 ; then
+ HAS_PYTHON2=yes
+ break
+ fi
+done
+AC_MSG_RESULT($HAS_PYTHON2)
+
+if test x"$HAS_PYTHON2" = xyes; then
+ AC_PATH_PROG(PYTHON, $PYTHON2)
+ PYTHON_VERSION=$PYTHON_VERSION2
+fi
+
+dnl export $pyexecdir using existent $PYTHON
+AM_PATH_PYTHON([$IBUS_PYTHON_MIN_VERSION])
AC_PATH_PROG(PYTHON_CONFIG, python$PYTHON_VERSION-config)
if test x"$PYTHON_CONFIG" = x""; then
+ AC_PATH_PROG(PYTHON_CONFIG, python-config-$PYTHON_VERSION)
+fi
+if test x"$PYTHON_CONFIG" = x""; then
AC_PATH_PROG(PYTHON_CONFIG, python-config)
fi
if test x"$PYTHON_CONFIG" != x""; then
@@ -196,7 +248,8 @@ AC_OUTPUT
echo "
IBus-Anthy version ibus_version
-python-config: $PYTHON_CONFIG
+python $PYTHON
+python-config $PYTHON_CONFIG
PYTHON_CFLAGS $PYTHON_CFLAGS
PYTHON_LIBS $PYTHON_LIBS
ANTHY_ZIPCODE_FILE $ANTHY_ZIPCODE_FILE