function configure_source
This function is one of the longest and most complex of the src2pkg
functions. Configuring sources can be difficult and many package builds
will fail at this step. Because of that this function provides many
chances to cutomize configuration using the Build Option variables.
Main purpose
- Discover what kind of configuration system is used by the sources
and the location of the files.
- Configure the sources using the options supplied by the user
and/or defaults.
- Repair or pre-prepare broken or incomplete sources.
- Skip the step if not used.
Notes
src2pkg can automatically recognize and work with several different
configuration systems or with sources that use no configuration at all.
- autoconf using Makefiles or GNUmakefiles
- imake
- scons or SConstruct
- jam build system
- simple Makefile/GNUmakefile/makefile sources
autoconf sources which are incomplete or use outdated files may be
repaired before configuration. For example some CVS 'snapshot' tarballs
require running autogen.sh to generate the autoconf files.
configure_source can usually take care of this and other problems
like out-dated autoconf/automake files automatically.
imake, scons and jam sources are configured using a simple default
method appropriate for each.
Sources that use a simple Makefile don't include a configure script so
not much can be done. src2pkg does look for conflicts with the
installation prefix and tries to repair it if there is only one
Makefile in the package. This covers many small programs which are
hard-coded to install to the prefix /usr/local. If you are using the
default src2pkg PRE_FIX of /usr, src2pkg will try to correct the
Makefile so that the software is compiled for PRE_FIX=/usr. A more
dependable way to handle this is by providing a patch which corrects
the Makefiles(s).
Some source archives have the Makefiles or configure script in a
subdirectory of the sources. configure_source is usally able to find
these if they are in a directory called src, Src or something with the
same name or name+lib as the package name. The final directory
where the files are found is called the CONFIG_DIR. With 'normal'
sources where the config files are in the main directory CONFIG_DIR is
the same as SRC_DIR.
When autoconf sources are configured the CFLAGS variable is passed to
configure along with the prefix and any other configuration options you
specify. You can also specify the CONFIG_COMMAND to be used instead of
'configure', though this is rarely needed. Examples: 'Configure' or
'configure Linux'
The CFLAGS exported before running the CONFIG_COMMAND are made up of
several variables which are strung together for the final value. When
pre_process was run the STD_FLAGS are set to match the architecture of
your machine, unless you have given them. You can also use the
EXTRA_FLAGS argument to add other options to the string, such as -fPIC
(needed for x86_64 architecture). Compiler optimization can also be
explicitly set to whatever you want using OPTIM_FLAGS='' , or easily
set to -Os (maximum size optimization) with MAXIMIZE_FOR_SIZE=YES.
The arguments passed to the CONFIG_COMMAND are also composed of several
easily configurable variables which you supply when needed or are
derived from the defaults, etc. The configuration prefix
(--prefix) is set to the system default which is normally /usr.
Software which is to be installed in a non-default prefix needs to have
the PRE_FIX specified. Other options which usually follow the prefix na
be supplied using the STD_CONFIGS and EXTRA_CONFIGS arguments.
STD_CONFIGS should mostly be used in the src2pkg.conf file for setting
up options to configure which will nearly always be needed, like
STD_CONFIGS='--libdir=/usr/lib64' for 64-bit systems.
EXTRA_CONFIGS is the most used of the optional variables since most
configurations which fail do so because the configure script needs to
have one or more options passed to it for successful configuration.
When you want or need to pass arguments to the configure script besides
the prefix, use the EXTRA_CONFIGS variable. Example:
EXTRA_CONFIGS='--without-gnome --disable-tests'
configure_source skip to the next step if nothing needs to be done, or
you can explicitly skip the step by using CONFIG_COMMAND=skip.
If configuration fails the script will exit gracefully. If you are
running src2pkg in the default non-verbose mode you won't see the
actual output from the configure command. Using REPLAY_ERRORS=YES will
cause src2pkg to turn on the verbosity and re-run the configuration
commands after failing so you can see the ouput. Or you can see all the
ouput the first time by using QUIET=NO. When configuration fails
src2pkg will search the sources for rpm-type .spec files or debian
control files which may contain information about requirements or
dependencies of the software you are trying to build. This information
will be shown, if found.
Some configure scripts are interactive and won't work unless you use
QUIET=NO. If you are attempting a build and the process 'hangs' at this
step, kill it with <CTRL+c>. Then restart the build and use
QUIET=NO to see what is happening. Using DEBUG=1 may also help to show
what's going wrong if you have problems with a build.