3 # Copyright 2009, Red Hat, Inc.
4 # Copyright 2010,2011 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.
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
67 git-all: git-mk-install
70 @echo Installing git makefile
72 find "`test -z "$(top_srcdir)" && echo . || echo "$(top_srcdir)"`" -name Makefile.am | while read x; do \
73 if grep 'include .*/git.mk' $$x >/dev/null; then \
74 echo $$x already includes git.mk; \
77 echo "Updating $$x"; \
80 echo '-include $$(top_srcdir)/git.mk'; \
81 } > $$x.tmp || failed=1; \
82 if test x$$failed = x; then \
83 mv $$x.tmp $$x || failed=1; \
85 if test x$$failed = x; then : else \
86 echo Failed updating $$x; >&2 \
89 fi; done; test -z "$$any_failed"
91 .PHONY: git-all git-mk-install
94 ### .gitignore generation
96 $(srcdir)/.gitignore: Makefile.am $(top_srcdir)/git.mk
99 if test "x$(DOC_MODULE)" = x -o "x$(DOC_MAIN_SGML_FILE)" = x; then :; else \
101 $(DOC_MODULE)-decl-list.txt \
102 $(DOC_MODULE)-decl.txt \
103 tmpl/$(DOC_MODULE)-unused.sgml \
106 ; do echo /$$x; done; \
108 if test "x$(DOC_MODULE)$(DOC_ID)" = x -o "x$(DOC_LINGUAS)" = x; then :; else \
109 for lc in $(DOC_LINGUAS); do \
111 $(if $(DOC_MODULE),$(DOC_MODULE).xml) \
114 ; do echo /$$lc/$$x; done; \
124 ; do echo /$$x; done; \
126 if test "x$(HELP_ID)" = x -o "x$(HELP_LINGUAS)" = x; then :; else \
127 for lc in $(HELP_LINGUAS); do \
132 ; do echo /$$lc/$$x; done; \
135 if test "x$(gsettings_SCHEMAS)" = x; then :; else \
137 $(gsettings_SCHEMAS:.xml=.valid) \
138 $(gsettings__enum_file) \
139 ; do echo /$$x; done; \
141 if test -f $(srcdir)/po/Makefile.in.in; then \
148 po/.intltool-merge-cache \
151 po/$(GETTEXT_PACKAGE).pot \
152 intltool-extract.in \
155 ; do echo /$$x; done; \
157 if test -f $(srcdir)/configure; then \
165 ; do echo /$$x; done; \
167 if test "x$(DEJATOOL)" = x; then :; else \
170 ; do echo /$$x.sum; echo /$$x.log; done; \
177 $(PROGRAMS) $(check_PROGRAMS) $(EXTRA_PROGRAMS) \
178 $(LIBRARIES) $(check_LIBRARIES) $(EXTRA_LIBRARIES) \
179 $(LTLIBRARIES) $(check_LTLIBRARIES) $(EXTRA_LTLIBRARIES) \
182 $(MOSTLYCLEANFILES) \
186 $(am__CONFIG_DISTCLEAN_FILES) \
187 $(CONFIG_CLEAN_FILES) \
188 TAGS ID GTAGS GRTAGS GSYMS GPATH tags \
190 $(MAINTAINERCLEANFILES) \
201 ; do echo /$$x; done; \
203 sed "s@^/`echo "$(srcdir)" | sed 's/\(.\)/[\1]/g'`/@/@" | \
204 sed 's@/[.]/@/@g' | \
205 LC_ALL=C sort | uniq > $@.tmp && \
208 all: $(srcdir)/.gitignore gitignore-recurse-maybe
209 gitignore: $(srcdir)/.gitignore gitignore-recurse
211 gitignore-recurse-maybe:
212 @for subdir in $(DIST_SUBDIRS); do \
213 case " $(SUBDIRS) " in \
214 *" $$subdir "*) :;; \
215 *) test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) .gitignore gitignore-recurse-maybe || echo "Skipping $$subdir");; \
219 @for subdir in $(DIST_SUBDIRS); do \
220 test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) .gitignore gitignore-recurse || echo "Skipping $$subdir"); \
223 maintainer-clean: gitignore-clean
225 -rm -f $(srcdir)/.gitignore
227 .PHONY: gitignore-clean gitignore gitignore-recurse gitignore-recurse-maybe