|
| 1 | +# git.mk |
| 2 | +# |
| 3 | +# Copyright 2009, Red Hat, Inc. |
| 4 | +# Copyright 2010,2011 Behdad Esfahbod |
| 5 | +# Written by Behdad Esfahbod |
| 6 | +# |
| 7 | +# Copying and distribution of this file, with or without modification, |
| 8 | +# is permitted in any medium without royalty provided the copyright |
| 9 | +# notice and this notice are preserved. |
| 10 | +# |
| 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 |
| 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 |
| 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". |
| 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, |
| 30 | +# or maintainer-clean-local make targets. |
| 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 |
| 38 | +# the directories involved and I'll diagnose. |
| 39 | +# |
| 40 | +# For a list of toplevel files that should be in MAINTAINERCLEANFILES, see |
| 41 | +# Makefile.am.sample in the git.mk git repo. |
| 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, |
| 48 | +# gnome-doc-utils, yelp.m4, mallard, intltool, gsettings, dejagnu. |
| 49 | +# |
| 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. |
| 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 | + |
| 67 | +git-all: git-mk-install |
| 68 | + |
| 69 | +git-mk-install: |
| 70 | + @echo Installing git makefile |
| 71 | + @any_failed=; \ |
| 72 | + find "`test -z "$(top_srcdir)" && echo . || echo "$(top_srcdir)"`" -name Makefile.am | while read x; do \ |
| 73 | + if grep 'include .*/git.mk' $$x >/dev/null; then \ |
| 74 | + echo $$x already includes git.mk; \ |
| 75 | + else \ |
| 76 | + failed=; \ |
| 77 | + echo "Updating $$x"; \ |
| 78 | + { cat $$x; \ |
| 79 | + echo ''; \ |
| 80 | + echo '-include $$(top_srcdir)/git.mk'; \ |
| 81 | + } > $$x.tmp || failed=1; \ |
| 82 | + if test x$$failed = x; then \ |
| 83 | + mv $$x.tmp $$x || failed=1; \ |
| 84 | + fi; \ |
| 85 | + if test x$$failed = x; then : else \ |
| 86 | + echo Failed updating $$x; >&2 \ |
| 87 | + any_failed=1; \ |
| 88 | + fi; \ |
| 89 | + fi; done; test -z "$$any_failed" |
| 90 | + |
| 91 | +.PHONY: git-all git-mk-install |
| 92 | + |
| 93 | + |
| 94 | +### .gitignore generation |
| 95 | + |
| 96 | +$(srcdir)/.gitignore: Makefile.am $(top_srcdir)/git.mk |
| 97 | + $(AM_V_GEN) \ |
| 98 | + { \ |
| 99 | + if test "x$(DOC_MODULE)" = x -o "x$(DOC_MAIN_SGML_FILE)" = x; then :; else \ |
| 100 | + for x in \ |
| 101 | + $(DOC_MODULE)-decl-list.txt \ |
| 102 | + $(DOC_MODULE)-decl.txt \ |
| 103 | + tmpl/$(DOC_MODULE)-unused.sgml \ |
| 104 | + "tmpl/*.bak" \ |
| 105 | + xml html \ |
| 106 | + ; do echo /$$x; done; \ |
| 107 | + fi; \ |
| 108 | + if test "x$(DOC_MODULE)$(DOC_ID)" = x -o "x$(DOC_LINGUAS)" = x; then :; else \ |
| 109 | + for lc in $(DOC_LINGUAS); do \ |
| 110 | + for x in \ |
| 111 | + $(if $(DOC_MODULE),$(DOC_MODULE).xml) \ |
| 112 | + $(DOC_PAGES) \ |
| 113 | + $(DOC_INCLUDES) \ |
| 114 | + ; do echo /$$lc/$$x; done; \ |
| 115 | + done; \ |
| 116 | + for x in \ |
| 117 | + $(_DOC_OMF_ALL) \ |
| 118 | + $(_DOC_DSK_ALL) \ |
| 119 | + $(_DOC_HTML_ALL) \ |
| 120 | + $(_DOC_MOFILES) \ |
| 121 | + $(DOC_H_FILE) \ |
| 122 | + "*/.xml2po.mo" \ |
| 123 | + "*/*.omf.out" \ |
| 124 | + ; do echo /$$x; done; \ |
| 125 | + fi; \ |
| 126 | + if test "x$(HELP_ID)" = x -o "x$(HELP_LINGUAS)" = x; then :; else \ |
| 127 | + for lc in $(HELP_LINGUAS); do \ |
| 128 | + for x in \ |
| 129 | + $(HELP_FILES) \ |
| 130 | + "$$lc.stamp" \ |
| 131 | + "$$lc.mo" \ |
| 132 | + ; do echo /$$lc/$$x; done; \ |
| 133 | + done; \ |
| 134 | + fi; \ |
| 135 | + if test "x$(gsettings_SCHEMAS)" = x; then :; else \ |
| 136 | + for x in \ |
| 137 | + $(gsettings_SCHEMAS:.xml=.valid) \ |
| 138 | + $(gsettings__enum_file) \ |
| 139 | + ; do echo /$$x; done; \ |
| 140 | + fi; \ |
| 141 | + if test -f $(srcdir)/po/Makefile.in.in; then \ |
| 142 | + for x in \ |
| 143 | + po/Makefile.in.in \ |
| 144 | + po/Makefile.in \ |
| 145 | + po/Makefile \ |
| 146 | + po/POTFILES \ |
| 147 | + po/stamp-it \ |
| 148 | + po/.intltool-merge-cache \ |
| 149 | + "po/*.gmo" \ |
| 150 | + "po/*.mo" \ |
| 151 | + po/$(GETTEXT_PACKAGE).pot \ |
| 152 | + intltool-extract.in \ |
| 153 | + intltool-merge.in \ |
| 154 | + intltool-update.in \ |
| 155 | + ; do echo /$$x; done; \ |
| 156 | + fi; \ |
| 157 | + if test -f $(srcdir)/configure; then \ |
| 158 | + for x in \ |
| 159 | + autom4te.cache \ |
| 160 | + configure \ |
| 161 | + config.h \ |
| 162 | + stamp-h1 \ |
| 163 | + libtool \ |
| 164 | + config.lt \ |
| 165 | + ; do echo /$$x; done; \ |
| 166 | + fi; \ |
| 167 | + if test "x$(DEJATOOL)" = x; then :; else \ |
| 168 | + for x in \ |
| 169 | + $(DEJATOOL) \ |
| 170 | + ; do echo /$$x.sum; echo /$$x.log; done; \ |
| 171 | + echo /site.exp; \ |
| 172 | + fi; \ |
| 173 | + for x in \ |
| 174 | + .gitignore \ |
| 175 | + $(GITIGNOREFILES) \ |
| 176 | + $(CLEANFILES) \ |
| 177 | + $(PROGRAMS) $(check_PROGRAMS) $(EXTRA_PROGRAMS) \ |
| 178 | + $(LIBRARIES) $(check_LIBRARIES) $(EXTRA_LIBRARIES) \ |
| 179 | + $(LTLIBRARIES) $(check_LTLIBRARIES) $(EXTRA_LTLIBRARIES) \ |
| 180 | + so_locations \ |
| 181 | + .libs _libs \ |
| 182 | + $(MOSTLYCLEANFILES) \ |
| 183 | + "*.$(OBJEXT)" \ |
| 184 | + "*.lo" \ |
| 185 | + $(DISTCLEANFILES) \ |
| 186 | + $(am__CONFIG_DISTCLEAN_FILES) \ |
| 187 | + $(CONFIG_CLEAN_FILES) \ |
| 188 | + TAGS ID GTAGS GRTAGS GSYMS GPATH tags \ |
| 189 | + "*.tab.c" \ |
| 190 | + $(MAINTAINERCLEANFILES) \ |
| 191 | + $(BUILT_SOURCES) \ |
| 192 | + $(DEPDIR) \ |
| 193 | + Makefile \ |
| 194 | + Makefile.in \ |
| 195 | + "*.orig" \ |
| 196 | + "*.rej" \ |
| 197 | + "*.bak" \ |
| 198 | + "*~" \ |
| 199 | + ".*.sw[nop]" \ |
| 200 | + ".dirstamp" \ |
| 201 | + ; do echo /$$x; done; \ |
| 202 | + } | \ |
| 203 | + sed "s@^/`echo "$(srcdir)" | sed 's/\(.\)/[\1]/g'`/@/@" | \ |
| 204 | + sed 's@/[.]/@/@g' | \ |
| 205 | + LC_ALL=C sort | uniq > $@.tmp && \ |
| 206 | + mv $@.tmp $@; |
| 207 | + |
| 208 | +all: $(srcdir)/.gitignore gitignore-recurse-maybe |
| 209 | +gitignore: $(srcdir)/.gitignore gitignore-recurse |
| 210 | + |
| 211 | +gitignore-recurse-maybe: |
| 212 | + @for subdir in $(DIST_SUBDIRS); do \ |
| 213 | + case " $(SUBDIRS) " in \ |
| 214 | + *" $$subdir "*) :;; \ |
| 215 | + *) test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) .gitignore gitignore-recurse-maybe || echo "Skipping $$subdir");; \ |
| 216 | + esac; \ |
| 217 | + done |
| 218 | +gitignore-recurse: |
| 219 | + @for subdir in $(DIST_SUBDIRS); do \ |
| 220 | + test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) .gitignore gitignore-recurse || echo "Skipping $$subdir"); \ |
| 221 | + done |
| 222 | + |
| 223 | +maintainer-clean: gitignore-clean |
| 224 | +gitignore-clean: |
| 225 | + -rm -f $(srcdir)/.gitignore |
| 226 | + |
| 227 | +.PHONY: gitignore-clean gitignore gitignore-recurse gitignore-recurse-maybe |
0 commit comments