Next: , Up: Library Maintenance   [Contents][Index]


D.1 Adding New Functions

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:

subdir

The name of the subdirectory, for example stdio. This variable must be defined.

headers

The names of the header files in this section of the library, such as stdio.h.

routines
aux

The 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.

tests

The 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.

others

The 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-lib
install-data
install

Files 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.

distribute

Other 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.

generated

Files 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-objs

Extra 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.


Next: Porting the GNU C Library, Up: Library Maintenance   [Contents][Index]