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# are permitted in any medium without royalty provided the copyright 9# notice and this notice are preserved. 10# 11# The canonical source for this file is https://github.com/behdad/git.mk. 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. 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". 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, 27# or maintainer-clean-local make targets. 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 35# the directories involved and I'll diagnose. 36# 37# For a list of toplevel files that should be in MAINTAINERCLEANFILES, see 38# Makefile.am.sample in the git.mk git repo. 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, 45# gnome-doc-utils, yelp.m4, mallard, intltool, gsettings. 46# 47# 48# KNOWN ISSUES: 49# 50# - Recursive configure doesn't work as $(top_srcdir)/git.mk inside the 51# submodule doesn't find us. If you have configure.{in,ac} files in 52# subdirs, add a proxy git.mk file in those dirs that simply does: 53# "include $(top_srcdir)/../git.mk". Add more ..'s to your taste. 54# And add those files to git. See vte/gnome-pty-helper/git.mk for 55# example. 56# 57 58git-all: git-mk-install 59 60git-mk-install: 61 @echo Installing git makefile 62 @any_failed=; \ 63 find "`test -z "$(top_srcdir)" && echo . || echo "$(top_srcdir)"`" -name Makefile.am | while read x; do \ 64 if grep 'include .*/git.mk' $$x >/dev/null; then \ 65 echo $$x already includes git.mk; \ 66 else \ 67 failed=; \ 68 echo "Updating $$x"; \ 69 { cat $$x; \ 70 echo ''; \ 71 echo '-include $$(top_srcdir)/git.mk'; \ 72 } > $$x.tmp || failed=1; \ 73 if test x$$failed = x; then \ 74 mv $$x.tmp $$x || failed=1; \ 75 fi; \ 76 if test x$$failed = x; then : else \ 77 echo Failed updating $$x; >&2 \ 78 any_failed=1; \ 79 fi; \ 80 fi; done; test -z "$$any_failed" 81 82.PHONY: git-all git-mk-install 83 84 85### .gitignore generation 86 87$(srcdir)/.gitignore: Makefile.am $(top_srcdir)/git.mk 88 $(AM_V_GEN) \ 89 { \ 90 if test "x$(DOC_MODULE)" = x -o "x$(DOC_MAIN_SGML_FILE)" = x; then :; else \ 91 for x in \ 92 $(DOC_MODULE)-decl-list.txt \ 93 $(DOC_MODULE)-decl.txt \ 94 tmpl/$(DOC_MODULE)-unused.sgml \ 95 "tmpl/*.bak" \ 96 xml html \ 97 ; do echo /$$x; done; \ 98 fi; \ 99 if test "x$(DOC_MODULE)$(DOC_ID)" = x -o "x$(DOC_LINGUAS)" = x; then :; else \ 100 for x in \ 101 $(_DOC_C_DOCS) \ 102 $(_DOC_LC_DOCS) \ 103 $(_DOC_OMF_ALL) \ 104 $(_DOC_DSK_ALL) \ 105 $(_DOC_HTML_ALL) \ 106 $(_DOC_MOFILES) \ 107 $(_DOC_POFILES) \ 108 $(DOC_H_FILE) \ 109 "*/.xml2po.mo" \ 110 "*/*.omf.out" \ 111 ; do echo /$$x; done; \ 112 fi; \ 113 if test "x$(HELP_ID)" = x -o "x$(HELP_LINGUAS)" = x; then :; else \ 114 for x in \ 115 $(_HELP_LC_FILES) \ 116 $(_HELP_LC_STAMPS) \ 117 $(_HELP_MOFILES) \ 118 ; do echo /$$x; done; \ 119 fi; \ 120 if test "x$(gsettings_SCHEMAS)" = x; then :; else \ 121 for x in \ 122 $(gsettings_SCHEMAS:.xml=.valid) \ 123 $(gsettings__enum_file) \ 124 ; do echo /$$x; done; \ 125 fi; \ 126 if test -f $(srcdir)/po/Makefile.in.in; then \ 127 for x in \ 128 po/Makefile.in.in \ 129 po/Makefile.in \ 130 po/Makefile \ 131 po/POTFILES \ 132 po/stamp-it \ 133 po/.intltool-merge-cache \ 134 "po/*.gmo" \ 135 "po/*.mo" \ 136 po/$(GETTEXT_PACKAGE).pot \ 137 intltool-extract.in \ 138 intltool-merge.in \ 139 intltool-update.in \ 140 ; do echo /$$x; done; \ 141 fi; \ 142 if test -f $(srcdir)/configure; then \ 143 for x in \ 144 autom4te.cache \ 145 configure \ 146 config.h \ 147 stamp-h1 \ 148 libtool \ 149 config.lt \ 150 ; do echo /$$x; done; \ 151 fi; \ 152 for x in \ 153 .gitignore \ 154 $(GITIGNOREFILES) \ 155 $(CLEANFILES) \ 156 $(PROGRAMS) \ 157 $(check_PROGRAMS) \ 158 $(EXTRA_PROGRAMS) \ 159 $(LTLIBRARIES) \ 160 so_locations \ 161 .libs _libs \ 162 $(MOSTLYCLEANFILES) \ 163 "*.$(OBJEXT)" \ 164 "*.lo" \ 165 $(DISTCLEANFILES) \ 166 $(am__CONFIG_DISTCLEAN_FILES) \ 167 $(CONFIG_CLEAN_FILES) \ 168 TAGS ID GTAGS GRTAGS GSYMS GPATH tags \ 169 "*.tab.c" \ 170 $(MAINTAINERCLEANFILES) \ 171 $(BUILT_SOURCES) \ 172 $(DEPDIR) \ 173 Makefile \ 174 Makefile.in \ 175 "*.orig" \ 176 "*.rej" \ 177 "*.bak" \ 178 "*~" \ 179 ".*.sw[nop]" \ 180 ".dirstamp" \ 181 ; do echo /$$x; done; \ 182 } | \ 183 sed "s@^/`echo "$(srcdir)" | sed 's/\(.\)/[\1]/g'`/@/@" | \ 184 sed 's@/[.]/@/@g' | \ 185 LC_ALL=C sort | uniq > $@.tmp && \ 186 mv $@.tmp $@; 187 188all: $(srcdir)/.gitignore gitignore-recurse-maybe 189gitignore-recurse-maybe: 190 @if test "x$(SUBDIRS)" = "x$(DIST_SUBDIRS)"; then :; else \ 191 $(MAKE) $(AM_MAKEFLAGS) gitignore-recurse; \ 192 fi; 193gitignore-recurse: 194 @for subdir in $(DIST_SUBDIRS); do \ 195 case " $(SUBDIRS) " in \ 196 *" $$subdir "*) :;; \ 197 *) test "$$subdir" = . || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) .gitignore gitignore-recurse || echo "Skipping $$subdir");; \ 198 esac; \ 199 done 200gitignore: $(srcdir)/.gitignore gitignore-recurse 201 202maintainer-clean: gitignore-clean 203gitignore-clean: 204 -rm -f $(srcdir)/.gitignore 205 206.PHONY: gitignore-clean gitignore gitignore-recurse gitignore-recurse-maybe 207