How about this? It bases the default values of PYTHON_PREFIX and PYTHON_EXEC_PREFIX on sys.prefix and sys.exec_prefix respectively, which the documentation has long said might happen. Behaviour should not change in the case that sys.prefix = $prefix. The variables can still be overridden; e.g. PYTHON_PREFIX is defined with reference to $prefix if the former is a subdir of (or the same as) the latter, and pythondir is defined with reference to $PYTHON_PREFIX. There's also a fix for an apparent bug where $am_py_prefix was used instead of $am_py_exec_prefix when setting up the value of pyexecdir. - Josh