-lpthread is a linker flag, not a compilation or preprocessor flag, so it doesn't make sense to include it in PTHREAD_INC.
With gcc, my understanding is that the correct flag is -pthread, for both compiling and linking (i.e. it should be in both PTHREAD_INC and PTHREAD_LIB). It causes -lpthread to be linked, but also defines -D_REENTRANT in order that you use re-entrant versions of libc functions. (There used to be a much wider variety of options, but nowadays the other platforms have mostly died off.)
-DHAVE_UNISTD_H doesn't really have anything to do with pthreads; unistd.h is available on any POSIX system (nowadays, any non-Windows system) these days, and HAVE_UNISTD_H is a carryover from your conversion from autoconf. (If you were going to switch to anything, I would have recommended cmake, but that's a different story.) Since you only check for this on non-Windows machines anyway, you should be able to just omit the check.
The Makefile recommends the following pthread flags
Some problems with this:
-lpthread
is a linker flag, not a compilation or preprocessor flag, so it doesn't make sense to include it inPTHREAD_INC
.gcc
, my understanding is that the correct flag is-pthread
, for both compiling and linking (i.e. it should be in bothPTHREAD_INC
andPTHREAD_LIB
). It causes-lpthread
to be linked, but also defines-D_REENTRANT
in order that you use re-entrant versions of libc functions. (There used to be a much wider variety of options, but nowadays the other platforms have mostly died off.)-DHAVE_UNISTD_H
doesn't really have anything to do with pthreads;unistd.h
is available on any POSIX system (nowadays, any non-Windows system) these days, andHAVE_UNISTD_H
is a carryover from your conversion from autoconf. (If you were going to switch to anything, I would have recommendedcmake
, but that's a different story.) Since you only check for this on non-Windows machines anyway, you should be able to just omit the check.