Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

Is there a way to build emacs on Linux so it doesn't embed the path where it was built into the binary, and it can be relocated harmlessly to a different path?

That is, if you build with --prefix=/a/b/c then move everything to /d/e/f it won't run, because it depends on the fixed path /a/b/c. I see the string /a/b/c inside the binary itself.

Windows emacs can be installed to any directory and it runs from there just fine, so it makes me think you can tell Linux emacs to run the same way, from "wherever you are sitting now".

We have no options like a fixed name symlink up the directory tree pointing to the variable path below it.

share|improve this question
1  
Just FYI, "relocatable" usually means something different than how you use it. A compiled, but not linked, executable (.o file) is usually called "a relocatable" because the address at which it will reside during execution hasn't been figured out yet. –  Bruce Ediger Aug 31 '12 at 22:02

1 Answer 1

up vote 3 down vote accepted

Emacs can be relocated mostly harmlessly, even if you don't take any precautions when compiling. If the hardcoded paths don't work, Emacs looks for directories near the executable.

Emacs tries to determine where the executable that invoked it is located. It stores this information in the variable invocation-directory. Let's say that this is /path/to/bin/emacs; Emacs looks for the data files it needs in the hard-coded directories, and falls back to directories in /path/to.

You need to structure your directories in the same way as the Emacs source, more or less, with toplevel directories bin, etc, leim, lib-src, lisp, site-lisp. In particular, at least with Emacs 23.2, the directory lib-src must exist (even if it's empty).

There are a few directories that Emacs doesn't find this way. Set the environment EMACSDATA=/path/to/etc. You may need to set INFOPATH as well.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.