Two things.
First, if you are using the AIX C compiler (and not GCC),
then, instead of "CPPFLAGS=-D_THREAD_SAFE", you should
use "CC=xlc_r", this will use the "threaded" personality
of the compiler, which sets -D_THREAD_SAFE, and includes
"-lpthreads" as...