use ac's @LIBS@ instead of magic string
add check for pthread_create and re-order link flags