JuliaLang/julia — pull request #5527 by staticfloat (2014-01-25 10:08:09+00:00)
Title: Revamp Makefiles to better conform to common packaging guidelines

This is a huge patchset, I know. I've done as much testing as I can (OSX, Ubuntu, Fedora, Windows cross-compile) but I'd like to get some other people to test it if possible before merging. The motivating factors for this are mostly to adhere to standard practice as much as possible, and to clean up the way installation directories are handled in general. Comments are welcome, here is a summary of what these changes represent:

* Change/create Makefile variables to more standard names
* `$(PREFIX)` -> `$(prefix)`, `$(PREFIX)/bin` -> `$(bindir)`, etc.
* Also create new `$(build_prefix)` and `$(build_bindir)` makevars to abstract away "build time" tree layout from "install time" tree layout
* Because we can now flexibly set the build layout, a fair amount of windows-specific checks and moves can be removed
* we just set `$(build_libdir) = $(build_bindir)`, and this transparently makes its way through configure scripts and Makefiles

* Relocates binaries' RPATH entries on install
* This is necessary when build-time tree layout != install-time tree layout
* Better than changing build-time tree layout, as that requires a reconfiguration of all deps
* Only done if the relative path from `julia` to `libjulia` changes between compilation and installation

* Adds tool to replace strings in binaries (`contrib/stringpatch.c`)
* Used to overwrite `image_file` hardcoded in julia binary in `ui/repl.c` [here]().
* Source modified to include ample extra space so if the new path is longer, we don't overwrite anything important
* This modification is only done if the relative path from `julia` to `sys.ji` changes between compilation and installation
* You can prevent this from happening if you know apriori what install-time tree layout you want, by setting `build_libdir` and friends at build time.

* Passes `make testall` in both the build directory (e.g. after a `make`) and in a foreign installed directory (e.g. after a `make install prefix=/usr/local libdir=/usr/local/lib64 DESTDIR=/tmp/jdst`) on OSX, Ubuntu and Windows cross-compile.

* Changes `$(libdir)` on windows to be equal to `$(bindir)` instead of equal to just `bin`. This gets rid of some special-cases we've needed in the past.