Autotools: A Tutorial

Transcription

Embedded Linux Conference 2016GNU Autotools: a tutorialFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com1/99

Thomas PetazzoniICTO and Embedded Linux engineer at Free ElectronsIIIIContributionsIIIEmbedded Linux specialists.Development, consulting and training.http://free-electrons.comKernel support for the Marvell Armada ARM SoCsfrom MarvellMajor contributor to Buildroot, an open-source, simpleand fast embedded Linux build systemLiving in Toulouse, south west of FranceFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com2/99

When talking about autotools, most people think:Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com3/99

When talking about autotools, most people think:Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com3/99

When talking about autotools, most people think:But this is a German book, really about the autotools!Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com3/99

Autotools, why?IYes, the autotools are oldIYes, they have their pain pointsIYes, people hate themIDue to this, people tend to roll-their-own, and roll-their-own build systems tend tobe even worse than the autotoolsButIIIThey bring a number of very useful benefitsThey are not that complicated when you take the time to get back to the basicsFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com4/99

Autotools: benefitsIStandardized build procedure and behavior: users know how to build things thatuse the autotoolsIIGood for human users, but also for build systemsProper handling for diverted installationII.e. build with prefix /usr, but divert the installation to another directory. Neededfor cross-compilation.IBuilt-in support for out-of-tree buildIBuilt-in handling of dependencies on header filesISupport for cross-compilation aspectsSomewhat esoteric, but standardized languages usedIIIILearn once, use for many projectsNew contributors are more likely to know the autotools than your own custom thingOf course, there are alternatives, CMake being the most interesting and widelyused.Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com5/99

DisclaimerII am not an autotools expertII don’t know the internals of autotools, only their usageThis tutorial will only cover the basics aspectsIIIISufficient to understand the autoconf/automake documentationSufficient to understand most existing build systemsWon’t cover many advanced aspectsFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com6/99

Autotools tutorial: agenda1. User point of view2. autoconf basics3. automake basics4. autoconf advanced5. automake advancedFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com7/99

User point of viewFree ElectronsUser point of viewEmbedded LinuxDevelopersThomas Petazzoni Copyright 2004-2016, Free Electrons.Creative Commons BY-SA 3.0 license.Corrections, suggestions, contributions and translations are welcome!Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com8/99

Using autotools based packagesIThe basic steps to build an autotools based software component are:1. Configuration./configureWill look at the available build environment, verify required dependencies, generateMakefiles and a config.h2. CompilationmakeActually builds the software component, using the generated Makefiles.3. Installationmake installInstalls what has been built.Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com9/99

What is configure doing?Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com10/99

Standard Makefile targetsIall, builds everything. The default target.Iinstall, installs everything that should be installed.Iinstall-strip, same as install, but then strips debugging symbolsIuninstallIclean, remove what was builtIdistclean, same as clean, but also removes the generated autotools filesIcheck, run the test suiteIinstallcheck, check the installationIdist, create a tarballFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com11/99

Standard filesystem hierarchyIprefix, defaults to /usr/localIexec-prefix, defaults to prefixIIIIincludedir, for headers, defaults to prefix/includedatarootdir, defaults to prefix/shareIIIIIbindir, for programs, defaults to exec-prefix/binlibdir, for libraries, defaults to exec-prefix/libdatadir, defaults to datarootdirmandir, for man pages, defaults to datarootdir/maninfodir, for info documents, defaults to datarootdir/infosysconfdir, for configuration files, defaults to prefix/etc-- option available for each of themIE.g: ./configure --prefix /sys/Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com12/99

Standard configuration variablesICC, C compiler commandICFLAGS, C compiler flagsICXX, C compiler commandICXXFLAGS, C compiler flagsILDFLAGS, linker flagsICPPFLAGS, C/C preprocessor flagsIand many more, see ./configure --helpIE.g: ./configure CC arm-linux-gccFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com13/99

