git.mk 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348
  1. # git.mk, a small Makefile to autogenerate .gitignore files
  2. # for autotools-based projects.
  3. #
  4. # Copyright 2009, Red Hat, Inc.
  5. # Copyright 2010,2011,2012,2013 Behdad Esfahbod
  6. # Written by Behdad Esfahbod
  7. #
  8. # Copying and distribution of this file, with or without modification,
  9. # is permitted in any medium without royalty provided the copyright
  10. # notice and this notice are preserved.
  11. #
  12. # The latest version of this file can be downloaded from:
  13. GIT_MK_URL = https://raw.githubusercontent.com/behdad/git.mk/master/git.mk
  14. #
  15. # Bugs, etc, should be reported upstream at:
  16. # https://github.com/behdad/git.mk
  17. #
  18. # To use in your project, import this file in your git repo's toplevel,
  19. # then do "make -f git.mk". This modifies all Makefile.am files in
  20. # your project to -include git.mk. Remember to add that line to new
  21. # Makefile.am files you create in your project, or just rerun the
  22. # "make -f git.mk".
  23. #
  24. # This enables automatic .gitignore generation. If you need to ignore
  25. # more files, add them to the GITIGNOREFILES variable in your Makefile.am.
  26. # But think twice before doing that. If a file has to be in .gitignore,
  27. # chances are very high that it's a generated file and should be in one
  28. # of MOSTLYCLEANFILES, CLEANFILES, DISTCLEANFILES, or MAINTAINERCLEANFILES.
  29. #
  30. # The only case that you need to manually add a file to GITIGNOREFILES is
  31. # when remove files in one of mostlyclean-local, clean-local, distclean-local,
  32. # or maintainer-clean-local make targets.
  33. #
  34. # Note that for files like editor backup, etc, there are better places to
  35. # ignore them. See "man gitignore".
  36. #
  37. # If "make maintainer-clean" removes the files but they are not recognized
  38. # by this script (that is, if "git status" shows untracked files still), send
  39. # me the output of "git status" as well as your Makefile.am and Makefile for
  40. # the directories involved and I'll diagnose.
  41. #
  42. # For a list of toplevel files that should be in MAINTAINERCLEANFILES, see
  43. # Makefile.am.sample in the git.mk git repo.
  44. #
  45. # Don't EXTRA_DIST this file. It is supposed to only live in git clones,
  46. # not tarballs. It serves no useful purpose in tarballs and clutters the
  47. # build dir.
  48. #
  49. # This file knows how to handle autoconf, automake, libtool, gtk-doc,
  50. # gnome-doc-utils, yelp.m4, mallard, intltool, gsettings, dejagnu, appdata,
  51. # appstream.
  52. #
  53. # This makefile provides the following targets:
  54. #
  55. # - all: "make all" will build all gitignore files.
  56. # - gitignore: makes all gitignore files in the current dir and subdirs.
  57. # - .gitignore: make gitignore file for the current dir.
  58. # - gitignore-recurse: makes all gitignore files in the subdirs.
  59. #
  60. # KNOWN ISSUES:
  61. #
  62. # - Recursive configure doesn't work as $(top_srcdir)/git.mk inside the
  63. # submodule doesn't find us. If you have configure.{in,ac} files in
  64. # subdirs, add a proxy git.mk file in those dirs that simply does:
  65. # "include $(top_srcdir)/../git.mk". Add more ..'s to your taste.
  66. # And add those files to git. See vte/gnome-pty-helper/git.mk for
  67. # example.
  68. #
  69. ###############################################################################
  70. # Variables user modules may want to add to toplevel MAINTAINERCLEANFILES:
  71. ###############################################################################
  72. #
  73. # Most autotools-using modules should be fine including this variable in their
  74. # toplevel MAINTAINERCLEANFILES:
  75. GITIGNORE_MAINTAINERCLEANFILES_TOPLEVEL = \
  76. $(srcdir)/aclocal.m4 \
  77. $(srcdir)/autoscan.log \
  78. $(srcdir)/configure.scan \
  79. `AUX_DIR=$(srcdir)/$$(cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_AUX_DIR:$$1' ./configure.ac); \
  80. test "x$$AUX_DIR" = "x$(srcdir)/" && AUX_DIR=$(srcdir); \
  81. for x in \
  82. ar-lib \
  83. compile \
  84. config.guess \
  85. config.sub \
  86. depcomp \
  87. install-sh \
  88. ltmain.sh \
  89. missing \
  90. mkinstalldirs \
  91. test-driver \
  92. ylwrap \
  93. ; do echo "$$AUX_DIR/$$x"; done` \
  94. `cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_HEADERS:$$1' ./configure.ac | \
  95. head -n 1 | while read f; do echo "$(srcdir)/$$f.in"; done`
  96. #
  97. # All modules should also be fine including the following variable, which
  98. # removes automake-generated Makefile.in files:
  99. GITIGNORE_MAINTAINERCLEANFILES_MAKEFILE_IN = \
  100. `cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_FILES:$$1' ./configure.ac | \
  101. while read f; do \
  102. case $$f in Makefile|*/Makefile) \
  103. test -f "$(srcdir)/$$f.am" && echo "$(srcdir)/$$f.in";; esac; \
  104. done`
  105. #
  106. # Modules that use libtool and use AC_CONFIG_MACRO_DIR() may also include this,
  107. # though it's harmless to include regardless.
  108. GITIGNORE_MAINTAINERCLEANFILES_M4_LIBTOOL = \
  109. `MACRO_DIR=$(srcdir)/$$(cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_MACRO_DIR:$$1' ./configure.ac); \
  110. if test "x$$MACRO_DIR" != "x$(srcdir)/"; then \
  111. for x in \
  112. libtool.m4 \
  113. ltoptions.m4 \
  114. ltsugar.m4 \
  115. ltversion.m4 \
  116. lt~obsolete.m4 \
  117. ; do echo "$$MACRO_DIR/$$x"; done; \
  118. fi`
  119. ###############################################################################
  120. # Default rule is to install ourselves in all Makefile.am files:
  121. ###############################################################################
  122. git-all: git-mk-install
  123. git-mk-install:
  124. @echo "Installing git makefile"
  125. @any_failed=; \
  126. find "`test -z "$(top_srcdir)" && echo . || echo "$(top_srcdir)"`" -name Makefile.am | while read x; do \
  127. if grep 'include .*/git.mk' $$x >/dev/null; then \
  128. echo "$$x already includes git.mk"; \
  129. else \
  130. failed=; \
  131. echo "Updating $$x"; \
  132. { cat $$x; \
  133. echo ''; \
  134. echo '-include $$(top_srcdir)/git.mk'; \
  135. } > $$x.tmp || failed=1; \
  136. if test x$$failed = x; then \
  137. mv $$x.tmp $$x || failed=1; \
  138. fi; \
  139. if test x$$failed = x; then : else \
  140. echo "Failed updating $$x"; >&2 \
  141. any_failed=1; \
  142. fi; \
  143. fi; done; test -z "$$any_failed"
  144. git-mk-update:
  145. wget $(GIT_MK_URL) -O $(top_srcdir)/git.mk
  146. .PHONY: git-all git-mk-install git-mk-update
  147. ###############################################################################
  148. # Actual .gitignore generation:
  149. ###############################################################################
  150. $(srcdir)/.gitignore: Makefile.am $(top_srcdir)/git.mk
  151. @echo "git.mk: Generating $@"
  152. @{ \
  153. if test "x$(DOC_MODULE)" = x -o "x$(DOC_MAIN_SGML_FILE)" = x; then :; else \
  154. for x in \
  155. $(DOC_MODULE)-decl-list.txt \
  156. $(DOC_MODULE)-decl.txt \
  157. tmpl/$(DOC_MODULE)-unused.sgml \
  158. "tmpl/*.bak" \
  159. $(REPORT_FILES) \
  160. $(DOC_MODULE).pdf \
  161. xml html \
  162. ; do echo "/$$x"; done; \
  163. FLAVOR=$$(cd $(top_srcdir); $(AUTOCONF) --trace 'GTK_DOC_CHECK:$$2' ./configure.ac); \
  164. case $$FLAVOR in *no-tmpl*) echo /tmpl;; esac; \
  165. if echo "$(SCAN_OPTIONS)" | grep -q "\-\-rebuild-types"; then \
  166. echo "/$(DOC_MODULE).types"; \
  167. fi; \
  168. if echo "$(SCAN_OPTIONS)" | grep -q "\-\-rebuild-sections"; then \
  169. echo "/$(DOC_MODULE)-sections.txt"; \
  170. fi; \
  171. if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
  172. for x in \
  173. $(SETUP_FILES) \
  174. $(DOC_MODULE).types \
  175. ; do echo "/$$x"; done; \
  176. fi; \
  177. fi; \
  178. if test "x$(DOC_MODULE)$(DOC_ID)" = x -o "x$(DOC_LINGUAS)" = x; then :; else \
  179. for lc in $(DOC_LINGUAS); do \
  180. for x in \
  181. $(if $(DOC_MODULE),$(DOC_MODULE).xml) \
  182. $(DOC_PAGES) \
  183. $(DOC_INCLUDES) \
  184. ; do echo "/$$lc/$$x"; done; \
  185. done; \
  186. for x in \
  187. $(_DOC_OMF_ALL) \
  188. $(_DOC_DSK_ALL) \
  189. $(_DOC_HTML_ALL) \
  190. $(_DOC_MOFILES) \
  191. $(DOC_H_FILE) \
  192. "*/.xml2po.mo" \
  193. "*/*.omf.out" \
  194. ; do echo /$$x; done; \
  195. fi; \
  196. if test "x$(HELP_ID)" = x -o "x$(HELP_LINGUAS)" = x; then :; else \
  197. for lc in $(HELP_LINGUAS); do \
  198. for x in \
  199. $(HELP_FILES) \
  200. "$$lc.stamp" \
  201. "$$lc.mo" \
  202. ; do echo "/$$lc/$$x"; done; \
  203. done; \
  204. fi; \
  205. if test "x$(gsettings_SCHEMAS)" = x; then :; else \
  206. for x in \
  207. $(gsettings_SCHEMAS:.xml=.valid) \
  208. $(gsettings__enum_file) \
  209. ; do echo "/$$x"; done; \
  210. fi; \
  211. if test "x$(appdata_XML)" = x; then :; else \
  212. for x in \
  213. $(appdata_XML:.xml=.valid) \
  214. ; do echo "/$$x"; done; \
  215. fi; \
  216. if test "x$(appstream_XML)" = x; then :; else \
  217. for x in \
  218. $(appstream_XML:.xml=.valid) \
  219. ; do echo "/$$x"; done; \
  220. fi; \
  221. if test -f $(srcdir)/po/Makefile.in.in; then \
  222. for x in \
  223. po/Makefile.in.in \
  224. po/Makefile.in.in~ \
  225. po/Makefile.in \
  226. po/Makefile \
  227. po/Makevars.template \
  228. po/POTFILES \
  229. po/Rules-quot \
  230. po/stamp-it \
  231. po/.intltool-merge-cache \
  232. "po/*.gmo" \
  233. "po/*.header" \
  234. "po/*.mo" \
  235. "po/*.sed" \
  236. "po/*.sin" \
  237. po/$(GETTEXT_PACKAGE).pot \
  238. intltool-extract.in \
  239. intltool-merge.in \
  240. intltool-update.in \
  241. ; do echo "/$$x"; done; \
  242. fi; \
  243. if test -f $(srcdir)/configure; then \
  244. for x in \
  245. autom4te.cache \
  246. configure \
  247. config.h \
  248. stamp-h1 \
  249. libtool \
  250. config.lt \
  251. ; do echo "/$$x"; done; \
  252. fi; \
  253. if test "x$(DEJATOOL)" = x; then :; else \
  254. for x in \
  255. $(DEJATOOL) \
  256. ; do echo "/$$x.sum"; echo "/$$x.log"; done; \
  257. echo /site.exp; \
  258. fi; \
  259. if test "x$(am__dirstamp)" = x; then :; else \
  260. echo "$(am__dirstamp)"; \
  261. fi; \
  262. if test "x$(LTCOMPILE)" = x -a "x$(LTCXXCOMPILE)" = x -a "x$(GTKDOC_RUN)" = x; then :; else \
  263. for x in \
  264. "*.lo" \
  265. ".libs" "_libs" \
  266. ; do echo "$$x"; done; \
  267. fi; \
  268. for x in \
  269. .gitignore \
  270. $(GITIGNOREFILES) \
  271. $(CLEANFILES) \
  272. $(PROGRAMS) $(check_PROGRAMS) $(EXTRA_PROGRAMS) \
  273. $(LIBRARIES) $(check_LIBRARIES) $(EXTRA_LIBRARIES) \
  274. $(LTLIBRARIES) $(check_LTLIBRARIES) $(EXTRA_LTLIBRARIES) \
  275. so_locations \
  276. $(MOSTLYCLEANFILES) \
  277. $(TEST_LOGS) \
  278. $(TEST_LOGS:.log=.trs) \
  279. $(TEST_SUITE_LOG) \
  280. $(TESTS:=.test) \
  281. "*.gcda" \
  282. "*.gcno" \
  283. $(DISTCLEANFILES) \
  284. $(am__CONFIG_DISTCLEAN_FILES) \
  285. $(CONFIG_CLEAN_FILES) \
  286. TAGS ID GTAGS GRTAGS GSYMS GPATH tags \
  287. "*.tab.c" \
  288. $(MAINTAINERCLEANFILES) \
  289. $(BUILT_SOURCES) \
  290. $(patsubst %.vala,%.c,$(filter %.vala,$(SOURCES))) \
  291. $(filter %_vala.stamp,$(DIST_COMMON)) \
  292. $(filter %.vapi,$(DIST_COMMON)) \
  293. $(filter $(addprefix %,$(notdir $(patsubst %.vapi,%.h,$(filter %.vapi,$(DIST_COMMON))))),$(DIST_COMMON)) \
  294. Makefile \
  295. Makefile.in \
  296. "*.orig" \
  297. "*.rej" \
  298. "*.bak" \
  299. "*~" \
  300. ".*.sw[nop]" \
  301. ".dirstamp" \
  302. ; do echo "/$$x"; done; \
  303. for x in \
  304. "*.$(OBJEXT)" \
  305. $(DEPDIR) \
  306. ; do echo "$$x"; done; \
  307. } | \
  308. sed "s@^/`echo "$(srcdir)" | sed 's/\(.\)/[\1]/g'`/@/@" | \
  309. sed 's@/[.]/@/@g' | \
  310. LC_ALL=C sort | uniq > $@.tmp && \
  311. mv $@.tmp $@;
  312. all: $(srcdir)/.gitignore gitignore-recurse-maybe
  313. gitignore: $(srcdir)/.gitignore gitignore-recurse
  314. gitignore-recurse-maybe:
  315. @for subdir in $(DIST_SUBDIRS); do \
  316. case " $(SUBDIRS) " in \
  317. *" $$subdir "*) :;; \
  318. *) test "$$subdir" = . -o -e "$$subdir/.git" || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) gitignore || echo "Skipping $$subdir");; \
  319. esac; \
  320. done
  321. gitignore-recurse:
  322. @for subdir in $(DIST_SUBDIRS); do \
  323. test "$$subdir" = . -o -e "$$subdir/.git" || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) gitignore || echo "Skipping $$subdir"); \
  324. done
  325. maintainer-clean: gitignore-clean
  326. gitignore-clean:
  327. -rm -f $(srcdir)/.gitignore
  328. .PHONY: gitignore-clean gitignore gitignore-recurse gitignore-recurse-maybe