Getting started with autotools
This document assumes, that the plugin project uses autotools as building tool. So first thing to do is to verify that necessary tools, and libraries are installed on the development machine. If you have never used autotools, this page should give you some idea on how to use it's power with plugin development, otherwise you probably know enough to skip to next page.
*) Making sure that development tools are installed
To check versions, and if programs are installed at all, commands from the table below can be used. I have also included version numbers from my system (updated: 3.6.2007), but you most likely have different versions installed, and that is ok as long as your system is at least somewhat up to date.
| Command | Version |
| automake --version | 1.10 |
| aclocal --version | 1.10 |
| libtoolize --version | 1.5.22 |
| autoheader --version | 2.61 |
| gcc --version | 4.1.1 |
Everything ok? If one or more program(s) are missing, please install them before continuing. If you had all the programs mentioned in the list installed, and the version numbers were even close to the ones I listed, you should have no problems.
*) Creating folder structure for autotools experiment
Although I am using ~ (home) as root folder and aptut subfolder to place tutorials in this document, feel free to create folder structure where ever you like. Name or location of the tutorial container (aptut) is not important. So, to begin with, create a folder called 'tutorial1', and 3 folders inside it, called 'src', 'config' and 'doc'. If you are lazy like me, just use the following command:
| mkdir -p ~/aptut/tutorial1/src ~/aptut/tutorial1/doc ~/aptut/tutorial1/config |
Autotools files go to folder tutorial1, plugin source files to src directory, documentation (if any) go to doc folder, and config folder is storage for autotools.
*) Populating folders
Autotools without program would serve no purpose, so newly created folder is populated with two files. First file is called 'usage_instructions.txt', and it's place is inside 'doc' folder. Content of this file is not important, just that it is there, and contains at least one character. Other file is called main.c, and it is placed under 'src' folder. Content of main.c is below:
|
#include <stdio.h> #include <math.h> #include "config.h" int main(void) { printf("Did you know, that M_PI = %f ?\n",M_PI); return(0); } |
| Content of: src/main.c |
Note: Files can also be downloaded from downloads page (tutorial1.tar), archive also contains
*) Creating files needed by autotools
Autotools assumes, that there are few standard text files in top-level directory ('example1'-folder in this case), some which contain only various information about author, license, etc, and others which contain "build" instructions. Because we are currently only interested in filling build instructions, other files can be created with command:
| touch ChangeLog README AUTHORS NEWS |
Next there are 2 files, both called Makefile.am. First one is at top-level directory, and contains only information about subfolders, second file is located at 'src'-folder and contains instructions on how to compile files.
|
SUBDIRS = src EXTRA_DIST = doc |
| Content of: Makefile.am |
|
AM_CFLAGS = -Wall bin_PROGRAMS = tutorial1 tutorial1_SOURCES = main.c |
| Content of: src/Makefile.am |
|
AC_INIT(tutorial1,1.0.0) AC_CONFIG_SRCDIR(src/main.c) AC_CONFIG_AUX_DIR(config) AM_CONFIG_HEADER(config.h) AM_INIT_AUTOMAKE AC_PROG_CC AC_PROG_INSTALL AC_OUTPUT(Makefile src/Makefile) |
| Content of: configure.ac |
|
aclocal autoheader autoconf automake --add-missing --copy |
*) Example2 - Simple plugin with autotools
|
AC_INIT(tutorial2,1.0.0) AC_CONFIG_SRCDIR(src/plugin_main.c) AC_CONFIG_AUX_DIR(config) AM_CONFIG_HEADER(config.h) AM_INIT_AUTOMAKE # GCC , install and libtool must be present AC_PROG_CC AC_PROG_INSTALL AC_PROG_LIBTOOL # Audacious 1.3.0 or greater must be installed PKG_CHECK_MODULES(AUDACIOUS, [audacious >= 1.3.0] ,, AC_MSG_ERROR([*** Audacious >= 1.3.0 not installed - please install first ***])) # Audacious visualization plugin directory test AVPDIR=`pkg-config audacious --variable=visualization_plugin_dir` AC_SUBST(AVPDIR) # Audacious visualization plugin data directory AVPDD=`pkg-config audacious --variable=data_dir`-plugins AC_SUBST(AVPDD) AC_OUTPUT(Makefile src/Makefile) |
| Content of: configure.ac |
|
lib_LTLIBRARIES = libexample2.la libdir = @AVPDIR@ AM_CFLAGS = -Wall @AUDACIOUS_CFLAGS@ @CFLAGS@ -DDATADIR=\"@AVPDD@\" LIBS = @AUDACIOUS_LIBS@ libexample2_la_LDFLAGS = -module -avoid-version libexample2_la_SOURCES = plugin_main.c |
| Content of: src/Makefile.am |
|
#include <audacious/plugin.h> #include "config.h" VisPlugin example2_vp = { NULL,NULL,0, "Autotools example 2", 0,0, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL }; VisPlugin *get_vplugin_info(void) { printf("Data directory: %s\n",DATADIR); return &example2_vp; } |
| Content of: src/plugin_main.c |
|
aclocal libtoolize --force --copy autoheader autoconf automake --add-missing --copy |
*) Autotools related www-links
http://www.amath.washington.edu/~lf/tutorials/autoconf/toolsmanual_toc.html
* Somewhat old page, but still quite informative
http://www.gnu.org/software/automake/manual/automake.html
* Manual page for automake
http://sources.redhat.com/autobook/
* Tutorial book for autotools
