Subject: Re: [PATCH 1/1] Honor $(prefix) set in config.mak* when defining ETC_GIT* and sysconfdir

From: Johannes Sixt <[email-masked]>
Date: Mon, 09 May 2011 10:24:55 +0200

Am 5/5/2011 17:46, schrieb Junio C Hamano:
> Kacper Kornet <[email-masked]> writes:
> 
>> Should the patch be based on main or on the previous patch that was
>> merged to next?
> 
> After having this much discussion, it is preferrable to have a patch
> relative to what you have in 'next' (2910bf5) as a fix-up, explaining "The
> initial version does not cover these cases / has these problems" to
> summarize the discussion so far, followed by explanation of the
> incremental change "Fix this and that by doing ...".
> 
> We could revert what is in 'next' and start from scratch, but then it is
> likely that the thought process will be lost when you write the log
> message.

I'd implement it like this, discarding Kacper's patch, but I'm not sure
whether the commit message summarizes the discussion sufficiently. Let me
know whether you want a version based on top of Kacper's patch, or how
else to proceed.

Of your two patches regarding configure --sysconfdir, only the second
(e8de44bc05) is needed on top of this patch.

--- 8< ---
From: Johannes Sixt <[email-masked]>
Subject: [PATCH] Honor $(prefix) set in config.mak* when defining ETC_GIT*

Notice that the prefix specified for the build influenced the definitions
of ETC_GITCONFIG and ETC_GITATTRIBUTES only when it was exactly '/usr'.
Kacper Kornet noticed that this was furthermore only the case when the
build was triggered using 'make prefix=/usr', i.e., the prefix was given
on the command line; it did not work when the prefix was specified in
config.mak because this file is included much later in the Makefile.

To fix this, move the conditional after the inclusion of config.mak.

Additionally, it is desirable to specify the etc directory for a build
(for example, a build with prefix /usr/local may still want to have the
system configuration in /etc/gitconfig). For this purpose, promote the
variable 'sysconfdir' from a helper variable to a configuration
variable. The prefix check that was moved must now be wrapped so that it
does not override sysconfdir setting given in config.mak.

Signed-off-by: Johannes Sixt <[email-masked]>
---
 Makefile |   18 +++++++++---------
 1 files changed, 9 insertions(+), 9 deletions(-)

diff --git a/Makefile b/Makefile
index ca4b38e..10d6bd5 100644
--- a/Makefile
+++ b/Makefile
@@ -274,8 +274,7 @@ STRIP ?= strip
 #   mandir
 #   infodir
 #   htmldir
-#   ETC_GITCONFIG (but not sysconfdir)
-#   ETC_GITATTRIBUTES
+#   sysconfdir
 # can be specified as a relative path some/where/else;
 # this is interpreted as relative to $(prefix) and "git" at
 # runtime figures out where they are based on the path to the executable.
@@ -291,15 +290,8 @@ sharedir = $(prefix)/share
 gitwebdir = $(sharedir)/gitweb
 template_dir = share/git-core/templates
 htmldir = share/doc/git-doc
-ifeq ($(prefix),/usr)
-sysconfdir = /etc
 ETC_GITCONFIG = $(sysconfdir)/gitconfig
 ETC_GITATTRIBUTES = $(sysconfdir)/gitattributes
-else
-sysconfdir = $(prefix)/etc
-ETC_GITCONFIG = etc/gitconfig
-ETC_GITATTRIBUTES = etc/gitattributes
-endif
 lib = lib
 # DESTDIR=
 pathsep = :
@@ -1192,6 +1184,14 @@ endif
 -include config.mak.autogen
 -include config.mak
 
+ifndef sysconfdir
+ifeq ($(prefix),/usr)
+sysconfdir = /etc
+else
+sysconfdir = etc
+endif
+endif
+
 ifdef CHECK_HEADER_DEPENDENCIES
 COMPUTE_HEADER_DEPENDENCIES =
 USE_COMPUTED_HEADER_DEPENDENCIES =
-- 
1.7.4.1.317.g0b25