An overview of the GNU autotools Some practical











- Slides: 11
An overview of the GNU autotools Some practical advice about GNU autotools April 14, 2003 – Stanford Linear Accelerator Center Fabrizio Coccetti April 14, 2003 Fabrizio Coccetti - Stanford Linear Accelerator Center 1
The Issue n Warren did not only have PIPE Dreams at CHEP 03 … n He also has Auto-configuration Dreams Something that works out of the box, you just say ‘install’ and it works. April 14, 2003 Fabrizio Coccetti - Stanford Linear Accelerator Center 2
The real Problem n How do we handle platform specific issues? n n Providing a different Makefile for each architecture Using Autoconf, Automake and Libtool n The installer needs only n n n Bourne shell C compilers Make program April 14, 2003 Fabrizio Coccetti - Stanford Linear Accelerator Center 3
Some advantages when using GNU autotools n The installation of a program is straightforward: . /configure; make install n This procedure checks for system parameters, libraries, location of programs, availability of functions and writes a Makefile n. /configure supports many options to overwrite defaults settings April 14, 2003 Fabrizio Coccetti - Stanford Linear Accelerator Center 4
GNU autoconf Source Code configure. ac (configure. in) aclocal autoscan autoconfigure. scan configure April 14, 2003 Fabrizio Coccetti - Stanford Linear Accelerator Center 5
GNU automake Makefile. am automake Makefile. in configure Makefile April 14, 2003 Fabrizio Coccetti - Stanford Linear Accelerator Center 6
configure. ac n dnl Comment … … n AC_INIT(main. c) n AM_INIT_AUTOMAKE(project_name, 1. 2. 8) n AM_PROG_LIBTOOL it supports libtool and shared libraries n AC_PROG_CC it locates the C (C++) compiler n AC_HEADER_STDC it checks for standard headers n AC_CHECK_HEADERS(sys/time. h /header. h) it checks for headers availability n AC_CHECK_LIB(crypto SSLeay_version) it checks for libraries availability n AC_CHECK_FUNCS(ctime) it checks for functions availability n AC_PROG_INSTALL it checks for BSD compatible install utility n AC_OUTPUT([Makefile]) April 14, 2003 (or AC_PROG_CXX) Fabrizio Coccetti - Stanford Linear Accelerator Center 7
Makefile. am n bin_PROGRAMS = foo /configure --prefix=… (default /usr/local) n foo_PROGRAMS=foo. c foo. h n noist_PROGRAMS=test (make compiles, make install does nothing) n EXTRA_DIST=disclaimer. txt April 14, 2003 Fabrizio Coccetti - Stanford Linear Accelerator Center 8
Example n foo. c : #include <stdio. h> main() { printf(“Cum grano salisn"); } n Makefile. am : bin_PROGRAMS = foo_SOURCES = foo. c n configure. ac : AC_INIT(foo. c) AM_INIT_AUTOMAKE(latin_words, 0. 9) AC_PROG_CC AC_HEADER_STDC AC_PROG_INSTALL AC_OUTPUT([Makefile]) April 14, 2003 Fabrizio Coccetti - Stanford Linear Accelerator Center 9
Summary n Source Code, configure. ac, Makefile. am n autoscan; aclocal; autoconf n Create NEWS README AUTHORS Change. Log automake –add-missing n. /configure; make dist n n Result: project_name-2. 10. tar. gz aclocal. m 4 configure. in NEWS config. log mkinstalldirs April 14, 2003 autom 4 te-2. 53. cache Change. Log config. status COPYING install-sh Makefile. am missing README AUTHORS autoscan. log configure. scan INSTALL Makefile. in code. c Fabrizio Coccetti - Stanford Linear Accelerator Center 10
References n GNU Autoconf, Automake, and Libtool http: //sources. redhat. com/autobook/autobook_toc. html n GNU Autoconf Manual http: //www. gnu. org/manual/autoconf n GNU Automake Manual http: //www. gnu. org/manual/automake n GNU Libtool Manual http: //www. gnu. org/manual/libtool n Learning the GNU development tools http: //autotoolset. sourceforge. net/tutorial. html n The GNU configure and build system http: //www. airs. com/ian/configure_toc. html n GNU macro processor (GNU m 4) http: //www. gnu. org/manual/m 4 -1. 4/m 4. html April 14, 2003 Fabrizio Coccetti - Stanford Linear Accelerator Center 11