Previous: , Up: mfmod   [Contents][Index]


4.25.3 Creating a Mfmod Structure

The mfmodnew provides a convenient start for writing a new mfmod. Given a name of the planned module, this command creates directory mfmod_name and populates it with the files necessary for building the new module using GNU autotools, as well as boilerplate files for the loadable library and interface module.

Let’s see how to use it to create the crypt module outlined in previous subsections.

First, invoke the command:

$ mfmodnew crypt
mfmodnew: setting up new module in mfmod_crypt

Let’s change to the new directory and see the files in it:

$ cd mfmod_crypt
$ ls
Makefile.am  configure.ac  crypt.mfl  mfmod_crypt.c

Now, open the mfmod_crypt.c file and add to it the definition of the cryptval function (see Loadable Library). Then, add the interface function definition from Interface Module to file crypt.mfl.

The last thing to do is to edit configure.ac. The crypt function requires the libcrypt library, so the following line should be added to the ‘Checks for libraries.’ section.

AC_CHECK_LIB([crypt], [crypt])

Now, run autoreconf, as follows:

$ autoreconf -f -i -s

It will bootstrap the autotools infrastructure, importing additional files as necessary. Once done, you can build the project:

$ ./configure
$ make

Notice, that if the autoreconf stage ends abnormally with a diagnostics like:

configure.ac:21: error: possibly undefined macro: AC_MFMOD

that means that autoconf was unable to find the file mfmod.m4, which provides that macro. That’s because the directory where this file is installed is not searched by autoreconf. To fix this, supply the name of that directory using the -I option. E.g. assuming mfmod.m4 is installed in /usr/local/share:

$ autoreconf -fis -I /usr/local/share/aclocal

Previous: , Up: mfmod   [Contents][Index]