summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKaz Kylheku <kaz@kylheku.com>2018-05-04 06:31:46 -0700
committerKaz Kylheku <kaz@kylheku.com>2018-05-04 06:31:46 -0700
commitc5afb01548c5b6bf4ec83373b5e2e09f14690b01 (patch)
tree572a1ed182f280a48097b58ddc27d3926b5cb757
parent8ac435caf03bd91f4f73e62e57bcc9a2f31eaf4c (diff)
downloadtxr-c5afb01548c5b6bf4ec83373b5e2e09f14690b01.tar.gz
txr-c5afb01548c5b6bf4ec83373b5e2e09f14690b01.tar.bz2
txr-c5afb01548c5b6bf4ec83373b5e2e09f14690b01.zip
More reasonable fallback for self path.
* Makefile (opt/txr.o, dbg/txr.o): Set up TXR_REL_PATH preprocessor symbol on command line which specifies the hard installation path derived from the configure prefix. * txr.c (get_self_path): The fallback implementation simply returns TXR_REL_PATH. This will work if in fact the executable is installed at that path. What it means is that the build of TXR which uses this fallback get_self_path will not support relocation: the installation cannot be moved to another directory, yet still find its supporting files. This is better than what we are replacing: not working even in the original installation directory, if not invoked by an absolute path.
-rw-r--r--Makefile6
-rw-r--r--txr.c10
2 files changed, 5 insertions, 11 deletions
diff --git a/Makefile b/Makefile
index c9d0f99d..64c2f02a 100644
--- a/Makefile
+++ b/Makefile
@@ -325,9 +325,11 @@ dbg/ffi.o: TXR_CFLAGS += $(LIBFFI_CFLAGS)
# calculations.
opt/txr.o: TXR_CFLAGS += -DPROG_NAME=\"$(PROG)\" \
- -DTXR_REL_PATH=\"$(bindir_rel)/$(PROG)$(EXE)\"
+ -DTXR_REL_PATH=\"$(bindir_rel)/$(PROG)$(EXE)\" \
+ -DTXR_INST_PATH=\"$(bindir)/$(PROG)$(EXE)\"
dbg/txr.o: TXR_CFLAGS += -DPROG_NAME=\"$(PROG)-dbg\" \
- -DTXR_REL_PATH=\"$(bindir_rel)/$(PROG)-dbg$(EXE)\"
+ -DTXR_REL_PATH=\"$(bindir_rel)/$(PROG)-dbg$(EXE)\" \
+ -DTXR_INST_PATH=\"$(bindir)/$(PROG)$(EXE)\"
opt/txr-win.o: TXR_CFLAGS += -DPROG_NAME=\"$(PROG)-win\" \
-DTXR_REL_PATH=\"$(bindir_rel)/$(PROG)-win$(EXE)\"
dbg/txr-win.o: TXR_CFLAGS += -DPROG_NAME=\"$(PROG)-win-dbg\" \
diff --git a/txr.c b/txr.c
index 197f6515..a77c53c9 100644
--- a/txr.c
+++ b/txr.c
@@ -254,15 +254,7 @@ static val get_self_path(void)
#else
static val get_self_path(void)
{
- char self[PATH_MAX];
-
- if (!progname_u8)
- return nil;
-
- if (realpath(progname_u8, self))
- return string_utf8(self);
-
- return nil;
+ return lit(TXR_INST_PATH);
}
#endif