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