Generate much of the CREDITS file from git log

* CREDITS.in: New file, derived from CREDITS, without names of
those who are listed as git log 'Author:'s.
* CREDITS: Remove file.
* Makefile.am [MAINTAINER_MODE] (CREDITS): New rule.
* .gitignore: Add CREDITS.
* .mailmap: New file, required to map git author names and email
addresses to canonical/preferred form.
diff --git a/Makefile.am b/Makefile.am
index 3c15e06..4082cb3 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -107,6 +107,18 @@
 	chmod 444 $@.new
 	mv -f $@.new $@
 
+$(srcdir)/CREDITS: $(top_srcdir)/CREDITS.in $(top_srcdir)/.mailmap \
+		   $(srcdir)/Makefile.in
+	$(AM_V_GEN)							\
+	{								\
+	  cd $(top_srcdir);						\
+	  sed '/^##/,$$d' CREDITS.in;					\
+	  { sed -n '1,/^##>/d; s/  \+/\t/; s/^./&/p' CREDITS.in;	\
+	    git log --pretty=format:'%aN	%aE';			\
+	  } | LC_ALL=C sort -u						\
+	    | awk -F'\t' '{printf("\t%s <%s>\n",$$1,$$2)}';		\
+	} > $@-t && mv $@-t $@
+
 export TAR_OPTIONS = --owner=0 --group=0 --numeric-owner --mode=go-w,go+rX
 
 if LINUX