r2905: Apply the patch for bug #1822. Add -D_REENTRANT to CPPFLAGS and -lthread