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