Linux – Compiling Downloaded Source Code with Make’s 101
I’ve been doing quite a bit of source code compiling using the “make” command and figured I provide a brief primer on how to compile.
DISCLAIMER – Not all source codes are the same, some may/may not follow this structure.
First step, download the source code you wish to compile. For this example, I will download cmake 3.0. The tool can be downloaded from: http://www.cmake.org/files/v3.0/cmake-3.0.0.tar.gz.
Untar the file, the following command will work when executed from the same directory the tar file is located.
tar -xvf cmake-3.0.0.tar.gz
Next, change directories into the newly tar-ed folder (the source code directory).
The following commands need to be executed within the source directory. Some source codes have and autogen.sh file. If this exists, run it to auto generate the correct configure.
However, if there is already a configure file (note this is not configure.<EXTENSION>), run that to check and setup your environment.
will show you the manner different setup variables you can assign values. For example, if you do not want the source code to be compiled in default directories, add the –prefix flag to specify another directory.
./configure –prefix=<DIRECTORY FOR INSTALL>
Some sources require you to run
first to run/setup default variables. However, I normal just run
in most instances, after configuring.
That’s pretty much it! It is compiled and ready to go. Happy coding!