* automake.in (top_srcdir): New global. (generate_makefile): Compute it. (fill_dist_dirs): New function extracted from handle_dist. (handle_dist, handle_configure): Use fill_dist_dirs. * tests/distdir.test: Test for cases where $(top_srcdir) or $(srcdir) appear in EXTRA_DIST. Report from Sander Niemeijer.