49
Autotools - 16 Juin 2015 1 www.ciose.fr Autotools Autotools C. Charreyre C. Charreyre [email protected] [email protected] http://www.ciose.fr http://www.ciose.fr @CIOinfoindus @CIOinfoindus

Autotools

Embed Size (px)

Citation preview

Autotools - 16 Juin 2015 1

www.ciose.fr

AutotoolsAutotools

C. CharreyreC. [email protected]@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 = srcChaî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 numberm4_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], [[email protected]])AC_CONFIG_SRCDIR([src/autohello.c])AC_CONFIG_HEADERS([config.h])AM_INIT_AUTOMAKE([foreign])

AUTOHELLO_VERSION_MAJOR=autohello_version_majorAUTOHELLO_VERSION_MINOR=autohello_version_minorAUTOHELLO_VERSION_MICRO=autohello_version_microAUTOHELLO_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], [[email protected]])AC_CONFIG_SRCDIR([src/autohello.c])AC_CONFIG_HEADERS([config.h])AM_INIT_AUTOMAKE([foreign])

AUTOHELLO_VERSION_MAJOR=autohello_version_majorAUTOHELLO_VERSION_MINOR=autohello_version_minorAUTOHELLO_VERSION_MICRO=autohello_version_microAUTOHELLO_VERSION=autohello_version

AC_SUBST(AUTOHELLO_VERSION_MAJOR)AC_SUBST(AUTOHELLO_VERSION_MINOR)AC_SUBST(AUTOHELLO_VERSION_MICRO)AC_SUBST(AUTOHELLO_VERSION)

Version minimaled'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], [[email protected]])AC_CONFIG_SRCDIR([src/autohello.c])AC_CONFIG_HEADERS([config.h])AM_INIT_AUTOMAKE([foreign])

AUTOHELLO_VERSION_MAJOR=autohello_version_majorAUTOHELLO_VERSION_MINOR=autohello_version_minorAUTOHELLO_VERSION_MICRO=autohello_version_microAUTOHELLO_VERSION=autohello_version

AC_SUBST(AUTOHELLO_VERSION_MAJOR)AC_SUBST(AUTOHELLO_VERSION_MINOR)AC_SUBST(AUTOHELLO_VERSION_MICRO)AC_SUBST(AUTOHELLO_VERSION)

InitialisationParamè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], [[email protected]])AC_CONFIG_SRCDIR([src/autohello.c])AC_CONFIG_HEADERS([config.h])AM_INIT_AUTOMAKE([foreign])

AUTOHELLO_VERSION_MAJOR=autohello_version_majorAUTOHELLO_VERSION_MINOR=autohello_version_minorAUTOHELLO_VERSION_MICRO=autohello_version_microAUTOHELLO_VERSION=autohello_version

AC_SUBST(AUTOHELLO_VERSION_MAJOR)AC_SUBST(AUTOHELLO_VERSION_MINOR)AC_SUBST(AUTOHELLO_VERSION_MICRO)AC_SUBST(AUTOHELLO_VERSION)

Définitionré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], [[email protected]])AC_CONFIG_SRCDIR([src/autohello.c])AC_CONFIG_HEADERS([config.h])AM_INIT_AUTOMAKE([foreign])

AUTOHELLO_VERSION_MAJOR=autohello_version_majorAUTOHELLO_VERSION_MINOR=autohello_version_minorAUTOHELLO_VERSION_MICRO=autohello_version_microAUTOHELLO_VERSION=autohello_version

AC_SUBST(AUTOHELLO_VERSION_MAJOR)AC_SUBST(AUTOHELLO_VERSION_MINOR)AC_SUBST(AUTOHELLO_VERSION_MICRO)AC_SUBST(AUTOHELLO_VERSION)

Demande créationautomatique

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], [[email protected]])AC_CONFIG_SRCDIR([src/autohello.c])AC_CONFIG_HEADERS([config.h])AM_INIT_AUTOMAKE([foreign])

AUTOHELLO_VERSION_MAJOR=autohello_version_majorAUTOHELLO_VERSION_MINOR=autohello_version_minorAUTOHELLO_VERSION_MICRO=autohello_version_microAUTOHELLO_VERSION=autohello_version

