summaryrefslogtreecommitdiff
path: root/exec_cmd.c
diff options
context:
space:
mode:
authorSteffen Prohaska <prohaska@zib.de>2009-01-18 12:00:09 (GMT)
committerJunio C Hamano <gitster@pobox.com>2009-01-26 08:26:05 (GMT)
commit026fa0d5ad9538ca76838070861531c037d7b9ba (patch)
tree62b19e4750f7e3fc44f93385f758b6a7b3ec2d6c /exec_cmd.c
parenta83c88525ed6d8d940f8cf7f21e92b189f7844e3 (diff)
downloadgit-026fa0d5ad9538ca76838070861531c037d7b9ba.zip
git-026fa0d5ad9538ca76838070861531c037d7b9ba.tar.gz
git-026fa0d5ad9538ca76838070861531c037d7b9ba.tar.bz2
Move computation of absolute paths from Makefile to runtime (in preparation for RUNTIME_PREFIX)
This commit prepares the Makefile for relocatable binaries (called RUNTIME_PREFIX). Such binaries will be able to be moved together with the system configuration files to a different directory, requiring to compute the prefix at runtime. In a first step, we make all paths relative in the Makefile and teach system_path() to add the prefix instead. We used to compute absolute paths in the Makefile and passed them to C as defines. We now pass relative paths to C and call system_path() to add the prefix at runtime. Signed-off-by: Steffen Prohaska <prohaska@zib.de> Acked-by: Johannes Sixt <j6t@kdbg.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'exec_cmd.c')
-rw-r--r--exec_cmd.c13
1 files changed, 8 insertions, 5 deletions
diff --git a/exec_cmd.c b/exec_cmd.c
index cdd35f9..114d638 100644
--- a/exec_cmd.c
+++ b/exec_cmd.c
@@ -9,11 +9,14 @@ static const char *argv0_path;
const char *system_path(const char *path)
{
- if (!is_absolute_path(path) && argv0_path) {
- struct strbuf d = STRBUF_INIT;
- strbuf_addf(&d, "%s/%s", argv0_path, path);
- path = strbuf_detach(&d, NULL);
- }
+ static const char *prefix = PREFIX;
+ struct strbuf d = STRBUF_INIT;
+
+ if (is_absolute_path(path))
+ return path;
+
+ strbuf_addf(&d, "%s/%s", prefix, path);
+ path = strbuf_detach(&d, NULL);
return path;
}