blob: 6b9c7d79a39d72d3d269d39077b91966e9253cc0 [file] [log] [blame]
Behdad Esfahbod29aa4002009-11-02 16:28:39 -05001# git.mk
2#
3# Copyright 2009, Red Hat, Inc.
Behdad Esfahbod22c625a2013-03-04 20:56:15 -05004# Copyright 2010,2011,2012,2013 Behdad Esfahbod
Behdad Esfahbod29aa4002009-11-02 16:28:39 -05005# Written by Behdad Esfahbod
6#
7# Copying and distribution of this file, with or without modification,
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -04008# is permitted in any medium without royalty provided the copyright
Behdad Esfahbod29aa4002009-11-02 16:28:39 -05009# notice and this notice are preserved.
10#
Behdad Esfahbod22c625a2013-03-04 20:56:15 -050011# 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
Behdad Esfahbod29aa4002009-11-02 16:28:39 -050015#
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
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -050018# 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
20# "make -f git.mk".
Behdad Esfahbod29aa4002009-11-02 16:28:39 -050021#
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.
27#
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,
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -050030# or maintainer-clean-local make targets.
Behdad Esfahbod29aa4002009-11-02 16:28:39 -050031#
32# Note that for files like editor backup, etc, there are better places to
33# ignore them. See "man gitignore".
34#
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
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -050038# the directories involved and I'll diagnose.
Behdad Esfahbod29aa4002009-11-02 16:28:39 -050039#
40# For a list of toplevel files that should be in MAINTAINERCLEANFILES, see
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -050041# Makefile.am.sample in the git.mk git repo.
Behdad Esfahbod29aa4002009-11-02 16:28:39 -050042#
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
45# build dir.
46#
47# This file knows how to handle autoconf, automake, libtool, gtk-doc,
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -040048# gnome-doc-utils, yelp.m4, mallard, intltool, gsettings, dejagnu.
Behdad Esfahbod29aa4002009-11-02 16:28:39 -050049#
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -040050# This makefile provides the following targets:
51#
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.
Behdad Esfahbod29aa4002009-11-02 16:28:39 -050056#
57# KNOWN ISSUES:
58#
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
64# example.
65#
66
Behdad Esfahbod22c625a2013-03-04 20:56:15 -050067
68
69###############################################################################
70# Variables user modules may want to add to toplevel MAINTAINERCLEANFILES:
71###############################################################################
72
73#
74# Most autotools-using modules should be fine including this variable in their
75# toplevel MAINTAINERCLEANFILES:
76GITIGNORE_MAINTAINERCLEANFILES_TOPLEVEL = \
77 $(srcdir)/aclocal.m4 \
Behdad Esfahbod4d4fc922013-04-05 17:58:25 -040078 $(srcdir)/ar-lib \
Behdad Esfahbod22c625a2013-03-04 20:56:15 -050079 $(srcdir)/autoscan.log \
80 $(srcdir)/compile \
81 $(srcdir)/config.guess \
82 $(srcdir)/config.h.in \
83 $(srcdir)/config.sub \
84 $(srcdir)/configure.scan \
85 $(srcdir)/depcomp \
86 $(srcdir)/install-sh \
87 $(srcdir)/ltmain.sh \
88 $(srcdir)/missing \
89 $(srcdir)/mkinstalldirs
90#
91# All modules should also be fine including the following variable, which
92# removes automake-generated Makefile.in files:
93GITIGNORE_MAINTAINERCLEANFILES_MAKEFILE_IN = \
94 `$(AUTOCONF) --trace 'AC_CONFIG_FILES:$$1' $(srcdir)/configure.ac | \
95 while read f; do \
96 case $$f in Makefile|*/Makefile) \
97 test -f "$(srcdir)/$$f.am" && echo "$(srcdir)/$$f.in";; esac; \
98 done`
99#
100# Modules that use libtool /and/ use AC_CONFIG_MACRO_DIR([m4]) may also
101# include this:
102GITIGNORE_MAINTAINERCLEANFILES_M4_LIBTOOL = \
103 $(srcdir)/m4/libtool.m4 \
104 $(srcdir)/m4/ltoptions.m4 \
105 $(srcdir)/m4/ltsugar.m4 \
106 $(srcdir)/m4/ltversion.m4 \
107 $(srcdir)/m4/lt~obsolete.m4
108
109
110
111###############################################################################
112# Default rule is to install ourselves in all Makefile.am files:
113###############################################################################
114
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500115git-all: git-mk-install
116
117git-mk-install:
118 @echo Installing git makefile
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500119 @any_failed=; \
120 find "`test -z "$(top_srcdir)" && echo . || echo "$(top_srcdir)"`" -name Makefile.am | while read x; do \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500121 if grep 'include .*/git.mk' $$x >/dev/null; then \
122 echo $$x already includes git.mk; \
123 else \
124 failed=; \
125 echo "Updating $$x"; \
126 { cat $$x; \
127 echo ''; \
128 echo '-include $$(top_srcdir)/git.mk'; \
129 } > $$x.tmp || failed=1; \
130 if test x$$failed = x; then \
131 mv $$x.tmp $$x || failed=1; \
132 fi; \
133 if test x$$failed = x; then : else \
134 echo Failed updating $$x; >&2 \
135 any_failed=1; \
136 fi; \
137 fi; done; test -z "$$any_failed"
138
139.PHONY: git-all git-mk-install
140
141
Behdad Esfahbod22c625a2013-03-04 20:56:15 -0500142
143###############################################################################
144# Actual .gitignore generation:
145###############################################################################
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500146
147$(srcdir)/.gitignore: Makefile.am $(top_srcdir)/git.mk
148 $(AM_V_GEN) \
149 { \
150 if test "x$(DOC_MODULE)" = x -o "x$(DOC_MAIN_SGML_FILE)" = x; then :; else \
151 for x in \
152 $(DOC_MODULE)-decl-list.txt \
153 $(DOC_MODULE)-decl.txt \
154 tmpl/$(DOC_MODULE)-unused.sgml \
155 "tmpl/*.bak" \
156 xml html \
157 ; do echo /$$x; done; \
158 fi; \
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500159 if test "x$(DOC_MODULE)$(DOC_ID)" = x -o "x$(DOC_LINGUAS)" = x; then :; else \
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400160 for lc in $(DOC_LINGUAS); do \
161 for x in \
162 $(if $(DOC_MODULE),$(DOC_MODULE).xml) \
163 $(DOC_PAGES) \
164 $(DOC_INCLUDES) \
165 ; do echo /$$lc/$$x; done; \
166 done; \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500167 for x in \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500168 $(_DOC_OMF_ALL) \
169 $(_DOC_DSK_ALL) \
170 $(_DOC_HTML_ALL) \
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500171 $(_DOC_MOFILES) \
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500172 $(DOC_H_FILE) \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500173 "*/.xml2po.mo" \
174 "*/*.omf.out" \
175 ; do echo /$$x; done; \
176 fi; \
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500177 if test "x$(HELP_ID)" = x -o "x$(HELP_LINGUAS)" = x; then :; else \
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400178 for lc in $(HELP_LINGUAS); do \
179 for x in \
180 $(HELP_FILES) \
181 "$$lc.stamp" \
182 "$$lc.mo" \
183 ; do echo /$$lc/$$x; done; \
184 done; \
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500185 fi; \
186 if test "x$(gsettings_SCHEMAS)" = x; then :; else \
187 for x in \
188 $(gsettings_SCHEMAS:.xml=.valid) \
189 $(gsettings__enum_file) \
190 ; do echo /$$x; done; \
191 fi; \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500192 if test -f $(srcdir)/po/Makefile.in.in; then \
193 for x in \
194 po/Makefile.in.in \
195 po/Makefile.in \
196 po/Makefile \
197 po/POTFILES \
198 po/stamp-it \
199 po/.intltool-merge-cache \
200 "po/*.gmo" \
201 "po/*.mo" \
202 po/$(GETTEXT_PACKAGE).pot \
203 intltool-extract.in \
204 intltool-merge.in \
205 intltool-update.in \
206 ; do echo /$$x; done; \
207 fi; \
208 if test -f $(srcdir)/configure; then \
209 for x in \
210 autom4te.cache \
211 configure \
212 config.h \
213 stamp-h1 \
214 libtool \
215 config.lt \
216 ; do echo /$$x; done; \
217 fi; \
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400218 if test "x$(DEJATOOL)" = x; then :; else \
219 for x in \
220 $(DEJATOOL) \
221 ; do echo /$$x.sum; echo /$$x.log; done; \
222 echo /site.exp; \
223 fi; \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500224 for x in \
225 .gitignore \
226 $(GITIGNOREFILES) \
227 $(CLEANFILES) \
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400228 $(PROGRAMS) $(check_PROGRAMS) $(EXTRA_PROGRAMS) \
229 $(LIBRARIES) $(check_LIBRARIES) $(EXTRA_LIBRARIES) \
230 $(LTLIBRARIES) $(check_LTLIBRARIES) $(EXTRA_LTLIBRARIES) \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500231 so_locations \
232 .libs _libs \
233 $(MOSTLYCLEANFILES) \
234 "*.$(OBJEXT)" \
235 "*.lo" \
236 $(DISTCLEANFILES) \
237 $(am__CONFIG_DISTCLEAN_FILES) \
238 $(CONFIG_CLEAN_FILES) \
239 TAGS ID GTAGS GRTAGS GSYMS GPATH tags \
240 "*.tab.c" \
241 $(MAINTAINERCLEANFILES) \
242 $(BUILT_SOURCES) \
243 $(DEPDIR) \
244 Makefile \
245 Makefile.in \
246 "*.orig" \
247 "*.rej" \
248 "*.bak" \
249 "*~" \
250 ".*.sw[nop]" \
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500251 ".dirstamp" \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500252 ; do echo /$$x; done; \
253 } | \
254 sed "s@^/`echo "$(srcdir)" | sed 's/\(.\)/[\1]/g'`/@/@" | \
255 sed 's@/[.]/@/@g' | \
256 LC_ALL=C sort | uniq > $@.tmp && \
257 mv $@.tmp $@;
258
259all: $(srcdir)/.gitignore gitignore-recurse-maybe
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400260gitignore: $(srcdir)/.gitignore gitignore-recurse
261
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500262gitignore-recurse-maybe:
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500263 @for subdir in $(DIST_SUBDIRS); do \
264 case " $(SUBDIRS) " in \
265 *" $$subdir "*) :;; \
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400266 *) test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) .gitignore gitignore-recurse-maybe || echo "Skipping $$subdir");; \
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500267 esac; \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500268 done
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400269gitignore-recurse:
270 @for subdir in $(DIST_SUBDIRS); do \
271 test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) .gitignore gitignore-recurse || echo "Skipping $$subdir"); \
272 done
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500273
274maintainer-clean: gitignore-clean
275gitignore-clean:
276 -rm -f $(srcdir)/.gitignore
277
278.PHONY: gitignore-clean gitignore gitignore-recurse gitignore-recurse-maybe