System types: build, host, targetIautotools identify three system types:IIIICorresponding --build, --host and --target configure options.IIIIIbuild, which is the system where the build takes placehost, which is the system where the execution of the compiled code will take placetarget, which is the system for which the program will generate code. This is onlyused for compilers, assemblers, linkers, etc.They are all automatically guessed to the current machine by default--build, generally does not need to be changed--host, must be overridden to do cross-compilation--target, needs to be overridden if needed (to generate a cross-compiler, forexample)Arguments to these options are configuration names, also called system tuplesFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com14/99

System type: native compilation exampleDemo(based on the kmod source code)Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com15/99

Cross-compilationIBy default, autotools will guess the host machine as being the current machineITo cross-compile, it must be overridden by passing the --host option with theappropriate configuration nameIBy default, autotools will try to use the cross-compilation tools that use theconfiguration name as their prefix.IIf not, the variables CC, CXX, LD, AR, etc. can be used to point to thecross-compilation tools.Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com16/99

Out of tree buildIautotools support out of tree compilation by defaultIConsists in doing the build in a directory separate from the source directoryAllows to:IIIIBuild different configurations without having to rebuild from scratch each time.Not clutter the source directory with build related filesTo use out of tree compilation, simply run the configure script from anotherempty directoryIThis directory will become the build directoryFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com17/99

Out of tree build: exampleDemoFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com18/99

Diverted installation with DESTDIRIIBy default, make install installs to the directories given in --prefix andrelated options.In some situations, it is useful to divert the installation to another directoryIIICross-compilation, where the build machine is not the machine where applicationswill be executed.Packaging, where the installation needs to be done in a temporary directory.Achieved using the DESTDIR variable.Demo!Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com19/99

--prefix or DESTDIR ?I--prefix and DESTDIR are often misunderstoodI--prefix is the location where the programs/libraries will be placed whenexecuted on the host machineIDESTDIR is a way of temporarily diverting the installation to a different location.For example, if you use --prefix /home/ foo /sys/usr, then binaries/librarieswill look for icons in /home/ foo /sys/usr/share/iconsIIIGood for native installation in /home/ foo /sysBad for cross-compilation where the binaries will ultimately be in /usrFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com20/99

--prefix or DESTDIR use casesINative compilation, install system-wide in /usr ./configure --prefix /usr make sudo make installINative compilation, install in a user-specific directory: ./configure --prefix /home/ foo /sys/ make make installICross-compilation, install in /usr, diverted to a temporary directory where thesystem for the target is built ./configure --prefix /usr make make DESTDIR /home/ foo /target-rootfs/ installFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com21/99

Analyzing issuesIautoconf keeps a log of all the tests it runs in a file called config.logIVery useful for analysis of autoconf issuesIIt contains several sections: Platform, Core tests, Running config.status, Cachevariables, Output variables, confdefs.hThe end of the Core tests section is usually the most interesting partIIIThis is where you would get more details about the reason of the configure scriptfailureAt the beginning of config.log you can also see the ./configure line that wasused, with all options and environment variables.Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com22/99

autotools: autoconf and automakeIThe configure script is a shell script generated from configure.ac by aprogram called autoconfIIIThe Makefile.in are generated from Makefile.am files by a program calledautomakeIIUses special make variables that are expanded in standard make constructsSome auxilliary tools like autoheader or aclocal are also usedIIconfigure.ac used to be named configure.in but this name is now deprecatedWritten in shell script, augmented with numerous m4 macrosautoheader is responsible for generating the configuration header template,config.h.inGenerated files (configure, Makefile.in, Makefile) should not be modified.IReading them is also very difficult. Read the real source instead!Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com23/99

Overall organizationFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com24/99

Cache variablesIEach test done by a configure.ac script is associated with a cache variableIThe list of such variables and their values is visible in config.log:## ---------------- #### Cache variables. #### ---------------- ##ac cv build x86 64-unknown-linux-gnuac cv c compiler gnu yes[.]ac cv path SED /bin/sedIIf the autodetected value is not correct for some reason, you can override any ofthese variables in the environment: ac cv path SED /path/to/sed ./configureIThis is sometimes useful when cross-compiling, since some tests are not alwayscross-compilation friendly.Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com25/99

