Documentation / Makefileon commit doc: Makefile regularise OBSOLETE_HTML list building (5a568ea)
   1# Guard against environment variables
   2MAN1_TXT =
   3MAN5_TXT =
   4MAN7_TXT =
   5TECH_DOCS =
   6ARTICLES =
   7SP_ARTICLES =
   8OBSOLETE_HTML =
   9
  10MAN1_TXT += $(filter-out \
  11                $(addsuffix .txt, $(ARTICLES) $(SP_ARTICLES)), \
  12                $(wildcard git-*.txt))
  13MAN1_TXT += git.txt
  14MAN1_TXT += gitk.txt
  15MAN1_TXT += gitremote-helpers.txt
  16MAN1_TXT += gitweb.txt
  17
  18MAN5_TXT += gitattributes.txt
  19MAN5_TXT += githooks.txt
  20MAN5_TXT += gitignore.txt
  21MAN5_TXT += gitmodules.txt
  22MAN5_TXT += gitrepository-layout.txt
  23MAN5_TXT += gitweb.conf.txt
  24
  25MAN7_TXT += gitcli.txt
  26MAN7_TXT += gitcore-tutorial.txt
  27MAN7_TXT += gitcredentials.txt
  28MAN7_TXT += gitcvs-migration.txt
  29MAN7_TXT += gitdiffcore.txt
  30MAN7_TXT += gitglossary.txt
  31MAN7_TXT += gitnamespaces.txt
  32MAN7_TXT += gitrevisions.txt
  33MAN7_TXT += gittutorial-2.txt
  34MAN7_TXT += gittutorial.txt
  35MAN7_TXT += gitworkflows.txt
  36
  37MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)
  38MAN_XML = $(patsubst %.txt,%.xml,$(MAN_TXT))
  39MAN_HTML = $(patsubst %.txt,%.html,$(MAN_TXT))
  40
  41OBSOLETE_HTML += git-remote-helpers.html
  42DOC_HTML = $(MAN_HTML) $(OBSOLETE_HTML)
  43
  44ARTICLES += howto-index
  45ARTICLES += everyday
  46ARTICLES += git-tools
  47ARTICLES += git-bisect-lk2009
  48# with their own formatting rules.
  49SP_ARTICLES += user-manual
  50SP_ARTICLES += howto/new-command
  51SP_ARTICLES += howto/revert-branch-rebase
  52SP_ARTICLES += howto/using-merge-subtree
  53SP_ARTICLES += howto/using-signed-tag-in-pull-request
  54SP_ARTICLES += howto/use-git-daemon
  55SP_ARTICLES += howto/update-hook-example
  56SP_ARTICLES += howto/setup-git-server-over-http
  57SP_ARTICLES += howto/separating-topic-branches
  58SP_ARTICLES += howto/revert-a-faulty-merge
  59SP_ARTICLES += howto/recover-corrupted-blob-object
  60SP_ARTICLES += howto/recover-corrupted-object-harder
  61SP_ARTICLES += howto/rebuild-from-update-hook
  62SP_ARTICLES += howto/rebase-from-internal-branch
  63SP_ARTICLES += howto/keep-canonical-history-correct
  64SP_ARTICLES += howto/maintain-git
  65API_DOCS = $(patsubst %.txt,%,$(filter-out technical/api-index-skel.txt technical/api-index.txt, $(wildcard technical/api-*.txt)))
  66SP_ARTICLES += $(API_DOCS)
  67
  68TECH_DOCS += technical/http-protocol
  69TECH_DOCS += technical/index-format
  70TECH_DOCS += technical/pack-format
  71TECH_DOCS += technical/pack-heuristics
  72TECH_DOCS += technical/pack-protocol
  73TECH_DOCS += technical/protocol-capabilities
  74TECH_DOCS += technical/protocol-common
  75TECH_DOCS += technical/racy-git
  76TECH_DOCS += technical/send-pack-pipeline
  77TECH_DOCS += technical/shallow
  78TECH_DOCS += technical/trivial-merge
  79SP_ARTICLES += $(TECH_DOCS)
  80SP_ARTICLES += technical/api-index
  81
  82DOC_HTML += $(patsubst %,%.html,$(ARTICLES) $(SP_ARTICLES))
  83
  84DOC_MAN1 = $(patsubst %.txt,%.1,$(MAN1_TXT))
  85DOC_MAN5 = $(patsubst %.txt,%.5,$(MAN5_TXT))
  86DOC_MAN7 = $(patsubst %.txt,%.7,$(MAN7_TXT))
  87
  88prefix ?= $(HOME)
  89bindir ?= $(prefix)/bin
  90htmldir ?= $(prefix)/share/doc/git-doc
  91infodir ?= $(prefix)/share/info
  92pdfdir ?= $(prefix)/share/doc/git-doc
  93mandir ?= $(prefix)/share/man
  94man1dir = $(mandir)/man1
  95man5dir = $(mandir)/man5
  96man7dir = $(mandir)/man7
  97# DESTDIR =
  98
  99ASCIIDOC = asciidoc
 100ASCIIDOC_EXTRA =
 101MANPAGE_XSL = manpage-normal.xsl
 102XMLTO = xmlto
 103XMLTO_EXTRA =
 104INSTALL ?= install
 105RM ?= rm -f
 106MAN_REPO = ../../git-manpages
 107HTML_REPO = ../../git-htmldocs
 108
 109MAKEINFO = makeinfo
 110INSTALL_INFO = install-info
 111DOCBOOK2X_TEXI = docbook2x-texi
 112DBLATEX = dblatex
 113ASCIIDOC_DBLATEX_DIR = /etc/asciidoc/dblatex
 114ifndef PERL_PATH
 115        PERL_PATH = /usr/bin/perl
 116endif
 117
 118-include ../config.mak.autogen
 119-include ../config.mak
 120
 121#
 122# For docbook-xsl ...
 123#       -1.68.1,        no extra settings are needed?
 124#       1.69.0,         set ASCIIDOC_ROFF?
 125#       1.69.1-1.71.0,  set DOCBOOK_SUPPRESS_SP?
 126#       1.71.1,         set ASCIIDOC_ROFF?
 127#       1.72.0,         set DOCBOOK_XSL_172.
 128#       1.73.0-,        no extra settings are needed
 129#
 130
 131ifdef DOCBOOK_XSL_172
 132ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
 133MANPAGE_XSL = manpage-1.72.xsl
 134else
 135        ifndef ASCIIDOC_ROFF
 136        # docbook-xsl after 1.72 needs the regular XSL, but will not
 137        # pass-thru raw roff codes from asciidoc.conf, so turn them off.
 138        ASCIIDOC_EXTRA += -a git-asciidoc-no-roff
 139        endif
 140endif
 141ifdef MAN_BOLD_LITERAL
 142XMLTO_EXTRA += -m manpage-bold-literal.xsl
 143endif
 144ifdef DOCBOOK_SUPPRESS_SP
 145XMLTO_EXTRA += -m manpage-suppress-sp.xsl
 146endif
 147
 148# Newer DocBook stylesheet emits warning cruft in the output when
 149# this is not set, and if set it shows an absolute link.  Older
 150# stylesheets simply ignore this parameter.
 151#
 152# Distros may want to use MAN_BASE_URL=file:///path/to/git/docs/
 153# or similar.
 154ifndef MAN_BASE_URL
 155MAN_BASE_URL = file://$(htmldir)/
 156endif
 157XMLTO_EXTRA += -m manpage-base-url.xsl
 158
 159# If your target system uses GNU groff, it may try to render
 160# apostrophes as a "pretty" apostrophe using unicode.  This breaks
 161# cut&paste, so you should set GNU_ROFF to force them to be ASCII
 162# apostrophes.  Unfortunately does not work with non-GNU roff.
 163ifdef GNU_ROFF
 164XMLTO_EXTRA += -m manpage-quote-apos.xsl
 165endif
 166
 167SHELL_PATH ?= $(SHELL)
 168# Shell quote;
 169SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
 170
 171ifdef DEFAULT_PAGER
 172DEFAULT_PAGER_SQ = $(subst ','\'',$(DEFAULT_PAGER))
 173ASCIIDOC_EXTRA += -a 'git-default-pager=$(DEFAULT_PAGER_SQ)'
 174endif
 175
 176ifdef DEFAULT_EDITOR
 177DEFAULT_EDITOR_SQ = $(subst ','\'',$(DEFAULT_EDITOR))
 178ASCIIDOC_EXTRA += -a 'git-default-editor=$(DEFAULT_EDITOR_SQ)'
 179endif
 180
 181QUIET_SUBDIR0  = +$(MAKE) -C # space to separate -C and subdir
 182QUIET_SUBDIR1  =
 183
 184ifneq ($(findstring $(MAKEFLAGS),w),w)
 185PRINT_DIR = --no-print-directory
 186else # "make -w"
 187NO_SUBDIR = :
 188endif
 189
 190ifneq ($(findstring $(MAKEFLAGS),s),s)
 191ifndef V
 192        QUIET_ASCIIDOC  = @echo '   ' ASCIIDOC $@;
 193        QUIET_XMLTO     = @echo '   ' XMLTO $@;
 194        QUIET_DB2TEXI   = @echo '   ' DB2TEXI $@;
 195        QUIET_MAKEINFO  = @echo '   ' MAKEINFO $@;
 196        QUIET_DBLATEX   = @echo '   ' DBLATEX $@;
 197        QUIET_XSLTPROC  = @echo '   ' XSLTPROC $@;
 198        QUIET_GEN       = @echo '   ' GEN $@;
 199        QUIET_STDERR    = 2> /dev/null
 200        QUIET_SUBDIR0   = +@subdir=
 201        QUIET_SUBDIR1   = ;$(NO_SUBDIR) echo '   ' SUBDIR $$subdir; \
 202                          $(MAKE) $(PRINT_DIR) -C $$subdir
 203        export V
 204endif
 205endif
 206
 207all: html man
 208
 209html: $(DOC_HTML)
 210
 211man: man1 man5 man7
 212man1: $(DOC_MAN1)
 213man5: $(DOC_MAN5)
 214man7: $(DOC_MAN7)
 215
 216info: git.info gitman.info
 217
 218pdf: user-manual.pdf
 219
 220install: install-man
 221
 222install-man: man
 223        $(INSTALL) -d -m 755 $(DESTDIR)$(man1dir)
 224        $(INSTALL) -d -m 755 $(DESTDIR)$(man5dir)
 225        $(INSTALL) -d -m 755 $(DESTDIR)$(man7dir)
 226        $(INSTALL) -m 644 $(DOC_MAN1) $(DESTDIR)$(man1dir)
 227        $(INSTALL) -m 644 $(DOC_MAN5) $(DESTDIR)$(man5dir)
 228        $(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
 229
 230install-info: info
 231        $(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
 232        $(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(infodir)
 233        if test -r $(DESTDIR)$(infodir)/dir; then \
 234          $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\
 235          $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) gitman.info ;\
 236        else \
 237          echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
 238        fi
 239
 240install-pdf: pdf
 241        $(INSTALL) -d -m 755 $(DESTDIR)$(pdfdir)
 242        $(INSTALL) -m 644 user-manual.pdf $(DESTDIR)$(pdfdir)
 243
 244install-html: html
 245        '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
 246
 247../GIT-VERSION-FILE: FORCE
 248        $(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
 249
 250-include ../GIT-VERSION-FILE
 251
 252#
 253# Determine "include::" file references in asciidoc files.
 254#
 255docdep_prereqs = \
 256        mergetools-list.made $(mergetools_txt) \
 257        cmd-list.made $(cmds_txt)
 258
 259doc.dep : $(docdep_prereqs) $(wildcard *.txt) build-docdep.perl
 260        $(QUIET_GEN)$(RM) $@+ $@ && \
 261        $(PERL_PATH) ./build-docdep.perl >$@+ $(QUIET_STDERR) && \
 262        mv $@+ $@
 263
 264-include doc.dep
 265
 266cmds_txt = cmds-ancillaryinterrogators.txt \
 267        cmds-ancillarymanipulators.txt \
 268        cmds-mainporcelain.txt \
 269        cmds-plumbinginterrogators.txt \
 270        cmds-plumbingmanipulators.txt \
 271        cmds-synchingrepositories.txt \
 272        cmds-synchelpers.txt \
 273        cmds-purehelpers.txt \
 274        cmds-foreignscminterface.txt
 275
 276$(cmds_txt): cmd-list.made
 277
 278cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT)
 279        $(QUIET_GEN)$(RM) $@ && \
 280        $(PERL_PATH) ./cmd-list.perl ../command-list.txt $(QUIET_STDERR) && \
 281        date >$@
 282
 283mergetools_txt = mergetools-diff.txt mergetools-merge.txt
 284
 285$(mergetools_txt): mergetools-list.made
 286
 287mergetools-list.made: ../git-mergetool--lib.sh $(wildcard ../mergetools/*)
 288        $(QUIET_GEN)$(RM) $@ && \
 289        $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
 290                . ../git-mergetool--lib.sh && \
 291                show_tool_names can_diff "* " || :' >mergetools-diff.txt && \
 292        $(SHELL_PATH) -c 'MERGE_TOOLS_DIR=../mergetools && \
 293                . ../git-mergetool--lib.sh && \
 294                show_tool_names can_merge "* " || :' >mergetools-merge.txt && \
 295        date >$@
 296
 297clean:
 298        $(RM) *.xml *.xml+ *.html *.html+ *.1 *.5 *.7
 299        $(RM) *.texi *.texi+ *.texi++ git.info gitman.info
 300        $(RM) *.pdf
 301        $(RM) howto-index.txt howto/*.html doc.dep
 302        $(RM) technical/*.html technical/api-index.txt
 303        $(RM) $(cmds_txt) $(mergetools_txt) *.made
 304        $(RM) manpage-base-url.xsl
 305
 306$(MAN_HTML): %.html : %.txt asciidoc.conf
 307        $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
 308        $(ASCIIDOC) -b xhtml11 -d manpage -f asciidoc.conf \
 309                $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
 310        mv $@+ $@
 311
 312$(OBSOLETE_HTML): %.html : %.txto asciidoc.conf
 313        $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
 314        $(ASCIIDOC) -b xhtml11 -f asciidoc.conf \
 315                $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
 316        mv $@+ $@
 317
 318manpage-base-url.xsl: manpage-base-url.xsl.in
 319        sed "s|@@MAN_BASE_URL@@|$(MAN_BASE_URL)|" $< > $@
 320
 321%.1 %.5 %.7 : %.xml manpage-base-url.xsl
 322        $(QUIET_XMLTO)$(RM) $@ && \
 323        $(XMLTO) -m $(MANPAGE_XSL) $(XMLTO_EXTRA) man $<
 324
 325%.xml : %.txt asciidoc.conf
 326        $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
 327        $(ASCIIDOC) -b docbook -d manpage -f asciidoc.conf \
 328                $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) -o $@+ $< && \
 329        mv $@+ $@
 330
 331user-manual.xml: user-manual.txt user-manual.conf
 332        $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
 333        $(ASCIIDOC) $(ASCIIDOC_EXTRA) -b docbook -d article -o $@+ $< && \
 334        mv $@+ $@
 335
 336technical/api-index.txt: technical/api-index-skel.txt \
 337        technical/api-index.sh $(patsubst %,%.txt,$(API_DOCS))
 338        $(QUIET_GEN)cd technical && '$(SHELL_PATH_SQ)' ./api-index.sh
 339
 340technical/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
 341$(patsubst %,%.html,$(API_DOCS) technical/api-index $(TECH_DOCS)): %.html : %.txt asciidoc.conf
 342        $(QUIET_ASCIIDOC)$(ASCIIDOC) -b xhtml11 -f asciidoc.conf \
 343                $(ASCIIDOC_EXTRA) -agit_version=$(GIT_VERSION) $*.txt
 344
 345XSLT = docbook.xsl
 346XSLTOPTS = --xinclude --stringparam html.stylesheet docbook-xsl.css
 347
 348user-manual.html: user-manual.xml $(XSLT)
 349        $(QUIET_XSLTPROC)$(RM) $@+ $@ && \
 350        xsltproc $(XSLTOPTS) -o $@+ $(XSLT) $< && \
 351        mv $@+ $@
 352
 353git.info: user-manual.texi
 354        $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi
 355
 356user-manual.texi: user-manual.xml
 357        $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
 358        $(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@++ && \
 359        $(PERL_PATH) fix-texi.perl <$@++ >$@+ && \
 360        rm $@++ && \
 361        mv $@+ $@
 362
 363user-manual.pdf: user-manual.xml
 364        $(QUIET_DBLATEX)$(RM) $@+ $@ && \
 365        $(DBLATEX) -o $@+ -p $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.xsl -s $(ASCIIDOC_DBLATEX_DIR)/asciidoc-dblatex.sty $< && \
 366        mv $@+ $@
 367
 368gitman.texi: $(MAN_XML) cat-texi.perl
 369        $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
 370        ($(foreach xml,$(MAN_XML),$(DOCBOOK2X_TEXI) --encoding=UTF-8 \
 371                --to-stdout $(xml) &&) true) > $@++ && \
 372        $(PERL_PATH) cat-texi.perl $@ <$@++ >$@+ && \
 373        rm $@++ && \
 374        mv $@+ $@
 375
 376gitman.info: gitman.texi
 377        $(QUIET_MAKEINFO)$(MAKEINFO) --no-split --no-validate $*.texi
 378
 379$(patsubst %.txt,%.texi,$(MAN_TXT)): %.texi : %.xml
 380        $(QUIET_DB2TEXI)$(RM) $@+ $@ && \
 381        $(DOCBOOK2X_TEXI) --to-stdout $*.xml >$@+ && \
 382        mv $@+ $@
 383
 384howto-index.txt: howto-index.sh $(wildcard howto/*.txt)
 385        $(QUIET_GEN)$(RM) $@+ $@ && \
 386        '$(SHELL_PATH_SQ)' ./howto-index.sh $(sort $(wildcard howto/*.txt)) >$@+ && \
 387        mv $@+ $@
 388
 389$(patsubst %,%.html,$(ARTICLES)) : %.html : %.txt
 390        $(QUIET_ASCIIDOC)$(ASCIIDOC) $(ASCIIDOC_EXTRA) -b xhtml11 $*.txt
 391
 392WEBDOC_DEST = /pub/software/scm/git/docs
 393
 394howto/%.html: ASCIIDOC_EXTRA += -a git-relative-html-prefix=../
 395$(patsubst %.txt,%.html,$(wildcard howto/*.txt)): %.html : %.txt
 396        $(QUIET_ASCIIDOC)$(RM) $@+ $@ && \
 397        sed -e '1,/^$$/d' $< | $(ASCIIDOC) $(ASCIIDOC_EXTRA) -b xhtml11 - >$@+ && \
 398        mv $@+ $@
 399
 400install-webdoc : html
 401        '$(SHELL_PATH_SQ)' ./install-webdoc.sh $(WEBDOC_DEST)
 402
 403# You must have a clone of 'git-htmldocs' and 'git-manpages' repositories
 404# next to the 'git' repository itself for the following to work.
 405
 406quick-install: quick-install-man
 407
 408require-manrepo::
 409        @if test ! -d $(MAN_REPO); \
 410        then echo "git-manpages repository must exist at $(MAN_REPO)"; exit 1; fi
 411
 412quick-install-man: require-manrepo
 413        '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(MAN_REPO) $(DESTDIR)$(mandir)
 414
 415require-htmlrepo::
 416        @if test ! -d $(HTML_REPO); \
 417        then echo "git-htmldocs repository must exist at $(HTML_REPO)"; exit 1; fi
 418
 419quick-install-html: require-htmlrepo
 420        '$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REPO) $(DESTDIR)$(htmldir)
 421
 422print-man1:
 423        @for i in $(MAN1_TXT); do echo $$i; done
 424
 425.PHONY: FORCE