Autotools
Petit HowTo pour mettre en place un programme compilé / distribué avec les Autotools.
Dans un répertoire vide on commence par créer notre programme src/hello.c
(conformément à la norme ISO) :
#include <stdlib.h>
#include <stdio.h>
int main(void) {
printf("hello, world\n");
return EXIT_SUCCESS;
}
Rajouter un fichier README
(nécessaire à Automake) contenant une présentation du programme.
Rajouter les fichiers Makefile.am
et src/Makefile.am
contenant les instructions Automake pour ces deux sous-dossiers :
Makefile.am:
SUBDIRS = src
dist_doc_DATA = README
src/Makefile.an:
bin_PROGRAMS = hello
hello_SOURCES = hello.c
Enfin rajouter le fichier configure.ac
contenant les instructions Autoconf pour la création du script configure
:
AC_PREREQ([2.69])
AC_INIT([hello], [0.1.0], [klnavarro@caramail.fr])
AM_INIT_AUTOMAKE
AC_CONFIG_SRCDIR([src/hello.c])
AC_CONFIG_HEADERS([config.h])
AC_PROG_CC
AC_CONFIG_FILES([Makefile
src/Makefile])
AC_OUTPUT
Il ne reste plus qu’à initier l’environnement de compilation avec les autotools via :
autoreconf --install
Et à lancer la configuration / compilation :
$ ./configure
$ make (all/install/uninstall/clean/distclean/dist)