Python 3.1.1 with --enable-shared : will not build any extensions
Something is wrong with your build environment. It is picking up a libpython3.1.a from /usr/local/lib
; this confuses the error messages. It tries linking with that library, which fails - however, it shouldn't have tried that in the first place, since it should have used the libpython that it just built. I recommend taking the Python 3.1 installation in /usr/local
out of the way.
You don't show in your output whether a libpython3.1.so.1.0 was created in the build tree; it would be important to find out whether it exists, how it was linked, and what symbols it has exported.
/usr/local/lib has been added to the library include path at compile time:
-L/usr/local/lib -L.
Its common for compile time to look in multiple 'common' paths for libraries (/usr/lib, /usr/local/lib, ./, etc) but also, it's possibly picking up /usr/local/lib from the environment variable LD_LIBRARY_PATH and tacking it on to the build command.