git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 3/3] Documentation/Makefile: fix inherited {html,info,man}dir

From
John Keeping <john@keeping.me.uk>
Date
Feb 12, 2013, 20:17 UTC
Message-ID
<60caa0f956179b0396614afd83e133198e9b4430.1360700102.git.john@keeping.me.uk>
In-Reply-To
<cover.1360700102.git.john@keeping.me.uk>
Commit e14421b (Allow INSTALL, bindir, mandir to be set in main Makefile
- 2006-06-29) changed Documentation/Makefile to inherit the value of
mandir from the top-level Makefile when invoked as "make install-doc" at
the top-level.  This was inherited by infodir and htmldir when they were
added.

This was broken by commit 026fa0d (Move computation of absolute paths from Makefile to runtime (in preparation for RUNTIME_PREFIX) - 2009-01-18) which changed these variables to have relative paths in the top-level Makefile, causing the documentation to be installed into the path without $(prefix) prepended.

Fix this by changing the defaults to be paths relative to $(prefix) and introducing new variables {html,info,man}_instdir which contain the full installation paths.

Signed-off-by: John Keeping <john@keeping.me.uk>
---
I'm not sure if this is the best approach - the alternative would be to
change the top-level Makefile to use {html,info,man}dir_relative and
derive the {html,info,man}dir variables from that.

The top-level Makefile is inconsistent in the approach it takes - bindir is derived from bindir_relative but gitexecdir and template_dir have gitexec_instdir and template_instdir derived from them.

 Documentation/Makefile | 56 +++++++++++++++++++++++++++++++++++---------------
 1 file changed, 40 insertions(+), 16 deletions(-)
diff --git a/Documentation/Makefile b/Documentation/Makefile
index 0cfdc36..34cd9f2 100644
--- a/Documentation/Makefile
+++ b/Documentation/Makefile
@@ -78,15 +78,21 @@ DOC_MAN1 = $(patsubst %.txt,%.1,$(MAN1_TXT))
 DOC_MAN5 = $(patsubst %.txt,%.5,$(MAN5_TXT))
 DOC_MAN7 = $(patsubst %.txt,%.7,$(MAN7_TXT))
 
+# The following variables can be relative paths due to the way they can be
+# inherited from the top-level Makefile:
+#   htmldir
+#   infodir
+#   mandir
+# Note that pdfdir is an exception to this since it is not used by git-help.
 prefix ?= $(HOME)
 bindir ?= $(prefix)/bin
-htmldir ?= $(prefix)/share/doc/git-doc
-infodir ?= $(prefix)/share/info
 pdfdir ?= $(prefix)/share/doc/git-doc
-mandir ?= $(prefix)/share/man
-man1dir = $(mandir)/man1
-man5dir = $(mandir)/man5
-man7dir = $(mandir)/man7
+htmldir ?= share/doc/git-doc
+infodir ?= share/info
+mandir ?= share/man
+man1dir = $(man_instdir)/man1
+man5dir = $(man_instdir)/man5
+man7dir = $(man_instdir)/man7
 # DESTDIR =
 
 ASCIIDOC = asciidoc
@@ -110,6 +116,24 @@ endif
 -include ../config.mak.autogen
 -include ../config.mak
 
+ifneq ($(filter /%,$(firstword $(htmldir))),)
+html_instdir = $(htmldir)
+else
+html_instdir = $(prefix)/$(htmldir)
+endif
+
+ifneq ($(filter /%,$(firstword $(infodir))),)
+info_instdir = $(infodir)
+else
+info_instdir = $(prefix)/$(infodir)
+endif
+
+ifneq ($(filter /%,$(firstword $(mandir))),)
+man_instdir = $(mandir)
+else
+man_instdir = $(prefix)/$(mandir)
+endif
+
 #
 # For docbook-xsl ...
 #	-1.68.1,	no extra settings are needed?
@@ -144,7 +168,7 @@ endif
 # Distros may want to use MAN_BASE_URL=file:///path/to/git/docs/
 # or similar.
 ifndef MAN_BASE_URL
-MAN_BASE_URL = file://$(htmldir)/
+MAN_BASE_URL = file://$(html_instdir)/
 endif
 XMLTO_EXTRA += -m manpage-base-url.xsl
 
