blob: b68e54365b3e00df63c4b6d32522a557e61cce58 [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 Esfahbod72225272013-08-06 15:19:23 -040080 `AUX_DIR=$(srcdir)/$$($(AUTOCONF) --trace 'AC_CONFIG_AUX_DIR:$$1' $(srcdir)/configure.ac); for x in \
81 ar-lib \
82 compile \
83 config.guess \
84 config.sub \
85 depcomp \
86 install-sh \
87 ltmain.sh \
88 missing \
89 mkinstalldirs \
90 ; do echo "$$AUX_DIR/$$x"; done` \
91 `$(AUTOCONF) --trace 'AC_CONFIG_HEADERS:$$1' $(srcdir)/configure.ac | \
92 head -n 1 | while read f; do echo "$(srcdir)/$$f.in"; done`
Behdad Esfahbod22c625a2013-03-04 20:56:15 -050093#
94# All modules should also be fine including the following variable, which
95# removes automake-generated Makefile.in files:
96GITIGNORE_MAINTAINERCLEANFILES_MAKEFILE_IN = \
97 `$(AUTOCONF) --trace 'AC_CONFIG_FILES:$$1' $(srcdir)/configure.ac | \
98 while read f; do \
99 case $$f in Makefile|*/Makefile) \
100 test -f "$(srcdir)/$$f.am" && echo "$(srcdir)/$$f.in";; esac; \
101 done`
102#
103# Modules that use libtool /and/ use AC_CONFIG_MACRO_DIR([m4]) may also
104# include this:
105GITIGNORE_MAINTAINERCLEANFILES_M4_LIBTOOL = \
106 $(srcdir)/m4/libtool.m4 \
107 $(srcdir)/m4/ltoptions.m4 \
108 $(srcdir)/m4/ltsugar.m4 \
109 $(srcdir)/m4/ltversion.m4 \
110 $(srcdir)/m4/lt~obsolete.m4
111
112
113
114###############################################################################
115# Default rule is to install ourselves in all Makefile.am files:
116###############################################################################
117
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500118git-all: git-mk-install
119
120git-mk-install:
Behdad Esfahbod36a661c2013-04-11 13:38:37 -0400121 @echo "Installing git makefile"
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500122 @any_failed=; \
123 find "`test -z "$(top_srcdir)" && echo . || echo "$(top_srcdir)"`" -name Makefile.am | while read x; do \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500124 if grep 'include .*/git.mk' $$x >/dev/null; then \
Behdad Esfahbod36a661c2013-04-11 13:38:37 -0400125 echo "$$x already includes git.mk"; \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500126 else \
127 failed=; \
128 echo "Updating $$x"; \
129 { cat $$x; \
130 echo ''; \
131 echo '-include $$(top_srcdir)/git.mk'; \
132 } > $$x.tmp || failed=1; \
133 if test x$$failed = x; then \
134 mv $$x.tmp $$x || failed=1; \
135 fi; \
136 if test x$$failed = x; then : else \
Behdad Esfahbod36a661c2013-04-11 13:38:37 -0400137 echo "Failed updating $$x"; >&2 \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500138 any_failed=1; \
139 fi; \
140 fi; done; test -z "$$any_failed"
141
142.PHONY: git-all git-mk-install
143
144
Behdad Esfahbod22c625a2013-03-04 20:56:15 -0500145
146###############################################################################
147# Actual .gitignore generation:
148###############################################################################
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500149
150$(srcdir)/.gitignore: Makefile.am $(top_srcdir)/git.mk
Behdad Esfahbod72225272013-08-06 15:19:23 -0400151 @echo "git.mk: Generating $@"
152 @{ \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500153 if test "x$(DOC_MODULE)" = x -o "x$(DOC_MAIN_SGML_FILE)" = x; then :; else \
154 for x in \
155 $(DOC_MODULE)-decl-list.txt \
156 $(DOC_MODULE)-decl.txt \
157 tmpl/$(DOC_MODULE)-unused.sgml \
158 "tmpl/*.bak" \
159 xml html \
Behdad Esfahbod36a661c2013-04-11 13:38:37 -0400160 ; do echo "/$$x"; done; \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500161 fi; \
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500162 if test "x$(DOC_MODULE)$(DOC_ID)" = x -o "x$(DOC_LINGUAS)" = x; then :; else \
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400163 for lc in $(DOC_LINGUAS); do \
164 for x in \
165 $(if $(DOC_MODULE),$(DOC_MODULE).xml) \
166 $(DOC_PAGES) \
167 $(DOC_INCLUDES) \
Behdad Esfahbod36a661c2013-04-11 13:38:37 -0400168 ; do echo "/$$lc/$$x"; done; \
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400169 done; \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500170 for x in \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500171 $(_DOC_OMF_ALL) \
172 $(_DOC_DSK_ALL) \
173 $(_DOC_HTML_ALL) \
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500174 $(_DOC_MOFILES) \
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500175 $(DOC_H_FILE) \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500176 "*/.xml2po.mo" \
177 "*/*.omf.out" \
178 ; do echo /$$x; done; \
179 fi; \
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500180 if test "x$(HELP_ID)" = x -o "x$(HELP_LINGUAS)" = x; then :; else \
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400181 for lc in $(HELP_LINGUAS); do \
182 for x in \
183 $(HELP_FILES) \
184 "$$lc.stamp" \
185 "$$lc.mo" \
Behdad Esfahbod36a661c2013-04-11 13:38:37 -0400186 ; do echo "/$$lc/$$x"; done; \
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400187 done; \
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500188 fi; \
189 if test "x$(gsettings_SCHEMAS)" = x; then :; else \
190 for x in \
191 $(gsettings_SCHEMAS:.xml=.valid) \
192 $(gsettings__enum_file) \
Behdad Esfahbod36a661c2013-04-11 13:38:37 -0400193 ; do echo "/$$x"; done; \
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500194 fi; \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500195 if test -f $(srcdir)/po/Makefile.in.in; then \
196 for x in \
197 po/Makefile.in.in \
Behdad Esfahbod72225272013-08-06 15:19:23 -0400198 po/Makefile.in.in~ \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500199 po/Makefile.in \
200 po/Makefile \
Behdad Esfahbod72225272013-08-06 15:19:23 -0400201 po/Makevars.template \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500202 po/POTFILES \
Behdad Esfahbod72225272013-08-06 15:19:23 -0400203 po/Rules-quot \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500204 po/stamp-it \
205 po/.intltool-merge-cache \
206 "po/*.gmo" \
Behdad Esfahbod72225272013-08-06 15:19:23 -0400207 "po/*.header" \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500208 "po/*.mo" \
Behdad Esfahbod72225272013-08-06 15:19:23 -0400209 "po/*.sed" \
210 "po/*.sin" \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500211 po/$(GETTEXT_PACKAGE).pot \
212 intltool-extract.in \
213 intltool-merge.in \
214 intltool-update.in \
Behdad Esfahbod36a661c2013-04-11 13:38:37 -0400215 ; do echo "/$$x"; done; \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500216 fi; \
217 if test -f $(srcdir)/configure; then \
218 for x in \
219 autom4te.cache \
220 configure \
221 config.h \
222 stamp-h1 \
223 libtool \
224 config.lt \
Behdad Esfahbod36a661c2013-04-11 13:38:37 -0400225 ; do echo "/$$x"; done; \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500226 fi; \
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400227 if test "x$(DEJATOOL)" = x; then :; else \
228 for x in \
229 $(DEJATOOL) \
Behdad Esfahbod36a661c2013-04-11 13:38:37 -0400230 ; do echo "/$$x.sum"; echo "/$$x.log"; done; \
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400231 echo /site.exp; \
232 fi; \
Behdad Esfahbod36a661c2013-04-11 13:38:37 -0400233 if test "x$(am__dirstamp)" = x; then :; else \
234 echo "$(am__dirstamp)"; \
235 fi; \
236 if test "x$(LTCOMPILE)" = x; then :; else \
237 for x in \
238 "*.lo" \
239 ".libs" "_libs" \
240 ; do echo "$$x"; done; \
241 fi; \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500242 for x in \
243 .gitignore \
244 $(GITIGNOREFILES) \
245 $(CLEANFILES) \
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400246 $(PROGRAMS) $(check_PROGRAMS) $(EXTRA_PROGRAMS) \
247 $(LIBRARIES) $(check_LIBRARIES) $(EXTRA_LIBRARIES) \
248 $(LTLIBRARIES) $(check_LTLIBRARIES) $(EXTRA_LTLIBRARIES) \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500249 so_locations \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500250 $(MOSTLYCLEANFILES) \
251 "*.$(OBJEXT)" \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500252 $(DISTCLEANFILES) \
253 $(am__CONFIG_DISTCLEAN_FILES) \
254 $(CONFIG_CLEAN_FILES) \
255 TAGS ID GTAGS GRTAGS GSYMS GPATH tags \
256 "*.tab.c" \
257 $(MAINTAINERCLEANFILES) \
258 $(BUILT_SOURCES) \
259 $(DEPDIR) \
260 Makefile \
261 Makefile.in \
262 "*.orig" \
263 "*.rej" \
264 "*.bak" \
265 "*~" \
266 ".*.sw[nop]" \
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500267 ".dirstamp" \
Behdad Esfahbod36a661c2013-04-11 13:38:37 -0400268 ; do echo "/$$x"; done; \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500269 } | \
270 sed "s@^/`echo "$(srcdir)" | sed 's/\(.\)/[\1]/g'`/@/@" | \
271 sed 's@/[.]/@/@g' | \
272 LC_ALL=C sort | uniq > $@.tmp && \
273 mv $@.tmp $@;
274
275all: $(srcdir)/.gitignore gitignore-recurse-maybe
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400276gitignore: $(srcdir)/.gitignore gitignore-recurse
277
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500278gitignore-recurse-maybe:
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500279 @for subdir in $(DIST_SUBDIRS); do \
280 case " $(SUBDIRS) " in \
281 *" $$subdir "*) :;; \
Behdad Esfahbod72225272013-08-06 15:19:23 -0400282 *) test "$$subdir" = . -o -e "$$subdir/.git" || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) gitignore || echo "Skipping $$subdir");; \
Behdad Esfahbodbee74ef2012-01-27 02:14:08 -0500283 esac; \
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500284 done
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400285gitignore-recurse:
286 @for subdir in $(DIST_SUBDIRS); do \
Behdad Esfahbod72225272013-08-06 15:19:23 -0400287 test "$$subdir" = . -o -e "$$subdir/.git" || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) gitignore || echo "Skipping $$subdir"); \
Behdad Esfahbod6efe1ec2012-07-11 15:30:08 -0400288 done
Behdad Esfahbod29aa4002009-11-02 16:28:39 -0500289
290maintainer-clean: gitignore-clean
291gitignore-clean:
292 -rm -f $(srcdir)/.gitignore
293
294.PHONY: gitignore-clean gitignore gitignore-recurse gitignore-recurse-maybe