[Reprint]linux Under the Configure command detailed introduction

Source: Internet
Author: User
Tags bz2 gtar

Original link: http://www.chinaz.com/server/2009/0807/85792.shtml.

The installation of software in Linux is not an easy task; if it is installed by source code, it is more complicated; now the tutorial of installing various software is very common, but the change of the basic knowledge of the solid grasp, the installation of various software problems will be solved. Configure script Configuration tool is one of the basics, it is the basic application of autoconf tools.

Compared with some skills, configure appears to be based on some, of course, the use and learning is dull, of course, to become a master, the foundation of the familiar can not go beyond oh.

For this I have reproduced a detailed description of the Configure option configuration. For everyone's reference

The ' Configure ' script has a number of command-line options. These options may change for different packages, but many of the basic options will not change. Take '--help ' option to execute ' configure ' The script can see all the options available. Although many of the options are rarely used, it is beneficial to know that they exist when you configure a package for special needs. Here is a brief introduction to each of these options:

--cache-file=file

' Configure ' will test the existing features (or bug!) on your system. To speed up the subsequent configuration, the results of the test are stored in a cache file. When configure a complex source tree with a ' configure ' script in each subtree, the existence of a good cache file can be a great help.

--help

Output help information. Even experienced users occasionally need to use the '--help ' option because a complex project contains additional options. For example, the ' configure ' script in the GCC package contains options that allow you to control whether to generate and use the GNU assembler in GCC.

--no-create

One of the main functions in ' Configure ' is to make the output file. This option prevents ' configure ' from generating this file. You can think of this as an exercise (dry run), although the cache is still being rewritten.

--quiet

--silent

When ' Configure ' carries out his tests, it will output a brief message telling the user what is being done. This is because ' configure ' may be slower, without which the user will be thrown aside wondering what is happening. Using either of these options will throw you aside. . These two words are more interesting, the original is this: If there was no such output, the user would are left wondering what is happening. By using the option, you too can is left wondering!)

--version

Prints the version number of the autoconf used to generate the ' configure ' script.

--prefix=pewfix

'--prefix ' is the most commonly used option. The ' Makefile ' of the system will look at the parameters passed with this option, and when a package is installed, it can be completely relocated to a separate part of the structure. For example, when installing a package, such as Emacs, the following command will cause Emacs Lisp file to be installed to "/opt/gnu/share":

$./configure--prefix=/opt/gnu

--exec-prefix=eprefix

Similar to the '--prefix ' option, but he is the installation location of the file used to set up the structure dependency. The compiled ' emacs ' binary is one such question. If this option is not set, the default option value will be set to the same value as the '--prefix ' option.

--bindir=dir

Specifies the location where the binaries are installed. The binaries here are defined as programs that can be executed directly by the user.

--sbindir=dir

Specifies the location where the super binaries are installed. This is a program that is typically executed only by superuser users.

--libexecdir=dir

Specifies the location where executable support files are installed. In contrast to binary files, these files are never executed directly by the user, but can be executed by the binaries mentioned above.

--datadir=dir

Specifies the installation location for the common data file.

--sysconfdir=dir

Specifies the installation location for read-only data that is used on a single machine.

--sharedstatedir=dir

Specifies the installation location of writable data that can be shared across multiple machines.

--localstatedir=dir

Specifies the installation location of writable data that can be used only on a single machine.

--libdir=dir

Specifies the location where the library files are installed.

--includedir=dir

Specifies the installation location of the C header file. This option is also available for other languages such as header files for C + +.

--oldincludedir=dir

Specifies the installation location for the C header files installed in addition to the GCC external compiler.

--infodir=dir

Specifies the location where the info format document is installed. Info is the document format used by the GNU project.

--mandir=dir

Specifies the installation location for the manual page.

--srcdir=dir

This option has no effect on the installation. He will tell the location of the ' configure ' source. In general, this option is not specified because the ' configure ' script is generally in the same directory as the source file.

--program-prefix=prefix

Specifies the prefix that will be added to the name of the installed program. For example, using '--program-prefix=g ' to configure a program called ' tar ' will cause the installed program to be named ' Gtar '. When used with other installation options, this option is only available when he is ' Makefile.in ' files will not work until they are used.

