Next: Various Kinds of Modules, Previous: Target Platforms, Up: Philosophy [Contents][Index]
Gnulib is divided into modules. Every module implements a single facility. Modules can depend on other modules.
A module consists of a number of files and a module description. The
files are copied by gnulib-tool
into the package that will use it,
usually verbatim, without changes. Source code files (.h, .c files)
reside in the lib/ subdirectory. Autoconf macro files reside in
the m4/ subdirectory. Build scripts reside in the
build-aux/ subdirectory.
The module description contains the list of files; gnulib-tool
copies these files. It contains the module’s
dependencies; gnulib-tool
installs them as well. It also
contains the autoconf macro invocation (usually a single line or
nothing at all); gnulib-tool
ensures this is invoked from the
package’s configure.ac file. And also a Makefile.am
snippet; gnulib-tool
collects these into a Makefile.am
for the tailored Gnulib part. The module description and include file
specification are for documentation purposes; they are combined into
MODULES.html.
The module system serves two purposes:
getopt_long
function—this is a common way to implement parsing
of command line options in a way that complies with the GNU standards—needs
the source code (lib/getopt.c and others), the autoconf macro
which detects whether the system’s libc already has this function (in
m4/getopt.m4), and a few Makefile.am lines that create the
substitute getopt.h if not. These three pieces belong together.
They cannot be used without each other. The module description and
gnulib-tool
ensure that they are copied altogether into the
destination package.
In other words, the module is the elementary unit of code in Gnulib, comparable to a class in object-oriented languages like Java or C#.
The module system is the basis of gnulib-tool
. When
gnulib-tool
copies a part of Gnulib into a package, it first
compiles a module list, starting with the requested modules and adding all
the dependencies, and then collects the files, configure.ac
snippets and Makefile.am snippets.
Next: Various Kinds of Modules, Previous: Target Platforms, Up: Philosophy [Contents][Index]