I currently work with a large build system that has recursive make files, configure scripts, makefile.am's, makefile.in's etc. So my work involves spending 1 unit of time in writing the code and 2 to 3 units of time in trying to make it compile with the jargon.
Hence I decided to look a bit deep into it. Here is what I thought should be noted down.
Autotools are mainly useful when you are doing cross platform development. It is a set of 3 tools:
1. Autoconf: Creates a configure script that analyzes the system at compile time. e.g. whether 'cc' is used or 'gcc'
2. Automake: Generates makefile that will compile your code.
3. Libtools: Used to create shared libraries, platform independently
Summary of the build process:
./configure -> make -> make install :: is the standard build process.
1. "configure" script has to be generated. It is generated by 'autoconf'.
-- 'autoconf' needs a file called 'configure.ac' for this. Writing configure.ac by hand is difficult. Hence 'autoscan' is used
-- autoscan (run w/o arguments on shell - $autoscan <-|) generates 'configure.scan' You will mostly rename it to be configure.ac
-- running 'autoconf' in a directory where 'configure.ac' is present creates 'configure' script. (Other files are generated in the process. Ignore them for time being)
-- Now we have 'configure' file and can run './configure' BUT 'configure' script uses a file called 'Makefile.in' to generate makefile. Hence this 'Makefile.in' needs to be present.
-- You will also need a 'config.h.in' if you want to make your program portable. That is done using 'autoheader' ($autoheader <-|). Then you can modify config.h as you want.
2. Makefile has to be generated. As mentioned above it is generated by 'configure' script by using 'Makefile.in'
-- Makefile.in is generated by 'automake' tool by using a file called 'Makefile.am'. 'Makefile.am' has to be written manually :-) (Writing 'Makefile.am' needs a bigger explanation. so, lets assume here that its written)
-- In the same directory $automake<-| -> $aclocal<-| (aclocal generates some needed macros)
-- If automake generates errors, you will have to modify 'configure.ac' and rerun 'aclocal' and 'autoconf'
3. Finally, 1. ./configure to generate 'Makefile' -> 2. Make 3. Make install
Resources:
1. http://markuskimius.wikidot.com/programming:tut:autotools
2. http://sources.redhat.com/autobook/autobook/autobook_toc.html
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment