source: trunk/src/binutils/etc/standards.info@ 2012

Last change on this file since 2012 was 610, checked in by bird, 22 years ago

This commit was generated by cvs2svn to compensate for changes in r609,
which included commits to RCS files with non-trunk default branches.

  • Property cvs2svn:cvs-rev set to 1.1.1.2
  • Property svn:eol-style set to native
  • Property svn:executable set to *
File size: 177.9 KB
Line 
1This is standards.info, produced by makeinfo version 4.3 from
2./standards.texi.
3
4START-INFO-DIR-ENTRY
5* Standards: (standards). GNU coding standards.
6END-INFO-DIR-ENTRY
7
8 GNU Coding Standards Copyright (C) 1992, 1993, 1994, 1995, 1996,
91997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
10
11 Permission is granted to copy, distribute and/or modify this document
12under the terms of the GNU Free Documentation License, Version 1.1 or
13any later version published by the Free Software Foundation; with no
14Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
15Texts. A copy of the license is included in the section entitled "GNU
16Free Documentation License".
17
18
19File: standards.info, Node: Top, Next: Preface, Prev: (dir), Up: (dir)
20
21Version
22*******
23
24 Last updated February 14, 2002.
25
26* Menu:
27
28* Preface:: About the GNU Coding Standards
29* Legal Issues:: Keeping Free Software Free
30* Design Advice:: General Program Design
31* Program Behavior:: Program Behavior for All Programs
32* Writing C:: Making The Best Use of C
33* Documentation:: Documenting Programs
34* Managing Releases:: The Release Process
35* References:: References to Non-Free Software or Documentation
36* Copying This Manual:: How to Make Copies of This Manual
37* Index::
38
39
40File: standards.info, Node: Preface, Next: Legal Issues, Prev: Top, Up: Top
41
42About the GNU Coding Standards
43******************************
44
45 The GNU Coding Standards were written by Richard Stallman and other
46GNU Project volunteers. Their purpose is to make the GNU system clean,
47consistent, and easy to install. This document can also be read as a
48guide to writing portable, robust and reliable programs. It focuses on
49programs written in C, but many of the rules and principles are useful
50even if you write in another programming language. The rules often
51state reasons for writing in a certain way.
52
53 This release of the GNU Coding Standards was last updated February
5414, 2002.
55
56 If you did not obtain this file directly from the GNU project and
57recently, please check for a newer version. You can ftp the GNU Coding
58Standards from any GNU FTP host in the directory `/pub/gnu/standards/'.
59The GNU Coding Standards are available there in several different
60formats: `standards.text', `standards.info', and `standards.dvi', as
61well as the Texinfo "source" which is divided in two files:
62`standards.texi' and `make-stds.texi'. The GNU Coding Standards are
63also available on the GNU World Wide Web server:
64`http://www.gnu.org/prep/standards_toc.html'.
65
66 Corrections or suggestions for this document should be sent to
67<bug-standards@gnu.org>. If you make a suggestion, please include a
68suggested new wording for it; our time is limited. We prefer a context
69diff to the `standards.texi' or `make-stds.texi' files, but if you
70don't have those files, please mail your suggestion anyway.
71
72 These standards cover the minimum of what is important when writing a
73GNU package. Likely, the needs for additional standards will come up.
74Sometimes, you might suggest that such standards be added to this
75document. If you think your standards would be generally useful, please
76do suggest them.
77
78 You should also set standards for your package on many questions not
79addressed or not firmly specified here. The most important point is to
80be self-consistent--try to stick to the conventions you pick, and try
81to document them as much as possible. That way, your program will be
82more maintainable by others.
83
84
85File: standards.info, Node: Legal Issues, Next: Design Advice, Prev: Preface, Up: Top
86
87Keeping Free Software Free
88**************************
89
90 This node discusses how you can make sure that GNU software avoids
91legal difficulties, and other related issues.
92
93* Menu:
94
95* Reading Non-Free Code:: Referring to Proprietary Programs
96* Contributions:: Accepting Contributions
97* Trademarks:: How We Deal with Trademark Issues
98
99
100File: standards.info, Node: Reading Non-Free Code, Next: Contributions, Up: Legal Issues
101
102Referring to Proprietary Programs
103=================================
104
105 Don't in any circumstances refer to Unix source code for or during
106your work on GNU! (Or to any other proprietary programs.)
107
108 If you have a vague recollection of the internals of a Unix program,
109this does not absolutely mean you can't write an imitation of it, but
110do try to organize the imitation internally along different lines,
111because this is likely to make the details of the Unix version
112irrelevant and dissimilar to your results.
113
114 For example, Unix utilities were generally optimized to minimize
115memory use; if you go for speed instead, your program will be very
116different. You could keep the entire input file in core and scan it
117there instead of using stdio. Use a smarter algorithm discovered more
118recently than the Unix program. Eliminate use of temporary files. Do
119it in one pass instead of two (we did this in the assembler).
120
121 Or, on the contrary, emphasize simplicity instead of speed. For some
122applications, the speed of today's computers makes simpler algorithms
123adequate.
124
125 Or go for generality. For example, Unix programs often have static
126tables or fixed-size strings, which make for arbitrary limits; use
127dynamic allocation instead. Make sure your program handles NULs and
128other funny characters in the input files. Add a programming language
129for extensibility and write part of the program in that language.
130
131 Or turn some parts of the program into independently usable
132libraries. Or use a simple garbage collector instead of tracking
133precisely when to free memory, or use a new GNU facility such as
134obstacks.
135
136
137File: standards.info, Node: Contributions, Next: Trademarks, Prev: Reading Non-Free Code, Up: Legal Issues
138
139Accepting Contributions
140=======================
141
142 If the program you are working on is copyrighted by the Free Software
143Foundation, then when someone else sends you a piece of code to add to
144the program, we need legal papers to use it--just as we asked you to
145sign papers initially. _Each_ person who makes a nontrivial
146contribution to a program must sign some sort of legal papers in order
147for us to have clear title to the program; the main author alone is not
148enough.
149
150 So, before adding in any contributions from other people, please tell
151us, so we can arrange to get the papers. Then wait until we tell you
152that we have received the signed papers, before you actually use the
153contribution.
154
155 This applies both before you release the program and afterward. If
156you receive diffs to fix a bug, and they make significant changes, we
157need legal papers for that change.
158
159 This also applies to comments and documentation files. For copyright
160law, comments and code are just text. Copyright applies to all kinds of
161text, so we need legal papers for all kinds.
162
163 We know it is frustrating to ask for legal papers; it's frustrating
164for us as well. But if you don't wait, you are going out on a limb--for
165example, what if the contributor's employer won't sign a disclaimer?
166You might have to take that code out again!
167
168 You don't need papers for changes of a few lines here or there, since
169they are not significant for copyright purposes. Also, you don't need
170papers if all you get from the suggestion is some ideas, not actual code
171which you use. For example, if someone send you one implementation, but
172you write a different implementation of the same idea, you don't need to
173get papers.
174
175 The very worst thing is if you forget to tell us about the other
176contributor. We could be very embarrassed in court some day as a
177result.
178
179 We have more detailed advice for maintainers of programs; if you have
180reached the stage of actually maintaining a program for GNU (whether
181released or not), please ask us for a copy.
182
183
184File: standards.info, Node: Trademarks, Prev: Contributions, Up: Legal Issues
185
186Trademarks
187==========
188
189 Please do not include any trademark acknowledgements in GNU software
190packages or documentation.
191
192 Trademark acknowledgements are the statements that such-and-such is a
193trademark of so-and-so. The GNU Project has no objection to the basic
194idea of trademarks, but these acknowledgements feel like kowtowing, so
195we don't use them. There is no legal requirement for them.
196
197 What is legally required, as regards other people's trademarks, is to
198avoid using them in ways which a reader might read as naming or labeling
199our own programs or activities. For example, since "Objective C" is
200(or at least was) a trademark, we made sure to say that we provide a
201"compiler for the Objective C language" rather than an "Objective C
202compiler". The latter is meant to be short for the former, but it does
203not explicitly state the relationship, so it could be misinterpreted as
204using "Objective C" as a label for the compiler rather than for the
205language.
206
207
208File: standards.info, Node: Design Advice, Next: Program Behavior, Prev: Legal Issues, Up: Top
209
210General Program Design
211**********************
212
213 This node discusses some of the issues you should take into account
214when designing your program.
215
216* Menu:
217
218* Source Language:: Which languges to use.
219* Compatibility:: Compatibility with other implementations
220* Using Extensions:: Using non-standard features
221* Standard C:: Using Standard C features
222* Conditional Compilation:: Compiling Code Only If A Conditional is True
223
224
225File: standards.info, Node: Source Language, Next: Compatibility, Up: Design Advice
226
227Which Languages to Use
228======================
229
230 When you want to use a language that gets compiled and runs at high
231speed, the best language to use is C. Using another language is like
232using a non-standard feature: it will cause trouble for users. Even if
233GCC supports the other language, users may find it inconvenient to have
234to install the compiler for that other language in order to build your
235program. For example, if you write your program in C++, people will
236have to install the GNU C++ compiler in order to compile your program.
237
238 C has one other advantage over C++ and other compiled languages: more
239people know C, so more people will find it easy to read and modify the
240program if it is written in C.
241
242 So in general it is much better to use C, rather than the comparable
243alternatives.
244
245 But there are two exceptions to that conclusion:
246
247 * It is no problem to use another language to write a tool
248 specifically intended for use with that language. That is because
249 the only people who want to build the tool will be those who have
250 installed the other language anyway.
251
252 * If an application is of interest only to a narrow part of the
253 community, then the question of which language it is written in
254 has less effect on other people, so you may as well please
255 yourself.
256
257 Many programs are designed to be extensible: they include an
258interpreter for a language that is higher level than C. Often much of
259the program is written in that language, too. The Emacs editor
260pioneered this technique.
261
262 The standard extensibility interpreter for GNU software is GUILE,
263which implements the language Scheme (an especially clean and simple
264dialect of Lisp). `http://www.gnu.org/software/guile/'. We don't
265reject programs written in other "scripting languages" such as Perl and
266Python, but using GUILE is very important for the overall consistency of
267the GNU system.
268
269
270File: standards.info, Node: Compatibility, Next: Using Extensions, Prev: Source Language, Up: Design Advice
271
272Compatibility with Other Implementations
273========================================
274
275 With occasional exceptions, utility programs and libraries for GNU
276should be upward compatible with those in Berkeley Unix, and upward
277compatible with Standard C if Standard C specifies their behavior, and
278upward compatible with POSIX if POSIX specifies their behavior.
279
280 When these standards conflict, it is useful to offer compatibility
281modes for each of them.
282
283 Standard C and POSIX prohibit many kinds of extensions. Feel free
284to make the extensions anyway, and include a `--ansi', `--posix', or
285`--compatible' option to turn them off. However, if the extension has
286a significant chance of breaking any real programs or scripts, then it
287is not really upward compatible. So you should try to redesign its
288interface to make it upward compatible.
289
290 Many GNU programs suppress extensions that conflict with POSIX if the
291environment variable `POSIXLY_CORRECT' is defined (even if it is
292defined with a null value). Please make your program recognize this
293variable if appropriate.
294
295 When a feature is used only by users (not by programs or command
296files), and it is done poorly in Unix, feel free to replace it
297completely with something totally different and better. (For example,
298`vi' is replaced with Emacs.) But it is nice to offer a compatible
299feature as well. (There is a free `vi' clone, so we offer it.)
300
301 Additional useful features are welcome regardless of whether there
302is any precedent for them.
303
304
305File: standards.info, Node: Using Extensions, Next: Standard C, Prev: Compatibility, Up: Design Advice
306
307Using Non-standard Features
308===========================
309
310 Many GNU facilities that already exist support a number of convenient
311extensions over the comparable Unix facilities. Whether to use these
312extensions in implementing your program is a difficult question.
313
314 On the one hand, using the extensions can make a cleaner program.
315On the other hand, people will not be able to build the program unless
316the other GNU tools are available. This might cause the program to
317work on fewer kinds of machines.
318
319 With some extensions, it might be easy to provide both alternatives.
320For example, you can define functions with a "keyword" `INLINE' and
321define that as a macro to expand into either `inline' or nothing,
322depending on the compiler.
323
324 In general, perhaps it is best not to use the extensions if you can
325straightforwardly do without them, but to use the extensions if they
326are a big improvement.
327
328 An exception to this rule are the large, established programs (such
329as Emacs) which run on a great variety of systems. Using GNU
330extensions in such programs would make many users unhappy, so we don't
331do that.
332
333 Another exception is for programs that are used as part of
334compilation: anything that must be compiled with other compilers in
335order to bootstrap the GNU compilation facilities. If these require
336the GNU compiler, then no one can compile them without having them
337installed already. That would be extremely troublesome in certain
338cases.
339
340
341File: standards.info, Node: Standard C, Next: Conditional Compilation, Prev: Using Extensions, Up: Design Advice
342
343Standard C and Pre-Standard C
344=============================
345
346 1989 Standard C is widespread enough now that it is ok to use its
347features in new programs. There is one exception: do not ever use the
348"trigraph" feature of Standard C.
349
350 1999 Standard C is not widespread yet, so please do not require its
351features in programs. It is ok to use its features if they are present.
352
353 However, it is easy to support pre-standard compilers in most
354programs, so if you know how to do that, feel free. If a program you
355are maintaining has such support, you should try to keep it working.
356
357 To support pre-standard C, instead of writing function definitions in
358standard prototype form,
359
360 int
361 foo (int x, int y)
362 ...
363
364write the definition in pre-standard style like this,
365
366 int
367 foo (x, y)
368 int x, y;
369 ...
370
371and use a separate declaration to specify the argument prototype:
372
373 int foo (int, int);
374
375 You need such a declaration anyway, in a header file, to get the
376benefit of prototypes in all the files where the function is called.
377And once you have the declaration, you normally lose nothing by writing
378the function definition in the pre-standard style.
379
380 This technique does not work for integer types narrower than `int'.
381If you think of an argument as being of a type narrower than `int',
382declare it as `int' instead.
383
384 There are a few special cases where this technique is hard to use.
385For example, if a function argument needs to hold the system type
386`dev_t', you run into trouble, because `dev_t' is shorter than `int' on
387some machines; but you cannot use `int' instead, because `dev_t' is
388wider than `int' on some machines. There is no type you can safely use
389on all machines in a non-standard definition. The only way to support
390non-standard C and pass such an argument is to check the width of
391`dev_t' using Autoconf and choose the argument type accordingly. This
392may not be worth the trouble.
393
394 In order to support pre-standard compilers that do not recognize
395prototypes, you may want to use a preprocessor macro like this:
396
397 /* Declare the prototype for a general external function. */
398 #if defined (__STDC__) || defined (WINDOWSNT)
399 #define P_(proto) proto
400 #else
401 #define P_(proto) ()
402 #endif
403
404
405File: standards.info, Node: Conditional Compilation, Prev: Standard C, Up: Design Advice
406
407Conditional Compilation
408=======================
409
410 When supporting configuration options already known when building
411your program we prefer using `if (... )' over conditional compilation,
412as in the former case the compiler is able to perform more extensive
413checking of all possible code paths.
414
415 For example, please write
416
417 if (HAS_FOO)
418 ...
419 else
420 ...
421
422 instead of:
423
424 #ifdef HAS_FOO
425 ...
426 #else
427 ...
428 #endif
429
430 A modern compiler such as GCC will generate exactly the same code in
431both cases, and we have been using similar techniques with good success
432in several projects.
433
434 While this is not a silver bullet solving all portability problems,
435following this policy would have saved the GCC project alone many person
436hours if not days per year.
437
438 In the case of function-like macros like `REVERSIBLE_CC_MODE' in GCC
439which cannot be simply used in `if( ...)' statements, there is an easy
440workaround. Simply introduce another macro `HAS_REVERSIBLE_CC_MODE' as
441in the following example:
442
443 #ifdef REVERSIBLE_CC_MODE
444 #define HAS_REVERSIBLE_CC_MODE 1
445 #else
446 #define HAS_REVERSIBLE_CC_MODE 0
447 #endif
448
449
450File: standards.info, Node: Program Behavior, Next: Writing C, Prev: Design Advice, Up: Top
451
452Program Behavior for All Programs
453*********************************
454
455 This node describes conventions for writing robust software. It
456also describes general standards for error messages, the command line
457interface, and how libraries should behave.
458
459* Menu:
460
461* Semantics:: Writing robust programs
462* Libraries:: Library behavior
463* Errors:: Formatting error messages
464* User Interfaces:: Standards about interfaces generally
465* Graphical Interfaces:: Standards for graphical interfaces
466* Command-Line Interfaces:: Standards for command line interfaces
467* Option Table:: Table of long options
468* Memory Usage:: When and how to care about memory needs
469* File Usage:: Which files to use, and where
470
471
472File: standards.info, Node: Semantics, Next: Libraries, Up: Program Behavior
473
474Writing Robust Programs
475=======================
476
477 Avoid arbitrary limits on the length or number of _any_ data
478structure, including file names, lines, files, and symbols, by
479allocating all data structures dynamically. In most Unix utilities,
480"long lines are silently truncated". This is not acceptable in a GNU
481utility.
482
483 Utilities reading files should not drop NUL characters, or any other
484nonprinting characters _including those with codes above 0177_. The
485only sensible exceptions would be utilities specifically intended for
486interface to certain types of terminals or printers that can't handle
487those characters. Whenever possible, try to make programs work
488properly with sequences of bytes that represent multibyte characters,
489using encodings such as UTF-8 and others.
490
491 Check every system call for an error return, unless you know you
492wish to ignore errors. Include the system error text (from `perror' or
493equivalent) in _every_ error message resulting from a failing system
494call, as well as the name of the file if any and the name of the
495utility. Just "cannot open foo.c" or "stat failed" is not sufficient.
496
497 Check every call to `malloc' or `realloc' to see if it returned
498zero. Check `realloc' even if you are making the block smaller; in a
499system that rounds block sizes to a power of 2, `realloc' may get a
500different block if you ask for less space.
501
502 In Unix, `realloc' can destroy the storage block if it returns zero.
503GNU `realloc' does not have this bug: if it fails, the original block
504is unchanged. Feel free to assume the bug is fixed. If you wish to
505run your program on Unix, and wish to avoid lossage in this case, you
506can use the GNU `malloc'.
507
508 You must expect `free' to alter the contents of the block that was
509freed. Anything you want to fetch from the block, you must fetch before
510calling `free'.
511
512 If `malloc' fails in a noninteractive program, make that a fatal
513error. In an interactive program (one that reads commands from the
514user), it is better to abort the command and return to the command
515reader loop. This allows the user to kill other processes to free up
516virtual memory, and then try the command again.
517
518 Use `getopt_long' to decode arguments, unless the argument syntax
519makes this unreasonable.
520
521 When static storage is to be written in during program execution, use
522explicit C code to initialize it. Reserve C initialized declarations
523for data that will not be changed.
524
525 Try to avoid low-level interfaces to obscure Unix data structures
526(such as file directories, utmp, or the layout of kernel memory), since
527these are less likely to work compatibly. If you need to find all the
528files in a directory, use `readdir' or some other high-level interface.
529These are supported compatibly by GNU.
530
531 The preferred signal handling facilities are the BSD variant of
532`signal', and the POSIX `sigaction' function; the alternative USG
533`signal' interface is an inferior design.
534
535 Nowadays, using the POSIX signal functions may be the easiest way to
536make a program portable. If you use `signal', then on GNU/Linux
537systems running GNU libc version 1, you should include `bsd/signal.h'
538instead of `signal.h', so as to get BSD behavior. It is up to you
539whether to support systems where `signal' has only the USG behavior, or
540give up on them.
541
542 In error checks that detect "impossible" conditions, just abort.
543There is usually no point in printing any message. These checks
544indicate the existence of bugs. Whoever wants to fix the bugs will have
545to read the source code and run a debugger. So explain the problem with
546comments in the source. The relevant data will be in variables, which
547are easy to examine with the debugger, so there is no point moving them
548elsewhere.
549
550 Do not use a count of errors as the exit status for a program.
551_That does not work_, because exit status values are limited to 8 bits
552(0 through 255). A single run of the program might have 256 errors; if
553you try to return 256 as the exit status, the parent process will see 0
554as the status, and it will appear that the program succeeded.
555
556 If you make temporary files, check the `TMPDIR' environment
557variable; if that variable is defined, use the specified directory
558instead of `/tmp'.
559
560 In addition, be aware that there is a possible security problem when
561creating temporary files in world-writable directories. In C, you can
562avoid this problem by creating temporary files in this manner:
563
564 fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0600);
565
566or by using the `mkstemps' function from libiberty.
567
568 In bash, use `set -C' to avoid this problem.
569
570
571File: standards.info, Node: Libraries, Next: Errors, Prev: Semantics, Up: Program Behavior
572
573Library Behavior
574================
575
576 Try to make library functions reentrant. If they need to do dynamic
577storage allocation, at least try to avoid any nonreentrancy aside from
578that of `malloc' itself.
579
580 Here are certain name conventions for libraries, to avoid name
581conflicts.
582
583 Choose a name prefix for the library, more than two characters long.
584All external function and variable names should start with this prefix.
585In addition, there should only be one of these in any given library
586member. This usually means putting each one in a separate source file.
587
588 An exception can be made when two external symbols are always used
589together, so that no reasonable program could use one without the
590other; then they can both go in the same file.
591
592 External symbols that are not documented entry points for the user
593should have names beginning with `_'. The `_' should be followed by
594the chosen name prefix for the library, to prevent collisions with
595other libraries. These can go in the same files with user entry points
596if you like.
597
598 Static functions and variables can be used as you like and need not
599fit any naming convention.
600
601
602File: standards.info, Node: Errors, Next: User Interfaces, Prev: Libraries, Up: Program Behavior
603
604Formatting Error Messages
605=========================
606
607 Error messages from compilers should look like this:
608
609 SOURCE-FILE-NAME:LINENO: MESSAGE
610
611If you want to mention the column number, use this format:
612
613 SOURCE-FILE-NAME:LINENO:COLUMN: MESSAGE
614
615Line numbers should start from 1 at the beginning of the file, and
616column numbers should start from 1 at the beginning of the line. (Both
617of these conventions are chosen for compatibility.) Calculate column
618numbers assuming that space and all ASCII printing characters have
619equal width, and assuming tab stops every 8 columns.
620
621 Error messages from other noninteractive programs should look like
622this:
623
624 PROGRAM:SOURCE-FILE-NAME:LINENO: MESSAGE
625
626when there is an appropriate source file, or like this:
627
628 PROGRAM: MESSAGE
629
630when there is no relevant source file.
631
632 If you want to mention the column number, use this format:
633
634 PROGRAM:SOURCE-FILE-NAME:LINENO:COLUMN: MESSAGE
635
636 In an interactive program (one that is reading commands from a
637terminal), it is better not to include the program name in an error
638message. The place to indicate which program is running is in the
639prompt or with the screen layout. (When the same program runs with
640input from a source other than a terminal, it is not interactive and
641would do best to print error messages using the noninteractive style.)
642
643 The string MESSAGE should not begin with a capital letter when it
644follows a program name and/or file name. Also, it should not end with
645a period.
646
647 Error messages from interactive programs, and other messages such as
648usage messages, should start with a capital letter. But they should not
649end with a period.
650
651
652File: standards.info, Node: User Interfaces, Next: Graphical Interfaces, Prev: Errors, Up: Program Behavior
653
654Standards for Interfaces Generally
655==================================
656
657 Please don't make the behavior of a utility depend on the name used
658to invoke it. It is useful sometimes to make a link to a utility with
659a different name, and that should not change what it does.
660
661 Instead, use a run time option or a compilation switch or both to
662select among the alternate behaviors.
663
664 Likewise, please don't make the behavior of the program depend on the
665type of output device it is used with. Device independence is an
666important principle of the system's design; do not compromise it merely
667to save someone from typing an option now and then. (Variation in error
668message syntax when using a terminal is ok, because that is a side issue
669that people do not depend on.)
670
671 If you think one behavior is most useful when the output is to a
672terminal, and another is most useful when the output is a file or a
673pipe, then it is usually best to make the default behavior the one that
674is useful with output to a terminal, and have an option for the other
675behavior.
676
677 Compatibility requires certain programs to depend on the type of
678output device. It would be disastrous if `ls' or `sh' did not do so in
679the way all users expect. In some of these cases, we supplement the
680program with a preferred alternate version that does not depend on the
681output device type. For example, we provide a `dir' program much like
682`ls' except that its default output format is always multi-column
683format.
684
685
686File: standards.info, Node: Graphical Interfaces, Next: Command-Line Interfaces, Prev: User Interfaces, Up: Program Behavior
687
688Standards for Graphical Interfaces
689==================================
690
691 When you write a program that provides a graphical user interface,
692please make it work with X Windows and the GTK toolkit unless the
693functionality specifically requires some alternative (for example,
694"displaying jpeg images while in console mode").
695
696 In addition, please provide a command-line interface to control the
697functionality. (In many cases, the graphical user interface can be a
698separate program which invokes the command-line program.) This is so
699that the same jobs can be done from scripts.
700
701 Please also consider providing a CORBA interface (for use from
702GNOME), a library interface (for use from C), and perhaps a
703keyboard-driven console interface (for use by users from console mode).
704Once you are doing the work to provide the functionality and the
705graphical interface, these won't be much extra work.
706
707
708File: standards.info, Node: Command-Line Interfaces, Next: Option Table, Prev: Graphical Interfaces, Up: Program Behavior
709
710Standards for Command Line Interfaces
711=====================================
712
713 It is a good idea to follow the POSIX guidelines for the
714command-line options of a program. The easiest way to do this is to use
715`getopt' to parse them. Note that the GNU version of `getopt' will
716normally permit options anywhere among the arguments unless the special
717argument `--' is used. This is not what POSIX specifies; it is a GNU
718extension.
719
720 Please define long-named options that are equivalent to the
721single-letter Unix-style options. We hope to make GNU more user
722friendly this way. This is easy to do with the GNU function
723`getopt_long'.
724
725 One of the advantages of long-named options is that they can be
726consistent from program to program. For example, users should be able
727to expect the "verbose" option of any GNU program which has one, to be
728spelled precisely `--verbose'. To achieve this uniformity, look at the
729table of common long-option names when you choose the option names for
730your program (*note Option Table::).
731
732 It is usually a good idea for file names given as ordinary arguments
733to be input files only; any output files would be specified using
734options (preferably `-o' or `--output'). Even if you allow an output
735file name as an ordinary argument for compatibility, try to provide an
736option as another way to specify it. This will lead to more consistency
737among GNU utilities, and fewer idiosyncracies for users to remember.
738
739 All programs should support two standard options: `--version' and
740`--help'.
741
742`--version'
743 This option should direct the program to print information about
744 its name, version, origin and legal status, all on standard
745 output, and then exit successfully. Other options and arguments
746 should be ignored once this is seen, and the program should not
747 perform its normal function.
748
749 The first line is meant to be easy for a program to parse; the
750 version number proper starts after the last space. In addition,
751 it contains the canonical name for this program, in this format:
752
753 GNU Emacs 19.30
754
755 The program's name should be a constant string; _don't_ compute it
756 from `argv[0]'. The idea is to state the standard or canonical
757 name for the program, not its file name. There are other ways to
758 find out the precise file name where a command is found in `PATH'.
759
760 If the program is a subsidiary part of a larger package, mention
761 the package name in parentheses, like this:
762
763 emacsserver (GNU Emacs) 19.30
764
765 If the package has a version number which is different from this
766 program's version number, you can mention the package version
767 number just before the close-parenthesis.
768
769 If you *need* to mention the version numbers of libraries which
770 are distributed separately from the package which contains this
771 program, you can do so by printing an additional line of version
772 info for each library you want to mention. Use the same format
773 for these lines as for the first line.
774
775 Please do not mention all of the libraries that the program uses
776 "just for completeness"--that would produce a lot of unhelpful
777 clutter. Please mention library version numbers only if you find
778 in practice that they are very important to you in debugging.
779
780 The following line, after the version number line or lines, should
781 be a copyright notice. If more than one copyright notice is
782 called for, put each on a separate line.
783
784 Next should follow a brief statement that the program is free
785 software, and that users are free to copy and change it on certain
786 conditions. If the program is covered by the GNU GPL, say so
787 here. Also mention that there is no warranty, to the extent
788 permitted by law.
789
790 It is ok to finish the output with a list of the major authors of
791 the program, as a way of giving credit.
792
793 Here's an example of output that follows these rules:
794
795 GNU Emacs 19.34.5
796 Copyright (C) 1996 Free Software Foundation, Inc.
797 GNU Emacs comes with NO WARRANTY,
798 to the extent permitted by law.
799 You may redistribute copies of GNU Emacs
800 under the terms of the GNU General Public License.
801 For more information about these matters,
802 see the files named COPYING.
803
804 You should adapt this to your program, of course, filling in the
805 proper year, copyright holder, name of program, and the references
806 to distribution terms, and changing the rest of the wording as
807 necessary.
808
809 This copyright notice only needs to mention the most recent year in
810 which changes were made--there's no need to list the years for
811 previous versions' changes. You don't have to mention the name of
812 the program in these notices, if that is inconvenient, since it
813 appeared in the first line.
814
815 Translations of the above lines must preserve the validity of the
816 copyright notices (*note Internationalization::). If the
817 translation's character set supports it, the `(C)' should be
818 replaced with the copyright symbol, as follows:
819
820 (the official copyright symbol, which is the letter C in a circle);
821
822 Write the word "Copyright" exactly like that, in English. Do not
823 translate it into another language. International treaties
824 recognize the English word "Copyright"; translations into other
825 languages do not have legal significance.
826
827`--help'
828 This option should output brief documentation for how to invoke the
829 program, on standard output, then exit successfully. Other
830 options and arguments should be ignored once this is seen, and the
831 program should not perform its normal function.
832
833 Near the end of the `--help' option's output there should be a line
834 that says where to mail bug reports. It should have this format:
835
836 Report bugs to MAILING-ADDRESS.
837
838
839File: standards.info, Node: Option Table, Next: Memory Usage, Prev: Command-Line Interfaces, Up: Program Behavior
840
841Table of Long Options
842=====================
843
844 Here is a table of long options used by GNU programs. It is surely
845incomplete, but we aim to list all the options that a new program might
846want to be compatible with. If you use names not already in the table,
847please send <bug-standards@gnu.org> a list of them, with their
848meanings, so we can update the table.
849
850`after-date'
851 `-N' in `tar'.
852
853`all'
854 `-a' in `du', `ls', `nm', `stty', `uname', and `unexpand'.
855
856`all-text'
857 `-a' in `diff'.
858
859`almost-all'
860 `-A' in `ls'.
861
862`append'
863 `-a' in `etags', `tee', `time'; `-r' in `tar'.
864
865`archive'
866 `-a' in `cp'.
867
868`archive-name'
869 `-n' in `shar'.
870
871`arglength'
872 `-l' in `m4'.
873
874`ascii'
875 `-a' in `diff'.
876
877`assign'
878 `-v' in `gawk'.
879
880`assume-new'
881 `-W' in Make.
882
883`assume-old'
884 `-o' in Make.
885
886`auto-check'
887 `-a' in `recode'.
888
889`auto-pager'
890 `-a' in `wdiff'.
891
892`auto-reference'
893 `-A' in `ptx'.
894
895`avoid-wraps'
896 `-n' in `wdiff'.
897
898`background'
899 For server programs, run in the background.
900
901`backward-search'
902 `-B' in `ctags'.
903
904`basename'
905 `-f' in `shar'.
906
907`batch'
908 Used in GDB.
909
910`baud'
911 Used in GDB.
912
913`before'
914 `-b' in `tac'.
915
916`binary'
917 `-b' in `cpio' and `diff'.
918
919`bits-per-code'
920 `-b' in `shar'.
921
922`block-size'
923 Used in `cpio' and `tar'.
924
925`blocks'
926 `-b' in `head' and `tail'.
927
928`break-file'
929 `-b' in `ptx'.
930
931`brief'
932 Used in various programs to make output shorter.
933
934`bytes'
935 `-c' in `head', `split', and `tail'.
936
937`c++'
938 `-C' in `etags'.
939
940`catenate'
941 `-A' in `tar'.
942
943`cd'
944 Used in various programs to specify the directory to use.
945
946`changes'
947 `-c' in `chgrp' and `chown'.
948
949`classify'
950 `-F' in `ls'.
951
952`colons'
953 `-c' in `recode'.
954
955`command'
956 `-c' in `su'; `-x' in GDB.
957
958`compare'
959 `-d' in `tar'.
960
961`compat'
962 Used in `gawk'.
963
964`compress'
965 `-Z' in `tar' and `shar'.
966
967`concatenate'
968 `-A' in `tar'.
969
970`confirmation'
971 `-w' in `tar'.
972
973`context'
974 Used in `diff'.
975
976`copyleft'
977 `-W copyleft' in `gawk'.
978
979`copyright'
980 `-C' in `ptx', `recode', and `wdiff'; `-W copyright' in `gawk'.
981
982`core'
983 Used in GDB.
984
985`count'
986 `-q' in `who'.
987
988`count-links'
989 `-l' in `du'.
990
991`create'
992 Used in `tar' and `cpio'.
993
994`cut-mark'
995 `-c' in `shar'.
996
997`cxref'
998 `-x' in `ctags'.
999
1000`date'
1001 `-d' in `touch'.
1002
1003`debug'
1004 `-d' in Make and `m4'; `-t' in Bison.
1005
1006`define'
1007 `-D' in `m4'.
1008
1009`defines'
1010 `-d' in Bison and `ctags'.
1011
1012`delete'
1013 `-D' in `tar'.
1014
1015`dereference'
1016 `-L' in `chgrp', `chown', `cpio', `du', `ls', and `tar'.
1017
1018`dereference-args'
1019 `-D' in `du'.
1020
1021`device'
1022 Specify an I/O device (special file name).
1023
1024`diacritics'
1025 `-d' in `recode'.
1026
1027`dictionary-order'
1028 `-d' in `look'.
1029
1030`diff'
1031 `-d' in `tar'.
1032
1033`digits'
1034 `-n' in `csplit'.
1035
1036`directory'
1037 Specify the directory to use, in various programs. In `ls', it
1038 means to show directories themselves rather than their contents.
1039 In `rm' and `ln', it means to not treat links to directories
1040 specially.
1041
1042`discard-all'
1043 `-x' in `strip'.
1044
1045`discard-locals'
1046 `-X' in `strip'.
1047
1048`dry-run'
1049 `-n' in Make.
1050
1051`ed'
1052 `-e' in `diff'.
1053
1054`elide-empty-files'
1055 `-z' in `csplit'.
1056
1057`end-delete'
1058 `-x' in `wdiff'.
1059
1060`end-insert'
1061 `-z' in `wdiff'.
1062
1063`entire-new-file'
1064 `-N' in `diff'.
1065
1066`environment-overrides'
1067 `-e' in Make.
1068
1069`eof'
1070 `-e' in `xargs'.
1071
1072`epoch'
1073 Used in GDB.
1074
1075`error-limit'
1076 Used in `makeinfo'.
1077
1078`error-output'
1079 `-o' in `m4'.
1080
1081`escape'
1082 `-b' in `ls'.
1083
1084`exclude-from'
1085 `-X' in `tar'.
1086
1087`exec'
1088 Used in GDB.
1089
1090`exit'
1091 `-x' in `xargs'.
1092
1093`exit-0'
1094 `-e' in `unshar'.
1095
1096`expand-tabs'
1097 `-t' in `diff'.
1098
1099`expression'
1100 `-e' in `sed'.
1101
1102`extern-only'
1103 `-g' in `nm'.
1104
1105`extract'
1106 `-i' in `cpio'; `-x' in `tar'.
1107
1108`faces'
1109 `-f' in `finger'.
1110
1111`fast'
1112 `-f' in `su'.
1113
1114`fatal-warnings'
1115 `-E' in `m4'.
1116
1117`file'
1118 `-f' in `info', `gawk', Make, `mt', and `tar'; `-n' in `sed'; `-r'
1119 in `touch'.
1120
1121`field-separator'
1122 `-F' in `gawk'.
1123
1124`file-prefix'
1125 `-b' in Bison.
1126
1127`file-type'
1128 `-F' in `ls'.
1129
1130`files-from'
1131 `-T' in `tar'.
1132
1133`fill-column'
1134 Used in `makeinfo'.
1135
1136`flag-truncation'
1137 `-F' in `ptx'.
1138
1139`fixed-output-files'
1140 `-y' in Bison.
1141
1142`follow'
1143 `-f' in `tail'.
1144
1145`footnote-style'
1146 Used in `makeinfo'.
1147
1148`force'
1149 `-f' in `cp', `ln', `mv', and `rm'.
1150
1151`force-prefix'
1152 `-F' in `shar'.
1153
1154`foreground'
1155 For server programs, run in the foreground; in other words, don't
1156 do anything special to run the server in the background.
1157
1158`format'
1159 Used in `ls', `time', and `ptx'.
1160
1161`freeze-state'
1162 `-F' in `m4'.
1163
1164`fullname'
1165 Used in GDB.
1166
1167`gap-size'
1168 `-g' in `ptx'.
1169
1170`get'
1171 `-x' in `tar'.
1172
1173`graphic'
1174 `-i' in `ul'.
1175
1176`graphics'
1177 `-g' in `recode'.
1178
1179`group'
1180 `-g' in `install'.
1181
1182`gzip'
1183 `-z' in `tar' and `shar'.
1184
1185`hashsize'
1186 `-H' in `m4'.
1187
1188`header'
1189 `-h' in `objdump' and `recode'
1190
1191`heading'
1192 `-H' in `who'.
1193
1194`help'
1195 Used to ask for brief usage information.
1196
1197`here-delimiter'
1198 `-d' in `shar'.
1199
1200`hide-control-chars'
1201 `-q' in `ls'.
1202
1203`html'
1204 In `makeinfo', output HTML.
1205
1206`idle'
1207 `-u' in `who'.
1208
1209`ifdef'
1210 `-D' in `diff'.
1211
1212`ignore'
1213 `-I' in `ls'; `-x' in `recode'.
1214
1215`ignore-all-space'
1216 `-w' in `diff'.
1217
1218`ignore-backups'
1219 `-B' in `ls'.
1220
1221`ignore-blank-lines'
1222 `-B' in `diff'.
1223
1224`ignore-case'
1225 `-f' in `look' and `ptx'; `-i' in `diff' and `wdiff'.
1226
1227`ignore-errors'
1228 `-i' in Make.
1229
1230`ignore-file'
1231 `-i' in `ptx'.
1232
1233`ignore-indentation'
1234 `-I' in `etags'.
1235
1236`ignore-init-file'
1237 `-f' in Oleo.
1238
1239`ignore-interrupts'
1240 `-i' in `tee'.
1241
1242`ignore-matching-lines'
1243 `-I' in `diff'.
1244
1245`ignore-space-change'
1246 `-b' in `diff'.
1247
1248`ignore-zeros'
1249 `-i' in `tar'.
1250
1251`include'
1252 `-i' in `etags'; `-I' in `m4'.
1253
1254`include-dir'
1255 `-I' in Make.
1256
1257`incremental'
1258 `-G' in `tar'.
1259
1260`info'
1261 `-i', `-l', and `-m' in Finger.
1262
1263`init-file'
1264 In some programs, specify the name of the file to read as the
1265 user's init file.
1266
1267`initial'
1268 `-i' in `expand'.
1269
1270`initial-tab'
1271 `-T' in `diff'.
1272
1273`inode'
1274 `-i' in `ls'.
1275
1276`interactive'
1277 `-i' in `cp', `ln', `mv', `rm'; `-e' in `m4'; `-p' in `xargs';
1278 `-w' in `tar'.
1279
1280`intermix-type'
1281 `-p' in `shar'.
1282
1283`iso-8601'
1284 Used in `date'
1285
1286`jobs'
1287 `-j' in Make.
1288
1289`just-print'
1290 `-n' in Make.
1291
1292`keep-going'
1293 `-k' in Make.
1294
1295`keep-files'
1296 `-k' in `csplit'.
1297
1298`kilobytes'
1299 `-k' in `du' and `ls'.
1300
1301`language'
1302 `-l' in `etags'.
1303
1304`less-mode'
1305 `-l' in `wdiff'.
1306
1307`level-for-gzip'
1308 `-g' in `shar'.
1309
1310`line-bytes'
1311 `-C' in `split'.
1312
1313`lines'
1314 Used in `split', `head', and `tail'.
1315
1316`link'
1317 `-l' in `cpio'.
1318
1319`lint'
1320`lint-old'
1321 Used in `gawk'.
1322
1323`list'
1324 `-t' in `cpio'; `-l' in `recode'.
1325
1326`list'
1327 `-t' in `tar'.
1328
1329`literal'
1330 `-N' in `ls'.
1331
1332`load-average'
1333 `-l' in Make.
1334
1335`login'
1336 Used in `su'.
1337
1338`machine'
1339 No listing of which programs already use this; someone should
1340 check to see if any actually do, and tell <gnu@gnu.org>.
1341
1342`macro-name'
1343 `-M' in `ptx'.
1344
1345`mail'
1346 `-m' in `hello' and `uname'.
1347
1348`make-directories'
1349 `-d' in `cpio'.
1350
1351`makefile'
1352 `-f' in Make.
1353
1354`mapped'
1355 Used in GDB.
1356
1357`max-args'
1358 `-n' in `xargs'.
1359
1360`max-chars'
1361 `-n' in `xargs'.
1362
1363`max-lines'
1364 `-l' in `xargs'.
1365
1366`max-load'
1367 `-l' in Make.
1368
1369`max-procs'
1370 `-P' in `xargs'.
1371
1372`mesg'
1373 `-T' in `who'.
1374
1375`message'
1376 `-T' in `who'.
1377
1378`minimal'
1379 `-d' in `diff'.
1380
1381`mixed-uuencode'
1382 `-M' in `shar'.
1383
1384`mode'
1385 `-m' in `install', `mkdir', and `mkfifo'.
1386
1387`modification-time'
1388 `-m' in `tar'.
1389
1390`multi-volume'
1391 `-M' in `tar'.
1392
1393`name-prefix'
1394 `-a' in Bison.
1395
1396`nesting-limit'
1397 `-L' in `m4'.
1398
1399`net-headers'
1400 `-a' in `shar'.
1401
1402`new-file'
1403 `-W' in Make.
1404
1405`no-builtin-rules'
1406 `-r' in Make.
1407
1408`no-character-count'
1409 `-w' in `shar'.
1410
1411`no-check-existing'
1412 `-x' in `shar'.
1413
1414`no-common'
1415 `-3' in `wdiff'.
1416
1417`no-create'
1418 `-c' in `touch'.
1419
1420`no-defines'
1421 `-D' in `etags'.
1422
1423`no-deleted'
1424 `-1' in `wdiff'.
1425
1426`no-dereference'
1427 `-d' in `cp'.
1428
1429`no-inserted'
1430 `-2' in `wdiff'.
1431
1432`no-keep-going'
1433 `-S' in Make.
1434
1435`no-lines'
1436 `-l' in Bison.
1437
1438`no-piping'
1439 `-P' in `shar'.
1440
1441`no-prof'
1442 `-e' in `gprof'.
1443
1444`no-regex'
1445 `-R' in `etags'.
1446
1447`no-sort'
1448 `-p' in `nm'.
1449
1450`no-split'
1451 Used in `makeinfo'.
1452
1453`no-static'
1454 `-a' in `gprof'.
1455
1456`no-time'
1457 `-E' in `gprof'.
1458
1459`no-timestamp'
1460 `-m' in `shar'.
1461
1462`no-validate'
1463 Used in `makeinfo'.
1464
1465`no-wait'
1466 Used in `emacsclient'.
1467
1468`no-warn'
1469 Used in various programs to inhibit warnings.
1470
1471`node'
1472 `-n' in `info'.
1473
1474`nodename'
1475 `-n' in `uname'.
1476
1477`nonmatching'
1478 `-f' in `cpio'.
1479
1480`nstuff'
1481 `-n' in `objdump'.
1482
1483`null'
1484 `-0' in `xargs'.
1485
1486`number'
1487 `-n' in `cat'.
1488
1489`number-nonblank'
1490 `-b' in `cat'.
1491
1492`numeric-sort'
1493 `-n' in `nm'.
1494
1495`numeric-uid-gid'
1496 `-n' in `cpio' and `ls'.
1497
1498`nx'
1499 Used in GDB.
1500
1501`old-archive'
1502 `-o' in `tar'.
1503
1504`old-file'
1505 `-o' in Make.
1506
1507`one-file-system'
1508 `-l' in `tar', `cp', and `du'.
1509
1510`only-file'
1511 `-o' in `ptx'.
1512
1513`only-prof'
1514 `-f' in `gprof'.
1515
1516`only-time'
1517 `-F' in `gprof'.
1518
1519`options'
1520 `-o' in `getopt', `fdlist', `fdmount', `fdmountd', and `fdumount'.
1521
1522`output'
1523 In various programs, specify the output file name.
1524
1525`output-prefix'
1526 `-o' in `shar'.
1527
1528`override'
1529 `-o' in `rm'.
1530
1531`overwrite'
1532 `-c' in `unshar'.
1533
1534`owner'
1535 `-o' in `install'.
1536
1537`paginate'
1538 `-l' in `diff'.
1539
1540`paragraph-indent'
1541 Used in `makeinfo'.
1542
1543`parents'
1544 `-p' in `mkdir' and `rmdir'.
1545
1546`pass-all'
1547 `-p' in `ul'.
1548
1549`pass-through'
1550 `-p' in `cpio'.
1551
1552`port'
1553 `-P' in `finger'.
1554
1555`portability'
1556 `-c' in `cpio' and `tar'.
1557
1558`posix'
1559 Used in `gawk'.
1560
1561`prefix-builtins'
1562 `-P' in `m4'.
1563
1564`prefix'
1565 `-f' in `csplit'.
1566
1567`preserve'
1568 Used in `tar' and `cp'.
1569
1570`preserve-environment'
1571 `-p' in `su'.
1572
1573`preserve-modification-time'
1574 `-m' in `cpio'.
1575
1576`preserve-order'
1577 `-s' in `tar'.
1578
1579`preserve-permissions'
1580 `-p' in `tar'.
1581
1582`print'
1583 `-l' in `diff'.
1584
1585`print-chars'
1586 `-L' in `cmp'.
1587
1588`print-data-base'
1589 `-p' in Make.
1590
1591`print-directory'
1592 `-w' in Make.
1593
1594`print-file-name'
1595 `-o' in `nm'.
1596
1597`print-symdefs'
1598 `-s' in `nm'.
1599
1600`printer'
1601 `-p' in `wdiff'.
1602
1603`prompt'
1604 `-p' in `ed'.
1605
1606`proxy'
1607 Specify an HTTP proxy.
1608
1609`query-user'
1610 `-X' in `shar'.
1611
1612`question'
1613 `-q' in Make.
1614
1615`quiet'
1616 Used in many programs to inhibit the usual output. *Note:* every
1617 program accepting `--quiet' should accept `--silent' as a synonym.
1618
1619`quiet-unshar'
1620 `-Q' in `shar'
1621
1622`quote-name'
1623 `-Q' in `ls'.
1624
1625`rcs'
1626 `-n' in `diff'.
1627
1628`re-interval'
1629 Used in `gawk'.
1630
1631`read-full-blocks'
1632 `-B' in `tar'.
1633
1634`readnow'
1635 Used in GDB.
1636
1637`recon'
1638 `-n' in Make.
1639
1640`record-number'
1641 `-R' in `tar'.
1642
1643`recursive'
1644 Used in `chgrp', `chown', `cp', `ls', `diff', and `rm'.
1645
1646`reference-limit'
1647 Used in `makeinfo'.
1648
1649`references'
1650 `-r' in `ptx'.
1651
1652`regex'
1653 `-r' in `tac' and `etags'.
1654
1655`release'
1656 `-r' in `uname'.
1657
1658`reload-state'
1659 `-R' in `m4'.
1660
1661`relocation'
1662 `-r' in `objdump'.
1663
1664`rename'
1665 `-r' in `cpio'.
1666
1667`replace'
1668 `-i' in `xargs'.
1669
1670`report-identical-files'
1671 `-s' in `diff'.
1672
1673`reset-access-time'
1674 `-a' in `cpio'.
1675
1676`reverse'
1677 `-r' in `ls' and `nm'.
1678
1679`reversed-ed'
1680 `-f' in `diff'.
1681
1682`right-side-defs'
1683 `-R' in `ptx'.
1684
1685`same-order'
1686 `-s' in `tar'.
1687
1688`same-permissions'
1689 `-p' in `tar'.
1690
1691`save'
1692 `-g' in `stty'.
1693
1694`se'
1695 Used in GDB.
1696
1697`sentence-regexp'
1698 `-S' in `ptx'.
1699
1700`separate-dirs'
1701 `-S' in `du'.
1702
1703`separator'
1704 `-s' in `tac'.
1705
1706`sequence'
1707 Used by `recode' to chose files or pipes for sequencing passes.
1708
1709`shell'
1710 `-s' in `su'.
1711
1712`show-all'
1713 `-A' in `cat'.
1714
1715`show-c-function'
1716 `-p' in `diff'.
1717
1718`show-ends'
1719 `-E' in `cat'.
1720
1721`show-function-line'
1722 `-F' in `diff'.
1723
1724`show-tabs'
1725 `-T' in `cat'.
1726
1727`silent'
1728 Used in many programs to inhibit the usual output. *Note:* every
1729 program accepting `--silent' should accept `--quiet' as a synonym.
1730
1731`size'
1732 `-s' in `ls'.
1733
1734`socket'
1735 Specify a file descriptor for a network server to use for its
1736 socket, instead of opening and binding a new socket. This
1737 provides a way to run, in a nonpriveledged process, a server that
1738 normally needs a reserved port number.
1739
1740`sort'
1741 Used in `ls'.
1742
1743`source'
1744 `-W source' in `gawk'.
1745
1746`sparse'
1747 `-S' in `tar'.
1748
1749`speed-large-files'
1750 `-H' in `diff'.
1751
1752`split-at'
1753 `-E' in `unshar'.
1754
1755`split-size-limit'
1756 `-L' in `shar'.
1757
1758`squeeze-blank'
1759 `-s' in `cat'.
1760
1761`start-delete'
1762 `-w' in `wdiff'.
1763
1764`start-insert'
1765 `-y' in `wdiff'.
1766
1767`starting-file'
1768 Used in `tar' and `diff' to specify which file within a directory
1769 to start processing with.
1770
1771`statistics'
1772 `-s' in `wdiff'.
1773
1774`stdin-file-list'
1775 `-S' in `shar'.
1776
1777`stop'
1778 `-S' in Make.
1779
1780`strict'
1781 `-s' in `recode'.
1782
1783`strip'
1784 `-s' in `install'.
1785
1786`strip-all'
1787 `-s' in `strip'.
1788
1789`strip-debug'
1790 `-S' in `strip'.
1791
1792`submitter'
1793 `-s' in `shar'.
1794
1795`suffix'
1796 `-S' in `cp', `ln', `mv'.
1797
1798`suffix-format'
1799 `-b' in `csplit'.
1800
1801`sum'
1802 `-s' in `gprof'.
1803
1804`summarize'
1805 `-s' in `du'.
1806
1807`symbolic'
1808 `-s' in `ln'.
1809
1810`symbols'
1811 Used in GDB and `objdump'.
1812
1813`synclines'
1814 `-s' in `m4'.
1815
1816`sysname'
1817 `-s' in `uname'.
1818
1819`tabs'
1820 `-t' in `expand' and `unexpand'.
1821
1822`tabsize'
1823 `-T' in `ls'.
1824
1825`terminal'
1826 `-T' in `tput' and `ul'. `-t' in `wdiff'.
1827
1828`text'
1829 `-a' in `diff'.
1830
1831`text-files'
1832 `-T' in `shar'.
1833
1834`time'
1835 Used in `ls' and `touch'.
1836
1837`timeout'
1838 Specify how long to wait before giving up on some operation.
1839
1840`to-stdout'
1841 `-O' in `tar'.
1842
1843`total'
1844 `-c' in `du'.
1845
1846`touch'
1847 `-t' in Make, `ranlib', and `recode'.
1848
1849`trace'
1850 `-t' in `m4'.
1851
1852`traditional'
1853 `-t' in `hello'; `-W traditional' in `gawk'; `-G' in `ed', `m4',
1854 and `ptx'.
1855
1856`tty'
1857 Used in GDB.
1858
1859`typedefs'
1860 `-t' in `ctags'.
1861
1862`typedefs-and-c++'
1863 `-T' in `ctags'.
1864
1865`typeset-mode'
1866 `-t' in `ptx'.
1867
1868`uncompress'
1869 `-z' in `tar'.
1870
1871`unconditional'
1872 `-u' in `cpio'.
1873
1874`undefine'
1875 `-U' in `m4'.
1876
1877`undefined-only'
1878 `-u' in `nm'.
1879
1880`update'
1881 `-u' in `cp', `ctags', `mv', `tar'.
1882
1883`usage'
1884 Used in `gawk'; same as `--help'.
1885
1886`uuencode'
1887 `-B' in `shar'.
1888
1889`vanilla-operation'
1890 `-V' in `shar'.
1891
1892`verbose'
1893 Print more information about progress. Many programs support this.
1894
1895`verify'
1896 `-W' in `tar'.
1897
1898`version'
1899 Print the version number.
1900
1901`version-control'
1902 `-V' in `cp', `ln', `mv'.
1903
1904`vgrind'
1905 `-v' in `ctags'.
1906
1907`volume'
1908 `-V' in `tar'.
1909
1910`what-if'
1911 `-W' in Make.
1912
1913`whole-size-limit'
1914 `-l' in `shar'.
1915
1916`width'
1917 `-w' in `ls' and `ptx'.
1918
1919`word-regexp'
1920 `-W' in `ptx'.
1921
1922`writable'
1923 `-T' in `who'.
1924
1925`zeros'
1926 `-z' in `gprof'.
1927
1928
1929File: standards.info, Node: Memory Usage, Next: File Usage, Prev: Option Table, Up: Program Behavior
1930
1931Memory Usage
1932============
1933
1934 If a program typically uses just a few meg of memory, don't bother
1935making any effort to reduce memory usage. For example, if it is
1936impractical for other reasons to operate on files more than a few meg
1937long, it is reasonable to read entire input files into core to operate
1938on them.
1939
1940 However, for programs such as `cat' or `tail', that can usefully
1941operate on very large files, it is important to avoid using a technique
1942that would artificially limit the size of files it can handle. If a
1943program works by lines and could be applied to arbitrary user-supplied
1944input files, it should keep only a line in memory, because this is not
1945very hard and users will want to be able to operate on input files that
1946are bigger than will fit in core all at once.
1947
1948 If your program creates complicated data structures, just make them
1949in core and give a fatal error if `malloc' returns zero.
1950
1951
1952File: standards.info, Node: File Usage, Prev: Memory Usage, Up: Program Behavior
1953
1954File Usage
1955==========
1956
1957 Programs should be prepared to operate when `/usr' and `/etc' are
1958read-only file systems. Thus, if the program manages log files, lock
1959files, backup files, score files, or any other files which are modified
1960for internal purposes, these files should not be stored in `/usr' or
1961`/etc'.
1962
1963 There are two exceptions. `/etc' is used to store system
1964configuration information; it is reasonable for a program to modify
1965files in `/etc' when its job is to update the system configuration.
1966Also, if the user explicitly asks to modify one file in a directory, it
1967is reasonable for the program to store other files in the same
1968directory.
1969
1970
1971File: standards.info, Node: Writing C, Next: Documentation, Prev: Program Behavior, Up: Top
1972
1973Making The Best Use of C
1974************************
1975
1976 This node provides advice on how best to use the C language when
1977writing GNU software.
1978
1979* Menu:
1980
1981* Formatting:: Formatting Your Source Code
1982* Comments:: Commenting Your Work
1983* Syntactic Conventions:: Clean Use of C Constructs
1984* Names:: Naming Variables, Functions, and Files
1985* System Portability:: Portability between different operating systems
1986* CPU Portability:: Supporting the range of CPU types
1987* System Functions:: Portability and ``standard'' library functions
1988* Internationalization:: Techniques for internationalization
1989* Mmap:: How you can safely use `mmap'.
1990
1991
1992File: standards.info, Node: Formatting, Next: Comments, Up: Writing C
1993
1994Formatting Your Source Code
1995===========================
1996
1997 It is important to put the open-brace that starts the body of a C
1998function in column zero, and avoid putting any other open-brace or
1999open-parenthesis or open-bracket in column zero. Several tools look
2000for open-braces in column zero to find the beginnings of C functions.
2001These tools will not work on code not formatted that way.
2002
2003 It is also important for function definitions to start the name of
2004the function in column zero. This helps people to search for function
2005definitions, and may also help certain tools recognize them. Thus, the
2006proper format is this:
2007
2008 static char *
2009 concat (s1, s2) /* Name starts in column zero here */
2010 char *s1, *s2;
2011 { /* Open brace in column zero here */
2012 ...
2013 }
2014
2015or, if you want to use Standard C syntax, format the definition like
2016this:
2017
2018 static char *
2019 concat (char *s1, char *s2)
2020 {
2021 ...
2022 }
2023
2024 In Standard C, if the arguments don't fit nicely on one line, split
2025it like this:
2026
2027 int
2028 lots_of_args (int an_integer, long a_long, short a_short,
2029 double a_double, float a_float)
2030 ...
2031
2032 The rest of this section gives our recommendations for other aspects
2033of C formatting style, which is also the default style of the `indent'
2034program in version 1.2 and newer. It corresponds to the options
2035
2036 -nbad -bap -nbc -bbo -bl -bli2 -bls -ncdb -nce -cp1 -cs -di2
2037 -ndj -nfc1 -nfca -hnl -i2 -ip5 -lp -pcs -psl -nsc -nsob
2038
2039 We don't think of these recommendations as requirements, because it
2040causes no problems for users if two different programs have different
2041formatting styles.
2042
2043 But whatever style you use, please use it consistently, since a
2044mixture of styles within one program tends to look ugly. If you are
2045contributing changes to an existing program, please follow the style of
2046that program.
2047
2048 For the body of the function, our recommended style looks like this:
2049
2050 if (x < foo (y, z))
2051 haha = bar[4] + 5;
2052 else
2053 {
2054 while (z)
2055 {
2056 haha += foo (z, z);
2057 z--;
2058 }
2059 return ++x + bar ();
2060 }
2061
2062 We find it easier to read a program when it has spaces before the
2063open-parentheses and after the commas. Especially after the commas.
2064
2065 When you split an expression into multiple lines, split it before an
2066operator, not after one. Here is the right way:
2067
2068 if (foo_this_is_long && bar > win (x, y, z)
2069 && remaining_condition)
2070
2071 Try to avoid having two operators of different precedence at the same
2072level of indentation. For example, don't write this:
2073
2074 mode = (inmode[j] == VOIDmode
2075 || GET_MODE_SIZE (outmode[j]) > GET_MODE_SIZE (inmode[j])
2076 ? outmode[j] : inmode[j]);
2077
2078 Instead, use extra parentheses so that the indentation shows the
2079nesting:
2080
2081 mode = ((inmode[j] == VOIDmode
2082 || (GET_MODE_SIZE (outmode[j]) > GET_MODE_SIZE (inmode[j])))
2083 ? outmode[j] : inmode[j]);
2084
2085 Insert extra parentheses so that Emacs will indent the code properly.
2086For example, the following indentation looks nice if you do it by hand,
2087
2088 v = rup->ru_utime.tv_sec*1000 + rup->ru_utime.tv_usec/1000
2089 + rup->ru_stime.tv_sec*1000 + rup->ru_stime.tv_usec/1000;
2090
2091but Emacs would alter it. Adding a set of parentheses produces
2092something that looks equally nice, and which Emacs will preserve:
2093
2094 v = (rup->ru_utime.tv_sec*1000 + rup->ru_utime.tv_usec/1000
2095 + rup->ru_stime.tv_sec*1000 + rup->ru_stime.tv_usec/1000);
2096
2097 Format do-while statements like this:
2098
2099 do
2100 {
2101 a = foo (a);
2102 }
2103 while (a > 0);
2104
2105 Please use formfeed characters (control-L) to divide the program into
2106pages at logical places (but not within a function). It does not matter
2107just how long the pages are, since they do not have to fit on a printed
2108page. The formfeeds should appear alone on lines by themselves.
2109
2110
2111File: standards.info, Node: Comments, Next: Syntactic Conventions, Prev: Formatting, Up: Writing C
2112
2113Commenting Your Work
2114====================
2115
2116 Every program should start with a comment saying briefly what it is
2117for. Example: `fmt - filter for simple filling of text'.
2118
2119 Please write the comments in a GNU program in English, because
2120English is the one language that nearly all programmers in all
2121countries can read. If you do not write English well, please write
2122comments in English as well as you can, then ask other people to help
2123rewrite them. If you can't write comments in English, please find
2124someone to work with you and translate your comments into English.
2125
2126 Please put a comment on each function saying what the function does,
2127what sorts of arguments it gets, and what the possible values of
2128arguments mean and are used for. It is not necessary to duplicate in
2129words the meaning of the C argument declarations, if a C type is being
2130used in its customary fashion. If there is anything nonstandard about
2131its use (such as an argument of type `char *' which is really the
2132address of the second character of a string, not the first), or any
2133possible values that would not work the way one would expect (such as,
2134that strings containing newlines are not guaranteed to work), be sure
2135to say so.
2136
2137 Also explain the significance of the return value, if there is one.
2138
2139 Please put two spaces after the end of a sentence in your comments,
2140so that the Emacs sentence commands will work. Also, please write
2141complete sentences and capitalize the first word. If a lower-case
2142identifier comes at the beginning of a sentence, don't capitalize it!
2143Changing the spelling makes it a different identifier. If you don't
2144like starting a sentence with a lower case letter, write the sentence
2145differently (e.g., "The identifier lower-case is ...").
2146
2147 The comment on a function is much clearer if you use the argument
2148names to speak about the argument values. The variable name itself
2149should be lower case, but write it in upper case when you are speaking
2150about the value rather than the variable itself. Thus, "the inode
2151number NODE_NUM" rather than "an inode".
2152
2153 There is usually no purpose in restating the name of the function in
2154the comment before it, because the reader can see that for himself.
2155There might be an exception when the comment is so long that the
2156function itself would be off the bottom of the screen.
2157
2158 There should be a comment on each static variable as well, like this:
2159
2160 /* Nonzero means truncate lines in the display;
2161 zero means continue them. */
2162 int truncate_lines;
2163
2164 Every `#endif' should have a comment, except in the case of short
2165conditionals (just a few lines) that are not nested. The comment should
2166state the condition of the conditional that is ending, _including its
2167sense_. `#else' should have a comment describing the condition _and
2168sense_ of the code that follows. For example:
2169
2170 #ifdef foo
2171 ...
2172 #else /* not foo */
2173 ...
2174 #endif /* not foo */
2175 #ifdef foo
2176 ...
2177 #endif /* foo */
2178
2179but, by contrast, write the comments this way for a `#ifndef':
2180
2181 #ifndef foo
2182 ...
2183 #else /* foo */
2184 ...
2185 #endif /* foo */
2186 #ifndef foo
2187 ...
2188 #endif /* not foo */
2189
2190
2191File: standards.info, Node: Syntactic Conventions, Next: Names, Prev: Comments, Up: Writing C
2192
2193Clean Use of C Constructs
2194=========================
2195
2196 Please explicitly declare the types of all objects. For example, you
2197should explicitly declare all arguments to functions, and you should
2198declare functions to return `int' rather than omitting the `int'.
2199
2200 Some programmers like to use the GCC `-Wall' option, and change the
2201code whenever it issues a warning. If you want to do this, then do.
2202Other programmers prefer not to use `-Wall', because it gives warnings
2203for valid and legitimate code which they do not want to change. If you
2204want to do this, then do. The compiler should be your servant, not
2205your master.
2206
2207 Declarations of external functions and functions to appear later in
2208the source file should all go in one place near the beginning of the
2209file (somewhere before the first function definition in the file), or
2210else should go in a header file. Don't put `extern' declarations inside
2211functions.
2212
2213 It used to be common practice to use the same local variables (with
2214names like `tem') over and over for different values within one
2215function. Instead of doing this, it is better declare a separate local
2216variable for each distinct purpose, and give it a name which is
2217meaningful. This not only makes programs easier to understand, it also
2218facilitates optimization by good compilers. You can also move the
2219declaration of each local variable into the smallest scope that includes
2220all its uses. This makes the program even cleaner.
2221
2222 Don't use local variables or parameters that shadow global
2223identifiers.
2224
2225 Don't declare multiple variables in one declaration that spans lines.
2226Start a new declaration on each line, instead. For example, instead of
2227this:
2228
2229 int foo,
2230 bar;
2231
2232write either this:
2233
2234 int foo, bar;
2235
2236or this:
2237
2238 int foo;
2239 int bar;
2240
2241(If they are global variables, each should have a comment preceding it
2242anyway.)
2243
2244 When you have an `if'-`else' statement nested in another `if'
2245statement, always put braces around the `if'-`else'. Thus, never write
2246like this:
2247
2248 if (foo)
2249 if (bar)
2250 win ();
2251 else
2252 lose ();
2253
2254always like this:
2255
2256 if (foo)
2257 {
2258 if (bar)
2259 win ();
2260 else
2261 lose ();
2262 }
2263
2264 If you have an `if' statement nested inside of an `else' statement,
2265either write `else if' on one line, like this,
2266
2267 if (foo)
2268 ...
2269 else if (bar)
2270 ...
2271
2272with its `then'-part indented like the preceding `then'-part, or write
2273the nested `if' within braces like this:
2274
2275 if (foo)
2276 ...
2277 else
2278 {
2279 if (bar)
2280 ...
2281 }
2282
2283 Don't declare both a structure tag and variables or typedefs in the
2284same declaration. Instead, declare the structure tag separately and
2285then use it to declare the variables or typedefs.
2286
2287 Try to avoid assignments inside `if'-conditions. For example, don't
2288write this:
2289
2290 if ((foo = (char *) malloc (sizeof *foo)) == 0)
2291 fatal ("virtual memory exhausted");
2292
2293instead, write this:
2294
2295 foo = (char *) malloc (sizeof *foo);
2296 if (foo == 0)
2297 fatal ("virtual memory exhausted");
2298
2299 Don't make the program ugly to placate `lint'. Please don't insert
2300any casts to `void'. Zero without a cast is perfectly fine as a null
2301pointer constant, except when calling a varargs function.
2302
2303
2304File: standards.info, Node: Names, Next: System Portability, Prev: Syntactic Conventions, Up: Writing C
2305
2306Naming Variables, Functions, and Files
2307======================================
2308
2309 The names of global variables and functions in a program serve as
2310comments of a sort. So don't choose terse names--instead, look for
2311names that give useful information about the meaning of the variable or
2312function. In a GNU program, names should be English, like other
2313comments.
2314
2315 Local variable names can be shorter, because they are used only
2316within one context, where (presumably) comments explain their purpose.
2317
2318 Try to limit your use of abbreviations in symbol names. It is ok to
2319make a few abbreviations, explain what they mean, and then use them
2320frequently, but don't use lots of obscure abbreviations.
2321
2322 Please use underscores to separate words in a name, so that the Emacs
2323word commands can be useful within them. Stick to lower case; reserve
2324upper case for macros and `enum' constants, and for name-prefixes that
2325follow a uniform convention.
2326
2327 For example, you should use names like `ignore_space_change_flag';
2328don't use names like `iCantReadThis'.
2329
2330 Variables that indicate whether command-line options have been
2331specified should be named after the meaning of the option, not after
2332the option-letter. A comment should state both the exact meaning of
2333the option and its letter. For example,
2334
2335 /* Ignore changes in horizontal whitespace (-b). */
2336 int ignore_space_change_flag;
2337
2338 When you want to define names with constant integer values, use
2339`enum' rather than `#define'. GDB knows about enumeration constants.
2340
2341 You might want to make sure that none of the file names would
2342conflict the files were loaded onto an MS-DOS file system which
2343shortens the names. You can use the program `doschk' to test for this.
2344
2345 Some GNU programs were designed to limit themselves to file names of
234614 characters or less, to avoid file name conflicts if they are read
2347into older System V systems. Please preserve this feature in the
2348existing GNU programs that have it, but there is no need to do this in
2349new GNU programs. `doschk' also reports file names longer than 14
2350characters.
2351
2352
2353File: standards.info, Node: System Portability, Next: CPU Portability, Prev: Names, Up: Writing C
2354
2355Portability between System Types
2356================================
2357
2358 In the Unix world, "portability" refers to porting to different Unix
2359versions. For a GNU program, this kind of portability is desirable, but
2360not paramount.
2361
2362 The primary purpose of GNU software is to run on top of the GNU
2363kernel, compiled with the GNU C compiler, on various types of CPU. So
2364the kinds of portability that are absolutely necessary are quite
2365limited. But it is important to support Linux-based GNU systems, since
2366they are the form of GNU that is popular.
2367
2368 Beyond that, it is good to support the other free operating systems
2369(*BSD), and it is nice to support other Unix-like systems if you want
2370to. Supporting a variety of Unix-like systems is desirable, although
2371not paramount. It is usually not too hard, so you may as well do it.
2372But you don't have to consider it an obligation, if it does turn out to
2373be hard.
2374
2375 The easiest way to achieve portability to most Unix-like systems is
2376to use Autoconf. It's unlikely that your program needs to know more
2377information about the host platform than Autoconf can provide, simply
2378because most of the programs that need such knowledge have already been
2379written.
2380
2381 Avoid using the format of semi-internal data bases (e.g.,
2382directories) when there is a higher-level alternative (`readdir').
2383
2384 As for systems that are not like Unix, such as MSDOS, Windows, the
2385Macintosh, VMS, and MVS, supporting them is often a lot of work. When
2386that is the case, it is better to spend your time adding features that
2387will be useful on GNU and GNU/Linux, rather than on supporting other
2388incompatible systems.
2389
2390 It is a good idea to define the "feature test macro" `_GNU_SOURCE'
2391when compiling your C files. When you compile on GNU or GNU/Linux,
2392this will enable the declarations of GNU library extension functions,
2393and that will usually give you a compiler error message if you define
2394the same function names in some other way in your program. (You don't
2395have to actually _use_ these functions, if you prefer to make the
2396program more portable to other systems.)
2397
2398 But whether or not you use these GNU extensions, you should avoid
2399using their names for any other meanings. Doing so would make it hard
2400to move your code into other GNU programs.
2401
2402
2403File: standards.info, Node: CPU Portability, Next: System Functions, Prev: System Portability, Up: Writing C
2404
2405Portability between CPUs
2406========================
2407
2408 Even GNU systems will differ because of differences among CPU
2409types--for example, difference in byte ordering and alignment
2410requirements. It is absolutely essential to handle these differences.
2411However, don't make any effort to cater to the possibility that an
2412`int' will be less than 32 bits. We don't support 16-bit machines in
2413GNU.
2414
2415 Similarly, don't make any effort to cater to the possibility that
2416`long' will be smaller than predefined types like `size_t'. For
2417example, the following code is ok:
2418
2419 printf ("size = %lu\n", (unsigned long) sizeof array);
2420 printf ("diff = %ld\n", (long) (pointer2 - pointer1));
2421
2422 1989 Standard C requires this to work, and we know of only one
2423counterexample: 64-bit programs on Microsoft Windows IA-64. We will
2424leave it to those who want to port GNU programs to that environment to
2425figure out how to do it.
2426
2427 Predefined file-size types like `off_t' are an exception: they are
2428longer than `long' on many platforms, so code like the above won't work
2429with them. One way to print an `off_t' value portably is to print its
2430digits yourself, one by one.
2431
2432 Don't assume that the address of an `int' object is also the address
2433of its least-significant byte. This is false on big-endian machines.
2434Thus, don't make the following mistake:
2435
2436 int c;
2437 ...
2438 while ((c = getchar()) != EOF)
2439 write(file_descriptor, &c, 1);
2440
2441 When calling functions, you need not worry about the difference
2442between pointers of various types, or between pointers and integers.
2443On most machines, there's no difference anyway. As for the few
2444machines where there is a difference, all of them support Standard C
2445prototypes, so you can use prototypes (perhaps conditionalized to be
2446active only in Standard C) to make the code work on those systems.
2447
2448 In certain cases, it is ok to pass integer and pointer arguments
2449indiscriminately to the same function, and use no prototype on any
2450system. For example, many GNU programs have error-reporting functions
2451that pass their arguments along to `printf' and friends:
2452
2453 error (s, a1, a2, a3)
2454 char *s;
2455 char *a1, *a2, *a3;
2456 {
2457 fprintf (stderr, "error: ");
2458 fprintf (stderr, s, a1, a2, a3);
2459 }
2460
2461In practice, this works on all machines, since a pointer is generally
2462the widest possible kind of argument; it is much simpler than any
2463"correct" alternative. Be sure _not_ to use a prototype for such
2464functions.
2465
2466 If you have decided to use Standard C, then you can instead define
2467`error' using `stdarg.h', and pass the arguments along to `vfprintf'.
2468
2469 Avoid casting pointers to integers if you can. Such casts greatly
2470reduce portability, and in most programs they are easy to avoid. In the
2471cases where casting pointers to integers is essential--such as, a Lisp
2472interpreter which stores type information as well as an address in one
2473word--you'll have to make explicit provisions to handle different word
2474sizes. You will also need to make provision for systems in which the
2475normal range of addresses you can get from `malloc' starts far away
2476from zero.
2477
2478
2479File: standards.info, Node: System Functions, Next: Internationalization, Prev: CPU Portability, Up: Writing C
2480
2481Calling System Functions
2482========================
2483
2484 C implementations differ substantially. Standard C reduces but does
2485not eliminate the incompatibilities; meanwhile, many GNU packages still
2486support pre-standard compilers because this is not hard to do. This
2487chapter gives recommendations for how to use the more-or-less standard C
2488library functions to avoid unnecessary loss of portability.
2489
2490 * Don't use the return value of `sprintf'. It returns the number of
2491 characters written on some systems, but not on all systems.
2492
2493 * Be aware that `vfprintf' is not always available.
2494
2495 * `main' should be declared to return type `int'. It should
2496 terminate either by calling `exit' or by returning the integer
2497 status code; make sure it cannot ever return an undefined value.
2498
2499 * Don't declare system functions explicitly.
2500
2501 Almost any declaration for a system function is wrong on some
2502 system. To minimize conflicts, leave it to the system header
2503 files to declare system functions. If the headers don't declare a
2504 function, let it remain undeclared.
2505
2506 While it may seem unclean to use a function without declaring it,
2507 in practice this works fine for most system library functions on
2508 the systems where this really happens; thus, the disadvantage is
2509 only theoretical. By contrast, actual declarations have
2510 frequently caused actual conflicts.
2511
2512 * If you must declare a system function, don't specify the argument
2513 types. Use an old-style declaration, not a Standard C prototype.
2514 The more you specify about the function, the more likely a
2515 conflict.
2516
2517 * In particular, don't unconditionally declare `malloc' or `realloc'.
2518
2519 Most GNU programs use those functions just once, in functions
2520 conventionally named `xmalloc' and `xrealloc'. These functions
2521 call `malloc' and `realloc', respectively, and check the results.
2522
2523 Because `xmalloc' and `xrealloc' are defined in your program, you
2524 can declare them in other files without any risk of type conflict.
2525
2526 On most systems, `int' is the same length as a pointer; thus, the
2527 calls to `malloc' and `realloc' work fine. For the few
2528 exceptional systems (mostly 64-bit machines), you can use
2529 *conditionalized* declarations of `malloc' and `realloc'--or put
2530 these declarations in configuration files specific to those
2531 systems.
2532
2533 * The string functions require special treatment. Some Unix systems
2534 have a header file `string.h'; others have `strings.h'. Neither
2535 file name is portable. There are two things you can do: use
2536 Autoconf to figure out which file to include, or don't include
2537 either file.
2538
2539 * If you don't include either strings file, you can't get
2540 declarations for the string functions from the header file in the
2541 usual way.
2542
2543 That causes less of a problem than you might think. The newer
2544 standard string functions should be avoided anyway because many
2545 systems still don't support them. The string functions you can
2546 use are these:
2547
2548 strcpy strncpy strcat strncat
2549 strlen strcmp strncmp
2550 strchr strrchr
2551
2552 The copy and concatenate functions work fine without a declaration
2553 as long as you don't use their values. Using their values without
2554 a declaration fails on systems where the width of a pointer
2555 differs from the width of `int', and perhaps in other cases. It
2556 is trivial to avoid using their values, so do that.
2557
2558 The compare functions and `strlen' work fine without a declaration
2559 on most systems, possibly all the ones that GNU software runs on.
2560 You may find it necessary to declare them *conditionally* on a few
2561 systems.
2562
2563 The search functions must be declared to return `char *'. Luckily,
2564 there is no variation in the data type they return. But there is
2565 variation in their names. Some systems give these functions the
2566 names `index' and `rindex'; other systems use the names `strchr'
2567 and `strrchr'. Some systems support both pairs of names, but
2568 neither pair works on all systems.
2569
2570 You should pick a single pair of names and use it throughout your
2571 program. (Nowadays, it is better to choose `strchr' and `strrchr'
2572 for new programs, since those are the standard names.) Declare
2573 both of those names as functions returning `char *'. On systems
2574 which don't support those names, define them as macros in terms of
2575 the other pair. For example, here is what to put at the beginning
2576 of your file (or in a header) if you want to use the names
2577 `strchr' and `strrchr' throughout:
2578
2579 #ifndef HAVE_STRCHR
2580 #define strchr index
2581 #endif
2582 #ifndef HAVE_STRRCHR
2583 #define strrchr rindex
2584 #endif
2585
2586 char *strchr ();
2587 char *strrchr ();
2588
2589 Here we assume that `HAVE_STRCHR' and `HAVE_STRRCHR' are macros
2590defined in systems where the corresponding functions exist. One way to
2591get them properly defined is to use Autoconf.
2592
2593
2594File: standards.info, Node: Internationalization, Next: Mmap, Prev: System Functions, Up: Writing C
2595
2596Internationalization
2597====================
2598
2599 GNU has a library called GNU gettext that makes it easy to translate
2600the messages in a program into various languages. You should use this
2601library in every program. Use English for the messages as they appear
2602in the program, and let gettext provide the way to translate them into
2603other languages.
2604
2605 Using GNU gettext involves putting a call to the `gettext' macro
2606around each string that might need translation--like this:
2607
2608 printf (gettext ("Processing file `%s'..."));
2609
2610This permits GNU gettext to replace the string `"Processing file
2611`%s'..."' with a translated version.
2612
2613 Once a program uses gettext, please make a point of writing calls to
2614`gettext' when you add new strings that call for translation.
2615
2616 Using GNU gettext in a package involves specifying a "text domain
2617name" for the package. The text domain name is used to separate the
2618translations for this package from the translations for other packages.
2619Normally, the text domain name should be the same as the name of the
2620package--for example, `fileutils' for the GNU file utilities.
2621
2622 To enable gettext to work well, avoid writing code that makes
2623assumptions about the structure of words or sentences. When you want
2624the precise text of a sentence to vary depending on the data, use two or
2625more alternative string constants each containing a complete sentences,
2626rather than inserting conditionalized words or phrases into a single
2627sentence framework.
2628
2629 Here is an example of what not to do:
2630
2631 printf ("%d file%s processed", nfiles,
2632 nfiles != 1 ? "s" : "");
2633
2634The problem with that example is that it assumes that plurals are made
2635by adding `s'. If you apply gettext to the format string, like this,
2636
2637 printf (gettext ("%d file%s processed"), nfiles,
2638 nfiles != 1 ? "s" : "");
2639
2640the message can use different words, but it will still be forced to use
2641`s' for the plural. Here is a better way:
2642
2643 printf ((nfiles != 1 ? "%d files processed"
2644 : "%d file processed"),
2645 nfiles);
2646
2647This way, you can apply gettext to each of the two strings
2648independently:
2649
2650 printf ((nfiles != 1 ? gettext ("%d files processed")
2651 : gettext ("%d file processed")),
2652 nfiles);
2653
2654This can be any method of forming the plural of the word for "file", and
2655also handles languages that require agreement in the word for
2656"processed".
2657
2658 A similar problem appears at the level of sentence structure with
2659this code:
2660
2661 printf ("# Implicit rule search has%s been done.\n",
2662 f->tried_implicit ? "" : " not");
2663
2664Adding `gettext' calls to this code cannot give correct results for all
2665languages, because negation in some languages requires adding words at
2666more than one place in the sentence. By contrast, adding `gettext'
2667calls does the job straightfowardly if the code starts out like this:
2668
2669 printf (f->tried_implicit
2670 ? "# Implicit rule search has been done.\n",
2671 : "# Implicit rule search has not been done.\n");
2672
2673
2674File: standards.info, Node: Mmap, Prev: Internationalization, Up: Writing C
2675
2676Mmap
2677====
2678
2679 Don't assume that `mmap' either works on all files or fails for all
2680files. It may work on some files and fail on others.
2681
2682 The proper way to use `mmap' is to try it on the specific file for
2683which you want to use it--and if `mmap' doesn't work, fall back on
2684doing the job in another way using `read' and `write'.
2685
2686 The reason this precaution is needed is that the GNU kernel (the
2687HURD) provides a user-extensible file system, in which there can be many
2688different kinds of "ordinary files." Many of them support `mmap', but
2689some do not. It is important to make programs handle all these kinds
2690of files.
2691
2692
2693File: standards.info, Node: Documentation, Next: Managing Releases, Prev: Writing C, Up: Top
2694
2695Documenting Programs
2696********************
2697
2698 A GNU program should ideally come with full free documentation,
2699adequate for both reference and tutorial purposes. If the package can
2700be programmed or extended, the documentation should cover programming or
2701extending it, as well as just using it.
2702
2703* Menu:
2704
2705* GNU Manuals:: Writing proper manuals.
2706* Doc Strings and Manuals:: Compiling doc strings doesn't make a manual.
2707* Manual Structure Details:: Specific structure conventions.
2708* License for Manuals:: Writing the distribution terms for a manual.
2709* Manual Credits:: Giving credit to documentation contributors.
2710* Printed Manuals:: Mentioning the printed manual.
2711* NEWS File:: NEWS files supplement manuals.
2712* Change Logs:: Recording Changes
2713* Man Pages:: Man pages are secondary.
2714* Reading other Manuals:: How far you can go in learning
2715 from other manuals.
2716
2717
2718File: standards.info, Node: GNU Manuals, Next: Doc Strings and Manuals, Up: Documentation
2719
2720GNU Manuals
2721===========
2722
2723 The preferred document format for the GNU system is the Texinfo
2724formatting language. Every GNU package should (ideally) have
2725documentation in Texinfo both for reference and for learners. Texinfo
2726makes it possible to produce a good quality formatted book, using TeX,
2727and to generate an Info file. It is also possible to generate HTML
2728output from Texinfo source. See the Texinfo manual, either the
2729hardcopy, or the on-line version available through `info' or the Emacs
2730Info subsystem (`C-h i').
2731
2732 Nowadays some other formats such as Docbook and Sgmltexi can be
2733converted automatically into Texinfo. It is ok to produce the Texinfo
2734documentation by conversion this way, as long as it gives good results.
2735
2736 Programmers often find it most natural to structure the documentation
2737following the structure of the implementation, which they know. But
2738this structure is not necessarily good for explaining how to use the
2739program; it may be irrelevant and confusing for a user.
2740
2741 At every level, from the sentences in a paragraph to the grouping of
2742topics into separate manuals, the right way to structure documentation
2743is according to the concepts and questions that a user will have in mind
2744when reading it. Sometimes this structure of ideas matches the
2745structure of the implementation of the software being documented--but
2746often they are different. Often the most important part of learning to
2747write good documentation is learning to notice when you are structuring
2748the documentation like the implementation, and think about better
2749alternatives.
2750
2751 For example, each program in the GNU system probably ought to be
2752documented in one manual; but this does not mean each program should
2753have its own manual. That would be following the structure of the
2754implementation, rather than the structure that helps the user
2755understand.
2756
2757 Instead, each manual should cover a coherent _topic_. For example,
2758instead of a manual for `diff' and a manual for `diff3', we have one
2759manual for "comparison of files" which covers both of those programs,
2760as well as `cmp'. By documenting these programs together, we can make
2761the whole subject clearer.
2762
2763 The manual which discusses a program should certainly document all of
2764the program's command-line options and all of its commands. It should
2765give examples of their use. But don't organize the manual as a list of
2766features. Instead, organize it logically, by subtopics. Address the
2767questions that a user will ask when thinking about the job that the
2768program does.
2769
2770 In general, a GNU manual should serve both as tutorial and reference.
2771It should be set up for convenient access to each topic through Info,
2772and for reading straight through (appendixes aside). A GNU manual
2773should give a good introduction to a beginner reading through from the
2774start, and should also provide all the details that hackers want. The
2775Bison manual is a good example of this--please take a look at it to see
2776what we mean.
2777
2778 That is not as hard as it first sounds. Arrange each chapter as a
2779logical breakdown of its topic, but order the sections, and write their
2780text, so that reading the chapter straight through makes sense. Do
2781likewise when structuring the book into chapters, and when structuring a
2782section into paragraphs. The watchword is, _at each point, address the
2783most fundamental and important issue raised by the preceding text._
2784
2785 If necessary, add extra chapters at the beginning of the manual which
2786are purely tutorial and cover the basics of the subject. These provide
2787the framework for a beginner to understand the rest of the manual. The
2788Bison manual provides a good example of how to do this.
2789
2790 To serve as a reference, a manual should have an Index that list all
2791the functions, variables, options, and important concepts that are part
2792of the program. One combined Index should do for a short manual, but
2793sometimes for a complex package it is better to use multiple indices.
2794The Texinfo manual includes advice on preparing good index entries, see
2795*Note Making Index Entries: (texinfo)Index Entries, and see *Note
2796Defining the Entries of an Index: (texinfo)Indexing Commands.
2797
2798 Don't use Unix man pages as a model for how to write GNU
2799documentation; most of them are terse, badly structured, and give
2800inadequate explanation of the underlying concepts. (There are, of
2801course, some exceptions.) Also, Unix man pages use a particular format
2802which is different from what we use in GNU manuals.
2803
2804 Please include an email address in the manual for where to report
2805bugs _in the manual_.
2806
2807 Please do not use the term "pathname" that is used in Unix
2808documentation; use "file name" (two words) instead. We use the term
2809"path" only for search paths, which are lists of directory names.
2810
2811 Please do not use the term "illegal" to refer to erroneous input to a
2812computer program. Please use "invalid" for this, and reserve the term
2813"illegal" for activities punishable by law.
2814
2815
2816File: standards.info, Node: Doc Strings and Manuals, Next: Manual Structure Details, Prev: GNU Manuals, Up: Documentation
2817
2818Doc Strings and Manuals
2819=======================
2820
2821 Some programming systems, such as Emacs, provide a documentation
2822string for each function, command or variable. You may be tempted to
2823write a reference manual by compiling the documentation strings and
2824writing a little additional text to go around them--but you must not do
2825it. That approach is a fundamental mistake. The text of well-written
2826documentation strings will be entirely wrong for a manual.
2827
2828 A documentation string needs to stand alone--when it appears on the
2829screen, there will be no other text to introduce or explain it.
2830Meanwhile, it can be rather informal in style.
2831
2832 The text describing a function or variable in a manual must not stand
2833alone; it appears in the context of a section or subsection. Other text
2834at the beginning of the section should explain some of the concepts, and
2835should often make some general points that apply to several functions or
2836variables. The previous descriptions of functions and variables in the
2837section will also have given information about the topic. A description
2838written to stand alone would repeat some of that information; this
2839redundance looks bad. Meanwhile, the informality that is acceptable in
2840a documentation string is totally unacceptable in a manual.
2841
2842 The only good way to use documentation strings in writing a good
2843manual is to use them as a source of information for writing good text.
2844
2845
2846File: standards.info, Node: Manual Structure Details, Next: License for Manuals, Prev: Doc Strings and Manuals, Up: Documentation
2847
2848Manual Structure Details
2849========================
2850
2851 The title page of the manual should state the version of the
2852programs or packages documented in the manual. The Top node of the
2853manual should also contain this information. If the manual is changing
2854more frequently than or independent of the program, also state a version
2855number for the manual in both of these places.
2856
2857 Each program documented in the manual should have a node named
2858`PROGRAM Invocation' or `Invoking PROGRAM'. This node (together with
2859its subnodes, if any) should describe the program's command line
2860arguments and how to run it (the sort of information people would look
2861in a man page for). Start with an `@example' containing a template for
2862all the options and arguments that the program uses.
2863
2864 Alternatively, put a menu item in some menu whose item name fits one
2865of the above patterns. This identifies the node which that item points
2866to as the node for this purpose, regardless of the node's actual name.
2867
2868 The `--usage' feature of the Info reader looks for such a node or
2869menu item in order to find the relevant text, so it is essential for
2870every Texinfo file to have one.
2871
2872 If one manual describes several programs, it should have such a node
2873for each program described in the manual.
2874
2875
2876File: standards.info, Node: License for Manuals, Next: Manual Credits, Prev: Manual Structure Details, Up: Documentation
2877
2878License for Manuals
2879===================
2880
2881 Please use the GNU Free Documentation License for all GNU manuals
2882that are more than a few pages long. Likewise for a collection of short
2883documents--you only need one copy of the GNU FDL for the whole
2884collection. For a single short document, you can use a very permissive
2885non-copyleft license, to avoid taking up space with a long license.
2886
2887 See `http://www.gnu.org/copyleft/fdl-howto.html' for more explanation
2888of how to employ the GFDL.
2889
2890 Note that it is not obligatory to include a copy of the GNU GPL or
2891GNU LGPL in a manual whose license is neither the GPL nor the LGPL. It
2892can be a good idea to include the program's license in a large manual;
2893in a short manual, whose size would be increased considerably by
2894including the program's license, it is probably better not to include
2895it.
2896
2897
2898File: standards.info, Node: Manual Credits, Next: Printed Manuals, Prev: License for Manuals, Up: Documentation
2899
2900Manual Credits
2901==============
2902
2903 Please credit the principal human writers of the manual as the
2904authors, on the title page of the manual. If a company sponsored the
2905work, thank the company in a suitable place in the manual, but do not
2906cite the company as an author.
2907
2908
2909File: standards.info, Node: Printed Manuals, Next: NEWS File, Prev: Manual Credits, Up: Documentation
2910
2911Printed Manuals
2912===============
2913
2914 The FSF publishes some GNU manuals in printed form. To encourage
2915sales of these manuals, the on-line versions of the manual should
2916mention at the very start that the printed manual is available and
2917should point at information for getting it--for instance, with a link
2918to the page <http://www.gnu.org/order/order.html>. This should not be
2919included in the printed manual, though, because there it is redundant.
2920
2921 It is also useful to explain in the on-line forms of the manual how
2922the user can print out the manual from the sources.
2923
2924
2925File: standards.info, Node: NEWS File, Next: Change Logs, Prev: Printed Manuals, Up: Documentation
2926
2927The NEWS File
2928=============
2929
2930 In addition to its manual, the package should have a file named
2931`NEWS' which contains a list of user-visible changes worth mentioning.
2932In each new release, add items to the front of the file and identify
2933the version they pertain to. Don't discard old items; leave them in
2934the file after the newer items. This way, a user upgrading from any
2935previous version can see what is new.
2936
2937 If the `NEWS' file gets very long, move some of the older items into
2938a file named `ONEWS' and put a note at the end referring the user to
2939that file.
2940
2941
2942File: standards.info, Node: Change Logs, Next: Man Pages, Prev: NEWS File, Up: Documentation
2943
2944Change Logs
2945===========
2946
2947 Keep a change log to describe all the changes made to program source
2948files. The purpose of this is so that people investigating bugs in the
2949future will know about the changes that might have introduced the bug.
2950Often a new bug can be found by looking at what was recently changed.
2951More importantly, change logs can help you eliminate conceptual
2952inconsistencies between different parts of a program, by giving you a
2953history of how the conflicting concepts arose and who they came from.
2954
2955* Menu:
2956
2957* Change Log Concepts::
2958* Style of Change Logs::
2959* Simple Changes::
2960* Conditional Changes::
2961* Indicating the Part Changed::
2962
2963
2964File: standards.info, Node: Change Log Concepts, Next: Style of Change Logs, Up: Change Logs
2965
2966Change Log Concepts
2967-------------------
2968
2969 You can think of the change log as a conceptual "undo list" which
2970explains how earlier versions were different from the current version.
2971People can see the current version; they don't need the change log to
2972tell them what is in it. What they want from a change log is a clear
2973explanation of how the earlier version differed.
2974
2975 The change log file is normally called `ChangeLog' and covers an
2976entire directory. Each directory can have its own change log, or a
2977directory can use the change log of its parent directory-it's up to you.
2978
2979 Another alternative is to record change log information with a
2980version control system such as RCS or CVS. This can be converted
2981automatically to a `ChangeLog' file using `rcs2log'; in Emacs, the
2982command `C-x v a' (`vc-update-change-log') does the job.
2983
2984 There's no need to describe the full purpose of the changes or how
2985they work together. If you think that a change calls for explanation,
2986you're probably right. Please do explain it--but please put the
2987explanation in comments in the code, where people will see it whenever
2988they see the code. For example, "New function" is enough for the
2989change log when you add a function, because there should be a comment
2990before the function definition to explain what it does.
2991
2992 However, sometimes it is useful to write one line to describe the
2993overall purpose of a batch of changes.
2994
2995 The easiest way to add an entry to `ChangeLog' is with the Emacs
2996command `M-x add-change-log-entry'. An entry should have an asterisk,
2997the name of the changed file, and then in parentheses the name of the
2998changed functions, variables or whatever, followed by a colon. Then
2999describe the changes you made to that function or variable.
3000
3001
3002File: standards.info, Node: Style of Change Logs, Next: Simple Changes, Prev: Change Log Concepts, Up: Change Logs
3003
3004Style of Change Logs
3005--------------------
3006
3007 Here are some simple examples of change log entries, starting with
3008the header line that says who made the change and when, followed by
3009descriptions of specific changes. (These examples are drawn from Emacs
3010and GCC.)
3011
3012 1998-08-17 Richard Stallman <rms@gnu.org>
3013
3014 * register.el (insert-register): Return nil.
3015 (jump-to-register): Likewise.
3016
3017 * sort.el (sort-subr): Return nil.
3018
3019 * tex-mode.el (tex-bibtex-file, tex-file, tex-region):
3020 Restart the tex shell if process is gone or stopped.
3021 (tex-shell-running): New function.
3022
3023 * expr.c (store_one_arg): Round size up for move_block_to_reg.
3024 (expand_call): Round up when emitting USE insns.
3025 * stmt.c (assign_parms): Round size up for move_block_from_reg.
3026
3027 It's important to name the changed function or variable in full.
3028Don't abbreviate function or variable names, and don't combine them.
3029Subsequent maintainers will often search for a function name to find all
3030the change log entries that pertain to it; if you abbreviate the name,
3031they won't find it when they search.
3032
3033 For example, some people are tempted to abbreviate groups of function
3034names by writing `* register.el ({insert,jump-to}-register)'; this is
3035not a good idea, since searching for `jump-to-register' or
3036`insert-register' would not find that entry.
3037
3038 Separate unrelated change log entries with blank lines. When two
3039entries represent parts of the same change, so that they work together,
3040then don't put blank lines between them. Then you can omit the file
3041name and the asterisk when successive entries are in the same file.
3042
3043 Break long lists of function names by closing continued lines with
3044`)', rather than `,', and opening the continuation with `(' as in this
3045example:
3046
3047 * keyboard.c (menu_bar_items, tool_bar_items)
3048 (Fexecute_extended_command): Deal with `keymap' property.
3049
3050
3051File: standards.info, Node: Simple Changes, Next: Conditional Changes, Prev: Style of Change Logs, Up: Change Logs
3052
3053Simple Changes
3054--------------
3055
3056 Certain simple kinds of changes don't need much detail in the change
3057log.
3058
3059 When you change the calling sequence of a function in a simple
3060fashion, and you change all the callers of the function to use the new
3061calling sequence, there is no need to make individual entries for all
3062the callers that you changed. Just write in the entry for the function
3063being called, "All callers changed"--like this:
3064
3065 * keyboard.c (Fcommand_execute): New arg SPECIAL.
3066 All callers changed.
3067
3068 When you change just comments or doc strings, it is enough to write
3069an entry for the file, without mentioning the functions. Just "Doc
3070fixes" is enough for the change log.
3071
3072 There's no need to make change log entries for documentation files.
3073This is because documentation is not susceptible to bugs that are hard
3074to fix. Documentation does not consist of parts that must interact in a
3075precisely engineered fashion. To correct an error, you need not know
3076the history of the erroneous passage; it is enough to compare what the
3077documentation says with the way the program actually works.
3078
3079
3080File: standards.info, Node: Conditional Changes, Next: Indicating the Part Changed, Prev: Simple Changes, Up: Change Logs
3081
3082Conditional Changes
3083-------------------
3084
3085 C programs often contain compile-time `#if' conditionals. Many
3086changes are conditional; sometimes you add a new definition which is
3087entirely contained in a conditional. It is very useful to indicate in
3088the change log the conditions for which the change applies.
3089
3090 Our convention for indicating conditional changes is to use square
3091brackets around the name of the condition.
3092
3093 Here is a simple example, describing a change which is conditional
3094but does not have a function or entity name associated with it:
3095
3096 * xterm.c [SOLARIS2]: Include string.h.
3097
3098 Here is an entry describing a new definition which is entirely
3099conditional. This new definition for the macro `FRAME_WINDOW_P' is
3100used only when `HAVE_X_WINDOWS' is defined:
3101
3102 * frame.h [HAVE_X_WINDOWS] (FRAME_WINDOW_P): Macro defined.
3103
3104 Here is an entry for a change within the function `init_display',
3105whose definition as a whole is unconditional, but the changes themselves
3106are contained in a `#ifdef HAVE_LIBNCURSES' conditional:
3107
3108 * dispnew.c (init_display) [HAVE_LIBNCURSES]: If X, call tgetent.
3109
3110 Here is an entry for a change that takes affect only when a certain
3111macro is _not_ defined:
3112
3113 (gethostname) [!HAVE_SOCKETS]: Replace with winsock version.
3114
3115
3116File: standards.info, Node: Indicating the Part Changed, Prev: Conditional Changes, Up: Change Logs
3117
3118Indicating the Part Changed
3119---------------------------
3120
3121 Indicate the part of a function which changed by using angle brackets
3122enclosing an indication of what the changed part does. Here is an entry
3123for a change in the part of the function `sh-while-getopts' that deals
3124with `sh' commands:
3125
3126 * progmodes/sh-script.el (sh-while-getopts) <sh>: Handle case that
3127 user-specified option string is empty.
3128
3129
3130File: standards.info, Node: Man Pages, Next: Reading other Manuals, Prev: Change Logs, Up: Documentation
3131
3132Man Pages
3133=========
3134
3135 In the GNU project, man pages are secondary. It is not necessary or
3136expected for every GNU program to have a man page, but some of them do.
3137It's your choice whether to include a man page in your program.
3138
3139 When you make this decision, consider that supporting a man page
3140requires continual effort each time the program is changed. The time
3141you spend on the man page is time taken away from more useful work.
3142
3143 For a simple program which changes little, updating the man page may
3144be a small job. Then there is little reason not to include a man page,
3145if you have one.
3146
3147 For a large program that changes a great deal, updating a man page
3148may be a substantial burden. If a user offers to donate a man page,
3149you may find this gift costly to accept. It may be better to refuse
3150the man page unless the same person agrees to take full responsibility
3151for maintaining it--so that you can wash your hands of it entirely. If
3152this volunteer later ceases to do the job, then don't feel obliged to
3153pick it up yourself; it may be better to withdraw the man page from the
3154distribution until someone else agrees to update it.
3155
3156 When a program changes only a little, you may feel that the
3157discrepancies are small enough that the man page remains useful without
3158updating. If so, put a prominent note near the beginning of the man
3159page explaining that you don't maintain it and that the Texinfo manual
3160is more authoritative. The note should say how to access the Texinfo
3161documentation.
3162
3163
3164File: standards.info, Node: Reading other Manuals, Prev: Man Pages, Up: Documentation
3165
3166Reading other Manuals
3167=====================
3168
3169 There may be non-free books or documentation files that describe the
3170program you are documenting.
3171
3172 It is ok to use these documents for reference, just as the author of
3173a new algebra textbook can read other books on algebra. A large portion
3174of any non-fiction book consists of facts, in this case facts about how
3175a certain program works, and these facts are necessarily the same for
3176everyone who writes about the subject. But be careful not to copy your
3177outline structure, wording, tables or examples from preexisting non-free
3178documentation. Copying from free documentation may be ok; please check
3179with the FSF about the individual case.
3180
3181
3182File: standards.info, Node: Managing Releases, Next: References, Prev: Documentation, Up: Top
3183
3184The Release Process
3185*******************
3186
3187 Making a release is more than just bundling up your source files in a
3188tar file and putting it up for FTP. You should set up your software so
3189that it can be configured to run on a variety of systems. Your Makefile
3190should conform to the GNU standards described below, and your directory
3191layout should also conform to the standards discussed below. Doing so
3192makes it easy to include your package into the larger framework of all
3193GNU software.
3194
3195* Menu:
3196
3197* Configuration:: How Configuration Should Work
3198* Makefile Conventions:: Makefile Conventions
3199* Releases:: Making Releases
3200
3201
3202File: standards.info, Node: Configuration, Next: Makefile Conventions, Up: Managing Releases
3203
3204How Configuration Should Work
3205=============================
3206
3207 Each GNU distribution should come with a shell script named
3208`configure'. This script is given arguments which describe the kind of
3209machine and system you want to compile the program for.
3210
3211 The `configure' script must record the configuration options so that
3212they affect compilation.
3213
3214 One way to do this is to make a link from a standard name such as
3215`config.h' to the proper configuration file for the chosen system. If
3216you use this technique, the distribution should _not_ contain a file
3217named `config.h'. This is so that people won't be able to build the
3218program without configuring it first.
3219
3220 Another thing that `configure' can do is to edit the Makefile. If
3221you do this, the distribution should _not_ contain a file named
3222`Makefile'. Instead, it should include a file `Makefile.in' which
3223contains the input used for editing. Once again, this is so that people
3224won't be able to build the program without configuring it first.
3225
3226 If `configure' does write the `Makefile', then `Makefile' should
3227have a target named `Makefile' which causes `configure' to be rerun,
3228setting up the same configuration that was set up last time. The files
3229that `configure' reads should be listed as dependencies of `Makefile'.
3230
3231 All the files which are output from the `configure' script should
3232have comments at the beginning explaining that they were generated
3233automatically using `configure'. This is so that users won't think of
3234trying to edit them by hand.
3235
3236 The `configure' script should write a file named `config.status'
3237which describes which configuration options were specified when the
3238program was last configured. This file should be a shell script which,
3239if run, will recreate the same configuration.
3240
3241 The `configure' script should accept an option of the form
3242`--srcdir=DIRNAME' to specify the directory where sources are found (if
3243it is not the current directory). This makes it possible to build the
3244program in a separate directory, so that the actual source directory is
3245not modified.
3246
3247 If the user does not specify `--srcdir', then `configure' should
3248check both `.' and `..' to see if it can find the sources. If it finds
3249the sources in one of these places, it should use them from there.
3250Otherwise, it should report that it cannot find the sources, and should
3251exit with nonzero status.
3252
3253 Usually the easy way to support `--srcdir' is by editing a
3254definition of `VPATH' into the Makefile. Some rules may need to refer
3255explicitly to the specified source directory. To make this possible,
3256`configure' can add to the Makefile a variable named `srcdir' whose
3257value is precisely the specified directory.
3258
3259 The `configure' script should also take an argument which specifies
3260the type of system to build the program for. This argument should look
3261like this:
3262
3263 CPU-COMPANY-SYSTEM
3264
3265 For example, a Sun 3 might be `m68k-sun-sunos4.1'.
3266
3267 The `configure' script needs to be able to decode all plausible
3268alternatives for how to describe a machine. Thus, `sun3-sunos4.1'
3269would be a valid alias. For many programs, `vax-dec-ultrix' would be
3270an alias for `vax-dec-bsd', simply because the differences between
3271Ultrix and BSD are rarely noticeable, but a few programs might need to
3272distinguish them.
3273
3274 There is a shell script called `config.sub' that you can use as a
3275subroutine to validate system types and canonicalize aliases.
3276
3277 Other options are permitted to specify in more detail the software
3278or hardware present on the machine, and include or exclude optional
3279parts of the package:
3280
3281`--enable-FEATURE[=PARAMETER]'
3282 Configure the package to build and install an optional user-level
3283 facility called FEATURE. This allows users to choose which
3284 optional features to include. Giving an optional PARAMETER of
3285 `no' should omit FEATURE, if it is built by default.
3286
3287 No `--enable' option should *ever* cause one feature to replace
3288 another. No `--enable' option should ever substitute one useful
3289 behavior for another useful behavior. The only proper use for
3290 `--enable' is for questions of whether to build part of the program
3291 or exclude it.
3292
3293`--with-PACKAGE'
3294 The package PACKAGE will be installed, so configure this package
3295 to work with PACKAGE.
3296
3297 Possible values of PACKAGE include `gnu-as' (or `gas'), `gnu-ld',
3298 `gnu-libc', `gdb', `x', and `x-toolkit'.
3299
3300 Do not use a `--with' option to specify the file name to use to
3301 find certain files. That is outside the scope of what `--with'
3302 options are for.
3303
3304 All `configure' scripts should accept all of these "detail" options,
3305whether or not they make any difference to the particular package at
3306hand. In particular, they should accept any option that starts with
3307`--with-' or `--enable-'. This is so users will be able to configure
3308an entire GNU source tree at once with a single set of options.
3309
3310 You will note that the categories `--with-' and `--enable-' are
3311narrow: they *do not* provide a place for any sort of option you might
3312think of. That is deliberate. We want to limit the possible
3313configuration options in GNU software. We do not want GNU programs to
3314have idiosyncratic configuration options.
3315
3316 Packages that perform part of the compilation process may support
3317cross-compilation. In such a case, the host and target machines for the
3318program may be different.
3319
3320 The `configure' script should normally treat the specified type of
3321system as both the host and the target, thus producing a program which
3322works for the same type of machine that it runs on.
3323
3324 To configure a cross-compiler, cross-assembler, or what have you, you
3325should specify a target different from the host, using the configure
3326option `--target=TARGETTYPE'. The syntax for TARGETTYPE is the same as
3327for the host type. So the command would look like this:
3328
3329 ./configure HOSTTYPE --target=TARGETTYPE
3330
3331 Programs for which cross-operation is not meaningful need not accept
3332the `--target' option, because configuring an entire operating system
3333for cross-operation is not a meaningful operation.
3334
3335 Bootstrapping a cross-compiler requires compiling it on a machine
3336other than the host it will run on. Compilation packages accept a
3337configuration option `--build=BUILDTYPE' for specifying the
3338configuration on which you will compile them, but the configure script
3339should normally guess the build machine type (using `config.guess'), so
3340this option is probably not necessary. The host and target types
3341normally default from the build type, so in bootstrapping a
3342cross-compiler you must specify them both explicitly.
3343
3344 Some programs have ways of configuring themselves automatically. If
3345your program is set up to do this, your `configure' script can simply
3346ignore most of its arguments.
3347
3348
3349File: standards.info, Node: Makefile Conventions, Next: Releases, Prev: Configuration, Up: Managing Releases
3350
3351Makefile Conventions
3352====================
3353
3354 This node describes conventions for writing the Makefiles for GNU
3355programs. Using Automake will help you write a Makefile that follows
3356these conventions.
3357
3358* Menu:
3359
3360* Makefile Basics:: General Conventions for Makefiles
3361* Utilities in Makefiles:: Utilities in Makefiles
3362* Command Variables:: Variables for Specifying Commands
3363* Directory Variables:: Variables for Installation Directories
3364* Standard Targets:: Standard Targets for Users
3365* Install Command Categories:: Three categories of commands in the `install'
3366 rule: normal, pre-install and post-install.
3367
3368
3369File: standards.info, Node: Makefile Basics, Next: Utilities in Makefiles, Up: Makefile Conventions
3370
3371General Conventions for Makefiles
3372---------------------------------
3373
3374 Every Makefile should contain this line:
3375
3376 SHELL = /bin/sh
3377
3378to avoid trouble on systems where the `SHELL' variable might be
3379inherited from the environment. (This is never a problem with GNU
3380`make'.)
3381
3382 Different `make' programs have incompatible suffix lists and
3383implicit rules, and this sometimes creates confusion or misbehavior. So
3384it is a good idea to set the suffix list explicitly using only the
3385suffixes you need in the particular Makefile, like this:
3386
3387 .SUFFIXES:
3388 .SUFFIXES: .c .o
3389
3390The first line clears out the suffix list, the second introduces all
3391suffixes which may be subject to implicit rules in this Makefile.
3392
3393 Don't assume that `.' is in the path for command execution. When
3394you need to run programs that are a part of your package during the
3395make, please make sure that it uses `./' if the program is built as
3396part of the make or `$(srcdir)/' if the file is an unchanging part of
3397the source code. Without one of these prefixes, the current search
3398path is used.
3399
3400 The distinction between `./' (the "build directory") and
3401`$(srcdir)/' (the "source directory") is important because users can
3402build in a separate directory using the `--srcdir' option to
3403`configure'. A rule of the form:
3404
3405 foo.1 : foo.man sedscript
3406 sed -e sedscript foo.man > foo.1
3407
3408will fail when the build directory is not the source directory, because
3409`foo.man' and `sedscript' are in the source directory.
3410
3411 When using GNU `make', relying on `VPATH' to find the source file
3412will work in the case where there is a single dependency file, since
3413the `make' automatic variable `$<' will represent the source file
3414wherever it is. (Many versions of `make' set `$<' only in implicit
3415rules.) A Makefile target like
3416
3417 foo.o : bar.c
3418 $(CC) -I. -I$(srcdir) $(CFLAGS) -c bar.c -o foo.o
3419
3420should instead be written as
3421
3422 foo.o : bar.c
3423 $(CC) -I. -I$(srcdir) $(CFLAGS) -c $< -o $@
3424
3425in order to allow `VPATH' to work correctly. When the target has
3426multiple dependencies, using an explicit `$(srcdir)' is the easiest way
3427to make the rule work well. For example, the target above for `foo.1'
3428is best written as:
3429
3430 foo.1 : foo.man sedscript
3431 sed -e $(srcdir)/sedscript $(srcdir)/foo.man > $@
3432
3433 GNU distributions usually contain some files which are not source
3434files--for example, Info files, and the output from Autoconf, Automake,
3435Bison or Flex. Since these files normally appear in the source
3436directory, they should always appear in the source directory, not in the
3437build directory. So Makefile rules to update them should put the
3438updated files in the source directory.
3439
3440 However, if a file does not appear in the distribution, then the
3441Makefile should not put it in the source directory, because building a
3442program in ordinary circumstances should not modify the source directory
3443in any way.
3444
3445 Try to make the build and installation targets, at least (and all
3446their subtargets) work correctly with a parallel `make'.
3447
3448
3449File: standards.info, Node: Utilities in Makefiles, Next: Command Variables, Prev: Makefile Basics, Up: Makefile Conventions
3450
3451Utilities in Makefiles
3452----------------------
3453
3454 Write the Makefile commands (and any shell scripts, such as
3455`configure') to run in `sh', not in `csh'. Don't use any special
3456features of `ksh' or `bash'.
3457
3458 The `configure' script and the Makefile rules for building and
3459installation should not use any utilities directly except these:
3460
3461 cat cmp cp diff echo egrep expr false grep install-info
3462 ln ls mkdir mv pwd rm rmdir sed sleep sort tar test touch true
3463
3464 The compression program `gzip' can be used in the `dist' rule.
3465
3466 Stick to the generally supported options for these programs. For
3467example, don't use `mkdir -p', convenient as it may be, because most
3468systems don't support it.
3469
3470 It is a good idea to avoid creating symbolic links in makefiles,
3471since a few systems don't support them.
3472
3473 The Makefile rules for building and installation can also use
3474compilers and related programs, but should do so via `make' variables
3475so that the user can substitute alternatives. Here are some of the
3476programs we mean:
3477
3478 ar bison cc flex install ld ldconfig lex
3479 make makeinfo ranlib texi2dvi yacc
3480
3481 Use the following `make' variables to run those programs:
3482
3483 $(AR) $(BISON) $(CC) $(FLEX) $(INSTALL) $(LD) $(LDCONFIG) $(LEX)
3484 $(MAKE) $(MAKEINFO) $(RANLIB) $(TEXI2DVI) $(YACC)
3485
3486 When you use `ranlib' or `ldconfig', you should make sure nothing
3487bad happens if the system does not have the program in question.
3488Arrange to ignore an error from that command, and print a message before
3489the command to tell the user that failure of this command does not mean
3490a problem. (The Autoconf `AC_PROG_RANLIB' macro can help with this.)
3491
3492 If you use symbolic links, you should implement a fallback for
3493systems that don't have symbolic links.
3494
3495 Additional utilities that can be used via Make variables are:
3496
3497 chgrp chmod chown mknod
3498
3499 It is ok to use other utilities in Makefile portions (or scripts)
3500intended only for particular systems where you know those utilities
3501exist.
3502
3503
3504File: standards.info, Node: Command Variables, Next: Directory Variables, Prev: Utilities in Makefiles, Up: Makefile Conventions
3505
3506Variables for Specifying Commands
3507---------------------------------
3508
3509 Makefiles should provide variables for overriding certain commands,
3510options, and so on.
3511
3512 In particular, you should run most utility programs via variables.
3513Thus, if you use Bison, have a variable named `BISON' whose default
3514value is set with `BISON = bison', and refer to it with `$(BISON)'
3515whenever you need to use Bison.
3516
3517 File management utilities such as `ln', `rm', `mv', and so on, need
3518not be referred to through variables in this way, since users don't
3519need to replace them with other programs.
3520
3521 Each program-name variable should come with an options variable that
3522is used to supply options to the program. Append `FLAGS' to the
3523program-name variable name to get the options variable name--for
3524example, `BISONFLAGS'. (The names `CFLAGS' for the C compiler,
3525`YFLAGS' for yacc, and `LFLAGS' for lex, are exceptions to this rule,
3526but we keep them because they are standard.) Use `CPPFLAGS' in any
3527compilation command that runs the preprocessor, and use `LDFLAGS' in
3528any compilation command that does linking as well as in any direct use
3529of `ld'.
3530
3531 If there are C compiler options that _must_ be used for proper
3532compilation of certain files, do not include them in `CFLAGS'. Users
3533expect to be able to specify `CFLAGS' freely themselves. Instead,
3534arrange to pass the necessary options to the C compiler independently
3535of `CFLAGS', by writing them explicitly in the compilation commands or
3536by defining an implicit rule, like this:
3537
3538 CFLAGS = -g
3539 ALL_CFLAGS = -I. $(CFLAGS)
3540 .c.o:
3541 $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $<
3542
3543 Do include the `-g' option in `CFLAGS', because that is not
3544_required_ for proper compilation. You can consider it a default that
3545is only recommended. If the package is set up so that it is compiled
3546with GCC by default, then you might as well include `-O' in the default
3547value of `CFLAGS' as well.
3548
3549 Put `CFLAGS' last in the compilation command, after other variables
3550containing compiler options, so the user can use `CFLAGS' to override
3551the others.
3552
3553 `CFLAGS' should be used in every invocation of the C compiler, both
3554those which do compilation and those which do linking.
3555
3556 Every Makefile should define the variable `INSTALL', which is the
3557basic command for installing a file into the system.
3558
3559 Every Makefile should also define the variables `INSTALL_PROGRAM'
3560and `INSTALL_DATA'. (The default for `INSTALL_PROGRAM' should be
3561`$(INSTALL)'; the default for `INSTALL_DATA' should be `${INSTALL} -m
3562644'.) Then it should use those variables as the commands for actual
3563installation, for executables and nonexecutables respectively. Use
3564these variables as follows:
3565
3566 $(INSTALL_PROGRAM) foo $(bindir)/foo
3567 $(INSTALL_DATA) libfoo.a $(libdir)/libfoo.a
3568
3569 Optionally, you may prepend the value of `DESTDIR' to the target
3570filename. Doing this allows the installer to create a snapshot of the
3571installation to be copied onto the real target filesystem later. Do not
3572set the value of `DESTDIR' in your Makefile, and do not include it in
3573any installed files. With support for `DESTDIR', the above examples
3574become:
3575
3576 $(INSTALL_PROGRAM) foo $(DESTDIR)$(bindir)/foo
3577 $(INSTALL_DATA) libfoo.a $(DESTDIR)$(libdir)/libfoo.a
3578
3579Always use a file name, not a directory name, as the second argument of
3580the installation commands. Use a separate command for each file to be
3581installed.
3582
3583
3584File: standards.info, Node: Directory Variables, Next: Standard Targets, Prev: Command Variables, Up: Makefile Conventions
3585
3586Variables for Installation Directories
3587--------------------------------------
3588
3589 Installation directories should always be named by variables, so it
3590is easy to install in a nonstandard place. The standard names for these
3591variables are described below. They are based on a standard filesystem
3592layout; variants of it are used in SVR4, 4.4BSD, GNU/Linux, Ultrix v4,
3593and other modern operating systems.
3594
3595 These two variables set the root for the installation. All the other
3596installation directories should be subdirectories of one of these two,
3597and nothing should be directly installed into these two directories.
3598
3599`prefix'
3600 A prefix used in constructing the default values of the variables
3601 listed below. The default value of `prefix' should be
3602 `/usr/local'. When building the complete GNU system, the prefix
3603 will be empty and `/usr' will be a symbolic link to `/'. (If you
3604 are using Autoconf, write it as `@prefix@'.)
3605
3606 Running `make install' with a different value of `prefix' from the
3607 one used to build the program should _not_ recompile the program.
3608
3609`exec_prefix'
3610 A prefix used in constructing the default values of some of the
3611 variables listed below. The default value of `exec_prefix' should
3612 be `$(prefix)'. (If you are using Autoconf, write it as
3613 `@exec_prefix@'.)
3614
3615 Generally, `$(exec_prefix)' is used for directories that contain
3616 machine-specific files (such as executables and subroutine
3617 libraries), while `$(prefix)' is used directly for other
3618 directories.
3619
3620 Running `make install' with a different value of `exec_prefix'
3621 from the one used to build the program should _not_ recompile the
3622 program.
3623
3624 Executable programs are installed in one of the following
3625directories.
3626
3627`bindir'
3628 The directory for installing executable programs that users can
3629 run. This should normally be `/usr/local/bin', but write it as
3630 `$(exec_prefix)/bin'. (If you are using Autoconf, write it as
3631 `@bindir@'.)
3632
3633`sbindir'
3634 The directory for installing executable programs that can be run
3635 from the shell, but are only generally useful to system
3636 administrators. This should normally be `/usr/local/sbin', but
3637 write it as `$(exec_prefix)/sbin'. (If you are using Autoconf,
3638 write it as `@sbindir@'.)
3639
3640`libexecdir'
3641 The directory for installing executable programs to be run by other
3642 programs rather than by users. This directory should normally be
3643 `/usr/local/libexec', but write it as `$(exec_prefix)/libexec'.
3644 (If you are using Autoconf, write it as `@libexecdir@'.)
3645
3646 Data files used by the program during its execution are divided into
3647categories in two ways.
3648
3649 * Some files are normally modified by programs; others are never
3650 normally modified (though users may edit some of these).
3651
3652 * Some files are architecture-independent and can be shared by all
3653 machines at a site; some are architecture-dependent and can be
3654 shared only by machines of the same kind and operating system;
3655 others may never be shared between two machines.
3656
3657 This makes for six different possibilities. However, we want to
3658discourage the use of architecture-dependent files, aside from object
3659files and libraries. It is much cleaner to make other data files
3660architecture-independent, and it is generally not hard.
3661
3662 Therefore, here are the variables Makefiles should use to specify
3663directories:
3664
3665`datadir'
3666 The directory for installing read-only architecture independent
3667 data files. This should normally be `/usr/local/share', but write
3668 it as `$(prefix)/share'. (If you are using Autoconf, write it as
3669 `@datadir@'.) As a special exception, see `$(infodir)' and
3670 `$(includedir)' below.
3671
3672`sysconfdir'
3673 The directory for installing read-only data files that pertain to a
3674 single machine-that is to say, files for configuring a host.
3675 Mailer and network configuration files, `/etc/passwd', and so
3676 forth belong here. All the files in this directory should be
3677 ordinary ASCII text files. This directory should normally be
3678 `/usr/local/etc', but write it as `$(prefix)/etc'. (If you are
3679 using Autoconf, write it as `@sysconfdir@'.)
3680
3681 Do not install executables here in this directory (they probably
3682 belong in `$(libexecdir)' or `$(sbindir)'). Also do not install
3683 files that are modified in the normal course of their use (programs
3684 whose purpose is to change the configuration of the system
3685 excluded). Those probably belong in `$(localstatedir)'.
3686
3687`sharedstatedir'
3688 The directory for installing architecture-independent data files
3689 which the programs modify while they run. This should normally be
3690 `/usr/local/com', but write it as `$(prefix)/com'. (If you are
3691 using Autoconf, write it as `@sharedstatedir@'.)
3692
3693`localstatedir'
3694 The directory for installing data files which the programs modify
3695 while they run, and that pertain to one specific machine. Users
3696 should never need to modify files in this directory to configure
3697 the package's operation; put such configuration information in
3698 separate files that go in `$(datadir)' or `$(sysconfdir)'.
3699 `$(localstatedir)' should normally be `/usr/local/var', but write
3700 it as `$(prefix)/var'. (If you are using Autoconf, write it as
3701 `@localstatedir@'.)
3702
3703`libdir'
3704 The directory for object files and libraries of object code. Do
3705 not install executables here, they probably ought to go in
3706 `$(libexecdir)' instead. The value of `libdir' should normally be
3707 `/usr/local/lib', but write it as `$(exec_prefix)/lib'. (If you
3708 are using Autoconf, write it as `@libdir@'.)
3709
3710`infodir'
3711 The directory for installing the Info files for this package. By
3712 default, it should be `/usr/local/info', but it should be written
3713 as `$(prefix)/info'. (If you are using Autoconf, write it as
3714 `@infodir@'.)
3715
3716`lispdir'
3717 The directory for installing any Emacs Lisp files in this package.
3718 By default, it should be `/usr/local/share/emacs/site-lisp', but
3719 it should be written as `$(prefix)/share/emacs/site-lisp'.
3720
3721 If you are using Autoconf, write the default as `@lispdir@'. In
3722 order to make `@lispdir@' work, you need the following lines in
3723 your `configure.in' file:
3724
3725 lispdir='${datadir}/emacs/site-lisp'
3726 AC_SUBST(lispdir)
3727
3728`includedir'
3729 The directory for installing header files to be included by user
3730 programs with the C `#include' preprocessor directive. This
3731 should normally be `/usr/local/include', but write it as
3732 `$(prefix)/include'. (If you are using Autoconf, write it as
3733 `@includedir@'.)
3734
3735 Most compilers other than GCC do not look for header files in
3736 directory `/usr/local/include'. So installing the header files
3737 this way is only useful with GCC. Sometimes this is not a problem
3738 because some libraries are only really intended to work with GCC.
3739 But some libraries are intended to work with other compilers.
3740 They should install their header files in two places, one
3741 specified by `includedir' and one specified by `oldincludedir'.
3742
3743`oldincludedir'
3744 The directory for installing `#include' header files for use with
3745 compilers other than GCC. This should normally be `/usr/include'.
3746 (If you are using Autoconf, you can write it as `@oldincludedir@'.)
3747
3748 The Makefile commands should check whether the value of
3749 `oldincludedir' is empty. If it is, they should not try to use
3750 it; they should cancel the second installation of the header files.
3751
3752 A package should not replace an existing header in this directory
3753 unless the header came from the same package. Thus, if your Foo
3754 package provides a header file `foo.h', then it should install the
3755 header file in the `oldincludedir' directory if either (1) there
3756 is no `foo.h' there or (2) the `foo.h' that exists came from the
3757 Foo package.
3758
3759 To tell whether `foo.h' came from the Foo package, put a magic
3760 string in the file--part of a comment--and `grep' for that string.
3761
3762 Unix-style man pages are installed in one of the following:
3763
3764`mandir'
3765 The top-level directory for installing the man pages (if any) for
3766 this package. It will normally be `/usr/local/man', but you should
3767 write it as `$(prefix)/man'. (If you are using Autoconf, write it
3768 as `@mandir@'.)
3769
3770`man1dir'
3771 The directory for installing section 1 man pages. Write it as
3772 `$(mandir)/man1'.
3773
3774`man2dir'
3775 The directory for installing section 2 man pages. Write it as
3776 `$(mandir)/man2'
3777
3778`...'
3779 *Don't make the primary documentation for any GNU software be a
3780 man page. Write a manual in Texinfo instead. Man pages are just
3781 for the sake of people running GNU software on Unix, which is a
3782 secondary application only.*
3783
3784`manext'
3785 The file name extension for the installed man page. This should
3786 contain a period followed by the appropriate digit; it should
3787 normally be `.1'.
3788
3789`man1ext'
3790 The file name extension for installed section 1 man pages.
3791
3792`man2ext'
3793 The file name extension for installed section 2 man pages.
3794
3795`...'
3796 Use these names instead of `manext' if the package needs to
3797 install man pages in more than one section of the manual.
3798
3799 And finally, you should set the following variable:
3800
3801`srcdir'
3802 The directory for the sources being compiled. The value of this
3803 variable is normally inserted by the `configure' shell script.
3804 (If you are using Autconf, use `srcdir = @srcdir@'.)
3805
3806 For example:
3807
3808 # Common prefix for installation directories.
3809 # NOTE: This directory must exist when you start the install.
3810 prefix = /usr/local
3811 exec_prefix = $(prefix)
3812 # Where to put the executable for the command `gcc'.
3813 bindir = $(exec_prefix)/bin
3814 # Where to put the directories used by the compiler.
3815 libexecdir = $(exec_prefix)/libexec
3816 # Where to put the Info files.
3817 infodir = $(prefix)/info
3818
3819 If your program installs a large number of files into one of the
3820standard user-specified directories, it might be useful to group them
3821into a subdirectory particular to that program. If you do this, you
3822should write the `install' rule to create these subdirectories.
3823
3824 Do not expect the user to include the subdirectory name in the value
3825of any of the variables listed above. The idea of having a uniform set
3826of variable names for installation directories is to enable the user to
3827specify the exact same values for several different GNU packages. In
3828order for this to be useful, all the packages must be designed so that
3829they will work sensibly when the user does so.
3830
3831
3832File: standards.info, Node: Standard Targets, Next: Install Command Categories, Prev: Directory Variables, Up: Makefile Conventions
3833
3834Standard Targets for Users
3835--------------------------
3836
3837 All GNU programs should have the following targets in their
3838Makefiles:
3839
3840`all'
3841 Compile the entire program. This should be the default target.
3842 This target need not rebuild any documentation files; Info files
3843 should normally be included in the distribution, and DVI files
3844 should be made only when explicitly asked for.
3845
3846 By default, the Make rules should compile and link with `-g', so
3847 that executable programs have debugging symbols. Users who don't
3848 mind being helpless can strip the executables later if they wish.
3849
3850`install'
3851 Compile the program and copy the executables, libraries, and so on
3852 to the file names where they should reside for actual use. If
3853 there is a simple test to verify that a program is properly
3854 installed, this target should run that test.
3855
3856 Do not strip executables when installing them. Devil-may-care
3857 users can use the `install-strip' target to do that.
3858
3859 If possible, write the `install' target rule so that it does not
3860 modify anything in the directory where the program was built,
3861 provided `make all' has just been done. This is convenient for
3862 building the program under one user name and installing it under
3863 another.
3864
3865 The commands should create all the directories in which files are
3866 to be installed, if they don't already exist. This includes the
3867 directories specified as the values of the variables `prefix' and
3868 `exec_prefix', as well as all subdirectories that are needed. One
3869 way to do this is by means of an `installdirs' target as described
3870 below.
3871
3872 Use `-' before any command for installing a man page, so that
3873 `make' will ignore any errors. This is in case there are systems
3874 that don't have the Unix man page documentation system installed.
3875
3876 The way to install Info files is to copy them into `$(infodir)'
3877 with `$(INSTALL_DATA)' (*note Command Variables::), and then run
3878 the `install-info' program if it is present. `install-info' is a
3879 program that edits the Info `dir' file to add or update the menu
3880 entry for the given Info file; it is part of the Texinfo package.
3881 Here is a sample rule to install an Info file:
3882
3883 $(DESTDIR)$(infodir)/foo.info: foo.info
3884 $(POST_INSTALL)
3885 # There may be a newer info file in . than in srcdir.
3886 -if test -f foo.info; then d=.; \
3887 else d=$(srcdir); fi; \
3888 $(INSTALL_DATA) $$d/foo.info $(DESTDIR)$@; \
3889 # Run install-info only if it exists.
3890 # Use `if' instead of just prepending `-' to the
3891 # line so we notice real errors from install-info.
3892 # We use `$(SHELL) -c' because some shells do not
3893 # fail gracefully when there is an unknown command.
3894 if $(SHELL) -c 'install-info --version' \
3895 >/dev/null 2>&1; then \
3896 install-info --dir-file=$(DESTDIR)$(infodir)/dir \
3897 $(DESTDIR)$(infodir)/foo.info; \
3898 else true; fi
3899
3900 When writing the `install' target, you must classify all the
3901 commands into three categories: normal ones, "pre-installation"
3902 commands and "post-installation" commands. *Note Install Command
3903 Categories::.
3904
3905`uninstall'
3906 Delete all the installed files--the copies that the `install'
3907 target creates.
3908
3909 This rule should not modify the directories where compilation is
3910 done, only the directories where files are installed.
3911
3912 The uninstallation commands are divided into three categories,
3913 just like the installation commands. *Note Install Command
3914 Categories::.
3915
3916`install-strip'
3917 Like `install', but strip the executable files while installing
3918 them. In simple cases, this target can use the `install' target in
3919 a simple way:
3920
3921 install-strip:
3922 $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \
3923 install
3924
3925 But if the package installs scripts as well as real executables,
3926 the `install-strip' target can't just refer to the `install'
3927 target; it has to strip the executables but not the scripts.
3928
3929 `install-strip' should not strip the executables in the build
3930 directory which are being copied for installation. It should only
3931 strip the copies that are installed.
3932
3933 Normally we do not recommend stripping an executable unless you
3934 are sure the program has no bugs. However, it can be reasonable
3935 to install a stripped executable for actual execution while saving
3936 the unstripped executable elsewhere in case there is a bug.
3937
3938`clean'
3939 Delete all files from the current directory that are normally
3940 created by building the program. Don't delete the files that
3941 record the configuration. Also preserve files that could be made
3942 by building, but normally aren't because the distribution comes
3943 with them.
3944
3945 Delete `.dvi' files here if they are not part of the distribution.
3946
3947`distclean'
3948 Delete all files from the current directory that are created by
3949 configuring or building the program. If you have unpacked the
3950 source and built the program without creating any other files,
3951 `make distclean' should leave only the files that were in the
3952 distribution.
3953
3954`mostlyclean'
3955 Like `clean', but may refrain from deleting a few files that people
3956 normally don't want to recompile. For example, the `mostlyclean'
3957 target for GCC does not delete `libgcc.a', because recompiling it
3958 is rarely necessary and takes a lot of time.
3959
3960`maintainer-clean'
3961 Delete almost everything from the current directory that can be
3962 reconstructed with this Makefile. This typically includes
3963 everything deleted by `distclean', plus more: C source files
3964 produced by Bison, tags tables, Info files, and so on.
3965
3966 The reason we say "almost everything" is that running the command
3967 `make maintainer-clean' should not delete `configure' even if
3968 `configure' can be remade using a rule in the Makefile. More
3969 generally, `make maintainer-clean' should not delete anything that
3970 needs to exist in order to run `configure' and then begin to build
3971 the program. This is the only exception; `maintainer-clean' should
3972 delete everything else that can be rebuilt.
3973
3974 The `maintainer-clean' target is intended to be used by a
3975 maintainer of the package, not by ordinary users. You may need
3976 special tools to reconstruct some of the files that `make
3977 maintainer-clean' deletes. Since these files are normally
3978 included in the distribution, we don't take care to make them easy
3979 to reconstruct. If you find you need to unpack the full
3980 distribution again, don't blame us.
3981
3982 To help make users aware of this, the commands for the special
3983 `maintainer-clean' target should start with these two:
3984
3985 @echo 'This command is intended for maintainers to use; it'
3986 @echo 'deletes files that may need special tools to rebuild.'
3987
3988`TAGS'
3989 Update a tags table for this program.
3990
3991`info'
3992 Generate any Info files needed. The best way to write the rules
3993 is as follows:
3994
3995 info: foo.info
3996
3997 foo.info: foo.texi chap1.texi chap2.texi
3998 $(MAKEINFO) $(srcdir)/foo.texi
3999
4000 You must define the variable `MAKEINFO' in the Makefile. It should
4001 run the `makeinfo' program, which is part of the Texinfo
4002 distribution.
4003
4004 Normally a GNU distribution comes with Info files, and that means
4005 the Info files are present in the source directory. Therefore,
4006 the Make rule for an info file should update it in the source
4007 directory. When users build the package, ordinarily Make will not
4008 update the Info files because they will already be up to date.
4009
4010`dvi'
4011 Generate DVI files for all Texinfo documentation. For example:
4012
4013 dvi: foo.dvi
4014
4015 foo.dvi: foo.texi chap1.texi chap2.texi
4016 $(TEXI2DVI) $(srcdir)/foo.texi
4017
4018 You must define the variable `TEXI2DVI' in the Makefile. It should
4019 run the program `texi2dvi', which is part of the Texinfo
4020 distribution.(1) Alternatively, write just the dependencies, and
4021 allow GNU `make' to provide the command.
4022
4023`dist'
4024 Create a distribution tar file for this program. The tar file
4025 should be set up so that the file names in the tar file start with
4026 a subdirectory name which is the name of the package it is a
4027 distribution for. This name can include the version number.
4028
4029 For example, the distribution tar file of GCC version 1.40 unpacks
4030 into a subdirectory named `gcc-1.40'.
4031
4032 The easiest way to do this is to create a subdirectory
4033 appropriately named, use `ln' or `cp' to install the proper files
4034 in it, and then `tar' that subdirectory.
4035
4036 Compress the tar file with `gzip'. For example, the actual
4037 distribution file for GCC version 1.40 is called `gcc-1.40.tar.gz'.
4038
4039 The `dist' target should explicitly depend on all non-source files
4040 that are in the distribution, to make sure they are up to date in
4041 the distribution. *Note Making Releases: Releases.
4042
4043`check'
4044 Perform self-tests (if any). The user must build the program
4045 before running the tests, but need not install the program; you
4046 should write the self-tests so that they work when the program is
4047 built but not installed.
4048
4049 The following targets are suggested as conventional names, for
4050programs in which they are useful.
4051
4052`installcheck'
4053 Perform installation tests (if any). The user must build and
4054 install the program before running the tests. You should not
4055 assume that `$(bindir)' is in the search path.
4056
4057`installdirs'
4058 It's useful to add a target named `installdirs' to create the
4059 directories where files are installed, and their parent
4060 directories. There is a script called `mkinstalldirs' which is
4061 convenient for this; you can find it in the Texinfo package. You
4062 can use a rule like this:
4063
4064 # Make sure all installation directories (e.g. $(bindir))
4065 # actually exist by making them if necessary.
4066 installdirs: mkinstalldirs
4067 $(srcdir)/mkinstalldirs $(bindir) $(datadir) \
4068 $(libdir) $(infodir) \
4069 $(mandir)
4070
4071 or, if you wish to support `DESTDIR',
4072
4073 # Make sure all installation directories (e.g. $(bindir))
4074 # actually exist by making them if necessary.
4075 installdirs: mkinstalldirs
4076 $(srcdir)/mkinstalldirs \
4077 $(DESTDIR)$(bindir) $(DESTDIR)$(datadir) \
4078 $(DESTDIR)$(libdir) $(DESTDIR)$(infodir) \
4079 $(DESTDIR)$(mandir)
4080
4081 This rule should not modify the directories where compilation is
4082 done. It should do nothing but create installation directories.
4083
4084 ---------- Footnotes ----------
4085
4086 (1) `texi2dvi' uses TeX to do the real work of formatting. TeX is
4087not distributed with Texinfo.
4088
4089
4090File: standards.info, Node: Install Command Categories, Prev: Standard Targets, Up: Makefile Conventions
4091
4092Install Command Categories
4093--------------------------
4094
4095 When writing the `install' target, you must classify all the
4096commands into three categories: normal ones, "pre-installation"
4097commands and "post-installation" commands.
4098
4099 Normal commands move files into their proper places, and set their
4100modes. They may not alter any files except the ones that come entirely
4101from the package they belong to.
4102
4103 Pre-installation and post-installation commands may alter other
4104files; in particular, they can edit global configuration files or data
4105bases.
4106
4107 Pre-installation commands are typically executed before the normal
4108commands, and post-installation commands are typically run after the
4109normal commands.
4110
4111 The most common use for a post-installation command is to run
4112`install-info'. This cannot be done with a normal command, since it
4113alters a file (the Info directory) which does not come entirely and
4114solely from the package being installed. It is a post-installation
4115command because it needs to be done after the normal command which
4116installs the package's Info files.
4117
4118 Most programs don't need any pre-installation commands, but we have
4119the feature just in case it is needed.
4120
4121 To classify the commands in the `install' rule into these three
4122categories, insert "category lines" among them. A category line
4123specifies the category for the commands that follow.
4124
4125 A category line consists of a tab and a reference to a special Make
4126variable, plus an optional comment at the end. There are three
4127variables you can use, one for each category; the variable name
4128specifies the category. Category lines are no-ops in ordinary execution
4129because these three Make variables are normally undefined (and you
4130_should not_ define them in the makefile).
4131
4132 Here are the three possible category lines, each with a comment that
4133explains what it means:
4134
4135 $(PRE_INSTALL) # Pre-install commands follow.
4136 $(POST_INSTALL) # Post-install commands follow.
4137 $(NORMAL_INSTALL) # Normal commands follow.
4138
4139 If you don't use a category line at the beginning of the `install'
4140rule, all the commands are classified as normal until the first category
4141line. If you don't use any category lines, all the commands are
4142classified as normal.
4143
4144 These are the category lines for `uninstall':
4145
4146 $(PRE_UNINSTALL) # Pre-uninstall commands follow.
4147 $(POST_UNINSTALL) # Post-uninstall commands follow.
4148 $(NORMAL_UNINSTALL) # Normal commands follow.
4149
4150 Typically, a pre-uninstall command would be used for deleting entries
4151from the Info directory.
4152
4153 If the `install' or `uninstall' target has any dependencies which
4154act as subroutines of installation, then you should start _each_
4155dependency's commands with a category line, and start the main target's
4156commands with a category line also. This way, you can ensure that each
4157command is placed in the right category regardless of which of the
4158dependencies actually run.
4159
4160 Pre-installation and post-installation commands should not run any
4161programs except for these:
4162
4163 [ basename bash cat chgrp chmod chown cmp cp dd diff echo
4164 egrep expand expr false fgrep find getopt grep gunzip gzip
4165 hostname install install-info kill ldconfig ln ls md5sum
4166 mkdir mkfifo mknod mv printenv pwd rm rmdir sed sort tee
4167 test touch true uname xargs yes
4168
4169 The reason for distinguishing the commands in this way is for the
4170sake of making binary packages. Typically a binary package contains
4171all the executables and other files that need to be installed, and has
4172its own method of installing them--so it does not need to run the normal
4173installation commands. But installing the binary package does need to
4174execute the pre-installation and post-installation commands.
4175
4176 Programs to build binary packages work by extracting the
4177pre-installation and post-installation commands. Here is one way of
4178extracting the pre-installation commands:
4179
4180 make -n install -o all \
4181 PRE_INSTALL=pre-install \
4182 POST_INSTALL=post-install \
4183 NORMAL_INSTALL=normal-install \
4184 | gawk -f pre-install.awk
4185
4186where the file `pre-install.awk' could contain this:
4187
4188 $0 ~ /^\t[ \t]*(normal_install|post_install)[ \t]*$/ {on = 0}
4189 on {print $0}
4190 $0 ~ /^\t[ \t]*pre_install[ \t]*$/ {on = 1}
4191
4192 The resulting file of pre-installation commands is executed as a
4193shell script as part of installing the binary package.
4194
4195
4196File: standards.info, Node: Releases, Prev: Makefile Conventions, Up: Managing Releases
4197
4198Making Releases
4199===============
4200
4201 Package the distribution of `Foo version 69.96' up in a gzipped tar
4202file with the name `foo-69.96.tar.gz'. It should unpack into a
4203subdirectory named `foo-69.96'.
4204
4205 Building and installing the program should never modify any of the
4206files contained in the distribution. This means that all the files
4207that form part of the program in any way must be classified into "source
4208files" and "non-source files". Source files are written by humans and
4209never changed automatically; non-source files are produced from source
4210files by programs under the control of the Makefile.
4211
4212 The distribution should contain a file named `README' which gives
4213the name of the package, and a general description of what it does. It
4214is also good to explain the purpose of each of the first-level
4215subdirectories in the package, if there are any. The `README' file
4216should either state the version number of the package, or refer to where
4217in the package it can be found.
4218
4219 The `README' file should refer to the file `INSTALL', which should
4220contain an explanation of the installation procedure.
4221
4222 The `README' file should also refer to the file which contains the
4223copying conditions. The GNU GPL, if used, should be in a file called
4224`COPYING'. If the GNU LGPL is used, it should be in a file called
4225`COPYING.LIB'.
4226
4227 Naturally, all the source files must be in the distribution. It is
4228okay to include non-source files in the distribution, provided they are
4229up-to-date and machine-independent, so that building the distribution
4230normally will never modify them. We commonly include non-source files
4231produced by Bison, `lex', TeX, and `makeinfo'; this helps avoid
4232unnecessary dependencies between our distributions, so that users can
4233install whichever packages they want to install.
4234
4235 Non-source files that might actually be modified by building and
4236installing the program should *never* be included in the distribution.
4237So if you do distribute non-source files, always make sure they are up
4238to date when you make a new distribution.
4239
4240 Make sure that the directory into which the distribution unpacks (as
4241well as any subdirectories) are all world-writable (octal mode 777).
4242This is so that old versions of `tar' which preserve the ownership and
4243permissions of the files from the tar archive will be able to extract
4244all the files even if the user is unprivileged.
4245
4246 Make sure that all the files in the distribution are world-readable.
4247
4248 Make sure that no file name in the distribution is more than 14
4249characters long. Likewise, no file created by building the program
4250should have a name longer than 14 characters. The reason for this is
4251that some systems adhere to a foolish interpretation of the POSIX
4252standard, and refuse to open a longer name, rather than truncating as
4253they did in the past.
4254
4255 Don't include any symbolic links in the distribution itself. If the
4256tar file contains symbolic links, then people cannot even unpack it on
4257systems that don't support symbolic links. Also, don't use multiple
4258names for one file in different directories, because certain file
4259systems cannot handle this and that prevents unpacking the distribution.
4260
4261 Try to make sure that all the file names will be unique on MS-DOS. A
4262name on MS-DOS consists of up to 8 characters, optionally followed by a
4263period and up to three characters. MS-DOS will truncate extra
4264characters both before and after the period. Thus, `foobarhacker.c'
4265and `foobarhacker.o' are not ambiguous; they are truncated to
4266`foobarha.c' and `foobarha.o', which are distinct.
4267
4268 Include in your distribution a copy of the `texinfo.tex' you used to
4269test print any `*.texinfo' or `*.texi' files.
4270
4271 Likewise, if your program uses small GNU software packages like
4272regex, getopt, obstack, or termcap, include them in the distribution
4273file. Leaving them out would make the distribution file a little
4274smaller at the expense of possible inconvenience to a user who doesn't
4275know what other files to get.
4276
4277
4278File: standards.info, Node: References, Next: Copying This Manual, Prev: Managing Releases, Up: Top
4279
4280References to Non-Free Software and Documentation
4281*************************************************
4282
4283 A GNU program should not recommend use of any non-free program. We
4284can't stop some people from writing proprietary programs, or stop other
4285people from using them, but we can and should avoid helping to
4286advertise them to new potential customers. Proprietary software is a
4287social and ethical problem, and the point of GNU is to solve that
4288problem.
4289
4290 When a non-free program or system is well known, you can mention it
4291in passing--that is harmless, since users who might want to use it
4292probably already know about it. For instance, it is fine to explain
4293how to build your package on top of some non-free operating system, or
4294how to use it together with some widely used non-free program.
4295
4296 However, you should give only the necessary information to help those
4297who already use the non-free program to use your program with it--don't
4298give, or refer to, any further information about the proprietary
4299program, and don't imply that the proprietary program enhances your
4300program, or that its existence is in any way a good thing. The goal
4301should be that people already using the proprietary program will get
4302the advice they need about how to use your free program, while people
4303who don't already use the proprietary program will not see anything to
4304lead them to take an interest in it.
4305
4306 If a non-free program or system is obscure in your program's domain,
4307your program should not mention or support it at all, since doing so
4308would tend to popularize the non-free program more than it popularizes
4309your program. (You cannot hope to find many additional users among the
4310users of Foobar if the users of Foobar are few.)
4311
4312 A GNU package should not refer the user to any non-free documentation
4313for free software. Free documentation that can be included in free
4314operating systems is essential for completing the GNU system, so it is
4315a major focus of the GNU Project; to recommend use of documentation
4316that we are not allowed to use in GNU would undermine the efforts to
4317get documentation that we can include. So GNU packages should never
4318recommend non-free documentation.
4319
4320
4321File: standards.info, Node: Copying This Manual, Next: Index, Prev: References, Up: Top
4322
4323Copying This Manual
4324*******************
4325
4326* Menu:
4327
4328* GNU Free Documentation License:: License for copying this manual
4329
4330
4331File: standards.info, Node: GNU Free Documentation License, Up: Copying This Manual
4332
4333GNU Free Documentation License
4334******************************
4335
4336 Version 1.1, March 2000
4337 Copyright (C) 2000 Free Software Foundation, Inc.
4338 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
4339
4340 Everyone is permitted to copy and distribute verbatim copies
4341 of this license document, but changing it is not allowed.
4342
4343
4344 0. PREAMBLE
4345
4346 The purpose of this License is to make a manual, textbook, or other
4347 written document "free" in the sense of freedom: to assure everyone
4348 the effective freedom to copy and redistribute it, with or without
4349 modifying it, either commercially or noncommercially. Secondarily,
4350 this License preserves for the author and publisher a way to get
4351 credit for their work, while not being considered responsible for
4352 modifications made by others.
4353
4354 This License is a kind of "copyleft", which means that derivative
4355 works of the document must themselves be free in the same sense.
4356 It complements the GNU General Public License, which is a copyleft
4357 license designed for free software.
4358
4359 We have designed this License in order to use it for manuals for
4360 free software, because free software needs free documentation: a
4361 free program should come with manuals providing the same freedoms
4362 that the software does. But this License is not limited to
4363 software manuals; it can be used for any textual work, regardless
4364 of subject matter or whether it is published as a printed book.
4365 We recommend this License principally for works whose purpose is
4366 instruction or reference.
4367
4368
4369 1. APPLICABILITY AND DEFINITIONS
4370
4371 This License applies to any manual or other work that contains a
4372 notice placed by the copyright holder saying it can be distributed
4373 under the terms of this License. The "Document", below, refers to
4374 any such manual or work. Any member of the public is a licensee,
4375 and is addressed as "you."
4376
4377 A "Modified Version" of the Document means any work containing the
4378 Document or a portion of it, either copied verbatim, or with
4379 modifications and/or translated into another language.
4380
4381 A "Secondary Section" is a named appendix or a front-matter
4382 section of the Document that deals exclusively with the
4383 relationship of the publishers or authors of the Document to the
4384 Document's overall subject (or to related matters) and contains
4385 nothing that could fall directly within that overall subject.
4386 (For example, if the Document is in part a textbook of
4387 mathematics, a Secondary Section may not explain any mathematics.)
4388 The relationship could be a matter of historical connection with
4389 the subject or with related matters, or of legal, commercial,
4390 philosophical, ethical or political position regarding them.
4391
4392 The "Invariant Sections" are certain Secondary Sections whose
4393 titles are designated, as being those of Invariant Sections, in
4394 the notice that says that the Document is released under this
4395 License.
4396
4397 The "Cover Texts" are certain short passages of text that are
4398 listed, as Front-Cover Texts or Back-Cover Texts, in the notice
4399 that says that the Document is released under this License.
4400
4401 A "Transparent" copy of the Document means a machine-readable copy,
4402 represented in a format whose specification is available to the
4403 general public, whose contents can be viewed and edited directly
4404 and straightforwardly with generic text editors or (for images
4405 composed of pixels) generic paint programs or (for drawings) some
4406 widely available drawing editor, and that is suitable for input to
4407 text formatters or for automatic translation to a variety of
4408 formats suitable for input to text formatters. A copy made in an
4409 otherwise Transparent file format whose markup has been designed
4410 to thwart or discourage subsequent modification by readers is not
4411 Transparent. A copy that is not "Transparent" is called "Opaque."
4412
4413 Examples of suitable formats for Transparent copies include plain
4414 ASCII without markup, Texinfo input format, LaTeX input format,
4415 SGML or XML using a publicly available DTD, and
4416 standard-conforming simple HTML designed for human modification.
4417 Opaque formats include PostScript, PDF, proprietary formats that
4418 can be read and edited only by proprietary word processors, SGML
4419 or XML for which the DTD and/or processing tools are not generally
4420 available, and the machine-generated HTML produced by some word
4421 processors for output purposes only.
4422
4423 The "Title Page" means, for a printed book, the title page itself,
4424 plus such following pages as are needed to hold, legibly, the
4425 material this License requires to appear in the title page. For
4426 works in formats which do not have any title page as such, "Title
4427 Page" means the text near the most prominent appearance of the
4428 work's title, preceding the beginning of the body of the text.
4429
4430 2. VERBATIM COPYING
4431
4432 You may copy and distribute the Document in any medium, either
4433 commercially or noncommercially, provided that this License, the
4434 copyright notices, and the license notice saying this License
4435 applies to the Document are reproduced in all copies, and that you
4436 add no other conditions whatsoever to those of this License. You
4437 may not use technical measures to obstruct or control the reading
4438 or further copying of the copies you make or distribute. However,
4439 you may accept compensation in exchange for copies. If you
4440 distribute a large enough number of copies you must also follow
4441 the conditions in section 3.
4442
4443 You may also lend copies, under the same conditions stated above,
4444 and you may publicly display copies.
4445
4446 3. COPYING IN QUANTITY
4447
4448 If you publish printed copies of the Document numbering more than
4449 100, and the Document's license notice requires Cover Texts, you
4450 must enclose the copies in covers that carry, clearly and legibly,
4451 all these Cover Texts: Front-Cover Texts on the front cover, and
4452 Back-Cover Texts on the back cover. Both covers must also clearly
4453 and legibly identify you as the publisher of these copies. The
4454 front cover must present the full title with all words of the
4455 title equally prominent and visible. You may add other material
4456 on the covers in addition. Copying with changes limited to the
4457 covers, as long as they preserve the title of the Document and
4458 satisfy these conditions, can be treated as verbatim copying in
4459 other respects.
4460
4461 If the required texts for either cover are too voluminous to fit
4462 legibly, you should put the first ones listed (as many as fit
4463 reasonably) on the actual cover, and continue the rest onto
4464 adjacent pages.
4465
4466 If you publish or distribute Opaque copies of the Document
4467 numbering more than 100, you must either include a
4468 machine-readable Transparent copy along with each Opaque copy, or
4469 state in or with each Opaque copy a publicly-accessible
4470 computer-network location containing a complete Transparent copy
4471 of the Document, free of added material, which the general
4472 network-using public has access to download anonymously at no
4473 charge using public-standard network protocols. If you use the
4474 latter option, you must take reasonably prudent steps, when you
4475 begin distribution of Opaque copies in quantity, to ensure that
4476 this Transparent copy will remain thus accessible at the stated
4477 location until at least one year after the last time you
4478 distribute an Opaque copy (directly or through your agents or
4479 retailers) of that edition to the public.
4480
4481 It is requested, but not required, that you contact the authors of
4482 the Document well before redistributing any large number of
4483 copies, to give them a chance to provide you with an updated
4484 version of the Document.
4485
4486 4. MODIFICATIONS
4487
4488 You may copy and distribute a Modified Version of the Document
4489 under the conditions of sections 2 and 3 above, provided that you
4490 release the Modified Version under precisely this License, with
4491 the Modified Version filling the role of the Document, thus
4492 licensing distribution and modification of the Modified Version to
4493 whoever possesses a copy of it. In addition, you must do these
4494 things in the Modified Version:
4495
4496 A. Use in the Title Page (and on the covers, if any) a title
4497 distinct from that of the Document, and from those of previous
4498 versions (which should, if there were any, be listed in the
4499 History section of the Document). You may use the same title
4500 as a previous version if the original publisher of that version
4501 gives permission.
4502 B. List on the Title Page, as authors, one or more persons or
4503 entities responsible for authorship of the modifications in the
4504 Modified Version, together with at least five of the principal
4505 authors of the Document (all of its principal authors, if it
4506 has less than five).
4507 C. State on the Title page the name of the publisher of the
4508 Modified Version, as the publisher.
4509 D. Preserve all the copyright notices of the Document.
4510 E. Add an appropriate copyright notice for your modifications
4511 adjacent to the other copyright notices.
4512 F. Include, immediately after the copyright notices, a license
4513 notice giving the public permission to use the Modified Version
4514 under the terms of this License, in the form shown in the
4515 Addendum below.
4516 G. Preserve in that license notice the full lists of Invariant
4517 Sections and required Cover Texts given in the Document's
4518 license notice.
4519 H. Include an unaltered copy of this License.
4520 I. Preserve the section entitled "History", and its title, and add
4521 to it an item stating at least the title, year, new authors, and
4522 publisher of the Modified Version as given on the Title Page.
4523 If there is no section entitled "History" in the Document,
4524 create one stating the title, year, authors, and publisher of
4525 the Document as given on its Title Page, then add an item
4526 describing the Modified Version as stated in the previous
4527 sentence.
4528 J. Preserve the network location, if any, given in the Document for
4529 public access to a Transparent copy of the Document, and
4530 likewise the network locations given in the Document for
4531 previous versions it was based on. These may be placed in the
4532 "History" section. You may omit a network location for a work
4533 that was published at least four years before the Document
4534 itself, or if the original publisher of the version it refers
4535 to gives permission.
4536 K. In any section entitled "Acknowledgements" or "Dedications",
4537 preserve the section's title, and preserve in the section all the
4538 substance and tone of each of the contributor acknowledgements
4539 and/or dedications given therein.
4540 L. Preserve all the Invariant Sections of the Document,
4541 unaltered in their text and in their titles. Section numbers
4542 or the equivalent are not considered part of the section titles.
4543 M. Delete any section entitled "Endorsements." Such a section
4544 may not be included in the Modified Version.
4545 N. Do not retitle any existing section as "Endorsements" or to
4546 conflict in title with any Invariant Section.
4547
4548 If the Modified Version includes new front-matter sections or
4549 appendices that qualify as Secondary Sections and contain no
4550 material copied from the Document, you may at your option
4551 designate some or all of these sections as invariant. To do this,
4552 add their titles to the list of Invariant Sections in the Modified
4553 Version's license notice. These titles must be distinct from any
4554 other section titles.
4555
4556 You may add a section entitled "Endorsements", provided it contains
4557 nothing but endorsements of your Modified Version by various
4558 parties-for example, statements of peer review or that the text has
4559 been approved by an organization as the authoritative definition
4560 of a standard.
4561
4562 You may add a passage of up to five words as a Front-Cover Text,
4563 and a passage of up to 25 words as a Back-Cover Text, to the end
4564 of the list of Cover Texts in the Modified Version. Only one
4565 passage of Front-Cover Text and one of Back-Cover Text may be
4566 added by (or through arrangements made by) any one entity. If the
4567 Document already includes a cover text for the same cover,
4568 previously added by you or by arrangement made by the same entity
4569 you are acting on behalf of, you may not add another; but you may
4570 replace the old one, on explicit permission from the previous
4571 publisher that added the old one.
4572
4573 The author(s) and publisher(s) of the Document do not by this
4574 License give permission to use their names for publicity for or to
4575 assert or imply endorsement of any Modified Version.
4576
4577 5. COMBINING DOCUMENTS
4578
4579 You may combine the Document with other documents released under
4580 this License, under the terms defined in section 4 above for
4581 modified versions, provided that you include in the combination
4582 all of the Invariant Sections of all of the original documents,
4583 unmodified, and list them all as Invariant Sections of your
4584 combined work in its license notice.
4585
4586 The combined work need only contain one copy of this License, and
4587 multiple identical Invariant Sections may be replaced with a single
4588 copy. If there are multiple Invariant Sections with the same name
4589 but different contents, make the title of each such section unique
4590 by adding at the end of it, in parentheses, the name of the
4591 original author or publisher of that section if known, or else a
4592 unique number. Make the same adjustment to the section titles in
4593 the list of Invariant Sections in the license notice of the
4594 combined work.
4595
4596 In the combination, you must combine any sections entitled
4597 "History" in the various original documents, forming one section
4598 entitled "History"; likewise combine any sections entitled
4599 "Acknowledgements", and any sections entitled "Dedications." You
4600 must delete all sections entitled "Endorsements."
4601
4602 6. COLLECTIONS OF DOCUMENTS
4603
4604 You may make a collection consisting of the Document and other
4605 documents released under this License, and replace the individual
4606 copies of this License in the various documents with a single copy
4607 that is included in the collection, provided that you follow the
4608 rules of this License for verbatim copying of each of the
4609 documents in all other respects.
4610
4611 You may extract a single document from such a collection, and
4612 distribute it individually under this License, provided you insert
4613 a copy of this License into the extracted document, and follow
4614 this License in all other respects regarding verbatim copying of
4615 that document.
4616
4617 7. AGGREGATION WITH INDEPENDENT WORKS
4618
4619 A compilation of the Document or its derivatives with other
4620 separate and independent documents or works, in or on a volume of
4621 a storage or distribution medium, does not as a whole count as a
4622 Modified Version of the Document, provided no compilation
4623 copyright is claimed for the compilation. Such a compilation is
4624 called an "aggregate", and this License does not apply to the
4625 other self-contained works thus compiled with the Document, on
4626 account of their being thus compiled, if they are not themselves
4627 derivative works of the Document.
4628
4629 If the Cover Text requirement of section 3 is applicable to these
4630 copies of the Document, then if the Document is less than one
4631 quarter of the entire aggregate, the Document's Cover Texts may be
4632 placed on covers that surround only the Document within the
4633 aggregate. Otherwise they must appear on covers around the whole
4634 aggregate.
4635
4636 8. TRANSLATION
4637
4638 Translation is considered a kind of modification, so you may
4639 distribute translations of the Document under the terms of section
4640 4. Replacing Invariant Sections with translations requires special
4641 permission from their copyright holders, but you may include
4642 translations of some or all Invariant Sections in addition to the
4643 original versions of these Invariant Sections. You may include a
4644 translation of this License provided that you also include the
4645 original English version of this License. In case of a
4646 disagreement between the translation and the original English
4647 version of this License, the original English version will prevail.
4648
4649 9. TERMINATION
4650
4651 You may not copy, modify, sublicense, or distribute the Document
4652 except as expressly provided for under this License. Any other
4653 attempt to copy, modify, sublicense or distribute the Document is
4654 void, and will automatically terminate your rights under this
4655 License. However, parties who have received copies, or rights,
4656 from you under this License will not have their licenses
4657 terminated so long as such parties remain in full compliance.
4658
4659 10. FUTURE REVISIONS OF THIS LICENSE
4660
4661 The Free Software Foundation may publish new, revised versions of
4662 the GNU Free Documentation License from time to time. Such new
4663 versions will be similar in spirit to the present version, but may
4664 differ in detail to address new problems or concerns. See
4665 http://www.gnu.org/copyleft/.
4666
4667 Each version of the License is given a distinguishing version
4668 number. If the Document specifies that a particular numbered
4669 version of this License "or any later version" applies to it, you
4670 have the option of following the terms and conditions either of
4671 that specified version or of any later version that has been
4672 published (not as a draft) by the Free Software Foundation. If
4673 the Document does not specify a version number of this License,
4674 you may choose any version ever published (not as a draft) by the
4675 Free Software Foundation.
4676
4677
4678ADDENDUM: How to use this License for your documents
4679====================================================
4680
4681 To use this License in a document you have written, include a copy of
4682the License in the document and put the following copyright and license
4683notices just after the title page:
4684
4685 Copyright (C) YEAR YOUR NAME.
4686 Permission is granted to copy, distribute and/or modify this document
4687 under the terms of the GNU Free Documentation License, Version 1.1
4688 or any later version published by the Free Software Foundation;
4689 with the Invariant Sections being LIST THEIR TITLES, with the
4690 Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
4691 A copy of the license is included in the section entitled "GNU
4692 Free Documentation License."
4693
4694 If you have no Invariant Sections, write "with no Invariant Sections"
4695instead of saying which ones are invariant. If you have no Front-Cover
4696Texts, write "no Front-Cover Texts" instead of "Front-Cover Texts being
4697LIST"; likewise for Back-Cover Texts.
4698
4699 If your document contains nontrivial examples of program code, we
4700recommend releasing these examples in parallel under your choice of
4701free software license, such as the GNU General Public License, to
4702permit their use in free software.
4703
4704
4705File: standards.info, Node: Index, Prev: Copying This Manual, Up: Top
4706
4707Index
4708*****
4709
4710* Menu:
4711
4712* #endif, commenting: Comments.
4713* --help option: Command-Line Interfaces.
4714* --version option: Command-Line Interfaces.
4715* -Wall compiler option: Syntactic Conventions.
4716* accepting contributions: Contributions.
4717* address for bug reports: Command-Line Interfaces.
4718* ANSI C standard: Standard C.
4719* arbitrary limits on data: Semantics.
4720* autoconf: System Portability.
4721* avoiding proprietary code: Reading Non-Free Code.
4722* behavior, dependent on program's name: User Interfaces.
4723* binary packages: Install Command Categories.
4724* bindir: Directory Variables.
4725* braces, in C source: Formatting.
4726* bug reports: Command-Line Interfaces.
4727* canonical name of a program: Command-Line Interfaces.
4728* casting pointers to integers: CPU Portability.
4729* change logs: Change Logs.
4730* change logs, conditional changes: Conditional Changes.
4731* change logs, style: Style of Change Logs.
4732* command-line arguments, decoding: Semantics.
4733* command-line interface: Command-Line Interfaces.
4734* commenting: Comments.
4735* compatibility with C and POSIX standards: Compatibility.
4736* compiler warnings: Syntactic Conventions.
4737* conditional changes, and change logs: Conditional Changes.
4738* conditionals, comments for: Comments.
4739* configure: Configuration.
4740* control-L: Formatting.
4741* conventions for makefiles: Makefile Conventions.
4742* corba: Graphical Interfaces.
4743* credits for manuals: Manual Credits.
4744* data types, and portability: CPU Portability.
4745* declaration for system functions: System Functions.
4746* documentation: Documentation.
4747* doschk: Names.
4748* downloading this manual: Preface.
4749* error messages: Semantics.
4750* error messages, formatting: Errors.
4751* exec_prefix: Directory Variables.
4752* expressions, splitting: Formatting.
4753* file usage: File Usage.
4754* file-name limitations: Names.
4755* formatting error messages: Errors.
4756* formatting source code: Formatting.
4757* formfeed: Formatting.
4758* function argument, declaring: Syntactic Conventions.
4759* function prototypes: Standard C.
4760* getopt: Command-Line Interfaces.
4761* gettext: Internationalization.
4762* gnome: Graphical Interfaces.
4763* graphical user interface: Graphical Interfaces.
4764* gtk: Graphical Interfaces.
4765* GUILE: Source Language.
4766* implicit int: Syntactic Conventions.
4767* impossible conditions: Semantics.
4768* internationalization: Internationalization.
4769* legal aspects: Legal Issues.
4770* legal papers: Contributions.
4771* libexecdir: Directory Variables.
4772* libraries: Libraries.
4773* library functions, and portability: System Functions.
4774* license for manuals: License for Manuals.
4775* lint: Syntactic Conventions.
4776* long option names: Option Table.
4777* long-named options: Command-Line Interfaces.
4778* makefile, conventions for: Makefile Conventions.
4779* malloc return value: Semantics.
4780* man pages: Man Pages.
4781* manual structure: Manual Structure Details.
4782* memory allocation failure: Semantics.
4783* memory usage: Memory Usage.
4784* message text, and internationalization: Internationalization.
4785* mmap: Mmap.
4786* multiple variables in a line: Syntactic Conventions.
4787* names of variables, functions, and files: Names.
4788* NEWS file: NEWS File.
4789* non-POSIX systems, and portability: System Portability.
4790* non-standard extensions: Using Extensions.
4791* NUL characters: Semantics.
4792* open brace: Formatting.
4793* optional features, configure-time: Configuration.
4794* options for compatibility: Compatibility.
4795* output device and program's behavior: User Interfaces.
4796* packaging: Releases.
4797* portability, and data types: CPU Portability.
4798* portability, and library functions: System Functions.
4799* portability, between system types: System Portability.
4800* POSIX compatibility: Compatibility.
4801* POSIXLY_CORRECT, environment variable: Compatibility.
4802* post-installation commands: Install Command Categories.
4803* pre-installation commands: Install Command Categories.
4804* prefix: Directory Variables.
4805* program configuration: Configuration.
4806* program design: Design Advice.
4807* program name and its behavior: User Interfaces.
4808* program's canonical name: Command-Line Interfaces.
4809* programming languges: Source Language.
4810* proprietary programs: Reading Non-Free Code.
4811* README file: Releases.
4812* references to non-free material: References.
4813* releasing: Managing Releases.
4814* sbindir: Directory Variables.
4815* signal handling: Semantics.
4816* spaces before open-paren: Formatting.
4817* standard command-line options: Command-Line Interfaces.
4818* standards for makefiles: Makefile Conventions.
4819* string library functions: System Functions.
4820* syntactic conventions: Syntactic Conventions.
4821* table of long options: Option Table.
4822* temporary files: Semantics.
4823* temporary variables: Syntactic Conventions.
4824* texinfo.tex, in a distribution: Releases.
4825* TMPDIR environment variable: Semantics.
4826* trademarks: Trademarks.
4827* where to obtain standards.texi: Preface.
4828
4829
4830
4831Tag Table:
4832Node: Top689
4833Node: Preface1392
4834Node: Legal Issues3611
4835Node: Reading Non-Free Code4074
4836Node: Contributions5797
4837Node: Trademarks7946
4838Node: Design Advice9004
4839Node: Source Language9587
4840Node: Compatibility11594
4841Node: Using Extensions13217
4842Node: Standard C14788
4843Node: Conditional Compilation17186
4844Node: Program Behavior18480
4845Node: Semantics19398
4846Node: Libraries24086
4847Node: Errors25326
4848Node: User Interfaces27102
4849Node: Graphical Interfaces28702
4850Node: Command-Line Interfaces29732
4851Node: Option Table35798
4852Node: Memory Usage50802
4853Node: File Usage51822
4854Node: Writing C52565
4855Node: Formatting53414
4856Node: Comments57472
4857Node: Syntactic Conventions60770
4858Node: Names64177
4859Node: System Portability66381
4860Node: CPU Portability68761
4861Node: System Functions72012
4862Node: Internationalization77214
4863Node: Mmap80362
4864Node: Documentation81067
4865Node: GNU Manuals82171
4866Node: Doc Strings and Manuals87223
4867Node: Manual Structure Details88771
4868Node: License for Manuals90184
4869Node: Manual Credits91153
4870Node: Printed Manuals91541
4871Node: NEWS File92222
4872Node: Change Logs92894
4873Node: Change Log Concepts93643
4874Node: Style of Change Logs95498
4875Node: Simple Changes97544
4876Node: Conditional Changes98779
4877Node: Indicating the Part Changed100192
4878Node: Man Pages100710
4879Node: Reading other Manuals102329
4880Node: Managing Releases103113
4881Node: Configuration103875
4882Node: Makefile Conventions110775
4883Node: Makefile Basics111576
4884Node: Utilities in Makefiles114741
4885Node: Command Variables116877
4886Node: Directory Variables120445
4887Node: Standard Targets131330
4888Ref: Standard Targets-Footnote-1142581
4889Node: Install Command Categories142681
4890Node: Releases147254
4891Node: References151337
4892Node: Copying This Manual153621
4893Node: GNU Free Documentation License153835
4894Node: Index173521
4895
4896End Tag Table
Note: See TracBrowser for help on using the repository browser.