The process of building the library is driven by the makefiles, which
make heavy use of special features of GNU make. The makefiles
are very complex, and you probably don’t want to try to understand them.
But what they do is fairly straightforward, and only requires that you
define a few variables in the right places.
The library sources are divided into subdirectories, grouped by topic.
The string subdirectory has all the string-manipulation functions, math has all the mathematical functions, etc.
Each subdirectory contains a simple makefile, called Makefile,
which defines a few make variables and then includes the global
makefile Rules with a line like:
include ../Rules
The basic variables that a subdirectory makefile defines are:
subdirThe name of the subdirectory, for example stdio. This variable must be defined.
headersThe names of the header files in this section of the library, such as stdio.h.
routinesauxThe names of the modules (source files) in this section of the library.
These should be simple names, such as ‘strlen’ (rather than
complete file names, such as strlen.c). Use routines for
modules that define functions in the library, and aux for
auxiliary modules containing things like data definitions. But the
values of routines and aux are just concatenated, so there
really is no practical difference.
testsThe names of test programs for this section of the library. These should be simple names, such as ‘tester’ (rather than complete file names, such as tester.c). ‘make tests’ will build and run all the test programs. If a test program needs input, put the test data in a file called test-program.input; it will be given to the test program on its standard input. If a test program wants to be run with arguments, put the arguments (all on a single line) in a file called test-program.args. Test programs should exit with zero status when the test passes, and nonzero status when the test indicates a bug in the library or error in building.
othersThe names of “other” programs associated with this section of the library. These are programs which are not tests per se, but are other small programs included with the library. They are built by ‘make others’.
install-libinstall-datainstallFiles to be installed by ‘make install’. Files listed in
‘install-lib’ are installed in the directory specified by
‘libdir’ in configparms or Makeconfig
(see Installing the GNU C Library). Files listed in install-data are
installed in the directory specified by ‘datadir’ in
configparms or Makeconfig. Files listed in install
are installed in the directory specified by ‘bindir’ in
configparms or Makeconfig.
distributeOther files from this subdirectory which should be put into a
distribution tar file. You need not list here the makefile itself or
the source and header files listed in the other standard variables.
Only define distribute if there are files used in an unusual way
that should go into the distribution.
generatedFiles which are generated by Makefile in this subdirectory. These files will be removed by ‘make clean’, and they will never go into a distribution.
extra-objsExtra object files which are built by Makefile in this
subdirectory. This should be a list of file names like foo.o;
the files will actually be found in whatever directory object files are
being built in. These files will be removed by ‘make clean’.
This variable is used for secondary object files needed to build
others or tests.