summaryrefslogtreecommitdiff
path: root/git.mk
blob: e6606bc508e485eaf6cbb3fd06166e465a6fa1c7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
# git.mk
#
# Copyright 2009 Red Hat, Inc.
# Written by Behdad Esfahbod
#
# 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.
# Note that for files like editor backup, etc, there are better places to
# ignore them.  See "man gitignore".
#

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 x$$any_failed = x


### .gitignore generation

.gitignore: Makefile.am $(top_srcdir)/git.mk
	@echo Generating $@
	@GTKDOCIGNOREFILES=; test "x$(DOC_MODULE)" = x || \
	GTKDOCIGNOREFILES=" \
		$(DOC_MODULE)-decl-list.txt $(DOC_MODULE)-decl.txt \
		tmpl/$(DOC_MODULE)-unused.sgml tmpl/*.bak \
		xml html"; \
	for x in .gitignore \
		$(GITIGNOREFILES) \
		$$GTKDOCIGNOREFILES \
		$(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" \
		$(top_builddir)/config.h $(top_builddir)/stamp-h1 \
		$(top_builddir)/libtool $(top_builddir)/config.lt \
		$(MAINTAINERCLEANFILES) \
		$(BUILT_SOURCES) \
		$(DEPDIR) \
		$(top_srcdir)/autom4te.cache \
		Makefile \
		Makefile.in \
		$(top_srcdir)/configure \
		$(top_srcdir)/gtk-doc.make \
		$(top_srcdir)/git.mk \
		"*.orig" "*.rej" "*.bak" "*~" \
	; do echo /$$x; done | \
	grep -v '/[.][.]/' | \
	sed 's@/[.]/@/@g' | \
	LANG=C sort | uniq > $@.tmp && \
	mv $@.tmp $@

Makefile.in: $(top_srcdir)/git.mk
all: .gitignore
maintainer-clean-local: gitignore-clean
gitignore-clean:
	rm -f .gitignore
.PHONY: gitignore-clean