The autotools structure of a package

Writing packages which compile on all platforms and can easily be maintained is a complex task. The Mathemagix philosophy is to be as standard and simple as possible, by using the following guidelines:

  1. Systematically use Automake/Autoconf, even though these tools are very bureaucratic.

  2. Keep and the as straightforward as possible.

  3. Use a uniform organization for the directory structure.

More precisely, the directory structure of a new package foox should be as follows:

| macros
| | ac_prefix_config_h.m4
| | mmx_module.m4
| | dependency.m4
| | …
| build
| |
| include
| | foox
| | | header_file1.hpp
| | | …
| src
| | src_file1.cpp
| | …
| glue
| | glue_file1.cpp
| | …
| script
| |
| bin 
| | …
| test
| | …
| subdir …

Of course, there may be multiple dependency: any external dependency of your package should come with a separate .m4 file. Similarly, you also have one subdir for each type of functionality of your package. A configuration file foox/include/foox-config.hpp should be created automatically using autoheader and AC_PREFIX_CONFIG_H. The file foox/ is very short and mainly refers to the main makefile foox/build/

1.The file

The file should be modeled on the corresponding file of basix. In particular, you have to start with something like

AC_INIT([foox], [0.2.2], [])
AM_INIT_AUTOMAKE([nostdinc -Wall -Werror foreign])


and end with something like

],[chmod +x script/foox-config])


The file mmx_module.m4 defines a convenient macro AC_MMX_MODULE. When calling this macro inside your, the following common options for Mathemagix packages will be supported.


Enable debugging (disabled by default).


Enable optimization (enabled by default).


Support exceptions for high level routines (enabled by default).


Enable security checks for low level routines (disabled by default).


Build the glue libraries for use with the interpreter (enabled by default).


Build suite of test programs (disabled by default).


Build suite of benchmark programs (disabled by default).


Activate the building of the documentation (disabled by default).

Additional dependencies should all come with a corresponding m4 file. For instance, numerix tests for gmp in the following way:


The macro AC_WITH_GMP provides an option to specify the install path for gmp. The macro AC_LIB_GMP tests whether it is possible to execute some functionality of the library. Notice that the m4 files of some of the Mathemagix packages provide similar macros AC_WITH_BASIX, AC_LIB_BASIX, etc.

2.The file

Each package should come with a global which should be kept as straightforward as possible and the build/, which control how to build the package. Let us describe its content.

First of all, all include files in foox/include/ should be put into the mathemagix subdirectory of includedir:

mmxincludedir = $(includedir)/mathemagix

mmxinclude_HEADERS = \
  ../include/foox/file1.hpp \
  ../include/foox/file2.hpp \
  ../include/foox/file3.hpp \

One next has to specify the Libtool library


and the corresponding sources to be built:

libfoox_la_CPPFLAGS = \
  -I../include \
  … \

libfoox_la_SOURCES = \
  ../src/foo1.cpp \
  ../src/foo2.cpp \

We also have to provide a configuration script foox/script/ and distribute it with our package:

  ../macros/ac_prefix_config_h.m4 \ 
  ../macros/mmx_module.m4 \
  …  \

In order to produce a clean distribution of the package, you also have to add:

DISTCLEANFILES = ../include/foox-config.hpp

In addition to the above required sources and targets, additional libraries and binaries may have to be built as a function of the configuration options –enable-glue, –enable-test and –enable-bench. For instance, in order to build the library which has to be glued to the interpreter, one typically adds the following lines:

  mmxinclude_HEADERS += \
  ../include/foox/file1.hpp \
  ../include/foox/file2.hpp \


  libmmxbasix_la_CPPFLAGS = \
    -I../glue \
    … \

  libmmxfoox_la_SOURCES = \
    ../glue/glue1.cpp \
    ../glue/glue2.cpp \

For the other options, and as a more general rule, we recommend to mimick the code in the existing files */build/

3.Inclusion in the global Mathemagix project

When your package is finished, according to the above guidelines, then we can include it in the main Mathemagix tree. Prior to this inclusion some modifications are necessary so that the above configuration and installation files could be maintained automatically by the script automagix.

Permission is granted to copy, distribute and/or modify this document under the terms of the GNU General Public License. If you don't have this file, write to the Free Software Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.