diff --git a/acinclude.m4 b/acinclude.m4
index 4b9972c..e66ac6c 100644
--- a/acinclude.m4
+++ b/acinclude.m4
@@ -73,8 +73,8 @@ AC_DEFUN([AM_CHECK_PYTHON_LIBS],
 AC_MSG_CHECKING(for libraries required to embed python)
 dnl deduce PYTHON_LIBS
 py_exec_prefix=`$PYTHON -c "import sys; print sys.exec_prefix"`
-PYTHON_LIBS="-L${py_prefix}/lib -lpython${PYTHON_VERSION}"
-PYTHON_LIB_LOC="${py_prefix}/lib" 
+PYTHON_LIBS=`$PYTHON-config --ldflags`
+PYTHON_LIB_LOC=`$PYTHON-config --ldflags | cut -d' ' -f 1`
 AC_SUBST(PYTHON_LIBS)
 AC_SUBST(PYTHON_LIB_LOC)
 dnl check if the headers exist:
