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 GIT_MK_URL = https://raw.githubusercontent.com/behdad/git.mk/master/git.mk
14 # Bugs, etc, should be reported upstream at:
15 # https://github.com/behdad/git.mk
17 # To use in your project, import this file in your git repo's toplevel,
18 # then do "make -f git.mk". This modifies all Makefile.am files in
19 # your project to -include git.mk. Remember to add that line to new
20 # Makefile.am files you create in your project, or just rerun the
23 # This enables automatic .gitignore generation. If you need to ignore
24 # more files, add them to the GITIGNOREFILES variable in your Makefile.am.
25 # But think twice before doing that. If a file has to be in .gitignore,
26 # chances are very high that it's a generated file and should be in one
27 # of MOSTLYCLEANFILES, CLEANFILES, DISTCLEANFILES, or MAINTAINERCLEANFILES.
29 # The only case that you need to manually add a file to GITIGNOREFILES is
30 # when remove files in one of mostlyclean-local, clean-local, distclean-local,
31 # or maintainer-clean-local make targets.
33 # Note that for files like editor backup, etc, there are better places to
34 # ignore them. See "man gitignore".
36 # If "make maintainer-clean" removes the files but they are not recognized
37 # by this script (that is, if "git status" shows untracked files still), send
38 # me the output of "git status" as well as your Makefile.am and Makefile for
39 # the directories involved and I'll diagnose.
41 # For a list of toplevel files that should be in MAINTAINERCLEANFILES, see
42 # Makefile.am.sample in the git.mk git repo.
44 # Don't EXTRA_DIST this file. It is supposed to only live in git clones,
45 # not tarballs. It serves no useful purpose in tarballs and clutters the
48 # This file knows how to handle autoconf, automake, libtool, gtk-doc,
49 # gnome-doc-utils, yelp.m4, mallard, intltool, gsettings, dejagnu, appdata,
52 # This makefile provides the following targets:
54 # - all: "make all" will build all gitignore files.
55 # - gitignore: makes all gitignore files in the current dir and subdirs.
56 # - .gitignore: make gitignore file for the current dir.
57 # - gitignore-recurse: makes all gitignore files in the subdirs.
61 # - Recursive configure doesn't work as $(top_srcdir)/git.mk inside the
62 # submodule doesn't find us. If you have configure.{in,ac} files in
63 # subdirs, add a proxy git.mk file in those dirs that simply does:
64 # "include $(top_srcdir)/../git.mk". Add more ..'s to your taste.
65 # And add those files to git. See vte/gnome-pty-helper/git.mk for
71 ###############################################################################
72 # Variables user modules may want to add to toplevel MAINTAINERCLEANFILES:
73 ###############################################################################
76 # Most autotools-using modules should be fine including this variable in their
77 # toplevel MAINTAINERCLEANFILES:
78 GITIGNORE_MAINTAINERCLEANFILES_TOPLEVEL = \
79 $(srcdir)/aclocal.m4 \
80 $(srcdir)/autoscan.log \
81 $(srcdir)/configure.scan \
82 `AUX_DIR=$(srcdir)/$$(cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_AUX_DIR:$$1' ./configure.ac); \
83 test "x$$AUX_DIR" = "x$(srcdir)/" && AUX_DIR=$(srcdir); \
96 ; do echo "$$AUX_DIR/$$x"; done` \
97 `cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_HEADERS:$$1' ./configure.ac | \
98 head -n 1 | while read f; do echo "$(srcdir)/$$f.in"; done`
100 # All modules should also be fine including the following variable, which
101 # removes automake-generated Makefile.in files:
102 GITIGNORE_MAINTAINERCLEANFILES_MAKEFILE_IN = \
103 `cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_FILES:$$1' ./configure.ac | \
105 case $$f in Makefile|*/Makefile) \
106 test -f "$(srcdir)/$$f.am" && echo "$(srcdir)/$$f.in";; esac; \
109 # Modules that use libtool and use AC_CONFIG_MACRO_DIR() may also include this,
110 # though it's harmless to include regardless.
111 GITIGNORE_MAINTAINERCLEANFILES_M4_LIBTOOL = \
112 `MACRO_DIR=$(srcdir)/$$(cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_MACRO_DIR:$$1' ./configure.ac); \
113 if test "x$$MACRO_DIR" != "x$(srcdir)/"; then \
120 ; do echo "$$MACRO_DIR/$$x"; done; \
125 ###############################################################################
126 # Default rule is to install ourselves in all Makefile.am files:
127 ###############################################################################
129 git-all: git-mk-install
132 @echo "Installing git makefile"
134 find "`test -z "$(top_srcdir)" && echo . || echo "$(top_srcdir)"`" -name Makefile.am | while read x; do \
135 if grep 'include .*/git.mk' $$x >/dev/null; then \
136 echo "$$x already includes git.mk"; \
139 echo "Updating $$x"; \
142 echo '-include $$(top_srcdir)/git.mk'; \
143 } > $$x.tmp || failed=1; \
144 if test x$$failed = x; then \
145 mv $$x.tmp $$x || failed=1; \
147 if test x$$failed = x; then : else \
148 echo "Failed updating $$x"; >&2 \
151 fi; done; test -z "$$any_failed"
154 wget $(GIT_MK_URL) -O $(top_srcdir)/git.mk
156 .PHONY: git-all git-mk-install git-mk-update
160 ###############################################################################
161 # Actual .gitignore generation:
162 ###############################################################################
164 $(srcdir)/.gitignore: Makefile.am $(top_srcdir)/git.mk
165 @echo "git.mk: Generating $@"
167 if test "x$(DOC_MODULE)" = x -o "x$(DOC_MAIN_SGML_FILE)" = x; then :; else \
169 $(DOC_MODULE)-decl-list.txt \
170 $(DOC_MODULE)-decl.txt \
171 tmpl/$(DOC_MODULE)-unused.sgml \
174 ; do echo "/$$x"; done; \
175 FLAVOR=$$(cd $(top_srcdir); $(AUTOCONF) --trace 'GTK_DOC_CHECK:$$2' ./configure.ac); \
176 case $$FLAVOR in *no-tmpl*) echo /tmpl;; esac; \
178 if test "x$(DOC_MODULE)$(DOC_ID)" = x -o "x$(DOC_LINGUAS)" = x; then :; else \
179 for lc in $(DOC_LINGUAS); do \
181 $(if $(DOC_MODULE),$(DOC_MODULE).xml) \
184 ; do echo "/$$lc/$$x"; done; \
194 ; do echo /$$x; done; \
196 if test "x$(HELP_ID)" = x -o "x$(HELP_LINGUAS)" = x; then :; else \
197 for lc in $(HELP_LINGUAS); do \
202 ; do echo "/$$lc/$$x"; done; \
205 if test "x$(gsettings_SCHEMAS)" = x; then :; else \
207 $(gsettings_SCHEMAS:.xml=.valid) \
208 $(gsettings__enum_file) \
209 ; do echo "/$$x"; done; \
211 if test "x$(appdata_XML)" = x; then :; else \
213 $(appdata_XML:.xml=.valid) \
214 ; do echo "/$$x"; done; \
216 if test "x$(appstream_XML)" = x; then :; else \
218 $(appstream_XML:.xml=.valid) \
219 ; do echo "/$$x"; done; \
221 if test -f $(srcdir)/po/Makefile.in.in; then \
227 po/Makevars.template \
231 po/.intltool-merge-cache \
237 po/$(GETTEXT_PACKAGE).pot \
238 intltool-extract.in \
241 ; do echo "/$$x"; done; \
243 if test -f $(srcdir)/configure; then \
251 ; do echo "/$$x"; done; \
253 if test "x$(DEJATOOL)" = x; then :; else \
256 ; do echo "/$$x.sum"; echo "/$$x.log"; done; \
259 if test "x$(am__dirstamp)" = x; then :; else \
260 echo "$(am__dirstamp)"; \
262 if test "x$(LTCOMPILE)" = x -a "x$(LTCXXCOMPILE)" = x -a "x$(GTKDOC_RUN)" = x; then :; else \
266 ; do echo "$$x"; done; \
272 $(PROGRAMS) $(check_PROGRAMS) $(EXTRA_PROGRAMS) \
273 $(LIBRARIES) $(check_LIBRARIES) $(EXTRA_LIBRARIES) \
274 $(LTLIBRARIES) $(check_LTLIBRARIES) $(EXTRA_LTLIBRARIES) \
276 $(MOSTLYCLEANFILES) \
278 $(TEST_LOGS:.log=.trs) \
284 $(am__CONFIG_DISTCLEAN_FILES) \
285 $(CONFIG_CLEAN_FILES) \
286 TAGS ID GTAGS GRTAGS GSYMS GPATH tags \
288 $(MAINTAINERCLEANFILES) \
290 $(patsubst %.vala,%.c,$(filter %.vala,$(SOURCES))) \
291 $(filter %_vala.stamp,$(DIST_COMMON)) \
292 $(filter %.vapi,$(DIST_COMMON)) \
293 $(filter $(addprefix %,$(notdir $(patsubst %.vapi,%.h,$(filter %.vapi,$(DIST_COMMON))))),$(DIST_COMMON)) \
302 ; do echo "/$$x"; done; \
306 ; do echo "$$x"; done; \
308 sed "s@^/`echo "$(srcdir)" | sed 's/\(.\)/[\1]/g'`/@/@" | \
309 sed 's@/[.]/@/@g' | \
310 LC_ALL=C sort | uniq > $@.tmp && \
313 all: $(srcdir)/.gitignore gitignore-recurse-maybe
314 gitignore: $(srcdir)/.gitignore gitignore-recurse
316 gitignore-recurse-maybe:
317 @for subdir in $(DIST_SUBDIRS); do \
318 case " $(SUBDIRS) " in \
319 *" $$subdir "*) :;; \
320 *) test "$$subdir" = . -o -e "$$subdir/.git" || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) gitignore || echo "Skipping $$subdir");; \
324 @for subdir in $(DIST_SUBDIRS); do \
325 test "$$subdir" = . -o -e "$$subdir/.git" || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) gitignore || echo "Skipping $$subdir"); \
328 maintainer-clean: gitignore-clean
330 -rm -f $(srcdir)/.gitignore
332 .PHONY: gitignore-clean gitignore gitignore-recurse gitignore-recurse-maybe