Doc: auto-detect changed build flags
If you build the documentation switching between different options, e.g., to build with both Asciidoc and Asciidoctor, you'll probably find yourself running `make -C Documentation clean` either too often (wasting time) or too rarely (getting mixed builds). Track the flags we're using in the documentation build, similar to how the main Makefile tracks CFLAGS and prefix flags. Track ASCIIDOC_COMMON directly rather than its individual components -- that should make it harder to forget to update the tracking if/when we modify the build commands. Signed-off-by: Martin Ågren <martin.agren@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Martin Ågren committed
Mar 17, 2019 at 19:36 UTC
9a71722b4df993475553ea499fdf44dab5fed544
2 files changed
+18
-6
Documentation/.gitignore
+1
@@ -13,3 +13,4 @@ mergetools-*.txt
13
manpage-base-url.xsl
14
SubmittingPatches.txt
15
tmp-doc-diff/
16
+GIT-ASCIIDOCFLAGS
Documentation/Makefile
+17
-6
@@ -331,6 +331,15 @@ mergetools-list.made: ../git-mergetool--lib.sh $(wildcard ../mergetools/*)
331
show_tool_names can_merge "* " || :' >mergetools-merge.txt && \
332
date >$@
333
334
+TRACK_ASCIIDOCFLAGS = $(subst ','\'',$(ASCIIDOC_COMMON):$(ASCIIDOC_HTML):$(ASCIIDOC_DOCBOOK))
335
+
336
+GIT-ASCIIDOCFLAGS: FORCE
337
+ @FLAGS='$(TRACK_ASCIIDOCFLAGS)'; \
338
+ if test x"$$FLAGS" != x"`cat GIT-ASCIIDOCFLAGS 2>/dev/null`" ; then \
339
+ echo >&2 " * new asciidoc flags"; \
340
+ echo "$$FLAGS" >GIT-ASCIIDOCFLAGS; \
341
+ fi
342
+
343
clean:
344
$(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
345
$(RM) *.texi *.texi+ *.texi++ git.info gitman.info
@@ -340,13 +349,14 @@ clean:
349
$(RM) SubmittingPatches.txt
350
$(RM) $(cmds_txt) $(mergetools_txt) *.made
351
$(RM) manpage-base-url.xsl
352
+ $(RM) GIT-ASCIIDOCFLAGS
353
344
-$(MAN_HTML): %.html : %.txt asciidoc.conf
354
+$(MAN_HTML): %.html : %.txt asciidoc.conf GIT-ASCIIDOCFLAGS
355
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
356
$(TXT_TO_HTML) -d manpage -o $@+ $< && \
357
mv $@+ $@
358
349
-$(OBSOLETE_HTML): %.html : %.txto asciidoc.conf
359
+$(OBSOLETE_HTML): %.html : %.txto asciidoc.conf GIT-ASCIIDOCFLAGS
360
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
361
$(TXT_TO_HTML) -o $@+ $< && \
362
mv $@+ $@
@@ -358,12 +368,12 @@ manpage-base-url.xsl: manpage-base-url.xsl.in
368
$(QUIET_XMLTO)$(RM) $@ && \
369
$(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
370
361
-%.xml : %.txt asciidoc.conf
371
+%.xml : %.txt asciidoc.conf GIT-ASCIIDOCFLAGS
372
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
373
$(TXT_TO_XML) -d manpage -o $@+ $< && \
374
mv $@+ $@
375
366
-user-manual.xml: user-manual.txt user-manual.conf
376
+user-manual.xml: user-manual.txt user-manual.conf GIT-ASCIIDOCFLAGS
377
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
378
$(TXT_TO_XML) -d book -o $@+ $< && \
379
mv $@+ $@
@@ -373,7 +383,8 @@ technical/api-index.txt: technical/api-index-skel.txt \
383
$(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
384
385
technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
376
-$(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt asciidoc.conf
386
+$(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt \
387
+ asciidoc.conf GIT-ASCIIDOCFLAGS
388
$(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
389
390
SubmittingPatches.txt: SubmittingPatches
@@ -430,7 +441,7 @@ $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
441
WEBDOC_DEST = /pub/software/scm/git/docs
442
443
howto/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
433
-$(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
444
+$(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt GIT-ASCIIDOCFLAGS
445
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
446
sed -e '1,/^$$/d' $< | \
447
$(TXT_TO_HTML) - >$@+ && \