Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 1 | # git.mk |
| 2 | # |
| 3 | # Copyright 2009, Red Hat, Inc. |
Behdad Esfahbod | 22c625a | 2013-03-04 20:56:15 -0500 | [diff] [blame] | 4 | # Copyright 2010,2011,2012,2013 Behdad Esfahbod |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 5 | # Written by Behdad Esfahbod |
| 6 | # |
| 7 | # Copying and distribution of this file, with or without modification, |
Behdad Esfahbod | 6efe1ec | 2012-07-11 15:30:08 -0400 | [diff] [blame] | 8 | # is permitted in any medium without royalty provided the copyright |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 9 | # notice and this notice are preserved. |
| 10 | # |
Behdad Esfahbod | 22c625a | 2013-03-04 20:56:15 -0500 | [diff] [blame] | 11 | # 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 Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 15 | # |
| 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 Esfahbod | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 18 | # 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 Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 21 | # |
| 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 Esfahbod | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 30 | # or maintainer-clean-local make targets. |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 31 | # |
| 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 Esfahbod | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 38 | # the directories involved and I'll diagnose. |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 39 | # |
| 40 | # For a list of toplevel files that should be in MAINTAINERCLEANFILES, see |
Behdad Esfahbod | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 41 | # Makefile.am.sample in the git.mk git repo. |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 42 | # |
| 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 Esfahbod | 6efe1ec | 2012-07-11 15:30:08 -0400 | [diff] [blame] | 48 | # gnome-doc-utils, yelp.m4, mallard, intltool, gsettings, dejagnu. |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 49 | # |
Behdad Esfahbod | 6efe1ec | 2012-07-11 15:30:08 -0400 | [diff] [blame] | 50 | # 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 Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 56 | # |
| 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 Esfahbod | 22c625a | 2013-03-04 20:56:15 -0500 | [diff] [blame] | 67 | |
| 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: |
| 76 | GITIGNORE_MAINTAINERCLEANFILES_TOPLEVEL = \ |
| 77 | $(srcdir)/aclocal.m4 \ |
Behdad Esfahbod | 4d4fc92 | 2013-04-05 17:58:25 -0400 | [diff] [blame] | 78 | $(srcdir)/ar-lib \ |
Behdad Esfahbod | 22c625a | 2013-03-04 20:56:15 -0500 | [diff] [blame] | 79 | $(srcdir)/autoscan.log \ |
| 80 | $(srcdir)/compile \ |
| 81 | $(srcdir)/config.guess \ |
| 82 | $(srcdir)/config.h.in \ |
| 83 | $(srcdir)/config.sub \ |
| 84 | $(srcdir)/configure.scan \ |
| 85 | $(srcdir)/depcomp \ |
| 86 | $(srcdir)/install-sh \ |
| 87 | $(srcdir)/ltmain.sh \ |
| 88 | $(srcdir)/missing \ |
| 89 | $(srcdir)/mkinstalldirs |
| 90 | # |
| 91 | # All modules should also be fine including the following variable, which |
| 92 | # removes automake-generated Makefile.in files: |
| 93 | GITIGNORE_MAINTAINERCLEANFILES_MAKEFILE_IN = \ |
| 94 | `$(AUTOCONF) --trace 'AC_CONFIG_FILES:$$1' $(srcdir)/configure.ac | \ |
| 95 | while read f; do \ |
| 96 | case $$f in Makefile|*/Makefile) \ |
| 97 | test -f "$(srcdir)/$$f.am" && echo "$(srcdir)/$$f.in";; esac; \ |
| 98 | done` |
| 99 | # |
| 100 | # Modules that use libtool /and/ use AC_CONFIG_MACRO_DIR([m4]) may also |
| 101 | # include this: |
| 102 | GITIGNORE_MAINTAINERCLEANFILES_M4_LIBTOOL = \ |
| 103 | $(srcdir)/m4/libtool.m4 \ |
| 104 | $(srcdir)/m4/ltoptions.m4 \ |
| 105 | $(srcdir)/m4/ltsugar.m4 \ |
| 106 | $(srcdir)/m4/ltversion.m4 \ |
| 107 | $(srcdir)/m4/lt~obsolete.m4 |
| 108 | |
| 109 | |
| 110 | |
| 111 | ############################################################################### |
| 112 | # Default rule is to install ourselves in all Makefile.am files: |
| 113 | ############################################################################### |
| 114 | |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 115 | git-all: git-mk-install |
| 116 | |
| 117 | git-mk-install: |
| 118 | @echo Installing git makefile |
Behdad Esfahbod | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 119 | @any_failed=; \ |
| 120 | find "`test -z "$(top_srcdir)" && echo . || echo "$(top_srcdir)"`" -name Makefile.am | while read x; do \ |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 121 | if grep 'include .*/git.mk' $$x >/dev/null; then \ |
| 122 | echo $$x already includes git.mk; \ |
| 123 | else \ |
| 124 | failed=; \ |
| 125 | echo "Updating $$x"; \ |
| 126 | { cat $$x; \ |
| 127 | echo ''; \ |
| 128 | echo '-include $$(top_srcdir)/git.mk'; \ |
| 129 | } > $$x.tmp || failed=1; \ |
| 130 | if test x$$failed = x; then \ |
| 131 | mv $$x.tmp $$x || failed=1; \ |
| 132 | fi; \ |
| 133 | if test x$$failed = x; then : else \ |
| 134 | echo Failed updating $$x; >&2 \ |
| 135 | any_failed=1; \ |
| 136 | fi; \ |
| 137 | fi; done; test -z "$$any_failed" |
| 138 | |
| 139 | .PHONY: git-all git-mk-install |
| 140 | |
| 141 | |
Behdad Esfahbod | 22c625a | 2013-03-04 20:56:15 -0500 | [diff] [blame] | 142 | |
| 143 | ############################################################################### |
| 144 | # Actual .gitignore generation: |
| 145 | ############################################################################### |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 146 | |
| 147 | $(srcdir)/.gitignore: Makefile.am $(top_srcdir)/git.mk |
| 148 | $(AM_V_GEN) \ |
| 149 | { \ |
| 150 | if test "x$(DOC_MODULE)" = x -o "x$(DOC_MAIN_SGML_FILE)" = x; then :; else \ |
| 151 | for x in \ |
| 152 | $(DOC_MODULE)-decl-list.txt \ |
| 153 | $(DOC_MODULE)-decl.txt \ |
| 154 | tmpl/$(DOC_MODULE)-unused.sgml \ |
| 155 | "tmpl/*.bak" \ |
| 156 | xml html \ |
| 157 | ; do echo /$$x; done; \ |
| 158 | fi; \ |
Behdad Esfahbod | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 159 | if test "x$(DOC_MODULE)$(DOC_ID)" = x -o "x$(DOC_LINGUAS)" = x; then :; else \ |
Behdad Esfahbod | 6efe1ec | 2012-07-11 15:30:08 -0400 | [diff] [blame] | 160 | for lc in $(DOC_LINGUAS); do \ |
| 161 | for x in \ |
| 162 | $(if $(DOC_MODULE),$(DOC_MODULE).xml) \ |
| 163 | $(DOC_PAGES) \ |
| 164 | $(DOC_INCLUDES) \ |
| 165 | ; do echo /$$lc/$$x; done; \ |
| 166 | done; \ |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 167 | for x in \ |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 168 | $(_DOC_OMF_ALL) \ |
| 169 | $(_DOC_DSK_ALL) \ |
| 170 | $(_DOC_HTML_ALL) \ |
Behdad Esfahbod | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 171 | $(_DOC_MOFILES) \ |
Behdad Esfahbod | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 172 | $(DOC_H_FILE) \ |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 173 | "*/.xml2po.mo" \ |
| 174 | "*/*.omf.out" \ |
| 175 | ; do echo /$$x; done; \ |
| 176 | fi; \ |
Behdad Esfahbod | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 177 | if test "x$(HELP_ID)" = x -o "x$(HELP_LINGUAS)" = x; then :; else \ |
Behdad Esfahbod | 6efe1ec | 2012-07-11 15:30:08 -0400 | [diff] [blame] | 178 | for lc in $(HELP_LINGUAS); do \ |
| 179 | for x in \ |
| 180 | $(HELP_FILES) \ |
| 181 | "$$lc.stamp" \ |
| 182 | "$$lc.mo" \ |
| 183 | ; do echo /$$lc/$$x; done; \ |
| 184 | done; \ |
Behdad Esfahbod | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 185 | fi; \ |
| 186 | if test "x$(gsettings_SCHEMAS)" = x; then :; else \ |
| 187 | for x in \ |
| 188 | $(gsettings_SCHEMAS:.xml=.valid) \ |
| 189 | $(gsettings__enum_file) \ |
| 190 | ; do echo /$$x; done; \ |
| 191 | fi; \ |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 192 | if test -f $(srcdir)/po/Makefile.in.in; then \ |
| 193 | for x in \ |
| 194 | po/Makefile.in.in \ |
| 195 | po/Makefile.in \ |
| 196 | po/Makefile \ |
| 197 | po/POTFILES \ |
| 198 | po/stamp-it \ |
| 199 | po/.intltool-merge-cache \ |
| 200 | "po/*.gmo" \ |
| 201 | "po/*.mo" \ |
| 202 | po/$(GETTEXT_PACKAGE).pot \ |
| 203 | intltool-extract.in \ |
| 204 | intltool-merge.in \ |
| 205 | intltool-update.in \ |
| 206 | ; do echo /$$x; done; \ |
| 207 | fi; \ |
| 208 | if test -f $(srcdir)/configure; then \ |
| 209 | for x in \ |
| 210 | autom4te.cache \ |
| 211 | configure \ |
| 212 | config.h \ |
| 213 | stamp-h1 \ |
| 214 | libtool \ |
| 215 | config.lt \ |
| 216 | ; do echo /$$x; done; \ |
| 217 | fi; \ |
Behdad Esfahbod | 6efe1ec | 2012-07-11 15:30:08 -0400 | [diff] [blame] | 218 | if test "x$(DEJATOOL)" = x; then :; else \ |
| 219 | for x in \ |
| 220 | $(DEJATOOL) \ |
| 221 | ; do echo /$$x.sum; echo /$$x.log; done; \ |
| 222 | echo /site.exp; \ |
| 223 | fi; \ |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 224 | for x in \ |
| 225 | .gitignore \ |
| 226 | $(GITIGNOREFILES) \ |
| 227 | $(CLEANFILES) \ |
Behdad Esfahbod | 6efe1ec | 2012-07-11 15:30:08 -0400 | [diff] [blame] | 228 | $(PROGRAMS) $(check_PROGRAMS) $(EXTRA_PROGRAMS) \ |
| 229 | $(LIBRARIES) $(check_LIBRARIES) $(EXTRA_LIBRARIES) \ |
| 230 | $(LTLIBRARIES) $(check_LTLIBRARIES) $(EXTRA_LTLIBRARIES) \ |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 231 | so_locations \ |
| 232 | .libs _libs \ |
| 233 | $(MOSTLYCLEANFILES) \ |
| 234 | "*.$(OBJEXT)" \ |
| 235 | "*.lo" \ |
| 236 | $(DISTCLEANFILES) \ |
| 237 | $(am__CONFIG_DISTCLEAN_FILES) \ |
| 238 | $(CONFIG_CLEAN_FILES) \ |
| 239 | TAGS ID GTAGS GRTAGS GSYMS GPATH tags \ |
| 240 | "*.tab.c" \ |
| 241 | $(MAINTAINERCLEANFILES) \ |
| 242 | $(BUILT_SOURCES) \ |
| 243 | $(DEPDIR) \ |
| 244 | Makefile \ |
| 245 | Makefile.in \ |
| 246 | "*.orig" \ |
| 247 | "*.rej" \ |
| 248 | "*.bak" \ |
| 249 | "*~" \ |
| 250 | ".*.sw[nop]" \ |
Behdad Esfahbod | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 251 | ".dirstamp" \ |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 252 | ; do echo /$$x; done; \ |
| 253 | } | \ |
| 254 | sed "s@^/`echo "$(srcdir)" | sed 's/\(.\)/[\1]/g'`/@/@" | \ |
| 255 | sed 's@/[.]/@/@g' | \ |
| 256 | LC_ALL=C sort | uniq > $@.tmp && \ |
| 257 | mv $@.tmp $@; |
| 258 | |
| 259 | all: $(srcdir)/.gitignore gitignore-recurse-maybe |
Behdad Esfahbod | 6efe1ec | 2012-07-11 15:30:08 -0400 | [diff] [blame] | 260 | gitignore: $(srcdir)/.gitignore gitignore-recurse |
| 261 | |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 262 | gitignore-recurse-maybe: |
Behdad Esfahbod | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 263 | @for subdir in $(DIST_SUBDIRS); do \ |
| 264 | case " $(SUBDIRS) " in \ |
| 265 | *" $$subdir "*) :;; \ |
Behdad Esfahbod | 6efe1ec | 2012-07-11 15:30:08 -0400 | [diff] [blame] | 266 | *) test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) .gitignore gitignore-recurse-maybe || echo "Skipping $$subdir");; \ |
Behdad Esfahbod | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 267 | esac; \ |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 268 | done |
Behdad Esfahbod | 6efe1ec | 2012-07-11 15:30:08 -0400 | [diff] [blame] | 269 | gitignore-recurse: |
| 270 | @for subdir in $(DIST_SUBDIRS); do \ |
| 271 | test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) .gitignore gitignore-recurse || echo "Skipping $$subdir"); \ |
| 272 | done |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 273 | |
| 274 | maintainer-clean: gitignore-clean |
| 275 | gitignore-clean: |
| 276 | -rm -f $(srcdir)/.gitignore |
| 277 | |
| 278 | .PHONY: gitignore-clean gitignore gitignore-recurse gitignore-recurse-maybe |