Detailed explanation of configuration parameter of configure option in Linux

Time:2021-7-20

It is not easy to install software in Linux environment; If the source code is compiled and installed, of course, things will be more complicated; Now the installation of various software tutorials are very common; However, all changes can not be separated from them. With a solid grasp of basic knowledge, the problem of installing various kinds of software can be easily solved. Configuration script configuration tool is one of the basic tools, which is the basic application of Autoconf tools.

Compared with some skills, configure is more basic. Of course, it’s boring to use and learn. If you want to be an expert, you can’t be more familiar with the basics.

For this reason, I reprinted a detailed introduction to configure option configuration. For your reference, the ‘configure’ script has a large number of command-line options. For different software packages, these options may change, but many basic options will not change. With the ‘- help’ option, you can see all the available options when you execute the ‘configure’ script. Although many options are rarely used, the, But when you configure a package for special needs, it’s good to know that they exist

–cache-file=FILE
Configure” will test the existing features (or bugs!) on your system In order to speed up the subsequent configuration, the test results will be stored in a cache file. When configuring a complex source tree with ‘configure’ script in each subtree, the existence of a good cache file will help a lot

–help
Even experienced users occasionally need to use the ‘– help’ option, because a complex project will contain additional options. For example, the ‘configure’ script in GCC package contains options that allow you to control whether to generate and use GNU assembler in GCC

–no-create
One of the main functions in ‘configure’ makes the output file. This option prevents’ configure ‘from generating this file. You can think of this as a dry run, even though the cache is still rewritten

–quiet
–silent
When ‘configure’ runs its tests, it will output brief information to tell the user what is being done. This is because ‘configure’ may be slow. Without this output, the user will be left wondering what is going on, If there was no such output, the user would be left wondering what is happening. By using this option, you too can be left wondering!)

–version
Print the version number of Autoconf used to generate the ‘configure’ script

– prefix = prefix (where the file is installed)
‘– prefix’ is the most commonly used option. The created ‘makefile’ will check the parameters passed with this option. When a package is installed, it can completely relocate the independent parts of its structure. For example, when a package, such as Emacs, is installed, the following command will make Emacs LISP file be installed to ‘/ opt / GNU / share’:
$ ./configure –prefix=/opt/gnu/share

–exec-prefix=EPREFIX
It is similar to the ‘- prefix’ option, but it is used to set the installation location of the structure dependent files. The compiled ‘Emacs’ binary is such a file. If this option is not set, the default option value will be set to the same as the’ – prefix ‘option value

–bindir=DIR
Specify the installation location of the binary file. The binary file here is defined as the program that can be executed directly by the user

—sbindir=DIR
Specify the installation location of superbinaries. These are programs that can only be executed by superusers

– libexecdir = dir (package directory, program call)
Specifies the location where the executable support files are installed. As opposed to binary files, these files are never executed directly by the user, but can be executed by the binary files mentioned above

–datadir=DIR
Specifies the installation location of the general data file

– sysconfdir = dir (/ etc configuration file directory)
Specifies the installation location of read-only data used on a single machine

–sharedstatedir=DIR
Specifies the installation location of writable data that can be shared on multiple machines

–localstatedir=DIR
Specifies the installation location of writable data that can only be used by a single machine

– libdir = dir (library file directory)
Specifies the installation location of the library file

–includedir=DIR
Specify the installation location of C header files. Other languages such as C + + can also use this option

–oldincludedir=DIR
Specifies the installation location of C header files installed for compilers other than GCC

–infodir=DIR
Specify the installation location of info format document. Info is the document format used by GNU Project

– Mandir = dir (installation directory of help documents)
Specify the installation location of the man page

–srcdir=DIR
This option has no effect on the installation. It will tell you the location of the ‘configure’ source code. Generally speaking, you don’t need to specify this option because the ‘configure’ script and the source code file are in the same directory

–program-prefix=PREFIX
Specifies the prefix to be added to the name of the program to be installed. For example, using ‘– program prefix = g’ to configure a program named ‘tar’ will cause the installed program to be named ‘gtar’. When used with other installation options, this option works only when it is used by the ‘makefile. In’ file

–program-suffix=SUFFIX
Specifies the suffix to be added to the name of the installed program

–program-transform-name=PROGRAM
The program here is a sed script. When a program is installed, its name will be generated by ‘sed – e program’

–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
Specify the system platform on which the software runs. If not specified, run ‘config. Guess’ to detect

–target=GARGET
Specifies the system platform to which the software is targeted. This mainly works in the context of programming language tools such as compilers and assemblers. If not specified, the value of the ‘– host’ option is used by default

–disable-FEATURE
Some packages can choose this option to provide compile time configuration for large options, such as using Kerberos authentication system or an experimental compiler optimal configuration. If these features are provided by default, you can use ‘– disable feature’ to disable it, where ‘feature’ is the name of the feature

Copy code

The code is as follows:

$ ./configure –disable-gui

-Enable feature [= Arg] (system parameter configuration, completed at compile time)
On the contrary, some packages may provide some features that are forbidden by default. You can use ‘– enable feature’ to activate it. Here ‘feature’ is the name of the feature. A feature may accept an optional parameter. For example:

Copy code

The code is as follows:

$ ./configure –enable-buffers=128

`– 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 software packages and libraries. When you configure a source tree with ‘configure’, you can provide information about other installed software packages. For example, BLT device kits that rely on TCL and TK. To configure blt, you may need to provide ‘configure’ with some information about where we install TCL and TK

Copy code

The code is as follows:

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

“– with package = no” is synonymous with “– without package” mentioned below

–without-PACKAGE
Sometimes you may not want your software package to be compatible with the existing software of the system
For example, you may not want your new compiler to use GNU LD

Copy code

The code is as follows:

$ ./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 an alternative to 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’s unnecessary and bad to run ‘configure’ in the source tree. A good ‘makefile’ generated by ‘configure’ can build a package whose source code belongs to another tree. The advantage of constructing derived files in a source independent tree is obvious: derived files, such as target files, can be used to build a package whose source code belongs to another tree, This also makes it very difficult to build the same object file in a different system or with different configuration options. It is recommended to use three trees: a source tree, a build tree, and an install tree. Here is a very close example of using this method to build the GNU malloc package:

Copy code

The code is as follows:

$ 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 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

In this way, the build tree is configured. You can continue to build and install the package to the default location ‘/ usr / local’:

Copy code

The code is as follows:

$ make all && make install

After a software package is installed by compiling source code, how to completely uninstall it??

If the original source is still there, many makefiles of the source have written the uninstall rule. It’s feasible to make uninstall directly in souce. However, when the unscrupulous author doesn’t write it, look at what he has done in the install part of makefile one by one, and then delete it one by one.
If the source is gone, let’s be depressed

So far, I can make universal
(because it is always installed in the wrong place by mistake, the result is to make a final & & make clean, and then reconfigure…)