Synchronize with Evolution's git.mk.
[platform/upstream/evolution-data-server.git] / git.mk
1 # git.mk
2 #
3 # Copyright 2009, Red Hat, Inc.
4 # Written by Behdad Esfahbod
5 #
6 # Copying and distribution of this file, with or without modification,
7 # are permitted in any medium without royalty provided the copyright
8 # notice and this notice are preserved.
9 #
10 # The canonical source for this file is pango/git.mk, or whereever the
11 # header of pango/git.mk suggests in the future.
12 #
13 # To use in your project, import this file in your git repo's toplevel,
14 # then do "make -f git.mk".  This modifies all Makefile.am files in
15 # your project to include git.mk.
16 #
17 # This enables automatic .gitignore generation.  If you need to ignore
18 # more files, add them to the GITIGNOREFILES variable in your Makefile.am.
19 # But think twice before doing that.  If a file has to be in .gitignore,
20 # chances are very high that it's a generated file and should be in one
21 # of MOSTLYCLEANFILES, CLEANFILES, DISTCLEANFILES, or MAINTAINERCLEANFILES.
22 #
23 # The only case that you need to manually add a file to GITIGNOREFILES is
24 # when remove files in one of mostlyclean-local, clean-local, distclean-local,
25 # or maintainer-clean-local.
26 #
27 # Note that for files like editor backup, etc, there are better places to
28 # ignore them.  See "man gitignore".
29 #
30 # If "make maintainer-clean" removes the files but they are not recognized
31 # by this script (that is, if "git status" shows untracked files still), send
32 # me the output of "git status" as well as your Makefile.am and Makefile for
33 # the directories involved.
34 #
35 # For a list of toplevel files that should be in MAINTAINERCLEANFILES, see
36 # pango/Makefile.am.
37 #
38 # Don't EXTRA_DIST this file.  It is supposed to only live in git clones,
39 # not tarballs.  It serves no useful purpose in tarballs and clutters the
40 # build dir.
41 #
42 # This file knows how to handle autoconf, automake, libtool, gtk-doc,
43 # gnome-doc-utils, mallard, intltool, gsettings.
44 #
45 #
46 # KNOWN ISSUES:
47 #
48 # - Recursive configure doesn't work as $(top_srcdir)/git.mk inside the
49 #   submodule doesn't find us.  If you have configure.{in,ac} files in
50 #   subdirs, add a proxy git.mk file in those dirs that simply does:
51 #   "include $(top_srcdir)/../git.mk".  Add more ..'s to your taste.
52 #   And add those files to git.  See vte/gnome-pty-helper/git.mk for
53 #   example.
54 #
55 # ChangeLog
56 #
57 # - 2012-03-28 Use temporary file for docs to avoid hitting ARG_MAX
58 # - 2010-12-06 Add support for Mallard docs
59 # - 2010-12-06 Start this change log
60
61 git-all: git-mk-install
62
63 git-mk-install:
64         @echo Installing git makefile
65         @any_failed=; find $(top_srcdir) -name Makefile.am | while read x; do \
66                 if grep 'include .*/git.mk' $$x >/dev/null; then \
67                         echo $$x already includes git.mk; \
68                 else \
69                         failed=; \
70                         echo "Updating $$x"; \
71                         { cat $$x; \
72                           echo ''; \
73                           echo '-include $$(top_srcdir)/git.mk'; \
74                         } > $$x.tmp || failed=1; \
75                         if test x$$failed = x; then \
76                                 mv $$x.tmp $$x || failed=1; \
77                         fi; \
78                         if test x$$failed = x; then : else \
79                                 echo Failed updating $$x; >&2 \
80                                 any_failed=1; \
81                         fi; \
82         fi; done; test -z "$$any_failed"
83
84 .PHONY: git-all git-mk-install
85
86
87 ### .gitignore generation
88
89
90 $(srcdir)/.gitignore: Makefile.am $(top_srcdir)/git.mk
91         @echo $(_DOC_C_DOCS) > $@.docs.tmp
92         @echo $(_DOC_LC_DOCS) >> $@.docs.tmp
93         @echo $(_DOC_OMF_ALL) >> $@.docs.tmp
94         @echo $(_DOC_DSK_ALL) >> $@.docs.tmp
95         @echo $(_DOC_HTML_ALL) >> $@.docs.tmp
96         $(AM_V_GEN) \
97         { \
98                 if test "x$(DOC_MODULE)" = x -o "x$(DOC_MAIN_SGML_FILE)" = x; then :; else \
99                         for x in \
100                                 $(DOC_MODULE)-decl-list.txt \
101                                 $(DOC_MODULE)-decl.txt \
102                                 tmpl/$(DOC_MODULE)-unused.sgml \
103                                 "tmpl/*.bak" \
104                                 xml html \
105                         ; do echo /$$x; done; \
106                 fi; \
107                 if test "x$(DOC_MODULE)$(DOC_ID)" = x -o "x$(DOC_LINGUAS)" = x; then :; else \
108                         for x in \
109                                 $$(cat $@.docs.tmp) \
110                                 $(_DOC_MOFILES) \
111                                 $(_DOC_POFILES) \
112                                 $(DOC_H_FILE) \
113                                 "*/.xml2po.mo" \
114                                 "*/*.omf.out" \
115                         ; do echo /$$x; done; \
116                 fi; \
117                 if test "x$(gsettings_SCHEMAS)" = x; then :; else \
118                         for x in \
119                                 $(gsettings_SCHEMAS:.xml=.valid) \
120                                 $(gsettings__enum_file) \
121                         ; do echo /$$x; done; \
122                 fi; \
123                 if test -f $(srcdir)/po/Makefile.in.in; then \
124                         for x in \
125                                 po/Makefile.in.in \
126                                 po/Makefile.in \
127                                 po/Makefile \
128                                 po/POTFILES \
129                                 po/stamp-it \
130                                 po/.intltool-merge-cache \
131                                 "po/*.gmo" \
132                                 "po/*.mo" \
133                                 po/$(GETTEXT_PACKAGE).pot \
134                                 intltool-extract.in \
135                                 intltool-merge.in \
136                                 intltool-update.in \
137                         ; do echo /$$x; done; \
138                 fi; \
139                 if test -f $(srcdir)/configure; then \
140                         for x in \
141                                 autom4te.cache \
142                                 configure \
143                                 config.h \
144                                 stamp-h1 \
145                                 libtool \
146                                 config.lt \
147                         ; do echo /$$x; done; \
148                 fi; \
149                 for x in \
150                         .gitignore \
151                         $(GITIGNOREFILES) \
152                         $(CLEANFILES) \
153                         $(PROGRAMS) \
154                         $(check_PROGRAMS) \
155                         $(EXTRA_PROGRAMS) \
156                         $(LTLIBRARIES) \
157                         so_locations \
158                         .libs _libs \
159                         $(MOSTLYCLEANFILES) \
160                         "*.$(OBJEXT)" \
161                         "*.lo" \
162                         $(DISTCLEANFILES) \
163                         $(am__CONFIG_DISTCLEAN_FILES) \
164                         $(CONFIG_CLEAN_FILES) \
165                         TAGS ID GTAGS GRTAGS GSYMS GPATH tags \
166                         "*.tab.c" \
167                         $(MAINTAINERCLEANFILES) \
168                         $(BUILT_SOURCES) \
169                         $(DEPDIR) \
170                         Makefile \
171                         Makefile.in \
172                         "*.orig" \
173                         "*.rej" \
174                         "*.bak" \
175                         "*~" \
176                         ".*.sw[nop]" \
177                         ".dirstamp" \
178                 ; do echo /$$x; done; \
179         } | \
180         sed "s@^/`echo "$(srcdir)" | sed 's/\(.\)/[\1]/g'`/@/@" | \
181         sed 's@/[.]/@/@g' | \
182         LC_ALL=C sort | uniq > $@.tmp && \
183         mv $@.tmp $@;
184         @rm -f $@.docs.tmp
185
186 all: $(srcdir)/.gitignore gitignore-recurse-maybe
187 gitignore-recurse-maybe:
188         @if test "x$(SUBDIRS)" = "x$(DIST_SUBDIRS)"; then :; else \
189                 $(MAKE) $(AM_MAKEFLAGS) gitignore-recurse; \
190         fi;
191 gitignore-recurse:
192         @for subdir in $(DIST_SUBDIRS); do \
193           case " $(SUBDIRS) " in \
194             *" $$subdir "*) :;; \
195             *) test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) .gitignore gitignore-recurse || echo "Skipping $$subdir");; \
196           esac; \
197         done
198 gitignore: $(srcdir)/.gitignore gitignore-recurse
199
200 maintainer-clean: gitignore-clean
201 gitignore-clean:
202         -rm -f $(srcdir)/.gitignore
203
204 .PHONY: gitignore-clean gitignore gitignore-recurse gitignore-recurse-maybe