Stow – no configure script

configuremakepackage-managementstow

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)

Best Answer

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.

Related Question