[gok] Add git.mk script to auto-generate .gitignore files



commit d2020d01aa0d5c342315c0155221fea518ababe5
Author: Gerd Kohlberger <gerdk src gnome org>
Date:   Sun Apr 26 17:20:11 2009 +0200

    Add git.mk script to auto-generate .gitignore files
    
    git.mk will create .gitignore files in the local repository during
    'make'. Files that are not covered by the script can be added to
    GITIGNOREFILES. See:
    
    http://mail.gnome.org/archives/desktop-devel-list/2009-April/msg00211.html
    
    The toplevel Makefile.am now contains a distclean hook to remove
    directories with translated keyboard files.
---
 Makefile.am                |   36 ++++++++-
 configure.in               |    4 +
 docs/reference/Makefile.am |    2 +
 git.mk                     |  174 ++++++++++++++++++++++++++++++++++++++++++++
 gok/Makefile.am            |    2 +
 help/Makefile.am           |    2 +
 help/gok/C/Makefile.am     |    4 +
 help/gok/Makefile.am       |    2 +
 help/gok/eu/Makefile.am    |    2 +
 omf-install/Makefile.am    |    2 +
 10 files changed, 225 insertions(+), 5 deletions(-)

diff --git a/Makefile.am b/Makefile.am
index b501876..91109b7 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -1,3 +1,5 @@
+
+
 SUBDIRS = gok po help omf-install docs samples
 
 distuninstallcheck_listfiles = find . -type f -print | grep -v scrollkeeper
@@ -165,10 +167,34 @@ gokwebdoc.tar.gz: README INSTALL help/gok/C/gok.xml
 
 DISTCHECK_CONFIGURE_FLAGS = --enable-gtk-doc
 CLEANFILES = $(kbd_files)
-DISTCLEANFILES = 		\
-	$(desktop_DATA)		\
-	Keyboard.kbd		\
-	gok-with-references.schemas.in	\
+DISTCLEANFILES =			\
+	$(desktop_DATA)			\
+	Keyboard.kbd			\
 	gok-with-references.schemas	\
-	$(schema_DATA)		\
+	$(schema_DATA)			\
 	$(xam_DATA)
+
+distclean-local:
+	@for l in *; do 			\
+		if [ -f $$l/main.kbd ]; then 	\
+			rm -rf $$l;		\
+		fi;				\
+	done
+
+MAINTAINERCLEANFILES =			\
+	$(srcdir)/aclocal.m4		\
+	$(srcdir)/compile		\
+	$(srcdir)/config.guess		\
+	$(srcdir)/config.h.in		\
+	$(srcdir)/config.sub		\
+	$(srcdir)/depcomp		\
+	$(srcdir)/install-sh		\
+	$(srcdir)/missing		\
+	$(srcdir)/mkinstalldirs		\
+	$(srcdir)/ltmain.sh		\
+	$(srcdir)/omf.make		\
+	$(srcdir)/gtk-doc.make
+
+GITIGNOREFILES = C/ $(LANGDIRS)
+
+-include $(top_srcdir)/git.mk
diff --git a/configure.in b/configure.in
index e2b179c..0778a7f 100644
--- a/configure.in
+++ b/configure.in
@@ -241,6 +241,10 @@ LIBBONOBO_IDL_DIR="`$PKG_CONFIG --variable=idldir libbonobo-2.0`"
 AC_SUBST(BONOBO_ACTIVATION_IDL_DIR)
 AC_SUBST(LIBBONOBO_IDL_DIR)
 
+dnl list of language subdirs (for .gitignore)
+LANGDIRS="`$GREP -v "^\#" po/LINGUAS | while read line; do echo -n "$line/ "; done `"
+AC_SUBST(LANGDIRS)
+
 AC_SUBST(CFLAGS)
 AC_SUBST(CPPFLAGS)
 AC_SUBST(LDFLAGS)
diff --git a/docs/reference/Makefile.am b/docs/reference/Makefile.am
index 88b4488..502b4ee 100644
--- a/docs/reference/Makefile.am
+++ b/docs/reference/Makefile.am
@@ -29,3 +29,5 @@ content_files =
 HTML_IMAGES =
 
 include $(top_srcdir)/gtk-doc.make
