1 This is standards.info, produced by makeinfo version 4.2 from
2 ../../src/etc/standards.texi.
5 * Standards: (standards). GNU coding standards.
8 GNU Coding Standards Copyright (C) 1992, 1993, 1994, 1995, 1996,
9 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
11 Permission is granted to copy, distribute and/or modify this document
12 under the terms of the GNU Free Documentation License, Version 1.1 or
13 any later version published by the Free Software Foundation; with no
14 Invariant Sections, with no Front-Cover Texts, and with no Back-Cover
15 Texts. A copy of the license is included in the section entitled "GNU
16 Free Documentation License".
19 File: standards.info, Node: Top, Next: Preface, Prev: (dir), Up: (dir)
24 Last updated February 14, 2002.
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
40 File: standards.info, Node: Preface, Next: Legal Issues, Prev: Top, Up: Top
42 About the GNU Coding Standards
43 ******************************
45 The GNU Coding Standards were written by Richard Stallman and other
46 GNU Project volunteers. Their purpose is to make the GNU system clean,
47 consistent, and easy to install. This document can also be read as a
48 guide to writing portable, robust and reliable programs. It focuses on
49 programs written in C, but many of the rules and principles are useful
50 even if you write in another programming language. The rules often
51 state reasons for writing in a certain way.
53 This release of the GNU Coding Standards was last updated February
56 If you did not obtain this file directly from the GNU project and
57 recently, please check for a newer version. You can ftp the GNU Coding
58 Standards from any GNU FTP host in the directory `/pub/gnu/standards/'.
59 The GNU Coding Standards are available there in several different
60 formats: `standards.text', `standards.info', and `standards.dvi', as
61 well as the Texinfo "source" which is divided in two files:
62 `standards.texi' and `make-stds.texi'. The GNU Coding Standards are
63 also available on the GNU World Wide Web server:
64 `http://www.gnu.org/prep/standards_toc.html'.
66 Corrections or suggestions for this document should be sent to
67 <bug-standards@gnu.org>. If you make a suggestion, please include a
68 suggested new wording for it; our time is limited. We prefer a context
69 diff to the `standards.texi' or `make-stds.texi' files, but if you
70 don't have those files, please mail your suggestion anyway.
72 These standards cover the minimum of what is important when writing a
73 GNU package. Likely, the needs for additional standards will come up.
74 Sometimes, you might suggest that such standards be added to this
75 document. If you think your standards would be generally useful, please
78 You should also set standards for your package on many questions not
79 addressed or not firmly specified here. The most important point is to
80 be self-consistent--try to stick to the conventions you pick, and try
81 to document them as much as possible. That way, your program will be
82 more maintainable by others.
85 File: standards.info, Node: Legal Issues, Next: Design Advice, Prev: Preface, Up: Top
87 Keeping Free Software Free
88 **************************
90 This node discusses how you can make sure that GNU software avoids
91 legal difficulties, and other related issues.
95 * Reading Non-Free Code:: Referring to Proprietary Programs
96 * Contributions:: Accepting Contributions
97 * Trademarks:: How We Deal with Trademark Issues
100 File: standards.info, Node: Reading Non-Free Code, Next: Contributions, Up: Legal Issues
102 Referring to Proprietary Programs
103 =================================
105 Don't in any circumstances refer to Unix source code for or during
106 your work on GNU! (Or to any other proprietary programs.)
108 If you have a vague recollection of the internals of a Unix program,
109 this does not absolutely mean you can't write an imitation of it, but
110 do try to organize the imitation internally along different lines,
111 because this is likely to make the details of the Unix version
112 irrelevant and dissimilar to your results.
114 For example, Unix utilities were generally optimized to minimize
115 memory use; if you go for speed instead, your program will be very
116 different. You could keep the entire input file in core and scan it
117 there instead of using stdio. Use a smarter algorithm discovered more
118 recently than the Unix program. Eliminate use of temporary files. Do
119 it in one pass instead of two (we did this in the assembler).
121 Or, on the contrary, emphasize simplicity instead of speed. For some
122 applications, the speed of today's computers makes simpler algorithms
125 Or go for generality. For example, Unix programs often have static
126 tables or fixed-size strings, which make for arbitrary limits; use
127 dynamic allocation instead. Make sure your program handles NULs and
128 other funny characters in the input files. Add a programming language
129 for extensibility and write part of the program in that language.
131 Or turn some parts of the program into independently usable
132 libraries. Or use a simple garbage collector instead of tracking
133 precisely when to free memory, or use a new GNU facility such as
137 File: standards.info, Node: Contributions, Next: Trademarks, Prev: Reading Non-Free Code, Up: Legal Issues
139 Accepting Contributions
140 =======================
142 If the program you are working on is copyrighted by the Free Software
143 Foundation, then when someone else sends you a piece of code to add to
144 the program, we need legal papers to use it--just as we asked you to
145 sign papers initially. _Each_ person who makes a nontrivial
146 contribution to a program must sign some sort of legal papers in order
147 for us to have clear title to the program; the main author alone is not
150 So, before adding in any contributions from other people, please tell
151 us, so we can arrange to get the papers. Then wait until we tell you
152 that we have received the signed papers, before you actually use the
155 This applies both before you release the program and afterward. If
156 you receive diffs to fix a bug, and they make significant changes, we
157 need legal papers for that change.
159 This also applies to comments and documentation files. For copyright
160 law, comments and code are just text. Copyright applies to all kinds of
161 text, so we need legal papers for all kinds.
163 We know it is frustrating to ask for legal papers; it's frustrating
164 for us as well. But if you don't wait, you are going out on a limb--for
165 example, what if the contributor's employer won't sign a disclaimer?
166 You might have to take that code out again!
168 You don't need papers for changes of a few lines here or there, since
169 they are not significant for copyright purposes. Also, you don't need
170 papers if all you get from the suggestion is some ideas, not actual code
171 which you use. For example, if someone send you one implementation, but
172 you write a different implementation of the same idea, you don't need to
175 The very worst thing is if you forget to tell us about the other
176 contributor. We could be very embarrassed in court some day as a
179 We have more detailed advice for maintainers of programs; if you have
180 reached the stage of actually maintaining a program for GNU (whether
181 released or not), please ask us for a copy.
184 File: standards.info, Node: Trademarks, Prev: Contributions, Up: Legal Issues
189 Please do not include any trademark acknowledgements in GNU software
190 packages or documentation.
192 Trademark acknowledgements are the statements that such-and-such is a
193 trademark of so-and-so. The GNU Project has no objection to the basic
194 idea of trademarks, but these acknowledgements feel like kowtowing, so
195 we don't use them. There is no legal requirement for them.
197 What is legally required, as regards other people's trademarks, is to
198 avoid using them in ways which a reader might read as naming or labeling
199 our 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
202 compiler". The latter is meant to be short for the former, but it does
203 not explicitly state the relationship, so it could be misinterpreted as
204 using "Objective C" as a label for the compiler rather than for the
208 File: standards.info, Node: Design Advice, Next: Program Behavior, Prev: Legal Issues, Up: Top
210 General Program Design
211 **********************
213 This node discusses some of the issues you should take into account
214 when designing your program.
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
225 File: standards.info, Node: Source Language, Next: Compatibility, Up: Design Advice
227 Which Languages to Use
228 ======================
230 When you want to use a language that gets compiled and runs at high
231 speed, the best language to use is C. Using another language is like
232 using a non-standard feature: it will cause trouble for users. Even if
233 GCC supports the other language, users may find it inconvenient to have
234 to install the compiler for that other language in order to build your
235 program. For example, if you write your program in C++, people will
236 have to install the GNU C++ compiler in order to compile your program.
238 C has one other advantage over C++ and other compiled languages: more
239 people know C, so more people will find it easy to read and modify the
240 program if it is written in C.
242 So in general it is much better to use C, rather than the comparable
245 But there are two exceptions to that conclusion:
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.
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
257 Many programs are designed to be extensible: they include an
258 interpreter for a language that is higher level than C. Often much of
259 the program is written in that language, too. The Emacs editor
260 pioneered this technique.
262 The standard extensibility interpreter for GNU software is GUILE,
263 which implements the language Scheme (an especially clean and simple
264 dialect of Lisp). `http://www.gnu.org/software/guile/'. We don't
265 reject programs written in other "scripting languages" such as Perl and
266 Python, but using GUILE is very important for the overall consistency of
270 File: standards.info, Node: Compatibility, Next: Using Extensions, Prev: Source Language, Up: Design Advice
272 Compatibility with Other Implementations
273 ========================================
275 With occasional exceptions, utility programs and libraries for GNU
276 should be upward compatible with those in Berkeley Unix, and upward
277 compatible with Standard C if Standard C specifies their behavior, and
278 upward compatible with POSIX if POSIX specifies their behavior.
280 When these standards conflict, it is useful to offer compatibility
281 modes for each of them.
283 Standard C and POSIX prohibit many kinds of extensions. Feel free
284 to make the extensions anyway, and include a `--ansi', `--posix', or
285 `--compatible' option to turn them off. However, if the extension has
286 a significant chance of breaking any real programs or scripts, then it
287 is not really upward compatible. So you should try to redesign its
288 interface to make it upward compatible.
290 Many GNU programs suppress extensions that conflict with POSIX if the
291 environment variable `POSIXLY_CORRECT' is defined (even if it is
292 defined with a null value). Please make your program recognize this
293 variable if appropriate.
295 When a feature is used only by users (not by programs or command
296 files), and it is done poorly in Unix, feel free to replace it
297 completely with something totally different and better. (For example,
298 `vi' is replaced with Emacs.) But it is nice to offer a compatible
299 feature as well. (There is a free `vi' clone, so we offer it.)
301 Additional useful features are welcome regardless of whether there
302 is any precedent for them.
305 File: standards.info, Node: Using Extensions, Next: Standard C, Prev: Compatibility, Up: Design Advice
307 Using Non-standard Features
308 ===========================
310 Many GNU facilities that already exist support a number of convenient
311 extensions over the comparable Unix facilities. Whether to use these
312 extensions in implementing your program is a difficult question.
314 On the one hand, using the extensions can make a cleaner program.
315 On the other hand, people will not be able to build the program unless
316 the other GNU tools are available. This might cause the program to
317 work on fewer kinds of machines.
319 With some extensions, it might be easy to provide both alternatives.
320 For example, you can define functions with a "keyword" `INLINE' and
321 define that as a macro to expand into either `inline' or nothing,
322 depending on the compiler.
324 In general, perhaps it is best not to use the extensions if you can
325 straightforwardly do without them, but to use the extensions if they
326 are a big improvement.
328 An exception to this rule are the large, established programs (such
329 as Emacs) which run on a great variety of systems. Using GNU
330 extensions in such programs would make many users unhappy, so we don't
333 Another exception is for programs that are used as part of
334 compilation: anything that must be compiled with other compilers in
335 order to bootstrap the GNU compilation facilities. If these require
336 the GNU compiler, then no one can compile them without having them
337 installed already. That would be extremely troublesome in certain
341 File: standards.info, Node: Standard C, Next: Conditional Compilation, Prev: Using Extensions, Up: Design Advice
343 Standard C and Pre-Standard C
344 =============================
346 1989 Standard C is widespread enough now that it is ok to use its
347 features in new programs. There is one exception: do not ever use the
348 "trigraph" feature of Standard C.
350 1999 Standard C is not widespread yet, so please do not require its
351 features in programs. It is ok to use its features if they are present.
353 However, it is easy to support pre-standard compilers in most
354 programs, so if you know how to do that, feel free. If a program you
355 are maintaining has such support, you should try to keep it working.
357 To support pre-standard C, instead of writing function definitions in
358 standard prototype form,
364 write the definition in pre-standard style like this,
371 and use a separate declaration to specify the argument prototype:
375 You need such a declaration anyway, in a header file, to get the
376 benefit of prototypes in all the files where the function is called.
377 And once you have the declaration, you normally lose nothing by writing
378 the function definition in the pre-standard style.
380 This technique does not work for integer types narrower than `int'.
381 If you think of an argument as being of a type narrower than `int',
382 declare it as `int' instead.
384 There are a few special cases where this technique is hard to use.
385 For 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
387 some machines; but you cannot use `int' instead, because `dev_t' is
388 wider than `int' on some machines. There is no type you can safely use
389 on all machines in a non-standard definition. The only way to support
390 non-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
392 may not be worth the trouble.
394 In order to support pre-standard compilers that do not recognize
395 prototypes, you may want to use a preprocessor macro like this:
397 /* Declare the prototype for a general external function. */
398 #if defined (__STDC__) || defined (WINDOWSNT)
399 #define P_(proto) proto
405 File: standards.info, Node: Conditional Compilation, Prev: Standard C, Up: Design Advice
407 Conditional Compilation
408 =======================
410 When supporting configuration options already known when building
411 your program we prefer using `if (... )' over conditional compilation,
412 as in the former case the compiler is able to perform more extensive
413 checking of all possible code paths.
415 For example, please write
430 A modern compiler such as GCC will generate exactly the same code in
431 both cases, and we have been using similar techniques with good success
434 While this is not a silver bullet solving all portability problems,
435 following this policy would have saved the GCC project alone many person
436 hours if not days per year.
438 In the case of function-like macros like `REVERSIBLE_CC_MODE' in GCC
439 which cannot be simply used in `if( ...)' statements, there is an easy
440 workaround. Simply introduce another macro `HAS_REVERSIBLE_CC_MODE' as
441 in the following example:
443 #ifdef REVERSIBLE_CC_MODE
444 #define HAS_REVERSIBLE_CC_MODE 1
446 #define HAS_REVERSIBLE_CC_MODE 0
450 File: standards.info, Node: Program Behavior, Next: Writing C, Prev: Design Advice, Up: Top
452 Program Behavior for All Programs
453 *********************************
455 This node describes conventions for writing robust software. It
456 also describes general standards for error messages, the command line
457 interface, and how libraries should behave.
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
472 File: standards.info, Node: Semantics, Next: Libraries, Up: Program Behavior
474 Writing Robust Programs
475 =======================
477 Avoid arbitrary limits on the length or number of _any_ data
478 structure, including file names, lines, files, and symbols, by
479 allocating all data structures dynamically. In most Unix utilities,
480 "long lines are silently truncated". This is not acceptable in a GNU
483 Utilities reading files should not drop NUL characters, or any other
484 nonprinting characters _including those with codes above 0177_. The
485 only sensible exceptions would be utilities specifically intended for
486 interface to certain types of terminals or printers that can't handle
487 those characters. Whenever possible, try to make programs work
488 properly with sequences of bytes that represent multibyte characters,
489 using encodings such as UTF-8 and others.
491 Check every system call for an error return, unless you know you
492 wish to ignore errors. Include the system error text (from `perror' or
493 equivalent) in _every_ error message resulting from a failing system
494 call, as well as the name of the file if any and the name of the
495 utility. Just "cannot open foo.c" or "stat failed" is not sufficient.
497 Check every call to `malloc' or `realloc' to see if it returned
498 zero. Check `realloc' even if you are making the block smaller; in a
499 system that rounds block sizes to a power of 2, `realloc' may get a
500 different block if you ask for less space.
502 In Unix, `realloc' can destroy the storage block if it returns zero.
503 GNU `realloc' does not have this bug: if it fails, the original block
504 is unchanged. Feel free to assume the bug is fixed. If you wish to
505 run your program on Unix, and wish to avoid lossage in this case, you
506 can use the GNU `malloc'.
508 You must expect `free' to alter the contents of the block that was
509 freed. Anything you want to fetch from the block, you must fetch before
512 If `malloc' fails in a noninteractive program, make that a fatal
513 error. In an interactive program (one that reads commands from the
514 user), it is better to abort the command and return to the command
515 reader loop. This allows the user to kill other processes to free up
516 virtual memory, and then try the command again.
518 Use `getopt_long' to decode arguments, unless the argument syntax
519 makes this unreasonable.
521 When static storage is to be written in during program execution, use
522 explicit C code to initialize it. Reserve C initialized declarations
523 for data that will not be changed.
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
527 these are less likely to work compatibly. If you need to find all the
528 files in a directory, use `readdir' or some other high-level interface.
529 These are supported compatibly by GNU.
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.
535 Nowadays, using the POSIX signal functions may be the easiest way to
536 make a program portable. If you use `signal', then on GNU/Linux
537 systems running GNU libc version 1, you should include `bsd/signal.h'
538 instead of `signal.h', so as to get BSD behavior. It is up to you
539 whether to support systems where `signal' has only the USG behavior, or
542 In error checks that detect "impossible" conditions, just abort.
543 There is usually no point in printing any message. These checks
544 indicate the existence of bugs. Whoever wants to fix the bugs will have
545 to read the source code and run a debugger. So explain the problem with
546 comments in the source. The relevant data will be in variables, which
547 are easy to examine with the debugger, so there is no point moving them
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
553 you try to return 256 as the exit status, the parent process will see 0
554 as the status, and it will appear that the program succeeded.
556 If you make temporary files, check the `TMPDIR' environment
557 variable; if that variable is defined, use the specified directory
560 In addition, be aware that there is a possible security problem when
561 creating temporary files in world-writable directories. In C, you can
562 avoid this problem by creating temporary files in this manner:
564 fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0600);
566 or by using the `mkstemps' function from libiberty.
568 In bash, use `set -C' to avoid this problem.
571 File: standards.info, Node: Libraries, Next: Errors, Prev: Semantics, Up: Program Behavior
576 Try to make library functions reentrant. If they need to do dynamic
577 storage allocation, at least try to avoid any nonreentrancy aside from
578 that of `malloc' itself.
580 Here are certain name conventions for libraries, to avoid name
583 Choose a name prefix for the library, more than two characters long.
584 All external function and variable names should start with this prefix.
585 In addition, there should only be one of these in any given library
586 member. This usually means putting each one in a separate source file.
588 An exception can be made when two external symbols are always used
589 together, so that no reasonable program could use one without the
590 other; then they can both go in the same file.
592 External symbols that are not documented entry points for the user
593 should have names beginning with `_'. The `_' should be followed by
594 the chosen name prefix for the library, to prevent collisions with
595 other libraries. These can go in the same files with user entry points
598 Static functions and variables can be used as you like and need not
599 fit any naming convention.
602 File: standards.info, Node: Errors, Next: User Interfaces, Prev: Libraries, Up: Program Behavior
604 Formatting Error Messages
605 =========================
607 Error messages from compilers should look like this:
609 SOURCE-FILE-NAME:LINENO: MESSAGE
611 If you want to mention the column number, use this format:
613 SOURCE-FILE-NAME:LINENO:COLUMN: MESSAGE
615 Line numbers should start from 1 at the beginning of the file, and
616 column numbers should start from 1 at the beginning of the line. (Both
617 of these conventions are chosen for compatibility.) Calculate column
618 numbers assuming that space and all ASCII printing characters have
619 equal width, and assuming tab stops every 8 columns.
621 Error messages from other noninteractive programs should look like
624 PROGRAM:SOURCE-FILE-NAME:LINENO: MESSAGE
626 when there is an appropriate source file, or like this:
630 when there is no relevant source file.
632 If you want to mention the column number, use this format:
634 PROGRAM:SOURCE-FILE-NAME:LINENO:COLUMN: MESSAGE
636 In an interactive program (one that is reading commands from a
637 terminal), it is better not to include the program name in an error
638 message. The place to indicate which program is running is in the
639 prompt or with the screen layout. (When the same program runs with
640 input from a source other than a terminal, it is not interactive and
641 would do best to print error messages using the noninteractive style.)
643 The string MESSAGE should not begin with a capital letter when it
644 follows a program name and/or file name. Also, it should not end with
647 Error messages from interactive programs, and other messages such as
648 usage messages, should start with a capital letter. But they should not
652 File: standards.info, Node: User Interfaces, Next: Graphical Interfaces, Prev: Errors, Up: Program Behavior
654 Standards for Interfaces Generally
655 ==================================
657 Please don't make the behavior of a utility depend on the name used
658 to invoke it. It is useful sometimes to make a link to a utility with
659 a different name, and that should not change what it does.
661 Instead, use a run time option or a compilation switch or both to
662 select among the alternate behaviors.
664 Likewise, please don't make the behavior of the program depend on the
665 type of output device it is used with. Device independence is an
666 important principle of the system's design; do not compromise it merely
667 to save someone from typing an option now and then. (Variation in error
668 message syntax when using a terminal is ok, because that is a side issue
669 that people do not depend on.)
671 If you think one behavior is most useful when the output is to a
672 terminal, and another is most useful when the output is a file or a
673 pipe, then it is usually best to make the default behavior the one that
674 is useful with output to a terminal, and have an option for the other
677 Compatibility requires certain programs to depend on the type of
678 output device. It would be disastrous if `ls' or `sh' did not do so in
679 the way all users expect. In some of these cases, we supplement the
680 program with a preferred alternate version that does not depend on the
681 output device type. For example, we provide a `dir' program much like
682 `ls' except that its default output format is always multi-column
686 File: standards.info, Node: Graphical Interfaces, Next: Command-Line Interfaces, Prev: User Interfaces, Up: Program Behavior
688 Standards for Graphical Interfaces
689 ==================================
691 When you write a program that provides a graphical user interface,
692 please make it work with X Windows and the GTK toolkit unless the
693 functionality specifically requires some alternative (for example,
694 "displaying jpeg images while in console mode").
696 In addition, please provide a command-line interface to control the
697 functionality. (In many cases, the graphical user interface can be a
698 separate program which invokes the command-line program.) This is so
699 that the same jobs can be done from scripts.
701 Please also consider providing a CORBA interface (for use from
702 GNOME), a library interface (for use from C), and perhaps a
703 keyboard-driven console interface (for use by users from console mode).
704 Once you are doing the work to provide the functionality and the
705 graphical interface, these won't be much extra work.
708 File: standards.info, Node: Command-Line Interfaces, Next: Option Table, Prev: Graphical Interfaces, Up: Program Behavior
710 Standards for Command Line Interfaces
711 =====================================
713 It is a good idea to follow the POSIX guidelines for the
714 command-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
716 normally permit options anywhere among the arguments unless the special
717 argument `--' is used. This is not what POSIX specifies; it is a GNU
720 Please define long-named options that are equivalent to the
721 single-letter Unix-style options. We hope to make GNU more user
722 friendly this way. This is easy to do with the GNU function
725 One of the advantages of long-named options is that they can be
726 consistent from program to program. For example, users should be able
727 to expect the "verbose" option of any GNU program which has one, to be
728 spelled precisely `--verbose'. To achieve this uniformity, look at the
729 table of common long-option names when you choose the option names for
730 your program (*note Option Table::).
732 It is usually a good idea for file names given as ordinary arguments
733 to be input files only; any output files would be specified using
734 options (preferably `-o' or `--output'). Even if you allow an output
735 file name as an ordinary argument for compatibility, try to provide an
736 option as another way to specify it. This will lead to more consistency
737 among GNU utilities, and fewer idiosyncracies for users to remember.
739 All programs should support two standard options: `--version' and
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.
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:
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'.
760 If the program is a subsidiary part of a larger package, mention
761 the package name in parentheses, like this:
763 emacsserver (GNU Emacs) 19.30
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.
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.
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.
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.
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
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.
793 Here's an example of output that follows these rules:
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.
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
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.
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:
820 (the official copyright symbol, which is the letter C in a circle);
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.
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.
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:
836 Report bugs to MAILING-ADDRESS.
839 File: standards.info, Node: Option Table, Next: Memory Usage, Prev: Command-Line Interfaces, Up: Program Behavior
841 Table of Long Options
842 =====================
844 Here is a table of long options used by GNU programs. It is surely
845 incomplete, but we aim to list all the options that a new program might
846 want to be compatible with. If you use names not already in the table,
847 please send <bug-standards@gnu.org> a list of them, with their
848 meanings, so we can update the table.
854 `-a' in `du', `ls', `nm', `stty', `uname', and `unexpand'.
863 `-a' in `etags', `tee', `time'; `-r' in `tar'.
899 For server programs, run in the background.
917 `-b' in `cpio' and `diff'.
923 Used in `cpio' and `tar'.
926 `-b' in `head' and `tail'.
932 Used in various programs to make output shorter.
935 `-c' in `head', `split', and `tail'.
944 Used in various programs to specify the directory to use.
947 `-c' in `chgrp' and `chown'.
956 `-c' in `su'; `-x' in GDB.
965 `-Z' in `tar' and `shar'.
977 `-W copyleft' in `gawk'.
980 `-C' in `ptx', `recode', and `wdiff'; `-W copyright' in `gawk'.
992 Used in `tar' and `cpio'.
1004 `-d' in Make and `m4'; `-t' in Bison.
1010 `-d' in Bison and `ctags'.
1016 `-L' in `chgrp', `chown', `cpio', `du', `ls', and `tar'.
1022 Specify an I/O device (special file name).
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
1066 `environment-overrides'
1106 `-i' in `cpio'; `-x' in `tar'.
1118 `-f' in `info', `gawk', Make, `mt', and `tar'; `-n' in `sed'; `-r'
1139 `fixed-output-files'
1149 `-f' in `cp', `ln', `mv', and `rm'.
1155 For server programs, run in the foreground; in other words, don't
1156 do anything special to run the server in the background.
1159 Used in `ls', `time', and `ptx'.
1183 `-z' in `tar' and `shar'.
1189 `-h' in `objdump' and `recode'
1195 Used to ask for brief usage information.
1200 `hide-control-chars'
1204 In `makeinfo', output HTML.
1213 `-I' in `ls'; `-x' in `recode'.
1221 `ignore-blank-lines'
1225 `-f' in `look' and `ptx'; `-i' in `diff' and `wdiff'.
1233 `ignore-indentation'
1242 `ignore-matching-lines'
1245 `ignore-space-change'
1252 `-i' in `etags'; `-I' in `m4'.
1261 `-i', `-l', and `-m' in Finger.
1264 In some programs, specify the name of the file to read as the
1277 `-i' in `cp', `ln', `mv', `rm'; `-e' in `m4'; `-p' in `xargs';
1299 `-k' in `du' and `ls'.
1314 Used in `split', `head', and `tail'.
1324 `-t' in `cpio'; `-l' in `recode'.
1339 No listing of which programs already use this; someone should
1340 check to see if any actually do, and tell <gnu@gnu.org>.
1346 `-m' in `hello' and `uname'.
1385 `-m' in `install', `mkdir', and `mkfifo'.
1408 `no-character-count'
1466 Used in `emacsclient'.
1469 Used in various programs to inhibit warnings.
1496 `-n' in `cpio' and `ls'.
1508 `-l' in `tar', `cp', and `du'.
1520 `-o' in `getopt', `fdlist', `fdmount', `fdmountd', and `fdumount'.
1523 In various programs, specify the output file name.
1544 `-p' in `mkdir' and `rmdir'.
1556 `-c' in `cpio' and `tar'.
1568 Used in `tar' and `cp'.
1570 `preserve-environment'
1573 `preserve-modification-time'
1579 `preserve-permissions'
1607 Specify an HTTP proxy.
1616 Used in many programs to inhibit the usual output. *Note:* every
1617 program accepting `--quiet' should accept `--silent' as a synonym.
1644 Used in `chgrp', `chown', `cp', `ls', `diff', and `rm'.
1653 `-r' in `tac' and `etags'.
1670 `report-identical-files'
1677 `-r' in `ls' and `nm'.
1707 Used by `recode' to chose files or pipes for sequencing passes.
1721 `show-function-line'
1728 Used in many programs to inhibit the usual output. *Note:* every
1729 program accepting `--silent' should accept `--quiet' as a synonym.
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.
1744 `-W source' in `gawk'.
1768 Used in `tar' and `diff' to specify which file within a directory
1769 to start processing with.
1796 `-S' in `cp', `ln', `mv'.
1811 Used in GDB and `objdump'.
1820 `-t' in `expand' and `unexpand'.
1826 `-T' in `tput' and `ul'. `-t' in `wdiff'.
1835 Used in `ls' and `touch'.
1838 Specify how long to wait before giving up on some operation.
1847 `-t' in Make, `ranlib', and `recode'.
1853 `-t' in `hello'; `-W traditional' in `gawk'; `-G' in `ed', `m4',
1881 `-u' in `cp', `ctags', `mv', `tar'.
1884 Used in `gawk'; same as `--help'.
1893 Print more information about progress. Many programs support this.
1899 Print the version number.
1902 `-V' in `cp', `ln', `mv'.
1917 `-w' in `ls' and `ptx'.
1929 File: standards.info, Node: Memory Usage, Next: File Usage, Prev: Option Table, Up: Program Behavior
1934 If a program typically uses just a few meg of memory, don't bother
1935 making any effort to reduce memory usage. For example, if it is
1936 impractical for other reasons to operate on files more than a few meg
1937 long, it is reasonable to read entire input files into core to operate
1940 However, for programs such as `cat' or `tail', that can usefully
1941 operate on very large files, it is important to avoid using a technique
1942 that would artificially limit the size of files it can handle. If a
1943 program works by lines and could be applied to arbitrary user-supplied
1944 input files, it should keep only a line in memory, because this is not
1945 very hard and users will want to be able to operate on input files that
1946 are bigger than will fit in core all at once.
1948 If your program creates complicated data structures, just make them
1949 in core and give a fatal error if `malloc' returns zero.
1952 File: standards.info, Node: File Usage, Prev: Memory Usage, Up: Program Behavior
1957 Programs should be prepared to operate when `/usr' and `/etc' are
1958 read-only file systems. Thus, if the program manages log files, lock
1959 files, backup files, score files, or any other files which are modified
1960 for internal purposes, these files should not be stored in `/usr' or
1963 There are two exceptions. `/etc' is used to store system
1964 configuration information; it is reasonable for a program to modify
1965 files in `/etc' when its job is to update the system configuration.
1966 Also, if the user explicitly asks to modify one file in a directory, it
1967 is reasonable for the program to store other files in the same
1971 File: standards.info, Node: Writing C, Next: Documentation, Prev: Program Behavior, Up: Top
1973 Making The Best Use of C
1974 ************************
1976 This node provides advice on how best to use the C language when
1977 writing GNU software.
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'.
1992 File: standards.info, Node: Formatting, Next: Comments, Up: Writing C
1994 Formatting Your Source Code
1995 ===========================
1997 It is important to put the open-brace that starts the body of a C
1998 function in column zero, and avoid putting any other open-brace or
1999 open-parenthesis or open-bracket in column zero. Several tools look
2000 for open-braces in column zero to find the beginnings of C functions.
2001 These tools will not work on code not formatted that way.
2003 It is also important for function definitions to start the name of
2004 the function in column zero. This helps people to search for function
2005 definitions, and may also help certain tools recognize them. Thus, the
2006 proper format is this:
2009 concat (s1, s2) /* Name starts in column zero here */
2011 { /* Open brace in column zero here */
2015 or, if you want to use Standard C syntax, format the definition like
2019 concat (char *s1, char *s2)
2024 In Standard C, if the arguments don't fit nicely on one line, split
2028 lots_of_args (int an_integer, long a_long, short a_short,
2029 double a_double, float a_float)
2032 The rest of this section gives our recommendations for other aspects
2033 of C formatting style, which is also the default style of the `indent'
2034 program in version 1.2 and newer. It corresponds to the options
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
2039 We don't think of these recommendations as requirements, because it
2040 causes no problems for users if two different programs have different
2043 But whatever style you use, please use it consistently, since a
2044 mixture of styles within one program tends to look ugly. If you are
2045 contributing changes to an existing program, please follow the style of
2048 For the body of the function, our recommended style looks like this:
2059 return ++x + bar ();
2062 We find it easier to read a program when it has spaces before the
2063 open-parentheses and after the commas. Especially after the commas.
2065 When you split an expression into multiple lines, split it before an
2066 operator, not after one. Here is the right way:
2068 if (foo_this_is_long && bar > win (x, y, z)
2069 && remaining_condition)
2071 Try to avoid having two operators of different precedence at the same
2072 level of indentation. For example, don't write this:
2074 mode = (inmode[j] == VOIDmode
2075 || GET_MODE_SIZE (outmode[j]) > GET_MODE_SIZE (inmode[j])
2076 ? outmode[j] : inmode[j]);
2078 Instead, use extra parentheses so that the indentation shows the
2081 mode = ((inmode[j] == VOIDmode
2082 || (GET_MODE_SIZE (outmode[j]) > GET_MODE_SIZE (inmode[j])))
2083 ? outmode[j] : inmode[j]);
2085 Insert extra parentheses so that Emacs will indent the code properly.
2086 For example, the following indentation looks nice if you do it by hand,
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;
2091 but Emacs would alter it. Adding a set of parentheses produces
2092 something that looks equally nice, and which Emacs will preserve:
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);
2097 Format do-while statements like this:
2105 Please use formfeed characters (control-L) to divide the program into
2106 pages at logical places (but not within a function). It does not matter
2107 just how long the pages are, since they do not have to fit on a printed
2108 page. The formfeeds should appear alone on lines by themselves.
2111 File: standards.info, Node: Comments, Next: Syntactic Conventions, Prev: Formatting, Up: Writing C
2113 Commenting Your Work
2114 ====================
2116 Every program should start with a comment saying briefly what it is
2117 for. Example: `fmt - filter for simple filling of text'.
2119 Please write the comments in a GNU program in English, because
2120 English is the one language that nearly all programmers in all
2121 countries can read. If you do not write English well, please write
2122 comments in English as well as you can, then ask other people to help
2123 rewrite them. If you can't write comments in English, please find
2124 someone to work with you and translate your comments into English.
2126 Please put a comment on each function saying what the function does,
2127 what sorts of arguments it gets, and what the possible values of
2128 arguments mean and are used for. It is not necessary to duplicate in
2129 words the meaning of the C argument declarations, if a C type is being
2130 used in its customary fashion. If there is anything nonstandard about
2131 its use (such as an argument of type `char *' which is really the
2132 address of the second character of a string, not the first), or any
2133 possible values that would not work the way one would expect (such as,
2134 that strings containing newlines are not guaranteed to work), be sure
2137 Also explain the significance of the return value, if there is one.
2139 Please put two spaces after the end of a sentence in your comments,
2140 so that the Emacs sentence commands will work. Also, please write
2141 complete sentences and capitalize the first word. If a lower-case
2142 identifier comes at the beginning of a sentence, don't capitalize it!
2143 Changing the spelling makes it a different identifier. If you don't
2144 like starting a sentence with a lower case letter, write the sentence
2145 differently (e.g., "The identifier lower-case is ...").
2147 The comment on a function is much clearer if you use the argument
2148 names to speak about the argument values. The variable name itself
2149 should be lower case, but write it in upper case when you are speaking
2150 about the value rather than the variable itself. Thus, "the inode
2151 number NODE_NUM" rather than "an inode".
2153 There is usually no purpose in restating the name of the function in
2154 the comment before it, because the reader can see that for himself.
2155 There might be an exception when the comment is so long that the
2156 function itself would be off the bottom of the screen.
2158 There should be a comment on each static variable as well, like this:
2160 /* Nonzero means truncate lines in the display;
2161 zero means continue them. */
2164 Every `#endif' should have a comment, except in the case of short
2165 conditionals (just a few lines) that are not nested. The comment should
2166 state the condition of the conditional that is ending, _including its
2167 sense_. `#else' should have a comment describing the condition _and
2168 sense_ of the code that follows. For example:
2174 #endif /* not foo */
2179 but, by contrast, write the comments this way for a `#ifndef':
2188 #endif /* not foo */
2191 File: standards.info, Node: Syntactic Conventions, Next: Names, Prev: Comments, Up: Writing C
2193 Clean Use of C Constructs
2194 =========================
2196 Please explicitly declare the types of all objects. For example, you
2197 should explicitly declare all arguments to functions, and you should
2198 declare functions to return `int' rather than omitting the `int'.
2200 Some programmers like to use the GCC `-Wall' option, and change the
2201 code whenever it issues a warning. If you want to do this, then do.
2202 Other programmers prefer not to use `-Wall', because it gives warnings
2203 for valid and legitimate code which they do not want to change. If you
2204 want to do this, then do. The compiler should be your servant, not
2207 Declarations of external functions and functions to appear later in
2208 the source file should all go in one place near the beginning of the
2209 file (somewhere before the first function definition in the file), or
2210 else should go in a header file. Don't put `extern' declarations inside
2213 It used to be common practice to use the same local variables (with
2214 names like `tem') over and over for different values within one
2215 function. Instead of doing this, it is better declare a separate local
2216 variable for each distinct purpose, and give it a name which is
2217 meaningful. This not only makes programs easier to understand, it also
2218 facilitates optimization by good compilers. You can also move the
2219 declaration of each local variable into the smallest scope that includes
2220 all its uses. This makes the program even cleaner.
2222 Don't use local variables or parameters that shadow global
2225 Don't declare multiple variables in one declaration that spans lines.
2226 Start a new declaration on each line, instead. For example, instead of
2241 (If they are global variables, each should have a comment preceding it
2244 When you have an `if'-`else' statement nested in another `if'
2245 statement, always put braces around the `if'-`else'. Thus, never write
2264 If you have an `if' statement nested inside of an `else' statement,
2265 either write `else if' on one line, like this,
2272 with its `then'-part indented like the preceding `then'-part, or write
2273 the nested `if' within braces like this:
2283 Don't declare both a structure tag and variables or typedefs in the
2284 same declaration. Instead, declare the structure tag separately and
2285 then use it to declare the variables or typedefs.
2287 Try to avoid assignments inside `if'-conditions. For example, don't
2290 if ((foo = (char *) malloc (sizeof *foo)) == 0)
2291 fatal ("virtual memory exhausted");
2293 instead, write this:
2295 foo = (char *) malloc (sizeof *foo);
2297 fatal ("virtual memory exhausted");
2299 Don't make the program ugly to placate `lint'. Please don't insert
2300 any casts to `void'. Zero without a cast is perfectly fine as a null
2301 pointer constant, except when calling a varargs function.
2304 File: standards.info, Node: Names, Next: System Portability, Prev: Syntactic Conventions, Up: Writing C
2306 Naming Variables, Functions, and Files
2307 ======================================
2309 The names of global variables and functions in a program serve as
2310 comments of a sort. So don't choose terse names--instead, look for
2311 names that give useful information about the meaning of the variable or
2312 function. In a GNU program, names should be English, like other
2315 Local variable names can be shorter, because they are used only
2316 within one context, where (presumably) comments explain their purpose.
2318 Try to limit your use of abbreviations in symbol names. It is ok to
2319 make a few abbreviations, explain what they mean, and then use them
2320 frequently, but don't use lots of obscure abbreviations.
2322 Please use underscores to separate words in a name, so that the Emacs
2323 word commands can be useful within them. Stick to lower case; reserve
2324 upper case for macros and `enum' constants, and for name-prefixes that
2325 follow a uniform convention.
2327 For example, you should use names like `ignore_space_change_flag';
2328 don't use names like `iCantReadThis'.
2330 Variables that indicate whether command-line options have been
2331 specified should be named after the meaning of the option, not after
2332 the option-letter. A comment should state both the exact meaning of
2333 the option and its letter. For example,
2335 /* Ignore changes in horizontal whitespace (-b). */
2336 int ignore_space_change_flag;
2338 When you want to define names with constant integer values, use
2339 `enum' rather than `#define'. GDB knows about enumeration constants.
2341 You might want to make sure that none of the file names would
2342 conflict the files were loaded onto an MS-DOS file system which
2343 shortens the names. You can use the program `doschk' to test for this.
2345 Some GNU programs were designed to limit themselves to file names of
2346 14 characters or less, to avoid file name conflicts if they are read
2347 into older System V systems. Please preserve this feature in the
2348 existing GNU programs that have it, but there is no need to do this in
2349 new GNU programs. `doschk' also reports file names longer than 14
2353 File: standards.info, Node: System Portability, Next: CPU Portability, Prev: Names, Up: Writing C
2355 Portability between System Types
2356 ================================
2358 In the Unix world, "portability" refers to porting to different Unix
2359 versions. For a GNU program, this kind of portability is desirable, but
2362 The primary purpose of GNU software is to run on top of the GNU
2363 kernel, compiled with the GNU C compiler, on various types of CPU. So
2364 the kinds of portability that are absolutely necessary are quite
2365 limited. But it is important to support Linux-based GNU systems, since
2366 they are the form of GNU that is popular.
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
2370 to. Supporting a variety of Unix-like systems is desirable, although
2371 not paramount. It is usually not too hard, so you may as well do it.
2372 But you don't have to consider it an obligation, if it does turn out to
2375 The easiest way to achieve portability to most Unix-like systems is
2376 to use Autoconf. It's unlikely that your program needs to know more
2377 information about the host platform than Autoconf can provide, simply
2378 because most of the programs that need such knowledge have already been
2381 Avoid using the format of semi-internal data bases (e.g.,
2382 directories) when there is a higher-level alternative (`readdir').
2384 As for systems that are not like Unix, such as MSDOS, Windows, the
2385 Macintosh, VMS, and MVS, supporting them is often a lot of work. When
2386 that is the case, it is better to spend your time adding features that
2387 will be useful on GNU and GNU/Linux, rather than on supporting other
2388 incompatible systems.
2390 It is a good idea to define the "feature test macro" `_GNU_SOURCE'
2391 when compiling your C files. When you compile on GNU or GNU/Linux,
2392 this will enable the declarations of GNU library extension functions,
2393 and that will usually give you a compiler error message if you define
2394 the same function names in some other way in your program. (You don't
2395 have to actually _use_ these functions, if you prefer to make the
2396 program more portable to other systems.)
2398 But whether or not you use these GNU extensions, you should avoid
2399 using their names for any other meanings. Doing so would make it hard
2400 to move your code into other GNU programs.
2403 File: standards.info, Node: CPU Portability, Next: System Functions, Prev: System Portability, Up: Writing C
2405 Portability between CPUs
2406 ========================
2408 Even GNU systems will differ because of differences among CPU
2409 types--for example, difference in byte ordering and alignment
2410 requirements. It is absolutely essential to handle these differences.
2411 However, 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
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
2417 example, the following code is ok:
2419 printf ("size = %lu\n", (unsigned long) sizeof array);
2420 printf ("diff = %ld\n", (long) (pointer2 - pointer1));
2422 1989 Standard C requires this to work, and we know of only one
2423 counterexample: 64-bit programs on Microsoft Windows IA-64. We will
2424 leave it to those who want to port GNU programs to that environment to
2425 figure out how to do it.
2427 Predefined file-size types like `off_t' are an exception: they are
2428 longer than `long' on many platforms, so code like the above won't work
2429 with them. One way to print an `off_t' value portably is to print its
2430 digits yourself, one by one.
2432 Don't assume that the address of an `int' object is also the address
2433 of its least-significant byte. This is false on big-endian machines.
2434 Thus, don't make the following mistake:
2438 while ((c = getchar()) != EOF)
2439 write(file_descriptor, &c, 1);
2441 When calling functions, you need not worry about the difference
2442 between pointers of various types, or between pointers and integers.
2443 On most machines, there's no difference anyway. As for the few
2444 machines where there is a difference, all of them support Standard C
2445 prototypes, so you can use prototypes (perhaps conditionalized to be
2446 active only in Standard C) to make the code work on those systems.
2448 In certain cases, it is ok to pass integer and pointer arguments
2449 indiscriminately to the same function, and use no prototype on any
2450 system. For example, many GNU programs have error-reporting functions
2451 that pass their arguments along to `printf' and friends:
2453 error (s, a1, a2, a3)
2457 fprintf (stderr, "error: ");
2458 fprintf (stderr, s, a1, a2, a3);
2461 In practice, this works on all machines, since a pointer is generally
2462 the widest possible kind of argument; it is much simpler than any
2463 "correct" alternative. Be sure _not_ to use a prototype for such
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'.
2469 Avoid casting pointers to integers if you can. Such casts greatly
2470 reduce portability, and in most programs they are easy to avoid. In the
2471 cases where casting pointers to integers is essential--such as, a Lisp
2472 interpreter which stores type information as well as an address in one
2473 word--you'll have to make explicit provisions to handle different word
2474 sizes. You will also need to make provision for systems in which the
2475 normal range of addresses you can get from `malloc' starts far away
2479 File: standards.info, Node: System Functions, Next: Internationalization, Prev: CPU Portability, Up: Writing C
2481 Calling System Functions
2482 ========================
2484 C implementations differ substantially. Standard C reduces but does
2485 not eliminate the incompatibilities; meanwhile, many GNU packages still
2486 support pre-standard compilers because this is not hard to do. This
2487 chapter gives recommendations for how to use the more-or-less standard C
2488 library functions to avoid unnecessary loss of portability.
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.
2493 * Be aware that `vfprintf' is not always available.
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.
2499 * Don't declare system functions explicitly.
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.
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.
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
2517 * In particular, don't unconditionally declare `malloc' or `realloc'.
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.
2523 Because `xmalloc' and `xrealloc' are defined in your program, you
2524 can declare them in other files without any risk of type conflict.
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
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
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
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
2548 strcpy strncpy strcat strncat
2549 strlen strcmp strncmp
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.
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
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.
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:
2580 #define strchr index
2582 #ifndef HAVE_STRRCHR
2583 #define strrchr rindex
2589 Here we assume that `HAVE_STRCHR' and `HAVE_STRRCHR' are macros
2590 defined in systems where the corresponding functions exist. One way to
2591 get them properly defined is to use Autoconf.
2594 File: standards.info, Node: Internationalization, Next: Mmap, Prev: System Functions, Up: Writing C
2596 Internationalization
2597 ====================
2599 GNU has a library called GNU gettext that makes it easy to translate
2600 the messages in a program into various languages. You should use this
2601 library in every program. Use English for the messages as they appear
2602 in the program, and let gettext provide the way to translate them into
2605 Using GNU gettext involves putting a call to the `gettext' macro
2606 around each string that might need translation--like this:
2608 printf (gettext ("Processing file `%s'..."));
2610 This permits GNU gettext to replace the string `"Processing file
2611 `%s'..."' with a translated version.
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.
2616 Using GNU gettext in a package involves specifying a "text domain
2617 name" for the package. The text domain name is used to separate the
2618 translations for this package from the translations for other packages.
2619 Normally, the text domain name should be the same as the name of the
2620 package--for example, `fileutils' for the GNU file utilities.
2622 To enable gettext to work well, avoid writing code that makes
2623 assumptions about the structure of words or sentences. When you want
2624 the precise text of a sentence to vary depending on the data, use two or
2625 more alternative string constants each containing a complete sentences,
2626 rather than inserting conditionalized words or phrases into a single
2629 Here is an example of what not to do:
2631 printf ("%d file%s processed", nfiles,
2632 nfiles != 1 ? "s" : "");
2634 The problem with that example is that it assumes that plurals are made
2635 by adding `s'. If you apply gettext to the format string, like this,
2637 printf (gettext ("%d file%s processed"), nfiles,
2638 nfiles != 1 ? "s" : "");
2640 the message can use different words, but it will still be forced to use
2641 `s' for the plural. Here is a better way:
2643 printf ((nfiles != 1 ? "%d files processed"
2644 : "%d file processed"),
2647 This way, you can apply gettext to each of the two strings
2650 printf ((nfiles != 1 ? gettext ("%d files processed")
2651 : gettext ("%d file processed")),
2654 This can be any method of forming the plural of the word for "file", and
2655 also handles languages that require agreement in the word for
2658 A similar problem appears at the level of sentence structure with
2661 printf ("# Implicit rule search has%s been done.\n",
2662 f->tried_implicit ? "" : " not");
2664 Adding `gettext' calls to this code cannot give correct results for all
2665 languages, because negation in some languages requires adding words at
2666 more than one place in the sentence. By contrast, adding `gettext'
2667 calls does the job straightfowardly if the code starts out like this:
2669 printf (f->tried_implicit
2670 ? "# Implicit rule search has been done.\n",
2671 : "# Implicit rule search has not been done.\n");
2674 File: standards.info, Node: Mmap, Prev: Internationalization, Up: Writing C
2679 Don't assume that `mmap' either works on all files or fails for all
2680 files. It may work on some files and fail on others.
2682 The proper way to use `mmap' is to try it on the specific file for
2683 which you want to use it--and if `mmap' doesn't work, fall back on
2684 doing the job in another way using `read' and `write'.
2686 The reason this precaution is needed is that the GNU kernel (the
2687 HURD) provides a user-extensible file system, in which there can be many
2688 different kinds of "ordinary files." Many of them support `mmap', but
2689 some do not. It is important to make programs handle all these kinds
2693 File: standards.info, Node: Documentation, Next: Managing Releases, Prev: Writing C, Up: Top
2695 Documenting Programs
2696 ********************
2698 A GNU program should ideally come with full free documentation,
2699 adequate for both reference and tutorial purposes. If the package can
2700 be programmed or extended, the documentation should cover programming or
2701 extending it, as well as just using it.
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
2718 File: standards.info, Node: GNU Manuals, Next: Doc Strings and Manuals, Up: Documentation
2723 The preferred document format for the GNU system is the Texinfo
2724 formatting language. Every GNU package should (ideally) have
2725 documentation in Texinfo both for reference and for learners. Texinfo
2726 makes it possible to produce a good quality formatted book, using TeX,
2727 and to generate an Info file. It is also possible to generate HTML
2728 output from Texinfo source. See the Texinfo manual, either the
2729 hardcopy, or the on-line version available through `info' or the Emacs
2730 Info subsystem (`C-h i').
2732 Nowadays some other formats such as Docbook and Sgmltexi can be
2733 converted automatically into Texinfo. It is ok to produce the Texinfo
2734 documentation by conversion this way, as long as it gives good results.
2736 Programmers often find it most natural to structure the documentation
2737 following the structure of the implementation, which they know. But
2738 this structure is not necessarily good for explaining how to use the
2739 program; it may be irrelevant and confusing for a user.
2741 At every level, from the sentences in a paragraph to the grouping of
2742 topics into separate manuals, the right way to structure documentation
2743 is according to the concepts and questions that a user will have in mind
2744 when reading it. Sometimes this structure of ideas matches the
2745 structure of the implementation of the software being documented--but
2746 often they are different. Often the most important part of learning to
2747 write good documentation is learning to notice when you are structuring
2748 the documentation like the implementation, and think about better
2751 For example, each program in the GNU system probably ought to be
2752 documented in one manual; but this does not mean each program should
2753 have its own manual. That would be following the structure of the
2754 implementation, rather than the structure that helps the user
2757 Instead, each manual should cover a coherent _topic_. For example,
2758 instead of a manual for `diff' and a manual for `diff3', we have one
2759 manual for "comparison of files" which covers both of those programs,
2760 as well as `cmp'. By documenting these programs together, we can make
2761 the whole subject clearer.
2763 The manual which discusses a program should certainly document all of
2764 the program's command-line options and all of its commands. It should
2765 give examples of their use. But don't organize the manual as a list of
2766 features. Instead, organize it logically, by subtopics. Address the
2767 questions that a user will ask when thinking about the job that the
2770 In general, a GNU manual should serve both as tutorial and reference.
2771 It should be set up for convenient access to each topic through Info,
2772 and for reading straight through (appendixes aside). A GNU manual
2773 should give a good introduction to a beginner reading through from the
2774 start, and should also provide all the details that hackers want. The
2775 Bison manual is a good example of this--please take a look at it to see
2778 That is not as hard as it first sounds. Arrange each chapter as a
2779 logical breakdown of its topic, but order the sections, and write their
2780 text, so that reading the chapter straight through makes sense. Do
2781 likewise when structuring the book into chapters, and when structuring a
2782 section into paragraphs. The watchword is, _at each point, address the
2783 most fundamental and important issue raised by the preceding text._
2785 If necessary, add extra chapters at the beginning of the manual which
2786 are purely tutorial and cover the basics of the subject. These provide
2787 the framework for a beginner to understand the rest of the manual. The
2788 Bison manual provides a good example of how to do this.
2790 To serve as a reference, a manual should have an Index that list all
2791 the functions, variables, options, and important concepts that are part
2792 of the program. One combined Index should do for a short manual, but
2793 sometimes for a complex package it is better to use multiple indices.
2794 The Texinfo manual includes advice on preparing good index entries, see
2795 *Note Making Index Entries: (texinfo)Index Entries, and see *Note
2796 Defining the Entries of an Index: (texinfo)Indexing Commands.
2798 Don't use Unix man pages as a model for how to write GNU
2799 documentation; most of them are terse, badly structured, and give
2800 inadequate explanation of the underlying concepts. (There are, of
2801 course, some exceptions.) Also, Unix man pages use a particular format
2802 which is different from what we use in GNU manuals.
2804 Please include an email address in the manual for where to report
2805 bugs _in the manual_.
2807 Please do not use the term "pathname" that is used in Unix
2808 documentation; use "file name" (two words) instead. We use the term
2809 "path" only for search paths, which are lists of directory names.
2811 Please do not use the term "illegal" to refer to erroneous input to a
2812 computer program. Please use "invalid" for this, and reserve the term
2813 "illegal" for activities punishable by law.
2816 File: standards.info, Node: Doc Strings and Manuals, Next: Manual Structure Details, Prev: GNU Manuals, Up: Documentation
2818 Doc Strings and Manuals
2819 =======================
2821 Some programming systems, such as Emacs, provide a documentation
2822 string for each function, command or variable. You may be tempted to
2823 write a reference manual by compiling the documentation strings and
2824 writing a little additional text to go around them--but you must not do
2825 it. That approach is a fundamental mistake. The text of well-written
2826 documentation strings will be entirely wrong for a manual.
2828 A documentation string needs to stand alone--when it appears on the
2829 screen, there will be no other text to introduce or explain it.
2830 Meanwhile, it can be rather informal in style.
2832 The text describing a function or variable in a manual must not stand
2833 alone; it appears in the context of a section or subsection. Other text
2834 at the beginning of the section should explain some of the concepts, and
2835 should often make some general points that apply to several functions or
2836 variables. The previous descriptions of functions and variables in the
2837 section will also have given information about the topic. A description
2838 written to stand alone would repeat some of that information; this
2839 redundance looks bad. Meanwhile, the informality that is acceptable in
2840 a documentation string is totally unacceptable in a manual.
2842 The only good way to use documentation strings in writing a good
2843 manual is to use them as a source of information for writing good text.
2846 File: standards.info, Node: Manual Structure Details, Next: License for Manuals, Prev: Doc Strings and Manuals, Up: Documentation
2848 Manual Structure Details
2849 ========================
2851 The title page of the manual should state the version of the
2852 programs or packages documented in the manual. The Top node of the
2853 manual should also contain this information. If the manual is changing
2854 more frequently than or independent of the program, also state a version
2855 number for the manual in both of these places.
2857 Each program documented in the manual should have a node named
2858 `PROGRAM Invocation' or `Invoking PROGRAM'. This node (together with
2859 its subnodes, if any) should describe the program's command line
2860 arguments and how to run it (the sort of information people would look
2861 in a man page for). Start with an `@example' containing a template for
2862 all the options and arguments that the program uses.
2864 Alternatively, put a menu item in some menu whose item name fits one
2865 of the above patterns. This identifies the node which that item points
2866 to as the node for this purpose, regardless of the node's actual name.
2868 The `--usage' feature of the Info reader looks for such a node or
2869 menu item in order to find the relevant text, so it is essential for
2870 every Texinfo file to have one.
2872 If one manual describes several programs, it should have such a node
2873 for each program described in the manual.
2876 File: standards.info, Node: License for Manuals, Next: Manual Credits, Prev: Manual Structure Details, Up: Documentation
2881 Please use the GNU Free Documentation License for all GNU manuals
2882 that are more than a few pages long. Likewise for a collection of short
2883 documents--you only need one copy of the GNU FDL for the whole
2884 collection. For a single short document, you can use a very permissive
2885 non-copyleft license, to avoid taking up space with a long license.
2887 See `http://www.gnu.org/copyleft/fdl-howto.html' for more explanation
2888 of how to employ the GFDL.
2890 Note that it is not obligatory to include a copy of the GNU GPL or
2891 GNU LGPL in a manual whose license is neither the GPL nor the LGPL. It
2892 can be a good idea to include the program's license in a large manual;
2893 in a short manual, whose size would be increased considerably by
2894 including the program's license, it is probably better not to include
2898 File: standards.info, Node: Manual Credits, Next: Printed Manuals, Prev: License for Manuals, Up: Documentation
2903 Please credit the principal human writers of the manual as the
2904 authors, on the title page of the manual. If a company sponsored the
2905 work, thank the company in a suitable place in the manual, but do not
2906 cite the company as an author.
2909 File: standards.info, Node: Printed Manuals, Next: NEWS File, Prev: Manual Credits, Up: Documentation
2914 The FSF publishes some GNU manuals in printed form. To encourage
2915 sales of these manuals, the on-line versions of the manual should
2916 mention at the very start that the printed manual is available and
2917 should point at information for getting it--for instance, with a link
2918 to the page <http://www.gnu.org/order/order.html>. This should not be
2919 included in the printed manual, though, because there it is redundant.
2921 It is also useful to explain in the on-line forms of the manual how
2922 the user can print out the manual from the sources.
2925 File: standards.info, Node: NEWS File, Next: Change Logs, Prev: Printed Manuals, Up: Documentation
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.
2932 In each new release, add items to the front of the file and identify
2933 the version they pertain to. Don't discard old items; leave them in
2934 the file after the newer items. This way, a user upgrading from any
2935 previous version can see what is new.
2937 If the `NEWS' file gets very long, move some of the older items into
2938 a file named `ONEWS' and put a note at the end referring the user to
2942 File: standards.info, Node: Change Logs, Next: Man Pages, Prev: NEWS File, Up: Documentation
2947 Keep a change log to describe all the changes made to program source
2948 files. The purpose of this is so that people investigating bugs in the
2949 future will know about the changes that might have introduced the bug.
2950 Often a new bug can be found by looking at what was recently changed.
2951 More importantly, change logs can help you eliminate conceptual
2952 inconsistencies between different parts of a program, by giving you a
2953 history of how the conflicting concepts arose and who they came from.
2957 * Change Log Concepts::
2958 * Style of Change Logs::
2960 * Conditional Changes::
2961 * Indicating the Part Changed::
2964 File: standards.info, Node: Change Log Concepts, Next: Style of Change Logs, Up: Change Logs
2969 You can think of the change log as a conceptual "undo list" which
2970 explains how earlier versions were different from the current version.
2971 People can see the current version; they don't need the change log to
2972 tell them what is in it. What they want from a change log is a clear
2973 explanation of how the earlier version differed.
2975 The change log file is normally called `ChangeLog' and covers an
2976 entire directory. Each directory can have its own change log, or a
2977 directory can use the change log of its parent directory-it's up to you.
2979 Another alternative is to record change log information with a
2980 version control system such as RCS or CVS. This can be converted
2981 automatically to a `ChangeLog' file using `rcs2log'; in Emacs, the
2982 command `C-x v a' (`vc-update-change-log') does the job.
2984 There's no need to describe the full purpose of the changes or how
2985 they work together. If you think that a change calls for explanation,
2986 you're probably right. Please do explain it--but please put the
2987 explanation in comments in the code, where people will see it whenever
2988 they see the code. For example, "New function" is enough for the
2989 change log when you add a function, because there should be a comment
2990 before the function definition to explain what it does.
2992 However, sometimes it is useful to write one line to describe the
2993 overall purpose of a batch of changes.
2995 The easiest way to add an entry to `ChangeLog' is with the Emacs
2996 command `M-x add-change-log-entry'. An entry should have an asterisk,
2997 the name of the changed file, and then in parentheses the name of the
2998 changed functions, variables or whatever, followed by a colon. Then
2999 describe the changes you made to that function or variable.
3002 File: standards.info, Node: Style of Change Logs, Next: Simple Changes, Prev: Change Log Concepts, Up: Change Logs
3004 Style of Change Logs
3005 --------------------
3007 Here are some simple examples of change log entries, starting with
3008 the header line that says who made the change and when, followed by
3009 descriptions of specific changes. (These examples are drawn from Emacs
3012 1998-08-17 Richard Stallman <rms@gnu.org>
3014 * register.el (insert-register): Return nil.
3015 (jump-to-register): Likewise.
3017 * sort.el (sort-subr): Return nil.
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.
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.
3027 It's important to name the changed function or variable in full.
3028 Don't abbreviate function or variable names, and don't combine them.
3029 Subsequent maintainers will often search for a function name to find all
3030 the change log entries that pertain to it; if you abbreviate the name,
3031 they won't find it when they search.
3033 For example, some people are tempted to abbreviate groups of function
3034 names by writing `* register.el ({insert,jump-to}-register)'; this is
3035 not a good idea, since searching for `jump-to-register' or
3036 `insert-register' would not find that entry.
3038 Separate unrelated change log entries with blank lines. When two
3039 entries represent parts of the same change, so that they work together,
3040 then don't put blank lines between them. Then you can omit the file
3041 name and the asterisk when successive entries are in the same file.
3043 Break long lists of function names by closing continued lines with
3044 `)', rather than `,', and opening the continuation with `(' as in this
3047 * keyboard.c (menu_bar_items, tool_bar_items)
3048 (Fexecute_extended_command): Deal with `keymap' property.
3051 File: standards.info, Node: Simple Changes, Next: Conditional Changes, Prev: Style of Change Logs, Up: Change Logs
3056 Certain simple kinds of changes don't need much detail in the change
3059 When you change the calling sequence of a function in a simple
3060 fashion, and you change all the callers of the function to use the new
3061 calling sequence, there is no need to make individual entries for all
3062 the callers that you changed. Just write in the entry for the function
3063 being called, "All callers changed"--like this:
3065 * keyboard.c (Fcommand_execute): New arg SPECIAL.
3066 All callers changed.
3068 When you change just comments or doc strings, it is enough to write
3069 an entry for the file, without mentioning the functions. Just "Doc
3070 fixes" is enough for the change log.
3072 There's no need to make change log entries for documentation files.
3073 This is because documentation is not susceptible to bugs that are hard
3074 to fix. Documentation does not consist of parts that must interact in a
3075 precisely engineered fashion. To correct an error, you need not know
3076 the history of the erroneous passage; it is enough to compare what the
3077 documentation says with the way the program actually works.
3080 File: standards.info, Node: Conditional Changes, Next: Indicating the Part Changed, Prev: Simple Changes, Up: Change Logs
3085 C programs often contain compile-time `#if' conditionals. Many
3086 changes are conditional; sometimes you add a new definition which is
3087 entirely contained in a conditional. It is very useful to indicate in
3088 the change log the conditions for which the change applies.
3090 Our convention for indicating conditional changes is to use square
3091 brackets around the name of the condition.
3093 Here is a simple example, describing a change which is conditional
3094 but does not have a function or entity name associated with it:
3096 * xterm.c [SOLARIS2]: Include string.h.
3098 Here is an entry describing a new definition which is entirely
3099 conditional. This new definition for the macro `FRAME_WINDOW_P' is
3100 used only when `HAVE_X_WINDOWS' is defined:
3102 * frame.h [HAVE_X_WINDOWS] (FRAME_WINDOW_P): Macro defined.
3104 Here is an entry for a change within the function `init_display',
3105 whose definition as a whole is unconditional, but the changes themselves
3106 are contained in a `#ifdef HAVE_LIBNCURSES' conditional:
3108 * dispnew.c (init_display) [HAVE_LIBNCURSES]: If X, call tgetent.
3110 Here is an entry for a change that takes affect only when a certain
3111 macro is _not_ defined:
3113 (gethostname) [!HAVE_SOCKETS]: Replace with winsock version.
3116 File: standards.info, Node: Indicating the Part Changed, Prev: Conditional Changes, Up: Change Logs
3118 Indicating the Part Changed
3119 ---------------------------
3121 Indicate the part of a function which changed by using angle brackets
3122 enclosing an indication of what the changed part does. Here is an entry
3123 for a change in the part of the function `sh-while-getopts' that deals
3126 * progmodes/sh-script.el (sh-while-getopts) <sh>: Handle case that
3127 user-specified option string is empty.
3130 File: standards.info, Node: Man Pages, Next: Reading other Manuals, Prev: Change Logs, Up: Documentation
3135 In the GNU project, man pages are secondary. It is not necessary or
3136 expected for every GNU program to have a man page, but some of them do.
3137 It's your choice whether to include a man page in your program.
3139 When you make this decision, consider that supporting a man page
3140 requires continual effort each time the program is changed. The time
3141 you spend on the man page is time taken away from more useful work.
3143 For a simple program which changes little, updating the man page may
3144 be a small job. Then there is little reason not to include a man page,
3147 For a large program that changes a great deal, updating a man page
3148 may be a substantial burden. If a user offers to donate a man page,
3149 you may find this gift costly to accept. It may be better to refuse
3150 the man page unless the same person agrees to take full responsibility
3151 for maintaining it--so that you can wash your hands of it entirely. If
3152 this volunteer later ceases to do the job, then don't feel obliged to
3153 pick it up yourself; it may be better to withdraw the man page from the
3154 distribution until someone else agrees to update it.
3156 When a program changes only a little, you may feel that the
3157 discrepancies are small enough that the man page remains useful without
3158 updating. If so, put a prominent note near the beginning of the man
3159 page explaining that you don't maintain it and that the Texinfo manual
3160 is more authoritative. The note should say how to access the Texinfo
3164 File: standards.info, Node: Reading other Manuals, Prev: Man Pages, Up: Documentation
3166 Reading other Manuals
3167 =====================
3169 There may be non-free books or documentation files that describe the
3170 program you are documenting.
3172 It is ok to use these documents for reference, just as the author of
3173 a new algebra textbook can read other books on algebra. A large portion
3174 of any non-fiction book consists of facts, in this case facts about how
3175 a certain program works, and these facts are necessarily the same for
3176 everyone who writes about the subject. But be careful not to copy your
3177 outline structure, wording, tables or examples from preexisting non-free
3178 documentation. Copying from free documentation may be ok; please check
3179 with the FSF about the individual case.
3182 File: standards.info, Node: Managing Releases, Next: References, Prev: Documentation, Up: Top
3187 Making a release is more than just bundling up your source files in a
3188 tar file and putting it up for FTP. You should set up your software so
3189 that it can be configured to run on a variety of systems. Your Makefile
3190 should conform to the GNU standards described below, and your directory
3191 layout should also conform to the standards discussed below. Doing so
3192 makes it easy to include your package into the larger framework of all
3197 * Configuration:: How Configuration Should Work
3198 * Makefile Conventions:: Makefile Conventions
3199 * Releases:: Making Releases
3202 File: standards.info, Node: Configuration, Next: Makefile Conventions, Up: Managing Releases
3204 How Configuration Should Work
3205 =============================
3207 Each GNU distribution should come with a shell script named
3208 `configure'. This script is given arguments which describe the kind of
3209 machine and system you want to compile the program for.
3211 The `configure' script must record the configuration options so that
3212 they affect compilation.
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
3216 you use this technique, the distribution should _not_ contain a file
3217 named `config.h'. This is so that people won't be able to build the
3218 program without configuring it first.
3220 Another thing that `configure' can do is to edit the Makefile. If
3221 you do this, the distribution should _not_ contain a file named
3222 `Makefile'. Instead, it should include a file `Makefile.in' which
3223 contains the input used for editing. Once again, this is so that people
3224 won't be able to build the program without configuring it first.
3226 If `configure' does write the `Makefile', then `Makefile' should
3227 have a target named `Makefile' which causes `configure' to be rerun,
3228 setting up the same configuration that was set up last time. The files
3229 that `configure' reads should be listed as dependencies of `Makefile'.
3231 All the files which are output from the `configure' script should
3232 have comments at the beginning explaining that they were generated
3233 automatically using `configure'. This is so that users won't think of
3234 trying to edit them by hand.
3236 The `configure' script should write a file named `config.status'
3237 which describes which configuration options were specified when the
3238 program was last configured. This file should be a shell script which,
3239 if run, will recreate the same configuration.
3241 The `configure' script should accept an option of the form
3242 `--srcdir=DIRNAME' to specify the directory where sources are found (if
3243 it is not the current directory). This makes it possible to build the
3244 program in a separate directory, so that the actual source directory is
3247 If the user does not specify `--srcdir', then `configure' should
3248 check both `.' and `..' to see if it can find the sources. If it finds
3249 the sources in one of these places, it should use them from there.
3250 Otherwise, it should report that it cannot find the sources, and should
3251 exit with nonzero status.
3253 Usually the easy way to support `--srcdir' is by editing a
3254 definition of `VPATH' into the Makefile. Some rules may need to refer
3255 explicitly to the specified source directory. To make this possible,
3256 `configure' can add to the Makefile a variable named `srcdir' whose
3257 value is precisely the specified directory.
3259 The `configure' script should also take an argument which specifies
3260 the type of system to build the program for. This argument should look
3265 For example, a Sun 3 might be `m68k-sun-sunos4.1'.
3267 The `configure' script needs to be able to decode all plausible
3268 alternatives for how to describe a machine. Thus, `sun3-sunos4.1'
3269 would be a valid alias. For many programs, `vax-dec-ultrix' would be
3270 an alias for `vax-dec-bsd', simply because the differences between
3271 Ultrix and BSD are rarely noticeable, but a few programs might need to
3274 There is a shell script called `config.sub' that you can use as a
3275 subroutine to validate system types and canonicalize aliases.
3277 Other options are permitted to specify in more detail the software
3278 or hardware present on the machine, and include or exclude optional
3279 parts of the package:
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.
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
3294 The package PACKAGE will be installed, so configure this package
3295 to work with PACKAGE.
3297 Possible values of PACKAGE include `gnu-as' (or `gas'), `gnu-ld',
3298 `gnu-libc', `gdb', `x', and `x-toolkit'.
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'
3304 All `configure' scripts should accept all of these "detail" options,
3305 whether or not they make any difference to the particular package at
3306 hand. In particular, they should accept any option that starts with
3307 `--with-' or `--enable-'. This is so users will be able to configure
3308 an entire GNU source tree at once with a single set of options.
3310 You will note that the categories `--with-' and `--enable-' are
3311 narrow: they *do not* provide a place for any sort of option you might
3312 think of. That is deliberate. We want to limit the possible
3313 configuration options in GNU software. We do not want GNU programs to
3314 have idiosyncratic configuration options.
3316 Packages that perform part of the compilation process may support
3317 cross-compilation. In such a case, the host and target machines for the
3318 program may be different.
3320 The `configure' script should normally treat the specified type of
3321 system as both the host and the target, thus producing a program which
3322 works for the same type of machine that it runs on.
3324 To configure a cross-compiler, cross-assembler, or what have you, you
3325 should specify a target different from the host, using the configure
3326 option `--target=TARGETTYPE'. The syntax for TARGETTYPE is the same as
3327 for the host type. So the command would look like this:
3329 ./configure HOSTTYPE --target=TARGETTYPE
3331 Programs for which cross-operation is not meaningful need not accept
3332 the `--target' option, because configuring an entire operating system
3333 for cross-operation is not a meaningful operation.
3335 Bootstrapping a cross-compiler requires compiling it on a machine
3336 other than the host it will run on. Compilation packages accept a
3337 configuration option `--build=BUILDTYPE' for specifying the
3338 configuration on which you will compile them, but the configure script
3339 should normally guess the build machine type (using `config.guess'), so
3340 this option is probably not necessary. The host and target types
3341 normally default from the build type, so in bootstrapping a
3342 cross-compiler you must specify them both explicitly.
3344 Some programs have ways of configuring themselves automatically. If
3345 your program is set up to do this, your `configure' script can simply
3346 ignore most of its arguments.
3349 File: standards.info, Node: Makefile Conventions, Next: Releases, Prev: Configuration, Up: Managing Releases
3351 Makefile Conventions
3352 ====================
3354 This node describes conventions for writing the Makefiles for GNU
3355 programs. Using Automake will help you write a Makefile that follows
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.
3369 File: standards.info, Node: Makefile Basics, Next: Utilities in Makefiles, Up: Makefile Conventions
3371 General Conventions for Makefiles
3372 ---------------------------------
3374 Every Makefile should contain this line:
3378 to avoid trouble on systems where the `SHELL' variable might be
3379 inherited from the environment. (This is never a problem with GNU
3382 Different `make' programs have incompatible suffix lists and
3383 implicit rules, and this sometimes creates confusion or misbehavior. So
3384 it is a good idea to set the suffix list explicitly using only the
3385 suffixes you need in the particular Makefile, like this:
3390 The first line clears out the suffix list, the second introduces all
3391 suffixes which may be subject to implicit rules in this Makefile.
3393 Don't assume that `.' is in the path for command execution. When
3394 you need to run programs that are a part of your package during the
3395 make, please make sure that it uses `./' if the program is built as
3396 part of the make or `$(srcdir)/' if the file is an unchanging part of
3397 the source code. Without one of these prefixes, the current search
3400 The distinction between `./' (the "build directory") and
3401 `$(srcdir)/' (the "source directory") is important because users can
3402 build in a separate directory using the `--srcdir' option to
3403 `configure'. A rule of the form:
3405 foo.1 : foo.man sedscript
3406 sed -e sedscript foo.man > foo.1
3408 will fail when the build directory is not the source directory, because
3409 `foo.man' and `sedscript' are in the source directory.
3411 When using GNU `make', relying on `VPATH' to find the source file
3412 will work in the case where there is a single dependency file, since
3413 the `make' automatic variable `$<' will represent the source file
3414 wherever it is. (Many versions of `make' set `$<' only in implicit
3415 rules.) A Makefile target like
3418 $(CC) -I. -I$(srcdir) $(CFLAGS) -c bar.c -o foo.o
3420 should instead be written as
3423 $(CC) -I. -I$(srcdir) $(CFLAGS) -c $< -o $@
3425 in order to allow `VPATH' to work correctly. When the target has
3426 multiple dependencies, using an explicit `$(srcdir)' is the easiest way
3427 to make the rule work well. For example, the target above for `foo.1'
3430 foo.1 : foo.man sedscript
3431 sed -e $(srcdir)/sedscript $(srcdir)/foo.man > $@
3433 GNU distributions usually contain some files which are not source
3434 files--for example, Info files, and the output from Autoconf, Automake,
3435 Bison or Flex. Since these files normally appear in the source
3436 directory, they should always appear in the source directory, not in the
3437 build directory. So Makefile rules to update them should put the
3438 updated files in the source directory.
3440 However, if a file does not appear in the distribution, then the
3441 Makefile should not put it in the source directory, because building a
3442 program in ordinary circumstances should not modify the source directory
3445 Try to make the build and installation targets, at least (and all
3446 their subtargets) work correctly with a parallel `make'.
3449 File: standards.info, Node: Utilities in Makefiles, Next: Command Variables, Prev: Makefile Basics, Up: Makefile Conventions
3451 Utilities in Makefiles
3452 ----------------------
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
3456 features of `ksh' or `bash'.
3458 The `configure' script and the Makefile rules for building and
3459 installation should not use any utilities directly except these:
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
3464 The compression program `gzip' can be used in the `dist' rule.
3466 Stick to the generally supported options for these programs. For
3467 example, don't use `mkdir -p', convenient as it may be, because most
3468 systems don't support it.
3470 It is a good idea to avoid creating symbolic links in makefiles,
3471 since a few systems don't support them.
3473 The Makefile rules for building and installation can also use
3474 compilers and related programs, but should do so via `make' variables
3475 so that the user can substitute alternatives. Here are some of the
3478 ar bison cc flex install ld ldconfig lex
3479 make makeinfo ranlib texi2dvi yacc
3481 Use the following `make' variables to run those programs:
3483 $(AR) $(BISON) $(CC) $(FLEX) $(INSTALL) $(LD) $(LDCONFIG) $(LEX)
3484 $(MAKE) $(MAKEINFO) $(RANLIB) $(TEXI2DVI) $(YACC)
3486 When you use `ranlib' or `ldconfig', you should make sure nothing
3487 bad happens if the system does not have the program in question.
3488 Arrange to ignore an error from that command, and print a message before
3489 the command to tell the user that failure of this command does not mean
3490 a problem. (The Autoconf `AC_PROG_RANLIB' macro can help with this.)
3492 If you use symbolic links, you should implement a fallback for
3493 systems that don't have symbolic links.
3495 Additional utilities that can be used via Make variables are:
3497 chgrp chmod chown mknod
3499 It is ok to use other utilities in Makefile portions (or scripts)
3500 intended only for particular systems where you know those utilities
3504 File: standards.info, Node: Command Variables, Next: Directory Variables, Prev: Utilities in Makefiles, Up: Makefile Conventions
3506 Variables for Specifying Commands
3507 ---------------------------------
3509 Makefiles should provide variables for overriding certain commands,
3512 In particular, you should run most utility programs via variables.
3513 Thus, if you use Bison, have a variable named `BISON' whose default
3514 value is set with `BISON = bison', and refer to it with `$(BISON)'
3515 whenever you need to use Bison.
3517 File management utilities such as `ln', `rm', `mv', and so on, need
3518 not be referred to through variables in this way, since users don't
3519 need to replace them with other programs.
3521 Each program-name variable should come with an options variable that
3522 is used to supply options to the program. Append `FLAGS' to the
3523 program-name variable name to get the options variable name--for
3524 example, `BISONFLAGS'. (The names `CFLAGS' for the C compiler,
3525 `YFLAGS' for yacc, and `LFLAGS' for lex, are exceptions to this rule,
3526 but we keep them because they are standard.) Use `CPPFLAGS' in any
3527 compilation command that runs the preprocessor, and use `LDFLAGS' in
3528 any compilation command that does linking as well as in any direct use
3531 If there are C compiler options that _must_ be used for proper
3532 compilation of certain files, do not include them in `CFLAGS'. Users
3533 expect to be able to specify `CFLAGS' freely themselves. Instead,
3534 arrange to pass the necessary options to the C compiler independently
3535 of `CFLAGS', by writing them explicitly in the compilation commands or
3536 by defining an implicit rule, like this:
3539 ALL_CFLAGS = -I. $(CFLAGS)
3541 $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $<
3543 Do include the `-g' option in `CFLAGS', because that is not
3544 _required_ for proper compilation. You can consider it a default that
3545 is only recommended. If the package is set up so that it is compiled
3546 with GCC by default, then you might as well include `-O' in the default
3547 value of `CFLAGS' as well.
3549 Put `CFLAGS' last in the compilation command, after other variables
3550 containing compiler options, so the user can use `CFLAGS' to override
3553 `CFLAGS' should be used in every invocation of the C compiler, both
3554 those which do compilation and those which do linking.
3556 Every Makefile should define the variable `INSTALL', which is the
3557 basic command for installing a file into the system.
3559 Every Makefile should also define the variables `INSTALL_PROGRAM'
3560 and `INSTALL_DATA'. (The default for `INSTALL_PROGRAM' should be
3561 `$(INSTALL)'; the default for `INSTALL_DATA' should be `${INSTALL} -m
3562 644'.) Then it should use those variables as the commands for actual
3563 installation, for executables and nonexecutables respectively. Use
3564 these variables as follows:
3566 $(INSTALL_PROGRAM) foo $(bindir)/foo
3567 $(INSTALL_DATA) libfoo.a $(libdir)/libfoo.a
3569 Optionally, you may prepend the value of `DESTDIR' to the target
3570 filename. Doing this allows the installer to create a snapshot of the
3571 installation to be copied onto the real target filesystem later. Do not
3572 set the value of `DESTDIR' in your Makefile, and do not include it in
3573 any installed files. With support for `DESTDIR', the above examples
3576 $(INSTALL_PROGRAM) foo $(DESTDIR)$(bindir)/foo
3577 $(INSTALL_DATA) libfoo.a $(DESTDIR)$(libdir)/libfoo.a
3579 Always use a file name, not a directory name, as the second argument of
3580 the installation commands. Use a separate command for each file to be
3584 File: standards.info, Node: Directory Variables, Next: Standard Targets, Prev: Command Variables, Up: Makefile Conventions
3586 Variables for Installation Directories
3587 --------------------------------------
3589 Installation directories should always be named by variables, so it
3590 is easy to install in a nonstandard place. The standard names for these
3591 variables are described below. They are based on a standard filesystem
3592 layout; variants of it are used in SVR4, 4.4BSD, GNU/Linux, Ultrix v4,
3593 and other modern operating systems.
3595 These two variables set the root for the installation. All the other
3596 installation directories should be subdirectories of one of these two,
3597 and nothing should be directly installed into these two directories.
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@'.)
3606 Running `make install' with a different value of `prefix' from the
3607 one used to build the program should _not_ recompile the program.
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
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
3620 Running `make install' with a different value of `exec_prefix'
3621 from the one used to build the program should _not_ recompile the
3624 Executable programs are installed in one of the following
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
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@'.)
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@'.)
3646 Data files used by the program during its execution are divided into
3647 categories in two ways.
3649 * Some files are normally modified by programs; others are never
3650 normally modified (though users may edit some of these).
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.
3657 This makes for six different possibilities. However, we want to
3658 discourage the use of architecture-dependent files, aside from object
3659 files and libraries. It is much cleaner to make other data files
3660 architecture-independent, and it is generally not hard.
3662 Therefore, here are the variables Makefiles should use to specify
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.
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@'.)
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)'.
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@'.)
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
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@'.)
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
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'.
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:
3725 lispdir='${datadir}/emacs/site-lisp'
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
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'.
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@'.)
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.
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
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.
3762 Unix-style man pages are installed in one of the following:
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
3771 The directory for installing section 1 man pages. Write it as
3775 The directory for installing section 2 man pages. Write it as
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.*
3785 The file name extension for the installed man page. This should
3786 contain a period followed by the appropriate digit; it should
3790 The file name extension for installed section 1 man pages.
3793 The file name extension for installed section 2 man pages.
3796 Use these names instead of `manext' if the package needs to
3797 install man pages in more than one section of the manual.
3799 And finally, you should set the following variable:
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@'.)
3808 # Common prefix for installation directories.
3809 # NOTE: This directory must exist when you start the install.
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
3819 If your program installs a large number of files into one of the
3820 standard user-specified directories, it might be useful to group them
3821 into a subdirectory particular to that program. If you do this, you
3822 should write the `install' rule to create these subdirectories.
3824 Do not expect the user to include the subdirectory name in the value
3825 of any of the variables listed above. The idea of having a uniform set
3826 of variable names for installation directories is to enable the user to
3827 specify the exact same values for several different GNU packages. In
3828 order for this to be useful, all the packages must be designed so that
3829 they will work sensibly when the user does so.
3832 File: standards.info, Node: Standard Targets, Next: Install Command Categories, Prev: Directory Variables, Up: Makefile Conventions
3834 Standard Targets for Users
3835 --------------------------
3837 All GNU programs should have the following targets in their
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.
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.
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.
3856 Do not strip executables when installing them. Devil-may-care
3857 users can use the `install-strip' target to do that.
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
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
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.
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:
3883 $(DESTDIR)$(infodir)/foo.info: foo.info
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; \
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
3906 Delete all the installed files--the copies that the `install'
3909 This rule should not modify the directories where compilation is
3910 done, only the directories where files are installed.
3912 The uninstallation commands are divided into three categories,
3913 just like the installation commands. *Note Install Command
3917 Like `install', but strip the executable files while installing
3918 them. In simple cases, this target can use the `install' target in
3922 $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \
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.
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.
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.
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
3945 Delete `.dvi' files here if they are not part of the distribution.
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
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.
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.
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.
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.
3982 To help make users aware of this, the commands for the special
3983 `maintainer-clean' target should start with these two:
3985 @echo 'This command is intended for maintainers to use; it'
3986 @echo 'deletes files that may need special tools to rebuild.'
3989 Update a tags table for this program.
3992 Generate any Info files needed. The best way to write the rules
3997 foo.info: foo.texi chap1.texi chap2.texi
3998 $(MAKEINFO) $(srcdir)/foo.texi
4000 You must define the variable `MAKEINFO' in the Makefile. It should
4001 run the `makeinfo' program, which is part of the Texinfo
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.
4011 Generate DVI files for all Texinfo documentation. For example:
4015 foo.dvi: foo.texi chap1.texi chap2.texi
4016 $(TEXI2DVI) $(srcdir)/foo.texi
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.
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.
4029 For example, the distribution tar file of GCC version 1.40 unpacks
4030 into a subdirectory named `gcc-1.40'.
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.
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'.
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.
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.
4049 The following targets are suggested as conventional names, for
4050 programs in which they are useful.
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.
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:
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) \
4071 or, if you wish to support `DESTDIR',
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) \
4081 This rule should not modify the directories where compilation is
4082 done. It should do nothing but create installation directories.
4084 ---------- Footnotes ----------
4086 (1) `texi2dvi' uses TeX to do the real work of formatting. TeX is
4087 not distributed with Texinfo.
4090 File: standards.info, Node: Install Command Categories, Prev: Standard Targets, Up: Makefile Conventions
4092 Install Command Categories
4093 --------------------------
4095 When writing the `install' target, you must classify all the
4096 commands into three categories: normal ones, "pre-installation"
4097 commands and "post-installation" commands.
4099 Normal commands move files into their proper places, and set their
4100 modes. They may not alter any files except the ones that come entirely
4101 from the package they belong to.
4103 Pre-installation and post-installation commands may alter other
4104 files; in particular, they can edit global configuration files or data
4107 Pre-installation commands are typically executed before the normal
4108 commands, and post-installation commands are typically run after the
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
4113 alters a file (the Info directory) which does not come entirely and
4114 solely from the package being installed. It is a post-installation
4115 command because it needs to be done after the normal command which
4116 installs the package's Info files.
4118 Most programs don't need any pre-installation commands, but we have
4119 the feature just in case it is needed.
4121 To classify the commands in the `install' rule into these three
4122 categories, insert "category lines" among them. A category line
4123 specifies the category for the commands that follow.
4125 A category line consists of a tab and a reference to a special Make
4126 variable, plus an optional comment at the end. There are three
4127 variables you can use, one for each category; the variable name
4128 specifies the category. Category lines are no-ops in ordinary execution
4129 because these three Make variables are normally undefined (and you
4130 _should not_ define them in the makefile).
4132 Here are the three possible category lines, each with a comment that
4133 explains what it means:
4135 $(PRE_INSTALL) # Pre-install commands follow.
4136 $(POST_INSTALL) # Post-install commands follow.
4137 $(NORMAL_INSTALL) # Normal commands follow.
4139 If you don't use a category line at the beginning of the `install'
4140 rule, all the commands are classified as normal until the first category
4141 line. If you don't use any category lines, all the commands are
4142 classified as normal.
4144 These are the category lines for `uninstall':
4146 $(PRE_UNINSTALL) # Pre-uninstall commands follow.
4147 $(POST_UNINSTALL) # Post-uninstall commands follow.
4148 $(NORMAL_UNINSTALL) # Normal commands follow.
4150 Typically, a pre-uninstall command would be used for deleting entries
4151 from the Info directory.
4153 If the `install' or `uninstall' target has any dependencies which
4154 act as subroutines of installation, then you should start _each_
4155 dependency's commands with a category line, and start the main target's
4156 commands with a category line also. This way, you can ensure that each
4157 command is placed in the right category regardless of which of the
4158 dependencies actually run.
4160 Pre-installation and post-installation commands should not run any
4161 programs except for these:
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
4169 The reason for distinguishing the commands in this way is for the
4170 sake of making binary packages. Typically a binary package contains
4171 all the executables and other files that need to be installed, and has
4172 its own method of installing them--so it does not need to run the normal
4173 installation commands. But installing the binary package does need to
4174 execute the pre-installation and post-installation commands.
4176 Programs to build binary packages work by extracting the
4177 pre-installation and post-installation commands. Here is one way of
4178 extracting the pre-installation commands:
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
4186 where the file `pre-install.awk' could contain this:
4188 $0 ~ /^\t[ \t]*(normal_install|post_install)[ \t]*$/ {on = 0}
4190 $0 ~ /^\t[ \t]*pre_install[ \t]*$/ {on = 1}
4192 The resulting file of pre-installation commands is executed as a
4193 shell script as part of installing the binary package.
4196 File: standards.info, Node: Releases, Prev: Makefile Conventions, Up: Managing Releases
4201 Package the distribution of `Foo version 69.96' up in a gzipped tar
4202 file with the name `foo-69.96.tar.gz'. It should unpack into a
4203 subdirectory named `foo-69.96'.
4205 Building and installing the program should never modify any of the
4206 files contained in the distribution. This means that all the files
4207 that form part of the program in any way must be classified into "source
4208 files" and "non-source files". Source files are written by humans and
4209 never changed automatically; non-source files are produced from source
4210 files by programs under the control of the Makefile.
4212 The distribution should contain a file named `README' which gives
4213 the name of the package, and a general description of what it does. It
4214 is also good to explain the purpose of each of the first-level
4215 subdirectories in the package, if there are any. The `README' file
4216 should either state the version number of the package, or refer to where
4217 in the package it can be found.
4219 The `README' file should refer to the file `INSTALL', which should
4220 contain an explanation of the installation procedure.
4222 The `README' file should also refer to the file which contains the
4223 copying 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
4227 Naturally, all the source files must be in the distribution. It is
4228 okay to include non-source files in the distribution, provided they are
4229 up-to-date and machine-independent, so that building the distribution
4230 normally will never modify them. We commonly include non-source files
4231 produced by Bison, `lex', TeX, and `makeinfo'; this helps avoid
4232 unnecessary dependencies between our distributions, so that users can
4233 install whichever packages they want to install.
4235 Non-source files that might actually be modified by building and
4236 installing the program should *never* be included in the distribution.
4237 So if you do distribute non-source files, always make sure they are up
4238 to date when you make a new distribution.
4240 Make sure that the directory into which the distribution unpacks (as
4241 well as any subdirectories) are all world-writable (octal mode 777).
4242 This is so that old versions of `tar' which preserve the ownership and
4243 permissions of the files from the tar archive will be able to extract
4244 all the files even if the user is unprivileged.
4246 Make sure that all the files in the distribution are world-readable.
4248 Make sure that no file name in the distribution is more than 14
4249 characters long. Likewise, no file created by building the program
4250 should have a name longer than 14 characters. The reason for this is
4251 that some systems adhere to a foolish interpretation of the POSIX
4252 standard, and refuse to open a longer name, rather than truncating as
4253 they did in the past.
4255 Don't include any symbolic links in the distribution itself. If the
4256 tar file contains symbolic links, then people cannot even unpack it on
4257 systems that don't support symbolic links. Also, don't use multiple
4258 names for one file in different directories, because certain file
4259 systems cannot handle this and that prevents unpacking the distribution.
4261 Try to make sure that all the file names will be unique on MS-DOS. A
4262 name on MS-DOS consists of up to 8 characters, optionally followed by a
4263 period and up to three characters. MS-DOS will truncate extra
4264 characters both before and after the period. Thus, `foobarhacker.c'
4265 and `foobarhacker.o' are not ambiguous; they are truncated to
4266 `foobarha.c' and `foobarha.o', which are distinct.
4268 Include in your distribution a copy of the `texinfo.tex' you used to
4269 test print any `*.texinfo' or `*.texi' files.
4271 Likewise, if your program uses small GNU software packages like
4272 regex, getopt, obstack, or termcap, include them in the distribution
4273 file. Leaving them out would make the distribution file a little
4274 smaller at the expense of possible inconvenience to a user who doesn't
4275 know what other files to get.
4278 File: standards.info, Node: References, Next: Copying This Manual, Prev: Managing Releases, Up: Top
4280 References to Non-Free Software and Documentation
4281 *************************************************
4283 A GNU program should not recommend use of any non-free program. We
4284 can't stop some people from writing proprietary programs, or stop other
4285 people from using them, but we can and should avoid helping to
4286 advertise them to new potential customers. Proprietary software is a
4287 social and ethical problem, and the point of GNU is to solve that
4290 When a non-free program or system is well known, you can mention it
4291 in passing--that is harmless, since users who might want to use it
4292 probably already know about it. For instance, it is fine to explain
4293 how to build your package on top of some non-free operating system, or
4294 how to use it together with some widely used non-free program.
4296 However, you should give only the necessary information to help those
4297 who already use the non-free program to use your program with it--don't
4298 give, or refer to, any further information about the proprietary
4299 program, and don't imply that the proprietary program enhances your
4300 program, or that its existence is in any way a good thing. The goal
4301 should be that people already using the proprietary program will get
4302 the advice they need about how to use your free program, while people
4303 who don't already use the proprietary program will not see anything to
4304 lead them to take an interest in it.
4306 If a non-free program or system is obscure in your program's domain,
4307 your program should not mention or support it at all, since doing so
4308 would tend to popularize the non-free program more than it popularizes
4309 your program. (You cannot hope to find many additional users among the
4310 users of Foobar if the users of Foobar are few.)
4312 A GNU package should not refer the user to any non-free documentation
4313 for free software. Free documentation that can be included in free
4314 operating systems is essential for completing the GNU system, so it is
4315 a major focus of the GNU Project; to recommend use of documentation
4316 that we are not allowed to use in GNU would undermine the efforts to
4317 get documentation that we can include. So GNU packages should never
4318 recommend non-free documentation.
4321 File: standards.info, Node: Copying This Manual, Next: Index, Prev: References, Up: Top
4328 * GNU Free Documentation License:: License for copying this manual
4331 File: standards.info, Node: GNU Free Documentation License, Up: Copying This Manual
4333 GNU Free Documentation License
4334 ******************************
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
4340 Everyone is permitted to copy and distribute verbatim copies
4341 of this license document, but changing it is not allowed.
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.
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.
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.
4369 1. APPLICABILITY AND DEFINITIONS
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."
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.
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.
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
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.
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."
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.
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.
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.
4443 You may also lend copies, under the same conditions stated above,
4444 and you may publicly display copies.
4446 3. COPYING IN QUANTITY
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
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
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.
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.
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:
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
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
4516 G. Preserve in that license notice the full lists of Invariant
4517 Sections and required Cover Texts given in the Document's
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
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.
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.
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
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.
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.
4577 5. COMBINING DOCUMENTS
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.
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
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."
4602 6. COLLECTIONS OF DOCUMENTS
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.
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
4617 7. AGGREGATION WITH INDEPENDENT WORKS
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.
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
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.
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.
4659 10. FUTURE REVISIONS OF THIS LICENSE
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/.
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.
4678 ADDENDUM: How to use this License for your documents
4679 ====================================================
4681 To use this License in a document you have written, include a copy of
4682 the License in the document and put the following copyright and license
4683 notices just after the title page:
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."
4694 If you have no Invariant Sections, write "with no Invariant Sections"
4695 instead of saying which ones are invariant. If you have no Front-Cover
4696 Texts, write "no Front-Cover Texts" instead of "Front-Cover Texts being
4697 LIST"; likewise for Back-Cover Texts.
4699 If your document contains nontrivial examples of program code, we
4700 recommend releasing these examples in parallel under your choice of
4701 free software license, such as the GNU General Public License, to
4702 permit their use in free software.
4705 File: standards.info, Node: Index, Prev: Copying This Manual, Up: Top
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.
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.
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.
4833 Node: Preface
\x7f1404
4834 Node: Legal Issues
\x7f3623
4835 Node: Reading Non-Free Code
\x7f4086
4836 Node: Contributions
\x7f5809
4837 Node: Trademarks
\x7f7958
4838 Node: Design Advice
\x7f9016
4839 Node: Source Language
\x7f9599
4840 Node: Compatibility
\x7f11606
4841 Node: Using Extensions
\x7f13229
4842 Node: Standard C
\x7f14800
4843 Node: Conditional Compilation
\x7f17198
4844 Node: Program Behavior
\x7f18492
4845 Node: Semantics
\x7f19410
4846 Node: Libraries
\x7f24098
4847 Node: Errors
\x7f25338
4848 Node: User Interfaces
\x7f27114
4849 Node: Graphical Interfaces
\x7f28714
4850 Node: Command-Line Interfaces
\x7f29744
4851 Node: Option Table
\x7f35810
4852 Node: Memory Usage
\x7f50814
4853 Node: File Usage
\x7f51834
4854 Node: Writing C
\x7f52577
4855 Node: Formatting
\x7f53426
4856 Node: Comments
\x7f57484
4857 Node: Syntactic Conventions
\x7f60782
4858 Node: Names
\x7f64189
4859 Node: System Portability
\x7f66393
4860 Node: CPU Portability
\x7f68773
4861 Node: System Functions
\x7f72024
4862 Node: Internationalization
\x7f77226
4864 Node: Documentation
\x7f81079
4865 Node: GNU Manuals
\x7f82183
4866 Node: Doc Strings and Manuals
\x7f87235
4867 Node: Manual Structure Details
\x7f88783
4868 Node: License for Manuals
\x7f90196
4869 Node: Manual Credits
\x7f91165
4870 Node: Printed Manuals
\x7f91553
4871 Node: NEWS File
\x7f92234
4872 Node: Change Logs
\x7f92906
4873 Node: Change Log Concepts
\x7f93655
4874 Node: Style of Change Logs
\x7f95510
4875 Node: Simple Changes
\x7f97556
4876 Node: Conditional Changes
\x7f98791
4877 Node: Indicating the Part Changed
\x7f100204
4878 Node: Man Pages
\x7f100722
4879 Node: Reading other Manuals
\x7f102341
4880 Node: Managing Releases
\x7f103125
4881 Node: Configuration
\x7f103887
4882 Node: Makefile Conventions
\x7f110787
4883 Node: Makefile Basics
\x7f111588
4884 Node: Utilities in Makefiles
\x7f114753
4885 Node: Command Variables
\x7f116889
4886 Node: Directory Variables
\x7f120457
4887 Node: Standard Targets
\x7f131342
4888 Ref: Standard Targets-Footnote-1
\x7f142593
4889 Node: Install Command Categories
\x7f142693
4890 Node: Releases
\x7f147266
4891 Node: References
\x7f151349
4892 Node: Copying This Manual
\x7f153633
4893 Node: GNU Free Documentation License
\x7f153847
4894 Node: Index
\x7f173533