SlideShare a Scribd company logo
1 of 49
Download to read offline
Autotools - 16 Juin 2015 1
www.ciose.fr
AutotoolsAutotools
C. CharreyreC. Charreyre
christian.charreyre@ciose.frchristian.charreyre@ciose.fr
http://www.ciose.frhttp://www.ciose.fr
@CIOinfoindus@CIOinfoindus
Autotools - 16 Juin 2015 2
www.ciose.fr
Licence
Attribution-Noncommercial-Share Alike 4.0 International
You are free:
to Share - copy and redistribute the material in any medium or format
to Adapt - remix, transform, and build upon the material
The licensor cannot revoke these freedoms as long as you follow the license terms.
Under the following conditions:
Attribution — You must give appropriate credit, provide a link to the license, and indicate if
changes were made. You may do so in any reasonable manner, but not in any way that
suggests the licensor endorses you or your use.
NonCommercial — You may not use the material for commercial purposes.
ShareAlike — If you remix, transform, or build upon the material, you must distribute your
contributions under the same license as the original.
No additional restrictions — You may not apply legal terms or
technological measures that legally restrict others from doing
anything the license permits.
License text : http://creativecommons.org/licenses/by-nc-sa/4.0/legalcode
Autotools - 16 Juin 2015 3
www.ciose.fr
Crédits
Document utilisé pour bâtir cette présentation :
Using GNU Autotools – Alexandre Duret-Lutz – 16
Mai 2010
Autotools - 16 Juin 2015 4
www.ciose.fr
CIO en quelques mots
Société d'ingénierie en systèmes embarqués :
électronique et logiciel
Au service de nos clients depuis 1990
15 spécialistes en embarqué et temps réel
Expert en Linux embarqué depuis 2000,
OpenEmbedded et Yocto depuis 2008
CA annuel : 1 500 000 €
Siège à Saint-Etienne
Agence à Marseille
Agréé CIR
Autotools - 16 Juin 2015 5
www.ciose.fr
C. Charreyre en quelques
mots
Associé au sein de CIO
Responsable des technologies Linux embarqué
Formateur Linux embarqué (avec Captronic et
en direct)
30 ans dans l'embarqué et le monde Unix / Linux
Fervent promoteur du logiciel libre
Membre de Medinsoft – Commission Logiciel
Libre
Autotools - 16 Juin 2015 6
www.ciose.fr
Pourquoi les Autotools ?
Dans l'univers du libre, on distribue le code
source
C'est l'utilisateur qui compile le code
Mais l'utilisateur n'a pas forcément le même
environnement logiciel que le développeur 
Nécessité de sources portables
Nécessité d'un système de build adaptatif
Autotools = système de génération de Makefiles
adaptés à l'environnement logiciel de l'utilisateur,
bâtis dynamiquement avant compilation
Utile dans le cas de l'embarqué : ressources
logicielles réduites, développement croisé ….
Autotools - 16 Juin 2015 7
www.ciose.fr
Les rôles
L'utilisateur final :
Extrait, configure, compile et installe le logiciel
tar xzvf prog.tar.gz, ./configure, 
make, sudo make install
Le développeur
Fournit un système de configuration dynamique des
Makefiles (en particulier flags compilateur et linker)
Fournit des contrôles de prérequis logiciel lors de la phase
de configuration
Écrit ses sources de manière portable avec des
compilations conditionnelles dépendant des résultats de
configuration dynamique
Fonction présente ou pas
Signatures fonction variable
Fichiers d'include variables ….
Options activées ou pas
Autotools - 16 Juin 2015 8
www.ciose.fr
Les rôles
Le développeur est utilisateur final sur son poste
de développement lorsqu'il exécute pour lui
même
./configure, make, sudo make install
Autotools - 16 Juin 2015 9
www.ciose.fr
Autoconf
Couvre les utilitaires autoconf, 
autoheader, autoscan, autoreconf, 
autoupdate
Fonction principale :
Créer configure et config.h.in à partir de
configure.ac
configure.ac écrit par le développeur
configure généré par autoconf – shell script de
configuration lancé avant compilation. Assure la
configuration dynamique de la chaîne de compilation.
config.h.in généré par autoheader – template
de fichier d'include pour les compilations
conditionnelles liés au résultat de configuration.
Permet la portabilité des sources
Autotools - 16 Juin 2015 10
www.ciose.fr
Autoconf
Autres fonctions :
autoscan crée un 1er
template de fichier
configure.ac nommé configure.scan, par
analyse du répertoire de travail
autoreconf appelle les divers outils en séquence,
dans le bon ordre – à utiliser au tout début
autoupdate actualise configure.ac en cas de
changement de version
autoconf exécuté par le développeur
Autotools - 16 Juin 2015 11
www.ciose.fr
Automake
Couvre les utilitaires automake, aclocal
Fonction principale :
Créer le(s) fichier(s) Makefile.in à partir du(des)
template(s) Makefile.am
Autres fonctions :
aclocal crée le fichier aclocal.m4 (macros en
langage m4) à partir de configure.ac
automake exécuté par le développeur.
Autotools - 16 Juin 2015 12
www.ciose.fr
configure
configure crée le fichier config.h et le(s)
fichier(s) Makefile à partir de config.h.in et
Makefile.in
configure est exécuté par l'utilisateur final
Autotools - 16 Juin 2015 13
www.ciose.fr
Récapitulatif
Crédit : Using GNU Autotools – Alexandre Duret-Lutz
Actions développeur
Autotools - 16 Juin 2015 14
www.ciose.fr
Récapitulatif
Actions utilisateur final
Autotools - 16 Juin 2015 15
www.ciose.fr
Un exemple : autohello
Création d'un programme Hello World basé
autotools
Structure standard :
Répertoire autohello comprend configure.ac et
Makefile.am
Sources dans un sous répertoire src
Autotools - 16 Juin 2015 16
www.ciose.fr
Autohello : top level
directory
Fichier Makefile.am
/tmp/autohello : cat Makefile.am
SUBDIRS = src
Chaînage vers
le répertoire src
Autotools - 16 Juin 2015 17
www.ciose.fr
Autohello : top level
directory
Fichier configure.ac
/tmp/autohello : cat configure.ac
# ­*­ Autoconf ­*­
# Process this file with autoconf to produce a 
configure script.
# Define version major, minor and micro number
m4_define([autohello_version_major], [1])
m4_define([autohello_version_minor], [0])
m4_define([autohello_version_micro], [0])
m4_define([autohello_version],        
[autohello_version_major.autohello_version_minor.
autohello_version_micro])
Définition des
éléments de
version
Autotools - 16 Juin 2015 18
www.ciose.fr
Autohello : top level
directory
Fichier configure.ac (continued)
AC_PREREQ([2.63])
AC_INIT([autohello], [autohello_version], 
[christian.charreyre@ciose.fr])
AC_CONFIG_SRCDIR([src/autohello.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([foreign])
AUTOHELLO_VERSION_MAJOR=autohello_version_major
AUTOHELLO_VERSION_MINOR=autohello_version_minor
AUTOHELLO_VERSION_MICRO=autohello_version_micro
AUTOHELLO_VERSION=autohello_version
AC_SUBST(AUTOHELLO_VERSION_MAJOR)
AC_SUBST(AUTOHELLO_VERSION_MINOR)
AC_SUBST(AUTOHELLO_VERSION_MICRO)
AC_SUBST(AUTOHELLO_VERSION)
Autotools - 16 Juin 2015 19
www.ciose.fr
Autohello : top level
directory
Fichier configure.ac (continued)
AC_PREREQ([2.63])
AC_INIT([autohello], [autohello_version], 
[christian.charreyre@ciose.fr])
AC_CONFIG_SRCDIR([src/autohello.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([foreign])
AUTOHELLO_VERSION_MAJOR=autohello_version_major
AUTOHELLO_VERSION_MINOR=autohello_version_minor
AUTOHELLO_VERSION_MICRO=autohello_version_micro
AUTOHELLO_VERSION=autohello_version
AC_SUBST(AUTOHELLO_VERSION_MAJOR)
AC_SUBST(AUTOHELLO_VERSION_MINOR)
AC_SUBST(AUTOHELLO_VERSION_MICRO)
AC_SUBST(AUTOHELLO_VERSION)
Version minimale
d'autoconf requise
Autotools - 16 Juin 2015 20
www.ciose.fr
Autohello : top level
directory
Fichier configure.ac (continued)
AC_PREREQ([2.63])
AC_INIT([autohello], [autohello_version], 
[christian.charreyre@ciose.fr])
AC_CONFIG_SRCDIR([src/autohello.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([foreign])
AUTOHELLO_VERSION_MAJOR=autohello_version_major
AUTOHELLO_VERSION_MINOR=autohello_version_minor
AUTOHELLO_VERSION_MICRO=autohello_version_micro
AUTOHELLO_VERSION=autohello_version
AC_SUBST(AUTOHELLO_VERSION_MAJOR)
AC_SUBST(AUTOHELLO_VERSION_MINOR)
AC_SUBST(AUTOHELLO_VERSION_MICRO)
AC_SUBST(AUTOHELLO_VERSION)
Initialisation
Paramètres :
Nom package,
Version,
Adresse mainteneur
Autotools - 16 Juin 2015 21
www.ciose.fr
Autohello : top level
directory
Fichier configure.ac (continued)
AC_PREREQ([2.63])
AC_INIT([autohello], [autohello_version], 
[christian.charreyre@ciose.fr])
AC_CONFIG_SRCDIR([src/autohello.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([foreign])
AUTOHELLO_VERSION_MAJOR=autohello_version_major
AUTOHELLO_VERSION_MINOR=autohello_version_minor
AUTOHELLO_VERSION_MICRO=autohello_version_micro
AUTOHELLO_VERSION=autohello_version
AC_SUBST(AUTOHELLO_VERSION_MAJOR)
AC_SUBST(AUTOHELLO_VERSION_MINOR)
AC_SUBST(AUTOHELLO_VERSION_MICRO)
AC_SUBST(AUTOHELLO_VERSION)
Définition
répertoire sources
Autotools - 16 Juin 2015 22
www.ciose.fr
Autohello : top level
directory
Fichier configure.ac (continued)
AC_PREREQ([2.63])
AC_INIT([autohello], [autohello_version], 
[christian.charreyre@ciose.fr])
AC_CONFIG_SRCDIR([src/autohello.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([foreign])
AUTOHELLO_VERSION_MAJOR=autohello_version_major
AUTOHELLO_VERSION_MINOR=autohello_version_minor
AUTOHELLO_VERSION_MICRO=autohello_version_micro
AUTOHELLO_VERSION=autohello_version
AC_SUBST(AUTOHELLO_VERSION_MAJOR)
AC_SUBST(AUTOHELLO_VERSION_MINOR)
AC_SUBST(AUTOHELLO_VERSION_MICRO)
AC_SUBST(AUTOHELLO_VERSION)
Demande création
automatique
header config.h
Autotools - 16 Juin 2015 23
www.ciose.fr
Autohello : top level
directory
Fichier configure.ac (continued)
AC_PREREQ([2.63])
AC_INIT([autohello], [autohello_version], 
[christian.charreyre@ciose.fr])
AC_CONFIG_SRCDIR([src/autohello.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([foreign])
AUTOHELLO_VERSION_MAJOR=autohello_version_major
AUTOHELLO_VERSION_MINOR=autohello_version_minor
AUTOHELLO_VERSION_MICRO=autohello_version_micro
AUTOHELLO_VERSION=autohello_version
AC_SUBST(AUTOHELLO_VERSION_MAJOR)
AC_SUBST(AUTOHELLO_VERSION_MINOR)
AC_SUBST(AUTOHELLO_VERSION_MICRO)
AC_SUBST(AUTOHELLO_VERSION)
Macros nécessaires
pour générer Makefiles
(lien vers automake)
Autotools - 16 Juin 2015 24
www.ciose.fr
Autohello : top level
directory
Fichier configure.ac (continued)
AC_PREREQ([2.63])
AC_INIT([autohello], [autohello_version], 
[christian.charreyre@ciose.fr])
AC_CONFIG_SRCDIR([src/autohello.c])
AC_CONFIG_HEADERS([config.h])
AM_INIT_AUTOMAKE([foreign])
AUTOHELLO_VERSION_MAJOR=autohello_version_major
AUTOHELLO_VERSION_MINOR=autohello_version_minor
AUTOHELLO_VERSION_MICRO=autohello_version_micro
AUTOHELLO_VERSION=autohello_version
AC_SUBST(AUTOHELLO_VERSION_MAJOR)
AC_SUBST(AUTOHELLO_VERSION_MINOR)
AC_SUBST(AUTOHELLO_VERSION_MICRO)
AC_SUBST(AUTOHELLO_VERSION)
Affectation des valeurs
définies par m4_define
Substitution des valeurs
dans les fichiers
générés
Autotools - 16 Juin 2015 25
www.ciose.fr
Autohello : top level
directory
Fichier configure.ac (continued)
# Checks for programs.
AC_PROG_CC
# Checks for header files.
AC_CHECK_HEADERS([stdio.h stdlib.h])
# Generate files
AC_CONFIG_FILES([Makefile
src/Makefile
src/autohello­version.h])
AC_OUTPUT
Autotools - 16 Juin 2015 26
www.ciose.fr
Autohello : top level
directory
Fichier configure.ac (continued)
# Checks for programs.
AC_PROG_CC
# Checks for header files.
AC_CHECK_HEADERS([stdio.h stdlib.h])
# Generate files
AC_CONFIG_FILES([Makefile
src/Makefile
src/autohello­version.h])
AC_OUTPUT
Vérification présence
compilateur C
Autotools - 16 Juin 2015 27
www.ciose.fr
Autohello : top level
directory
Fichier configure.ac (continued)
# Checks for programs.
AC_PROG_CC
# Checks for header files.
AC_CHECK_HEADERS([stdio.h stdlib.h])
# Generate files
AC_CONFIG_FILES([Makefile
src/Makefile
src/autohello­version.h])
AC_OUTPUT
Vérification
présence
headers requis
Autotools - 16 Juin 2015 28
www.ciose.fr
Autohello : top level
directory
Fichier configure.ac (continued)
# Checks for programs.
AC_PROG_CC
# Checks for header files.
AC_CHECK_HEADERS([stdio.h stdlib.h])
# Generate files
AC_CONFIG_FILES([Makefile
src/Makefile
src/autohello­version.h])
AC_OUTPUT
Fichiers à
créer
Autotools - 16 Juin 2015 29
www.ciose.fr
Autohello : src directory
Fichier autohello-version.h.in
/tmp/autohello/src : cat autohello­version.h.in
/**
* @file autohello­version.h
* 
* This header files defines parts if the software 
version.
* 
* @author Christian Charreyre 
<christian.charreyre@ciose.fr>
*/
#ifndef _AUTOHELLO_VERSION_H_
#define _AUTOHELLO_VERSION_H_
/** The major version, (1, if %AUTOHELLO_VERSION is 
1.2.3) */
#define AUTOHELLO_VERSION_MAJOR 
(@AUTOHELLO_VERSION_MAJOR@)
Remplacé par valeur définie
lors du configure
Autotools - 16 Juin 2015 30
www.ciose.fr
Autohello : src directory
Fichier autohello-version.h.in (continued)
/** The minor version (2, if %AUTOHELLO_VERSION is 
1.2.3) */
#define AUTOHELLO_VERSION_MINOR 
(@AUTOHELLO_VERSION_MINOR@)
/** The micro version (3, if %AUTOHELLO_VERSION is 
1.2.3) */
#define AUTOHELLO_VERSION_MICRO 
(@AUTOHELLO_VERSION_MICRO@)
/** The full version, like 1.2.3 */
#define AUTOHELLO_VERSION        @AUTOHELLO_VERSION@
/** The full version, in string form (suited for 
string concatenation)
 */
#define AUTOHELLO_VERSION_STRING "@AUTOHELLO_VERSION@"
#endif /* _AUTOHELLO_VERSION_H_ */
Remplacé par valeur définie
lors du configure
Autotools - 16 Juin 2015 31
www.ciose.fr
Autohello : src directory
Fichier autohello.c
/tmp/autohello/src : cat autohello.c
/**
 * @file autohello.c
 * 
 * This file implements simple hello world program.
 * 
 * @author Christian Charreyre 
<christian.charreyre@ciose.fr>
 */
#include <stdio.h>
#include <stdlib.h>
#include "config.h"
#include "autohello­version.h"
int main(int argc, char **argv)
{
    printf("Hello world version %sn",     
AUTOHELLO_VERSION_STRING);
    printf("Report bugs to %sn", PACKAGE_BUGREPORT);
    exit(0);
}
Autotools - 16 Juin 2015 32
www.ciose.fr
Autohello : src directory
Fichier autohello.c
/tmp/autohello/src : cat autohello.c
/**
 * @file autohello.c
 * 
 * This file implements simple hello world program.
 * 
 * @author Christian Charreyre 
<christian.charreyre@ciose.fr>
 */
#include <stdio.h>
#include <stdlib.h>
#include "config.h"
#include "autohello­version.h"
int main(int argc, char **argv)
{
    printf("Hello world version %sn",     
AUTOHELLO_VERSION_STRING);
    printf("Report bugs to %sn", PACKAGE_BUGREPORT);
    exit(0);
}
Présence headers
vérifiée durant
configure
Autotools - 16 Juin 2015 33
www.ciose.fr
Autohello : src directory
Fichier autohello.c
/tmp/autohello/src : cat autohello.c
/**
 * @file autohello.c
 * 
 * This file implements simple hello world program.
 * 
 * @author Christian Charreyre 
<christian.charreyre@ciose.fr>
 */
#include <stdio.h>
#include <stdlib.h>
#include "config.h"
#include "autohello­version.h"
int main(int argc, char **argv)
{
    printf("Hello world version %sn",     
AUTOHELLO_VERSION_STRING);
    printf("Report bugs to %sn", PACKAGE_BUGREPORT);
    exit(0);
}
config.h généré
par configure
Autotools - 16 Juin 2015 34
www.ciose.fr
Autohello : src directory
Fichier autohello.c
/tmp/autohello/src : cat autohello.c
/**
 * @file autohello.c
 * 
 * This file implements simple hello world program.
 * 
 * @author Christian Charreyre 
<christian.charreyre@ciose.fr>
 */
#include <stdio.h>
#include <stdlib.h>
#include "config.h"
#include "autohello­version.h"
int main(int argc, char **argv)
{
    printf("Hello world version %sn",     
AUTOHELLO_VERSION_STRING);
    printf("Report bugs to %sn", PACKAGE_BUGREPORT);
    exit(0);
}
autohello-version.h généré
par configure
Autotools - 16 Juin 2015 35
www.ciose.fr
Autohello : src directory
Fichier autohello.c
/tmp/autohello/src : cat autohello.c
/**
 * @file autohello.c
 * 
 * This file implements simple hello world program.
 * 
 * @author Christian Charreyre 
<christian.charreyre@ciose.fr>
 */
#include <stdio.h>
#include <stdlib.h>
#include "config.h"
#include "autohello­version.h"
int main(int argc, char **argv)
{
    printf("Hello world version %sn",     
AUTOHELLO_VERSION_STRING);
    printf("Report bugs to %sn", 
PACKAGE_BUGREPORT);
    exit(0);
}
Défini dans
autohello-version.h
Autotools - 16 Juin 2015 36
www.ciose.fr
Autohello : src directory
Fichier autohello.c
/tmp/autohello/src : cat autohello.c
/**
 * @file autohello.c
 * 
 * This file implements simple hello world program.
 * 
 * @author Christian Charreyre 
<christian.charreyre@ciose.fr>
 */
#include <stdio.h>
#include <stdlib.h>
#include "config.h"
#include "autohello­version.h"
int main(int argc, char **argv)
{
    printf("Hello world version %sn",     
AUTOHELLO_VERSION_STRING);
    printf("Report bugs to %sn", 
PACKAGE_BUGREPORT);
    exit(0);
}
Défini dans
config.h
Autotools - 16 Juin 2015 37
www.ciose.fr
Autohello : src directory
Fichier Makefile.am
/tmp/autohello/src : cat Makefile.am
bin_PROGRAMS = autohello
autohello_SOURCES = autohello.c
CLEANFILES = *~
AM_CPPFLAGS = ­D_GNU_SOURCE
AM_CFLAGS = ­Wall ­Werror
Autotools - 16 Juin 2015 38
www.ciose.fr
Autohello : src directory
Fichier Makefile.am
/tmp/autohello/src : cat Makefile.am
bin_PROGRAMS = autohello
autohello_SOURCES = autohello.c
CLEANFILES = *~
AM_CPPFLAGS = ­D_GNU_SOURCE
AM_CFLAGS = ­Wall ­Werror
Programme(s) à
installer dans $bindir
Autotools - 16 Juin 2015 39
www.ciose.fr
Autohello : src directory
Fichier Makefile.am
/tmp/autohello/src : cat Makefile.am
bin_PROGRAMS = autohello
autohello_SOURCES = autohello.c
CLEANFILES = *~
AM_CPPFLAGS = ­D_GNU_SOURCE
AM_CFLAGS = ­Wall ­Werror
Source(s) associé(s)
au(x)
programme(s)
Autotools - 16 Juin 2015 40
www.ciose.fr
Autohello : src directory
Fichier Makefile.am
/tmp/autohello/src : cat Makefile.am
bin_PROGRAMS = autohello
autohello_SOURCES = autohello.c
CLEANFILES = *~
AM_CPPFLAGS = ­D_GNU_SOURCE
AM_CFLAGS = ­Wall ­Werror
Fichiers additionnels
pour cibles de
nettoyage
Autotools - 16 Juin 2015 41
www.ciose.fr
Autohello : src directory
Fichier Makefile.am
/tmp/autohello/src : cat Makefile.am
bin_PROGRAMS = autohello
autohello_SOURCES = autohello.c
CLEANFILES = *~
AM_CPPFLAGS = ­D_GNU_SOURCE
AM_CFLAGS = ­Wall ­Werror
Flags additionnels
passés au préprocesseur
Autotools - 16 Juin 2015 42
www.ciose.fr
Autohello : src directory
Fichier Makefile.am
/tmp/autohello/src : cat Makefile.am
bin_PROGRAMS = autohello
autohello_SOURCES = autohello.c
CLEANFILES = *~
AM_CPPFLAGS = ­D_GNU_SOURCE
AM_CFLAGS = ­Wall ­Werror
Flags additionnels
passés au compilateur
Autotools - 16 Juin 2015 43
www.ciose.fr
Ajout option configuration
Ajout d'une option de configuration pour utiliser
gcc ou colorgcc
cat configure.ac
# Checks for programs.
AC_PROG_CC
# compiler option (gcc or colorgcc)
AC_ARG_ENABLE(colorgcc,
  AS_HELP_STRING([­­enable­colorgcc],
    [enable compiling with colorgcc]),
    [use_colorgcc=$enableval], [use_colorgcc=no])
if test "x$use_colorgcc" = "xyes"; then
    # we need colorgcc:
    AC_CHECK_PROG([COLORGCC], [colorgcc], [yes], [no])
    if test "$COLORGCC" == "yes"; then
        AC_MSG_NOTICE([Compiling using colorgcc])
        CC=colorgcc
    else
        AC_MSG_ERROR([colorgcc not found])
    fi
fi
Autotools - 16 Juin 2015 44
www.ciose.fr
Utilisation option
configuration
./configure –help
Optional Features:
  ­­disable­option­checking  ignore unrecognized 
­­enable/­­with options
  ­­disable­FEATURE       do not include FEATURE 
(same as ­­enable­FEATURE=no)
  ­­enable­FEATURE[=ARG]  include FEATURE [ARG=yes]
  ­­enable­silent­rules   less verbose build output 
(undo: "make V=1")
  ­­disable­silent­rules  verbose build output (undo: 
"make V=0")
  ­­enable­dependency­tracking
                          do not reject slow 
dependency extractors
  ­­disable­dependency­tracking
                          speeds up one­time build
  ­­enable­colorgcc       enable compiling with 
colorgcc
Autotools - 16 Juin 2015 45
www.ciose.fr
Utilisation option
configuration
Par défaut ./configure n'utilise pas colorgcc
Utilisation avec l'option –enable­colorgcc
./configure –enable­colorgcc
…
checking dependency style of gcc... gcc3
checking for colorgcc... yes
configure: Compiling using colorgcc
checking how to run the C preprocessor... colorgcc ­E
checking for grep that handles long lines and 
­e... /bin/grep
…
make
…
colorgcc ­DHAVE_CONFIG_H ­I. ­I..  ­D_GNU_SOURCE  
­Wall ­Werror ­g ­O2 ­MT autohello.o ­MD ­MP ­MF 
.deps/autohello.Tpo ­c ­o autohello.o autohello.c
Autotools - 16 Juin 2015 46
www.ciose.fr
Configuration librairie
Utilisation conditionnelle de la librairie glib
cat configure.ac
# Checks for header files.
AC_CHECK_HEADERS([stdio.h stdlib.h])
# Check for libraries.
PKG_CHECK_MODULES([glib], [glib­2.0 >= 2.40.0],
[AC_DEFINE([HAVE_GLIB], [1], [Use Glib])])
CPPFLAGS="$glib_CFLAGS"
LDADD="$glib_LIBS"
AC_SUBST([CPPFLAGS])
AC_SUBST([LDADD])
Recherche glib-2.0 >= 2.40.0
Définition constante HAVE_GLIB
dans config.h
Définition CPPFLAGS et LDADD
en fonction présence
Glib-2.0
Autotools - 16 Juin 2015 47
www.ciose.fr
Configuration librairie
cat src/autohello.c
#include "_build­date.h"
#ifdef HAVE_GLIB
#include <glib.h>
#endif
int main(int argc, char **argv)
{
#ifdef HAVE_GLIB
GString *text;
text=g_string_new("");
g_string_printf(text, "Hello world version %s built 
on %sn",
AUTOHELLO_VERSION_STRING, _BUILD_DATE);
printf("%s", (char*)(text­>str));
#else
Inclusion conditionnelle
Code si glib-2.0 disponible
Autotools - 16 Juin 2015 48
www.ciose.fr
Configuration librairie
#else
    printf("Hello world version %s built on %sn",
    AUTOHELLO_VERSION_STRING, _BUILD_DATE);
#endif
exit(0);
}
Code si glib-2.0 non disponible
Autotools - 16 Juin 2015 49
www.ciose.fr
Créer une archive
distribuable
Cibles dédiées à la distribution : dist­xxx, xxx
formats de compression variés
make dist­bzip2
…
ls *.tar.*
autohello­1.0.2.tar.bz2

More Related Content

What's hot

Conférence Shinken à SophiaConf2012 (Jean Gabès)
Conférence Shinken à SophiaConf2012 (Jean Gabès)Conférence Shinken à SophiaConf2012 (Jean Gabès)
Conférence Shinken à SophiaConf2012 (Jean Gabès)Jean Gabès
 
Concevoir un système Linux embarqué avec Yocto Project - Version révisée
Concevoir un système Linux embarqué avec Yocto Project - Version réviséeConcevoir un système Linux embarqué avec Yocto Project - Version révisée
Concevoir un système Linux embarqué avec Yocto Project - Version réviséeChristian Charreyre
 
Barre pour développeur Firefox et Eclipse
Barre pour développeur Firefox et EclipseBarre pour développeur Firefox et Eclipse
Barre pour développeur Firefox et EclipseYannick Pavard
 
Open Embedded un framework libre pour assurer la cohérence de son projet
Open Embedded un framework libre pour assurer la cohérence de son projetOpen Embedded un framework libre pour assurer la cohérence de son projet
Open Embedded un framework libre pour assurer la cohérence de son projetChristian Charreyre
 
Distro Recipes 2013 : Yocto / OpenEmbedded
Distro Recipes 2013 : Yocto / OpenEmbeddedDistro Recipes 2013 : Yocto / OpenEmbedded
Distro Recipes 2013 : Yocto / OpenEmbeddedAnne Nicolas
 
Séminaire Captronic Yocto 24 février 2015
Séminaire Captronic Yocto 24 février 2015Séminaire Captronic Yocto 24 février 2015
Séminaire Captronic Yocto 24 février 2015Christian Charreyre
 
Concevoir un système Linux embarqué avec Yocto Project
Concevoir un système Linux embarqué avec Yocto ProjectConcevoir un système Linux embarqué avec Yocto Project
Concevoir un système Linux embarqué avec Yocto ProjectChristian Charreyre
 
Open Wide : Les outils pour le développement des systemes embarques
Open Wide : Les outils pour le développement des systemes embarquesOpen Wide : Les outils pour le développement des systemes embarques
Open Wide : Les outils pour le développement des systemes embarquesAlexandre LAHAYE
 
Conference Informatique Embarquée Synergie-NTIC
Conference Informatique Embarquée Synergie-NTICConference Informatique Embarquée Synergie-NTIC
Conference Informatique Embarquée Synergie-NTICChristian Charreyre
 
Créer sa distribution Linux embarqué avec Yocto ou Angström
Créer sa distribution Linux embarqué avec Yocto ou AngströmCréer sa distribution Linux embarqué avec Yocto ou Angström
Créer sa distribution Linux embarqué avec Yocto ou AngströmChristian Charreyre
 
Strategie de Virtualisation Open Source
Strategie de Virtualisation Open SourceStrategie de Virtualisation Open Source
Strategie de Virtualisation Open SourceOpen Source School
 
Open Wide : les licences libres.
Open Wide : les licences libres. Open Wide : les licences libres.
Open Wide : les licences libres. Alexandre LAHAYE
 
Logiciel Libre - Hedi Magroun - AUF - 2008
Logiciel Libre - Hedi Magroun - AUF - 2008Logiciel Libre - Hedi Magroun - AUF - 2008
Logiciel Libre - Hedi Magroun - AUF - 2008Hedi Magroun
 
Petit Déjeuner Git chez Makina Corpus
Petit Déjeuner Git chez Makina CorpusPetit Déjeuner Git chez Makina Corpus
Petit Déjeuner Git chez Makina Corpusleplatrem
 
Linux - Hedi Magroun - AUF - 2008
Linux -  Hedi Magroun - AUF - 2008Linux -  Hedi Magroun - AUF - 2008
Linux - Hedi Magroun - AUF - 2008Hedi Magroun
 
Présentation de la pile réseau sous gnu linux
Présentation de la pile réseau sous gnu linuxPrésentation de la pile réseau sous gnu linux
Présentation de la pile réseau sous gnu linuxThierry Gayet
 
Présentation Git & GitHub
Présentation Git & GitHubPrésentation Git & GitHub
Présentation Git & GitHubThibault Vlacich
 

What's hot (20)

Conférence Shinken à SophiaConf2012 (Jean Gabès)
Conférence Shinken à SophiaConf2012 (Jean Gabès)Conférence Shinken à SophiaConf2012 (Jean Gabès)
Conférence Shinken à SophiaConf2012 (Jean Gabès)
 
Concevoir un système Linux embarqué avec Yocto Project - Version révisée
Concevoir un système Linux embarqué avec Yocto Project - Version réviséeConcevoir un système Linux embarqué avec Yocto Project - Version révisée
Concevoir un système Linux embarqué avec Yocto Project - Version révisée
 
Barre pour développeur Firefox et Eclipse
Barre pour développeur Firefox et EclipseBarre pour développeur Firefox et Eclipse
Barre pour développeur Firefox et Eclipse
 
Open Embedded un framework libre pour assurer la cohérence de son projet
Open Embedded un framework libre pour assurer la cohérence de son projetOpen Embedded un framework libre pour assurer la cohérence de son projet
Open Embedded un framework libre pour assurer la cohérence de son projet
 
Distro Recipes 2013 : Yocto / OpenEmbedded
Distro Recipes 2013 : Yocto / OpenEmbeddedDistro Recipes 2013 : Yocto / OpenEmbedded
Distro Recipes 2013 : Yocto / OpenEmbedded
 
Séminaire Captronic Yocto 24 février 2015
Séminaire Captronic Yocto 24 février 2015Séminaire Captronic Yocto 24 février 2015
Séminaire Captronic Yocto 24 février 2015
 
Concevoir un système Linux embarqué avec Yocto Project
Concevoir un système Linux embarqué avec Yocto ProjectConcevoir un système Linux embarqué avec Yocto Project
Concevoir un système Linux embarqué avec Yocto Project
 
Open Wide : Les outils pour le développement des systemes embarques
Open Wide : Les outils pour le développement des systemes embarquesOpen Wide : Les outils pour le développement des systemes embarques
Open Wide : Les outils pour le développement des systemes embarques
 
Conference Informatique Embarquée Synergie-NTIC
Conference Informatique Embarquée Synergie-NTICConference Informatique Embarquée Synergie-NTIC
Conference Informatique Embarquée Synergie-NTIC
 
Créer sa distribution Linux embarqué avec Yocto ou Angström
Créer sa distribution Linux embarqué avec Yocto ou AngströmCréer sa distribution Linux embarqué avec Yocto ou Angström
Créer sa distribution Linux embarqué avec Yocto ou Angström
 
PHP & Initiation Symfony
PHP & Initiation SymfonyPHP & Initiation Symfony
PHP & Initiation Symfony
 
Strategie de Virtualisation Open Source
Strategie de Virtualisation Open SourceStrategie de Virtualisation Open Source
Strategie de Virtualisation Open Source
 
Open Wide : les licences libres.
Open Wide : les licences libres. Open Wide : les licences libres.
Open Wide : les licences libres.
 
Logiciel Libre - Hedi Magroun - AUF - 2008
Logiciel Libre - Hedi Magroun - AUF - 2008Logiciel Libre - Hedi Magroun - AUF - 2008
Logiciel Libre - Hedi Magroun - AUF - 2008
 
Petit Déjeuner Git chez Makina Corpus
Petit Déjeuner Git chez Makina CorpusPetit Déjeuner Git chez Makina Corpus
Petit Déjeuner Git chez Makina Corpus
 
Install party
Install partyInstall party
Install party
 
Linux - Hedi Magroun - AUF - 2008
Linux -  Hedi Magroun - AUF - 2008Linux -  Hedi Magroun - AUF - 2008
Linux - Hedi Magroun - AUF - 2008
 
Présentation de la pile réseau sous gnu linux
Présentation de la pile réseau sous gnu linuxPrésentation de la pile réseau sous gnu linux
Présentation de la pile réseau sous gnu linux
 
Les logiciels libres
Les logiciels libresLes logiciels libres
Les logiciels libres
 
Présentation Git & GitHub
Présentation Git & GitHubPrésentation Git & GitHub
Présentation Git & GitHub
 

Viewers also liked

Don't Fear the Autotools
Don't Fear the AutotoolsDon't Fear the Autotools
Don't Fear the AutotoolsScott Garman
 
GNU Autotools - Automake and Autoconf
GNU Autotools - Automake and AutoconfGNU Autotools - Automake and Autoconf
GNU Autotools - Automake and AutoconfAvneet Kaur
 
ERTS 2008 - Using Linux for industrial projects
ERTS 2008 - Using Linux for industrial projectsERTS 2008 - Using Linux for industrial projects
ERTS 2008 - Using Linux for industrial projectsChristian Charreyre
 
Comment travailler avec les logiciels Open Source
Comment travailler avec les logiciels Open SourceComment travailler avec les logiciels Open Source
Comment travailler avec les logiciels Open SourceChristian Charreyre
 
ERTS 2008 - Using Linux for industrial projects
ERTS 2008 - Using Linux for industrial projectsERTS 2008 - Using Linux for industrial projects
ERTS 2008 - Using Linux for industrial projectsChristian Charreyre
 
BibBase Linked Data Triplification Challenge 2010 Presentation
BibBase Linked Data Triplification Challenge 2010 PresentationBibBase Linked Data Triplification Challenge 2010 Presentation
BibBase Linked Data Triplification Challenge 2010 PresentationReynold Xin
 
Using heka
Using hekaUsing heka
Using hekaExotel
 
Python Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & stylePython Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & styleKevlin Henney
 
Making Steaks from Sacred Cows
Making Steaks from Sacred CowsMaking Steaks from Sacred Cows
Making Steaks from Sacred CowsKevlin Henney
 
Logiciels libres en milieu industriel
Logiciels libres en milieu industrielLogiciels libres en milieu industriel
Logiciels libres en milieu industrielChristian Charreyre
 
The Architecture of Uncertainty
The Architecture of UncertaintyThe Architecture of Uncertainty
The Architecture of UncertaintyKevlin Henney
 
#Gophercon Talk by Smita Vijayakumar - Go's Context Library
#Gophercon Talk by Smita Vijayakumar - Go's Context Library#Gophercon Talk by Smita Vijayakumar - Go's Context Library
#Gophercon Talk by Smita Vijayakumar - Go's Context LibraryExotel
 
Linux et le temps réel - Meetup du 15 octobre 2015
Linux et le temps réel - Meetup du 15 octobre 2015Linux et le temps réel - Meetup du 15 octobre 2015
Linux et le temps réel - Meetup du 15 octobre 2015Christian Charreyre
 
Working at Exotel
Working at ExotelWorking at Exotel
Working at ExotelExotel
 
Contrat 2010-2013 Scduag
Contrat 2010-2013 ScduagContrat 2010-2013 Scduag
Contrat 2010-2013 Scduagscduag
 
Setting A Culture of Technical Excellence
Setting A Culture of Technical ExcellenceSetting A Culture of Technical Excellence
Setting A Culture of Technical ExcellenceExotel
 
Exotel For Last Mile Logistics
Exotel For Last Mile LogisticsExotel For Last Mile Logistics
Exotel For Last Mile LogisticsExotel
 
Stanford CS347 Guest Lecture: Apache Spark
Stanford CS347 Guest Lecture: Apache SparkStanford CS347 Guest Lecture: Apache Spark
Stanford CS347 Guest Lecture: Apache SparkReynold Xin
 
(Berkeley CS186 guest lecture) Big Data Analytics Systems: What Goes Around C...
(Berkeley CS186 guest lecture) Big Data Analytics Systems: What Goes Around C...(Berkeley CS186 guest lecture) Big Data Analytics Systems: What Goes Around C...
(Berkeley CS186 guest lecture) Big Data Analytics Systems: What Goes Around C...Reynold Xin
 
Cloud Communication for E-commerce & Last Mile Logistics
Cloud Communication for E-commerce & Last Mile LogisticsCloud Communication for E-commerce & Last Mile Logistics
Cloud Communication for E-commerce & Last Mile LogisticsExotel
 

Viewers also liked (20)

Don't Fear the Autotools
Don't Fear the AutotoolsDon't Fear the Autotools
Don't Fear the Autotools
 
GNU Autotools - Automake and Autoconf
GNU Autotools - Automake and AutoconfGNU Autotools - Automake and Autoconf
GNU Autotools - Automake and Autoconf
 
ERTS 2008 - Using Linux for industrial projects
ERTS 2008 - Using Linux for industrial projectsERTS 2008 - Using Linux for industrial projects
ERTS 2008 - Using Linux for industrial projects
 
Comment travailler avec les logiciels Open Source
Comment travailler avec les logiciels Open SourceComment travailler avec les logiciels Open Source
Comment travailler avec les logiciels Open Source
 
ERTS 2008 - Using Linux for industrial projects
ERTS 2008 - Using Linux for industrial projectsERTS 2008 - Using Linux for industrial projects
ERTS 2008 - Using Linux for industrial projects
 
BibBase Linked Data Triplification Challenge 2010 Presentation
BibBase Linked Data Triplification Challenge 2010 PresentationBibBase Linked Data Triplification Challenge 2010 Presentation
BibBase Linked Data Triplification Challenge 2010 Presentation
 
Using heka
Using hekaUsing heka
Using heka
 
Python Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & stylePython Foundation – A programmer's introduction to Python concepts & style
Python Foundation – A programmer's introduction to Python concepts & style
 
Making Steaks from Sacred Cows
Making Steaks from Sacred CowsMaking Steaks from Sacred Cows
Making Steaks from Sacred Cows
 
Logiciels libres en milieu industriel
Logiciels libres en milieu industrielLogiciels libres en milieu industriel
Logiciels libres en milieu industriel
 
The Architecture of Uncertainty
The Architecture of UncertaintyThe Architecture of Uncertainty
The Architecture of Uncertainty
 
#Gophercon Talk by Smita Vijayakumar - Go's Context Library
#Gophercon Talk by Smita Vijayakumar - Go's Context Library#Gophercon Talk by Smita Vijayakumar - Go's Context Library
#Gophercon Talk by Smita Vijayakumar - Go's Context Library
 
Linux et le temps réel - Meetup du 15 octobre 2015
Linux et le temps réel - Meetup du 15 octobre 2015Linux et le temps réel - Meetup du 15 octobre 2015
Linux et le temps réel - Meetup du 15 octobre 2015
 
Working at Exotel
Working at ExotelWorking at Exotel
Working at Exotel
 
Contrat 2010-2013 Scduag
Contrat 2010-2013 ScduagContrat 2010-2013 Scduag
Contrat 2010-2013 Scduag
 
Setting A Culture of Technical Excellence
Setting A Culture of Technical ExcellenceSetting A Culture of Technical Excellence
Setting A Culture of Technical Excellence
 
Exotel For Last Mile Logistics
Exotel For Last Mile LogisticsExotel For Last Mile Logistics
Exotel For Last Mile Logistics
 
Stanford CS347 Guest Lecture: Apache Spark
Stanford CS347 Guest Lecture: Apache SparkStanford CS347 Guest Lecture: Apache Spark
Stanford CS347 Guest Lecture: Apache Spark
 
(Berkeley CS186 guest lecture) Big Data Analytics Systems: What Goes Around C...
(Berkeley CS186 guest lecture) Big Data Analytics Systems: What Goes Around C...(Berkeley CS186 guest lecture) Big Data Analytics Systems: What Goes Around C...
(Berkeley CS186 guest lecture) Big Data Analytics Systems: What Goes Around C...
 
Cloud Communication for E-commerce & Last Mile Logistics
Cloud Communication for E-commerce & Last Mile LogisticsCloud Communication for E-commerce & Last Mile Logistics
Cloud Communication for E-commerce & Last Mile Logistics
 

Similar to Autotools

Symfony 2 : chapitre 1 - Présentation Générale
Symfony 2 : chapitre 1 - Présentation GénéraleSymfony 2 : chapitre 1 - Présentation Générale
Symfony 2 : chapitre 1 - Présentation GénéraleAbdelkader Rhouati
 
Industrialisation bar camp2010
Industrialisation bar camp2010Industrialisation bar camp2010
Industrialisation bar camp2010Lushkah911
 
Atelier Symfony2- Introduction
Atelier Symfony2- IntroductionAtelier Symfony2- Introduction
Atelier Symfony2- IntroductionMarwa OUNALLI
 
Presentation Symfony2
Presentation Symfony2Presentation Symfony2
Presentation Symfony2Ahmed ABATAL
 
Connected Developper Ep6 (25-05-2013)
Connected Developper Ep6 (25-05-2013)Connected Developper Ep6 (25-05-2013)
Connected Developper Ep6 (25-05-2013)Badr Hakkari
 
Outils de construction pour la recherche
Outils de construction pour la rechercheOutils de construction pour la recherche
Outils de construction pour la rechercheJohan Moreau
 
Python et son intégration avec Odoo
Python et son intégration avec OdooPython et son intégration avec Odoo
Python et son intégration avec OdooHassan WAHSISS
 
Introduction aux logiciels libres et à Linux
Introduction aux logiciels libres et à LinuxIntroduction aux logiciels libres et à Linux
Introduction aux logiciels libres et à LinuxBruno Cornec
 
Créez vos propres plugins qgis
Créez vos propres plugins qgisCréez vos propres plugins qgis
Créez vos propres plugins qgisGildas MFOUMBI
 
Musique : bien se servir des outils web - liste url
Musique : bien se servir des outils web - liste urlMusique : bien se servir des outils web - liste url
Musique : bien se servir des outils web - liste urlaf83media
 
Niji_Rapport prévention_2023.pptx
Niji_Rapport prévention_2023.pptxNiji_Rapport prévention_2023.pptx
Niji_Rapport prévention_2023.pptxGabriel DUPONT
 
Utiliser les licences libres dans le cadre d'un projet éditorial : quels cont...
Utiliser les licences libres dans le cadre d'un projet éditorial : quels cont...Utiliser les licences libres dans le cadre d'un projet éditorial : quels cont...
Utiliser les licences libres dans le cadre d'un projet éditorial : quels cont...Calimaq S.I.Lex
 
Android workshop - Bootcamp du Mauriapp Challenge 2016
Android workshop - Bootcamp du Mauriapp Challenge 2016Android workshop - Bootcamp du Mauriapp Challenge 2016
Android workshop - Bootcamp du Mauriapp Challenge 2016Hadina RIMTIC
 
« LabVIEW : programmation et applications » ou comment apprendre à utiliser L...
« LabVIEW : programmation et applications » ou comment apprendre à utiliser L...« LabVIEW : programmation et applications » ou comment apprendre à utiliser L...
« LabVIEW : programmation et applications » ou comment apprendre à utiliser L...Luc Desruelle
 
Guide pratique des logiciels libres dans les administrations
Guide pratique des logiciels libres dans les administrationsGuide pratique des logiciels libres dans les administrations
Guide pratique des logiciels libres dans les administrationsParis, France
 
Administration et logiciel libre - Guide pour les marchés publics
Administration et logiciel libre - Guide pour les marchés publicsAdministration et logiciel libre - Guide pour les marchés publics
Administration et logiciel libre - Guide pour les marchés publicsAPIE_gouv
 

Similar to Autotools (20)

Symfony 2 : chapitre 1 - Présentation Générale
Symfony 2 : chapitre 1 - Présentation GénéraleSymfony 2 : chapitre 1 - Présentation Générale
Symfony 2 : chapitre 1 - Présentation Générale
 
Industrialisation bar camp2010
Industrialisation bar camp2010Industrialisation bar camp2010
Industrialisation bar camp2010
 
Atelier Symfony2- Introduction
Atelier Symfony2- IntroductionAtelier Symfony2- Introduction
Atelier Symfony2- Introduction
 
Presentation Symfony2
Presentation Symfony2Presentation Symfony2
Presentation Symfony2
 
Hady bah l3
Hady bah l3Hady bah l3
Hady bah l3
 
Connected Developper Ep6 (25-05-2013)
Connected Developper Ep6 (25-05-2013)Connected Developper Ep6 (25-05-2013)
Connected Developper Ep6 (25-05-2013)
 
Outils de construction pour la recherche
Outils de construction pour la rechercheOutils de construction pour la recherche
Outils de construction pour la recherche
 
titre
titretitre
titre
 
Python et son intégration avec Odoo
Python et son intégration avec OdooPython et son intégration avec Odoo
Python et son intégration avec Odoo
 
Introduction aux logiciels libres et à Linux
Introduction aux logiciels libres et à LinuxIntroduction aux logiciels libres et à Linux
Introduction aux logiciels libres et à Linux
 
Créez vos propres plugins qgis
Créez vos propres plugins qgisCréez vos propres plugins qgis
Créez vos propres plugins qgis
 
test
testtest
test
 
« Creative Commons » Fiche pratique
« Creative Commons » Fiche pratique« Creative Commons » Fiche pratique
« Creative Commons » Fiche pratique
 
Musique : bien se servir des outils web - liste url
Musique : bien se servir des outils web - liste urlMusique : bien se servir des outils web - liste url
Musique : bien se servir des outils web - liste url
 
Niji_Rapport prévention_2023.pptx
Niji_Rapport prévention_2023.pptxNiji_Rapport prévention_2023.pptx
Niji_Rapport prévention_2023.pptx
 
Utiliser les licences libres dans le cadre d'un projet éditorial : quels cont...
Utiliser les licences libres dans le cadre d'un projet éditorial : quels cont...Utiliser les licences libres dans le cadre d'un projet éditorial : quels cont...
Utiliser les licences libres dans le cadre d'un projet éditorial : quels cont...
 
Android workshop - Bootcamp du Mauriapp Challenge 2016
Android workshop - Bootcamp du Mauriapp Challenge 2016Android workshop - Bootcamp du Mauriapp Challenge 2016
Android workshop - Bootcamp du Mauriapp Challenge 2016
 
« LabVIEW : programmation et applications » ou comment apprendre à utiliser L...
« LabVIEW : programmation et applications » ou comment apprendre à utiliser L...« LabVIEW : programmation et applications » ou comment apprendre à utiliser L...
« LabVIEW : programmation et applications » ou comment apprendre à utiliser L...
 
Guide pratique des logiciels libres dans les administrations
Guide pratique des logiciels libres dans les administrationsGuide pratique des logiciels libres dans les administrations
Guide pratique des logiciels libres dans les administrations
 
Administration et logiciel libre - Guide pour les marchés publics
Administration et logiciel libre - Guide pour les marchés publicsAdministration et logiciel libre - Guide pour les marchés publics
Administration et logiciel libre - Guide pour les marchés publics
 

Autotools

  • 1. Autotools - 16 Juin 2015 1 www.ciose.fr AutotoolsAutotools C. CharreyreC. Charreyre christian.charreyre@ciose.frchristian.charreyre@ciose.fr http://www.ciose.frhttp://www.ciose.fr @CIOinfoindus@CIOinfoindus
  • 2. Autotools - 16 Juin 2015 2 www.ciose.fr Licence Attribution-Noncommercial-Share Alike 4.0 International You are free: to Share - copy and redistribute the material in any medium or format to Adapt - remix, transform, and build upon the material The licensor cannot revoke these freedoms as long as you follow the license terms. Under the following conditions: Attribution — You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use. NonCommercial — You may not use the material for commercial purposes. ShareAlike — If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original. No additional restrictions — You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits. License text : http://creativecommons.org/licenses/by-nc-sa/4.0/legalcode
  • 3. Autotools - 16 Juin 2015 3 www.ciose.fr Crédits Document utilisé pour bâtir cette présentation : Using GNU Autotools – Alexandre Duret-Lutz – 16 Mai 2010
  • 4. Autotools - 16 Juin 2015 4 www.ciose.fr CIO en quelques mots Société d'ingénierie en systèmes embarqués : électronique et logiciel Au service de nos clients depuis 1990 15 spécialistes en embarqué et temps réel Expert en Linux embarqué depuis 2000, OpenEmbedded et Yocto depuis 2008 CA annuel : 1 500 000 € Siège à Saint-Etienne Agence à Marseille Agréé CIR
  • 5. Autotools - 16 Juin 2015 5 www.ciose.fr C. Charreyre en quelques mots Associé au sein de CIO Responsable des technologies Linux embarqué Formateur Linux embarqué (avec Captronic et en direct) 30 ans dans l'embarqué et le monde Unix / Linux Fervent promoteur du logiciel libre Membre de Medinsoft – Commission Logiciel Libre
  • 6. Autotools - 16 Juin 2015 6 www.ciose.fr Pourquoi les Autotools ? Dans l'univers du libre, on distribue le code source C'est l'utilisateur qui compile le code Mais l'utilisateur n'a pas forcément le même environnement logiciel que le développeur  Nécessité de sources portables Nécessité d'un système de build adaptatif Autotools = système de génération de Makefiles adaptés à l'environnement logiciel de l'utilisateur, bâtis dynamiquement avant compilation Utile dans le cas de l'embarqué : ressources logicielles réduites, développement croisé ….
  • 7. Autotools - 16 Juin 2015 7 www.ciose.fr Les rôles L'utilisateur final : Extrait, configure, compile et installe le logiciel tar xzvf prog.tar.gz, ./configure,  make, sudo make install Le développeur Fournit un système de configuration dynamique des Makefiles (en particulier flags compilateur et linker) Fournit des contrôles de prérequis logiciel lors de la phase de configuration Écrit ses sources de manière portable avec des compilations conditionnelles dépendant des résultats de configuration dynamique Fonction présente ou pas Signatures fonction variable Fichiers d'include variables …. Options activées ou pas
  • 8. Autotools - 16 Juin 2015 8 www.ciose.fr Les rôles Le développeur est utilisateur final sur son poste de développement lorsqu'il exécute pour lui même ./configure, make, sudo make install
  • 9. Autotools - 16 Juin 2015 9 www.ciose.fr Autoconf Couvre les utilitaires autoconf,  autoheader, autoscan, autoreconf,  autoupdate Fonction principale : Créer configure et config.h.in à partir de configure.ac configure.ac écrit par le développeur configure généré par autoconf – shell script de configuration lancé avant compilation. Assure la configuration dynamique de la chaîne de compilation. config.h.in généré par autoheader – template de fichier d'include pour les compilations conditionnelles liés au résultat de configuration. Permet la portabilité des sources
  • 10. Autotools - 16 Juin 2015 10 www.ciose.fr Autoconf Autres fonctions : autoscan crée un 1er template de fichier configure.ac nommé configure.scan, par analyse du répertoire de travail autoreconf appelle les divers outils en séquence, dans le bon ordre – à utiliser au tout début autoupdate actualise configure.ac en cas de changement de version autoconf exécuté par le développeur
  • 11. Autotools - 16 Juin 2015 11 www.ciose.fr Automake Couvre les utilitaires automake, aclocal Fonction principale : Créer le(s) fichier(s) Makefile.in à partir du(des) template(s) Makefile.am Autres fonctions : aclocal crée le fichier aclocal.m4 (macros en langage m4) à partir de configure.ac automake exécuté par le développeur.
  • 12. Autotools - 16 Juin 2015 12 www.ciose.fr configure configure crée le fichier config.h et le(s) fichier(s) Makefile à partir de config.h.in et Makefile.in configure est exécuté par l'utilisateur final
  • 13. Autotools - 16 Juin 2015 13 www.ciose.fr Récapitulatif Crédit : Using GNU Autotools – Alexandre Duret-Lutz Actions développeur
  • 14. Autotools - 16 Juin 2015 14 www.ciose.fr Récapitulatif Actions utilisateur final
  • 15. Autotools - 16 Juin 2015 15 www.ciose.fr Un exemple : autohello Création d'un programme Hello World basé autotools Structure standard : Répertoire autohello comprend configure.ac et Makefile.am Sources dans un sous répertoire src
  • 16. Autotools - 16 Juin 2015 16 www.ciose.fr Autohello : top level directory Fichier Makefile.am /tmp/autohello : cat Makefile.am SUBDIRS = src Chaînage vers le répertoire src
  • 17. Autotools - 16 Juin 2015 17 www.ciose.fr Autohello : top level directory Fichier configure.ac /tmp/autohello : cat configure.ac # ­*­ Autoconf ­*­ # Process this file with autoconf to produce a  configure script. # Define version major, minor and micro number m4_define([autohello_version_major], [1]) m4_define([autohello_version_minor], [0]) m4_define([autohello_version_micro], [0]) m4_define([autohello_version],         [autohello_version_major.autohello_version_minor. autohello_version_micro]) Définition des éléments de version
  • 18. Autotools - 16 Juin 2015 18 www.ciose.fr Autohello : top level directory Fichier configure.ac (continued) AC_PREREQ([2.63]) AC_INIT([autohello], [autohello_version],  [christian.charreyre@ciose.fr]) AC_CONFIG_SRCDIR([src/autohello.c]) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([foreign]) AUTOHELLO_VERSION_MAJOR=autohello_version_major AUTOHELLO_VERSION_MINOR=autohello_version_minor AUTOHELLO_VERSION_MICRO=autohello_version_micro AUTOHELLO_VERSION=autohello_version AC_SUBST(AUTOHELLO_VERSION_MAJOR) AC_SUBST(AUTOHELLO_VERSION_MINOR) AC_SUBST(AUTOHELLO_VERSION_MICRO) AC_SUBST(AUTOHELLO_VERSION)
  • 19. Autotools - 16 Juin 2015 19 www.ciose.fr Autohello : top level directory Fichier configure.ac (continued) AC_PREREQ([2.63]) AC_INIT([autohello], [autohello_version],  [christian.charreyre@ciose.fr]) AC_CONFIG_SRCDIR([src/autohello.c]) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([foreign]) AUTOHELLO_VERSION_MAJOR=autohello_version_major AUTOHELLO_VERSION_MINOR=autohello_version_minor AUTOHELLO_VERSION_MICRO=autohello_version_micro AUTOHELLO_VERSION=autohello_version AC_SUBST(AUTOHELLO_VERSION_MAJOR) AC_SUBST(AUTOHELLO_VERSION_MINOR) AC_SUBST(AUTOHELLO_VERSION_MICRO) AC_SUBST(AUTOHELLO_VERSION) Version minimale d'autoconf requise
  • 20. Autotools - 16 Juin 2015 20 www.ciose.fr Autohello : top level directory Fichier configure.ac (continued) AC_PREREQ([2.63]) AC_INIT([autohello], [autohello_version],  [christian.charreyre@ciose.fr]) AC_CONFIG_SRCDIR([src/autohello.c]) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([foreign]) AUTOHELLO_VERSION_MAJOR=autohello_version_major AUTOHELLO_VERSION_MINOR=autohello_version_minor AUTOHELLO_VERSION_MICRO=autohello_version_micro AUTOHELLO_VERSION=autohello_version AC_SUBST(AUTOHELLO_VERSION_MAJOR) AC_SUBST(AUTOHELLO_VERSION_MINOR) AC_SUBST(AUTOHELLO_VERSION_MICRO) AC_SUBST(AUTOHELLO_VERSION) Initialisation Paramètres : Nom package, Version, Adresse mainteneur
  • 21. Autotools - 16 Juin 2015 21 www.ciose.fr Autohello : top level directory Fichier configure.ac (continued) AC_PREREQ([2.63]) AC_INIT([autohello], [autohello_version],  [christian.charreyre@ciose.fr]) AC_CONFIG_SRCDIR([src/autohello.c]) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([foreign]) AUTOHELLO_VERSION_MAJOR=autohello_version_major AUTOHELLO_VERSION_MINOR=autohello_version_minor AUTOHELLO_VERSION_MICRO=autohello_version_micro AUTOHELLO_VERSION=autohello_version AC_SUBST(AUTOHELLO_VERSION_MAJOR) AC_SUBST(AUTOHELLO_VERSION_MINOR) AC_SUBST(AUTOHELLO_VERSION_MICRO) AC_SUBST(AUTOHELLO_VERSION) Définition répertoire sources
  • 22. Autotools - 16 Juin 2015 22 www.ciose.fr Autohello : top level directory Fichier configure.ac (continued) AC_PREREQ([2.63]) AC_INIT([autohello], [autohello_version],  [christian.charreyre@ciose.fr]) AC_CONFIG_SRCDIR([src/autohello.c]) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([foreign]) AUTOHELLO_VERSION_MAJOR=autohello_version_major AUTOHELLO_VERSION_MINOR=autohello_version_minor AUTOHELLO_VERSION_MICRO=autohello_version_micro AUTOHELLO_VERSION=autohello_version AC_SUBST(AUTOHELLO_VERSION_MAJOR) AC_SUBST(AUTOHELLO_VERSION_MINOR) AC_SUBST(AUTOHELLO_VERSION_MICRO) AC_SUBST(AUTOHELLO_VERSION) Demande création automatique header config.h
  • 23. Autotools - 16 Juin 2015 23 www.ciose.fr Autohello : top level directory Fichier configure.ac (continued) AC_PREREQ([2.63]) AC_INIT([autohello], [autohello_version],  [christian.charreyre@ciose.fr]) AC_CONFIG_SRCDIR([src/autohello.c]) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([foreign]) AUTOHELLO_VERSION_MAJOR=autohello_version_major AUTOHELLO_VERSION_MINOR=autohello_version_minor AUTOHELLO_VERSION_MICRO=autohello_version_micro AUTOHELLO_VERSION=autohello_version AC_SUBST(AUTOHELLO_VERSION_MAJOR) AC_SUBST(AUTOHELLO_VERSION_MINOR) AC_SUBST(AUTOHELLO_VERSION_MICRO) AC_SUBST(AUTOHELLO_VERSION) Macros nécessaires pour générer Makefiles (lien vers automake)
  • 24. Autotools - 16 Juin 2015 24 www.ciose.fr Autohello : top level directory Fichier configure.ac (continued) AC_PREREQ([2.63]) AC_INIT([autohello], [autohello_version],  [christian.charreyre@ciose.fr]) AC_CONFIG_SRCDIR([src/autohello.c]) AC_CONFIG_HEADERS([config.h]) AM_INIT_AUTOMAKE([foreign]) AUTOHELLO_VERSION_MAJOR=autohello_version_major AUTOHELLO_VERSION_MINOR=autohello_version_minor AUTOHELLO_VERSION_MICRO=autohello_version_micro AUTOHELLO_VERSION=autohello_version AC_SUBST(AUTOHELLO_VERSION_MAJOR) AC_SUBST(AUTOHELLO_VERSION_MINOR) AC_SUBST(AUTOHELLO_VERSION_MICRO) AC_SUBST(AUTOHELLO_VERSION) Affectation des valeurs définies par m4_define Substitution des valeurs dans les fichiers générés
  • 25. Autotools - 16 Juin 2015 25 www.ciose.fr Autohello : top level directory Fichier configure.ac (continued) # Checks for programs. AC_PROG_CC # Checks for header files. AC_CHECK_HEADERS([stdio.h stdlib.h]) # Generate files AC_CONFIG_FILES([Makefile src/Makefile src/autohello­version.h]) AC_OUTPUT
  • 26. Autotools - 16 Juin 2015 26 www.ciose.fr Autohello : top level directory Fichier configure.ac (continued) # Checks for programs. AC_PROG_CC # Checks for header files. AC_CHECK_HEADERS([stdio.h stdlib.h]) # Generate files AC_CONFIG_FILES([Makefile src/Makefile src/autohello­version.h]) AC_OUTPUT Vérification présence compilateur C
  • 27. Autotools - 16 Juin 2015 27 www.ciose.fr Autohello : top level directory Fichier configure.ac (continued) # Checks for programs. AC_PROG_CC # Checks for header files. AC_CHECK_HEADERS([stdio.h stdlib.h]) # Generate files AC_CONFIG_FILES([Makefile src/Makefile src/autohello­version.h]) AC_OUTPUT Vérification présence headers requis
  • 28. Autotools - 16 Juin 2015 28 www.ciose.fr Autohello : top level directory Fichier configure.ac (continued) # Checks for programs. AC_PROG_CC # Checks for header files. AC_CHECK_HEADERS([stdio.h stdlib.h]) # Generate files AC_CONFIG_FILES([Makefile src/Makefile src/autohello­version.h]) AC_OUTPUT Fichiers à créer
  • 29. Autotools - 16 Juin 2015 29 www.ciose.fr Autohello : src directory Fichier autohello-version.h.in /tmp/autohello/src : cat autohello­version.h.in /** * @file autohello­version.h *  * This header files defines parts if the software  version. *  * @author Christian Charreyre  <christian.charreyre@ciose.fr> */ #ifndef _AUTOHELLO_VERSION_H_ #define _AUTOHELLO_VERSION_H_ /** The major version, (1, if %AUTOHELLO_VERSION is  1.2.3) */ #define AUTOHELLO_VERSION_MAJOR  (@AUTOHELLO_VERSION_MAJOR@) Remplacé par valeur définie lors du configure
  • 30. Autotools - 16 Juin 2015 30 www.ciose.fr Autohello : src directory Fichier autohello-version.h.in (continued) /** The minor version (2, if %AUTOHELLO_VERSION is  1.2.3) */ #define AUTOHELLO_VERSION_MINOR  (@AUTOHELLO_VERSION_MINOR@) /** The micro version (3, if %AUTOHELLO_VERSION is  1.2.3) */ #define AUTOHELLO_VERSION_MICRO  (@AUTOHELLO_VERSION_MICRO@) /** The full version, like 1.2.3 */ #define AUTOHELLO_VERSION        @AUTOHELLO_VERSION@ /** The full version, in string form (suited for  string concatenation)  */ #define AUTOHELLO_VERSION_STRING "@AUTOHELLO_VERSION@" #endif /* _AUTOHELLO_VERSION_H_ */ Remplacé par valeur définie lors du configure
  • 31. Autotools - 16 Juin 2015 31 www.ciose.fr Autohello : src directory Fichier autohello.c /tmp/autohello/src : cat autohello.c /**  * @file autohello.c  *   * This file implements simple hello world program.  *   * @author Christian Charreyre  <christian.charreyre@ciose.fr>  */ #include <stdio.h> #include <stdlib.h> #include "config.h" #include "autohello­version.h" int main(int argc, char **argv) {     printf("Hello world version %sn",      AUTOHELLO_VERSION_STRING);     printf("Report bugs to %sn", PACKAGE_BUGREPORT);     exit(0); }
  • 32. Autotools - 16 Juin 2015 32 www.ciose.fr Autohello : src directory Fichier autohello.c /tmp/autohello/src : cat autohello.c /**  * @file autohello.c  *   * This file implements simple hello world program.  *   * @author Christian Charreyre  <christian.charreyre@ciose.fr>  */ #include <stdio.h> #include <stdlib.h> #include "config.h" #include "autohello­version.h" int main(int argc, char **argv) {     printf("Hello world version %sn",      AUTOHELLO_VERSION_STRING);     printf("Report bugs to %sn", PACKAGE_BUGREPORT);     exit(0); } Présence headers vérifiée durant configure
  • 33. Autotools - 16 Juin 2015 33 www.ciose.fr Autohello : src directory Fichier autohello.c /tmp/autohello/src : cat autohello.c /**  * @file autohello.c  *   * This file implements simple hello world program.  *   * @author Christian Charreyre  <christian.charreyre@ciose.fr>  */ #include <stdio.h> #include <stdlib.h> #include "config.h" #include "autohello­version.h" int main(int argc, char **argv) {     printf("Hello world version %sn",      AUTOHELLO_VERSION_STRING);     printf("Report bugs to %sn", PACKAGE_BUGREPORT);     exit(0); } config.h généré par configure
  • 34. Autotools - 16 Juin 2015 34 www.ciose.fr Autohello : src directory Fichier autohello.c /tmp/autohello/src : cat autohello.c /**  * @file autohello.c  *   * This file implements simple hello world program.  *   * @author Christian Charreyre  <christian.charreyre@ciose.fr>  */ #include <stdio.h> #include <stdlib.h> #include "config.h" #include "autohello­version.h" int main(int argc, char **argv) {     printf("Hello world version %sn",      AUTOHELLO_VERSION_STRING);     printf("Report bugs to %sn", PACKAGE_BUGREPORT);     exit(0); } autohello-version.h généré par configure
  • 35. Autotools - 16 Juin 2015 35 www.ciose.fr Autohello : src directory Fichier autohello.c /tmp/autohello/src : cat autohello.c /**  * @file autohello.c  *   * This file implements simple hello world program.  *   * @author Christian Charreyre  <christian.charreyre@ciose.fr>  */ #include <stdio.h> #include <stdlib.h> #include "config.h" #include "autohello­version.h" int main(int argc, char **argv) {     printf("Hello world version %sn",      AUTOHELLO_VERSION_STRING);     printf("Report bugs to %sn",  PACKAGE_BUGREPORT);     exit(0); } Défini dans autohello-version.h
  • 36. Autotools - 16 Juin 2015 36 www.ciose.fr Autohello : src directory Fichier autohello.c /tmp/autohello/src : cat autohello.c /**  * @file autohello.c  *   * This file implements simple hello world program.  *   * @author Christian Charreyre  <christian.charreyre@ciose.fr>  */ #include <stdio.h> #include <stdlib.h> #include "config.h" #include "autohello­version.h" int main(int argc, char **argv) {     printf("Hello world version %sn",      AUTOHELLO_VERSION_STRING);     printf("Report bugs to %sn",  PACKAGE_BUGREPORT);     exit(0); } Défini dans config.h
  • 37. Autotools - 16 Juin 2015 37 www.ciose.fr Autohello : src directory Fichier Makefile.am /tmp/autohello/src : cat Makefile.am bin_PROGRAMS = autohello autohello_SOURCES = autohello.c CLEANFILES = *~ AM_CPPFLAGS = ­D_GNU_SOURCE AM_CFLAGS = ­Wall ­Werror
  • 38. Autotools - 16 Juin 2015 38 www.ciose.fr Autohello : src directory Fichier Makefile.am /tmp/autohello/src : cat Makefile.am bin_PROGRAMS = autohello autohello_SOURCES = autohello.c CLEANFILES = *~ AM_CPPFLAGS = ­D_GNU_SOURCE AM_CFLAGS = ­Wall ­Werror Programme(s) à installer dans $bindir
  • 39. Autotools - 16 Juin 2015 39 www.ciose.fr Autohello : src directory Fichier Makefile.am /tmp/autohello/src : cat Makefile.am bin_PROGRAMS = autohello autohello_SOURCES = autohello.c CLEANFILES = *~ AM_CPPFLAGS = ­D_GNU_SOURCE AM_CFLAGS = ­Wall ­Werror Source(s) associé(s) au(x) programme(s)
  • 40. Autotools - 16 Juin 2015 40 www.ciose.fr Autohello : src directory Fichier Makefile.am /tmp/autohello/src : cat Makefile.am bin_PROGRAMS = autohello autohello_SOURCES = autohello.c CLEANFILES = *~ AM_CPPFLAGS = ­D_GNU_SOURCE AM_CFLAGS = ­Wall ­Werror Fichiers additionnels pour cibles de nettoyage
  • 41. Autotools - 16 Juin 2015 41 www.ciose.fr Autohello : src directory Fichier Makefile.am /tmp/autohello/src : cat Makefile.am bin_PROGRAMS = autohello autohello_SOURCES = autohello.c CLEANFILES = *~ AM_CPPFLAGS = ­D_GNU_SOURCE AM_CFLAGS = ­Wall ­Werror Flags additionnels passés au préprocesseur
  • 42. Autotools - 16 Juin 2015 42 www.ciose.fr Autohello : src directory Fichier Makefile.am /tmp/autohello/src : cat Makefile.am bin_PROGRAMS = autohello autohello_SOURCES = autohello.c CLEANFILES = *~ AM_CPPFLAGS = ­D_GNU_SOURCE AM_CFLAGS = ­Wall ­Werror Flags additionnels passés au compilateur
  • 43. Autotools - 16 Juin 2015 43 www.ciose.fr Ajout option configuration Ajout d'une option de configuration pour utiliser gcc ou colorgcc cat configure.ac # Checks for programs. AC_PROG_CC # compiler option (gcc or colorgcc) AC_ARG_ENABLE(colorgcc,   AS_HELP_STRING([­­enable­colorgcc],     [enable compiling with colorgcc]),     [use_colorgcc=$enableval], [use_colorgcc=no]) if test "x$use_colorgcc" = "xyes"; then     # we need colorgcc:     AC_CHECK_PROG([COLORGCC], [colorgcc], [yes], [no])     if test "$COLORGCC" == "yes"; then         AC_MSG_NOTICE([Compiling using colorgcc])         CC=colorgcc     else         AC_MSG_ERROR([colorgcc not found])     fi fi
  • 44. Autotools - 16 Juin 2015 44 www.ciose.fr Utilisation option configuration ./configure –help Optional Features:   ­­disable­option­checking  ignore unrecognized  ­­enable/­­with options   ­­disable­FEATURE       do not include FEATURE  (same as ­­enable­FEATURE=no)   ­­enable­FEATURE[=ARG]  include FEATURE [ARG=yes]   ­­enable­silent­rules   less verbose build output  (undo: "make V=1")   ­­disable­silent­rules  verbose build output (undo:  "make V=0")   ­­enable­dependency­tracking                           do not reject slow  dependency extractors   ­­disable­dependency­tracking                           speeds up one­time build   ­­enable­colorgcc       enable compiling with  colorgcc
  • 45. Autotools - 16 Juin 2015 45 www.ciose.fr Utilisation option configuration Par défaut ./configure n'utilise pas colorgcc Utilisation avec l'option –enable­colorgcc ./configure –enable­colorgcc … checking dependency style of gcc... gcc3 checking for colorgcc... yes configure: Compiling using colorgcc checking how to run the C preprocessor... colorgcc ­E checking for grep that handles long lines and  ­e... /bin/grep … make … colorgcc ­DHAVE_CONFIG_H ­I. ­I..  ­D_GNU_SOURCE   ­Wall ­Werror ­g ­O2 ­MT autohello.o ­MD ­MP ­MF  .deps/autohello.Tpo ­c ­o autohello.o autohello.c
  • 46. Autotools - 16 Juin 2015 46 www.ciose.fr Configuration librairie Utilisation conditionnelle de la librairie glib cat configure.ac # Checks for header files. AC_CHECK_HEADERS([stdio.h stdlib.h]) # Check for libraries. PKG_CHECK_MODULES([glib], [glib­2.0 >= 2.40.0], [AC_DEFINE([HAVE_GLIB], [1], [Use Glib])]) CPPFLAGS="$glib_CFLAGS" LDADD="$glib_LIBS" AC_SUBST([CPPFLAGS]) AC_SUBST([LDADD]) Recherche glib-2.0 >= 2.40.0 Définition constante HAVE_GLIB dans config.h Définition CPPFLAGS et LDADD en fonction présence Glib-2.0
  • 47. Autotools - 16 Juin 2015 47 www.ciose.fr Configuration librairie cat src/autohello.c #include "_build­date.h" #ifdef HAVE_GLIB #include <glib.h> #endif int main(int argc, char **argv) { #ifdef HAVE_GLIB GString *text; text=g_string_new(""); g_string_printf(text, "Hello world version %s built  on %sn", AUTOHELLO_VERSION_STRING, _BUILD_DATE); printf("%s", (char*)(text­>str)); #else Inclusion conditionnelle Code si glib-2.0 disponible
  • 48. Autotools - 16 Juin 2015 48 www.ciose.fr Configuration librairie #else     printf("Hello world version %s built on %sn",     AUTOHELLO_VERSION_STRING, _BUILD_DATE); #endif exit(0); } Code si glib-2.0 non disponible
  • 49. Autotools - 16 Juin 2015 49 www.ciose.fr Créer une archive distribuable Cibles dédiées à la distribution : dist­xxx, xxx formats de compression variés make dist­bzip2 … ls *.tar.* autohello­1.0.2.tar.bz2