blob: a989d9422e179c301c1cdf63d1dc36c5b9688427 [file] [log] [blame]
Andreas Fuchs034d1ca2019-05-15 17:33:54 +02001# git.mk, a small Makefile to autogenerate .gitignore files
2# for autotools-based projects.
3#
4# Copyright 2009, Red Hat, Inc.
5# Copyright 2010,2011,2012,2013 Behdad Esfahbod
6# Written by Behdad Esfahbod
7#
8# Copying and distribution of this file, with or without modification,
9# is permitted in any medium without royalty provided the copyright
10# notice and this notice are preserved.
11#
12# The latest version of this file can be downloaded from:
13GIT_MK_URL = https://raw.githubusercontent.com/behdad/git.mk/master/git.mk
14#
15# Bugs, etc, should be reported upstream at:
16# https://github.com/behdad/git.mk
17#
18# To use in your project, import this file in your git repo's toplevel,
19# then do "make -f git.mk". This modifies all Makefile.am files in
20# your project to -include git.mk. Remember to add that line to new
21# Makefile.am files you create in your project, or just rerun the
22# "make -f git.mk".
23#
24# This enables automatic .gitignore generation. If you need to ignore
25# more files, add them to the GITIGNOREFILES variable in your Makefile.am.
26# But think twice before doing that. If a file has to be in .gitignore,
27# chances are very high that it's a generated file and should be in one
28# of MOSTLYCLEANFILES, CLEANFILES, DISTCLEANFILES, or MAINTAINERCLEANFILES.
29#
30# The only case that you need to manually add a file to GITIGNOREFILES is
31# when remove files in one of mostlyclean-local, clean-local, distclean-local,
32# or maintainer-clean-local make targets.
33#
34# Note that for files like editor backup, etc, there are better places to
35# ignore them. See "man gitignore".
36#
37# If "make maintainer-clean" removes the files but they are not recognized
38# by this script (that is, if "git status" shows untracked files still), send
39# me the output of "git status" as well as your Makefile.am and Makefile for
40# the directories involved and I'll diagnose.
41#
42# For a list of toplevel files that should be in MAINTAINERCLEANFILES, see
43# Makefile.am.sample in the git.mk git repo.
44#
45# Don't EXTRA_DIST this file. It is supposed to only live in git clones,
46# not tarballs. It serves no useful purpose in tarballs and clutters the
47# build dir.
48#
49# This file knows how to handle autoconf, automake, libtool, gtk-doc,
50# gnome-doc-utils, yelp.m4, mallard, intltool, gsettings, dejagnu, appdata,
51# appstream, hotdoc.
52#
53# This makefile provides the following targets:
54#
55# - all: "make all" will build all gitignore files.
56# - gitignore: makes all gitignore files in the current dir and subdirs.
57# - .gitignore: make gitignore file for the current dir.
58# - gitignore-recurse: makes all gitignore files in the subdirs.
59#
60# KNOWN ISSUES:
61#
62# - Recursive configure doesn't work as $(top_srcdir)/git.mk inside the
63# submodule doesn't find us. If you have configure.{in,ac} files in
64# subdirs, add a proxy git.mk file in those dirs that simply does:
65# "include $(top_srcdir)/../git.mk". Add more ..'s to your taste.
66# And add those files to git. See vte/gnome-pty-helper/git.mk for
67# example.
68#
69
70
71
72###############################################################################
73# Variables user modules may want to add to toplevel MAINTAINERCLEANFILES:
74###############################################################################
75
76#
77# Most autotools-using modules should be fine including this variable in their
78# toplevel MAINTAINERCLEANFILES:
79GITIGNORE_MAINTAINERCLEANFILES_TOPLEVEL = \
80 $(srcdir)/aclocal.m4 \
81 $(srcdir)/autoscan.log \
82 $(srcdir)/configure.scan \
83 `AUX_DIR=$(srcdir)/$$(cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_AUX_DIR:$$1' ./configure.ac); \
84 test "x$$AUX_DIR" = "x$(srcdir)/" && AUX_DIR=$(srcdir); \
85 for x in \
86 ar-lib \
87 compile \
88 config.guess \
89 config.rpath \
90 config.sub \
91 depcomp \
92 install-sh \
93 ltmain.sh \
94 missing \
95 mkinstalldirs \
96 test-driver \
97 ylwrap \
98 ; do echo "$$AUX_DIR/$$x"; done` \
99 `cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_HEADERS:$$1' ./configure.ac | \
100 head -n 1 | while read f; do echo "$(srcdir)/$$f.in"; done`
101#
102# All modules should also be fine including the following variable, which
103# removes automake-generated Makefile.in files:
104GITIGNORE_MAINTAINERCLEANFILES_MAKEFILE_IN = \
105 `cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_FILES:$$1' ./configure.ac | \
106 while read f; do \
107 case $$f in Makefile|*/Makefile) \
108 test -f "$(srcdir)/$$f.am" && echo "$(srcdir)/$$f.in";; esac; \
109 done`
110#
111# Modules that use libtool and use AC_CONFIG_MACRO_DIR() may also include this,
112# though it's harmless to include regardless.
113GITIGNORE_MAINTAINERCLEANFILES_M4_LIBTOOL = \
114 `MACRO_DIR=$(srcdir)/$$(cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_MACRO_DIR:$$1' ./configure.ac); \
115 if test "x$$MACRO_DIR" != "x$(srcdir)/"; then \
116 for x in \
117 libtool.m4 \
Philip Tricca0590c2e2019-06-28 10:20:02 -0700118 ltdl.m4 \
Andreas Fuchs034d1ca2019-05-15 17:33:54 +0200119 ltoptions.m4 \
120 ltsugar.m4 \
121 ltversion.m4 \
122 lt~obsolete.m4 \
123 ; do echo "$$MACRO_DIR/$$x"; done; \
124 fi`
125#
126# Modules that use gettext and use AC_CONFIG_MACRO_DIR() may also include this,
127# though it's harmless to include regardless.
128GITIGNORE_MAINTAINERCLEANFILES_M4_GETTEXT = \
129 `MACRO_DIR=$(srcdir)/$$(cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_MACRO_DIR:$$1' ./configure.ac); \
130 if test "x$$MACRO_DIR" != "x$(srcdir)/"; then \
131 for x in \
132 codeset.m4 \
133 extern-inline.m4 \
134 fcntl-o.m4 \
135 gettext.m4 \
136 glibc2.m4 \
137 glibc21.m4 \
138 iconv.m4 \
139 intdiv0.m4 \
140 intl.m4 \
141 intldir.m4 \
142 intlmacosx.m4 \
143 intmax.m4 \
144 inttypes-pri.m4 \
145 inttypes_h.m4 \
146 lcmessage.m4 \
147 lib-ld.m4 \
148 lib-link.m4 \
149 lib-prefix.m4 \
150 lock.m4 \
151 longlong.m4 \
152 nls.m4 \
153 po.m4 \
154 printf-posix.m4 \
155 progtest.m4 \
156 size_max.m4 \
157 stdint_h.m4 \
158 threadlib.m4 \
159 uintmax_t.m4 \
160 visibility.m4 \
161 wchar_t.m4 \
162 wint_t.m4 \
163 xsize.m4 \
164 ; do echo "$$MACRO_DIR/$$x"; done; \
165 fi`
166
167
168
169###############################################################################
170# Default rule is to install ourselves in all Makefile.am files:
171###############################################################################
172
173git-all: git-mk-install
174
175git-mk-install:
176 @echo "Installing git makefile"
177 @any_failed=; \
178 find "`test -z "$(top_srcdir)" && echo . || echo "$(top_srcdir)"`" -name Makefile.am | while read x; do \
179 if grep 'include .*/git.mk' $$x >/dev/null; then \
180 echo "$$x already includes git.mk"; \
181 else \
182 failed=; \
183 echo "Updating $$x"; \
184 { cat $$x; \
185 echo ''; \
186 echo '-include $$(top_srcdir)/git.mk'; \
187 } > $$x.tmp || failed=1; \
188 if test x$$failed = x; then \
189 mv $$x.tmp $$x || failed=1; \
190 fi; \
191 if test x$$failed = x; then : else \
192 echo "Failed updating $$x"; >&2 \
193 any_failed=1; \
194 fi; \
195 fi; done; test -z "$$any_failed"
196
197git-mk-update:
198 wget $(GIT_MK_URL) -O $(top_srcdir)/git.mk
199
200.PHONY: git-all git-mk-install git-mk-update
201
202
203
204###############################################################################
205# Actual .gitignore generation:
206###############################################################################
207
208$(srcdir)/.gitignore: Makefile.am $(top_srcdir)/git.mk $(top_srcdir)/configure.ac
209 @echo "git.mk: Generating $@"
210 @{ \
211 if test "x$(DOC_MODULE)" = x -o "x$(DOC_MAIN_SGML_FILE)" = x; then :; else \
212 for x in \
213 $(DOC_MODULE)-decl-list.txt \
214 $(DOC_MODULE)-decl.txt \
215 tmpl/$(DOC_MODULE)-unused.sgml \
216 "tmpl/*.bak" \
217 $(REPORT_FILES) \
218 $(DOC_MODULE).pdf \
219 xml html \
220 ; do echo "/$$x"; done; \
221 FLAVOR=$$(cd $(top_srcdir); $(AUTOCONF) --trace 'GTK_DOC_CHECK:$$2' ./configure.ac); \
222 case $$FLAVOR in *no-tmpl*) echo /tmpl;; esac; \
223 if echo "$(SCAN_OPTIONS)" | grep -q "\-\-rebuild-types"; then \
224 echo "/$(DOC_MODULE).types"; \
225 fi; \
226 if echo "$(SCAN_OPTIONS)" | grep -q "\-\-rebuild-sections"; then \
227 echo "/$(DOC_MODULE)-sections.txt"; \
228 fi; \
229 if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
230 for x in \
231 $(SETUP_FILES) \
232 $(DOC_MODULE).types \
233 ; do echo "/$$x"; done; \
234 fi; \
235 fi; \
236 if test "x$(DOC_MODULE)$(DOC_ID)" = x -o "x$(DOC_LINGUAS)" = x; then :; else \
237 for lc in $(DOC_LINGUAS); do \
238 for x in \
239 $(if $(DOC_MODULE),$(DOC_MODULE).xml) \
240 $(DOC_PAGES) \
241 $(DOC_INCLUDES) \
242 ; do echo "/$$lc/$$x"; done; \
243 done; \
244 for x in \
245 $(_DOC_OMF_ALL) \
246 $(_DOC_DSK_ALL) \
247 $(_DOC_HTML_ALL) \
248 $(_DOC_MOFILES) \
249 $(DOC_H_FILE) \
250 "*/.xml2po.mo" \
251 "*/*.omf.out" \
252 ; do echo /$$x; done; \
253 fi; \
254 if test "x$(HOTDOC)" = x; then :; else \
255 $(foreach project, $(HOTDOC_PROJECTS),echo "/$(call HOTDOC_TARGET,$(project))"; \
256 echo "/$(shell $(call HOTDOC_PROJECT_COMMAND,$(project)) --get-conf-path output)" ; \
257 echo "/$(shell $(call HOTDOC_PROJECT_COMMAND,$(project)) --get-private-folder)" ; \
258 ) \
259 for x in \
260 .hotdoc.d \
261 ; do echo "/$$x"; done; \
262 fi; \
263 if test "x$(HELP_ID)" = x -o "x$(HELP_LINGUAS)" = x; then :; else \
264 for lc in $(HELP_LINGUAS); do \
265 for x in \
266 $(HELP_FILES) \
267 "$$lc.stamp" \
268 "$$lc.mo" \
269 ; do echo "/$$lc/$$x"; done; \
270 done; \
271 fi; \
272 if test "x$(gsettings_SCHEMAS)" = x; then :; else \
273 for x in \
274 $(gsettings_SCHEMAS:.xml=.valid) \
275 $(gsettings__enum_file) \
276 ; do echo "/$$x"; done; \
277 fi; \
278 if test "x$(appdata_XML)" = x; then :; else \
279 for x in \
280 $(appdata_XML:.xml=.valid) \
281 ; do echo "/$$x"; done; \
282 fi; \
283 if test "x$(appstream_XML)" = x; then :; else \
284 for x in \
285 $(appstream_XML:.xml=.valid) \
286 ; do echo "/$$x"; done; \
287 fi; \
288 if test -f $(srcdir)/po/Makefile.in.in; then \
289 for x in \
290 ABOUT-NLS \
291 po/Makefile.in.in \
292 po/Makefile.in.in~ \
293 po/Makefile.in \
294 po/Makefile \
295 po/Makevars.template \
296 po/POTFILES \
297 po/Rules-quot \
298 po/stamp-it \
299 po/stamp-po \
300 po/.intltool-merge-cache \
301 "po/*.gmo" \
302 "po/*.header" \
303 "po/*.mo" \
304 "po/*.sed" \
305 "po/*.sin" \
306 po/$(GETTEXT_PACKAGE).pot \
307 intltool-extract.in \
308 intltool-merge.in \
309 intltool-update.in \
310 ; do echo "/$$x"; done; \
311 fi; \
312 if test -f $(srcdir)/configure; then \
313 for x in \
314 autom4te.cache \
315 configure \
316 config.h \
317 stamp-h1 \
318 libtool \
319 config.lt \
320 ; do echo "/$$x"; done; \
321 fi; \
322 if test "x$(DEJATOOL)" = x; then :; else \
323 for x in \
324 $(DEJATOOL) \
325 ; do echo "/$$x.sum"; echo "/$$x.log"; done; \
326 echo /site.exp; \
327 fi; \
328 if test "x$(am__dirstamp)" = x; then :; else \
329 echo "$(am__dirstamp)"; \
330 fi; \
331 if test "x$(findstring libtool,$(LTCOMPILE))" = x -a "x$(findstring libtool,$(LTCXXCOMPILE))" = x -a "x$(GTKDOC_RUN)" = x; then :; else \
332 for x in \
333 "*.lo" \
334 ".libs" "_libs" \
335 ; do echo "$$x"; done; \
336 fi; \
337 for x in \
338 .gitignore \
339 $(GITIGNOREFILES) \
340 $(CLEANFILES) \
341 $(PROGRAMS) $(check_PROGRAMS) $(EXTRA_PROGRAMS) \
342 $(LIBRARIES) $(check_LIBRARIES) $(EXTRA_LIBRARIES) \
343 $(LTLIBRARIES) $(check_LTLIBRARIES) $(EXTRA_LTLIBRARIES) \
344 so_locations \
345 $(MOSTLYCLEANFILES) \
346 $(TEST_LOGS) \
347 $(TEST_LOGS:.log=.trs) \
348 $(TEST_SUITE_LOG) \
349 $(TESTS:=.test) \
Andreas Fuchs034d1ca2019-05-15 17:33:54 +0200350 $(DISTCLEANFILES) \
351 $(am__CONFIG_DISTCLEAN_FILES) \
352 $(CONFIG_CLEAN_FILES) \
353 TAGS ID GTAGS GRTAGS GSYMS GPATH tags \
354 "*.tab.c" \
355 $(MAINTAINERCLEANFILES) \
356 $(BUILT_SOURCES) \
357 $(patsubst %.vala,%.c,$(filter %.vala,$(SOURCES))) \
358 $(filter %_vala.stamp,$(DIST_COMMON)) \
359 $(filter %.vapi,$(DIST_COMMON)) \
360 $(filter $(addprefix %,$(notdir $(patsubst %.vapi,%.h,$(filter %.vapi,$(DIST_COMMON))))),$(DIST_COMMON)) \
361 Makefile \
362 Makefile.in \
363 "*.orig" \
364 "*.rej" \
365 "*.bak" \
366 "*~" \
367 ".*.sw[nop]" \
368 ".dirstamp" \
369 ; do echo "/$$x"; done; \
370 for x in \
Philip Tricca4707c6c2019-06-24 21:03:08 -0700371 "*.gcda" \
372 "*.gcno" \
Andreas Fuchs034d1ca2019-05-15 17:33:54 +0200373 "*.$(OBJEXT)" \
374 $(DEPDIR) \
375 ; do echo "$$x"; done; \
376 } | \
377 sed "s@^/`echo "$(srcdir)" | sed 's/\(.\)/[\1]/g'`/@/@" | \
378 sed 's@/[.]/@/@g' | \
379 LC_ALL=C sort | uniq > $@.tmp && \
380 mv $@.tmp $@;
381
382all: $(srcdir)/.gitignore gitignore-recurse-maybe
383gitignore: $(srcdir)/.gitignore gitignore-recurse
384
385gitignore-recurse-maybe:
386 @for subdir in $(DIST_SUBDIRS); do \
387 case " $(SUBDIRS) " in \
388 *" $$subdir "*) :;; \
389 *) test "$$subdir" = . -o -e "$$subdir/.git" || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) gitignore || echo "Skipping $$subdir");; \
390 esac; \
391 done
392gitignore-recurse:
393 @for subdir in $(DIST_SUBDIRS); do \
394 test "$$subdir" = . -o -e "$$subdir/.git" || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) gitignore || echo "Skipping $$subdir"); \
395 done
396
397maintainer-clean: gitignore-clean
398gitignore-clean:
399 -rm -f $(srcdir)/.gitignore
400
401.PHONY: gitignore-clean gitignore gitignore-recurse gitignore-recurse-maybe