Program distribution_GNU - autoconf
Program distribution_GNU - autoconf
lA simple start
lDeeper and deeper
lGenerated File Dependencies
A simple procedure
lcreate Makefile.am (will be shown later)
lrun autoscan
lmv configure.scan configure.ac
ladd bellow macros in configure.ac
–AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
–AM_INIT_AUTOMAKE(FULL-PACKAGE-NAME, VERSION)
lrun aclocal
lrun autoconf
lrun touch NEWS README AUTHORS ChangeLog COPYING
lrun autoheader
lrun automake --add-missing --copy (-a -c for short)
l./configure && make
lmake install is used to install binaries to specific directory
lmake dist is used to package the source to a tar ball.
A simple Makefile.am
lbin_PROGRAMS = xxx
–bin is the installation directory, xxx is the binary’s name.
lxxx_SOURCES = xx.c xx.c …
–set the binary’s dependent source files.
lFor further rules for Makefile.am, please refer to Chapter 6. Introducing GNU Automake of GNU Autoconf, Automake, and Libtool
Contents
lA simple start
lDeeper and deeper
lGenerated File Dependencies
A multi-directory project
lMakefile.am in each source directory:
–'SUBDIRS' is used to list the subdirectories that should be built.
–'$(top_srcdir)' indicates that it should be found relative to the topmost directory of the project.
–‘ INCLUDES‘ is used to set the header file directory. for example:
lINCLUDES = -I$(top_srcdir)/include
A project using libraries
lcreate Makefile.am (refer to next page)
lautoscan
lmv configure.scan configure.ac
ladd macros in configure.ac:
–AC_INIT(FULL-PACKAGE-NAME, VERSION, BUG-REPORT-ADDRESS)
–AM_INIT_AUTOMAKE (FULL-PACKAGE-NAME, VERSION)
–AC_PROG_LIBTOOL
laclocal
llibtoolize (to prepare a package to use libtool)
lautoconf
lautoheader
ltouch NEWS README AUTHORS ChangeLog
lautomake --add-missing --copy
l./configure && make
lmake install is used to install binaries to specific directory
lmake dist is used to package the source to a tar ball.
Makefile.am for libraries
lMakefile.am for libraries:
–lib_LIBRARIES = libmy.a
–libmy_a_SOURCES = xxx.c xxx.c xxx.c
–or:
–lib_LTLIBRARIES = libmy.la
–libmy_la_SOURCES = xxx.c xxx.c xxx.c
lMakefile.am for programs:
–xxx_LDADD = $(top_srcdir)/src/libs/libmy.la
–or:
–xxx_LDADD = $(top_srcdir)/src/libs/libmy.a
lIf external libraries is needed, for example, libpthread, add:
–AM_LDFLAGS = -lpthread
Optional features for configure
lUseful macros in configure.in
lAC_ARG_ENABLE (feature, help-string, [action-if-given], [action-if-not-given])
–If the user gave configure the option ‘--enable-feature’ or ‘--disable-feature’, run shell commands action-if-given.
lAC_MSG_CHECKING (feature-description)
–Notify the user that configure is checking for a particular feature.
lAC_MSG_RESULT (result-description)
–Notify the user of the results of a check.
Contents
lA simple start
lDeeper and deeper
lGenerated File Dependencies
autoscan
lautoscan examines source files in the directory tree rooted at current directory
lautoscan searches the source files for common portability problems, check for incompleteness of `configure.ac', and create a file `configure.scan' which is a preliminary `configure.ac' for that package.
aclocal
laclocal creates the file 'aclocal.m4' by combining stock-installed macros, user-defined macros, and the contents of 'acinclude.m4' to define all the macros required by 'configure.in' in a single file.
autoheader
lautoheader creates a template header for configure (config.h.in)
lautoheader runs m4 over 'configure.in', but with key macros defined differently from when autoconf is executed, such that suitable cpp definitions are output to 'config.h.in'.
automake
lautomake is a tool for automatically generating `Makefile.in' files compliant with the GNU Coding Standards.
lautomake calls libtoolize to generate some extra files if the macro 'AC_PROG_LIBTOOL' is used in 'configure.in'. If it is not present, automake installs 'config.guess' and 'config.sub' by itself.
lMakefile.am
–what needs to be built, and where does it go when it is installed?
automake & libtoolize
autoconf
lautoconf expands the m4 macros in 'configure.in', perhaps using macro definitions from 'aclocal.m4', to generate the configure script.
configure
lconfigure executes the various tests originally specified by the 'configure.in' file, and then creates other scripts.
lautoconf generates configure, configure creates:
–Makefiles
–C header file, including #defines
–Config.status, to recreates Makefiles, C header file.
–Config.log, contains any messages produced by compilers while running configure.
lif 'AC_PROG_LIBTOOL' was used, ltconfig is used to generate a libtool script.
make
lmake uses the rules in the generated 'Makefile' to compile the project sources with the aid of various other scripts generated earlier on.
References
lGNU Autoconf, Automake, and Libtool
By Vaughan, V. Gary, Ben Elliston,
Tom Tromey, Ian Lance Taylor
(http://sources.redhat.com/autobook/)
Tom Tromey, Ian Lance Taylor
(http://sources.redhat.com/autobook/)
lAutoconf manual
http://www.gnu.org/software/autoconf/manual/
http://www.gnu.org/software/autoconf/manual/