--program-suffix=suffix

Specifies the suffix that will be added to the name of the installed program.

--program-transform-name=program

The program here is an SED script. When an app is installed, his name will go through ' sed-e programs ' to produce the installed name.

--build=build

Specifies the system platform on which the package is installed. If not specified, the default value will be the value of the '--host ' option.

--host=host

Specifies the system platform on which the software runs. If not specified, ' config.guess ' will be run to detect.

--target=garget

Specifies the system platform that the software targets (target to). This is primarily useful in programming language tools such as compilers and assembler contexts. If not specified, the default value of the '--host ' option is used.

--disable-feature

Some packages can choose this option to provide compile-time configuration for large options, such as using a Kerberos authentication system or an experimental compiler optimal configuration. If you provide these features by default, you can disable it by using '--disable-feature ', where ' FEATURE ' is the name of the attribute. For example:

$./configure--disable-gui

-enable-feature[=arg]

Conversely, some packages may provide some default prohibited features that can be used with '--enable-feature '. Here ' FEATURE ' is the name of the feature. An attribute may accept an optional parameter. For example:

$./configure--enable-buffers=128

The '--enable-feature=no ' is synonymous with the above mentioned '--disable-feature '.

--with-package[=arg]

In the free software community, there is an excellent tradition of using existing packages and libraries. When you configure a source tree with ' Configure ', you can provide information about other packages that have already been installed. For example, the BLT Device Toolkit, which relies on Tcl and TK. To configure BLT, you may need to give ' configure ' To provide some information about where we have installed Tcl and TK:

$./configure--with-tcl=/usr/local--with-tk=/usr/local

'--with-package=no ' is synonymous with the '--without-package ' that will be mentioned below.

--without-package

Sometimes you may not want your package to interact with packages that are already in the system. For example, you might not want your new compiler to use the GNU ld. You can do this by using this option:

$./configure--without-gnu-ld

--x-includes=dir

This option is a special case of the '--with-package ' option. When Autoconf was first developed, it was popular to use ' configure ' as a workaround for Imake to make software running on X. ' The--x-includes ' option provides a way to indicate to the ' configure ' script the directory containing the X11 header file.

--x-libraries=dir

Similarly, the '--x-libraries ' option provides a way to indicate to the ' configure ' script the directory containing the X11 library.

It is not necessary to run ' configure ' in the source tree. A good ' Makefile ' produced by ' Configure ' can build a software package that belongs to another tree. The benefit of building a derived file in a tree that is independent of the source is obvious: the derived file , such as the target file, will be messy scattered in the source tree. This also makes it difficult to build the same target file on a different system or with different configuration options. Three trees are recommended: a source tree, a build tree, an installation tree (install Tree). Here is a very close example of using this method to build the GNU malloc package:

$ Gtar ZXF mmalloc-1.0.tar.gz

$ mkdir Build && CD Build

$ .. /mmalloc-1.0/configure

Creating cache./config.cache

Checking for gcc ... gcc

Checking whether the C compiler (GCC) works ... yes

Checking whether the C compiler (GCC) is a cross-compiler ... no

Checking whether we are using the GNU C ... yes

Checking whether GCC accepts-g ... yes

Checking for a BSD compatible install .../usr/bin/install-c

Checking host system Type ... I586-pc-linux-gnu

Checking build system Type ... I586-pc-linux-gnu

Checking for ar ... Ar

Checking for ranlib ... ranlib

Checking how to run the C preprocessor ... gcc-e

Checking for unistd.h ... yes

Checking for getpagesize ... yes

Checking for working mmap ... yes

Checking for limits.h ... yes

Checking for stddef.h ... yes

Updating cache. /config.cache

Creating./config.status

So this tree is configured, below you can continue to build and install this package to the default location '/usr/local ':

$ make all && make install

How to completely uninstall a package after it is installed by compiling the source code??

If the original source is still there, a lot of source makefile have written uninstall rules, directly in souce make uninstall is feasible, but met the unscrupulous author did not write, That one sentence to see makefile in the install part of what he did, and then delete each.

