9. Makefile.in / configure
If an application should build on many different systems, it needs to be properly configured to adapt to the particular features of any supported system. To solve this problem, there is a tool named autoconf which a software author can use for this purpose. With autoconf the author/ developer creates a file named configure that is then included in the source package and should be executed by the installer (configure is simply a shell script). When you execute configure, it will
probe your system for (hopefully) all relevant features,
generate a Makefile from an input file called Makefile.in, and
generate a file config.h from an input file called config.h.in.
bash$ ./configure
creating cache ./config.cache
checking for a BSD compatible install... /usr/bin/ginstall -c
…
checking for gcc... gcc
…
checking for gtk-config... /usr/bin/gtk-config
checking for GTK - version >= 1.2.0... yes
…
checking for getpagesize... yes
checking for working mmap... yes
…
creating Makefile
creating src/Makefile
creating config.h
You can see that configure checks for the
presence of the compiler (gcc) as well
as for an install utility. It also
looks for gtk+, which is a widget
library (i.e. it creates windows, buttons, text entry fields and so on
for graphical user interfaces), checks for system-specific items
(getpagesize, mmap), and finally creates Makefile,
Makefile.in, and config.h. Note
that only a small part of the output is shown in the example above.
configure should be invoked as ./configure and can take arguments. Some of the more interesting ones are:
- --help
./configure --help will list all available arguments.
- --prefix=PREFIX
Defines the prefix for install directories. E.g. if PREFIX is /usr/local, then executables will be installed into /usr/local/bin, libraries will be installed in /usr/local/lib, and manpages into /usr/local/man/man1
- --disable-nls
Disable internationalisation (Natural Language Support) if you don't need/want it. Note that NLS sometimes causes compile problems, so disabling it is safer.
![]() | TIP |
|---|---|
Use ./configure --help to list available options, and/or read the README and INSTALL files to check which of these options may be of interest for you. |
![]() | TIP |
|---|---|
If you edit the Makefile generated by configure, your changes will get lost if you run ./configure again. Edit the Makefile.in file instead. |