@@ -220,13 +244,13 @@ install-man: man
 	$(INSTALL) -m 644 $(DOC_MAN7) $(DESTDIR)$(man7dir)
 
 install-info: info
-	$(INSTALL) -d -m 755 $(DESTDIR)$(infodir)
-	$(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(infodir)
-	if test -r $(DESTDIR)$(infodir)/dir; then \
-	  $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) git.info ;\
-	  $(INSTALL_INFO) --info-dir=$(DESTDIR)$(infodir) gitman.info ;\
+	$(INSTALL) -d -m 755 $(DESTDIR)$(info_instdir)
+	$(INSTALL) -m 644 git.info gitman.info $(DESTDIR)$(info_instdir)
+	if test -r $(DESTDIR)$(info_instdir)/dir; then \
+	  $(INSTALL_INFO) --info-dir=$(DESTDIR)$(info_instdir) git.info ;\
+	  $(INSTALL_INFO) --info-dir=$(DESTDIR)$(info_instdir) gitman.info ;\
 	else \
-	  echo "No directory found in $(DESTDIR)$(infodir)" >&2 ; \
+	  echo "No directory found in $(DESTDIR)$(info_instdir)" >&2 ; \
 	fi
 
 install-pdf: pdf
@@ -234,7 +258,7 @@ install-pdf: pdf
 	$(INSTALL) -m 644 user-manual.pdf $(DESTDIR)$(pdfdir)
 
 install-html: html
-	'$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(htmldir)
+	'$(SHELL_PATH_SQ)' ./install-webdoc.sh $(DESTDIR)$(html_instdir)
 
 ../GIT-VERSION-FILE: FORCE
 	$(QUIET_SUBDIR0)../ $(QUIET_SUBDIR1) GIT-VERSION-FILE
@@ -402,14 +426,14 @@ require-manrepo::
 	then echo "git-manpages repository must exist at $(MAN_REPO)"; exit 1; fi
 
 quick-install-man: require-manrepo
-	'$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(MAN_REPO) $(DESTDIR)$(mandir)
+	'$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(MAN_REPO) $(DESTDIR)$(man_instdir)
 
 require-htmlrepo::
 	@if test ! -d $(HTML_REPO); \
 	then echo "git-htmldocs repository must exist at $(HTML_REPO)"; exit 1; fi
 
 quick-install-html: require-htmlrepo
-	'$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REPO) $(DESTDIR)$(htmldir)
+	'$(SHELL_PATH_SQ)' ./install-doc-quick.sh $(HTML_REPO) $(DESTDIR)$(html_instdir)
 
 print-man1:
 	@for i in $(MAN1_TXT); do echo $$i; done
-- 
1.8.1.2
Previous: John KeepingNext: Jonathan Nieder
Message 7 of 20 in “Fix installation paths with "make install-doc"”
  1. 0/3 Fix installation paths with "make install-doc"John Keeping, Feb 12, 2013
  2. 1/3 Documentation/Makefile: fix spaces around assignmentsJohn Keeping, Feb 12, 2013
  3. Jonathan NiederFeb 12, 2013
  4. 2/3 Documentation/Makefile: move infodir to be with other '*dir'sJohn Keeping, Feb 12, 2013
  5. Jonathan NiederFeb 12, 2013
  6. John KeepingFeb 12, 2013
  7. 3/3 Documentation/Makefile: fix inherited {html,info,man}dirJohn Keeping, Feb 12, 2013
  8. Jonathan NiederFeb 12, 2013
  9. John KeepingFeb 12, 2013
  10. Jonathan NiederFeb 12, 2013
  11. Junio C HamanoFeb 12, 2013
  12. Junio C HamanoFeb 12, 2013
  13. John KeepingFeb 12, 2013
  14. Junio C HamanoFeb 12, 2013
  15. Makefile: do not export mandir/htmldir/infodirJunio C Hamano, Feb 12, 2013
  16. Jonathan NiederFeb 12, 2013
  17. John KeepingFeb 12, 2013
  18. Makefile: make mandir, htmldir and infodir absoluteJohn Keeping, Feb 24, 2013
  19. Junio C HamanoFeb 25, 2013
  20. John KeepingFeb 12, 2013

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.