1# Copyright (c) 2011 Colomban Wendling <ban@herbesfolles.org>
2#
3# AX_PYTHON_LIBRARY([action-if-found], [action-if-not-found])
4#
5# Tries to locate Python DSO path. It requires $PYTHON to be set
6
7AC_DEFUN([AX_PYTHON_LIBRARY],[
8	AC_REQUIRE([AX_PYTHON_DEVEL])
9
10	AC_MSG_CHECKING([for Python DSO location])
11
12	ax_python_library=`cat << EOD | $PYTHON - 2>/dev/null
13from distutils.sysconfig import get_config_vars
14from os.path import join as path_join
15
16cvars = get_config_vars()
17# support multiarch-enabled distributions like Ubuntu
18if not 'MULTIARCH' in cvars.keys():
19    cvars[['MULTIARCH']] = ''
20# try to find the real installed lib, not the generic link
21if not 'INSTSONAME' in cvars.keys():
22    cvars[['INSTSONAME']] = cvars[['LDLIBRARY']]
23print(path_join(cvars[['LIBDIR']], cvars[['MULTIARCH']], cvars[['INSTSONAME']]))
24EOD`
25
26	AC_SUBST([PYTHON_LIBRARY], [$ax_python_library])
27	AC_MSG_RESULT([$PYTHON_LIBRARY])
28	AS_IF([test -z "$ax_python_library"], [$2], [$1])
29])
30