Autotools

De drev
(Redirigé depuis Autoconf)
Aller à : navigation, rechercher

Introduction

Le développeur doit écrire les fichier Makefile.am


commande autoscan

Scanner les fichiers source et produit le fichier configure.scan

il faut renommer ce fichier en configure.ac puis ajouter sois même quelques appelles de macro.

commande automake

Lit les fichiers Makefile.am et produit le fichier Makefile.in

Au debut, les fichiers Makefile.in étaient écrit manuellement

Plus tard, ils ont été générés a partir de fichiers Makefile.am


fichier (script) configure

Lit les fichiers Makefile.in Produit le Makefile

configure.ac

#                                               -*- Autoconf -*-
# Process this file with autoconf to produce a configure script.

AC_PREREQ([2.69])
AC_INIT([gtk_sample], [1.0], [BUG-REPORT-ADDRESS])
AC_CONFIG_SRCDIR([app.c])
AC_CONFIG_HEADERS([config.h])

AM_INIT_AUTOMAKE


GLIB_GSETTINGS  #Add this macro to use gsetting (gnome setting storage)


# Checks for programs.
AC_PROG_CC

# Checks for libraries.

# Checks for header files.

# Checks for typedefs, structures, and compiler characteristics.

# Checks for library functions.

AC_CONFIG_FILES([Makefile])
AC_OUTPUT

Makefile.am


## Makefile.am -- Process this file with automake to produce Makefile.in

PKGS=gtk+-3.0 glib-2.0 gmodule-2.0


bin_PROGRAMS = gtk_sample
gtk_sample_SOURCES = main.c app.c callbacks.c app.h
gtk_sample_CPPFLAGS = `pkg-config --cflags $(PKGS)` -Wall -rdynamic
gtk_sample_LDFLAGS = `pkg-config --libs $(PKGS)` -lm -rdynamic
gtk_sample_LDADD = 


Exemple de session


autoscan  #produce configure.scan
mv configure.scan configure.ac

#use your favorite source code editor
#to set the package name and version
#also add the automake initialisation
#macros :  
#AM_INIT_AUTOMAKE
#AC_CONFIG_FILES([Makefile])
#AC_OUTPUT

$EDITOR configure.ac

#add files necessary for GNU compliance
touch AUTHORS NEWS README ChangeLog

touch Makefile.am      
$EDITOR Makefile.am

#creates config.h.in
autoheader

#creates m4 macros in the current directory (like AM_INIT_AUTOMAKE)
aclocal

autoconf

automake --add-missing

./configure

make

make install


bibliographie

https://www.sourceware.org/autobook/autobook/autobook_toc.html