Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I know there is a sort of standard series of commands to compile and install packages that come only as source. What is it?

share|improve this question
add comment

4 Answers

up vote 11 down vote accepted

Usually it is something like that.

./configure

This (when executed in the directory your source code is), creates a Makefile with the rules that will be used to build the program. This is where you can change the behavior of the compilation (that is, compile the program with options that are not default).

make

This builds the program with the rules specified in the Makefile.

make install

This is usually executed as root (or using sudo make install to avoid logging in as root), and installs the compiled program in your system.

[EDIT]

As Mihai Limbasan noted, you can usually pass the --prefix option to ./configure to determine where the program will be installed. If you have the necessary permissions in the target directory you won't even need to run make install using sudo (or as root).

For example, if you do

--prefix=/home/username/whatever/directory/here

you should be able to install this program without root privileges. I should point out that this will restrict the program's usage to those with execute privileges on the directory you specified. So if you need a system wide install, you should probably use the default solution (running make install with root privileges).

Mihai also reminded that you can remove the installed program by running

make uninstall

(again, as root or using sudo if you used the default options in configure), but that requires that you keep the build directory in place after you install the program. That is, it's not best practice to remove the source directory of a program you've compiled, so that you can remove it later.

share|improve this answer
    
@Mihai Limbasan. Thank you very much. I edited the answer so it would inclued all of your suggestions. –  Flávio Amieiro May 17 '09 at 19:10
    
Thanks! This should help brendanjerwin a lot. –  Mihai Limbăşan May 17 '09 at 19:26
add comment

What I get the source for an application the first thing I do is to read the pretty standard README/INSTALL file. They usually tell me exactly what I need to do. They tell me what dependencies I will to install before I compile to get all the functionality I want. They tell me what I need to do to secure the install.

less INSTALL
less README

Take 3-5 minutes and read those docs they can save you a lot of time.

share|improve this answer
    
-1 (Answer is essentially RTFM) I understand how to RTFM... I was simply trying to get this very commonly asked question into the site. (BTW, the project that prompted me to ask this one didn't provide either an INSTALL or README. –  brendanjerwin May 17 '09 at 19:57
    
Perhaps, but I disagree with the assumption that there really is a useful set of 'standard' instructions. I can point at many packages where the configure, make, make install does nothing. Reading the docs tends be a more reliable method. –  Zoredache May 17 '09 at 20:13
    
+1 it's a good idea to at least skim these, if they exist, before installing, since if a package doesn't use the standard configure/make/make install paradigm, these files describe the alternative. (Even with the standard build system, many packages include a generic INSTALL file that just has the instructions to configure/make/make install.) I can understand why this answer wouldn't be accepted but it's good info to have here. –  David Z May 18 '09 at 2:04
add comment
  1. tar -xzvf package.tar.gz
  2. cd package/
  3. less INSTALL
  4. ./configure --with-options
  5. make
  6. make check
  7. sudo make install
  8. make clean

These steps assume package compiles properly, all dependencies are met, and "check" target exists and passes.

share|improve this answer
add comment

for your ./configure you may want to use ./configure --help first as this will show the configuration options that can be passed to configure. This will be particularly useful if you are getting problems with your compilation or do not want some support provided by the package.

make check is sometimes replaced with make test as well. I would recommend trying these on any software you are compiling prior to installation.

share|improve this answer
add comment

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.