1 This is standards.info, produced by makeinfo version 4.8 from
2 .././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 1 About the GNU Coding Standards
43 ********************************
45 The GNU Coding Standards were written by Richard Stallman and other GNU
46 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 2 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 2.1 Referring to Proprietary Programs
103 =====================================
105 Don't in any circumstances refer to Unix source code for or during your
106 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 2.2 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 3 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 3.1 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 3.2 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 3.3 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 3.4 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 3.5 Conditional Compilation
408 ===========================
410 When supporting configuration options already known when building your
411 program we prefer using `if (... )' over conditional compilation, as in
412 the former case the compiler is able to perform more extensive checking
413 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 4 Program Behavior for All Programs
453 ***********************************
455 This node describes conventions for writing robust software. It also
456 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 4.1 Writing Robust Programs
475 ===========================
477 Avoid arbitrary limits on the length or number of _any_ data structure,
478 including file names, lines, files, and symbols, by allocating all data
479 structures dynamically. In most Unix utilities, "long lines are
480 silently truncated". This is not acceptable in a GNU utility.
482 Utilities reading files should not drop NUL characters, or any other
483 nonprinting characters _including those with codes above 0177_. The
484 only sensible exceptions would be utilities specifically intended for
485 interface to certain types of terminals or printers that can't handle
486 those characters. Whenever possible, try to make programs work
487 properly with sequences of bytes that represent multibyte characters,
488 using encodings such as UTF-8 and others.
490 Check every system call for an error return, unless you know you
491 wish to ignore errors. Include the system error text (from `perror' or
492 equivalent) in _every_ error message resulting from a failing system
493 call, as well as the name of the file if any and the name of the
494 utility. Just "cannot open foo.c" or "stat failed" is not sufficient.
496 Check every call to `malloc' or `realloc' to see if it returned
497 zero. Check `realloc' even if you are making the block smaller; in a
498 system that rounds block sizes to a power of 2, `realloc' may get a
499 different block if you ask for less space.
501 In Unix, `realloc' can destroy the storage block if it returns zero.
502 GNU `realloc' does not have this bug: if it fails, the original block
503 is unchanged. Feel free to assume the bug is fixed. If you wish to
504 run your program on Unix, and wish to avoid lossage in this case, you
505 can use the GNU `malloc'.
507 You must expect `free' to alter the contents of the block that was
508 freed. Anything you want to fetch from the block, you must fetch before
511 If `malloc' fails in a noninteractive program, make that a fatal
512 error. In an interactive program (one that reads commands from the
513 user), it is better to abort the command and return to the command
514 reader loop. This allows the user to kill other processes to free up
515 virtual memory, and then try the command again.
517 Use `getopt_long' to decode arguments, unless the argument syntax
518 makes this unreasonable.
520 When static storage is to be written in during program execution, use
521 explicit C code to initialize it. Reserve C initialized declarations
522 for data that will not be changed.
524 Try to avoid low-level interfaces to obscure Unix data structures
525 (such as file directories, utmp, or the layout of kernel memory), since
526 these are less likely to work compatibly. If you need to find all the
527 files in a directory, use `readdir' or some other high-level interface.
528 These are supported compatibly by GNU.
530 The preferred signal handling facilities are the BSD variant of
531 `signal', and the POSIX `sigaction' function; the alternative USG
532 `signal' interface is an inferior design.
534 Nowadays, using the POSIX signal functions may be the easiest way to
535 make a program portable. If you use `signal', then on GNU/Linux
536 systems running GNU libc version 1, you should include `bsd/signal.h'
537 instead of `signal.h', so as to get BSD behavior. It is up to you
538 whether to support systems where `signal' has only the USG behavior, or
541 In error checks that detect "impossible" conditions, just abort.
542 There is usually no point in printing any message. These checks
543 indicate the existence of bugs. Whoever wants to fix the bugs will have
544 to read the source code and run a debugger. So explain the problem with
545 comments in the source. The relevant data will be in variables, which
546 are easy to examine with the debugger, so there is no point moving them
549 Do not use a count of errors as the exit status for a program.
550 _That does not work_, because exit status values are limited to 8 bits
551 (0 through 255). A single run of the program might have 256 errors; if
552 you try to return 256 as the exit status, the parent process will see 0
553 as the status, and it will appear that the program succeeded.
555 If you make temporary files, check the `TMPDIR' environment
556 variable; if that variable is defined, use the specified directory
559 In addition, be aware that there is a possible security problem when
560 creating temporary files in world-writable directories. In C, you can
561 avoid this problem by creating temporary files in this manner:
563 fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0600);
565 or by using the `mkstemps' function from libiberty.
567 In bash, use `set -C' to avoid this problem.
570 File: standards.info, Node: Libraries, Next: Errors, Prev: Semantics, Up: Program Behavior
575 Try to make library functions reentrant. If they need to do dynamic
576 storage allocation, at least try to avoid any nonreentrancy aside from
577 that of `malloc' itself.
579 Here are certain name conventions for libraries, to avoid name
582 Choose a name prefix for the library, more than two characters long.
583 All external function and variable names should start with this prefix.
584 In addition, there should only be one of these in any given library
585 member. This usually means putting each one in a separate source file.
587 An exception can be made when two external symbols are always used
588 together, so that no reasonable program could use one without the
589 other; then they can both go in the same file.
591 External symbols that are not documented entry points for the user
592 should have names beginning with `_'. The `_' should be followed by
593 the chosen name prefix for the library, to prevent collisions with
594 other libraries. These can go in the same files with user entry points
597 Static functions and variables can be used as you like and need not
598 fit any naming convention.
601 File: standards.info, Node: Errors, Next: User Interfaces, Prev: Libraries, Up: Program Behavior
603 4.3 Formatting Error Messages
604 =============================
606 Error messages from compilers should look like this:
608 SOURCE-FILE-NAME:LINENO: MESSAGE
610 If you want to mention the column number, use this format:
612 SOURCE-FILE-NAME:LINENO:COLUMN: MESSAGE
614 Line numbers should start from 1 at the beginning of the file, and
615 column numbers should start from 1 at the beginning of the line. (Both
616 of these conventions are chosen for compatibility.) Calculate column
617 numbers assuming that space and all ASCII printing characters have
618 equal width, and assuming tab stops every 8 columns.
620 Error messages from other noninteractive programs should look like
623 PROGRAM:SOURCE-FILE-NAME:LINENO: MESSAGE
625 when there is an appropriate source file, or like this:
629 when there is no relevant source file.
631 If you want to mention the column number, use this format:
633 PROGRAM:SOURCE-FILE-NAME:LINENO:COLUMN: MESSAGE
635 In an interactive program (one that is reading commands from a
636 terminal), it is better not to include the program name in an error
637 message. The place to indicate which program is running is in the
638 prompt or with the screen layout. (When the same program runs with
639 input from a source other than a terminal, it is not interactive and
640 would do best to print error messages using the noninteractive style.)
642 The string MESSAGE should not begin with a capital letter when it
643 follows a program name and/or file name. Also, it should not end with
646 Error messages from interactive programs, and other messages such as
647 usage messages, should start with a capital letter. But they should not
651 File: standards.info, Node: User Interfaces, Next: Graphical Interfaces, Prev: Errors, Up: Program Behavior
653 4.4 Standards for Interfaces Generally
654 ======================================
656 Please don't make the behavior of a utility depend on the name used to
657 invoke it. It is useful sometimes to make a link to a utility with a
658 different name, and that should not change what it does.
660 Instead, use a run time option or a compilation switch or both to
661 select among the alternate behaviors.
663 Likewise, please don't make the behavior of the program depend on the
664 type of output device it is used with. Device independence is an
665 important principle of the system's design; do not compromise it merely
666 to save someone from typing an option now and then. (Variation in error
667 message syntax when using a terminal is ok, because that is a side issue
668 that people do not depend on.)
670 If you think one behavior is most useful when the output is to a
671 terminal, and another is most useful when the output is a file or a
672 pipe, then it is usually best to make the default behavior the one that
673 is useful with output to a terminal, and have an option for the other
676 Compatibility requires certain programs to depend on the type of
677 output device. It would be disastrous if `ls' or `sh' did not do so in
678 the way all users expect. In some of these cases, we supplement the
679 program with a preferred alternate version that does not depend on the
680 output device type. For example, we provide a `dir' program much like
681 `ls' except that its default output format is always multi-column
685 File: standards.info, Node: Graphical Interfaces, Next: Command-Line Interfaces, Prev: User Interfaces, Up: Program Behavior
687 4.5 Standards for Graphical Interfaces
688 ======================================
690 When you write a program that provides a graphical user interface,
691 please make it work with X Windows and the GTK toolkit unless the
692 functionality specifically requires some alternative (for example,
693 "displaying jpeg images while in console mode").
695 In addition, please provide a command-line interface to control the
696 functionality. (In many cases, the graphical user interface can be a
697 separate program which invokes the command-line program.) This is so
698 that the same jobs can be done from scripts.
700 Please also consider providing a CORBA interface (for use from
701 GNOME), a library interface (for use from C), and perhaps a
702 keyboard-driven console interface (for use by users from console mode).
703 Once you are doing the work to provide the functionality and the
704 graphical interface, these won't be much extra work.
707 File: standards.info, Node: Command-Line Interfaces, Next: Option Table, Prev: Graphical Interfaces, Up: Program Behavior
709 4.6 Standards for Command Line Interfaces
710 =========================================
712 It is a good idea to follow the POSIX guidelines for the command-line
713 options of a program. The easiest way to do this is to use `getopt' to
714 parse them. Note that the GNU version of `getopt' will normally permit
715 options anywhere among the arguments unless the special argument `--'
716 is used. This is not what POSIX specifies; it is a GNU extension.
718 Please define long-named options that are equivalent to the
719 single-letter Unix-style options. We hope to make GNU more user
720 friendly this way. This is easy to do with the GNU function
723 One of the advantages of long-named options is that they can be
724 consistent from program to program. For example, users should be able
725 to expect the "verbose" option of any GNU program which has one, to be
726 spelled precisely `--verbose'. To achieve this uniformity, look at the
727 table of common long-option names when you choose the option names for
728 your program (*note Option Table::).
730 It is usually a good idea for file names given as ordinary arguments
731 to be input files only; any output files would be specified using
732 options (preferably `-o' or `--output'). Even if you allow an output
733 file name as an ordinary argument for compatibility, try to provide an
734 option as another way to specify it. This will lead to more consistency
735 among GNU utilities, and fewer idiosyncracies for users to remember.
737 All programs should support two standard options: `--version' and
741 This option should direct the program to print information about
742 its name, version, origin and legal status, all on standard
743 output, and then exit successfully. Other options and arguments
744 should be ignored once this is seen, and the program should not
745 perform its normal function.
747 The first line is meant to be easy for a program to parse; the
748 version number proper starts after the last space. In addition,
749 it contains the canonical name for this program, in this format:
753 The program's name should be a constant string; _don't_ compute it
754 from `argv[0]'. The idea is to state the standard or canonical
755 name for the program, not its file name. There are other ways to
756 find out the precise file name where a command is found in `PATH'.
758 If the program is a subsidiary part of a larger package, mention
759 the package name in parentheses, like this:
761 emacsserver (GNU Emacs) 19.30
763 If the package has a version number which is different from this
764 program's version number, you can mention the package version
765 number just before the close-parenthesis.
767 If you *need* to mention the version numbers of libraries which
768 are distributed separately from the package which contains this
769 program, you can do so by printing an additional line of version
770 info for each library you want to mention. Use the same format
771 for these lines as for the first line.
773 Please do not mention all of the libraries that the program uses
774 "just for completeness"--that would produce a lot of unhelpful
775 clutter. Please mention library version numbers only if you find
776 in practice that they are very important to you in debugging.
778 The following line, after the version number line or lines, should
779 be a copyright notice. If more than one copyright notice is
780 called for, put each on a separate line.
782 Next should follow a brief statement that the program is free
783 software, and that users are free to copy and change it on certain
784 conditions. If the program is covered by the GNU GPL, say so
785 here. Also mention that there is no warranty, to the extent
788 It is ok to finish the output with a list of the major authors of
789 the program, as a way of giving credit.
791 Here's an example of output that follows these rules:
794 Copyright (C) 1996 Free Software Foundation, Inc.
795 GNU Emacs comes with NO WARRANTY,
796 to the extent permitted by law.
797 You may redistribute copies of GNU Emacs
798 under the terms of the GNU General Public License.
799 For more information about these matters,
800 see the files named COPYING.
802 You should adapt this to your program, of course, filling in the
803 proper year, copyright holder, name of program, and the references
804 to distribution terms, and changing the rest of the wording as
807 This copyright notice only needs to mention the most recent year in
808 which changes were made--there's no need to list the years for
809 previous versions' changes. You don't have to mention the name of
810 the program in these notices, if that is inconvenient, since it
811 appeared in the first line.
813 Translations of the above lines must preserve the validity of the
814 copyright notices (*note Internationalization::). If the
815 translation's character set supports it, the `(C)' should be
816 replaced with the copyright symbol, as follows:
818 (the official copyright symbol, which is the letter C in a circle);
820 Write the word "Copyright" exactly like that, in English. Do not
821 translate it into another language. International treaties
822 recognize the English word "Copyright"; translations into other
823 languages do not have legal significance.
826 This option should output brief documentation for how to invoke the
827 program, on standard output, then exit successfully. Other
828 options and arguments should be ignored once this is seen, and the
829 program should not perform its normal function.
831 Near the end of the `--help' option's output there should be a line
832 that says where to mail bug reports. It should have this format:
834 Report bugs to MAILING-ADDRESS.
837 File: standards.info, Node: Option Table, Next: Memory Usage, Prev: Command-Line Interfaces, Up: Program Behavior
839 4.7 Table of Long Options
840 =========================
842 Here is a table of long options used by GNU programs. It is surely
843 incomplete, but we aim to list all the options that a new program might
844 want to be compatible with. If you use names not already in the table,
845 please send <bug-standards@gnu.org> a list of them, with their
846 meanings, so we can update the table.
852 `-a' in `du', `ls', `nm', `stty', `uname', and `unexpand'.
861 `-a' in `etags', `tee', `time'; `-r' in `tar'.
897 For server programs, run in the background.
915 `-b' in `cpio' and `diff'.
921 Used in `cpio' and `tar'.
924 `-b' in `head' and `tail'.
930 Used in various programs to make output shorter.
933 `-c' in `head', `split', and `tail'.
942 Used in various programs to specify the directory to use.
945 `-c' in `chgrp' and `chown'.
954 `-c' in `su'; `-x' in GDB.
963 `-Z' in `tar' and `shar'.
975 `-W copyleft' in `gawk'.
978 `-C' in `ptx', `recode', and `wdiff'; `-W copyright' in `gawk'.
990 Used in `tar' and `cpio'.
1002 `-d' in Make and `m4'; `-t' in Bison.
1008 `-d' in Bison and `ctags'.
1014 `-L' in `chgrp', `chown', `cpio', `du', `ls', and `tar'.
1020 Specify an I/O device (special file name).
1035 Specify the directory to use, in various programs. In `ls', it
1036 means to show directories themselves rather than their contents.
1037 In `rm' and `ln', it means to not treat links to directories
1064 `environment-overrides'
1104 `-i' in `cpio'; `-x' in `tar'.
1116 `-f' in `info', `gawk', Make, `mt', and `tar'; `-n' in `sed'; `-r'
1137 `fixed-output-files'
1147 `-f' in `cp', `ln', `mv', and `rm'.
1153 For server programs, run in the foreground; in other words, don't
1154 do anything special to run the server in the background.
1157 Used in `ls', `time', and `ptx'.
1181 `-z' in `tar' and `shar'.
1187 `-h' in `objdump' and `recode'
1193 Used to ask for brief usage information.
1198 `hide-control-chars'
1202 In `makeinfo', output HTML.
1211 `-I' in `ls'; `-x' in `recode'.
1219 `ignore-blank-lines'
1223 `-f' in `look' and `ptx'; `-i' in `diff' and `wdiff'.
1231 `ignore-indentation'
1240 `ignore-matching-lines'
1243 `ignore-space-change'
1250 `-i' in `etags'; `-I' in `m4'.
1259 `-i', `-l', and `-m' in Finger.
1262 In some programs, specify the name of the file to read as the
1275 `-i' in `cp', `ln', `mv', `rm'; `-e' in `m4'; `-p' in `xargs';
1297 `-k' in `du' and `ls'.
1312 Used in `split', `head', and `tail'.
1322 `-t' in `cpio'; `-l' in `recode'.
1337 No listing of which programs already use this; someone should
1338 check to see if any actually do, and tell <gnu@gnu.org>.
1344 `-m' in `hello' and `uname'.
1383 `-m' in `install', `mkdir', and `mkfifo'.
1406 `no-character-count'
1464 Used in `emacsclient'.
1467 Used in various programs to inhibit warnings.
1494 `-n' in `cpio' and `ls'.
1506 `-l' in `tar', `cp', and `du'.
1518 `-o' in `getopt', `fdlist', `fdmount', `fdmountd', and `fdumount'.
1521 In various programs, specify the output file name.
1542 `-p' in `mkdir' and `rmdir'.
1554 `-c' in `cpio' and `tar'.
1566 Used in `tar' and `cp'.
1568 `preserve-environment'
1571 `preserve-modification-time'
1577 `preserve-permissions'
1605 Specify an HTTP proxy.
1614 Used in many programs to inhibit the usual output. *Note_* every
1615 program accepting `--quiet' should accept `--silent' as a synonym.
1642 Used in `chgrp', `chown', `cp', `ls', `diff', and `rm'.
1651 `-r' in `tac' and `etags'.
1668 `report-identical-files'
1675 `-r' in `ls' and `nm'.
1705 Used by `recode' to chose files or pipes for sequencing passes.
1719 `show-function-line'
1726 Used in many programs to inhibit the usual output. *Note_* every
1727 program accepting `--silent' should accept `--quiet' as a synonym.
1733 Specify a file descriptor for a network server to use for its
1734 socket, instead of opening and binding a new socket. This
1735 provides a way to run, in a nonpriveledged process, a server that
1736 normally needs a reserved port number.
1742 `-W source' in `gawk'.
1766 Used in `tar' and `diff' to specify which file within a directory
1767 to start processing with.
1794 `-S' in `cp', `ln', `mv'.
1809 Used in GDB and `objdump'.
1818 `-t' in `expand' and `unexpand'.
1824 `-T' in `tput' and `ul'. `-t' in `wdiff'.
1833 Used in `ls' and `touch'.
1836 Specify how long to wait before giving up on some operation.
1845 `-t' in Make, `ranlib', and `recode'.
1851 `-t' in `hello'; `-W traditional' in `gawk'; `-G' in `ed', `m4',
1879 `-u' in `cp', `ctags', `mv', `tar'.
1882 Used in `gawk'; same as `--help'.
1891 Print more information about progress. Many programs support this.
1897 Print the version number.
1900 `-V' in `cp', `ln', `mv'.
1915 `-w' in `ls' and `ptx'.
1927 File: standards.info, Node: Memory Usage, Next: File Usage, Prev: Option Table, Up: Program Behavior
1932 If a program typically uses just a few meg of memory, don't bother
1933 making any effort to reduce memory usage. For example, if it is
1934 impractical for other reasons to operate on files more than a few meg
1935 long, it is reasonable to read entire input files into core to operate
1938 However, for programs such as `cat' or `tail', that can usefully
1939 operate on very large files, it is important to avoid using a technique
1940 that would artificially limit the size of files it can handle. If a
1941 program works by lines and could be applied to arbitrary user-supplied
1942 input files, it should keep only a line in memory, because this is not
1943 very hard and users will want to be able to operate on input files that
1944 are bigger than will fit in core all at once.
1946 If your program creates complicated data structures, just make them
1947 in core and give a fatal error if `malloc' returns zero.
1950 File: standards.info, Node: File Usage, Prev: Memory Usage, Up: Program Behavior
1955 Programs should be prepared to operate when `/usr' and `/etc' are
1956 read-only file systems. Thus, if the program manages log files, lock
1957 files, backup files, score files, or any other files which are modified
1958 for internal purposes, these files should not be stored in `/usr' or
1961 There are two exceptions. `/etc' is used to store system
1962 configuration information; it is reasonable for a program to modify
1963 files in `/etc' when its job is to update the system configuration.
1964 Also, if the user explicitly asks to modify one file in a directory, it
1965 is reasonable for the program to store other files in the same
1969 File: standards.info, Node: Writing C, Next: Documentation, Prev: Program Behavior, Up: Top
1971 5 Making The Best Use of C
1972 **************************
1974 This node provides advice on how best to use the C language when
1975 writing GNU software.
1979 * Formatting:: Formatting Your Source Code
1980 * Comments:: Commenting Your Work
1981 * Syntactic Conventions:: Clean Use of C Constructs
1982 * Names:: Naming Variables, Functions, and Files
1983 * System Portability:: Portability between different operating systems
1984 * CPU Portability:: Supporting the range of CPU types
1985 * System Functions:: Portability and ``standard'' library functions
1986 * Internationalization:: Techniques for internationalization
1987 * Mmap:: How you can safely use `mmap'.
1990 File: standards.info, Node: Formatting, Next: Comments, Up: Writing C
1992 5.1 Formatting Your Source Code
1993 ===============================
1995 It is important to put the open-brace that starts the body of a C
1996 function in column zero, and avoid putting any other open-brace or
1997 open-parenthesis or open-bracket in column zero. Several tools look
1998 for open-braces in column zero to find the beginnings of C functions.
1999 These tools will not work on code not formatted that way.
2001 It is also important for function definitions to start the name of
2002 the function in column zero. This helps people to search for function
2003 definitions, and may also help certain tools recognize them. Thus, the
2004 proper format is this:
2007 concat (s1, s2) /* Name starts in column zero here */
2009 { /* Open brace in column zero here */
2013 or, if you want to use Standard C syntax, format the definition like
2017 concat (char *s1, char *s2)
2022 In Standard C, if the arguments don't fit nicely on one line, split
2026 lots_of_args (int an_integer, long a_long, short a_short,
2027 double a_double, float a_float)
2030 The rest of this section gives our recommendations for other aspects
2031 of C formatting style, which is also the default style of the `indent'
2032 program in version 1.2 and newer. It corresponds to the options
2034 -nbad -bap -nbc -bbo -bl -bli2 -bls -ncdb -nce -cp1 -cs -di2
2035 -ndj -nfc1 -nfca -hnl -i2 -ip5 -lp -pcs -psl -nsc -nsob
2037 We don't think of these recommendations as requirements, because it
2038 causes no problems for users if two different programs have different
2041 But whatever style you use, please use it consistently, since a
2042 mixture of styles within one program tends to look ugly. If you are
2043 contributing changes to an existing program, please follow the style of
2046 For the body of the function, our recommended style looks like this:
2057 return ++x + bar ();
2060 We find it easier to read a program when it has spaces before the
2061 open-parentheses and after the commas. Especially after the commas.
2063 When you split an expression into multiple lines, split it before an
2064 operator, not after one. Here is the right way:
2066 if (foo_this_is_long && bar > win (x, y, z)
2067 && remaining_condition)
2069 Try to avoid having two operators of different precedence at the same
2070 level of indentation. For example, don't write this:
2072 mode = (inmode[j] == VOIDmode
2073 || GET_MODE_SIZE (outmode[j]) > GET_MODE_SIZE (inmode[j])
2074 ? outmode[j] : inmode[j]);
2076 Instead, use extra parentheses so that the indentation shows the
2079 mode = ((inmode[j] == VOIDmode
2080 || (GET_MODE_SIZE (outmode[j]) > GET_MODE_SIZE (inmode[j])))
2081 ? outmode[j] : inmode[j]);
2083 Insert extra parentheses so that Emacs will indent the code properly.
2084 For example, the following indentation looks nice if you do it by hand,
2086 v = rup->ru_utime.tv_sec*1000 + rup->ru_utime.tv_usec/1000
2087 + rup->ru_stime.tv_sec*1000 + rup->ru_stime.tv_usec/1000;
2089 but Emacs would alter it. Adding a set of parentheses produces
2090 something that looks equally nice, and which Emacs will preserve:
2092 v = (rup->ru_utime.tv_sec*1000 + rup->ru_utime.tv_usec/1000
2093 + rup->ru_stime.tv_sec*1000 + rup->ru_stime.tv_usec/1000);
2095 Format do-while statements like this:
2103 Please use formfeed characters (control-L) to divide the program into
2104 pages at logical places (but not within a function). It does not matter
2105 just how long the pages are, since they do not have to fit on a printed
2106 page. The formfeeds should appear alone on lines by themselves.
2109 File: standards.info, Node: Comments, Next: Syntactic Conventions, Prev: Formatting, Up: Writing C
2111 5.2 Commenting Your Work
2112 ========================
2114 Every program should start with a comment saying briefly what it is for.
2115 Example: `fmt - filter for simple filling of text'.
2117 Please write the comments in a GNU program in English, because
2118 English is the one language that nearly all programmers in all
2119 countries can read. If you do not write English well, please write
2120 comments in English as well as you can, then ask other people to help
2121 rewrite them. If you can't write comments in English, please find
2122 someone to work with you and translate your comments into English.
2124 Please put a comment on each function saying what the function does,
2125 what sorts of arguments it gets, and what the possible values of
2126 arguments mean and are used for. It is not necessary to duplicate in
2127 words the meaning of the C argument declarations, if a C type is being
2128 used in its customary fashion. If there is anything nonstandard about
2129 its use (such as an argument of type `char *' which is really the
2130 address of the second character of a string, not the first), or any
2131 possible values that would not work the way one would expect (such as,
2132 that strings containing newlines are not guaranteed to work), be sure
2135 Also explain the significance of the return value, if there is one.
2137 Please put two spaces after the end of a sentence in your comments,
2138 so that the Emacs sentence commands will work. Also, please write
2139 complete sentences and capitalize the first word. If a lower-case
2140 identifier comes at the beginning of a sentence, don't capitalize it!
2141 Changing the spelling makes it a different identifier. If you don't
2142 like starting a sentence with a lower case letter, write the sentence
2143 differently (e.g., "The identifier lower-case is ...").
2145 The comment on a function is much clearer if you use the argument
2146 names to speak about the argument values. The variable name itself
2147 should be lower case, but write it in upper case when you are speaking
2148 about the value rather than the variable itself. Thus, "the inode
2149 number NODE_NUM" rather than "an inode".
2151 There is usually no purpose in restating the name of the function in
2152 the comment before it, because the reader can see that for himself.
2153 There might be an exception when the comment is so long that the
2154 function itself would be off the bottom of the screen.
2156 There should be a comment on each static variable as well, like this:
2158 /* Nonzero means truncate lines in the display;
2159 zero means continue them. */
2162 Every `#endif' should have a comment, except in the case of short
2163 conditionals (just a few lines) that are not nested. The comment should
2164 state the condition of the conditional that is ending, _including its
2165 sense_. `#else' should have a comment describing the condition _and
2166 sense_ of the code that follows. For example:
2172 #endif /* not foo */
2177 but, by contrast, write the comments this way for a `#ifndef':
2186 #endif /* not foo */
2189 File: standards.info, Node: Syntactic Conventions, Next: Names, Prev: Comments, Up: Writing C
2191 5.3 Clean Use of C Constructs
2192 =============================
2194 Please explicitly declare the types of all objects. For example, you
2195 should explicitly declare all arguments to functions, and you should
2196 declare functions to return `int' rather than omitting the `int'.
2198 Some programmers like to use the GCC `-Wall' option, and change the
2199 code whenever it issues a warning. If you want to do this, then do.
2200 Other programmers prefer not to use `-Wall', because it gives warnings
2201 for valid and legitimate code which they do not want to change. If you
2202 want to do this, then do. The compiler should be your servant, not
2205 Declarations of external functions and functions to appear later in
2206 the source file should all go in one place near the beginning of the
2207 file (somewhere before the first function definition in the file), or
2208 else should go in a header file. Don't put `extern' declarations inside
2211 It used to be common practice to use the same local variables (with
2212 names like `tem') over and over for different values within one
2213 function. Instead of doing this, it is better declare a separate local
2214 variable for each distinct purpose, and give it a name which is
2215 meaningful. This not only makes programs easier to understand, it also
2216 facilitates optimization by good compilers. You can also move the
2217 declaration of each local variable into the smallest scope that includes
2218 all its uses. This makes the program even cleaner.
2220 Don't use local variables or parameters that shadow global
2223 Don't declare multiple variables in one declaration that spans lines.
2224 Start a new declaration on each line, instead. For example, instead of
2239 (If they are global variables, each should have a comment preceding it
2242 When you have an `if'-`else' statement nested in another `if'
2243 statement, always put braces around the `if'-`else'. Thus, never write
2262 If you have an `if' statement nested inside of an `else' statement,
2263 either write `else if' on one line, like this,
2270 with its `then'-part indented like the preceding `then'-part, or write
2271 the nested `if' within braces like this:
2281 Don't declare both a structure tag and variables or typedefs in the
2282 same declaration. Instead, declare the structure tag separately and
2283 then use it to declare the variables or typedefs.
2285 Try to avoid assignments inside `if'-conditions. For example, don't
2288 if ((foo = (char *) malloc (sizeof *foo)) == 0)
2289 fatal ("virtual memory exhausted");
2291 instead, write this:
2293 foo = (char *) malloc (sizeof *foo);
2295 fatal ("virtual memory exhausted");
2297 Don't make the program ugly to placate `lint'. Please don't insert
2298 any casts to `void'. Zero without a cast is perfectly fine as a null
2299 pointer constant, except when calling a varargs function.
2302 File: standards.info, Node: Names, Next: System Portability, Prev: Syntactic Conventions, Up: Writing C
2304 5.4 Naming Variables, Functions, and Files
2305 ==========================================
2307 The names of global variables and functions in a program serve as
2308 comments of a sort. So don't choose terse names--instead, look for
2309 names that give useful information about the meaning of the variable or
2310 function. In a GNU program, names should be English, like other
2313 Local variable names can be shorter, because they are used only
2314 within one context, where (presumably) comments explain their purpose.
2316 Try to limit your use of abbreviations in symbol names. It is ok to
2317 make a few abbreviations, explain what they mean, and then use them
2318 frequently, but don't use lots of obscure abbreviations.
2320 Please use underscores to separate words in a name, so that the Emacs
2321 word commands can be useful within them. Stick to lower case; reserve
2322 upper case for macros and `enum' constants, and for name-prefixes that
2323 follow a uniform convention.
2325 For example, you should use names like `ignore_space_change_flag';
2326 don't use names like `iCantReadThis'.
2328 Variables that indicate whether command-line options have been
2329 specified should be named after the meaning of the option, not after
2330 the option-letter. A comment should state both the exact meaning of
2331 the option and its letter. For example,
2333 /* Ignore changes in horizontal whitespace (-b). */
2334 int ignore_space_change_flag;
2336 When you want to define names with constant integer values, use
2337 `enum' rather than `#define'. GDB knows about enumeration constants.
2339 You might want to make sure that none of the file names would
2340 conflict the files were loaded onto an MS-DOS file system which
2341 shortens the names. You can use the program `doschk' to test for this.
2343 Some GNU programs were designed to limit themselves to file names of
2344 14 characters or less, to avoid file name conflicts if they are read
2345 into older System V systems. Please preserve this feature in the
2346 existing GNU programs that have it, but there is no need to do this in
2347 new GNU programs. `doschk' also reports file names longer than 14
2351 File: standards.info, Node: System Portability, Next: CPU Portability, Prev: Names, Up: Writing C
2353 5.5 Portability between System Types
2354 ====================================
2356 In the Unix world, "portability" refers to porting to different Unix
2357 versions. For a GNU program, this kind of portability is desirable, but
2360 The primary purpose of GNU software is to run on top of the GNU
2361 kernel, compiled with the GNU C compiler, on various types of CPU. So
2362 the kinds of portability that are absolutely necessary are quite
2363 limited. But it is important to support Linux-based GNU systems, since
2364 they are the form of GNU that is popular.
2366 Beyond that, it is good to support the other free operating systems
2367 (*BSD), and it is nice to support other Unix-like systems if you want
2368 to. Supporting a variety of Unix-like systems is desirable, although
2369 not paramount. It is usually not too hard, so you may as well do it.
2370 But you don't have to consider it an obligation, if it does turn out to
2373 The easiest way to achieve portability to most Unix-like systems is
2374 to use Autoconf. It's unlikely that your program needs to know more
2375 information about the host platform than Autoconf can provide, simply
2376 because most of the programs that need such knowledge have already been
2379 Avoid using the format of semi-internal data bases (e.g.,
2380 directories) when there is a higher-level alternative (`readdir').
2382 As for systems that are not like Unix, such as MSDOS, Windows, the
2383 Macintosh, VMS, and MVS, supporting them is often a lot of work. When
2384 that is the case, it is better to spend your time adding features that
2385 will be useful on GNU and GNU/Linux, rather than on supporting other
2386 incompatible systems.
2388 It is a good idea to define the "feature test macro" `_GNU_SOURCE'
2389 when compiling your C files. When you compile on GNU or GNU/Linux,
2390 this will enable the declarations of GNU library extension functions,
2391 and that will usually give you a compiler error message if you define
2392 the same function names in some other way in your program. (You don't
2393 have to actually _use_ these functions, if you prefer to make the
2394 program more portable to other systems.)
2396 But whether or not you use these GNU extensions, you should avoid
2397 using their names for any other meanings. Doing so would make it hard
2398 to move your code into other GNU programs.
2401 File: standards.info, Node: CPU Portability, Next: System Functions, Prev: System Portability, Up: Writing C
2403 5.6 Portability between CPUs
2404 ============================
2406 Even GNU systems will differ because of differences among CPU
2407 types--for example, difference in byte ordering and alignment
2408 requirements. It is absolutely essential to handle these differences.
2409 However, don't make any effort to cater to the possibility that an
2410 `int' will be less than 32 bits. We don't support 16-bit machines in
2413 Similarly, don't make any effort to cater to the possibility that
2414 `long' will be smaller than predefined types like `size_t'. For
2415 example, the following code is ok:
2417 printf ("size = %lu\n", (unsigned long) sizeof array);
2418 printf ("diff = %ld\n", (long) (pointer2 - pointer1));
2420 1989 Standard C requires this to work, and we know of only one
2421 counterexample: 64-bit programs on Microsoft Windows IA-64. We will
2422 leave it to those who want to port GNU programs to that environment to
2423 figure out how to do it.
2425 Predefined file-size types like `off_t' are an exception: they are
2426 longer than `long' on many platforms, so code like the above won't work
2427 with them. One way to print an `off_t' value portably is to print its
2428 digits yourself, one by one.
2430 Don't assume that the address of an `int' object is also the address
2431 of its least-significant byte. This is false on big-endian machines.
2432 Thus, don't make the following mistake:
2436 while ((c = getchar()) != EOF)
2437 write(file_descriptor, &c, 1);
2439 When calling functions, you need not worry about the difference
2440 between pointers of various types, or between pointers and integers.
2441 On most machines, there's no difference anyway. As for the few
2442 machines where there is a difference, all of them support Standard C
2443 prototypes, so you can use prototypes (perhaps conditionalized to be
2444 active only in Standard C) to make the code work on those systems.
2446 In certain cases, it is ok to pass integer and pointer arguments
2447 indiscriminately to the same function, and use no prototype on any
2448 system. For example, many GNU programs have error-reporting functions
2449 that pass their arguments along to `printf' and friends:
2451 error (s, a1, a2, a3)
2455 fprintf (stderr, "error: ");
2456 fprintf (stderr, s, a1, a2, a3);
2459 In practice, this works on all machines, since a pointer is generally
2460 the widest possible kind of argument; it is much simpler than any
2461 "correct" alternative. Be sure _not_ to use a prototype for such
2464 If you have decided to use Standard C, then you can instead define
2465 `error' using `stdarg.h', and pass the arguments along to `vfprintf'.
2467 Avoid casting pointers to integers if you can. Such casts greatly
2468 reduce portability, and in most programs they are easy to avoid. In the
2469 cases where casting pointers to integers is essential--such as, a Lisp
2470 interpreter which stores type information as well as an address in one
2471 word--you'll have to make explicit provisions to handle different word
2472 sizes. You will also need to make provision for systems in which the
2473 normal range of addresses you can get from `malloc' starts far away
2477 File: standards.info, Node: System Functions, Next: Internationalization, Prev: CPU Portability, Up: Writing C
2479 5.7 Calling System Functions
2480 ============================
2482 C implementations differ substantially. Standard C reduces but does
2483 not eliminate the incompatibilities; meanwhile, many GNU packages still
2484 support pre-standard compilers because this is not hard to do. This
2485 chapter gives recommendations for how to use the more-or-less standard C
2486 library functions to avoid unnecessary loss of portability.
2488 * Don't use the return value of `sprintf'. It returns the number of
2489 characters written on some systems, but not on all systems.
2491 * Be aware that `vfprintf' is not always available.
2493 * `main' should be declared to return type `int'. It should
2494 terminate either by calling `exit' or by returning the integer
2495 status code; make sure it cannot ever return an undefined value.
2497 * Don't declare system functions explicitly.
2499 Almost any declaration for a system function is wrong on some
2500 system. To minimize conflicts, leave it to the system header
2501 files to declare system functions. If the headers don't declare a
2502 function, let it remain undeclared.
2504 While it may seem unclean to use a function without declaring it,
2505 in practice this works fine for most system library functions on
2506 the systems where this really happens; thus, the disadvantage is
2507 only theoretical. By contrast, actual declarations have
2508 frequently caused actual conflicts.
2510 * If you must declare a system function, don't specify the argument
2511 types. Use an old-style declaration, not a Standard C prototype.
2512 The more you specify about the function, the more likely a
2515 * In particular, don't unconditionally declare `malloc' or `realloc'.
2517 Most GNU programs use those functions just once, in functions
2518 conventionally named `xmalloc' and `xrealloc'. These functions
2519 call `malloc' and `realloc', respectively, and check the results.
2521 Because `xmalloc' and `xrealloc' are defined in your program, you
2522 can declare them in other files without any risk of type conflict.
2524 On most systems, `int' is the same length as a pointer; thus, the
2525 calls to `malloc' and `realloc' work fine. For the few
2526 exceptional systems (mostly 64-bit machines), you can use
2527 *conditionalized* declarations of `malloc' and `realloc'--or put
2528 these declarations in configuration files specific to those
2531 * The string functions require special treatment. Some Unix systems
2532 have a header file `string.h'; others have `strings.h'. Neither
2533 file name is portable. There are two things you can do: use
2534 Autoconf to figure out which file to include, or don't include
2537 * If you don't include either strings file, you can't get
2538 declarations for the string functions from the header file in the
2541 That causes less of a problem than you might think. The newer
2542 standard string functions should be avoided anyway because many
2543 systems still don't support them. The string functions you can
2546 strcpy strncpy strcat strncat
2547 strlen strcmp strncmp
2550 The copy and concatenate functions work fine without a declaration
2551 as long as you don't use their values. Using their values without
2552 a declaration fails on systems where the width of a pointer
2553 differs from the width of `int', and perhaps in other cases. It
2554 is trivial to avoid using their values, so do that.
2556 The compare functions and `strlen' work fine without a declaration
2557 on most systems, possibly all the ones that GNU software runs on.
2558 You may find it necessary to declare them *conditionally* on a few
2561 The search functions must be declared to return `char *'. Luckily,
2562 there is no variation in the data type they return. But there is
2563 variation in their names. Some systems give these functions the
2564 names `index' and `rindex'; other systems use the names `strchr'
2565 and `strrchr'. Some systems support both pairs of names, but
2566 neither pair works on all systems.
2568 You should pick a single pair of names and use it throughout your
2569 program. (Nowadays, it is better to choose `strchr' and `strrchr'
2570 for new programs, since those are the standard names.) Declare
2571 both of those names as functions returning `char *'. On systems
2572 which don't support those names, define them as macros in terms of
2573 the other pair. For example, here is what to put at the beginning
2574 of your file (or in a header) if you want to use the names
2575 `strchr' and `strrchr' throughout:
2578 #define strchr index
2580 #ifndef HAVE_STRRCHR
2581 #define strrchr rindex
2587 Here we assume that `HAVE_STRCHR' and `HAVE_STRRCHR' are macros
2588 defined in systems where the corresponding functions exist. One way to
2589 get them properly defined is to use Autoconf.
2592 File: standards.info, Node: Internationalization, Next: Mmap, Prev: System Functions, Up: Writing C
2594 5.8 Internationalization
2595 ========================
2597 GNU has a library called GNU gettext that makes it easy to translate the
2598 messages in a program into various languages. You should use this
2599 library in every program. Use English for the messages as they appear
2600 in the program, and let gettext provide the way to translate them into
2603 Using GNU gettext involves putting a call to the `gettext' macro
2604 around each string that might need translation--like this:
2606 printf (gettext ("Processing file `%s'..."));
2608 This permits GNU gettext to replace the string `"Processing file
2609 `%s'..."' with a translated version.
2611 Once a program uses gettext, please make a point of writing calls to
2612 `gettext' when you add new strings that call for translation.
2614 Using GNU gettext in a package involves specifying a "text domain
2615 name" for the package. The text domain name is used to separate the
2616 translations for this package from the translations for other packages.
2617 Normally, the text domain name should be the same as the name of the
2618 package--for example, `fileutils' for the GNU file utilities.
2620 To enable gettext to work well, avoid writing code that makes
2621 assumptions about the structure of words or sentences. When you want
2622 the precise text of a sentence to vary depending on the data, use two or
2623 more alternative string constants each containing a complete sentences,
2624 rather than inserting conditionalized words or phrases into a single
2627 Here is an example of what not to do:
2629 printf ("%d file%s processed", nfiles,
2630 nfiles != 1 ? "s" : "");
2632 The problem with that example is that it assumes that plurals are made
2633 by adding `s'. If you apply gettext to the format string, like this,
2635 printf (gettext ("%d file%s processed"), nfiles,
2636 nfiles != 1 ? "s" : "");
2638 the message can use different words, but it will still be forced to use
2639 `s' for the plural. Here is a better way:
2641 printf ((nfiles != 1 ? "%d files processed"
2642 : "%d file processed"),
2645 This way, you can apply gettext to each of the two strings
2648 printf ((nfiles != 1 ? gettext ("%d files processed")
2649 : gettext ("%d file processed")),
2652 This can be any method of forming the plural of the word for "file", and
2653 also handles languages that require agreement in the word for
2656 A similar problem appears at the level of sentence structure with
2659 printf ("# Implicit rule search has%s been done.\n",
2660 f->tried_implicit ? "" : " not");
2662 Adding `gettext' calls to this code cannot give correct results for all
2663 languages, because negation in some languages requires adding words at
2664 more than one place in the sentence. By contrast, adding `gettext'
2665 calls does the job straightfowardly if the code starts out like this:
2667 printf (f->tried_implicit
2668 ? "# Implicit rule search has been done.\n",
2669 : "# Implicit rule search has not been done.\n");
2672 File: standards.info, Node: Mmap, Prev: Internationalization, Up: Writing C
2677 Don't assume that `mmap' either works on all files or fails for all
2678 files. It may work on some files and fail on others.
2680 The proper way to use `mmap' is to try it on the specific file for
2681 which you want to use it--and if `mmap' doesn't work, fall back on
2682 doing the job in another way using `read' and `write'.
2684 The reason this precaution is needed is that the GNU kernel (the
2685 HURD) provides a user-extensible file system, in which there can be many
2686 different kinds of "ordinary files." Many of them support `mmap', but
2687 some do not. It is important to make programs handle all these kinds
2691 File: standards.info, Node: Documentation, Next: Managing Releases, Prev: Writing C, Up: Top
2693 6 Documenting Programs
2694 **********************
2696 A GNU program should ideally come with full free documentation, adequate
2697 for both reference and tutorial purposes. If the package can be
2698 programmed or extended, the documentation should cover programming or
2699 extending it, as well as just using it.
2703 * GNU Manuals:: Writing proper manuals.
2704 * Doc Strings and Manuals:: Compiling doc strings doesn't make a manual.
2705 * Manual Structure Details:: Specific structure conventions.
2706 * License for Manuals:: Writing the distribution terms for a manual.
2707 * Manual Credits:: Giving credit to documentation contributors.
2708 * Printed Manuals:: Mentioning the printed manual.
2709 * NEWS File:: NEWS files supplement manuals.
2710 * Change Logs:: Recording Changes
2711 * Man Pages:: Man pages are secondary.
2712 * Reading other Manuals:: How far you can go in learning
2716 File: standards.info, Node: GNU Manuals, Next: Doc Strings and Manuals, Up: Documentation
2721 The preferred document format for the GNU system is the Texinfo
2722 formatting language. Every GNU package should (ideally) have
2723 documentation in Texinfo both for reference and for learners. Texinfo
2724 makes it possible to produce a good quality formatted book, using TeX,
2725 and to generate an Info file. It is also possible to generate HTML
2726 output from Texinfo source. See the Texinfo manual, either the
2727 hardcopy, or the on-line version available through `info' or the Emacs
2728 Info subsystem (`C-h i').
2730 Nowadays some other formats such as Docbook and Sgmltexi can be
2731 converted automatically into Texinfo. It is ok to produce the Texinfo
2732 documentation by conversion this way, as long as it gives good results.
2734 Programmers often find it most natural to structure the documentation
2735 following the structure of the implementation, which they know. But
2736 this structure is not necessarily good for explaining how to use the
2737 program; it may be irrelevant and confusing for a user.
2739 At every level, from the sentences in a paragraph to the grouping of
2740 topics into separate manuals, the right way to structure documentation
2741 is according to the concepts and questions that a user will have in mind
2742 when reading it. Sometimes this structure of ideas matches the
2743 structure of the implementation of the software being documented--but
2744 often they are different. Often the most important part of learning to
2745 write good documentation is learning to notice when you are structuring
2746 the documentation like the implementation, and think about better
2749 For example, each program in the GNU system probably ought to be
2750 documented in one manual; but this does not mean each program should
2751 have its own manual. That would be following the structure of the
2752 implementation, rather than the structure that helps the user
2755 Instead, each manual should cover a coherent _topic_. For example,
2756 instead of a manual for `diff' and a manual for `diff3', we have one
2757 manual for "comparison of files" which covers both of those programs,
2758 as well as `cmp'. By documenting these programs together, we can make
2759 the whole subject clearer.
2761 The manual which discusses a program should certainly document all of
2762 the program's command-line options and all of its commands. It should
2763 give examples of their use. But don't organize the manual as a list of
2764 features. Instead, organize it logically, by subtopics. Address the
2765 questions that a user will ask when thinking about the job that the
2768 In general, a GNU manual should serve both as tutorial and reference.
2769 It should be set up for convenient access to each topic through Info,
2770 and for reading straight through (appendixes aside). A GNU manual
2771 should give a good introduction to a beginner reading through from the
2772 start, and should also provide all the details that hackers want. The
2773 Bison manual is a good example of this--please take a look at it to see
2776 That is not as hard as it first sounds. Arrange each chapter as a
2777 logical breakdown of its topic, but order the sections, and write their
2778 text, so that reading the chapter straight through makes sense. Do
2779 likewise when structuring the book into chapters, and when structuring a
2780 section into paragraphs. The watchword is, _at each point, address the
2781 most fundamental and important issue raised by the preceding text._
2783 If necessary, add extra chapters at the beginning of the manual which
2784 are purely tutorial and cover the basics of the subject. These provide
2785 the framework for a beginner to understand the rest of the manual. The
2786 Bison manual provides a good example of how to do this.
2788 To serve as a reference, a manual should have an Index that list all
2789 the functions, variables, options, and important concepts that are part
2790 of the program. One combined Index should do for a short manual, but
2791 sometimes for a complex package it is better to use multiple indices.
2792 The Texinfo manual includes advice on preparing good index entries, see
2793 *Note Making Index Entries: (texinfo)Index Entries, and see *Note
2794 Defining the Entries of an Index: (texinfo)Indexing Commands.
2796 Don't use Unix man pages as a model for how to write GNU
2797 documentation; most of them are terse, badly structured, and give
2798 inadequate explanation of the underlying concepts. (There are, of
2799 course, some exceptions.) Also, Unix man pages use a particular format
2800 which is different from what we use in GNU manuals.
2802 Please include an email address in the manual for where to report
2803 bugs _in the manual_.
2805 Please do not use the term "pathname" that is used in Unix
2806 documentation; use "file name" (two words) instead. We use the term
2807 "path" only for search paths, which are lists of directory names.
2809 Please do not use the term "illegal" to refer to erroneous input to a
2810 computer program. Please use "invalid" for this, and reserve the term
2811 "illegal" for activities punishable by law.
2814 File: standards.info, Node: Doc Strings and Manuals, Next: Manual Structure Details, Prev: GNU Manuals, Up: Documentation
2816 6.2 Doc Strings and Manuals
2817 ===========================
2819 Some programming systems, such as Emacs, provide a documentation string
2820 for each function, command or variable. You may be tempted to write a
2821 reference manual by compiling the documentation strings and writing a
2822 little additional text to go around them--but you must not do it. That
2823 approach is a fundamental mistake. The text of well-written
2824 documentation strings will be entirely wrong for a manual.
2826 A documentation string needs to stand alone--when it appears on the
2827 screen, there will be no other text to introduce or explain it.
2828 Meanwhile, it can be rather informal in style.
2830 The text describing a function or variable in a manual must not stand
2831 alone; it appears in the context of a section or subsection. Other text
2832 at the beginning of the section should explain some of the concepts, and
2833 should often make some general points that apply to several functions or
2834 variables. The previous descriptions of functions and variables in the
2835 section will also have given information about the topic. A description
2836 written to stand alone would repeat some of that information; this
2837 redundance looks bad. Meanwhile, the informality that is acceptable in
2838 a documentation string is totally unacceptable in a manual.
2840 The only good way to use documentation strings in writing a good
2841 manual is to use them as a source of information for writing good text.
2844 File: standards.info, Node: Manual Structure Details, Next: License for Manuals, Prev: Doc Strings and Manuals, Up: Documentation
2846 6.3 Manual Structure Details
2847 ============================
2849 The title page of the manual should state the version of the programs or
2850 packages documented in the manual. The Top node of the manual should
2851 also contain this information. If the manual is changing more
2852 frequently than or independent of the program, also state a version
2853 number for the manual in both of these places.
2855 Each program documented in the manual should have a node named
2856 `PROGRAM Invocation' or `Invoking PROGRAM'. This node (together with
2857 its subnodes, if any) should describe the program's command line
2858 arguments and how to run it (the sort of information people would look
2859 in a man page for). Start with an `@example' containing a template for
2860 all the options and arguments that the program uses.
2862 Alternatively, put a menu item in some menu whose item name fits one
2863 of the above patterns. This identifies the node which that item points
2864 to as the node for this purpose, regardless of the node's actual name.
2866 The `--usage' feature of the Info reader looks for such a node or
2867 menu item in order to find the relevant text, so it is essential for
2868 every Texinfo file to have one.
2870 If one manual describes several programs, it should have such a node
2871 for each program described in the manual.
2874 File: standards.info, Node: License for Manuals, Next: Manual Credits, Prev: Manual Structure Details, Up: Documentation
2876 6.4 License for Manuals
2877 =======================
2879 Please use the GNU Free Documentation License for all GNU manuals that
2880 are more than a few pages long. Likewise for a collection of short
2881 documents--you only need one copy of the GNU FDL for the whole
2882 collection. For a single short document, you can use a very permissive
2883 non-copyleft license, to avoid taking up space with a long license.
2885 See `http://www.gnu.org/copyleft/fdl-howto.html' for more explanation
2886 of how to employ the GFDL.
2888 Note that it is not obligatory to include a copy of the GNU GPL or
2889 GNU LGPL in a manual whose license is neither the GPL nor the LGPL. It
2890 can be a good idea to include the program's license in a large manual;
2891 in a short manual, whose size would be increased considerably by
2892 including the program's license, it is probably better not to include
2896 File: standards.info, Node: Manual Credits, Next: Printed Manuals, Prev: License for Manuals, Up: Documentation
2901 Please credit the principal human writers of the manual as the authors,
2902 on the title page of the manual. If a company sponsored the work, thank
2903 the company in a suitable place in the manual, but do not cite the
2904 company as an author.
2907 File: standards.info, Node: Printed Manuals, Next: NEWS File, Prev: Manual Credits, Up: Documentation
2912 The FSF publishes some GNU manuals in printed form. To encourage sales
2913 of these manuals, the on-line versions of the manual should mention at
2914 the very start that the printed manual is available and should point at
2915 information for getting it--for instance, with a link to the page
2916 `http://www.gnu.org/order/order.html'. This should not be included in
2917 the printed manual, though, because there it is redundant.
2919 It is also useful to explain in the on-line forms of the manual how
2920 the user can print out the manual from the sources.
2923 File: standards.info, Node: NEWS File, Next: Change Logs, Prev: Printed Manuals, Up: Documentation
2928 In addition to its manual, the package should have a file named `NEWS'
2929 which contains a list of user-visible changes worth mentioning. In
2930 each new release, add items to the front of the file and identify the
2931 version they pertain to. Don't discard old items; leave them in the
2932 file after the newer items. This way, a user upgrading from any
2933 previous version can see what is new.
2935 If the `NEWS' file gets very long, move some of the older items into
2936 a file named `ONEWS' and put a note at the end referring the user to
2940 File: standards.info, Node: Change Logs, Next: Man Pages, Prev: NEWS File, Up: Documentation
2945 Keep a change log to describe all the changes made to program source
2946 files. The purpose of this is so that people investigating bugs in the
2947 future will know about the changes that might have introduced the bug.
2948 Often a new bug can be found by looking at what was recently changed.
2949 More importantly, change logs can help you eliminate conceptual
2950 inconsistencies between different parts of a program, by giving you a
2951 history of how the conflicting concepts arose and who they came from.
2955 * Change Log Concepts::
2956 * Style of Change Logs::
2958 * Conditional Changes::
2959 * Indicating the Part Changed::
2962 File: standards.info, Node: Change Log Concepts, Next: Style of Change Logs, Up: Change Logs
2964 6.8.1 Change Log Concepts
2965 -------------------------
2967 You can think of the change log as a conceptual "undo list" which
2968 explains how earlier versions were different from the current version.
2969 People can see the current version; they don't need the change log to
2970 tell them what is in it. What they want from a change log is a clear
2971 explanation of how the earlier version differed.
2973 The change log file is normally called `ChangeLog' and covers an
2974 entire directory. Each directory can have its own change log, or a
2975 directory can use the change log of its parent directory-it's up to you.
2977 Another alternative is to record change log information with a
2978 version control system such as RCS or CVS. This can be converted
2979 automatically to a `ChangeLog' file using `rcs2log'; in Emacs, the
2980 command `C-x v a' (`vc-update-change-log') does the job.
2982 There's no need to describe the full purpose of the changes or how
2983 they work together. If you think that a change calls for explanation,
2984 you're probably right. Please do explain it--but please put the
2985 explanation in comments in the code, where people will see it whenever
2986 they see the code. For example, "New function" is enough for the
2987 change log when you add a function, because there should be a comment
2988 before the function definition to explain what it does.
2990 However, sometimes it is useful to write one line to describe the
2991 overall purpose of a batch of changes.
2993 The easiest way to add an entry to `ChangeLog' is with the Emacs
2994 command `M-x add-change-log-entry'. An entry should have an asterisk,
2995 the name of the changed file, and then in parentheses the name of the
2996 changed functions, variables or whatever, followed by a colon. Then
2997 describe the changes you made to that function or variable.
3000 File: standards.info, Node: Style of Change Logs, Next: Simple Changes, Prev: Change Log Concepts, Up: Change Logs
3002 6.8.2 Style of Change Logs
3003 --------------------------
3005 Here are some simple examples of change log entries, starting with the
3006 header line that says who made the change and when, followed by
3007 descriptions of specific changes. (These examples are drawn from Emacs
3010 1998-08-17 Richard Stallman <rms@gnu.org>
3012 * register.el (insert-register): Return nil.
3013 (jump-to-register): Likewise.
3015 * sort.el (sort-subr): Return nil.
3017 * tex-mode.el (tex-bibtex-file, tex-file, tex-region):
3018 Restart the tex shell if process is gone or stopped.
3019 (tex-shell-running): New function.
3021 * expr.c (store_one_arg): Round size up for move_block_to_reg.
3022 (expand_call): Round up when emitting USE insns.
3023 * stmt.c (assign_parms): Round size up for move_block_from_reg.
3025 It's important to name the changed function or variable in full.
3026 Don't abbreviate function or variable names, and don't combine them.
3027 Subsequent maintainers will often search for a function name to find all
3028 the change log entries that pertain to it; if you abbreviate the name,
3029 they won't find it when they search.
3031 For example, some people are tempted to abbreviate groups of function
3032 names by writing `* register.el ({insert,jump-to}-register)'; this is
3033 not a good idea, since searching for `jump-to-register' or
3034 `insert-register' would not find that entry.
3036 Separate unrelated change log entries with blank lines. When two
3037 entries represent parts of the same change, so that they work together,
3038 then don't put blank lines between them. Then you can omit the file
3039 name and the asterisk when successive entries are in the same file.
3041 Break long lists of function names by closing continued lines with
3042 `)', rather than `,', and opening the continuation with `(' as in this
3045 * keyboard.c (menu_bar_items, tool_bar_items)
3046 (Fexecute_extended_command): Deal with `keymap' property.
3049 File: standards.info, Node: Simple Changes, Next: Conditional Changes, Prev: Style of Change Logs, Up: Change Logs
3051 6.8.3 Simple Changes
3052 --------------------
3054 Certain simple kinds of changes don't need much detail in the change
3057 When you change the calling sequence of a function in a simple
3058 fashion, and you change all the callers of the function to use the new
3059 calling sequence, there is no need to make individual entries for all
3060 the callers that you changed. Just write in the entry for the function
3061 being called, "All callers changed"--like this:
3063 * keyboard.c (Fcommand_execute): New arg SPECIAL.
3064 All callers changed.
3066 When you change just comments or doc strings, it is enough to write
3067 an entry for the file, without mentioning the functions. Just "Doc
3068 fixes" is enough for the change log.
3070 There's no need to make change log entries for documentation files.
3071 This is because documentation is not susceptible to bugs that are hard
3072 to fix. Documentation does not consist of parts that must interact in a
3073 precisely engineered fashion. To correct an error, you need not know
3074 the history of the erroneous passage; it is enough to compare what the
3075 documentation says with the way the program actually works.
3078 File: standards.info, Node: Conditional Changes, Next: Indicating the Part Changed, Prev: Simple Changes, Up: Change Logs
3080 6.8.4 Conditional Changes
3081 -------------------------
3083 C programs often contain compile-time `#if' conditionals. Many changes
3084 are conditional; sometimes you add a new definition which is entirely
3085 contained in a conditional. It is very useful to indicate in the
3086 change log the conditions for which the change applies.
3088 Our convention for indicating conditional changes is to use square
3089 brackets around the name of the condition.
3091 Here is a simple example, describing a change which is conditional
3092 but does not have a function or entity name associated with it:
3094 * xterm.c [SOLARIS2]: Include string.h.
3096 Here is an entry describing a new definition which is entirely
3097 conditional. This new definition for the macro `FRAME_WINDOW_P' is
3098 used only when `HAVE_X_WINDOWS' is defined:
3100 * frame.h [HAVE_X_WINDOWS] (FRAME_WINDOW_P): Macro defined.
3102 Here is an entry for a change within the function `init_display',
3103 whose definition as a whole is unconditional, but the changes themselves
3104 are contained in a `#ifdef HAVE_LIBNCURSES' conditional:
3106 * dispnew.c (init_display) [HAVE_LIBNCURSES]: If X, call tgetent.
3108 Here is an entry for a change that takes affect only when a certain
3109 macro is _not_ defined:
3111 (gethostname) [!HAVE_SOCKETS]: Replace with winsock version.
3114 File: standards.info, Node: Indicating the Part Changed, Prev: Conditional Changes, Up: Change Logs
3116 6.8.5 Indicating the Part Changed
3117 ---------------------------------
3119 Indicate the part of a function which changed by using angle brackets
3120 enclosing an indication of what the changed part does. Here is an entry
3121 for a change in the part of the function `sh-while-getopts' that deals
3124 * progmodes/sh-script.el (sh-while-getopts) <sh>: Handle case that
3125 user-specified option string is empty.
3128 File: standards.info, Node: Man Pages, Next: Reading other Manuals, Prev: Change Logs, Up: Documentation
3133 In the GNU project, man pages are secondary. It is not necessary or
3134 expected for every GNU program to have a man page, but some of them do.
3135 It's your choice whether to include a man page in your program.
3137 When you make this decision, consider that supporting a man page
3138 requires continual effort each time the program is changed. The time
3139 you spend on the man page is time taken away from more useful work.
3141 For a simple program which changes little, updating the man page may
3142 be a small job. Then there is little reason not to include a man page,
3145 For a large program that changes a great deal, updating a man page
3146 may be a substantial burden. If a user offers to donate a man page,
3147 you may find this gift costly to accept. It may be better to refuse
3148 the man page unless the same person agrees to take full responsibility
3149 for maintaining it--so that you can wash your hands of it entirely. If
3150 this volunteer later ceases to do the job, then don't feel obliged to
3151 pick it up yourself; it may be better to withdraw the man page from the
3152 distribution until someone else agrees to update it.
3154 When a program changes only a little, you may feel that the
3155 discrepancies are small enough that the man page remains useful without
3156 updating. If so, put a prominent note near the beginning of the man
3157 page explaining that you don't maintain it and that the Texinfo manual
3158 is more authoritative. The note should say how to access the Texinfo
3162 File: standards.info, Node: Reading other Manuals, Prev: Man Pages, Up: Documentation
3164 6.10 Reading other Manuals
3165 ==========================
3167 There may be non-free books or documentation files that describe the
3168 program you are documenting.
3170 It is ok to use these documents for reference, just as the author of
3171 a new algebra textbook can read other books on algebra. A large portion
3172 of any non-fiction book consists of facts, in this case facts about how
3173 a certain program works, and these facts are necessarily the same for
3174 everyone who writes about the subject. But be careful not to copy your
3175 outline structure, wording, tables or examples from preexisting non-free
3176 documentation. Copying from free documentation may be ok; please check
3177 with the FSF about the individual case.
3180 File: standards.info, Node: Managing Releases, Next: References, Prev: Documentation, Up: Top
3182 7 The Release Process
3183 *********************
3185 Making a release is more than just bundling up your source files in a
3186 tar file and putting it up for FTP. You should set up your software so
3187 that it can be configured to run on a variety of systems. Your Makefile
3188 should conform to the GNU standards described below, and your directory
3189 layout should also conform to the standards discussed below. Doing so
3190 makes it easy to include your package into the larger framework of all
3195 * Configuration:: How Configuration Should Work
3196 * Makefile Conventions:: Makefile Conventions
3197 * Releases:: Making Releases
3200 File: standards.info, Node: Configuration, Next: Makefile Conventions, Up: Managing Releases
3202 7.1 How Configuration Should Work
3203 =================================
3205 Each GNU distribution should come with a shell script named
3206 `configure'. This script is given arguments which describe the kind of
3207 machine and system you want to compile the program for.
3209 The `configure' script must record the configuration options so that
3210 they affect compilation.
3212 One way to do this is to make a link from a standard name such as
3213 `config.h' to the proper configuration file for the chosen system. If
3214 you use this technique, the distribution should _not_ contain a file
3215 named `config.h'. This is so that people won't be able to build the
3216 program without configuring it first.
3218 Another thing that `configure' can do is to edit the Makefile. If
3219 you do this, the distribution should _not_ contain a file named
3220 `Makefile'. Instead, it should include a file `Makefile.in' which
3221 contains the input used for editing. Once again, this is so that people
3222 won't be able to build the program without configuring it first.
3224 If `configure' does write the `Makefile', then `Makefile' should
3225 have a target named `Makefile' which causes `configure' to be rerun,
3226 setting up the same configuration that was set up last time. The files
3227 that `configure' reads should be listed as dependencies of `Makefile'.
3229 All the files which are output from the `configure' script should
3230 have comments at the beginning explaining that they were generated
3231 automatically using `configure'. This is so that users won't think of
3232 trying to edit them by hand.
3234 The `configure' script should write a file named `config.status'
3235 which describes which configuration options were specified when the
3236 program was last configured. This file should be a shell script which,
3237 if run, will recreate the same configuration.
3239 The `configure' script should accept an option of the form
3240 `--srcdir=DIRNAME' to specify the directory where sources are found (if
3241 it is not the current directory). This makes it possible to build the
3242 program in a separate directory, so that the actual source directory is
3245 If the user does not specify `--srcdir', then `configure' should
3246 check both `.' and `..' to see if it can find the sources. If it finds
3247 the sources in one of these places, it should use them from there.
3248 Otherwise, it should report that it cannot find the sources, and should
3249 exit with nonzero status.
3251 Usually the easy way to support `--srcdir' is by editing a
3252 definition of `VPATH' into the Makefile. Some rules may need to refer
3253 explicitly to the specified source directory. To make this possible,
3254 `configure' can add to the Makefile a variable named `srcdir' whose
3255 value is precisely the specified directory.
3257 The `configure' script should also take an argument which specifies
3258 the type of system to build the program for. This argument should look
3263 For example, a Sun 3 might be `m68k-sun-sunos4.1'.
3265 The `configure' script needs to be able to decode all plausible
3266 alternatives for how to describe a machine. Thus, `sun3-sunos4.1'
3267 would be a valid alias. For many programs, `vax-dec-ultrix' would be
3268 an alias for `vax-dec-bsd', simply because the differences between
3269 Ultrix and BSD are rarely noticeable, but a few programs might need to
3272 There is a shell script called `config.sub' that you can use as a
3273 subroutine to validate system types and canonicalize aliases.
3275 Other options are permitted to specify in more detail the software
3276 or hardware present on the machine, and include or exclude optional
3277 parts of the package:
3279 `--enable-FEATURE[=PARAMETER]'
3280 Configure the package to build and install an optional user-level
3281 facility called FEATURE. This allows users to choose which
3282 optional features to include. Giving an optional PARAMETER of
3283 `no' should omit FEATURE, if it is built by default.
3285 No `--enable' option should *ever* cause one feature to replace
3286 another. No `--enable' option should ever substitute one useful
3287 behavior for another useful behavior. The only proper use for
3288 `--enable' is for questions of whether to build part of the program
3292 The package PACKAGE will be installed, so configure this package
3293 to work with PACKAGE.
3295 Possible values of PACKAGE include `gnu-as' (or `gas'), `gnu-ld',
3296 `gnu-libc', `gdb', `x', and `x-toolkit'.
3298 Do not use a `--with' option to specify the file name to use to
3299 find certain files. That is outside the scope of what `--with'
3302 All `configure' scripts should accept all of these "detail" options,
3303 whether or not they make any difference to the particular package at
3304 hand. In particular, they should accept any option that starts with
3305 `--with-' or `--enable-'. This is so users will be able to configure
3306 an entire GNU source tree at once with a single set of options.
3308 You will note that the categories `--with-' and `--enable-' are
3309 narrow: they *do not* provide a place for any sort of option you might
3310 think of. That is deliberate. We want to limit the possible
3311 configuration options in GNU software. We do not want GNU programs to
3312 have idiosyncratic configuration options.
3314 Packages that perform part of the compilation process may support
3315 cross-compilation. In such a case, the host and target machines for the
3316 program may be different.
3318 The `configure' script should normally treat the specified type of
3319 system as both the host and the target, thus producing a program which
3320 works for the same type of machine that it runs on.
3322 To configure a cross-compiler, cross-assembler, or what have you, you
3323 should specify a target different from the host, using the configure
3324 option `--target=TARGETTYPE'. The syntax for TARGETTYPE is the same as
3325 for the host type. So the command would look like this:
3327 ./configure HOSTTYPE --target=TARGETTYPE
3329 Programs for which cross-operation is not meaningful need not accept
3330 the `--target' option, because configuring an entire operating system
3331 for cross-operation is not a meaningful operation.
3333 Bootstrapping a cross-compiler requires compiling it on a machine
3334 other than the host it will run on. Compilation packages accept a
3335 configuration option `--build=BUILDTYPE' for specifying the
3336 configuration on which you will compile them, but the configure script
3337 should normally guess the build machine type (using `config.guess'), so
3338 this option is probably not necessary. The host and target types
3339 normally default from the build type, so in bootstrapping a
3340 cross-compiler you must specify them both explicitly.
3342 Some programs have ways of configuring themselves automatically. If
3343 your program is set up to do this, your `configure' script can simply
3344 ignore most of its arguments.
3347 File: standards.info, Node: Makefile Conventions, Next: Releases, Prev: Configuration, Up: Managing Releases
3349 7.2 Makefile Conventions
3350 ========================
3352 This node describes conventions for writing the Makefiles for GNU
3353 programs. Using Automake will help you write a Makefile that follows
3358 * Makefile Basics:: General Conventions for Makefiles
3359 * Utilities in Makefiles:: Utilities in Makefiles
3360 * Command Variables:: Variables for Specifying Commands
3361 * Directory Variables:: Variables for Installation Directories
3362 * Standard Targets:: Standard Targets for Users
3363 * Install Command Categories:: Three categories of commands in the `install'
3364 rule: normal, pre-install and post-install.
3367 File: standards.info, Node: Makefile Basics, Next: Utilities in Makefiles, Up: Makefile Conventions
3369 7.2.1 General Conventions for Makefiles
3370 ---------------------------------------
3372 Every Makefile should contain this line:
3376 to avoid trouble on systems where the `SHELL' variable might be
3377 inherited from the environment. (This is never a problem with GNU
3380 Different `make' programs have incompatible suffix lists and
3381 implicit rules, and this sometimes creates confusion or misbehavior. So
3382 it is a good idea to set the suffix list explicitly using only the
3383 suffixes you need in the particular Makefile, like this:
3388 The first line clears out the suffix list, the second introduces all
3389 suffixes which may be subject to implicit rules in this Makefile.
3391 Don't assume that `.' is in the path for command execution. When
3392 you need to run programs that are a part of your package during the
3393 make, please make sure that it uses `./' if the program is built as
3394 part of the make or `$(srcdir)/' if the file is an unchanging part of
3395 the source code. Without one of these prefixes, the current search
3398 The distinction between `./' (the "build directory") and
3399 `$(srcdir)/' (the "source directory") is important because users can
3400 build in a separate directory using the `--srcdir' option to
3401 `configure'. A rule of the form:
3403 foo.1 : foo.man sedscript
3404 sed -e sedscript foo.man > foo.1
3406 will fail when the build directory is not the source directory, because
3407 `foo.man' and `sedscript' are in the source directory.
3409 When using GNU `make', relying on `VPATH' to find the source file
3410 will work in the case where there is a single dependency file, since
3411 the `make' automatic variable `$<' will represent the source file
3412 wherever it is. (Many versions of `make' set `$<' only in implicit
3413 rules.) A Makefile target like
3416 $(CC) -I. -I$(srcdir) $(CFLAGS) -c bar.c -o foo.o
3418 should instead be written as
3421 $(CC) -I. -I$(srcdir) $(CFLAGS) -c $< -o $@
3423 in order to allow `VPATH' to work correctly. When the target has
3424 multiple dependencies, using an explicit `$(srcdir)' is the easiest way
3425 to make the rule work well. For example, the target above for `foo.1'
3428 foo.1 : foo.man sedscript
3429 sed -e $(srcdir)/sedscript $(srcdir)/foo.man > $@
3431 GNU distributions usually contain some files which are not source
3432 files--for example, Info files, and the output from Autoconf, Automake,
3433 Bison or Flex. Since these files normally appear in the source
3434 directory, they should always appear in the source directory, not in the
3435 build directory. So Makefile rules to update them should put the
3436 updated files in the source directory.
3438 However, if a file does not appear in the distribution, then the
3439 Makefile should not put it in the source directory, because building a
3440 program in ordinary circumstances should not modify the source directory
3443 Try to make the build and installation targets, at least (and all
3444 their subtargets) work correctly with a parallel `make'.
3447 File: standards.info, Node: Utilities in Makefiles, Next: Command Variables, Prev: Makefile Basics, Up: Makefile Conventions
3449 7.2.2 Utilities in Makefiles
3450 ----------------------------
3452 Write the Makefile commands (and any shell scripts, such as
3453 `configure') to run in `sh', not in `csh'. Don't use any special
3454 features of `ksh' or `bash'.
3456 The `configure' script and the Makefile rules for building and
3457 installation should not use any utilities directly except these:
3459 cat cmp cp diff echo egrep expr false grep install-info
3460 ln ls mkdir mv pwd rm rmdir sed sleep sort tar test touch true
3462 The compression program `gzip' can be used in the `dist' rule.
3464 Stick to the generally supported options for these programs. For
3465 example, don't use `mkdir -p', convenient as it may be, because most
3466 systems don't support it.
3468 It is a good idea to avoid creating symbolic links in makefiles,
3469 since a few systems don't support them.
3471 The Makefile rules for building and installation can also use
3472 compilers and related programs, but should do so via `make' variables
3473 so that the user can substitute alternatives. Here are some of the
3476 ar bison cc flex install ld ldconfig lex
3477 make makeinfo ranlib texi2dvi yacc
3479 Use the following `make' variables to run those programs:
3481 $(AR) $(BISON) $(CC) $(FLEX) $(INSTALL) $(LD) $(LDCONFIG) $(LEX)
3482 $(MAKE) $(MAKEINFO) $(RANLIB) $(TEXI2DVI) $(YACC)
3484 When you use `ranlib' or `ldconfig', you should make sure nothing
3485 bad happens if the system does not have the program in question.
3486 Arrange to ignore an error from that command, and print a message before
3487 the command to tell the user that failure of this command does not mean
3488 a problem. (The Autoconf `AC_PROG_RANLIB' macro can help with this.)
3490 If you use symbolic links, you should implement a fallback for
3491 systems that don't have symbolic links.
3493 Additional utilities that can be used via Make variables are:
3495 chgrp chmod chown mknod
3497 It is ok to use other utilities in Makefile portions (or scripts)
3498 intended only for particular systems where you know those utilities
3502 File: standards.info, Node: Command Variables, Next: Directory Variables, Prev: Utilities in Makefiles, Up: Makefile Conventions
3504 7.2.3 Variables for Specifying Commands
3505 ---------------------------------------
3507 Makefiles should provide variables for overriding certain commands,
3510 In particular, you should run most utility programs via variables.
3511 Thus, if you use Bison, have a variable named `BISON' whose default
3512 value is set with `BISON = bison', and refer to it with `$(BISON)'
3513 whenever you need to use Bison.
3515 File management utilities such as `ln', `rm', `mv', and so on, need
3516 not be referred to through variables in this way, since users don't
3517 need to replace them with other programs.
3519 Each program-name variable should come with an options variable that
3520 is used to supply options to the program. Append `FLAGS' to the
3521 program-name variable name to get the options variable name--for
3522 example, `BISONFLAGS'. (The names `CFLAGS' for the C compiler,
3523 `YFLAGS' for yacc, and `LFLAGS' for lex, are exceptions to this rule,
3524 but we keep them because they are standard.) Use `CPPFLAGS' in any
3525 compilation command that runs the preprocessor, and use `LDFLAGS' in
3526 any compilation command that does linking as well as in any direct use
3529 If there are C compiler options that _must_ be used for proper
3530 compilation of certain files, do not include them in `CFLAGS'. Users
3531 expect to be able to specify `CFLAGS' freely themselves. Instead,
3532 arrange to pass the necessary options to the C compiler independently
3533 of `CFLAGS', by writing them explicitly in the compilation commands or
3534 by defining an implicit rule, like this:
3537 ALL_CFLAGS = -I. $(CFLAGS)
3539 $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $<
3541 Do include the `-g' option in `CFLAGS', because that is not
3542 _required_ for proper compilation. You can consider it a default that
3543 is only recommended. If the package is set up so that it is compiled
3544 with GCC by default, then you might as well include `-O' in the default
3545 value of `CFLAGS' as well.
3547 Put `CFLAGS' last in the compilation command, after other variables
3548 containing compiler options, so the user can use `CFLAGS' to override
3551 `CFLAGS' should be used in every invocation of the C compiler, both
3552 those which do compilation and those which do linking.
3554 Every Makefile should define the variable `INSTALL', which is the
3555 basic command for installing a file into the system.
3557 Every Makefile should also define the variables `INSTALL_PROGRAM'
3558 and `INSTALL_DATA'. (The default for `INSTALL_PROGRAM' should be
3559 `$(INSTALL)'; the default for `INSTALL_DATA' should be `${INSTALL} -m
3560 644'.) Then it should use those variables as the commands for actual
3561 installation, for executables and nonexecutables respectively. Use
3562 these variables as follows:
3564 $(INSTALL_PROGRAM) foo $(bindir)/foo
3565 $(INSTALL_DATA) libfoo.a $(libdir)/libfoo.a
3567 Optionally, you may prepend the value of `DESTDIR' to the target
3568 filename. Doing this allows the installer to create a snapshot of the
3569 installation to be copied onto the real target filesystem later. Do not
3570 set the value of `DESTDIR' in your Makefile, and do not include it in
3571 any installed files. With support for `DESTDIR', the above examples
3574 $(INSTALL_PROGRAM) foo $(DESTDIR)$(bindir)/foo
3575 $(INSTALL_DATA) libfoo.a $(DESTDIR)$(libdir)/libfoo.a
3577 Always use a file name, not a directory name, as the second argument of
3578 the installation commands. Use a separate command for each file to be
3582 File: standards.info, Node: Directory Variables, Next: Standard Targets, Prev: Command Variables, Up: Makefile Conventions
3584 7.2.4 Variables for Installation Directories
3585 --------------------------------------------
3587 Installation directories should always be named by variables, so it is
3588 easy to install in a nonstandard place. The standard names for these
3589 variables are described below. They are based on a standard filesystem
3590 layout; variants of it are used in SVR4, 4.4BSD, GNU/Linux, Ultrix v4,
3591 and other modern operating systems.
3593 These two variables set the root for the installation. All the other
3594 installation directories should be subdirectories of one of these two,
3595 and nothing should be directly installed into these two directories.
3598 A prefix used in constructing the default values of the variables
3599 listed below. The default value of `prefix' should be
3600 `/usr/local'. When building the complete GNU system, the prefix
3601 will be empty and `/usr' will be a symbolic link to `/'. (If you
3602 are using Autoconf, write it as `@prefix@'.)
3604 Running `make install' with a different value of `prefix' from the
3605 one used to build the program should _not_ recompile the program.
3608 A prefix used in constructing the default values of some of the
3609 variables listed below. The default value of `exec_prefix' should
3610 be `$(prefix)'. (If you are using Autoconf, write it as
3613 Generally, `$(exec_prefix)' is used for directories that contain
3614 machine-specific files (such as executables and subroutine
3615 libraries), while `$(prefix)' is used directly for other
3618 Running `make install' with a different value of `exec_prefix'
3619 from the one used to build the program should _not_ recompile the
3622 Executable programs are installed in one of the following
3626 The directory for installing executable programs that users can
3627 run. This should normally be `/usr/local/bin', but write it as
3628 `$(exec_prefix)/bin'. (If you are using Autoconf, write it as
3632 The directory for installing executable programs that can be run
3633 from the shell, but are only generally useful to system
3634 administrators. This should normally be `/usr/local/sbin', but
3635 write it as `$(exec_prefix)/sbin'. (If you are using Autoconf,
3636 write it as `@sbindir@'.)
3639 The directory for installing executable programs to be run by other
3640 programs rather than by users. This directory should normally be
3641 `/usr/local/libexec', but write it as `$(exec_prefix)/libexec'.
3642 (If you are using Autoconf, write it as `@libexecdir@'.)
3644 Data files used by the program during its execution are divided into
3645 categories in two ways.
3647 * Some files are normally modified by programs; others are never
3648 normally modified (though users may edit some of these).
3650 * Some files are architecture-independent and can be shared by all
3651 machines at a site; some are architecture-dependent and can be
3652 shared only by machines of the same kind and operating system;
3653 others may never be shared between two machines.
3655 This makes for six different possibilities. However, we want to
3656 discourage the use of architecture-dependent files, aside from object
3657 files and libraries. It is much cleaner to make other data files
3658 architecture-independent, and it is generally not hard.
3660 Therefore, here are the variables Makefiles should use to specify
3664 The directory for installing read-only architecture independent
3665 data files. This should normally be `/usr/local/share', but write
3666 it as `$(prefix)/share'. (If you are using Autoconf, write it as
3667 `@datadir@'.) As a special exception, see `$(infodir)' and
3668 `$(includedir)' below.
3671 The directory for installing read-only data files that pertain to a
3672 single machine-that is to say, files for configuring a host.
3673 Mailer and network configuration files, `/etc/passwd', and so
3674 forth belong here. All the files in this directory should be
3675 ordinary ASCII text files. This directory should normally be
3676 `/usr/local/etc', but write it as `$(prefix)/etc'. (If you are
3677 using Autoconf, write it as `@sysconfdir@'.)
3679 Do not install executables here in this directory (they probably
3680 belong in `$(libexecdir)' or `$(sbindir)'). Also do not install
3681 files that are modified in the normal course of their use (programs
3682 whose purpose is to change the configuration of the system
3683 excluded). Those probably belong in `$(localstatedir)'.
3686 The directory for installing architecture-independent data files
3687 which the programs modify while they run. This should normally be
3688 `/usr/local/com', but write it as `$(prefix)/com'. (If you are
3689 using Autoconf, write it as `@sharedstatedir@'.)
3692 The directory for installing data files which the programs modify
3693 while they run, and that pertain to one specific machine. Users
3694 should never need to modify files in this directory to configure
3695 the package's operation; put such configuration information in
3696 separate files that go in `$(datadir)' or `$(sysconfdir)'.
3697 `$(localstatedir)' should normally be `/usr/local/var', but write
3698 it as `$(prefix)/var'. (If you are using Autoconf, write it as
3702 The directory for object files and libraries of object code. Do
3703 not install executables here, they probably ought to go in
3704 `$(libexecdir)' instead. The value of `libdir' should normally be
3705 `/usr/local/lib', but write it as `$(exec_prefix)/lib'. (If you
3706 are using Autoconf, write it as `@libdir@'.)
3709 The directory for installing the Info files for this package. By
3710 default, it should be `/usr/local/info', but it should be written
3711 as `$(prefix)/info'. (If you are using Autoconf, write it as
3715 The directory for installing any Emacs Lisp files in this package.
3716 By default, it should be `/usr/local/share/emacs/site-lisp', but
3717 it should be written as `$(prefix)/share/emacs/site-lisp'.
3719 If you are using Autoconf, write the default as `@lispdir@'. In
3720 order to make `@lispdir@' work, you need the following lines in
3721 your `configure.in' file:
3723 lispdir='${datadir}/emacs/site-lisp'
3727 The directory for installing header files to be included by user
3728 programs with the C `#include' preprocessor directive. This
3729 should normally be `/usr/local/include', but write it as
3730 `$(prefix)/include'. (If you are using Autoconf, write it as
3733 Most compilers other than GCC do not look for header files in
3734 directory `/usr/local/include'. So installing the header files
3735 this way is only useful with GCC. Sometimes this is not a problem
3736 because some libraries are only really intended to work with GCC.
3737 But some libraries are intended to work with other compilers.
3738 They should install their header files in two places, one
3739 specified by `includedir' and one specified by `oldincludedir'.
3742 The directory for installing `#include' header files for use with
3743 compilers other than GCC. This should normally be `/usr/include'.
3744 (If you are using Autoconf, you can write it as `@oldincludedir@'.)
3746 The Makefile commands should check whether the value of
3747 `oldincludedir' is empty. If it is, they should not try to use
3748 it; they should cancel the second installation of the header files.
3750 A package should not replace an existing header in this directory
3751 unless the header came from the same package. Thus, if your Foo
3752 package provides a header file `foo.h', then it should install the
3753 header file in the `oldincludedir' directory if either (1) there
3754 is no `foo.h' there or (2) the `foo.h' that exists came from the
3757 To tell whether `foo.h' came from the Foo package, put a magic
3758 string in the file--part of a comment--and `grep' for that string.
3760 Unix-style man pages are installed in one of the following:
3763 The top-level directory for installing the man pages (if any) for
3764 this package. It will normally be `/usr/local/man', but you should
3765 write it as `$(prefix)/man'. (If you are using Autoconf, write it
3769 The directory for installing section 1 man pages. Write it as
3773 The directory for installing section 2 man pages. Write it as
3777 *Don't make the primary documentation for any GNU software be a
3778 man page. Write a manual in Texinfo instead. Man pages are just
3779 for the sake of people running GNU software on Unix, which is a
3780 secondary application only.*
3783 The file name extension for the installed man page. This should
3784 contain a period followed by the appropriate digit; it should
3788 The file name extension for installed section 1 man pages.
3791 The file name extension for installed section 2 man pages.
3794 Use these names instead of `manext' if the package needs to
3795 install man pages in more than one section of the manual.
3797 And finally, you should set the following variable:
3800 The directory for the sources being compiled. The value of this
3801 variable is normally inserted by the `configure' shell script.
3802 (If you are using Autconf, use `srcdir = @srcdir@'.)
3806 # Common prefix for installation directories.
3807 # NOTE: This directory must exist when you start the install.
3809 exec_prefix = $(prefix)
3810 # Where to put the executable for the command `gcc'.
3811 bindir = $(exec_prefix)/bin
3812 # Where to put the directories used by the compiler.
3813 libexecdir = $(exec_prefix)/libexec
3814 # Where to put the Info files.
3815 infodir = $(prefix)/info
3817 If your program installs a large number of files into one of the
3818 standard user-specified directories, it might be useful to group them
3819 into a subdirectory particular to that program. If you do this, you
3820 should write the `install' rule to create these subdirectories.
3822 Do not expect the user to include the subdirectory name in the value
3823 of any of the variables listed above. The idea of having a uniform set
3824 of variable names for installation directories is to enable the user to
3825 specify the exact same values for several different GNU packages. In
3826 order for this to be useful, all the packages must be designed so that
3827 they will work sensibly when the user does so.
3830 File: standards.info, Node: Standard Targets, Next: Install Command Categories, Prev: Directory Variables, Up: Makefile Conventions
3832 7.2.5 Standard Targets for Users
3833 --------------------------------
3835 All GNU programs should have the following targets in their Makefiles:
3838 Compile the entire program. This should be the default target.
3839 This target need not rebuild any documentation files; Info files
3840 should normally be included in the distribution, and DVI files
3841 should be made only when explicitly asked for.
3843 By default, the Make rules should compile and link with `-g', so
3844 that executable programs have debugging symbols. Users who don't
3845 mind being helpless can strip the executables later if they wish.
3848 Compile the program and copy the executables, libraries, and so on
3849 to the file names where they should reside for actual use. If
3850 there is a simple test to verify that a program is properly
3851 installed, this target should run that test.
3853 Do not strip executables when installing them. Devil-may-care
3854 users can use the `install-strip' target to do that.
3856 If possible, write the `install' target rule so that it does not
3857 modify anything in the directory where the program was built,
3858 provided `make all' has just been done. This is convenient for
3859 building the program under one user name and installing it under
3862 The commands should create all the directories in which files are
3863 to be installed, if they don't already exist. This includes the
3864 directories specified as the values of the variables `prefix' and
3865 `exec_prefix', as well as all subdirectories that are needed. One
3866 way to do this is by means of an `installdirs' target as described
3869 Use `-' before any command for installing a man page, so that
3870 `make' will ignore any errors. This is in case there are systems
3871 that don't have the Unix man page documentation system installed.
3873 The way to install Info files is to copy them into `$(infodir)'
3874 with `$(INSTALL_DATA)' (*note Command Variables::), and then run
3875 the `install-info' program if it is present. `install-info' is a
3876 program that edits the Info `dir' file to add or update the menu
3877 entry for the given Info file; it is part of the Texinfo package.
3878 Here is a sample rule to install an Info file:
3880 $(DESTDIR)$(infodir)/foo.info: foo.info
3882 # There may be a newer info file in . than in srcdir.
3883 -if test -f foo.info; then d=.; \
3884 else d=$(srcdir); fi; \
3885 $(INSTALL_DATA) $$d/foo.info $(DESTDIR)$@; \
3886 # Run install-info only if it exists.
3887 # Use `if' instead of just prepending `-' to the
3888 # line so we notice real errors from install-info.
3889 # We use `$(SHELL) -c' because some shells do not
3890 # fail gracefully when there is an unknown command.
3891 if $(SHELL) -c 'install-info --version' \
3892 >/dev/null 2>&1; then \
3893 install-info --dir-file=$(DESTDIR)$(infodir)/dir \
3894 $(DESTDIR)$(infodir)/foo.info; \
3897 When writing the `install' target, you must classify all the
3898 commands into three categories: normal ones, "pre-installation"
3899 commands and "post-installation" commands. *Note Install Command
3903 Delete all the installed files--the copies that the `install'
3906 This rule should not modify the directories where compilation is
3907 done, only the directories where files are installed.
3909 The uninstallation commands are divided into three categories,
3910 just like the installation commands. *Note Install Command
3914 Like `install', but strip the executable files while installing
3915 them. In simple cases, this target can use the `install' target in
3919 $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \
3922 But if the package installs scripts as well as real executables,
3923 the `install-strip' target can't just refer to the `install'
3924 target; it has to strip the executables but not the scripts.
3926 `install-strip' should not strip the executables in the build
3927 directory which are being copied for installation. It should only
3928 strip the copies that are installed.
3930 Normally we do not recommend stripping an executable unless you
3931 are sure the program has no bugs. However, it can be reasonable
3932 to install a stripped executable for actual execution while saving
3933 the unstripped executable elsewhere in case there is a bug.
3936 Delete all files from the current directory that are normally
3937 created by building the program. Don't delete the files that
3938 record the configuration. Also preserve files that could be made
3939 by building, but normally aren't because the distribution comes
3942 Delete `.dvi' files here if they are not part of the distribution.
3945 Delete all files from the current directory that are created by
3946 configuring or building the program. If you have unpacked the
3947 source and built the program without creating any other files,
3948 `make distclean' should leave only the files that were in the
3952 Like `clean', but may refrain from deleting a few files that people
3953 normally don't want to recompile. For example, the `mostlyclean'
3954 target for GCC does not delete `libgcc.a', because recompiling it
3955 is rarely necessary and takes a lot of time.
3958 Delete almost everything from the current directory that can be
3959 reconstructed with this Makefile. This typically includes
3960 everything deleted by `distclean', plus more: C source files
3961 produced by Bison, tags tables, Info files, and so on.
3963 The reason we say "almost everything" is that running the command
3964 `make maintainer-clean' should not delete `configure' even if
3965 `configure' can be remade using a rule in the Makefile. More
3966 generally, `make maintainer-clean' should not delete anything that
3967 needs to exist in order to run `configure' and then begin to build
3968 the program. This is the only exception; `maintainer-clean' should
3969 delete everything else that can be rebuilt.
3971 The `maintainer-clean' target is intended to be used by a
3972 maintainer of the package, not by ordinary users. You may need
3973 special tools to reconstruct some of the files that `make
3974 maintainer-clean' deletes. Since these files are normally
3975 included in the distribution, we don't take care to make them easy
3976 to reconstruct. If you find you need to unpack the full
3977 distribution again, don't blame us.
3979 To help make users aware of this, the commands for the special
3980 `maintainer-clean' target should start with these two:
3982 @echo 'This command is intended for maintainers to use; it'
3983 @echo 'deletes files that may need special tools to rebuild.'
3986 Update a tags table for this program.
3989 Generate any Info files needed. The best way to write the rules
3994 foo.info: foo.texi chap1.texi chap2.texi
3995 $(MAKEINFO) $(srcdir)/foo.texi
3997 You must define the variable `MAKEINFO' in the Makefile. It should
3998 run the `makeinfo' program, which is part of the Texinfo
4001 Normally a GNU distribution comes with Info files, and that means
4002 the Info files are present in the source directory. Therefore,
4003 the Make rule for an info file should update it in the source
4004 directory. When users build the package, ordinarily Make will not
4005 update the Info files because they will already be up to date.
4008 Generate DVI files for all Texinfo documentation. For example:
4012 foo.dvi: foo.texi chap1.texi chap2.texi
4013 $(TEXI2DVI) $(srcdir)/foo.texi
4015 You must define the variable `TEXI2DVI' in the Makefile. It should
4016 run the program `texi2dvi', which is part of the Texinfo
4017 distribution.(1) Alternatively, write just the dependencies, and
4018 allow GNU `make' to provide the command.
4021 Create a distribution tar file for this program. The tar file
4022 should be set up so that the file names in the tar file start with
4023 a subdirectory name which is the name of the package it is a
4024 distribution for. This name can include the version number.
4026 For example, the distribution tar file of GCC version 1.40 unpacks
4027 into a subdirectory named `gcc-1.40'.
4029 The easiest way to do this is to create a subdirectory
4030 appropriately named, use `ln' or `cp' to install the proper files
4031 in it, and then `tar' that subdirectory.
4033 Compress the tar file with `gzip'. For example, the actual
4034 distribution file for GCC version 1.40 is called `gcc-1.40.tar.gz'.
4036 The `dist' target should explicitly depend on all non-source files
4037 that are in the distribution, to make sure they are up to date in
4038 the distribution. *Note Making Releases: Releases.
4041 Perform self-tests (if any). The user must build the program
4042 before running the tests, but need not install the program; you
4043 should write the self-tests so that they work when the program is
4044 built but not installed.
4046 The following targets are suggested as conventional names, for
4047 programs in which they are useful.
4050 Perform installation tests (if any). The user must build and
4051 install the program before running the tests. You should not
4052 assume that `$(bindir)' is in the search path.
4055 It's useful to add a target named `installdirs' to create the
4056 directories where files are installed, and their parent
4057 directories. There is a script called `mkinstalldirs' which is
4058 convenient for this; you can find it in the Texinfo package. You
4059 can use a rule like this:
4061 # Make sure all installation directories (e.g. $(bindir))
4062 # actually exist by making them if necessary.
4063 installdirs: mkinstalldirs
4064 $(srcdir)/mkinstalldirs $(bindir) $(datadir) \
4065 $(libdir) $(infodir) \
4068 or, if you wish to support `DESTDIR',
4070 # Make sure all installation directories (e.g. $(bindir))
4071 # actually exist by making them if necessary.
4072 installdirs: mkinstalldirs
4073 $(srcdir)/mkinstalldirs \
4074 $(DESTDIR)$(bindir) $(DESTDIR)$(datadir) \
4075 $(DESTDIR)$(libdir) $(DESTDIR)$(infodir) \
4078 This rule should not modify the directories where compilation is
4079 done. It should do nothing but create installation directories.
4081 ---------- Footnotes ----------
4083 (1) `texi2dvi' uses TeX to do the real work of formatting. TeX is
4084 not distributed with Texinfo.
4087 File: standards.info, Node: Install Command Categories, Prev: Standard Targets, Up: Makefile Conventions
4089 7.2.6 Install Command Categories
4090 --------------------------------
4092 When writing the `install' target, you must classify all the commands
4093 into three categories: normal ones, "pre-installation" commands and
4094 "post-installation" commands.
4096 Normal commands move files into their proper places, and set their
4097 modes. They may not alter any files except the ones that come entirely
4098 from the package they belong to.
4100 Pre-installation and post-installation commands may alter other
4101 files; in particular, they can edit global configuration files or data
4104 Pre-installation commands are typically executed before the normal
4105 commands, and post-installation commands are typically run after the
4108 The most common use for a post-installation command is to run
4109 `install-info'. This cannot be done with a normal command, since it
4110 alters a file (the Info directory) which does not come entirely and
4111 solely from the package being installed. It is a post-installation
4112 command because it needs to be done after the normal command which
4113 installs the package's Info files.
4115 Most programs don't need any pre-installation commands, but we have
4116 the feature just in case it is needed.
4118 To classify the commands in the `install' rule into these three
4119 categories, insert "category lines" among them. A category line
4120 specifies the category for the commands that follow.
4122 A category line consists of a tab and a reference to a special Make
4123 variable, plus an optional comment at the end. There are three
4124 variables you can use, one for each category; the variable name
4125 specifies the category. Category lines are no-ops in ordinary execution
4126 because these three Make variables are normally undefined (and you
4127 _should not_ define them in the makefile).
4129 Here are the three possible category lines, each with a comment that
4130 explains what it means:
4132 $(PRE_INSTALL) # Pre-install commands follow.
4133 $(POST_INSTALL) # Post-install commands follow.
4134 $(NORMAL_INSTALL) # Normal commands follow.
4136 If you don't use a category line at the beginning of the `install'
4137 rule, all the commands are classified as normal until the first category
4138 line. If you don't use any category lines, all the commands are
4139 classified as normal.
4141 These are the category lines for `uninstall':
4143 $(PRE_UNINSTALL) # Pre-uninstall commands follow.
4144 $(POST_UNINSTALL) # Post-uninstall commands follow.
4145 $(NORMAL_UNINSTALL) # Normal commands follow.
4147 Typically, a pre-uninstall command would be used for deleting entries
4148 from the Info directory.
4150 If the `install' or `uninstall' target has any dependencies which
4151 act as subroutines of installation, then you should start _each_
4152 dependency's commands with a category line, and start the main target's
4153 commands with a category line also. This way, you can ensure that each
4154 command is placed in the right category regardless of which of the
4155 dependencies actually run.
4157 Pre-installation and post-installation commands should not run any
4158 programs except for these:
4160 [ basename bash cat chgrp chmod chown cmp cp dd diff echo
4161 egrep expand expr false fgrep find getopt grep gunzip gzip
4162 hostname install install-info kill ldconfig ln ls md5sum
4163 mkdir mkfifo mknod mv printenv pwd rm rmdir sed sort tee
4164 test touch true uname xargs yes
4166 The reason for distinguishing the commands in this way is for the
4167 sake of making binary packages. Typically a binary package contains
4168 all the executables and other files that need to be installed, and has
4169 its own method of installing them--so it does not need to run the normal
4170 installation commands. But installing the binary package does need to
4171 execute the pre-installation and post-installation commands.
4173 Programs to build binary packages work by extracting the
4174 pre-installation and post-installation commands. Here is one way of
4175 extracting the pre-installation commands:
4177 make -n install -o all \
4178 PRE_INSTALL=pre-install \
4179 POST_INSTALL=post-install \
4180 NORMAL_INSTALL=normal-install \
4181 | gawk -f pre-install.awk
4183 where the file `pre-install.awk' could contain this:
4185 $0 ~ /^\t[ \t]*(normal_install|post_install)[ \t]*$/ {on = 0}
4187 $0 ~ /^\t[ \t]*pre_install[ \t]*$/ {on = 1}
4189 The resulting file of pre-installation commands is executed as a
4190 shell script as part of installing the binary package.
4193 File: standards.info, Node: Releases, Prev: Makefile Conventions, Up: Managing Releases
4198 Package the distribution of `Foo version 69.96' up in a gzipped tar
4199 file with the name `foo-69.96.tar.gz'. It should unpack into a
4200 subdirectory named `foo-69.96'.
4202 Building and installing the program should never modify any of the
4203 files contained in the distribution. This means that all the files
4204 that form part of the program in any way must be classified into "source
4205 files" and "non-source files". Source files are written by humans and
4206 never changed automatically; non-source files are produced from source
4207 files by programs under the control of the Makefile.
4209 The distribution should contain a file named `README' which gives
4210 the name of the package, and a general description of what it does. It
4211 is also good to explain the purpose of each of the first-level
4212 subdirectories in the package, if there are any. The `README' file
4213 should either state the version number of the package, or refer to where
4214 in the package it can be found.
4216 The `README' file should refer to the file `INSTALL', which should
4217 contain an explanation of the installation procedure.
4219 The `README' file should also refer to the file which contains the
4220 copying conditions. The GNU GPL, if used, should be in a file called
4221 `COPYING'. If the GNU LGPL is used, it should be in a file called
4224 Naturally, all the source files must be in the distribution. It is
4225 okay to include non-source files in the distribution, provided they are
4226 up-to-date and machine-independent, so that building the distribution
4227 normally will never modify them. We commonly include non-source files
4228 produced by Bison, `lex', TeX, and `makeinfo'; this helps avoid
4229 unnecessary dependencies between our distributions, so that users can
4230 install whichever packages they want to install.
4232 Non-source files that might actually be modified by building and
4233 installing the program should *never* be included in the distribution.
4234 So if you do distribute non-source files, always make sure they are up
4235 to date when you make a new distribution.
4237 Make sure that the directory into which the distribution unpacks (as
4238 well as any subdirectories) are all world-writable (octal mode 777).
4239 This is so that old versions of `tar' which preserve the ownership and
4240 permissions of the files from the tar archive will be able to extract
4241 all the files even if the user is unprivileged.
4243 Make sure that all the files in the distribution are world-readable.
4245 Make sure that no file name in the distribution is more than 14
4246 characters long. Likewise, no file created by building the program
4247 should have a name longer than 14 characters. The reason for this is
4248 that some systems adhere to a foolish interpretation of the POSIX
4249 standard, and refuse to open a longer name, rather than truncating as
4250 they did in the past.
4252 Don't include any symbolic links in the distribution itself. If the
4253 tar file contains symbolic links, then people cannot even unpack it on
4254 systems that don't support symbolic links. Also, don't use multiple
4255 names for one file in different directories, because certain file
4256 systems cannot handle this and that prevents unpacking the distribution.
4258 Try to make sure that all the file names will be unique on MS-DOS. A
4259 name on MS-DOS consists of up to 8 characters, optionally followed by a
4260 period and up to three characters. MS-DOS will truncate extra
4261 characters both before and after the period. Thus, `foobarhacker.c'
4262 and `foobarhacker.o' are not ambiguous; they are truncated to
4263 `foobarha.c' and `foobarha.o', which are distinct.
4265 Include in your distribution a copy of the `texinfo.tex' you used to
4266 test print any `*.texinfo' or `*.texi' files.
4268 Likewise, if your program uses small GNU software packages like
4269 regex, getopt, obstack, or termcap, include them in the distribution
4270 file. Leaving them out would make the distribution file a little
4271 smaller at the expense of possible inconvenience to a user who doesn't
4272 know what other files to get.
4275 File: standards.info, Node: References, Next: Copying This Manual, Prev: Managing Releases, Up: Top
4277 8 References to Non-Free Software and Documentation
4278 ***************************************************
4280 A GNU program should not recommend use of any non-free program. We
4281 can't stop some people from writing proprietary programs, or stop other
4282 people from using them, but we can and should avoid helping to
4283 advertise them to new potential customers. Proprietary software is a
4284 social and ethical problem, and the point of GNU is to solve that
4287 When a non-free program or system is well known, you can mention it
4288 in passing--that is harmless, since users who might want to use it
4289 probably already know about it. For instance, it is fine to explain
4290 how to build your package on top of some non-free operating system, or
4291 how to use it together with some widely used non-free program.
4293 However, you should give only the necessary information to help those
4294 who already use the non-free program to use your program with it--don't
4295 give, or refer to, any further information about the proprietary
4296 program, and don't imply that the proprietary program enhances your
4297 program, or that its existence is in any way a good thing. The goal
4298 should be that people already using the proprietary program will get
4299 the advice they need about how to use your free program, while people
4300 who don't already use the proprietary program will not see anything to
4301 lead them to take an interest in it.
4303 If a non-free program or system is obscure in your program's domain,
4304 your program should not mention or support it at all, since doing so
4305 would tend to popularize the non-free program more than it popularizes
4306 your program. (You cannot hope to find many additional users among the
4307 users of Foobar if the users of Foobar are few.)
4309 A GNU package should not refer the user to any non-free documentation
4310 for free software. Free documentation that can be included in free
4311 operating systems is essential for completing the GNU system, so it is
4312 a major focus of the GNU Project; to recommend use of documentation
4313 that we are not allowed to use in GNU would undermine the efforts to
4314 get documentation that we can include. So GNU packages should never
4315 recommend non-free documentation.
4318 File: standards.info, Node: Copying This Manual, Next: Index, Prev: References, Up: Top
4320 Appendix A Copying This Manual
4321 ******************************
4325 * GNU Free Documentation License:: License for copying this manual
4328 File: standards.info, Node: GNU Free Documentation License, Up: Copying This Manual
4330 Appendix B GNU Free Documentation License
4331 *****************************************
4333 Version 1.1, March 2000
4335 Copyright (C) 2000 Free Software Foundation, Inc.
4336 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
4338 Everyone is permitted to copy and distribute verbatim copies
4339 of this license document, but changing it is not allowed.
4344 The purpose of this License is to make a manual, textbook, or other
4345 written document "free" in the sense of freedom: to assure everyone
4346 the effective freedom to copy and redistribute it, with or without
4347 modifying it, either commercially or noncommercially. Secondarily,
4348 this License preserves for the author and publisher a way to get
4349 credit for their work, while not being considered responsible for
4350 modifications made by others.
4352 This License is a kind of "copyleft", which means that derivative
4353 works of the document must themselves be free in the same sense.
4354 It complements the GNU General Public License, which is a copyleft
4355 license designed for free software.
4357 We have designed this License in order to use it for manuals for
4358 free software, because free software needs free documentation: a
4359 free program should come with manuals providing the same freedoms
4360 that the software does. But this License is not limited to
4361 software manuals; it can be used for any textual work, regardless
4362 of subject matter or whether it is published as a printed book.
4363 We recommend this License principally for works whose purpose is
4364 instruction or reference.
4367 1. APPLICABILITY AND DEFINITIONS
4369 This License applies to any manual or other work that contains a
4370 notice placed by the copyright holder saying it can be distributed
4371 under the terms of this License. The "Document", below, refers to
4372 any such manual or work. Any member of the public is a licensee,
4373 and is addressed as "you."
4375 A "Modified Version" of the Document means any work containing the
4376 Document or a portion of it, either copied verbatim, or with
4377 modifications and/or translated into another language.
4379 A "Secondary Section" is a named appendix or a front-matter
4380 section of the Document that deals exclusively with the
4381 relationship of the publishers or authors of the Document to the
4382 Document's overall subject (or to related matters) and contains
4383 nothing that could fall directly within that overall subject.
4384 (For example, if the Document is in part a textbook of
4385 mathematics, a Secondary Section may not explain any mathematics.)
4386 The relationship could be a matter of historical connection with
4387 the subject or with related matters, or of legal, commercial,
4388 philosophical, ethical or political position regarding them.
4390 The "Invariant Sections" are certain Secondary Sections whose
4391 titles are designated, as being those of Invariant Sections, in
4392 the notice that says that the Document is released under this
4395 The "Cover Texts" are certain short passages of text that are
4396 listed, as Front-Cover Texts or Back-Cover Texts, in the notice
4397 that says that the Document is released under this License.
4399 A "Transparent" copy of the Document means a machine-readable copy,
4400 represented in a format whose specification is available to the
4401 general public, whose contents can be viewed and edited directly
4402 and straightforwardly with generic text editors or (for images
4403 composed of pixels) generic paint programs or (for drawings) some
4404 widely available drawing editor, and that is suitable for input to
4405 text formatters or for automatic translation to a variety of
4406 formats suitable for input to text formatters. A copy made in an
4407 otherwise Transparent file format whose markup has been designed
4408 to thwart or discourage subsequent modification by readers is not
4409 Transparent. A copy that is not "Transparent" is called "Opaque."
4411 Examples of suitable formats for Transparent copies include plain
4412 ASCII without markup, Texinfo input format, LaTeX input format,
4413 SGML or XML using a publicly available DTD, and
4414 standard-conforming simple HTML designed for human modification.
4415 Opaque formats include PostScript, PDF, proprietary formats that
4416 can be read and edited only by proprietary word processors, SGML
4417 or XML for which the DTD and/or processing tools are not generally
4418 available, and the machine-generated HTML produced by some word
4419 processors for output purposes only.
4421 The "Title Page" means, for a printed book, the title page itself,
4422 plus such following pages as are needed to hold, legibly, the
4423 material this License requires to appear in the title page. For
4424 works in formats which do not have any title page as such, "Title
4425 Page" means the text near the most prominent appearance of the
4426 work's title, preceding the beginning of the body of the text.
4430 You may copy and distribute the Document in any medium, either
4431 commercially or noncommercially, provided that this License, the
4432 copyright notices, and the license notice saying this License
4433 applies to the Document are reproduced in all copies, and that you
4434 add no other conditions whatsoever to those of this License. You
4435 may not use technical measures to obstruct or control the reading
4436 or further copying of the copies you make or distribute. However,
4437 you may accept compensation in exchange for copies. If you
4438 distribute a large enough number of copies you must also follow
4439 the conditions in section 3.
4441 You may also lend copies, under the same conditions stated above,
4442 and you may publicly display copies.
4444 3. COPYING IN QUANTITY
4446 If you publish printed copies of the Document numbering more than
4447 100, and the Document's license notice requires Cover Texts, you
4448 must enclose the copies in covers that carry, clearly and legibly,
4449 all these Cover Texts: Front-Cover Texts on the front cover, and
4450 Back-Cover Texts on the back cover. Both covers must also clearly
4451 and legibly identify you as the publisher of these copies. The
4452 front cover must present the full title with all words of the
4453 title equally prominent and visible. You may add other material
4454 on the covers in addition. Copying with changes limited to the
4455 covers, as long as they preserve the title of the Document and
4456 satisfy these conditions, can be treated as verbatim copying in
4459 If the required texts for either cover are too voluminous to fit
4460 legibly, you should put the first ones listed (as many as fit
4461 reasonably) on the actual cover, and continue the rest onto
4464 If you publish or distribute Opaque copies of the Document
4465 numbering more than 100, you must either include a
4466 machine-readable Transparent copy along with each Opaque copy, or
4467 state in or with each Opaque copy a publicly-accessible
4468 computer-network location containing a complete Transparent copy
4469 of the Document, free of added material, which the general
4470 network-using public has access to download anonymously at no
4471 charge using public-standard network protocols. If you use the
4472 latter option, you must take reasonably prudent steps, when you
4473 begin distribution of Opaque copies in quantity, to ensure that
4474 this Transparent copy will remain thus accessible at the stated
4475 location until at least one year after the last time you
4476 distribute an Opaque copy (directly or through your agents or
4477 retailers) of that edition to the public.
4479 It is requested, but not required, that you contact the authors of
4480 the Document well before redistributing any large number of
4481 copies, to give them a chance to provide you with an updated
4482 version of the Document.
4486 You may copy and distribute a Modified Version of the Document
4487 under the conditions of sections 2 and 3 above, provided that you
4488 release the Modified Version under precisely this License, with
4489 the Modified Version filling the role of the Document, thus
4490 licensing distribution and modification of the Modified Version to
4491 whoever possesses a copy of it. In addition, you must do these
4492 things in the Modified Version:
4494 A. Use in the Title Page (and on the covers, if any) a title
4495 distinct from that of the Document, and from those of previous
4496 versions (which should, if there were any, be listed in the
4497 History section of the Document). You may use the same title
4498 as a previous version if the original publisher of that version
4500 B. List on the Title Page, as authors, one or more persons or
4501 entities responsible for authorship of the modifications in the
4502 Modified Version, together with at least five of the principal
4503 authors of the Document (all of its principal authors, if it
4504 has less than five).
4505 C. State on the Title page the name of the publisher of the
4506 Modified Version, as the publisher.
4507 D. Preserve all the copyright notices of the Document.
4508 E. Add an appropriate copyright notice for your modifications
4509 adjacent to the other copyright notices.
4510 F. Include, immediately after the copyright notices, a license
4511 notice giving the public permission to use the Modified Version
4512 under the terms of this License, in the form shown in the
4514 G. Preserve in that license notice the full lists of Invariant
4515 Sections and required Cover Texts given in the Document's
4517 H. Include an unaltered copy of this License.
4518 I. Preserve the section entitled "History", and its title, and add
4519 to it an item stating at least the title, year, new authors, and
4520 publisher of the Modified Version as given on the Title Page.
4521 If there is no section entitled "History" in the Document,
4522 create one stating the title, year, authors, and publisher of
4523 the Document as given on its Title Page, then add an item
4524 describing the Modified Version as stated in the previous
4526 J. Preserve the network location, if any, given in the Document for
4527 public access to a Transparent copy of the Document, and
4528 likewise the network locations given in the Document for
4529 previous versions it was based on. These may be placed in the
4530 "History" section. You may omit a network location for a work
4531 that was published at least four years before the Document
4532 itself, or if the original publisher of the version it refers
4533 to gives permission.
4534 K. In any section entitled "Acknowledgements" or "Dedications",
4535 preserve the section's title, and preserve in the section all the
4536 substance and tone of each of the contributor acknowledgements
4537 and/or dedications given therein.
4538 L. Preserve all the Invariant Sections of the Document,
4539 unaltered in their text and in their titles. Section numbers
4540 or the equivalent are not considered part of the section titles.
4541 M. Delete any section entitled "Endorsements." Such a section
4542 may not be included in the Modified Version.
4543 N. Do not retitle any existing section as "Endorsements" or to
4544 conflict in title with any Invariant Section.
4546 If the Modified Version includes new front-matter sections or
4547 appendices that qualify as Secondary Sections and contain no
4548 material copied from the Document, you may at your option
4549 designate some or all of these sections as invariant. To do this,
4550 add their titles to the list of Invariant Sections in the Modified
4551 Version's license notice. These titles must be distinct from any
4552 other section titles.
4554 You may add a section entitled "Endorsements", provided it contains
4555 nothing but endorsements of your Modified Version by various
4556 parties-for example, statements of peer review or that the text has
4557 been approved by an organization as the authoritative definition
4560 You may add a passage of up to five words as a Front-Cover Text,
4561 and a passage of up to 25 words as a Back-Cover Text, to the end
4562 of the list of Cover Texts in the Modified Version. Only one
4563 passage of Front-Cover Text and one of Back-Cover Text may be
4564 added by (or through arrangements made by) any one entity. If the
4565 Document already includes a cover text for the same cover,
4566 previously added by you or by arrangement made by the same entity
4567 you are acting on behalf of, you may not add another; but you may
4568 replace the old one, on explicit permission from the previous
4569 publisher that added the old one.
4571 The author(s) and publisher(s) of the Document do not by this
4572 License give permission to use their names for publicity for or to
4573 assert or imply endorsement of any Modified Version.
4575 5. COMBINING DOCUMENTS
4577 You may combine the Document with other documents released under
4578 this License, under the terms defined in section 4 above for
4579 modified versions, provided that you include in the combination
4580 all of the Invariant Sections of all of the original documents,
4581 unmodified, and list them all as Invariant Sections of your
4582 combined work in its license notice.
4584 The combined work need only contain one copy of this License, and
4585 multiple identical Invariant Sections may be replaced with a single
4586 copy. If there are multiple Invariant Sections with the same name
4587 but different contents, make the title of each such section unique
4588 by adding at the end of it, in parentheses, the name of the
4589 original author or publisher of that section if known, or else a
4590 unique number. Make the same adjustment to the section titles in
4591 the list of Invariant Sections in the license notice of the
4594 In the combination, you must combine any sections entitled
4595 "History" in the various original documents, forming one section
4596 entitled "History"; likewise combine any sections entitled
4597 "Acknowledgements", and any sections entitled "Dedications." You
4598 must delete all sections entitled "Endorsements."
4600 6. COLLECTIONS OF DOCUMENTS
4602 You may make a collection consisting of the Document and other
4603 documents released under this License, and replace the individual
4604 copies of this License in the various documents with a single copy
4605 that is included in the collection, provided that you follow the
4606 rules of this License for verbatim copying of each of the
4607 documents in all other respects.
4609 You may extract a single document from such a collection, and
4610 distribute it individually under this License, provided you insert
4611 a copy of this License into the extracted document, and follow
4612 this License in all other respects regarding verbatim copying of
4615 7. AGGREGATION WITH INDEPENDENT WORKS
4617 A compilation of the Document or its derivatives with other
4618 separate and independent documents or works, in or on a volume of
4619 a storage or distribution medium, does not as a whole count as a
4620 Modified Version of the Document, provided no compilation
4621 copyright is claimed for the compilation. Such a compilation is
4622 called an "aggregate", and this License does not apply to the
4623 other self-contained works thus compiled with the Document, on
4624 account of their being thus compiled, if they are not themselves
4625 derivative works of the Document.
4627 If the Cover Text requirement of section 3 is applicable to these
4628 copies of the Document, then if the Document is less than one
4629 quarter of the entire aggregate, the Document's Cover Texts may be
4630 placed on covers that surround only the Document within the
4631 aggregate. Otherwise they must appear on covers around the whole
4636 Translation is considered a kind of modification, so you may
4637 distribute translations of the Document under the terms of section
4638 4. Replacing Invariant Sections with translations requires special
4639 permission from their copyright holders, but you may include
4640 translations of some or all Invariant Sections in addition to the
4641 original versions of these Invariant Sections. You may include a
4642 translation of this License provided that you also include the
4643 original English version of this License. In case of a
4644 disagreement between the translation and the original English
4645 version of this License, the original English version will prevail.
4649 You may not copy, modify, sublicense, or distribute the Document
4650 except as expressly provided for under this License. Any other
4651 attempt to copy, modify, sublicense or distribute the Document is
4652 void, and will automatically terminate your rights under this
4653 License. However, parties who have received copies, or rights,
4654 from you under this License will not have their licenses
4655 terminated so long as such parties remain in full compliance.
4657 10. FUTURE REVISIONS OF THIS LICENSE
4659 The Free Software Foundation may publish new, revised versions of
4660 the GNU Free Documentation License from time to time. Such new
4661 versions will be similar in spirit to the present version, but may
4662 differ in detail to address new problems or concerns. See
4663 http://www.gnu.org/copyleft/.
4665 Each version of the License is given a distinguishing version
4666 number. If the Document specifies that a particular numbered
4667 version of this License "or any later version" applies to it, you
4668 have the option of following the terms and conditions either of
4669 that specified version or of any later version that has been
4670 published (not as a draft) by the Free Software Foundation. If
4671 the Document does not specify a version number of this License,
4672 you may choose any version ever published (not as a draft) by the
4673 Free Software Foundation.
4676 ADDENDUM: How to use this License for your documents
4677 ====================================================
4679 To use this License in a document you have written, include a copy of
4680 the License in the document and put the following copyright and license
4681 notices just after the title page:
4683 Copyright (C) YEAR YOUR NAME.
4684 Permission is granted to copy, distribute and/or modify this document
4685 under the terms of the GNU Free Documentation License, Version 1.1
4686 or any later version published by the Free Software Foundation;
4687 with the Invariant Sections being LIST THEIR TITLES, with the
4688 Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
4689 A copy of the license is included in the section entitled "GNU
4690 Free Documentation License."
4692 If you have no Invariant Sections, write "with no Invariant Sections"
4693 instead of saying which ones are invariant. If you have no Front-Cover
4694 Texts, write "no Front-Cover Texts" instead of "Front-Cover Texts being
4695 LIST"; likewise for Back-Cover Texts.
4697 If your document contains nontrivial examples of program code, we
4698 recommend releasing these examples in parallel under your choice of
4699 free software license, such as the GNU General Public License, to
4700 permit their use in free software.
4703 File: standards.info, Node: Index, Prev: Copying This Manual, Up: Top
4711 * #endif, commenting: Comments. (line 54)
4712 * --help option: Command-Line Interfaces.
4714 * --version option: Command-Line Interfaces.
4716 * -Wall compiler option: Syntactic Conventions.
4718 * accepting contributions: Contributions. (line 6)
4719 * address for bug reports: Command-Line Interfaces.
4721 * ANSI C standard: Standard C. (line 6)
4722 * arbitrary limits on data: Semantics. (line 6)
4723 * autoconf: System Portability. (line 23)
4724 * avoiding proprietary code: Reading Non-Free Code.
4726 * behavior, dependent on program's name: User Interfaces. (line 6)
4727 * binary packages: Install Command Categories.
4729 * bindir: Directory Variables. (line 45)
4730 * braces, in C source: Formatting. (line 6)
4731 * bug reports: Command-Line Interfaces.
4733 * canonical name of a program: Command-Line Interfaces.
4735 * casting pointers to integers: CPU Portability. (line 67)
4736 * change logs: Change Logs. (line 6)
4737 * change logs, conditional changes: Conditional Changes. (line 6)
4738 * change logs, style: Style of Change Logs.
4740 * command-line arguments, decoding: Semantics. (line 46)
4741 * command-line interface: Command-Line Interfaces.
4743 * commenting: Comments. (line 6)
4744 * compatibility with C and POSIX standards: Compatibility. (line 6)
4745 * compiler warnings: Syntactic Conventions.
4747 * conditional changes, and change logs: Conditional Changes. (line 6)
4748 * conditionals, comments for: Comments. (line 54)
4749 * configure: Configuration. (line 6)
4750 * control-L: Formatting. (line 114)
4751 * conventions for makefiles: Makefile Conventions.
4753 * corba: Graphical Interfaces.
4755 * credits for manuals: Manual Credits. (line 6)
4756 * data types, and portability: CPU Portability. (line 6)
4757 * declaration for system functions: System Functions. (line 21)
4758 * documentation: Documentation. (line 6)
4759 * doschk: Names. (line 38)
4760 * downloading this manual: Preface. (line 17)
4761 * error messages: Semantics. (line 19)
4762 * error messages, formatting: Errors. (line 6)
4763 * exec_prefix: Directory Variables. (line 27)
4764 * expressions, splitting: Formatting. (line 77)
4765 * file usage: File Usage. (line 6)
4766 * file-name limitations: Names. (line 38)
4767 * formatting error messages: Errors. (line 6)
4768 * formatting source code: Formatting. (line 6)
4769 * formfeed: Formatting. (line 114)
4770 * function argument, declaring: Syntactic Conventions.
4772 * function prototypes: Standard C. (line 17)
4773 * getopt: Command-Line Interfaces.
4775 * gettext: Internationalization.
4777 * gnome: Graphical Interfaces.
4779 * graphical user interface: Graphical Interfaces.
4781 * gtk: Graphical Interfaces.
4783 * GUILE: Source Language. (line 38)
4784 * implicit int: Syntactic Conventions.
4786 * impossible conditions: Semantics. (line 70)
4787 * internationalization: Internationalization.
4789 * legal aspects: Legal Issues. (line 6)
4790 * legal papers: Contributions. (line 6)
4791 * libexecdir: Directory Variables. (line 58)
4792 * libraries: Libraries. (line 6)
4793 * library functions, and portability: System Functions. (line 6)
4794 * license for manuals: License for Manuals. (line 6)
4795 * lint: Syntactic Conventions.
4797 * long option names: Option Table. (line 6)
4798 * long-named options: Command-Line Interfaces.
4800 * makefile, conventions for: Makefile Conventions.
4802 * malloc return value: Semantics. (line 25)
4803 * man pages: Man Pages. (line 6)
4804 * manual structure: Manual Structure Details.
4806 * memory allocation failure: Semantics. (line 25)
4807 * memory usage: Memory Usage. (line 6)
4808 * message text, and internationalization: Internationalization.
4810 * mmap: Mmap. (line 6)
4811 * multiple variables in a line: Syntactic Conventions.
4813 * names of variables, functions, and files: Names. (line 6)
4814 * NEWS file: NEWS File. (line 6)
4815 * non-POSIX systems, and portability: System Portability. (line 32)
4816 * non-standard extensions: Using Extensions. (line 6)
4817 * NUL characters: Semantics. (line 11)
4818 * open brace: Formatting. (line 6)
4819 * optional features, configure-time: Configuration. (line 76)
4820 * options for compatibility: Compatibility. (line 14)
4821 * output device and program's behavior: User Interfaces. (line 13)
4822 * packaging: Releases. (line 6)
4823 * portability, and data types: CPU Portability. (line 6)
4824 * portability, and library functions: System Functions. (line 6)
4825 * portability, between system types: System Portability. (line 6)
4826 * POSIX compatibility: Compatibility. (line 6)
4827 * POSIXLY_CORRECT, environment variable: Compatibility. (line 21)
4828 * post-installation commands: Install Command Categories.
4830 * pre-installation commands: Install Command Categories.
4832 * prefix: Directory Variables. (line 17)
4833 * program configuration: Configuration. (line 6)
4834 * program design: Design Advice. (line 6)
4835 * program name and its behavior: User Interfaces. (line 6)
4836 * program's canonical name: Command-Line Interfaces.
4838 * programming languges: Source Language. (line 6)
4839 * proprietary programs: Reading Non-Free Code.
4841 * README file: Releases. (line 17)
4842 * references to non-free material: References. (line 6)
4843 * releasing: Managing Releases. (line 6)
4844 * sbindir: Directory Variables. (line 51)
4845 * signal handling: Semantics. (line 59)
4846 * spaces before open-paren: Formatting. (line 71)
4847 * standard command-line options: Command-Line Interfaces.
4849 * standards for makefiles: Makefile Conventions.
4851 * string library functions: System Functions. (line 55)
4852 * syntactic conventions: Syntactic Conventions.
4854 * table of long options: Option Table. (line 6)
4855 * temporary files: Semantics. (line 84)
4856 * temporary variables: Syntactic Conventions.
4858 * texinfo.tex, in a distribution: Releases. (line 73)
4859 * TMPDIR environment variable: Semantics. (line 84)
4860 * trademarks: Trademarks. (line 6)
4861 * where to obtain standards.texi: Preface. (line 17)
4867 Node: Preface
\x7f1396
4868 Node: Legal Issues
\x7f3616
4869 Node: Reading Non-Free Code
\x7f4080
4870 Node: Contributions
\x7f5808
4871 Node: Trademarks
\x7f7962
4872 Node: Design Advice
\x7f9025
4873 Node: Source Language
\x7f9609
4874 Node: Compatibility
\x7f11621
4875 Node: Using Extensions
\x7f13249
4876 Node: Standard C
\x7f14825
4877 Node: Conditional Compilation
\x7f17228
4878 Node: Program Behavior
\x7f18527
4879 Node: Semantics
\x7f19446
4880 Node: Libraries
\x7f24139
4881 Node: Errors
\x7f25384
4882 Node: User Interfaces
\x7f27165
4883 Node: Graphical Interfaces
\x7f28770
4884 Node: Command-Line Interfaces
\x7f29805
4885 Node: Option Table
\x7f35876
4886 Node: Memory Usage
\x7f50885
4887 Node: File Usage
\x7f51910
4888 Node: Writing C
\x7f52658
4889 Node: Formatting
\x7f53508
4890 Node: Comments
\x7f57571
4891 Node: Syntactic Conventions
\x7f60873
4892 Node: Names
\x7f64285
4893 Node: System Portability
\x7f66494
4894 Node: CPU Portability
\x7f68879
4895 Node: System Functions
\x7f72135
4896 Node: Internationalization
\x7f77332
4898 Node: Documentation
\x7f81195
4899 Node: GNU Manuals
\x7f82300
4900 Node: Doc Strings and Manuals
\x7f87357
4901 Node: Manual Structure Details
\x7f88910
4902 Node: License for Manuals
\x7f90328
4903 Node: Manual Credits
\x7f91302
4904 Node: Printed Manuals
\x7f91695
4905 Node: NEWS File
\x7f92381
4906 Node: Change Logs
\x7f93059
4907 Node: Change Log Concepts
\x7f93813
4908 Node: Style of Change Logs
\x7f95677
4909 Node: Simple Changes
\x7f97712
4910 Node: Conditional Changes
\x7f98956
4911 Node: Indicating the Part Changed
\x7f100378
4912 Node: Man Pages
\x7f100905
4913 Node: Reading other Manuals
\x7f102529
4914 Node: Managing Releases
\x7f103320
4915 Node: Configuration
\x7f104083
4916 Node: Makefile Conventions
\x7f110988
4917 Node: Makefile Basics
\x7f111794
4918 Node: Utilities in Makefiles
\x7f114968
4919 Node: Command Variables
\x7f117113
4920 Node: Directory Variables
\x7f120690
4921 Node: Standard Targets
\x7f131584
4922 Ref: Standard Targets-Footnote-1
\x7f142824
4923 Node: Install Command Categories
\x7f142924
4924 Node: Releases
\x7f147506
4925 Node: References
\x7f151594
4926 Node: Copying This Manual
\x7f153879
4927 Node: GNU Free Documentation License
\x7f154115
4928 Node: Index
\x7f173816