If the source is gone ... Then let's be depressed.

So far, I have been able to make uninstall ....

(because you always accidentally install the wrong place, the result is make Uninstall&&make clean, and then re-configure ...)

Basic installation and uninstallation of software under Linux

Installing and uninstalling Linux software has always been a challenge for many new users. In Windows, we can use the software's own loading or unloading program or add/Remove Programs in the Control Panel. Similarly, there is a powerful software-on-load tool called RPM under Linux. It can be used to establish, install, query, update, uninstall software. The tool is used under the command line. You can get help for this command by entering RPM after the shell prompt.

Installation of software

There are two main types of software installation in Linux. The first installation file is named Xxx.tar.gz, and the other installation file is named xxx.i386.rpm. Most of the software issued in the first way is sent in the form of source code, and the second method is sent directly in binary form.

For the first type, the installation method is as follows:

1. First, copy the installation files to your directory. For example, if you are logged on as root, copy the software to/root.

#cp Xxx.tar.gz/root

2. Because the file is compressed and packaged, it should be uncompressed. The command is:

#tar Xvzf filename.tar.gz If it is in filename.tar.bz2 format, it should be tar jxvf filename.tar.bz2 to decompress

3. After the command is executed, the installation files are extracted by path and are decompressed in the current directory. You can see the extracted files with the LS command. Typically, files that are generated after decompression have "Install" files. This file is a plain text file, detailing how the package is installed.

4. An executable script named configure that was generated after the decompression was performed. It is used to check whether the system has a library that is required for compilation, and whether the version of the library meets the required system information for installation such as compilation. Prepare for the subsequent compilation work. The command is: #./configure

If you want to install the software to the specified directory, you should use #./configure--prefix=/your own designated directory, for example, I want to install a mlterm into the/opt/mlterm directory, should be entered as follows

#./configure--prefix=/opt/mlterm

5. After the check passes, a makefile file is generated for compilation. At this point, you can start compiling. The process of compiling depends on the size of the software and the performance of the computer, and the time spent is different. The command is: #make.

6. After successful compilation, type the following command to start the installation:

#make Install

7. After installation, the files generated during the compilation process should be cleared for temporary files and configuration. Type the following command:

#make Clean

#make Distclean

This concludes the installation of the software.

For the second, the installation method is much simpler.

As in the first way, copy the installation files to your directory. Then use RPM to install the file. The command is as follows:

#rpm-I. filename.i386.rpm

RPM will automatically unpack the installation files and install the software into the default directory. and register the installation information of the software in the RPM database. The function of the parameter i is to get the RPM into the installation mode.

Uninstalling the Software

1. The uninstallation of the software is mainly done using RPM. To uninstall the software, first know the name of the package registered in the system. Type the command:

#rpm-Q-A

You can query to all packages installed on the current system.

2. Determine the name of the software to be uninstalled, you can begin to actually uninstall the software. Type the command:

#rpm-E [package name]

You can uninstall the software. The function of the parameter e is to allow the RPM to enter the Unload mode. Uninstall the package named Packages name. Because of the dependencies between the various packages in the system. If there is a dependency that cannot be uninstalled, RPM will give you a hint and stop uninstalling. You can use the following command to ignore dependencies and start unloading directly:

#rpm-E [package name]-nodeps

Ignoring dependencies may cause other software in the system to become unusable

If you want to know where the RPM package is installed?

should use #rpm-QL [package name]

3. How to uninstall software installed with the source code package?

It is best to look at the Readme and install, the general situation has said, but most of the software does not provide the source package unloading method; We can find the installation point of the software to remove. It depends on where you have installed it.

Like what:

If you are installing the software, specify a directory. This problem is not difficult;

For example, using the source package to install Gaim

#./configure--prefix=/opt/gaim

#make

#make Install

If you install Mlterm

#./configure--prefix=/opt/mlterm

#make

#make Install

The source package installs the software, all specifies installs in the/OPT directory, so does not know??

If deleted, delete the corresponding software catalog;

Some software to perform make uninstall in the decompression installation directory, so that it is uninstalled

[Reprint]linux Under the Configure command detailed introduction

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.