DistributionIIn general:IIWhen a software is published as a tarball, the configure script and Makefile.infiles are already generated and part of the tarball.When a software is published through version control system, only the real sourcesconfigure.ac and Makefile.am are available.IThere are some exceptions (like tarballs not having pre-generatedconfigure/Makefile.in)IDo not version control generated files!Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com26/99

Regenerating autotools files: autoreconfITo generate all the files used by autotools, you could call automake, autoconf,aclocal, autoheader, etc. manually.IIIIBut it is not very easy and efficient.A tool called autoreconf automates this processUseful option: -i or --install, to ask autoreconf to copy missing auxiliary filesAlways use autoreconf!Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com27/99

autoconf basicsFree Electronsautoconf basicsEmbedded LinuxDevelopersThomas Petazzoni Copyright 2004-2016, Free Electrons.Creative Commons BY-SA 3.0 license.Corrections, suggestions, contributions and translations are welcome!Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com28/99

configure.ac languageIReally a shell scriptIProcessed through the m4 preprocessorShell script augmented with special constructs for portability:IIIIAS IF instead of shell if . then . fiAS CASE instead of shell case . esacetc.Iautoconf provides a large set of m4 macros to perform most of the usual testsIMake sure to quote macro arguments with []Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com29/99

Minimal configure.acconfigure.acAC INIT([hello], [1.0])AC OUTPUTIAC INITIIIIEvery configure script must call AC INIT before doing anything else that producesoutput.Process any command-line arguments and perform initialization and verification.Prototype:AC INIT (package, version, [bug-report], [tarname], [url])AC OUTPUTIIEvery configure.ac, should finish by calling AC OUTPUT.Generates and runs config.status, which in turn creates the makefiles and anyother files resulting from configuration.Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com30/99

Minimal configure.ac exampleDemo 01Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com31/99

Additional basic macrosIAC PREREQIIIAC CONFIG SRCDIRIIIIVerifies that a recent enough version of autoconf is usedAC PREREQ([2.68])Gives the path to one source file in your projectAllows autoconf to check that it is really where it should beAC CONFIG SRCDIR([hello.c])AC CONFIG AUX DIRIITells autoconf to put the auxiliary build tools it requires in a different directory,rather than the one of configure.acUseful to keep cleaner build directoryFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com32/99

Additional basic macrosDemo 02Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com33/99

Checking for basic programsIAC PROG CC, makes sure a C compiler is availableIAC PROG CXX, makes sure a C compiler is availableIAC PROG AWK, AC PROG GREP, AC PROG LEX, AC PROG YACC, etc.Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com34/99

Checking for basic programs: exampleDemo 03Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com35/99

AC CONFIG FILESIAC CONFIG FILES (file., [cmds], [init-cmds])IMake AC OUTPUT create each file by copying an input file (by default file.in),substituting the output variable values.ITypically used to turn the Makefile templates Makefile.in files into finalMakefile.IExample:AC CONFIG FILES([Makefile src/Makefile])Icmds and init-cmds are rarely used, see the autoconf documentation for details.Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com36/99

Output variablesIautoconf will replace @variable@ constructs by the appropriate values in fileslisted in AC CONFIG FILESILong list of standard variables replaced by autoconfIAdditional shell variables declared in configure.ac can be replaced usingAC SUBSTIThe following three examples are equivalent:AC SUBST([FOO], [42])FOO 42AC SUBST([FOO])AC SUBST([FOO])FOO 42Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com37/99

AC CONFIG FILES exampleDemo 04Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com38/99

configure.ac: a shell scriptIIt is possible to include normal shell constructs in configure.acIBeware to not use bashisms: use only POSIX compatible constructsIMost configure scripts use directly shell constructs, but AS ECHO, AS IF, etc. areavailable.Demo 05 and 05bFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com39/99

Writing Makefile.in?IAt this point, we have seen the very basics of autoconf to perform theconfiguration side of our softwareIWe could use AC CONFIG FILES to generate Makefile from Makefile.inHowever, writing a Makefile.in properly is not easy, especially if you want to:IIIIIbe portableautomatically handle dependenciessupport conditional compilation, out-of-tree build, diverted installation,cross-compilation, etc.For these reasons, Makefile.in are typically not written manually, but generatedby automake from a Makefile.am fileFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com40/99

