Use pkg-config for external libraries.

Instead of hardcoding -lthrift, use `pkg-config --libs thrift` in LDFLAGS. This
commit also adds a dummy call to pkg-config --cflags in CXXFLAGS for the sake of
uniformity.