blob: 2fa799d19e318cf53032122af22f277d4bff471a [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 \
78 $(srcdir)/autoscan.log \
Behdad Esfahbod22c625a2013-03-04 20:56:15 -050079 $(srcdir)/configure.scan \
Behdad Esfahboddddf9902013-08-26 17:58:25 -040080 `AUX_DIR=$(srcdir)/$$(cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_AUX_DIR:$$1' ./configure.ac); \
Behdad Esfahbod627af692013-08-06 16:53:56 -040081 test "x$$AUX_DIR" = "x$(srcdir)/" && AUX_DIR=$(srcdir); \
82 for x in \
Behdad Esfahbod72225272013-08-06 15:19:23 -040083 ar-lib \
84 compile \
85 config.guess \
86 config.sub \
87 depcomp \
88 install-sh \
89 ltmain.sh \
90 missing \
91 mkinstalldirs \
92 ; do echo "$$AUX_DIR/$$x"; done` \
Behdad Esfahboddddf9902013-08-26 17:58:25 -040093 `cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_HEADERS:$$1' ./configure.ac | \
Behdad Esfahbod72225272013-08-06 15:19:23 -040094 head -n 1 | while read f; do echo "$(srcdir)/$$f.in"; done`
Behdad Esfahbod22c625a2013-03-04 20:56:15 -050095#
96# All modules should also be fine including the following variable, which
97# removes automake-generated Makefile.in files:
98GITIGNORE_MAINTAINERCLEANFILES_MAKEFILE_IN = \
Behdad Esfahboddddf9902013-08-26 17:58:25 -040099 `cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_FILES:$$1' ./configure.ac | \
Behdad Esfahbod22c625a2013-03-04 20:56:15 -0500100 while read f; do \
101 case $$f in Makefile|*/Makefile) \
102 test -f "$(srcdir)/$$f.am" && echo "$(srcdir)/$$f.in";; esac; \
103 done`
104#
105# Modules that use libtool /and/ use AC_CONFIG_MACRO_DIR([m4]) may also
106# include this:
107GITIGNORE_MAINTAINERCLEANFILES_M4_LIBTOOL = \
108 $(srcdir)/m4/libtool.m4 \
109 $(srcdir)/m4/ltoptions.m4 \
110 $(srcdir)/m4/ltsugar.m4 \
111 $(srcdir)/m4/ltversion.m4 \
112 $(srcdir)/m4/lt~obsolete.m4
113
114
115
116###############################################################################
117# Default rule is to install ourselves in all Makefile.am files:
118###############################################################################
119
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500120git-all: git-mk-install
121
122git-mk-install:
Behdad Esfahbod36a661c2013-04-11 13:38:37 -0400123 @echo "Installing git makefile"
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500124 @any_failed=; \
125 find "`test -z "$(top_srcdir)" && echo . || echo "$(top_srcdir)"`" -name Makefile.am | while read x; do \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500126 if grep 'include .*/git.mk' $$x >/dev/null; then \
Behdad Esfahbod36a661c2013-04-11 13:38:37 -0400127 echo "$$x already includes git.mk"; \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500128 else \
129 failed=; \
130 echo "Updating $$x"; \
131 { cat $$x; \
132 echo ''; \
133 echo '-include $$(top_srcdir)/git.mk'; \
134 } > $$x.tmp || failed=1; \
135 if test x$$failed = x; then \
136 mv $$x.tmp $$x || failed=1; \
137 fi; \
138 if test x$$failed = x; then : else \
Behdad Esfahbod36a661c2013-04-11 13:38:37 -0400139 echo "Failed updating $$x"; >&2 \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500140 any_failed=1; \
141 fi; \
142 fi; done; test -z "$$any_failed"
143
144.PHONY: git-all git-mk-install
145
146
Behdad Esfahbod22c625a2013-03-04 20:56:15 -0500147
148###############################################################################
149# Actual .gitignore generation:
150###############################################################################
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500151
152$(srcdir)/.gitignore: Makefile.am $(top_srcdir)/git.mk
Behdad Esfahbod72225272013-08-06 15:19:23 -0400153 @echo "git.mk: Generating $@"
154 @{ \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500155 if test "x$(DOC_MODULE)" = x -o "x$(DOC_MAIN_SGML_FILE)" = x; then :; else \
156 for x in \
157 $(DOC_MODULE)-decl-list.txt \
158 $(DOC_MODULE)-decl.txt \
159 tmpl/$(DOC_MODULE)-unused.sgml \
160 "tmpl/*.bak" \
161 xml html \
Behdad Esfahbod36a661c2013-04-11 13:38:37 -0400162 ; do echo "/$$x"; done; \
Behdad Esfahboddddf9902013-08-26 17:58:25 -0400163 FLAVOR=$$(cd $(top_srcdir); $(AUTOCONF) --trace 'GTK_DOC_CHECK:$$2' ./configure.ac); \
164 case $$FLAVOR in *no-tmpl*) echo /tmpl;; esac; \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500165 fi; \
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500166 if test "x$(DOC_MODULE)$(DOC_ID)" = x -o "x$(DOC_LINGUAS)" = x; then :; else \
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400167 for lc in $(DOC_LINGUAS); do \
168 for x in \
169 $(if $(DOC_MODULE),$(DOC_MODULE).xml) \
170 $(DOC_PAGES) \
171 $(DOC_INCLUDES) \
Behdad Esfahbod36a661c2013-04-11 13:38:37 -0400172 ; do echo "/$$lc/$$x"; done; \
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400173 done; \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500174 for x in \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500175 $(_DOC_OMF_ALL) \
176 $(_DOC_DSK_ALL) \
177 $(_DOC_HTML_ALL) \
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500178 $(_DOC_MOFILES) \
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500179 $(DOC_H_FILE) \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500180 "*/.xml2po.mo" \
181 "*/*.omf.out" \
182 ; do echo /$$x; done; \
183 fi; \
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500184 if test "x$(HELP_ID)" = x -o "x$(HELP_LINGUAS)" = x; then :; else \
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400185 for lc in $(HELP_LINGUAS); do \
186 for x in \
187 $(HELP_FILES) \
188 "$$lc.stamp" \
189 "$$lc.mo" \
Behdad Esfahbod36a661c2013-04-11 13:38:37 -0400190 ; do echo "/$$lc/$$x"; done; \
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400191 done; \
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500192 fi; \
193 if test "x$(gsettings_SCHEMAS)" = x; then :; else \
194 for x in \
195 $(gsettings_SCHEMAS:.xml=.valid) \
196 $(gsettings__enum_file) \
Behdad Esfahbod36a661c2013-04-11 13:38:37 -0400197 ; do echo "/$$x"; done; \
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500198 fi; \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500199 if test -f $(srcdir)/po/Makefile.in.in; then \
200 for x in \
201 po/Makefile.in.in \
Behdad Esfahbod72225272013-08-06 15:19:23 -0400202 po/Makefile.in.in~ \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500203 po/Makefile.in \
204 po/Makefile \
Behdad Esfahbod72225272013-08-06 15:19:23 -0400205 po/Makevars.template \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500206 po/POTFILES \
Behdad Esfahbod72225272013-08-06 15:19:23 -0400207 po/Rules-quot \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500208 po/stamp-it \
209 po/.intltool-merge-cache \
210 "po/*.gmo" \
Behdad Esfahbod72225272013-08-06 15:19:23 -0400211 "po/*.header" \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500212 "po/*.mo" \
Behdad Esfahbod72225272013-08-06 15:19:23 -0400213 "po/*.sed" \
214 "po/*.sin" \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500215 po/$(GETTEXT_PACKAGE).pot \
216 intltool-extract.in \
217 intltool-merge.in \
218 intltool-update.in \
Behdad Esfahbod36a661c2013-04-11 13:38:37 -0400219 ; do echo "/$$x"; done; \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500220 fi; \
221 if test -f $(srcdir)/configure; then \
222 for x in \
223 autom4te.cache \
224 configure \
225 config.h \
226 stamp-h1 \
227 libtool \
228 config.lt \
Behdad Esfahbod36a661c2013-04-11 13:38:37 -0400229 ; do echo "/$$x"; done; \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500230 fi; \
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400231 if test "x$(DEJATOOL)" = x; then :; else \
232 for x in \
233 $(DEJATOOL) \
Behdad Esfahbod36a661c2013-04-11 13:38:37 -0400234 ; do echo "/$$x.sum"; echo "/$$x.log"; done; \
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400235 echo /site.exp; \
236 fi; \
Behdad Esfahbod36a661c2013-04-11 13:38:37 -0400237 if test "x$(am__dirstamp)" = x; then :; else \
238 echo "$(am__dirstamp)"; \
239 fi; \
Behdad Esfahboddddf9902013-08-26 17:58:25 -0400240 if test "x$(LTCOMPILE)" = x -a "x$(GTKDOC_RUN)" = x; then :; else \
Behdad Esfahbod36a661c2013-04-11 13:38:37 -0400241 for x in \
242 "*.lo" \
243 ".libs" "_libs" \
244 ; do echo "$$x"; done; \
245 fi; \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500246 for x in \
247 .gitignore \
248 $(GITIGNOREFILES) \
249 $(CLEANFILES) \
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400250 $(PROGRAMS) $(check_PROGRAMS) $(EXTRA_PROGRAMS) \
251 $(LIBRARIES) $(check_LIBRARIES) $(EXTRA_LIBRARIES) \
252 $(LTLIBRARIES) $(check_LTLIBRARIES) $(EXTRA_LTLIBRARIES) \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500253 so_locations \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500254 $(MOSTLYCLEANFILES) \
Behdad Esfahboddddf9902013-08-26 17:58:25 -0400255 $(TEST_LOGS) \
256 $(TEST_LOGS:.log=.trs) \
257 $(TEST_SUITE_LOG) \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500258 "*.$(OBJEXT)" \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500259 $(DISTCLEANFILES) \
260 $(am__CONFIG_DISTCLEAN_FILES) \
261 $(CONFIG_CLEAN_FILES) \
262 TAGS ID GTAGS GRTAGS GSYMS GPATH tags \
263 "*.tab.c" \
264 $(MAINTAINERCLEANFILES) \
265 $(BUILT_SOURCES) \
266 $(DEPDIR) \
Behdad Esfahboddddf9902013-08-26 17:58:25 -0400267 $(patsubst %.vala,%.c,$(filter %.vala,$(SOURCES))) \
268 $(filter %_vala.stamp,$(DIST_COMMON)) \
269 $(filter %.vapi,$(DIST_COMMON)) \
270 $(patsubst %.vapi,%.h,$(filter %.vapi,$(DIST_COMMON))) \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500271 Makefile \
272 Makefile.in \
273 "*.orig" \
274 "*.rej" \
275 "*.bak" \
276 "*~" \
277 ".*.sw[nop]" \
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500278 ".dirstamp" \
Behdad Esfahbod36a661c2013-04-11 13:38:37 -0400279 ; do echo "/$$x"; done; \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500280 } | \
281 sed "s@^/`echo "$(srcdir)" | sed 's/\(.\)/[\1]/g'`/@/@" | \
282 sed 's@/[.]/@/@g' | \
283 LC_ALL=C sort | uniq > $@.tmp && \
284 mv $@.tmp $@;
285
286all: $(srcdir)/.gitignore gitignore-recurse-maybe
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400287gitignore: $(srcdir)/.gitignore gitignore-recurse
288
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500289gitignore-recurse-maybe:
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500290 @for subdir in $(DIST_SUBDIRS); do \
291 case " $(SUBDIRS) " in \
292 *" $$subdir "*) :;; \
Behdad Esfahbod72225272013-08-06 15:19:23 -0400293 *) test "$$subdir" = . -o -e "$$subdir/.git" || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) gitignore || echo "Skipping $$subdir");; \
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500294 esac; \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500295 done
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400296gitignore-recurse:
297 @for subdir in $(DIST_SUBDIRS); do \
Behdad Esfahbod72225272013-08-06 15:19:23 -0400298 test "$$subdir" = . -o -e "$$subdir/.git" || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) gitignore || echo "Skipping $$subdir"); \
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400299 done
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500300
301maintainer-clean: gitignore-clean
302gitignore-clean:
303 -rm -f $(srcdir)/.gitignore
304
305.PHONY: gitignore-clean gitignore gitignore-recurse gitignore-recurse-maybe