+
+-include $(top_srcdir)/git.mk
diff --git a/git.mk b/git.mk
new file mode 100644
index 0000000..3809d71
--- /dev/null
+++ b/git.mk
@@ -0,0 +1,174 @@
+# git.mk
+#
+# Copyright 2009 Red Hat, Inc.
+# Written by Behdad Esfahbod
+#
+# The canonical source for this file is pango/git.mk, or whereever the
+# header of pango/git.mk suggests in the future.
+#
+# To use in your project, import this file in your git repo's toplevel,
+# then do "make -f git.mk".  This modifies all Makefile.am files in
+# your project to include git.mk.
+#
+# This enables automatic .gitignore generation.  If you need to ignore
+# more files, add them to the GITIGNOREFILES variable in your Makefile.am.
+# But think twice before doing that.  If a file has to be in .gitignore,
+# chances are very high that it's a generated file and should be in one
+# of MOSTLYCLEANFILES, CLEANFILES, DISTCLEANFILES, or MAINTAINERCLEANFILES.
+#
+# The only case that you need to manually add a file to GITIGNOREFILES is
+# when remove files in one of mostlyclean-local, clean-local, distclean-local,
+# or maintainer-clean-local.
+#
+# Note that for files like editor backup, etc, there are better places to
+# ignore them.  See "man gitignore".
+#
+# If "make maintainer-clean" removes the files but they are not recognized
+# by this script (that is, if "git stat" shows untracked files still), send
+# me the output of "git stat" as well as your Makefile.am and Makefile for
+# the directories involved.
+#
+# For a list of toplevel files that should be in MAINTAINERCLEANFILES, see
+# pango/Makefile.am.
+#
+# Don't EXTRA_DIST this file.  It is supposed to only live in git clones,
+# not tarballs.  It serves no useful purpose in tarballs and clutters the
+# build dir.
+#
+# This file knows how to handle autoconf, automake, libtool, gtk-doc,
+# gnome-doc-utils, intltool.
+#
+#
+# KNOWN ISSUES:
+#
+# - Recursive configure doesn't work as $(top_srcdir)/git.mk inside the
+#   submodule doesn't find us.  If you have configure.{in,ac} files in
+#   subdirs, add a proxy git.mk file in those dirs that simply does:
+#   "include $(top_srcdir)/../git.mk".  Add more ..'s to your taste.
+#   And add those files to git.  See vte/gnome-pty-helper/git.mk for
+#   example.
+#
+
+git-all: git-mk-install
+
+git-mk-install:
+	@echo Installing git makefile
+	@any_failed=; find $(top_srcdir) -name Makefile.am | while read x; do \
+		if grep 'include .*/git.mk' $$x >/dev/null; then \
+			echo $$x already includes git.mk; \
+		else \
+			failed=; \
+			echo "Updating $$x"; \
+			{ cat $$x; \
+			  echo ''; \
+			  echo '-include $$(top_srcdir)/git.mk'; \
+			} > $$x.tmp || failed=1; \
+			if test x$$failed = x; then \
+				mv $$x.tmp $$x || failed=1; \
+			fi; \
+			if test x$$failed = x; then : else \
+				echo Failed updating $$x; >&2 \
+				any_failed=1; \
+			fi; \
+	fi; done; test -z "$$any_failed"
+
+.PHONY: git-all git-mk-install
+
+
+### .gitignore generation
+
+.gitignore: Makefile.am $(top_srcdir)/git.mk
+	@echo Generating $@; \
+	GTKDOCGITIGNOREFILES=; \
+	test "x$(DOC_MODULE)" = x -o "x$(DOC_MAIN_SGML_FILE)" = x || \
+	GTKDOCGITIGNOREFILES=" \
+		$(DOC_MODULE)-decl-list.txt \
+		$(DOC_MODULE)-decl.txt \
+		tmpl/$(DOC_MODULE)-unused.sgml \
+		tmpl/*.bak \
+		xml html \
+		"; \
+	GNOMEDOCUTILSGITIGNOREFILES=; \
+	test "x$(DOC_MODULE)" = x -o "x$(DOC_LINGUAS)" = x || \
+	GNOMEDOCUTILSGITIGNOREFILES=" \
+		$(_DOC_C_DOCS) \
+		$(_DOC_LC_DOCS) \
+		$(_DOC_OMF_ALL) \
+		$(_DOC_DSK_ALL) \
+		$(_DOC_HTML_ALL) \
+		$(_DOC_POFILES) \
+		*/.xml2po.mo \
+		*/*.omf.out \
+		"; \
+	INTLTOOLGITIGNOREFILES=; test -f $(srcdir)/po/Makefile.in.in && \
+	INTLTOOLGITIGNOREFILES=" \
+		po/Makefile.in.in \
+		po/Makefile.in \
+		po/Makefile \
+		po/*.gmo \
+		po/*.mo \
+		po/POTFILES \
+		po/stamp-it \
+		po/.intltool-merge-cache \
+		intltool-extract.in \
+		intltool-merge.in \
+		intltool-update.in \
+		"; \
+	AUTOCONFGITIGNOREFILES=; test -f $(srcdir)/configure && \
+	AUTOCONFGITIGNOREFILES=" \
+		autom4te.cache \
+		configure \
+		config.h \
+		stamp-h1 \
+		libtool \
+		config.lt \
+		"; \
+	for x in \
+		.gitignore \
+		$$GTKDOCGITIGNOREFILES \
+		$$GNOMEDOCUTILSGITIGNOREFILES \
+		$$INTLTOOLGITIGNOREFILES \
+		$$AUTOCONFGITIGNOREFILES \
+		$(GITIGNOREFILES) \
+		$(CLEANFILES) \
+		$(PROGRAMS) \
+		$(EXTRA_PROGRAMS) \
+		$(LTLIBRARIES) \
+		so_locations \
+		.libs _libs \
+		$(MOSTLYCLEANFILES) \
+		"*.$(OBJEXT)" \
+		"*.lo" \
+		$(DISTCLEANFILES) \
+		$(am__CONFIG_DISTCLEAN_FILES) \
+		$(CONFIG_CLEAN_FILES) \
+		TAGS ID GTAGS GRTAGS GSYMS GPATH tags \
+		"*.tab.c" \
+		$(MAINTAINERCLEANFILES) \
+		$(BUILT_SOURCES) \
+		$(DEPDIR) \
+		Makefile \
+		Makefile.in \
+		"*.orig" \
+		"*.rej" \
+		"*.bak" \
+		"*~" \
+		".*.swp" \
+	; do echo /$$x; done | \
+	grep -v '/[.][.]/' | \
+	sed 's@/[.]/@/@g' | \
+	LANG=C sort | uniq > $  tmp && \
+	mv $  tmp $@;
+
+all: .gitignore gitignore-recurse
+gitignore-recurse:
+	@if test "x$(SUBDIRS)" = "x$(DIST_SUBDIRS)"; then :; else \
+		list='$(DIST_SUBDIRS)'; for subdir in $$list; do \
+		  test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) .gitignore); \
+		done; \
+	fi;
+maintainer-clean-local: gitignore-clean
+gitignore-clean:
+	rm -f .gitignore
+.PHONY: gitignore-clean gitignore-recurse
+
diff --git a/gok/Makefile.am b/gok/Makefile.am
index 5ca0630..99514f1 100644
--- a/gok/Makefile.am
+++ b/gok/Makefile.am
@@ -141,3 +141,5 @@ test_gok_wordcomplete_SOURCES = \
 keyboard_geometry_SOURCES = keyboard-geometry.c
 
 create_branching_keyboard_SOURCES = create-branching-keyboard.c
