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