Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 1 | # git.mk |
| 2 | # |
| 3 | # Copyright 2009, Red Hat, Inc. |
Behdad Esfahbod | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 4 | # Copyright 2010,2011 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 | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 11 | # The canonical source for this file is https://github.com/behdad/git.mk. |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 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 |
Behdad Esfahbod | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 15 | # your project to -include git.mk. Remember to add that line to new |
| 16 | # Makefile.am files you create in your project, or just rerun the |
| 17 | # "make -f git.mk". |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 18 | # |
| 19 | # This enables automatic .gitignore generation. If you need to ignore |
| 20 | # more files, add them to the GITIGNOREFILES variable in your Makefile.am. |
| 21 | # But think twice before doing that. If a file has to be in .gitignore, |
| 22 | # chances are very high that it's a generated file and should be in one |
| 23 | # of MOSTLYCLEANFILES, CLEANFILES, DISTCLEANFILES, or MAINTAINERCLEANFILES. |
| 24 | # |
| 25 | # The only case that you need to manually add a file to GITIGNOREFILES is |
| 26 | # when remove files in one of mostlyclean-local, clean-local, distclean-local, |
Behdad Esfahbod | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 27 | # or maintainer-clean-local make targets. |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 28 | # |
| 29 | # Note that for files like editor backup, etc, there are better places to |
| 30 | # ignore them. See "man gitignore". |
| 31 | # |
| 32 | # If "make maintainer-clean" removes the files but they are not recognized |
| 33 | # by this script (that is, if "git status" shows untracked files still), send |
| 34 | # 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] | 35 | # the directories involved and I'll diagnose. |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 36 | # |
| 37 | # For a list of toplevel files that should be in MAINTAINERCLEANFILES, see |
Behdad Esfahbod | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 38 | # Makefile.am.sample in the git.mk git repo. |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 39 | # |
| 40 | # Don't EXTRA_DIST this file. It is supposed to only live in git clones, |
| 41 | # not tarballs. It serves no useful purpose in tarballs and clutters the |
| 42 | # build dir. |
| 43 | # |
| 44 | # This file knows how to handle autoconf, automake, libtool, gtk-doc, |
Behdad Esfahbod | 6efe1ec | 2012-07-11 15:30:08 -0400 | [diff] [blame] | 45 | # gnome-doc-utils, yelp.m4, mallard, intltool, gsettings, dejagnu. |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 46 | # |
Behdad Esfahbod | 6efe1ec | 2012-07-11 15:30:08 -0400 | [diff] [blame] | 47 | # This makefile provides the following targets: |
| 48 | # |
| 49 | # - all: "make all" will build all gitignore files. |
| 50 | # - gitignore: makes all gitignore files in the current dir and subdirs. |
| 51 | # - .gitignore: make gitignore file for the current dir. |
| 52 | # - gitignore-recurse: makes all gitignore files in the subdirs. |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 53 | # |
| 54 | # KNOWN ISSUES: |
| 55 | # |
| 56 | # - Recursive configure doesn't work as $(top_srcdir)/git.mk inside the |
| 57 | # submodule doesn't find us. If you have configure.{in,ac} files in |
| 58 | # subdirs, add a proxy git.mk file in those dirs that simply does: |
| 59 | # "include $(top_srcdir)/../git.mk". Add more ..'s to your taste. |
| 60 | # And add those files to git. See vte/gnome-pty-helper/git.mk for |
| 61 | # example. |
| 62 | # |
| 63 | |
| 64 | git-all: git-mk-install |
| 65 | |
| 66 | git-mk-install: |
| 67 | @echo Installing git makefile |
Behdad Esfahbod | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 68 | @any_failed=; \ |
| 69 | 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] | 70 | if grep 'include .*/git.mk' $$x >/dev/null; then \ |
| 71 | echo $$x already includes git.mk; \ |
| 72 | else \ |
| 73 | failed=; \ |
| 74 | echo "Updating $$x"; \ |
| 75 | { cat $$x; \ |
| 76 | echo ''; \ |
| 77 | echo '-include $$(top_srcdir)/git.mk'; \ |
| 78 | } > $$x.tmp || failed=1; \ |
| 79 | if test x$$failed = x; then \ |
| 80 | mv $$x.tmp $$x || failed=1; \ |
| 81 | fi; \ |
| 82 | if test x$$failed = x; then : else \ |
| 83 | echo Failed updating $$x; >&2 \ |
| 84 | any_failed=1; \ |
| 85 | fi; \ |
| 86 | fi; done; test -z "$$any_failed" |
| 87 | |
| 88 | .PHONY: git-all git-mk-install |
| 89 | |
| 90 | |
| 91 | ### .gitignore generation |
| 92 | |
| 93 | $(srcdir)/.gitignore: Makefile.am $(top_srcdir)/git.mk |
| 94 | $(AM_V_GEN) \ |
| 95 | { \ |
| 96 | if test "x$(DOC_MODULE)" = x -o "x$(DOC_MAIN_SGML_FILE)" = x; then :; else \ |
| 97 | for x in \ |
| 98 | $(DOC_MODULE)-decl-list.txt \ |
| 99 | $(DOC_MODULE)-decl.txt \ |
| 100 | tmpl/$(DOC_MODULE)-unused.sgml \ |
| 101 | "tmpl/*.bak" \ |
| 102 | xml html \ |
| 103 | ; do echo /$$x; done; \ |
| 104 | fi; \ |
Behdad Esfahbod | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 105 | 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] | 106 | for lc in $(DOC_LINGUAS); do \ |
| 107 | for x in \ |
| 108 | $(if $(DOC_MODULE),$(DOC_MODULE).xml) \ |
| 109 | $(DOC_PAGES) \ |
| 110 | $(DOC_INCLUDES) \ |
| 111 | ; do echo /$$lc/$$x; done; \ |
| 112 | done; \ |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 113 | for x in \ |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 114 | $(_DOC_OMF_ALL) \ |
| 115 | $(_DOC_DSK_ALL) \ |
| 116 | $(_DOC_HTML_ALL) \ |
Behdad Esfahbod | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 117 | $(_DOC_MOFILES) \ |
Behdad Esfahbod | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 118 | $(DOC_H_FILE) \ |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 119 | "*/.xml2po.mo" \ |
| 120 | "*/*.omf.out" \ |
| 121 | ; do echo /$$x; done; \ |
| 122 | fi; \ |
Behdad Esfahbod | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 123 | 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] | 124 | for lc in $(HELP_LINGUAS); do \ |
| 125 | for x in \ |
| 126 | $(HELP_FILES) \ |
| 127 | "$$lc.stamp" \ |
| 128 | "$$lc.mo" \ |
| 129 | ; do echo /$$lc/$$x; done; \ |
| 130 | done; \ |
Behdad Esfahbod | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 131 | fi; \ |
| 132 | if test "x$(gsettings_SCHEMAS)" = x; then :; else \ |
| 133 | for x in \ |
| 134 | $(gsettings_SCHEMAS:.xml=.valid) \ |
| 135 | $(gsettings__enum_file) \ |
| 136 | ; do echo /$$x; done; \ |
| 137 | fi; \ |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 138 | if test -f $(srcdir)/po/Makefile.in.in; then \ |
| 139 | for x in \ |
| 140 | po/Makefile.in.in \ |
| 141 | po/Makefile.in \ |
| 142 | po/Makefile \ |
| 143 | po/POTFILES \ |
| 144 | po/stamp-it \ |
| 145 | po/.intltool-merge-cache \ |
| 146 | "po/*.gmo" \ |
| 147 | "po/*.mo" \ |
| 148 | po/$(GETTEXT_PACKAGE).pot \ |
| 149 | intltool-extract.in \ |
| 150 | intltool-merge.in \ |
| 151 | intltool-update.in \ |
| 152 | ; do echo /$$x; done; \ |
| 153 | fi; \ |
| 154 | if test -f $(srcdir)/configure; then \ |
| 155 | for x in \ |
| 156 | autom4te.cache \ |
| 157 | configure \ |
| 158 | config.h \ |
| 159 | stamp-h1 \ |
| 160 | libtool \ |
| 161 | config.lt \ |
| 162 | ; do echo /$$x; done; \ |
| 163 | fi; \ |
Behdad Esfahbod | 6efe1ec | 2012-07-11 15:30:08 -0400 | [diff] [blame] | 164 | if test "x$(DEJATOOL)" = x; then :; else \ |
| 165 | for x in \ |
| 166 | $(DEJATOOL) \ |
| 167 | ; do echo /$$x.sum; echo /$$x.log; done; \ |
| 168 | echo /site.exp; \ |
| 169 | fi; \ |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 170 | for x in \ |
| 171 | .gitignore \ |
| 172 | $(GITIGNOREFILES) \ |
| 173 | $(CLEANFILES) \ |
Behdad Esfahbod | 6efe1ec | 2012-07-11 15:30:08 -0400 | [diff] [blame] | 174 | $(PROGRAMS) $(check_PROGRAMS) $(EXTRA_PROGRAMS) \ |
| 175 | $(LIBRARIES) $(check_LIBRARIES) $(EXTRA_LIBRARIES) \ |
| 176 | $(LTLIBRARIES) $(check_LTLIBRARIES) $(EXTRA_LTLIBRARIES) \ |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 177 | so_locations \ |
| 178 | .libs _libs \ |
| 179 | $(MOSTLYCLEANFILES) \ |
| 180 | "*.$(OBJEXT)" \ |
| 181 | "*.lo" \ |
| 182 | $(DISTCLEANFILES) \ |
| 183 | $(am__CONFIG_DISTCLEAN_FILES) \ |
| 184 | $(CONFIG_CLEAN_FILES) \ |
| 185 | TAGS ID GTAGS GRTAGS GSYMS GPATH tags \ |
| 186 | "*.tab.c" \ |
| 187 | $(MAINTAINERCLEANFILES) \ |
| 188 | $(BUILT_SOURCES) \ |
| 189 | $(DEPDIR) \ |
| 190 | Makefile \ |
| 191 | Makefile.in \ |
| 192 | "*.orig" \ |
| 193 | "*.rej" \ |
| 194 | "*.bak" \ |
| 195 | "*~" \ |
| 196 | ".*.sw[nop]" \ |
Behdad Esfahbod | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 197 | ".dirstamp" \ |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 198 | ; do echo /$$x; done; \ |
| 199 | } | \ |
| 200 | sed "s@^/`echo "$(srcdir)" | sed 's/\(.\)/[\1]/g'`/@/@" | \ |
| 201 | sed 's@/[.]/@/@g' | \ |
| 202 | LC_ALL=C sort | uniq > $@.tmp && \ |
| 203 | mv $@.tmp $@; |
| 204 | |
| 205 | all: $(srcdir)/.gitignore gitignore-recurse-maybe |
Behdad Esfahbod | 6efe1ec | 2012-07-11 15:30:08 -0400 | [diff] [blame] | 206 | gitignore: $(srcdir)/.gitignore gitignore-recurse |
| 207 | |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 208 | gitignore-recurse-maybe: |
Behdad Esfahbod | bee74ef | 2012-01-27 02:14:08 -0500 | [diff] [blame] | 209 | @for subdir in $(DIST_SUBDIRS); do \ |
| 210 | case " $(SUBDIRS) " in \ |
| 211 | *" $$subdir "*) :;; \ |
Behdad Esfahbod | 6efe1ec | 2012-07-11 15:30:08 -0400 | [diff] [blame] | 212 | *) 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] | 213 | esac; \ |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 214 | done |
Behdad Esfahbod | 6efe1ec | 2012-07-11 15:30:08 -0400 | [diff] [blame] | 215 | gitignore-recurse: |
| 216 | @for subdir in $(DIST_SUBDIRS); do \ |
| 217 | test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) .gitignore gitignore-recurse || echo "Skipping $$subdir"); \ |
| 218 | done |
Behdad Esfahbod | 29aa400 | 2009-11-02 16:28:39 -0500 | [diff] [blame] | 219 | |
| 220 | maintainer-clean: gitignore-clean |
| 221 | gitignore-clean: |
| 222 | -rm -f $(srcdir)/.gitignore |
| 223 | |
| 224 | .PHONY: gitignore-clean gitignore gitignore-recurse gitignore-recurse-maybe |