Skip to content

Commit 9a71722

Browse files
Martin Ågrengitster
authored andcommitted
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 0e94f7a commit 9a71722

File tree

2 files changed

+18
-6
lines changed

2 files changed

+18
-6
lines changed

Documentation/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -13,3 +13,4 @@ mergetools-*.txt
1313
manpage-base-url.xsl
1414
SubmittingPatches.txt
1515
tmp-doc-diff/
16+
GIT-ASCIIDOCFLAGS

Documentation/Makefile

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,15 @@ mergetools-list.made: ../git-mergetool--lib.sh $(wildcard ../mergetools/*)
331331
show_tool_names can_merge "* " || :' >mergetools-merge.txt && \
332332
date >$@
333333

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+
334343
clean:
335344
$(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
336345
$(RM) *.texi *.texi+ *.texi++ git.info gitman.info
@@ -340,13 +349,14 @@ clean:
340349
$(RM) SubmittingPatches.txt
341350
$(RM) $(cmds_txt) $(mergetools_txt) *.made
342351
$(RM) manpage-base-url.xsl
352+
$(RM) GIT-ASCIIDOCFLAGS
343353

344-
$(MAN_HTML): %.html : %.txt asciidoc.conf
354+
$(MAN_HTML): %.html : %.txt asciidoc.conf GIT-ASCIIDOCFLAGS
345355
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
346356
$(TXT_TO_HTML) -d manpage -o $@+ $< && \
347357
mv $@+ $@
348358

349-
$(OBSOLETE_HTML): %.html : %.txto asciidoc.conf
359+
$(OBSOLETE_HTML): %.html : %.txto asciidoc.conf GIT-ASCIIDOCFLAGS
350360
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
351361
$(TXT_TO_HTML) -o $@+ $< && \
352362
mv $@+ $@
@@ -358,12 +368,12 @@ manpage-base-url.xsl: manpage-base-url.xsl.in
358368
$(QUIET_XMLTO)$(RM) $@ && \
359369
$(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
360370

361-
%.xml : %.txt asciidoc.conf
371+
%.xml : %.txt asciidoc.conf GIT-ASCIIDOCFLAGS
362372
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
363373
$(TXT_TO_XML) -d manpage -o $@+ $< && \
364374
mv $@+ $@
365375

366-
user-manual.xml: user-manual.txt user-manual.conf
376+
user-manual.xml: user-manual.txt user-manual.conf GIT-ASCIIDOCFLAGS
367377
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
368378
$(TXT_TO_XML) -d book -o $@+ $< && \
369379
mv $@+ $@
@@ -373,7 +383,8 @@ technical/api-index.txt: technical/api-index-skel.txt \
373383
$(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
374384

375385
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
377388
$(QUIET_ASCIIDOC)$(TXT_TO_HTML) $*.txt
378389

379390
SubmittingPatches.txt: SubmittingPatches
@@ -430,7 +441,7 @@ $(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
430441
WEBDOC_DEST = /pub/software/scm/git/docs
431442

432443
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
434445
$(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
435446
sed -e '1,/^$$/d' $< | \
436447
$(TXT_TO_HTML) - >$@+ && \

0 commit comments

Comments
 (0)