[PATCH] Makefile: fix misdetection of relative pathnames

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Junio C Hamano
Date: Thursday, February 5, 2009 - 1:18 am

A Large Angry SCM <gitzilla@gmail.com> writes:


Ok, here is the final one from me that I am considering to commit, but it
would be nice to hear success/failure feedback from people who had trouble
with Steffen's changes.  I'd also like to hear from people who have been
happy with Steffen's changes that this does not break things for them.

-- >8 --

The installation rules wanted to differentiate between a template_dir that
is given as an absolute path (e.g. /usr/share/git-core/templates) and a
relative one (e.g. share/git-core/templates) but it was done by checking
if $(abspath $(template_dir)) and $(template_dir) yield the same string.

This was wrong in number of ways.

 * The user can give template_dir with a trailing slash from the command
   line to invoke make, or in the included config.mak.  A directory path
   ought to mean the same thing with or without such a trailing slash but
   use of $(abspath) means with an absolute path with a trailing slash
   fails the test.

 * The compilation could be done inside /usr directory with a relative
   pathname share/git-core/templates and it will be mistaken as an
   absolute path.

 * Versions of GNU make older than 3.81 do not have $(abspath) to begin
   with.

This changes the detection logic to see if the given path begins with a
slash.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 Makefile |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/Makefile b/Makefile
index a82f173..605b147 100644
--- a/Makefile
+++ b/Makefile
@@ -1434,14 +1434,14 @@ remove-dashes:
 
 ### Installation rules
 
-ifeq ($(abspath $(template_dir)),$(template_dir))
+ifneq ($(filter /%,$(firstword $(template_dir))),)
 template_instdir = $(template_dir)
 else
 template_instdir = $(prefix)/$(template_dir)
 endif
 export template_instdir
 
-ifeq ($(abspath $(gitexecdir)),$(gitexecdir))
+ifneq ($(filter /%,$(firstword $(gitexecdir))),)
 gitexec_instdir = $(gitexecdir)
 else
 gitexec_instdir = $(prefix)/$(gitexecdir)
-- 
1.6.1.2.382.gda69a

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
026fa0d5ad Breaks installs with absolue $(gitexecdir) and ..., A Large Angry SCM, (Sun Feb 1, 11:24 am)
Re: 026fa0d5ad Breaks installs with absolue $(gitexecdir) ..., Steffen Prohaska, (Thu Feb 5, 12:13 am)
[PATCH] Makefile: fix misdetection of relative pathnames, Junio C Hamano, (Thu Feb 5, 1:18 am)
Re: [PATCH] Makefile: fix misdetection of relative pathnames, A Large Angry SCM, (Thu Feb 5, 3:16 pm)