automake basicsFree Electronsautomake basicsEmbedded LinuxDevelopersThomas Petazzoni Copyright 2004-2016, Free Electrons.Creative Commons BY-SA 3.0 license.Corrections, suggestions, contributions and translations are welcome!Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com41/99

Makefile.am languageIReally just a MakefileIYou can include regular make codeIAugmented with automake specific constructs that are expanded into regularmake codeIFor most situations, the automake constructs are sufficient to express what needsto be builtFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com42/99

Makefile.am minimal exampleIThe minimal example of Makefile.am to build just one C file into a program isonly two lines:Makefile.ambin PROGRAMS hellohello SOURCES main.cIWill compile main.c to main.oIAnd link hello.o into the hello executableIWhich will be installed in prefix/binFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com43/99

Enabling automake in configure.acITo enable automake usage in configure.ac, you need:IIIA call to AM INIT AUTOMAKEGenerate the Makefile using AC CONFIG FILESautomake will generate the Makefile.in at autoreconf time, and configure willgenerate the final Makefileconfigure.acAC INIT([hello], [1.0])AM INIT AUTOMAKE([foreign 1.13])AC PROG CCAC CONFIG FILES([Makefile])AC OUTPUTFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com44/99

First automake demoDemo 06Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com45/99

AM INIT AUTOMAKEIIAM INIT AUTOMAKE([OPTIONS])Interesting options:IIIIforeign, tells automake to not require all the GNU Coding Style files such as NEWS,README, AUTHORS, etc.dist-bzip2, dist-xz, etc. tell automake which tarball format should be generatedby make distsubdir-objects tells automake that the objects are placed into the subdirectory ofthe build directory corresponding to the subdirectory of the source fileversion, e.g 1.14.1, tells the minimal automake version that is expectedFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com46/99

Makefile.am syntaxIAn automake parsable Makefile.am is composed of product list variables:bin PROGRAMS helloIAnd product source variables:hello SOURCES main.cFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com47/99

Product list variables[modifier-list]prefix PRIMARY product1 product2 .Iprefix is the installation prefix, i.e. where it should be installedIIIPRIMARY describes what type of things should be built:IIIIIIIAll *dir variables from autoconf can be used, without their dir suffix: use bin forbindirE.g.: bindir, libdir, includedir, datadir, etc.PROGRAMS, for executablesLIBRARIES, LTLIBRARIES, for librariesHEADERS, for publicly installed header filesDATA, arbitrary data filesPYTHON, JAVA, SCRIPTSMANS, TEXINFOS, for documentationAfter the sign, list of products to be generatedFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com48/99

Product source variables[modifier-list]product SOURCES file1 file2 .IThe product is the normalized name of the product, as listed in a product listvariableIIThe normalization consists in replacing special characters such as . or by . Forexample, libfoo .a in a product list variable gives the libfoo a SOURCESproduct source variable.SOURCES is always used, it’s not like a configurable primary.IIContains the list of files containing the source code for the product to be built.Both source files and header files should be listed.Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com49/99

More complicated automake exampleDemo 07Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com50/99

autoconf advancedFree Electronsautoconf advancedEmbedded LinuxDevelopersThomas Petazzoni Copyright 2004-2016, Free Electrons.Creative Commons BY-SA 3.0 license.Corrections, suggestions, contributions and translations are welcome!Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com51/99

Configuration headerIVery often, C/C code needs to know the result of certain tests done by theconfigure script.IA template C header file can be automatically generated by autoheader,generally named config.h.inIThe final header file is generated by configure, generally named config.hIDeclared using AC CONFIG HEADERSconfigure.ac extractAC CONFIG HEADERS([config.h])Example config.h/* Define if the complete vga libraries (vga, vgagl) are installed *//* #undef HAVE LIBVGA *//* Define to 1 if you have the limits.h header file. */#define HAVE LIMITS H 1Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com52/99

AC DEFINEIAC DEFINE allows to create C definitions in the configuration headerIAC DEFINE (variable, value, description)configure.acAC DEFINE([FOOBAR], [42], [This is the foobar value])Demo 08Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com53/99

