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