Add conditional to detect in-tree build

Other modules in contrib have a block like this. Because pg_shard uses
libpq, it is listed as a prereq that needs to be built first (for an
in-tree build this is important): postgres_fdw does the same.