build script rewrite and link with pthreads on linux