I found a possible approach to overcome this issue. It is necessary to explicitly specify the path to libpq.so library within LD_LIBRARY_PATH environment variable before running the configure command.
In this case conftest program finds the desired libpq and in this case the generated config.h file contains proper defines: /* The size of `long', as computed by sizeof. */ #define SIZEOF_LONG 8
/* The size of `long int', as computed by sizeof. */ #define SIZEOF_LONG_INT 8
/* The size of `void *', as computed by sizeof. */ #define SIZEOF_VOID_P 8