1 # git.mk, a small Makefile to autogenerate .gitignore files
2 # for autotools-based projects.
4 # Copyright 2009, Red Hat, Inc.
5 # Copyright 2010,2011,2012,2013 Behdad Esfahbod
6 # Written by Behdad Esfahbod
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.
12 # The latest version of this file can be downloaded from:
13 GIT_MK_URL
= https
://raw.githubusercontent.com
/behdad
/git.mk
/master
/git.mk
15 # Bugs, etc, should be reported upstream at:
16 # https://github.com/behdad/git.mk
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
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.
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.
34 # Note that for files like editor backup, etc, there are better places to
35 # ignore them. See "man gitignore".
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.
42 # For a list of toplevel files that should be in MAINTAINERCLEANFILES, see
43 # Makefile.am.sample in the git.mk git repo.
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
49 # This file knows how to handle autoconf, automake, libtool, gtk-doc,
50 # gnome-doc-utils, yelp.m4, mallard, intltool, gsettings, dejagnu, appdata,
53 # This makefile provides the following targets:
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.
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
72 ###############################################################################
73 # Variables user modules may want to add to toplevel MAINTAINERCLEANFILES:
74 ###############################################################################
77 # Most autotools-using modules should be fine including this variable in their
78 # toplevel MAINTAINERCLEANFILES:
79 GITIGNORE_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); \
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`
102 # All modules should also be fine including the following variable, which
103 # removes automake-generated Makefile.in files:
104 GITIGNORE_MAINTAINERCLEANFILES_MAKEFILE_IN
= \
105 `cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_FILES:$$1' ./configure.ac | \
107 case $$f in Makefile|*/Makefile) \
108 test -f "$(srcdir)/$$f.am" && echo "$(srcdir)/$$f.in";; esac; \
111 # Modules that use libtool and use AC_CONFIG_MACRO_DIR() may also include this,
112 # though it's harmless to include regardless.
113 GITIGNORE_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 \
122 ; do echo "$$MACRO_DIR/$$x"; done; \
125 # Modules that use gettext and use AC_CONFIG_MACRO_DIR() may also include this,
126 # though it's harmless to include regardless.
127 GITIGNORE_MAINTAINERCLEANFILES_M4_GETTEXT
= \
128 `MACRO_DIR=$(srcdir)/$$(cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_MACRO_DIR:$$1' ./configure.ac); \
129 if test "x$$MACRO_DIR" != "x$(srcdir)/"; then \
163 ; do echo "$$MACRO_DIR/$$x"; done; \
168 ###############################################################################
169 # Default rule is to install ourselves in all Makefile.am files:
170 ###############################################################################
172 git-all
: git-mk-install
175 @echo
"Installing git makefile"
177 find
"`test -z "$(top_srcdir
)" && echo . || echo "$(top_srcdir
)"`" -name Makefile.am | while read x
; do \
178 if grep
'include .*/git.mk' $$x >/dev
/null
; then \
179 echo
"$$x already includes git.mk"; \
182 echo
"Updating $$x"; \
185 echo
'-include $$(top_srcdir)/git.mk'; \
186 } > $$x.tmp || failed
=1; \
187 if
test x
$$failed = x
; then \
188 mv
$$x.tmp
$$x || failed
=1; \
190 if
test x
$$failed = x
; then
: else \
191 echo
"Failed updating $$x"; >&2 \
194 fi
; done
; test -z
"$$any_failed"
197 wget
$(GIT_MK_URL
) -O
$(top_srcdir
)/git.mk
199 .PHONY
: git-all git-mk-install git-mk-update
203 ###############################################################################
204 # Actual .gitignore generation:
205 ###############################################################################
207 $(srcdir)/.gitignore
: Makefile.am
$(top_srcdir
)/git.mk
208 @echo
"git.mk: Generating $@"
210 if
test "x$(DOC_MODULE)" = x
-o
"x$(DOC_MAIN_SGML_FILE)" = x
; then
:; else \
212 $(DOC_MODULE
)-decl-list.txt \
213 $(DOC_MODULE
)-decl.txt \
214 tmpl
/$(DOC_MODULE
)-unused.sgml \
219 ; do echo
"/$$x"; done
; \
220 FLAVOR
=$$(cd
$(top_srcdir
); $(AUTOCONF
) --trace
'GTK_DOC_CHECK:$$2' .
/configure.ac
); \
221 case
$$FLAVOR in
*no-tmpl
*) echo
/tmpl
;; esac
; \
222 if echo
"$(SCAN_OPTIONS)" | grep
-q
"\-\-rebuild-types"; then \
223 echo
"/$(DOC_MODULE).types"; \
225 if echo
"$(SCAN_OPTIONS)" | grep
-q
"\-\-rebuild-sections"; then \
226 echo
"/$(DOC_MODULE)-sections.txt"; \
228 if
test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
231 $(DOC_MODULE
).types \
232 ; do echo
"/$$x"; done
; \
235 if
test "x$(DOC_MODULE)$(DOC_ID)" = x
-o
"x$(DOC_LINGUAS)" = x
; then
:; else \
236 for lc in
$(DOC_LINGUAS
); do \
238 $(if
$(DOC_MODULE
),$(DOC_MODULE
).xml
) \
241 ; do echo
"/$$lc/$$x"; done
; \
251 ; do echo
/$$x; done
; \
253 if
test "x$(HOTDOC)" = x
; then
:; else \
254 $(foreach project
, $(HOTDOC_PROJECTS
),echo
"/$(call HOTDOC_TARGET,$(project))"; \
255 echo
"/$(shell $(call HOTDOC_PROJECT_COMMAND,$(project)) --get-conf-path output)" ; \
256 echo
"/$(shell $(call HOTDOC_PROJECT_COMMAND,$(project)) --get-private-folder)" ; \
260 ; do echo
"/$$x"; done
; \
262 if
test "x$(HELP_ID)" = x
-o
"x$(HELP_LINGUAS)" = x
; then
:; else \
263 for lc in
$(HELP_LINGUAS
); do \
268 ; do echo
"/$$lc/$$x"; done
; \
271 if
test "x$(gsettings_SCHEMAS)" = x
; then
:; else \
273 $(gsettings_SCHEMAS
:.xml
=.valid
) \
274 $(gsettings__enum_file
) \
275 ; do echo
"/$$x"; done
; \
277 if
test "x$(appdata_XML)" = x
; then
:; else \
279 $(appdata_XML
:.xml
=.valid
) \
280 ; do echo
"/$$x"; done
; \
282 if
test "x$(appstream_XML)" = x
; then
:; else \
284 $(appstream_XML
:.xml
=.valid
) \
285 ; do echo
"/$$x"; done
; \
287 if
test -f
$(srcdir)/po
/Makefile.in.in
; then \
294 po
/Makevars.template \
299 po
/.intltool-merge-cache \
305 po
/$(GETTEXT_PACKAGE
).pot \
306 intltool-extract.in \
309 ; do echo
"/$$x"; done
; \
311 if
test -f
$(srcdir)/configure
; then \
319 ; do echo
"/$$x"; done
; \
321 if
test "x$(DEJATOOL)" = x
; then
:; else \
324 ; do echo
"/$$x.sum"; echo
"/$$x.log"; done
; \
327 if
test "x$(am__dirstamp)" = x
; then
:; else \
328 echo
"$(am__dirstamp)"; \
330 if
test "x$(findstring libtool,$(LTCOMPILE))" = x
-a
"x$(findstring libtool,$(LTCXXCOMPILE))" = x
-a
"x$(GTKDOC_RUN)" = x
; then
:; else \
334 ; do echo
"$$x"; done
; \
340 $(PROGRAMS
) $(check_PROGRAMS
) $(EXTRA_PROGRAMS
) \
341 $(LIBRARIES
) $(check_LIBRARIES
) $(EXTRA_LIBRARIES
) \
342 $(LTLIBRARIES
) $(check_LTLIBRARIES
) $(EXTRA_LTLIBRARIES
) \
344 $(MOSTLYCLEANFILES
) \
346 $(TEST_LOGS
:.log
=.trs
) \
352 $(am__CONFIG_DISTCLEAN_FILES
) \
353 $(CONFIG_CLEAN_FILES
) \
354 TAGS ID GTAGS GRTAGS GSYMS GPATH
tags \
356 $(MAINTAINERCLEANFILES
) \
358 $(patsubst %.vala
,%.c
,$(filter %.vala
,$(SOURCES
))) \
359 $(filter %_vala.stamp
,$(DIST_COMMON
)) \
360 $(filter %.vapi
,$(DIST_COMMON
)) \
361 $(filter $(addprefix %,$(notdir $(patsubst %.vapi
,%.h
,$(filter %.vapi
,$(DIST_COMMON
))))),$(DIST_COMMON
)) \
370 ; do echo
"/$$x"; done
; \
374 ; do echo
"$$x"; done
; \
376 sed
"s@^/`echo "$(srcdir)" | sed 's/\(.\)/[\1]/g'`/@/@" | \
377 sed
's@/[.]/@/@g' | \
378 LC_ALL
=C
sort | uniq
> $@.tmp
&& \
381 all: $(srcdir)/.gitignore gitignore-recurse-maybe
382 gitignore
: $(srcdir)/.gitignore gitignore-recurse
384 gitignore-recurse-maybe
:
385 @for subdir in
$(DIST_SUBDIRS
); do \
386 case
" $(SUBDIRS) " in \
387 *" $$subdir "*) :;; \
388 *) test "$$subdir" = .
-o
-e
"$$subdir/.git" ||
(cd
$$subdir && $(MAKE
) $(AM_MAKEFLAGS
) gitignore || echo
"Skipping $$subdir");; \
392 @for subdir in
$(DIST_SUBDIRS
); do \
393 test "$$subdir" = .
-o
-e
"$$subdir/.git" ||
(cd
$$subdir && $(MAKE
) $(AM_MAKEFLAGS
) gitignore || echo
"Skipping $$subdir"); \
396 maintainer-clean
: gitignore-clean
398 -rm -f
$(srcdir)/.gitignore
400 .PHONY
: gitignore-clean gitignore gitignore-recurse gitignore-recurse-maybe