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