+# The flex/bison rules refrain from updating unchanged headers for the
+# convenience of developers, but the headers must be distributed with
+# up-to-date timestamps, otherwise make will try to update them in a fresh
+# VPATH build.
+dist-hook: update-headers
+update-headers: unfuck-distdir
+ touch -c '$(distdir)/src/scan.h'
+ touch -c '$(distdir)/src/parse.h'
+.PHONY: update-headers
+
+# When running "make dist" in a VPATH build with a read-only srcdir, Automake
+# will produce a distribution with all files read-only. Moreover, the files
+# are read-only in distdir when the dist hooks are run. This hook will
+# manually fix up the permissions. All dist hooks that modify files in distdir
+# should list unfuck-distdir as a prerequisite.
+dist-hook: unfuck-distdir
+unfuck-distdir:
+ find '$(distdir)' -type f -exec chmod u+w {} +
+.PHONY: unfuck-distdir
+