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