So I just had a simple question that's probably going to make me look dumb, but I'm learning
When I do a
./configure --prefix/usr/bin/What is the prefix doing ? Is this just installing the package into that location
And can a reply give more of an elaborate answer for a complicated install and explain in detail the prefixes and options that go with it.
If I was to run an apt-get install how would I install it to a certain location with prefix
I've also seen
PREFIX=/tmp/installdir make PREFIX=/tmp/installdir make installIf prefix is called in ./configure why is it always being made in these two examples ?
Thank you in advance!
42 Answers
When you install software with make install or sudo make install, different files are placed in different directories. Executables that provide commands the user is intended to run usually go in a bin directory, libraries usually go in a lib directory, manual pages usually go in a man directory, and so forth.
When you run ./configure, the --prefix option lets you specify where those directories are. It is called --prefix because it lets you give the prefix that appears in the paths to each of the directories where files from the program or library that you are building are to be installed. Most configure scripts support --prefix, and omitting it and just running ./configure is typically equivalent to ./configure --prefix=/usr/local.
To answer this more fully, I've reproduced two sections from my answer to How to install tar file “globally”? (on Unix & Linux), which address this question specifically:
Configuring Your Build
When you have source code that is compiled by running
./configureandmake, you will usually usemake install(orsudo make install) to install it. This copies files from the build directory into the install location. When the thing you are installing provides executable commands, those executables are typically copied into a directory that is in$PATHor that you should consider adding to$PATH.Although building and installing software is often as simple as running
./configure,make, sometimesmake checkormake test, and thenmake installorsudo make install, you will sometimes want to pass options to theconfigurescript to configure the build. In particular, as pfnuesel says, this is how you configure where the software is going to be installed. Even though themake installstep actually installs the software, the locations where everything will be installed are typically established in the./configurestep.The most common option for this is
--prefix. The default prefix, when you don't tellconfigurewhat to use, is usually/usr/local. (Occasionally, a program or library's source code defaults to some other prefix. Fortunately this is rare.)So
./configureis usually equivalent to./configure --prefix=/usr/local. To install software in your home directory, you could use./configure --prefix=/home/galahad(if/home/galahadis your home directory) or--prefix="$HOME". Then of course you must still build and install the software withmake. I should say that not all software that is distributed in source code form is built this way. You should always look for documentation inside the extracted source code archive.What
--prefixMeansWhen you run
./configure --prefix=directory, you are indicating that the software should be installed under thedirectorydirectory. But this rarely, if ever, places loose files indirectory. Instead, it places files that serve different purposes in the different subdirectories ofdirectory. If those subdirectories don't exist, it creates them.Executables usually go in
directory/bin, though they may go indirectory/sbinif they're commonly used for system administration or they may go (more rarely, these days) indirectory/gamesif they are games. Libraries go indirectory/libor another similarly named directory likedirectory/lib32. Header files go indirectory/include. Manual pages go indirectory/man. Data files used by the software go indirectory/share.That's what it means for
directoryto be a prefix. It's the parent directory that contains the locations in which different files will be installed. It thus appears as a prefix in the absolute paths of most files and directories created by runningmake installorsudo make install.There are some exceptions to this. Systemwide configuration files--which are sometimes created when installing the software that will use them, though not always--usually go in
/etc. This is not typically affected by specifying a different prefix. Even if you install a lot of software in/usr/local, it will still mostly use/etc, and your/usr/local/etcdirectory will probably be nonexistent, empty, or contain very few files.On many systems, you can find more information about typical filesystem layout by running
man hier. If you're using a GNU/Linux system you may be interested in the Filesystem Hierarchy Standard.
It tells the location of the things which are required to configure the current package or software.
Like in a simple case, it can tell the location of ssl libraries:
--with-libssh2=/usr/local #used in configuring nagiosand it also tells which packages not to configure, to make suitable compilations of the program according to your system:
--disable-shared # used in configuring nagios
--disable-link-balancer # used in configuring FireholThese are just extra options to make a compilation suitable for your system. It is what I think. Do correct me if it is something else.
The --prefix=PREFIX option installs architecture independent files in PREFIX. When you run a make installcommand, libraries will be placed in the PREFIX/lib directory, executables in the PREFIX/bin directory and so on.
If this argument is not passed to the configure command then the default value is /usr/local.