3675c4faba9ffc6f85806242f56e928628816e97
[jlayton/glibc.git] / manual / maint.texi
1 @c \input /gd/gnu/doc/texinfo
2 @c This is for making the `INSTALL' file for the distribution.
3 @c Makeinfo ignores it when processing the file from the include.
4 @setfilename INSTALL
5
6 @node Maintenance, Copying, Library Summary, Top
7 @appendix Library Maintenance
8
9 @menu
10 * Installation::          How to configure, compile and
11                              install the GNU C library.
12 * Reporting Bugs::        How to report bugs (if you want to
13                              get them fixed) and other troubles
14                              you may have with the GNU C library.
15 * Source Layout::         How to add new functions or header files
16                              to the GNU C library.
17 * Porting::               How to port the GNU C library to
18                              a new machine or operating system.
19 * Contributors::          Contributors to the GNU C Library.
20 @end menu
21
22 @node Installation
23 @appendixsec How to Install the GNU C Library
24 @cindex installing the library
25
26 Installation of the GNU C library is relatively simple, but usually
27 requires several GNU tools to be installed already.
28 @iftex
29 (@pxref{Tools for Installation}, below.)
30 @end iftex
31
32 @menu
33 * Tools for Installation::      We recommend using these tools to build.
34 * Supported Configurations::    What systems the GNU C library runs on.
35 @end menu
36
37 To configure the GNU C library for your system, run the shell script
38 @file{configure} with @code{sh}.  Use an argument which is the
39 conventional GNU name for your system configuration---for example,
40 @samp{sparc-sun-sunos4.1}, for a Sun 4 running SunOS 4.1.
41 @xref{Installation, Installation, Installing GNU CC, gcc.info, Using and
42 Porting GNU CC}, for a full description of standard GNU configuration
43 names.  If you omit the configuration name, @file{configure} will try to
44 guess one for you by inspecting the system it is running on.  It may or
45 may not be able to come up with a guess, and the its guess might be
46 wrong.  @file{configure} will tell you the canonical name of the chosen
47 configuration before proceeding.
48
49 Here are some options that you should specify (if appropriate) when
50 you run @code{configure}:
51
52 @table @samp
53 @item --with-gnu-ld
54 Use this option if you plan to use GNU @code{ld} to link programs with
55 the GNU C Library.  (We strongly recommend that you do.)  This option
56 enables use of features that exist only in GNU @code{ld}; so if you
57 configure for GNU @code{ld} you must use GNU @code{ld} @emph{every time}
58 you link with the GNU C Library, and when building it.
59
60 @item --with-gnu-as
61 Use this option if you plan to use the GNU assembler, @code{gas}, when
62 building the GNU C Library.  On some systems, the library may not build
63 properly if you do @emph{not} use @code{gas}.
64
65 @item --with-gnu-binutils
66 This option implies both @w{@samp{--with-gnu-ld}} and @w{@samp{--with-gnu-as}}.
67 On systems where GNU tools are the system tools, there is no need to
68 specify this option.  These include GNU, GNU/Linux, and free BSD systems.
69
70 @c extra blank line makes it look better
71 @item --without-fp
72 @itemx --nfp
73
74 Use this option if your computer lacks hardware floating-point support.
75
76 @item --prefix=@var{directory}
77 Install machine-independent data files in subdirectories of
78 @file{@var{directory}}.  (You can also set this in @file{configparms};
79 see below.)  The default is to install in `/usr/local'.
80
81 @item --exec-prefix=@var{directory}
82 Install the library and other machine-dependent files in subdirectories
83 of @file{@var{directory}}.  (You can also set this in
84 @file{configparms}; see below.)  The default is to use <prefix>/bin
85 and <prefix>/sbin.
86
87 @item --enable-shared
88 @itemx --disable-shared
89 Enable or disable building of an ELF shared library on systems that
90 support it.  The default is to build the shared library on systems using
91 ELF when the GNU @code{binutils} are available.
92
93 @item --enable-profile
94 @itemx --disable-profile
95 Enable or disable building of the profiled C library, @samp{-lc_p}.  The
96 default is to build the profiled library.  You may wish to disable it if
97 you don't plan to do profiling, because it doubles the build time of
98 compiling just the unprofiled static library.
99
100 @item --enable-omitfp
101 Enable building a highly-optimized but possibly undebuggable static C
102 library.  This causes the normal static and shared (if enabled) C
103 libraries to be compiled with maximal optimization, including the
104 @samp{-fomit-frame-pointer} switch that makes debugging impossible on
105 many machines, and without debugging information (which makes the
106 binaries substantially smaller).  An additional static library is
107 compiled with no optimization and full debugging information, and
108 installed as @samp{-lc_g}.
109 @end table
110
111 The simplest way to run @code{configure} is to do it in the directory
112 that contains the library sources.  This prepares to build the library
113 in that very directory.
114
115 You can prepare to build the library in some other directory by going
116 to that other directory to run @code{configure}.  In order to run
117 configure, you will have to specify a directory for it, like this:
118
119 @smallexample
120 mkdir sun4
121 cd sun4
122 ../configure sparc-sun-sunos4.1
123 @end smallexample
124
125 @noindent
126 @code{configure} looks for the sources in whatever directory you
127 specified for finding @code{configure} itself.  It does not matter where
128 in the file system the source and build directories are---as long as you
129 specify the source directory when you run @code{configure}, you will get
130 the proper results.
131
132 This feature lets you keep sources and binaries in different
133 directories, and that makes it easy to build the library for several
134 different machines from the same set of sources.  Simply create a
135 build directory for each target machine, and run @code{configure} in
136 that directory specifying the target machine's configuration name.
137
138 The library has a number of special-purpose configuration parameters.
139 These are defined in the file @file{Makeconfig}; see the comments in
140 that file for the details.
141
142 But don't edit the file @file{Makeconfig} yourself---instead, create a
143 file @file{configparms} in the directory where you are building the
144 library, and define in that file the parameters you want to specify.
145 @file{configparms} should @strong{not} be an edited copy of
146 @file{Makeconfig}; specify only the parameters that you want to
147 override.  To see how to set these parameters, find the section of
148 @file{Makeconfig} that says ``These are the configuration variables.''
149 Then for each parameter that you want to change, copy the definition
150 from @file{Makeconfig} to your new @file{configparms} file, and change
151 the value as appropriate for your system.
152
153 It is easy to configure the GNU C library for cross-compilation by
154 setting a few variables in @file{configparms}.  Set @code{CC} to the
155 cross-compiler for the target you configured the library for; it is
156 important to use this same @code{CC} value when running
157 @code{configure}, like this: @samp{CC=@var{target}-gcc configure
158 @var{target}}.  Set @code{BUILD_CC} to the compiler to use for for
159 programs run on the build system as part of compiling the library.  You
160 may need to set @code{AR} and @code{RANLIB} to cross-compiling versions
161 of @code{ar} and @code{ranlib} if the native tools are not configured to
162 work with object files for the target you configured for.
163
164 Some of the machine-dependent code for some machines uses extensions in
165 the GNU C compiler, so you may need to compile the library with GCC.
166 (In fact, all of the existing complete ports require GCC.)
167
168
169 To build the library and related programs, type @code{make}.  This will
170 produce a lot of output, some of which may look like errors from
171 @code{make} (but isn't).  Look for error messages from @code{make}
172 containing @samp{***}.  Those indicate that something is really wrong.
173
174 To build and run some test programs which exercise some of the library
175 facilities, type @code{make check}.  This will produce several files
176 with names like @file{@var{program}.out}.
177
178 To format the @cite{GNU C Library Reference Manual} for printing, type
179 @w{@code{make dvi}}.
180
181 To install the library and its header files, and the Info files of the
182 manual, type @code{make install}.  This will build things if necessary,
183 before installing them.@refill
184
185 @node Tools for Installation
186 @appendixsubsec Recommended Tools to Install the GNU C Library
187 @cindex installation tools
188 @cindex tools, for installing library
189
190 We recommend installing the following GNU tools before attempting to
191 build the GNU C library:
192
193 @itemize @bullet
194 @item
195 @code{make} 3.75
196
197 You need the latest version of GNU @code{make}.  Modifying the GNU C
198 Library to work with other @code{make} programs would be so hard that we
199 recommend you port GNU @code{make} instead.  @strong{Really.}
200 We recommend version GNU @code{make} version 3.75 or later.
201
202 @item
203 GCC 2.7.2
204
205 On most platforms, the GNU C library can only be compiled with the GNU C
206 compiler.  We recommend GCC version 2.7.2 or later; earlier versions may
207 have problems.
208
209 On PowerPC, GCC versions dated earlier than 970904 are known not to work
210 (they crash), including 2.7.2.
211
212 @item
213 @code{binutils} 2.8.1
214
215 Using the GNU @code{binutils} (assembler, linker, and related tools) is
216 preferable when possible, and they are required to build an ELF shared C
217 library.  We recommend @code{binutils} version 2.8.1 or later; earlier
218 versions are known to have problems or to not support all architectures.
219 @end itemize
220
221 @node Supported Configurations
222 @appendixsubsec Supported Configurations
223 @cindex configurations, all supported
224
225 The GNU C Library currently supports configurations that match the
226 following patterns:
227
228 @smallexample
229 alpha-@var{anything}-linux
230 i@var{x}86-@var{anything}-gnu
231 i@var{x}86-@var{anything}-linux
232 m68k-@var{anything}-linux
233 powerpc-@var{anything}-linux
234 @end smallexample
235
236 Former releases of this library (version 1.09.1 and perhaps earlier
237 versions) used to run on the following configurations:
238
239 @smallexample
240 alpha-dec-osf1
241 alpha-@var{anything}-linuxecoff
242 i@var{x}86-@var{anything}-bsd4.3
243 i@var{x}86-@var{anything}-isc2.2
244 i@var{x}86-@var{anything}-isc3.@var{n}
245 i@var{x}86-@var{anything}-sco3.2
246 i@var{x}86-@var{anything}-sco3.2v4
247 i@var{x}86-@var{anything}-sysv
248 i@var{x}86-@var{anything}-sysv4
249 i@var{x}86-force_cpu386-none
250 i@var{x}86-sequent-bsd
251 i960-nindy960-none
252 m68k-hp-bsd4.3
253 m68k-mvme135-none
254 m68k-mvme136-none
255 m68k-sony-newsos3
256 m68k-sony-newsos4
257 m68k-sun-sunos4.@var{n}
258 mips-dec-ultrix4.@var{n}
259 mips-sgi-irix4.@var{n}
260 sparc-sun-solaris2.@var{n}
261 sparc-sun-sunos4.@var{n}
262 @end smallexample
263
264 Since no one has volunteered to test and fix the above configurations,
265 these are not supported at the moment.  It's expected that these don't
266 work anymore.  Porting the library is not hard.  If you are interested
267 in doing a port, please contact the glibc maintainers by sending
268 electronic mail to @email{bug-glibc@@prep.ai.mit.edu}.
269
270 Each case of @samp{i@var{x}86} can be @samp{i386}, @samp{i486},
271 @samp{i586}, or @samp{i686}.  All of those configurations produce a
272 library that can run on any of these processors.  The library will be
273 optimized for the specified processor, but will not use instructions not
274 available on all of them.
275
276 While no other configurations are supported, there are handy aliases for
277 these few.  (These aliases work in other GNU software as well.)
278
279 @smallexample
280 decstation
281 hp320-bsd4.3 hp300bsd
282 i486-gnu
283 i586-linux
284 i386-sco
285 i386-sco3.2v4
286 i386-sequent-dynix
287 i386-svr4
288 news
289 sun3-sunos4.@var{n} sun3
290 sun4-solaris2.@var{n} sun4-sunos5.@var{n}
291 sun4-sunos4.@var{n} sun4
292 @end smallexample
293
294 @node Reporting Bugs
295 @appendixsec Reporting Bugs
296 @cindex reporting bugs
297 @cindex bugs, reporting
298
299 There are probably bugs in the GNU C library.  There are certainly
300 errors and omissions in this manual.  If you report them, they will get
301 fixed.  If you don't, no one will ever know about them and they will
302 remain unfixed for all eternity, if not longer.
303
304 To report a bug, first you must find it.  Hopefully, this will be the
305 hard part.  Once you've found a bug, make sure it's really a bug.  A
306 good way to do this is to see if the GNU C library behaves the same way
307 some other C library does.  If so, probably you are wrong and the
308 libraries are right (but not necessarily).  If not, one of the libraries
309 is probably wrong.
310
311 Once you're sure you've found a bug, try to narrow it down to the
312 smallest test case that reproduces the problem.  In the case of a C
313 library, you really only need to narrow it down to one library
314 function call, if possible.  This should not be too difficult.
315
316 The final step when you have a simple test case is to report the bug.
317 When reporting a bug, send your test case, the results you got, the
318 results you expected, what you think the problem might be (if you've
319 thought of anything), your system type, and the version of the GNU C
320 library which you are using.  Also include the files
321 @file{config.status} and @file{config.make} which are created by running
322 @file{configure}; they will be in whatever directory was current when
323 you ran @file{configure}.
324
325 If you think you have found some way in which the GNU C library does not
326 conform to the ISO and POSIX standards (@pxref{Standards and
327 Portability}), that is definitely a bug.  Report it!@refill
328
329 Send bug reports to the Internet address
330 @email{bug-glibc@@prep.ai.mit.edu} or the UUCP path
331 @email{mit-eddie!prep.ai.mit.edu!bug-glibc}.  If you have other problems
332 with installation or use, please report those as well.@refill
333
334 If you are not sure how a function should behave, and this manual
335 doesn't tell you, that's a bug in the manual.  Report that too!  If the
336 function's behavior disagrees with the manual, then either the library
337 or the manual has a bug, so report the disagreement.  If you find any
338 errors or omissions in this manual, please report them to the Internet
339 address @email{bug-glibc-manual@@prep.ai.mit.edu} or the UUCP path
340 @email{mit-eddie!prep.ai.mit.edu!bug-glibc-manual}.
341
342 @node Source Layout
343 @appendixsec Adding New Functions
344
345 The process of building the library is driven by the makefiles, which
346 make heavy use of special features of GNU @code{make}.  The makefiles
347 are very complex, and you probably don't want to try to understand them.
348 But what they do is fairly straightforward, and only requires that you
349 define a few variables in the right places.
350
351 The library sources are divided into subdirectories, grouped by topic.
352
353 The @file{string} subdirectory has all the string-manipulation
354 functions, @file{math} has all the mathematical functions, etc.
355
356 Each subdirectory contains a simple makefile, called @file{Makefile},
357 which defines a few @code{make} variables and then includes the global
358 makefile @file{Rules} with a line like:
359
360 @smallexample
361 include ../Rules
362 @end smallexample
363
364 @noindent
365 The basic variables that a subdirectory makefile defines are:
366
367 @table @code
368 @item subdir
369 The name of the subdirectory, for example @file{stdio}.
370 This variable @strong{must} be defined.
371
372 @item headers
373 The names of the header files in this section of the library,
374 such as @file{stdio.h}.
375
376 @item routines
377 @itemx aux
378 The names of the modules (source files) in this section of the library.
379 These should be simple names, such as @samp{strlen} (rather than
380 complete file names, such as @file{strlen.c}).  Use @code{routines} for
381 modules that define functions in the library, and @code{aux} for
382 auxiliary modules containing things like data definitions.  But the
383 values of @code{routines} and @code{aux} are just concatenated, so there
384 really is no practical difference.@refill
385
386 @item tests
387 The names of test programs for this section of the library.  These
388 should be simple names, such as @samp{tester} (rather than complete file
389 names, such as @file{tester.c}).  @w{@samp{make tests}} will build and
390 run all the test programs.  If a test program needs input, put the test
391 data in a file called @file{@var{test-program}.input}; it will be given to
392 the test program on its standard input.  If a test program wants to be
393 run with arguments, put the arguments (all on a single line) in a file
394 called @file{@var{test-program}.args}.  Test programs should exit with
395 zero status when the test passes, and nonzero status when the test
396 indicates a bug in the library or error in building.
397
398 @item others
399 The names of ``other'' programs associated with this section of the
400 library.  These are programs which are not tests per se, but are other
401 small programs included with the library.  They are built by
402 @w{@samp{make others}}.@refill
403
404 @item install-lib
405 @itemx install-data
406 @itemx install
407 Files to be installed by @w{@samp{make install}}.  Files listed in
408 @samp{install-lib} are installed in the directory specified by
409 @samp{libdir} in @file{configparms} or @file{Makeconfig}
410 (@pxref{Installation}).  Files listed in @code{install-data} are
411 installed in the directory specified by @samp{datadir} in
412 @file{configparms} or @file{Makeconfig}.  Files listed in @code{install}
413 are installed in the directory specified by @samp{bindir} in
414 @file{configparms} or @file{Makeconfig}.@refill
415
416 @item distribute
417 Other files from this subdirectory which should be put into a
418 distribution tar file.  You need not list here the makefile itself or
419 the source and header files listed in the other standard variables.
420 Only define @code{distribute} if there are files used in an unusual way
421 that should go into the distribution.
422
423 @item generated
424 Files which are generated by @file{Makefile} in this subdirectory.
425 These files will be removed by @w{@samp{make clean}}, and they will
426 never go into a distribution.
427
428 @item extra-objs
429 Extra object files which are built by @file{Makefile} in this
430 subdirectory.  This should be a list of file names like @file{foo.o};
431 the files will actually be found in whatever directory object files are
432 being built in.  These files will be removed by @w{@samp{make clean}}.
433 This variable is used for secondary object files needed to build
434 @code{others} or @code{tests}.
435 @end table
436
437 @node Porting
438 @appendixsec Porting the GNU C Library
439
440 The GNU C library is written to be easily portable to a variety of
441 machines and operating systems.  Machine- and operating system-dependent
442 functions are well separated to make it easy to add implementations for
443 new machines or operating systems.  This section describes the layout of
444 the library source tree and explains the mechanisms used to select
445 machine-dependent code to use.
446
447 All the machine-dependent and operating system-dependent files in the
448 library are in the subdirectory @file{sysdeps} under the top-level
449 library source directory.  This directory contains a hierarchy of
450 subdirectories (@pxref{Hierarchy Conventions}).
451
452 Each subdirectory of @file{sysdeps} contains source files for a
453 particular machine or operating system, or for a class of machine or
454 operating system (for example, systems by a particular vendor, or all
455 machines that use IEEE 754 floating-point format).  A configuration
456 specifies an ordered list of these subdirectories.  Each subdirectory
457 implicitly appends its parent directory to the list.  For example,
458 specifying the list @file{unix/bsd/vax} is equivalent to specifying the
459 list @file{unix/bsd/vax unix/bsd unix}.  A subdirectory can also specify
460 that it implies other subdirectories which are not directly above it in
461 the directory hierarchy.  If the file @file{Implies} exists in a
462 subdirectory, it lists other subdirectories of @file{sysdeps} which are
463 appended to the list, appearing after the subdirectory containing the
464 @file{Implies} file.  Lines in an @file{Implies} file that begin with a
465 @samp{#} character are ignored as comments.  For example,
466 @file{unix/bsd/Implies} contains:@refill
467 @smallexample
468 # BSD has Internet-related things.
469 unix/inet
470 @end smallexample
471 @noindent
472 and @file{unix/Implies} contains:
473 @need 300
474 @smallexample
475 posix
476 @end smallexample
477
478 @noindent
479 So the final list is @file{unix/bsd/vax unix/bsd unix/inet unix posix}.
480
481 @file{sysdeps} has two ``special'' subdirectories, called @file{generic}
482 and @file{stub}.  These two are always implicitly appended to the list
483 of subdirectories (in that order), so you needn't put them in an
484 @file{Implies} file, and you should not create any subdirectories under
485 them intended to be new specific categories.  @file{generic} is for
486 things that can be implemented in machine-independent C, using only
487 other machine-independent functions in the C library.  @file{stub} is
488 for @dfn{stub} versions of functions which cannot be implemented on a
489 particular machine or operating system.  The stub functions always
490 return an error, and set @code{errno} to @code{ENOSYS} (Function not
491 implemented).  @xref{Error Reporting}.
492
493 A source file is known to be system-dependent by its having a version in
494 @file{generic} or @file{stub}; every generally-available function whose
495 implementation is system-dependent in should have either a generic or
496 stub implementation (there is no point in having both).  Some rare functions
497 are only useful on specific systems and aren't defined at all on others;
498 these do not appear anywhere in the system-independent source code or makefiles
499 (including the @file{generic} and @file{stub} directories), only in the
500 system-dependent @file{Makefile} in the specific system's subdirectory.
501
502 If you come across a file that is in one of the main source directories
503 (@file{string}, @file{stdio}, etc.), and you want to write a machine- or
504 operating system-dependent version of it, move the file into
505 @file{sysdeps/generic} and write your new implementation in the
506 appropriate system-specific subdirectory.  Note that if a file is to be
507 system-dependent, it @strong{must not} appear in one of the main source
508 directories.@refill
509
510 There are a few special files that may exist in each subdirectory of
511 @file{sysdeps}:
512
513 @comment Blank lines after items make the table look better.
514 @table @file
515 @item Makefile
516
517 A makefile for this machine or operating system, or class of machine or
518 operating system.  This file is included by the library makefile
519 @file{Makerules}, which is used by the top-level makefile and the
520 subdirectory makefiles.  It can change the variables set in the
521 including makefile or add new rules.  It can use GNU @code{make}
522 conditional directives based on the variable @samp{subdir} (see above) to
523 select different sets of variables and rules for different sections of
524 the library.  It can also set the @code{make} variable
525 @samp{sysdep-routines}, to specify extra modules to be included in the
526 library.  You should use @samp{sysdep-routines} rather than adding
527 modules to @samp{routines} because the latter is used in determining
528 what to distribute for each subdirectory of the main source tree.@refill
529
530 Each makefile in a subdirectory in the ordered list of subdirectories to
531 be searched is included in order.  Since several system-dependent
532 makefiles may be included, each should append to @samp{sysdep-routines}
533 rather than simply setting it:
534
535 @smallexample
536 sysdep-routines := $(sysdep-routines) foo bar
537 @end smallexample
538
539 @need 1000
540 @item Subdirs
541
542 This file contains the names of new whole subdirectories under the
543 top-level library source tree that should be included for this system.
544 These subdirectories are treated just like the system-independent
545 subdirectories in the library source tree, such as @file{stdio} and
546 @file{math}.
547
548 Use this when there are completely new sets of functions and header
549 files that should go into the library for the system this subdirectory
550 of @file{sysdeps} implements.  For example,
551 @file{sysdeps/unix/inet/Subdirs} contains @file{inet}; the @file{inet}
552 directory contains various network-oriented operations which only make
553 sense to put in the library on systems that support the Internet.@refill
554
555 @item Dist
556
557 This file contains the names of files (relative to the subdirectory of
558 @file{sysdeps} in which it appears) which should be included in the
559 distribution.  List any new files used by rules in the @file{Makefile}
560 in the same directory, or header files used by the source files in that
561 directory.  You don't need to list files that are implementations
562 (either C or assembly source) of routines whose names are given in the
563 machine-independent makefiles in the main source tree.
564
565 @item configure
566
567 This file is a shell script fragment to be run at configuration time.
568 The top-level @file{configure} script uses the shell @code{.} command to
569 read the @file{configure} file in each system-dependent directory
570 chosen, in order.  The @file{configure} files are often generated from
571 @file{configure.in} files using Autoconf.
572
573 A system-dependent @file{configure} script will usually add things to
574 the shell variables @samp{DEFS} and @samp{config_vars}; see the
575 top-level @file{configure} script for details.  The script can check for
576 @w{@samp{--with-@var{package}}} options that were passed to the
577 top-level @file{configure}.  For an option
578 @w{@samp{--with-@var{package}=@var{value}}} @file{configure} sets the
579 shell variable @w{@samp{with_@var{package}}} (with any dashes in
580 @var{package} converted to underscores) to @var{value}; if the option is
581 just @w{@samp{--with-@var{package}}} (no argument), then it sets
582 @w{@samp{with_@var{package}}} to @samp{yes}.
583
584 @item configure.in
585
586 This file is an Autoconf input fragment to be processed into the file
587 @file{configure} in this subdirectory.  @xref{Introduction,,,
588 autoconf.info, Autoconf: Generating Automatic Configuration Scripts},
589 for a description of Autoconf.  You should write either @file{configure}
590 or @file{configure.in}, but not both.  The first line of
591 @file{configure.in} should invoke the @code{m4} macro
592 @samp{GLIBC_PROVIDES}.  This macro does several @code{AC_PROVIDE} calls
593 for Autoconf macros which are used by the top-level @file{configure}
594 script; without this, those macros might be invoked again unnecessarily
595 by Autoconf.
596 @end table
597
598 That is the general system for how system-dependencies are isolated.
599 @iftex
600 The next section explains how to decide what directories in
601 @file{sysdeps} to use.  @ref{Porting to Unix}, has some tips on porting
602 the library to Unix variants.
603 @end iftex
604
605 @menu
606 * Hierarchy Conventions::       The layout of the @file{sysdeps} hierarchy.
607 * Porting to Unix::             Porting the library to an average
608                                    Unix-like system.
609 @end menu
610
611 @node Hierarchy Conventions
612 @appendixsubsec Layout of the @file{sysdeps} Directory Hierarchy
613
614 A GNU configuration name has three parts: the CPU type, the
615 manufacturer's name, and the operating system.  @file{configure} uses
616 these to pick the list of system-dependent directories to look for.  If
617 the @samp{--nfp} option is @emph{not} passed to @file{configure}, the
618 directory @file{@var{machine}/fpu} is also used.  The operating system
619 often has a @dfn{base operating system}; for example, if the operating
620 system is @samp{sunos4.1}, the base operating system is @samp{unix/bsd}.
621 The algorithm used to pick the list of directories is simple:
622 @file{configure} makes a list of the base operating system,
623 manufacturer, CPU type, and operating system, in that order.  It then
624 concatenates all these together with slashes in between, to produce a
625 directory name; for example, the configuration @w{@samp{sparc-sun-sunos4.1}}
626 results in @file{unix/bsd/sun/sparc/sunos4.1}.  @file{configure} then
627 tries removing each element of the list in turn, so
628 @file{unix/bsd/sparc} and @file{sun/sparc} are also tried, among others.
629 Since the precise version number of the operating system is often not
630 important, and it would be very inconvenient, for example, to have
631 identical @file{sunos4.1.1} and @file{sunos4.1.2} directories,
632 @file{configure} tries successively less specific operating system names
633 by removing trailing suffixes starting with a period.
634
635 As an example, here is the complete list of directories that would be
636 tried for the configuration @w{@samp{sparc-sun-sunos4.1}} (without the
637 @w{@samp{--nfp}} option):
638
639 @smallexample
640 sparc/fpu
641 unix/bsd/sun/sunos4.1/sparc
642 unix/bsd/sun/sunos4.1
643 unix/bsd/sun/sunos4/sparc
644 unix/bsd/sun/sunos4
645 unix/bsd/sun/sunos/sparc
646 unix/bsd/sun/sunos
647 unix/bsd/sun/sparc
648 unix/bsd/sun
649 unix/bsd/sunos4.1/sparc
650 unix/bsd/sunos4.1
651 unix/bsd/sunos4/sparc
652 unix/bsd/sunos4
653 unix/bsd/sunos/sparc
654 unix/bsd/sunos
655 unix/bsd/sparc
656 unix/bsd
657 unix/sun/sunos4.1/sparc
658 unix/sun/sunos4.1
659 unix/sun/sunos4/sparc
660 unix/sun/sunos4
661 unix/sun/sunos/sparc
662 unix/sun/sunos
663 unix/sun/sparc
664 unix/sun
665 unix/sunos4.1/sparc
666 unix/sunos4.1
667 unix/sunos4/sparc
668 unix/sunos4
669 unix/sunos/sparc
670 unix/sunos
671 unix/sparc
672 unix
673 sun/sunos4.1/sparc
674 sun/sunos4.1
675 sun/sunos4/sparc
676 sun/sunos4
677 sun/sunos/sparc
678 sun/sunos
679 sun/sparc
680 sun
681 sunos4.1/sparc
682 sunos4.1
683 sunos4/sparc
684 sunos4
685 sunos/sparc
686 sunos
687 sparc
688 @end smallexample
689
690 Different machine architectures are conventionally subdirectories at the
691 top level of the @file{sysdeps} directory tree.  For example,
692 @w{@file{sysdeps/sparc}} and @w{@file{sysdeps/m68k}}.  These contain
693 files specific to those machine architectures, but not specific to any
694 particular operating system.  There might be subdirectories for
695 specializations of those architectures, such as
696 @w{@file{sysdeps/m68k/68020}}. Code which is specific to the
697 floating-point coprocessor used with a particular machine should go in
698 @w{@file{sysdeps/@var{machine}/fpu}}.
699
700 There are a few directories at the top level of the @file{sysdeps}
701 hierarchy that are not for particular machine architectures.
702
703 @table @file
704 @item generic
705 @itemx stub
706 As described above (@pxref{Porting}), these are the two subdirectories
707 that every configuration implicitly uses after all others.
708
709 @item ieee754
710 This directory is for code using the IEEE 754 floating-point format,
711 where the C type @code{float} is IEEE 754 single-precision format, and
712 @code{double} is IEEE 754 double-precision format.  Usually this
713 directory is referred to in the @file{Implies} file in a machine
714 architecture-specific directory, such as @file{m68k/Implies}.
715
716 @item posix
717 This directory contains implementations of things in the library in
718 terms of @sc{POSIX.1} functions.  This includes some of the @sc{POSIX.1}
719 functions themselves.  Of course, @sc{POSIX.1} cannot be completely
720 implemented in terms of itself, so a configuration using just
721 @file{posix} cannot be complete.
722
723 @item unix
724 This is the directory for Unix-like things.  @xref{Porting to Unix}.
725 @file{unix} implies @file{posix}.  There are some special-purpose
726 subdirectories of @file{unix}:
727
728 @table @file
729 @item unix/common
730 This directory is for things common to both BSD and System V release 4.
731 Both @file{unix/bsd} and @file{unix/sysv/sysv4} imply @file{unix/common}.
732
733 @item unix/inet
734 This directory is for @code{socket} and related functions on Unix systems.
735 The @file{inet} top-level subdirectory is enabled by @file{unix/inet/Subdirs}.
736 @file{unix/common} implies @file{unix/inet}.
737 @end table
738
739 @item mach
740 This is the directory for things based on the Mach microkernel from CMU
741 (including the GNU operating system).  Other basic operating systems
742 (VMS, for example) would have their own directories at the top level of
743 the @file{sysdeps} hierarchy, parallel to @file{unix} and @file{mach}.
744 @end table
745
746 @node Porting to Unix
747 @appendixsubsec Porting the GNU C Library to Unix Systems
748
749 Most Unix systems are fundamentally very similar.  There are variations
750 between different machines, and variations in what facilities are
751 provided by the kernel.  But the interface to the operating system
752 facilities is, for the most part, pretty uniform and simple.
753
754 The code for Unix systems is in the directory @file{unix}, at the top
755 level of the @file{sysdeps} hierarchy.  This directory contains
756 subdirectories (and subdirectory trees) for various Unix variants.
757
758 The functions which are system calls in most Unix systems are
759 implemented in assembly code, which is generated automatically from
760 specifications in the file @file{sysdeps/unix/syscalls.list}.  Some
761 special system calls are implemented in files that are named with a
762 suffix of @samp{.S}; for example, @file{_exit.S}.  Files ending in
763 @samp{.S} are run through the C preprocessor before being fed to the
764 assembler.
765
766 These files all use a set of macros that should be defined in
767 @file{sysdep.h}.  The @file{sysdep.h} file in @file{sysdeps/unix}
768 partially defines them; a @file{sysdep.h} file in another directory must
769 finish defining them for the particular machine and operating system
770 variant.  See @file{sysdeps/unix/sysdep.h} and the machine-specific
771 @file{sysdep.h} implementations to see what these macros are and what
772 they should do.@refill
773
774 The system-specific makefile for the @file{unix} directory (that is, the
775 file @file{sysdeps/unix/Makefile}) gives rules to generate several files
776 from the Unix system you are building the library on (which is assumed
777 to be the target system you are building the library @emph{for}).  All
778 the generated files are put in the directory where the object files are
779 kept; they should not affect the source tree itself.  The files
780 generated are @file{ioctls.h}, @file{errnos.h}, @file{sys/param.h}, and
781 @file{errlist.c} (for the @file{stdio} section of the library).
782
783 @ignore
784 @c This section might be a good idea if it is finished,
785 @c but there's no point including it as it stands. --rms
786 @c @appendixsec Compatibility with Traditional C
787
788 @c ??? This section is really short now.  Want to keep it? --roland
789
790 Although the GNU C library implements the @w{ISO C} library facilities, you
791 @emph{can} use the GNU C library with traditional, ``pre-ISO'' C
792 compilers.  However, you need to be careful because the content and
793 organization of the GNU C library header files differs from that of
794 traditional C implementations.  This means you may need to make changes
795 to your program in order to get it to compile.
796 @end ignore
797
798 @node Contributors
799 @appendixsec Contributors to the GNU C Library
800
801 The GNU C library was written originally by Roland McGrath.  Some parts
802 of the library were contributed or worked on by other people.
803
804 @itemize @bullet
805 @item
806 The @code{getopt} function and related code were written by
807 Richard Stallman, @w{David J. MacKenzie}, and @w{Roland McGrath}.
808
809 @item
810 The merge sort function @code{qsort} was written by Michael J. Haertel.
811
812 @item
813 The quick sort function used as a fallback by @code{qsort} was written
814 by Douglas C. Schmidt.
815
816 @item
817 The memory allocation functions @code{malloc}, @code{realloc} and
818 @code{free} and related code were written by Michael J. Haertel.
819
820 @item
821 Fast implementations of many of the string functions (@code{memcpy},
822 @code{strlen}, etc.) were written by Torbj@"orn Granlund.
823
824 @item
825 The @file{tar.h} header file was written by David J. MacKenzie.
826
827 @item
828 The port to the MIPS DECStation running Ultrix 4
829 (@code{mips-dec-ultrix4})
830 was contributed by Brendan Kehoe and Ian Lance Taylor.
831
832 @item
833 The DES encryption function @code{crypt} and related functions were
834 contributed by Michael Glad.
835
836 @item
837 The @code{ftw} function was contributed by Ian Lance Taylor.
838
839 @item
840 The startup code to support SunOS shared libraries was contributed by
841 Tom Quinn.
842
843 @item
844 The @code{mktime} function was contributed by Paul Eggert.
845
846 @item
847 The port to the Sequent Symmetry running Dynix version 3
848 (@code{i386-sequent-bsd}) was contributed by Jason Merrill.
849
850 @item
851 The timezone support code is derived from the public-domain timezone
852 package by Arthur David Olson and his many contributors.
853
854 @item
855 The port to the DEC Alpha running OSF/1 (@code{alpha-dec-osf1}) was
856 contributed by Brendan Kehoe, using some code written by Roland McGrath.
857
858 @item
859 The port to SGI machines running Irix 4 (@code{mips-sgi-irix4}) was
860 contributed by Tom Quinn.
861
862 @item
863 The port of the Mach and Hurd code to the MIPS architecture
864 (@code{mips-@var{anything}-gnu}) was contributed by Kazumoto Kojima.
865
866 @item
867 The floating-point printing function used by @code{printf} and friends
868 and the floating-point reading function used by @code{scanf},
869 @code{strtod} and friends were written by Ulrich Drepper.  The
870 multi-precision integer functions used in those functions are taken from
871 GNU MP, which was contributed by Torbj@"orn Granlund.
872
873 @item
874 The internationalization support in the library, and the support
875 programs @code{locale} and @code{localedef}, were written by Ulrich
876 Drepper.  Ulrich Drepper adapted the support code for message catalogs
877 (@file{libintl.h}, etc.) from the GNU @code{gettext} package, which he
878 also wrote.  He also contributed the @code{catgets} support and the
879 entire suite of multi-byte and wide-character support functions
880 (@file{wctype.h}, @file{wchar.h}, etc.).
881
882 @item
883 The implementations of the @file{nsswitch.conf} mechanism and the files
884 and DNS backends for it were designed and written by Ulrich Drepper and
885 Roland McGrath, based on a backend interface defined by Peter Eriksson.
886
887 @item
888 The port to Linux i386/ELF (@code{i386-@var{anything}-linux}) was
889 contributed by Ulrich Drepper, based in large part on work done in
890 Hongjiu Lu's Linux version of the GNU C Library.
891
892 @item
893 The port to Linux/m68k (@code{m68k-@var{anything}-linux}) was
894 contributed by Andreas Schwab.
895
896 @item
897 Richard Henderson contributed the ELF dynamic linking code and other
898 support for the Alpha processor.
899
900 @item
901 David Mosberger-Tang contributed the port to Linux/Alpha
902 (@code{alpha-@var{anything}-linux}).
903
904 @item
905 The port to Linux on PowerPC (@code{powerpc-@var{anything}-linux})
906 was contributed by Geoffrey Keating.
907
908 @item
909 Miles Bader wrote the argp argument-parsing package, and the argz/envz
910 interfaces.
911
912 @item
913 Stephen R. van den Berg contributed a highly-optimized @code{strstr} function.
914
915 @item
916 Ulrich Drepper contributed the @code{hsearch} and @code{drand48}
917 families of functions; reentrant @samp{@dots{}@code{_r}} versions of the
918 @code{random} family; System V shared memory and IPC support code; and
919 several highly-optimized string functions for i@var{x}86 processors.
920
921 @item
922 The math functions are taken from @code{fdlibm-5.1} by Sun
923 Microsystems, as modified by J.T. Conklin, Ian Lance Taylor,
924 Ulrich Drepper, Andreas Schwab, and Roland McGrath.
925
926 @item
927 The @code{libio} library used to implement @code{stdio} functions on
928 some platforms was written by Per Bothner and modified by Ulrich Drepper.
929
930 @item
931 The Internet-related code (most of the @file{inet} subdirectory) and
932 several other miscellaneous functions and header files have been
933 included from 4.4 BSD with little or no modification.
934
935 All code incorporated from 4.4 BSD is under the following copyright:
936
937 @quotation
938 @display
939 Copyright @copyright{} 1991 Regents of the University of California.
940 All rights reserved.
941 @end display
942
943 Redistribution and use in source and binary forms, with or without
944 modification, are permitted provided that the following conditions
945 are met:
946
947 @enumerate
948 @item
949 Redistributions of source code must retain the above copyright
950 notice, this list of conditions and the following disclaimer.
951 @item
952 Redistributions in binary form must reproduce the above copyright
953 notice, this list of conditions and the following disclaimer in the
954 documentation and/or other materials provided with the distribution.
955 @item
956 All advertising materials mentioning features or use of this software
957 must display the following acknowledgement:
958 @quotation
959 This product includes software developed by the University of
960 California, Berkeley and its contributors.
961 @end quotation
962 @item
963 Neither the name of the University nor the names of its contributors
964 may be used to endorse or promote products derived from this software
965 without specific prior written permission.
966 @end enumerate
967
968 @sc{this software is provided by the regents and contributors ``as is'' and
969 any express or implied warranties, including, but not limited to, the
970 implied warranties of merchantability and fitness for a particular purpose
971 are disclaimed.  in no event shall the regents or contributors be liable
972 for any direct, indirect, incidental, special, exemplary, or consequential
973 damages (including, but not limited to, procurement of substitute goods
974 or services; loss of use, data, or profits; or business interruption)
975 however caused and on any theory of liability, whether in contract, strict
976 liability, or tort (including negligence or otherwise) arising in any way
977 out of the use of this software, even if advised of the possibility of
978 such damage.}
979 @end quotation
980
981 @item
982 The random number generation functions @code{random}, @code{srandom},
983 @code{setstate} and @code{initstate}, which are also the basis for the
984 @code{rand} and @code{srand} functions, were written by Earl T. Cohen
985 for the University of California at Berkeley and are copyrighted by the
986 Regents of the University of California.  They have undergone minor
987 changes to fit into the GNU C library and to fit the @w{ISO C} standard,
988 but the functional code is Berkeley's.@refill
989
990 @item
991 The Internet resolver code is taken directly from BIND 4.9.5, which is
992 under both the Berkeley copyright above and also:
993
994 @quotation
995 Portions Copyright @copyright{} 1993 by Digital Equipment Corporation.
996
997 Permission to use, copy, modify, and distribute this software for any
998 purpose with or without fee is hereby granted, provided that the above
999 copyright notice and this permission notice appear in all copies, and
1000 that the name of Digital Equipment Corporation not be used in
1001 advertising or publicity pertaining to distribution of the document or
1002 software without specific, written prior permission.
1003
1004 @sc{the software is provided ``as is'' and digital equipment corp.
1005 disclaims all warranties with regard to this software, including all
1006 implied warranties of merchantability and fitness.  in no event shall
1007 digital equipment corporation be liable for any special, direct,
1008 indirect, or consequential damages or any damages whatsoever resulting
1009 from loss of use, data or profits, whether in an action of contract,
1010 negligence or other tortious action, arising out of or in connection
1011 with the use or performance of this software.}
1012 @end quotation
1013
1014 @item
1015 The code to support Sun RPC is taken verbatim from Sun's
1016 @w{@sc{rpcsrc-4.0}} distribution, and is covered by this copyright:
1017
1018 @quotation
1019 @display
1020 Copyright @copyright{} 1984, Sun Microsystems, Inc.
1021 @end display
1022
1023 Sun RPC is a product of Sun Microsystems, Inc. and is provided for
1024 unrestricted use provided that this legend is included on all tape media
1025 and as a part of the software program in whole or part.  Users may copy
1026 or modify Sun RPC without charge, but are not authorized to license or
1027 distribute it to anyone else except as part of a product or program
1028 developed by the user.
1029
1030 @sc{sun rpc is provided as is with no warranties of any kind including the
1031 warranties of design, merchantibility and fitness for a particular
1032 purpose, or arising from a course of dealing, usage or trade practice.}
1033
1034 Sun RPC is provided with no support and without any obligation on the
1035 part of Sun Microsystems, Inc. to assist in its use, correction,
1036 modification or enhancement.
1037
1038 @sc{sun microsystems, inc. shall have no liability with respect to the
1039 infringement of copyrights, trade secrets or any patents by sun rpc
1040 or any part thereof.}
1041
1042 In no event will Sun Microsystems, Inc. be liable for any lost revenue
1043 or profits or other special, indirect and consequential damages, even if
1044 Sun has been advised of the possibility of such damages.
1045
1046 @display
1047 Sun Microsystems, Inc.
1048 2550 Garcia Avenue
1049 Mountain View, California  94043
1050 @end display
1051 @end quotation
1052
1053 @item
1054 Some of the support code for Mach is taken from Mach 3.0 by CMU,
1055 and is under the following copyright terms:
1056
1057 @quotation
1058 @display
1059 Mach Operating System
1060 Copyright @copyright{} 1991,1990,1989 Carnegie Mellon University
1061 All Rights Reserved.
1062 @end display
1063
1064 Permission to use, copy, modify and distribute this software and its
1065 documentation is hereby granted, provided that both the copyright
1066 notice and this permission notice appear in all copies of the
1067 software, derivative works or modified versions, and any portions
1068 thereof, and that both notices appear in supporting documentation.
1069
1070 @sc{carnegie mellon allows free use of this software in its ``as is''
1071 condition.  carnegie mellon disclaims any liability of any kind for
1072 any damages whatsoever resulting from the use of this software.}
1073
1074 Carnegie Mellon requests users of this software to return to
1075
1076 @display
1077  Software Distribution Coordinator
1078  School of Computer Science
1079  Carnegie Mellon University
1080  Pittsburgh PA 15213-3890
1081 @end display
1082
1083 @noindent
1084 or @email{Software.Distribution@@CS.CMU.EDU} any improvements or
1085 extensions that they make and grant Carnegie Mellon the rights to
1086 redistribute these changes.
1087 @end quotation
1088
1089 @end itemize
1090
1091 @c @bye