The ./configure
command is a common way to configure and prepare software source code for compilation on Linux systems. This command is typically run before the make command, which actually compiles the software. Understanding the options available with the ./configure
command can give you more control over the compilation process and help you customize the build to your specific needs.
When you run the ./configure
script, it performs several tasks to prepare the source code for compilation. Some of the main tasks it performs include:
- Checking for Dependencies: The script checks if the required dependencies, such as libraries and tools, are installed on the system. If any dependencies are missing, the script will usually inform you and stop the configuration process.
- Setting up configuration options: The script allows you to specify various configuration options, such as the location of libraries, the type of installation, and the features to be included in the compiled software.
- Creating makefiles: Once the dependencies and configuration options have been set up, the script creates makefiles, which are used by the make command to compile the software. The makefiles contain information on how to compile the software, such as the location of the source files, the options to be passed to the compiler, and the dependencies.
- Running some basic tests: The script also runs some basic tests on the system to ensure that the system is compatible with the software being installed. This includes running tests on the system’s architecture, operating system, and other system-specific details.
Running ./configure
Script
In Linux, systems packages can be installed using the package manager or they can also be compiled from source code. Most of the source code contains ./configure
script that prepares source code and system before running actual compilation.
For example, I have Python source code on my system. Then run the ./configure command as below screenshot:
Once the ./configure
is completed successfully, You will see the Makefiles created in your system that will be used by `make`
to compile source code and install on your machine.
You can see the file generated with ./configure
script using ls command.
Common Options for ./configure
- The most basic usage of the
./configure
command is to simply run it without any options. This will check for dependencies and configure the build to use the default settings. - The
--prefix
option allows you to specify the directory where the software will be installed. By default, the software is usually installed in /usr/local/, but you can specify a different directory if desired. For example, to install the software in /usr/local/mysoftware/, you would run the following command:./configure --prefix=/usr/local/mysoftware/
- The
--enable-feature
and--disable-feature
options allow you to enable or disable specific features of the software. These options can be used to enable or disable optional dependencies or specific functionality. For example, to disable the support for the PNG image format in an image manipulation software, you would run the following command:./configure --disable-png
- The
--with-package
and--without-package
options allow you to specify external dependencies that the software depends on. These options can be used to specify the location of specific libraries, like--with-ssl=/usr/local/ssl
. - The
--enable-debug
option can be used to enable debugging information during compilation. This can be useful for troubleshooting and debugging issues with the software. - The
--help
option can be used to view a list of all available options for the./configure
command. - Additionally, you can also use the CFLAGS and LDFLAGS environment variables to pass flags to the compiler and linker. For example, to enable additional optimization flags during the compilation, you can run the following command:
CFLAGS="-O3" LDFLAGS="-O3" ./configure
Conclusion
In conclusion, the ./configure command is an important step in the compilation process of software on Linux systems. Understanding the options available with this command can give you more control over the compilation process and help you customize the build to your specific needs. It’s important to always check for the availability of the options on the software documentation before using them.
It’s also important to note that the options presented above are just some examples, and each software package may have different options. It’s always a good idea to check the software documentation for the most accurate and up-to-date information on the available options for the ./configure command.
2 Comments
it was a nice read. I have a question though, how about using multiple options?
Can is use something like this:
./configure –enable-optimizations –enable-shared
I need to do this for custom python installation altinstall
Yes, we can use multiple options