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 <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>

Johannes Sixt committed May 9, 2011 at 10:24 UTC 9fb1e6984201892b6dfb7e1a9195e2544a5af754
1 file changed +9 -9
Makefile
+9 -9
@@ -274,8 +274,7 @@ STRIP ?= strip
274 # mandir
275 # infodir
276 # htmldir
277 -# ETC_GITCONFIG (but not sysconfdir)
278 -# ETC_GITATTRIBUTES
277 +# sysconfdir
278 # can be specified as a relative path some/where/else;
279 # this is interpreted as relative to $(prefix) and "git" at
280 # runtime figures out where they are based on the path to the executable.
@@ -291,15 +290,8 @@ sharedir = $(prefix)/share
290 gitwebdir = $(sharedir)/gitweb
291 template_dir = share/git-core/templates
292 htmldir = share/doc/git-doc
294 -ifeq ($(prefix),/usr)
295 -sysconfdir = /etc
293 ETC_GITCONFIG = $(sysconfdir)/gitconfig
294 ETC_GITATTRIBUTES = $(sysconfdir)/gitattributes
298 -else
299 -sysconfdir = $(prefix)/etc
300 -ETC_GITCONFIG = etc/gitconfig
301 -ETC_GITATTRIBUTES = etc/gitattributes
302 -endif
295 lib = lib
296 # DESTDIR=
297 pathsep = :
@@ -1196,6 +1188,14 @@ endif
1188 -include config.mak.autogen
1189 -include config.mak
1190
1191 +ifndef sysconfdir
1192 +ifeq ($(prefix),/usr)
1193 +sysconfdir = /etc
1194 +else
1195 +sysconfdir = etc
1196 +endif
1197 +endif
1198 +
1199 ifdef CHECK_HEADER_DEPENDENCIES
1200 COMPUTE_HEADER_DEPENDENCIES =
1201 USE_COMPUTED_HEADER_DEPENDENCIES =