+
+-include $(top_srcdir)/git.mk
diff --git a/help/Makefile.am b/help/Makefile.am
index 88091f8..83c0774 100644
--- a/help/Makefile.am
+++ b/help/Makefile.am
@@ -1 +1,3 @@
 SUBDIRS = gok
+
+-include $(top_srcdir)/git.mk
diff --git a/help/gok/C/Makefile.am b/help/gok/C/Makefile.am
index a8eb01a..7ddfeca 100644
--- a/help/gok/C/Makefile.am
+++ b/help/gok/C/Makefile.am
@@ -5,3 +5,7 @@ omffile = gok-C.omf
 entities = legal.xml 
 include $(top_srcdir)/xmldocs.make
 dist-hook: app-dist-hook
+
+GITIGNOREFILES = *.omf.out
+
+-include $(top_srcdir)/git.mk
diff --git a/help/gok/Makefile.am b/help/gok/Makefile.am
index 42ffacc..ec24079 100644
--- a/help/gok/Makefile.am
+++ b/help/gok/Makefile.am
@@ -1 +1,3 @@
 SUBDIRS = C
+
+-include $(top_srcdir)/git.mk
diff --git a/help/gok/eu/Makefile.am b/help/gok/eu/Makefile.am
index 577c9d7..fd60a34 100644
--- a/help/gok/eu/Makefile.am
+++ b/help/gok/eu/Makefile.am
@@ -6,3 +6,5 @@ omffile = gok-eu.omf
 entities = legal.xml 
 include $(top_srcdir)/xmldocs.make
 dist-hook: app-dist-hook
+
+-include $(top_srcdir)/git.mk
diff --git a/omf-install/Makefile.am b/omf-install/Makefile.am
index dd89908..2b7401e 100644
--- a/omf-install/Makefile.am
+++ b/omf-install/Makefile.am
@@ -32,3 +32,5 @@ uninstall-local:
 	-rmdir $(omf_dest_dir)
 	-scrollkeeper-update -p $(scrollkeeper_localstate_dir) 
 	-rm -rf $(scrollkeeper_localstate_dir)
+
+-include $(top_srcdir)/git.mk



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]