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