3 # Copyright 2009, Red Hat, Inc.
4 # Copyright 2010,2011,2012,2013 Behdad Esfahbod
5 # Written by Behdad Esfahbod
7 # Copying and distribution of this file, with or without modification,
8 # is permitted in any medium without royalty provided the copyright
9 # notice and this notice are preserved.
11 # The latest version of this file can be downloaded from:
12 # https://raw.github.com/behdad/git.mk/master/git.mk
13 # Bugs, etc, should be reported upstream at:
14 # https://github.com/behdad/git.mk
16 # To use in your project, import this file in your git repo's toplevel,
17 # then do "make -f git.mk". This modifies all Makefile.am files in
18 # your project to -include git.mk. Remember to add that line to new
19 # Makefile.am files you create in your project, or just rerun the
22 # This enables automatic .gitignore generation. If you need to ignore
23 # more files, add them to the GITIGNOREFILES variable in your Makefile.am.
24 # But think twice before doing that. If a file has to be in .gitignore,
25 # chances are very high that it's a generated file and should be in one
26 # of MOSTLYCLEANFILES, CLEANFILES, DISTCLEANFILES, or MAINTAINERCLEANFILES.
28 # The only case that you need to manually add a file to GITIGNOREFILES is
29 # when remove files in one of mostlyclean-local, clean-local, distclean-local,
30 # or maintainer-clean-local make targets.
32 # Note that for files like editor backup, etc, there are better places to
33 # ignore them. See "man gitignore".
35 # If "make maintainer-clean" removes the files but they are not recognized
36 # by this script (that is, if "git status" shows untracked files still), send
37 # me the output of "git status" as well as your Makefile.am and Makefile for
38 # the directories involved and I'll diagnose.
40 # For a list of toplevel files that should be in MAINTAINERCLEANFILES, see
41 # Makefile.am.sample in the git.mk git repo.
43 # Don't EXTRA_DIST this file. It is supposed to only live in git clones,
44 # not tarballs. It serves no useful purpose in tarballs and clutters the
47 # This file knows how to handle autoconf, automake, libtool, gtk-doc,
48 # gnome-doc-utils, yelp.m4, mallard, intltool, gsettings, dejagnu, appdata.
50 # This makefile provides the following targets:
52 # - all: "make all" will build all gitignore files.
53 # - gitignore: makes all gitignore files in the current dir and subdirs.
54 # - .gitignore: make gitignore file for the current dir.
55 # - gitignore-recurse: makes all gitignore files in the subdirs.
59 # - Recursive configure doesn't work as $(top_srcdir)/git.mk inside the
60 # submodule doesn't find us. If you have configure.{in,ac} files in
61 # subdirs, add a proxy git.mk file in those dirs that simply does:
62 # "include $(top_srcdir)/../git.mk". Add more ..'s to your taste.
63 # And add those files to git. See vte/gnome-pty-helper/git.mk for
69 ###############################################################################
70 # Variables user modules may want to add to toplevel MAINTAINERCLEANFILES:
71 ###############################################################################
74 # Most autotools-using modules should be fine including this variable in their
75 # toplevel MAINTAINERCLEANFILES:
76 GITIGNORE_MAINTAINERCLEANFILES_TOPLEVEL = \
77 $(srcdir)/aclocal.m4 \
78 $(srcdir)/autoscan.log \
79 $(srcdir)/configure.scan \
80 `AUX_DIR=$(srcdir)/$$(cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_AUX_DIR:$$1' ./configure.ac); \
81 test "x$$AUX_DIR" = "x$(srcdir)/" && AUX_DIR=$(srcdir); \
93 ; do echo "$$AUX_DIR/$$x"; done` \
94 `cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_HEADERS:$$1' ./configure.ac | \
95 head -n 1 | while read f; do echo "$(srcdir)/$$f.in"; done`
97 # All modules should also be fine including the following variable, which
98 # removes automake-generated Makefile.in files:
99 GITIGNORE_MAINTAINERCLEANFILES_MAKEFILE_IN = \
100 `cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_FILES:$$1' ./configure.ac | \
102 case $$f in Makefile|*/Makefile) \
103 test -f "$(srcdir)/$$f.am" && echo "$(srcdir)/$$f.in";; esac; \
106 # Modules that use libtool and use AC_CONFIG_MACRO_DIR() may also include this,
107 # though it's harmless to include regardless.
108 GITIGNORE_MAINTAINERCLEANFILES_M4_LIBTOOL = \
109 `MACRO_DIR=$(srcdir)/$$(cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_MACRO_DIR:$$1' ./configure.ac); \
110 if test "x$$MACRO_DIR" != "x$(srcdir)/"; then \
117 ; do echo "$$MACRO_DIR/$$x"; done; \
122 ###############################################################################
123 # Default rule is to install ourselves in all Makefile.am files:
124 ###############################################################################
126 git-all: git-mk-install
129 @echo "Installing git makefile"
131 find "`test -z "$(top_srcdir)" && echo . || echo "$(top_srcdir)"`" -name Makefile.am | while read x; do \
132 if grep 'include .*/git.mk' $$x >/dev/null; then \
133 echo "$$x already includes git.mk"; \
136 echo "Updating $$x"; \
139 echo '-include $$(top_srcdir)/git.mk'; \
140 } > $$x.tmp || failed=1; \
141 if test x$$failed = x; then \
142 mv $$x.tmp $$x || failed=1; \
144 if test x$$failed = x; then : else \
145 echo "Failed updating $$x"; >&2 \
148 fi; done; test -z "$$any_failed"
150 .PHONY: git-all git-mk-install
154 ###############################################################################
155 # Actual .gitignore generation:
156 ###############################################################################
158 $(srcdir)/.gitignore: Makefile.am $(top_srcdir)/git.mk
159 @echo "git.mk: Generating $@"
161 if test "x$(DOC_MODULE)" = x -o "x$(DOC_MAIN_SGML_FILE)" = x; then :; else \
163 $(DOC_MODULE)-decl-list.txt \
164 $(DOC_MODULE)-decl.txt \
165 tmpl/$(DOC_MODULE)-unused.sgml \
168 ; do echo "/$$x"; done; \
169 FLAVOR=$$(cd $(top_srcdir); $(AUTOCONF) --trace 'GTK_DOC_CHECK:$$2' ./configure.ac); \
170 case $$FLAVOR in *no-tmpl*) echo /tmpl;; esac; \
172 if test "x$(DOC_MODULE)$(DOC_ID)" = x -o "x$(DOC_LINGUAS)" = x; then :; else \
173 for lc in $(DOC_LINGUAS); do \
175 $(if $(DOC_MODULE),$(DOC_MODULE).xml) \
178 ; do echo "/$$lc/$$x"; done; \
188 ; do echo /$$x; done; \
190 if test "x$(HELP_ID)" = x -o "x$(HELP_LINGUAS)" = x; then :; else \
191 for lc in $(HELP_LINGUAS); do \
196 ; do echo "/$$lc/$$x"; done; \
199 if test "x$(gsettings_SCHEMAS)" = x; then :; else \
201 $(gsettings_SCHEMAS:.xml=.valid) \
202 $(gsettings__enum_file) \
203 ; do echo "/$$x"; done; \
205 if test "x$(appdata_XML)" = x; then :; else \
207 $(appdata_XML:.xml=.valid) \
208 ; do echo "/$$x"; done; \
210 if test -f $(srcdir)/po/Makefile.in.in; then \
216 po/Makevars.template \
220 po/.intltool-merge-cache \
226 po/$(GETTEXT_PACKAGE).pot \
227 intltool-extract.in \
230 ; do echo "/$$x"; done; \
232 if test -f $(srcdir)/configure; then \
240 ; do echo "/$$x"; done; \
242 if test "x$(DEJATOOL)" = x; then :; else \
245 ; do echo "/$$x.sum"; echo "/$$x.log"; done; \
248 if test "x$(am__dirstamp)" = x; then :; else \
249 echo "$(am__dirstamp)"; \
251 if test "x$(LTCOMPILE)" = x -a "x$(GTKDOC_RUN)" = x; then :; else \
255 ; do echo "$$x"; done; \
261 $(PROGRAMS) $(check_PROGRAMS) $(EXTRA_PROGRAMS) \
262 $(LIBRARIES) $(check_LIBRARIES) $(EXTRA_LIBRARIES) \
263 $(LTLIBRARIES) $(check_LTLIBRARIES) $(EXTRA_LTLIBRARIES) \
265 $(MOSTLYCLEANFILES) \
267 $(TEST_LOGS:.log=.trs) \
273 $(am__CONFIG_DISTCLEAN_FILES) \
274 $(CONFIG_CLEAN_FILES) \
275 TAGS ID GTAGS GRTAGS GSYMS GPATH tags \
277 $(MAINTAINERCLEANFILES) \
280 $(patsubst %.vala,%.c,$(filter %.vala,$(SOURCES))) \
281 $(filter %_vala.stamp,$(DIST_COMMON)) \
282 $(filter %.vapi,$(DIST_COMMON)) \
283 $(filter $(addprefix %,$(notdir $(patsubst %.vapi,%.h,$(filter %.vapi,$(DIST_COMMON))))),$(DIST_COMMON)) \
292 ; do echo "/$$x"; done; \
294 sed "s@^/`echo "$(srcdir)" | sed 's/\(.\)/[\1]/g'`/@/@" | \
295 sed 's@/[.]/@/@g' | \
296 LC_ALL=C sort | uniq > $@.tmp && \
299 all: $(srcdir)/.gitignore gitignore-recurse-maybe
300 gitignore: $(srcdir)/.gitignore gitignore-recurse
302 gitignore-recurse-maybe:
303 @for subdir in $(DIST_SUBDIRS); do \
304 case " $(SUBDIRS) " in \
305 *" $$subdir "*) :;; \
306 *) test "$$subdir" = . -o -e "$$subdir/.git" || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) gitignore || echo "Skipping $$subdir");; \
310 @for subdir in $(DIST_SUBDIRS); do \
311 test "$$subdir" = . -o -e "$$subdir/.git" || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) gitignore || echo "Skipping $$subdir"); \
314 maintainer-clean: gitignore-clean
316 -rm -f $(srcdir)/.gitignore
318 .PHONY: gitignore-clean gitignore gitignore-recurse gitignore-recurse-maybe