You can tell when a program uses configure because it will contain at least one file with the filename of Makefile.in. The quick and dirty method to compile software using configure is:


./configure
make
make install


Believe it or not once you've got a compiler installed and have your PATH adjusted, that is pretty much all you need to do to compile software.


Just because you can doesn't mean you should though. There are a few things that you need to know about configure to use it to its full potential. Running this single script will create the makefiles that will enable a compiler to produce code on just about any system that can run the script.


Before you do anything you should read the README and INSTALL docs that came with the source code. They feature comments by the programmer on the program, how to compile it, and things to watch out for. It goes without saying that you should read these files. These should be ASCII text files that any program should be able to display.


After you've finished reading README and INSTALL type:
./configure --help |more


After you press enter configure will run and will send to your screen all the options that are available for you to use. Almost any configure --help screen should include the option:


--enable-shared. In almost all cases you should set this option. When you compile GCC on your system I strongly encourage you to use this switch. I've had software fail to compile because my GCC was built with static libraries and not dynamic libraries. The open source programs that I've been compiling lately seem to have this set as the default option so you may not need to set it for current software.


After you've noted which configure options you're going to use run configure again with your list of options.


When you run 'configure -options' the shell script attempts to guess correct values for various system-dependent variables used during compilation. It uses those values to create a 'Makefile' in each directory of the package. It may also create one or more '.h' files containing system-dependent definitions. Finally, it creates a shell script 'config.status' that you can run in the future to recreate the current configuration, and a file 'config.log' containing compiler output (useful mainly for debugging 'configure').


You can copy the config.status file to another machine. Any options that you chose when you ran configure is saved to this file. Instead of running 'configure --options' again you can simply run config.status and it will recreate the environment for you automatically.


Another way to do what config.status is supposed to do is to simply head config.log. The first few lines of config.log contain the command line that was used to run configure. Just head the file and save off the command line to some safe file at some safe location.


If configure fails for any reason check the log file. I've sent my config.log file to developers before to get help when they had a major change of their software. This is a great way for them to see what's happening on the system you're using especially if you're running a different flavor of UNIX then they are. Remember, configures ATTEMPTS to automate the process of creating the all-important Makefile.


It can also use an optional file typically called 'config.cache' which is enabled by using '--cache-file=config.cache' or simply '-C'. Configure caches some of the results of its test to speed up reconfiguring. Caching is disabled by default to prevent problems with accidental use of stale cache files.


If you have a config.cache file running 'configure --options' again will NOT do you any good until you remove the cache file. Configure will look for the cache file before looking for an options list. It uses config.cache before it looks for your switches.


After configure finishes you simply type 'make', and then when that finishes, 'make install'. Make install installs the software onto your system. You're now finished with compiling software. There are a couple of more things you need to be aware of though.


If for any reason the software fails to compile run 'make distclean' before attempting to compile the program again.


Most software can be uninstalled by recompiling the software and instead of running 'make install' you run 'make uninstall' instead. The reason you need to recompile the software is because of: switches. Different switches can cause different files to be installed or not to be installed. In order to perform a clean unisntall you need to recreate the exact environment that was used to install the software in the first place.


We will discuss some other things you can do to help troubleshoot compilation failures in another section.


Next Section:  Compiling GCC (5 of 11)



This Web Site Copyright © 1997 - 2008
by Alan Pae - All Rights Reserved