AC_SUBST(AUTOHELLO_VERSION_MAJOR)AC_SUBST(AUTOHELLO_VERSION_MINOR)AC_SUBST(AUTOHELLO_VERSION_MICRO)AC_SUBST(AUTOHELLO_VERSION)

Macros nécessairespour 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], [[email protected]])AC_CONFIG_SRCDIR([src/autohello.c])AC_CONFIG_HEADERS([config.h])AM_INIT_AUTOMAKE([foreign])

AUTOHELLO_VERSION_MAJOR=autohello_version_majorAUTOHELLO_VERSION_MINOR=autohello_version_minorAUTOHELLO_VERSION_MICRO=autohello_version_microAUTOHELLO_VERSION=autohello_version

AC_SUBST(AUTOHELLO_VERSION_MAJOR)AC_SUBST(AUTOHELLO_VERSION_MINOR)AC_SUBST(AUTOHELLO_VERSION_MICRO)AC_SUBST(AUTOHELLO_VERSION)

Affectation des valeursdéfinies par m4_define

Substitution des valeursdans 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 filesAC_CONFIG_FILES([Makefilesrc/Makefilesrc/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 filesAC_CONFIG_FILES([Makefilesrc/Makefilesrc/autohello­version.h])

AC_OUTPUT

Vérification présencecompilateur 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 filesAC_CONFIG_FILES([Makefilesrc/Makefilesrc/autohello­version.h])

AC_OUTPUT

Vérificationpré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 filesAC_CONFIG_FILES([Makefilesrc/Makefilesrc/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 <[email protected]>*/

#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éfinielors 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éfinielors 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 <[email protected]> */#include <stdio.h>#include <stdlib.h>#include "config.h"#include "autohello­version.h"

int main(int argc, char **argv){    printf("Hello world version %s\n",     AUTOHELLO_VERSION_STRING);    printf("Report bugs to %s\n", 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 <[email protected]> */#include <stdio.h>#include <stdlib.h>#include "config.h"#include "autohello­version.h"

int main(int argc, char **argv){    printf("Hello world version %s\n",     AUTOHELLO_VERSION_STRING);    printf("Report bugs to %s\n", PACKAGE_BUGREPORT);    exit(0);}

Présence headersvé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 <[email protected]> */#include <stdio.h>#include <stdlib.h>#include "config.h"#include "autohello­version.h"

int main(int argc, char **argv){    printf("Hello world version %s\n",     AUTOHELLO_VERSION_STRING);    printf("Report bugs to %s\n", 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 <[email protected]> */#include <stdio.h>#include <stdlib.h>#include "config.h"#include "autohello­version.h"

int main(int argc, char **argv){    printf("Hello world version %s\n",     AUTOHELLO_VERSION_STRING);    printf("Report bugs to %s\n", 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 <[email protected]> */#include <stdio.h>#include <stdlib.h>#include "config.h"#include "autohello­version.h"

int main(int argc, char **argv){    printf("Hello world version %s\n",     AUTOHELLO_VERSION_STRING);    printf("Report bugs to %s\n", PACKAGE_BUGREPORT);    exit(0);}

Défini dansautohello-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 <[email protected]> */#include <stdio.h>#include <stdlib.h>#include "config.h"#include "autohello­version.h"

int main(int argc, char **argv){    printf("Hello world version %s\n",     AUTOHELLO_VERSION_STRING);    printf("Report bugs to %s\n", PACKAGE_BUGREPORT);    exit(0);}

Défini dansconfig.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_SOURCEAM_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_SOURCEAM_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_SOURCEAM_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_SOURCEAM_CFLAGS = ­Wall ­Werror

Fichiers additionnelspour 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_SOURCEAM_CFLAGS = ­Wall ­Werror

Flags additionnelspassé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_SOURCEAM_CFLAGS = ­Wall ­Werror

Flags additionnelspassé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])    fifi

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_GLIBdans config.h

Définition CPPFLAGS et LDADDen 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 %s\n",

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 %s\n",

    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 archivedistribuable

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