3

In the program GNU Stow, the symlink farm manager/package manager/whatever you want to call it, you can run the following commands to install a package to /usr/local:

./configure --prefix=/usr/local
make
sudo make prefix=/usr/local/stow/foo-1.2 install # well not nessecarily sudo but this is personal preference 
cd /usr/local/stow
sudo stow foo-1.2 # you have to have sudo here

Basically you are tricking the package so that programs link against /usr/local, but it is actually installed in /usr/local/stow/foo-1.2.

But what if there is no configure script? How can I trick it then? Some notable programs without configure scripts:

  • bzip2 (this is the program I wrote the question for)
  • R (the programming language)
2

First off, when using stow with a GNU autotools configure script, use

$ ./configure --prefix=/usr/local/stow/package-version

That way you don't have to repeat yourself when you invoke make.

bzip2 comes with a ready-made Makefile. It also has a README file that explains exactly how to install it in a non-standard location:

HOW TO BUILD -- UNIX

Type 'make'.  This builds the library libbz2.a and then the programs
bzip2 and bzip2recover.  Six self-tests are run.  If the self-tests
complete ok, carry on to installation:

To install in /usr/local/bin, /usr/local/lib, /usr/local/man and
/usr/local/include, type

   make install

To install somewhere else, eg, /xxx/yyy/{bin,lib,man,include}, type

   make install PREFIX=/xxx/yyy

This means that you may use

$ make install PREFIX=/usr/local/stow/bzip2-1.0.6

if you wish.

R comes with a configure script, at least in the source distribution of version 3.4.1 which I downloaded for testing.

Programs that build using CMake may be installed in a configurable location using

$ cmake -DCMAKE_INSTALL_PREFIX:PATH=/usr/local/stow/package-version .
$ make && sudo make install

If GNU autotools haven't been used to create a configure script, and if it's not a CMake project, then do read the README and/or INSTALL file about how to install the program (you should obviously do this nonetheless). Most programs are able to install in non-default locations quite easily.

If worse comes to worse, just read the Makefile.

  • Hold on, back up. I'm a bit confused. Look at this: gnu.org/software/stow/manual/…. Won't this mean that I have to "trick" it, as I stated in my original question, in order to ensure linking problems are fixed? And also will it still work in the way I want it to: being to swap versions quickly and easily? – fosslinux Aug 19 '17 at 7:09
  • @ubashu Don't try to correct for a problem that you don't have. Until you actually run into issues with having an application link against libraries in its explicit stow path, don't make it unnecessarily complicated for yourself. – Kusalananda Aug 19 '17 at 7:30
  • Yeah I'm not great at following the "don't fix what ain't broke" principle. – fosslinux Aug 19 '17 at 7:33
  • Hi, I'm the Stow maintainer. This is a good answer, and corresponds to what the Stow manual suggests as linked in the comment above by @ubashu, but I fear that the manual is actually out of date. I suspect that this text was probably written before DESTDIR was introduced into automake, and from memory DESTDIR is the more correct approach. However it's a long time since I looked into this in detail. I should probably revisit and update the manual. – Adam Spiers Aug 19 '17 at 22:40
  • 1
    @AdamSpiers I appreciate your input. Thanks! I happen to be the port maintainer for stow on OpenBSD, BTW. – Kusalananda Aug 22 '17 at 15:29

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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