Yes, I am trying to build against custom-built libraries.
and thanks for the suggestion about LDFLAGS, but that didn't work too.
It still picks up system versions of the libraries.
What has pkg-config got to do with this? (I havent worked extensively with linux so not much idea)
I think I should also mention that I am trying to build matplotlib against Python 3.2.3.
You can try setting LDFLAGS to "-L/path/to/your/libraries".