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); \
97 ; do echo "$$AUX_DIR/$$x"; done` \
98 `cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_HEADERS:$$1' ./configure.ac | \
99 head -n 1 | while read f; do echo "$(srcdir)/$$f.in"; done`
101 # All modules should also be fine including the following variable, which
102 # removes automake-generated Makefile.in files:
103 GITIGNORE_MAINTAINERCLEANFILES_MAKEFILE_IN
= \
104 `cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_FILES:$$1' ./configure.ac | \
106 case $$f in Makefile|*/Makefile) \
107 test -f "$(srcdir)/$$f.am" && echo "$(srcdir)/$$f.in";; esac; \
110 # Modules that use libtool and use AC_CONFIG_MACRO_DIR() may also include this,
111 # though it's harmless to include regardless.
112 GITIGNORE_MAINTAINERCLEANFILES_M4_LIBTOOL
= \
113 `MACRO_DIR=$(srcdir)/$$(cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_MACRO_DIR:$$1' ./configure.ac); \
114 if test "x$$MACRO_DIR" != "x$(srcdir)/"; then \
121 ; do echo "$$MACRO_DIR/$$x"; done; \
126 ###############################################################################
127 # Default rule is to install ourselves in all Makefile.am files:
128 ###############################################################################
130 git-all
: git-mk-install
133 @echo
"Installing git makefile"
135 find
"`test -z "$(top_srcdir
)" && echo . || echo "$(top_srcdir
)"`" -name Makefile.am | while read x
; do \
136 if grep
'include .*/git.mk' $$x >/dev
/null
; then \
137 echo
"$$x already includes git.mk"; \
140 echo
"Updating $$x"; \
143 echo
'-include $$(top_srcdir)/git.mk'; \
144 } > $$x.tmp || failed
=1; \
145 if
test x
$$failed = x
; then \
146 mv
$$x.tmp
$$x || failed
=1; \
148 if
test x
$$failed = x
; then
: else \
149 echo
"Failed updating $$x"; >&2 \
152 fi
; done
; test -z
"$$any_failed"
155 wget
$(GIT_MK_URL
) -O
$(top_srcdir
)/git.mk
157 .PHONY
: git-all git-mk-install git-mk-update
161 ###############################################################################
162 # Actual .gitignore generation:
163 ###############################################################################
165 $(srcdir)/.gitignore
: Makefile.am
$(top_srcdir
)/git.mk
166 @echo
"git.mk: Generating $@"
168 if
test "x$(DOC_MODULE)" = x
-o
"x$(DOC_MAIN_SGML_FILE)" = x
; then
:; else \
170 $(DOC_MODULE
)-decl-list.txt \
171 $(DOC_MODULE
)-decl.txt \
172 tmpl
/$(DOC_MODULE
)-unused.sgml \
175 ; do echo
"/$$x"; done
; \
176 FLAVOR
=$$(cd
$(top_srcdir
); $(AUTOCONF
) --trace
'GTK_DOC_CHECK:$$2' .
/configure.ac
); \
177 case
$$FLAVOR in
*no-tmpl
*) echo
/tmpl
;; esac
; \
179 if
test "x$(DOC_MODULE)$(DOC_ID)" = x
-o
"x$(DOC_LINGUAS)" = x
; then
:; else \
180 for lc in
$(DOC_LINGUAS
); do \
182 $(if
$(DOC_MODULE
),$(DOC_MODULE
).xml
) \
185 ; do echo
"/$$lc/$$x"; done
; \
195 ; do echo
/$$x; done
; \
197 if
test "x$(HELP_ID)" = x
-o
"x$(HELP_LINGUAS)" = x
; then
:; else \
198 for lc in
$(HELP_LINGUAS
); do \
203 ; do echo
"/$$lc/$$x"; done
; \
206 if
test "x$(gsettings_SCHEMAS)" = x
; then
:; else \
208 $(gsettings_SCHEMAS
:.xml
=.valid
) \
209 $(gsettings__enum_file
) \
210 ; do echo
"/$$x"; done
; \
212 if
test "x$(appdata_XML)" = x
; then
:; else \
214 $(appdata_XML
:.xml
=.valid
) \
215 ; do echo
"/$$x"; done
; \
217 if
test "x$(appstream_XML)" = x
; then
:; else \
219 $(appstream_XML
:.xml
=.valid
) \
220 ; do echo
"/$$x"; done
; \
222 if
test -f
$(srcdir)/po
/Makefile.in.in
; then \
228 po
/Makevars.template \
232 po
/.intltool-merge-cache \
238 po
/$(GETTEXT_PACKAGE
).pot \
239 intltool-extract.in \
242 ; do echo
"/$$x"; done
; \
244 if
test -f
$(srcdir)/configure
; then \
252 ; do echo
"/$$x"; done
; \
254 if
test "x$(DEJATOOL)" = x
; then
:; else \
257 ; do echo
"/$$x.sum"; echo
"/$$x.log"; done
; \
260 if
test "x$(am__dirstamp)" = x
; then
:; else \
261 echo
"$(am__dirstamp)"; \
263 if
test "x$(LTCOMPILE)" = x
-a
"x$(LTCXXCOMPILE)" = x
-a
"x$(GTKDOC_RUN)" = x
; then
:; else \
267 ; do echo
"$$x"; done
; \
273 $(PROGRAMS
) $(check_PROGRAMS
) $(EXTRA_PROGRAMS
) \
274 $(LIBRARIES
) $(check_LIBRARIES
) $(EXTRA_LIBRARIES
) \
275 $(LTLIBRARIES
) $(check_LTLIBRARIES
) $(EXTRA_LTLIBRARIES
) \
277 $(MOSTLYCLEANFILES
) \
279 $(TEST_LOGS
:.log
=.trs
) \
285 $(am__CONFIG_DISTCLEAN_FILES
) \
286 $(CONFIG_CLEAN_FILES
) \
287 TAGS ID GTAGS GRTAGS GSYMS GPATH
tags \
289 $(MAINTAINERCLEANFILES
) \
291 $(patsubst %.vala
,%.c
,$(filter %.vala
,$(SOURCES
))) \
292 $(filter %_vala.stamp
,$(DIST_COMMON
)) \
293 $(filter %.vapi
,$(DIST_COMMON
)) \
294 $(filter $(addprefix %,$(notdir $(patsubst %.vapi
,%.h
,$(filter %.vapi
,$(DIST_COMMON
))))),$(DIST_COMMON
)) \
303 ; do echo
"/$$x"; done
; \
307 ; do echo
"$$x"; done
; \
309 sed
"s@^/`echo "$(srcdir)" | sed 's/\(.\)/[\1]/g'`/@/@" | \
310 sed
's@/[.]/@/@g' | \
311 LC_ALL
=C
sort | uniq
> $@.tmp
&& \
314 all: $(srcdir)/.gitignore gitignore-recurse-maybe
315 gitignore
: $(srcdir)/.gitignore gitignore-recurse
317 gitignore-recurse-maybe
:
318 @for subdir in
$(DIST_SUBDIRS
); do \
319 case
" $(SUBDIRS) " in \
320 *" $$subdir "*) :;; \
321 *) test "$$subdir" = .
-o
-e
"$$subdir/.git" ||
(cd
$$subdir && $(MAKE
) $(AM_MAKEFLAGS
) gitignore || echo
"Skipping $$subdir");; \
325 @for subdir in
$(DIST_SUBDIRS
); do \
326 test "$$subdir" = .
-o
-e
"$$subdir/.git" ||
(cd
$$subdir && $(MAKE
) $(AM_MAKEFLAGS
) gitignore || echo
"Skipping $$subdir"); \
329 maintainer-clean
: gitignore-clean
331 -rm -f
$(srcdir)/.gitignore
333 .PHONY
: gitignore-clean gitignore gitignore-recurse gitignore-recurse-maybe