git.mk 12 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401
  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, hotdoc.
  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.rpath \
  86. config.sub \
  87. depcomp \
  88. install-sh \
  89. ltmain.sh \
  90. missing \
  91. mkinstalldirs \
  92. test-driver \
  93. ylwrap \
  94. ; do echo "$$AUX_DIR/$$x"; done` \
  95. `cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_HEADERS:$$1' ./configure.ac | \
  96. head -n 1 | while read f; do echo "$(srcdir)/$$f.in"; done`
  97. #
  98. # All modules should also be fine including the following variable, which
  99. # removes automake-generated Makefile.in files:
  100. GITIGNORE_MAINTAINERCLEANFILES_MAKEFILE_IN = \
  101. `cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_FILES:$$1' ./configure.ac | \
  102. while read f; do \
  103. case $$f in Makefile|*/Makefile) \
  104. test -f "$(srcdir)/$$f.am" && echo "$(srcdir)/$$f.in";; esac; \
  105. done`
  106. #
  107. # Modules that use libtool and use AC_CONFIG_MACRO_DIR() may also include this,
  108. # though it's harmless to include regardless.
  109. GITIGNORE_MAINTAINERCLEANFILES_M4_LIBTOOL = \
  110. `MACRO_DIR=$(srcdir)/$$(cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_MACRO_DIR:$$1' ./configure.ac); \
  111. if test "x$$MACRO_DIR" != "x$(srcdir)/"; then \
  112. for x in \
  113. libtool.m4 \
  114. ltoptions.m4 \
  115. ltsugar.m4 \
  116. ltversion.m4 \
  117. lt~obsolete.m4 \
  118. ; do echo "$$MACRO_DIR/$$x"; done; \
  119. fi`
  120. #
  121. # Modules that use gettext and use AC_CONFIG_MACRO_DIR() may also include this,
  122. # though it's harmless to include regardless.
  123. GITIGNORE_MAINTAINERCLEANFILES_M4_GETTEXT = \
  124. `MACRO_DIR=$(srcdir)/$$(cd $(top_srcdir); $(AUTOCONF) --trace 'AC_CONFIG_MACRO_DIR:$$1' ./configure.ac); \
  125. if test "x$$MACRO_DIR" != "x$(srcdir)/"; then \
  126. for x in \
  127. codeset.m4 \
  128. extern-inline.m4 \
  129. fcntl-o.m4 \
  130. gettext.m4 \
  131. glibc2.m4 \
  132. glibc21.m4 \
  133. iconv.m4 \
  134. intdiv0.m4 \
  135. intl.m4 \
  136. intldir.m4 \
  137. intlmacosx.m4 \
  138. intmax.m4 \
  139. inttypes-pri.m4 \
  140. inttypes_h.m4 \
  141. lcmessage.m4 \
  142. lib-ld.m4 \
  143. lib-link.m4 \
  144. lib-prefix.m4 \
  145. lock.m4 \
  146. longlong.m4 \
  147. nls.m4 \
  148. po.m4 \
  149. printf-posix.m4 \
  150. progtest.m4 \
  151. size_max.m4 \
  152. stdint_h.m4 \
  153. threadlib.m4 \
  154. uintmax_t.m4 \
  155. visibility.m4 \
  156. wchar_t.m4 \
  157. wint_t.m4 \
  158. xsize.m4 \
  159. ; do echo "$$MACRO_DIR/$$x"; done; \
  160. fi`
  161. ###############################################################################
  162. # Default rule is to install ourselves in all Makefile.am files:
  163. ###############################################################################
  164. git-all: git-mk-install
  165. git-mk-install:
  166. @echo "Installing git makefile"
  167. @any_failed=; \
  168. find "`test -z "$(top_srcdir)" && echo . || echo "$(top_srcdir)"`" -name Makefile.am | while read x; do \
  169. if grep 'include .*/git.mk' $$x >/dev/null; then \
  170. echo "$$x already includes git.mk"; \
  171. else \
  172. failed=; \
  173. echo "Updating $$x"; \
  174. { cat $$x; \
  175. echo ''; \
  176. echo '-include $$(top_srcdir)/git.mk'; \
  177. } > $$x.tmp || failed=1; \
  178. if test x$$failed = x; then \
  179. mv $$x.tmp $$x || failed=1; \
  180. fi; \
  181. if test x$$failed = x; then : else \
  182. echo "Failed updating $$x"; >&2 \
  183. any_failed=1; \
  184. fi; \
  185. fi; done; test -z "$$any_failed"
  186. git-mk-update:
  187. wget $(GIT_MK_URL) -O $(top_srcdir)/git.mk
  188. .PHONY: git-all git-mk-install git-mk-update
  189. ###############################################################################
  190. # Actual .gitignore generation:
  191. ###############################################################################
  192. $(srcdir)/.gitignore: Makefile.am $(top_srcdir)/git.mk $(top_srcdir)/configure.ac
  193. @echo "git.mk: Generating $@"
  194. @{ \
  195. if test "x$(DOC_MODULE)" = x -o "x$(DOC_MAIN_SGML_FILE)" = x; then :; else \
  196. for x in \
  197. $(DOC_MODULE)-decl-list.txt \
  198. $(DOC_MODULE)-decl.txt \
  199. tmpl/$(DOC_MODULE)-unused.sgml \
  200. "tmpl/*.bak" \
  201. $(REPORT_FILES) \
  202. $(DOC_MODULE).pdf \
  203. xml html \
  204. ; do echo "/$$x"; done; \
  205. FLAVOR=$$(cd $(top_srcdir); $(AUTOCONF) --trace 'GTK_DOC_CHECK:$$2' ./configure.ac); \
  206. case $$FLAVOR in *no-tmpl*) echo /tmpl;; esac; \
  207. if echo "$(SCAN_OPTIONS)" | grep -q "\-\-rebuild-types"; then \
  208. echo "/$(DOC_MODULE).types"; \
  209. fi; \
  210. if echo "$(SCAN_OPTIONS)" | grep -q "\-\-rebuild-sections"; then \
  211. echo "/$(DOC_MODULE)-sections.txt"; \
  212. fi; \
  213. if test "$(abs_srcdir)" != "$(abs_builddir)" ; then \
  214. for x in \
  215. $(SETUP_FILES) \
  216. $(DOC_MODULE).types \
  217. ; do echo "/$$x"; done; \
  218. fi; \
  219. fi; \
  220. if test "x$(DOC_MODULE)$(DOC_ID)" = x -o "x$(DOC_LINGUAS)" = x; then :; else \
  221. for lc in $(DOC_LINGUAS); do \
  222. for x in \
  223. $(if $(DOC_MODULE),$(DOC_MODULE).xml) \
  224. $(DOC_PAGES) \
  225. $(DOC_INCLUDES) \
  226. ; do echo "/$$lc/$$x"; done; \
  227. done; \
  228. for x in \
  229. $(_DOC_OMF_ALL) \
  230. $(_DOC_DSK_ALL) \
  231. $(_DOC_HTML_ALL) \
  232. $(_DOC_MOFILES) \
  233. $(DOC_H_FILE) \
  234. "*/.xml2po.mo" \
  235. "*/*.omf.out" \
  236. ; do echo /$$x; done; \
  237. fi; \
  238. if test "x$(HOTDOC)" = x; then :; else \
  239. $(foreach project, $(HOTDOC_PROJECTS),echo "/$(call HOTDOC_TARGET,$(project))"; \
  240. echo "/$(shell $(call HOTDOC_PROJECT_COMMAND,$(project)) --get-conf-path output)" ; \
  241. echo "/$(shell $(call HOTDOC_PROJECT_COMMAND,$(project)) --get-private-folder)" ; \
  242. ) \
  243. for x in \
  244. .hotdoc.d \
  245. ; do echo "/$$x"; done; \
  246. fi; \
  247. if test "x$(HELP_ID)" = x -o "x$(HELP_LINGUAS)" = x; then :; else \
  248. for lc in $(HELP_LINGUAS); do \
  249. for x in \
  250. $(HELP_FILES) \
  251. "$$lc.stamp" \
  252. "$$lc.mo" \
  253. ; do echo "/$$lc/$$x"; done; \
  254. done; \
  255. fi; \
  256. if test "x$(gsettings_SCHEMAS)" = x; then :; else \
  257. for x in \
  258. $(gsettings_SCHEMAS:.xml=.valid) \
  259. $(gsettings__enum_file) \
  260. ; do echo "/$$x"; done; \
  261. fi; \
  262. if test "x$(appdata_XML)" = x; then :; else \
  263. for x in \
  264. $(appdata_XML:.xml=.valid) \
  265. ; do echo "/$$x"; done; \
  266. fi; \
  267. if test "x$(appstream_XML)" = x; then :; else \
  268. for x in \
  269. $(appstream_XML:.xml=.valid) \
  270. ; do echo "/$$x"; done; \
  271. fi; \
  272. if test -f $(srcdir)/po/Makefile.in.in; then \
  273. for x in \
  274. ABOUT-NLS \
  275. po/Makefile.in.in \
  276. po/Makefile.in.in~ \
  277. po/Makefile.in \
  278. po/Makefile \
  279. po/Makevars.template \
  280. po/POTFILES \
  281. po/Rules-quot \
  282. po/stamp-it \
  283. po/stamp-po \
  284. po/.intltool-merge-cache \
  285. "po/*.gmo" \
  286. "po/*.header" \
  287. "po/*.mo" \
  288. "po/*.sed" \
  289. "po/*.sin" \
  290. po/$(GETTEXT_PACKAGE).pot \
  291. intltool-extract.in \
  292. intltool-merge.in \
  293. intltool-update.in \
  294. ; do echo "/$$x"; done; \
  295. fi; \
  296. if test -f $(srcdir)/configure; then \
  297. for x in \
  298. autom4te.cache \
  299. configure \
  300. config.h \
  301. stamp-h1 \
  302. libtool \
  303. config.lt \
  304. ; do echo "/$$x"; done; \
  305. fi; \
  306. if test "x$(DEJATOOL)" = x; then :; else \
  307. for x in \
  308. $(DEJATOOL) \
  309. ; do echo "/$$x.sum"; echo "/$$x.log"; done; \
  310. echo /site.exp; \
  311. fi; \
  312. if test "x$(am__dirstamp)" = x; then :; else \
  313. echo "$(am__dirstamp)"; \
  314. fi; \
  315. if test "x$(findstring libtool,$(LTCOMPILE))" = x -a "x$(findstring libtool,$(LTCXXCOMPILE))" = x -a "x$(GTKDOC_RUN)" = x; then :; else \
  316. for x in \
  317. "*.lo" \
  318. ".libs" "_libs" \
  319. ; do echo "$$x"; done; \
  320. fi; \
  321. for x in \
  322. .gitignore \
  323. $(GITIGNOREFILES) \
  324. $(CLEANFILES) \
  325. $(PROGRAMS) $(check_PROGRAMS) $(EXTRA_PROGRAMS) \
  326. $(LIBRARIES) $(check_LIBRARIES) $(EXTRA_LIBRARIES) \
  327. $(LTLIBRARIES) $(check_LTLIBRARIES) $(EXTRA_LTLIBRARIES) \
  328. so_locations \
  329. $(MOSTLYCLEANFILES) \
  330. $(TEST_LOGS) \
  331. $(TEST_LOGS:.log=.trs) \
  332. $(TEST_SUITE_LOG) \
  333. $(TESTS:=.test) \
  334. "*.gcda" \
  335. "*.gcno" \
  336. $(DISTCLEANFILES) \
  337. $(am__CONFIG_DISTCLEAN_FILES) \
  338. $(CONFIG_CLEAN_FILES) \
  339. TAGS ID GTAGS GRTAGS GSYMS GPATH tags \
  340. "*.tab.c" \
  341. $(MAINTAINERCLEANFILES) \
  342. $(BUILT_SOURCES) \
  343. $(patsubst %.vala,%.c,$(filter %.vala,$(SOURCES))) \
  344. $(filter %_vala.stamp,$(DIST_COMMON)) \
  345. $(filter %.vapi,$(DIST_COMMON)) \
  346. $(filter $(addprefix %,$(notdir $(patsubst %.vapi,%.h,$(filter %.vapi,$(DIST_COMMON))))),$(DIST_COMMON)) \
  347. Makefile \
  348. Makefile.in \
  349. "*.orig" \
  350. "*.rej" \
  351. "*.bak" \
  352. "*~" \
  353. ".*.sw[nop]" \
  354. ".dirstamp" \
  355. ; do echo "/$$x"; done; \
  356. for x in \
  357. "*.$(OBJEXT)" \
  358. $(DEPDIR) \
  359. ; do echo "$$x"; done; \
  360. } | \
  361. sed "s@^/`echo "$(srcdir)" | sed 's/\(.\)/[\1]/g'`/@/@" | \
  362. sed 's@/[.]/@/@g' | \
  363. LC_ALL=C sort | uniq > .gitignore.tmp && \
  364. (mv .gitignore.tmp $@ || (echo "WARNING: Cannot create $@ file; skipping"; \
  365. $(RM) .gitignore.tmp));
  366. all: $(srcdir)/.gitignore gitignore-recurse-maybe
  367. gitignore: $(srcdir)/.gitignore gitignore-recurse
  368. gitignore-recurse-maybe:
  369. @for subdir in $(DIST_SUBDIRS); do \
  370. case " $(SUBDIRS) " in \
  371. *" $$subdir "*) :;; \
  372. *) test "$$subdir" = . -o -e "$$subdir/.git" || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) gitignore || echo "Skipping $$subdir");; \
  373. esac; \
  374. done
  375. gitignore-recurse:
  376. @for subdir in $(DIST_SUBDIRS); do \
  377. test "$$subdir" = . -o -e "$$subdir/.git" || (cd $$subdir && $(MAKE) $(AM_MAKEFLAGS) gitignore || echo "Skipping $$subdir"); \
  378. done
  379. maintainer-clean: gitignore-clean
  380. gitignore-clean:
  381. -rm -f $(srcdir)/.gitignore
  382. .PHONY: gitignore-clean gitignore gitignore-recurse gitignore-recurse-maybe