Checking for functionsIIYou may need to check if certain functions are available and/or meet certaincharacteristicsFamily of AC FUNC * macrosIIIAC FUNC FORK, AC FUNC GETLOADAVG, AC FUNC MALLOC, etc.See autoconf manual for detailsAC CHECK FUNC[S] to check for generic functionsIIIAC CHECK FUNC (function, [action-if-found], [action-if-not-found])AC CHECK FUNCS (function., [action-if-found], [action-if-notfound])Results availableIIac cv func function variable in configure.acHAVE FUNCTION defines in configuration headersFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com54/99

AC CHECK FUNCS() exampleDemo 09Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com55/99

Checking for headersIIMuch like AC FUNC * and AC CHECK FUNC[S], but for headersVariety of AC HEADER * macrosIICheck the autoconf manual for detailsAC CHECK HEADER[S] for generic headers checkingIIIAC CHECK HEADER (header-file, [action-if-found], [action-if-notfound], [includes])AC CHECK HEADERS (header-file., [action-if-found], [action-ifnot-found], [includes])Results available in:IIac cv header header-file variable in configure.acHAVE HEADER H define in config.hFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com56/99

AC CHECK HEADERS exampleconfigure.ac[.]AC CHECK HEADERS([spawn.h],[echo "Header spawn.h was found"; has spawn yes],[echo "Header spawn.h was not found"])echo {has spawn}[.]Execution of ./configure ./configure[.]checking for spawn.h. yesHeader spawn.h was foundyes[.]Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com57/99

Checking for librariesAC SEARCH LIBS (function, search-libs,[action-if-found], ch for a library defining function, by linking a simple program callingfunctionTries first with no library, and then with the different libraries in search-libs,one after the other.If a library is found, -llibrary is prepended to the LIBS variable, so programswill be linked against it. action-if-found is executed.If not, action-if-not-found is executedother-libraries allows to pass additional -l foo arguments that may beneeded for the link test to succeed.Result in ac cv search function Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com58/99

AC SEARCH LIBS exampleDemo 10Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com59/99

Other checksIPrograms with AC CHECK PROGSIAC CHECK PROGS(PERL, [perl5 perl])IDeclarations with AC CHECK DECLSIStructure members with AC CHECK MEMBERSTypes with AC CHECK TYPESIIIAC CHECK TYPES(int8 t)See the autoconf manual for detailsFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com60/99

Writing new testsIYou can create your own tests by pre-processing, compiling or linking small testprograms:IIIIIPre-processing testAC PREPROC IFELSE (input, [action-if-true], [action-if-false])Compiling testAC COMPILE IFELSE (input, [action-if-true], [action-if-false])Link testAC LINK IFELSE (input, [action-if-true], [action-if-false])Input should be formatted with AC LANG SOURCE or AC LANG PROGRAMRuntime tests can also be createdIIBeware, by nature, they cannot work for cross-compilation!AC RUN IFELSEFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com61/99

Writing new tests: AC LINK IFELSEDemo 11Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com62/99

Printing messagesIIWhen creating new tests, you may want to show messages, warnings, errors, etc.AC MSG CHECKING (feature-description)IIAC MSG RESULT (result-description)IIDeliver the message to the user.AC MSG ERROR (error-description, [exit-status ?/1])IINotify the user of the results of a checkAC MSG NOTICE (message)IINotify the user that configure is checking for a particular feature.Notify the user of an error that prevents configure from completing.AC MSG WARN (problem-description)INotify the configure user of a possible problem.Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com63/99

Printing messages: exampleDemo 11 continuedFree Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting, training and support. http://free-electrons.com64/99

Cache variablesIEach test done by autoconf is normally associated to a cache variable.IIAllows to speed-up the configure step by passing

Disclaimer I I am not an autotools expert I I don't know the internals of autotools, only their usage I This tutorial will only cover the basics aspects I Su cient to understand the autoconf/automake documentation I Su cient to understand most existing build systems I Won't cover many advanced aspects Free Electrons - Embedded Linux, kernel, drivers and Android - Development, consulting .