Home | History | Annotate | Download | only in info
      1 This is standards.info, produced by makeinfo version 4.8 from
      2 .././etc/standards.texi.
      3 
      4 START-INFO-DIR-ENTRY
      5 * Standards: (standards).        GNU coding standards.
      6 END-INFO-DIR-ENTRY
      7 
      8    GNU Coding Standards Copyright (C) 1992, 1993, 1994, 1995, 1996,
      9 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc.
     10 
     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".
     17 
     18 
     19 File: standards.info,  Node: Top,  Next: Preface,  Prev: (dir),  Up: (dir)
     20 
     21 Version
     22 *******
     23 
     24 Last updated February 14, 2002.
     25 
     26 * Menu:
     27 
     28 * Preface::                     About the GNU Coding Standards
     29 * Legal Issues::                Keeping Free Software Free
     30 * Design Advice::               General Program Design
     31 * Program Behavior::            Program Behavior for All Programs
     32 * Writing C::                   Making The Best Use of C
     33 * Documentation::               Documenting Programs
     34 * Managing Releases::           The Release Process
     35 * References::                  References to Non-Free Software or Documentation
     36 * Copying This Manual::         How to Make Copies of This Manual
     37 * Index::
     38 
     39 
     40 File: standards.info,  Node: Preface,  Next: Legal Issues,  Prev: Top,  Up: Top
     41 
     42 1 About the GNU Coding Standards
     43 ********************************
     44 
     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.
     52 
     53    This release of the GNU Coding Standards was last updated February
     54 14, 2002.
     55 
     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'.
     65 
     66    Corrections or suggestions for this document should be sent to
     67 <bug-standards (a] 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.
     71 
     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
     76 do suggest them.
     77 
     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.
     83 
     84 
     85 File: standards.info,  Node: Legal Issues,  Next: Design Advice,  Prev: Preface,  Up: Top
     86 
     87 2 Keeping Free Software Free
     88 ****************************
     89 
     90 This node discusses how you can make sure that GNU software avoids
     91 legal difficulties, and other related issues.
     92 
     93 * Menu:
     94 
     95 * Reading Non-Free Code::       Referring to Proprietary Programs
     96 * Contributions::               Accepting Contributions
     97 * Trademarks::                  How We Deal with Trademark Issues
     98 
     99 
    100 File: standards.info,  Node: Reading Non-Free Code,  Next: Contributions,  Up: Legal Issues
    101 
    102 2.1 Referring to Proprietary Programs
    103 =====================================
    104 
    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.)
    107 
    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.
    113 
    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).
    120 
    121    Or, on the contrary, emphasize simplicity instead of speed.  For some
    122 applications, the speed of today's computers makes simpler algorithms
    123 adequate.
    124 
    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.
    130 
    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
    134 obstacks.
    135 
    136 
    137 File: standards.info,  Node: Contributions,  Next: Trademarks,  Prev: Reading Non-Free Code,  Up: Legal Issues
    138 
    139 2.2 Accepting Contributions
    140 ===========================
    141 
    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
    148 enough.
    149 
    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
    153 contribution.
    154 
    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.
    158 
    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.
    162 
    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!
    167 
    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
    173 get papers.
    174 
    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
    177 result.
    178 
    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.
    182 
    183 
    184 File: standards.info,  Node: Trademarks,  Prev: Contributions,  Up: Legal Issues
    185 
    186 2.3 Trademarks
    187 ==============
    188 
    189 Please do not include any trademark acknowledgements in GNU software
    190 packages or documentation.
    191 
    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.
    196 
    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
    205 language.
    206 
    207 
    208 File: standards.info,  Node: Design Advice,  Next: Program Behavior,  Prev: Legal Issues,  Up: Top
    209 
    210 3 General Program Design
    211 ************************
    212 
    213 This node discusses some of the issues you should take into account
    214 when designing your program.
    215 
    216 * Menu:
    217 
    218 * Source Language::             Which languges to use.
    219 * Compatibility::               Compatibility with other implementations
    220 * Using Extensions::            Using non-standard features
    221 * Standard C::                  Using Standard C features
    222 * Conditional Compilation::     Compiling Code Only If A Conditional is True
    223 
    224 
    225 File: standards.info,  Node: Source Language,  Next: Compatibility,  Up: Design Advice
    226 
    227 3.1 Which Languages to Use
    228 ==========================
    229 
    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.
    237 
    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.
    241 
    242    So in general it is much better to use C, rather than the comparable
    243 alternatives.
    244 
    245    But there are two exceptions to that conclusion:
    246 
    247    * It is no problem to use another language to write a tool
    248      specifically intended for use with that language.  That is because
    249      the only people who want to build the tool will be those who have
    250      installed the other language anyway.
    251 
    252    * If an application is of interest only to a narrow part of the
    253      community, then the question of which language it is written in
    254      has less effect on other people, so you may as well please
    255      yourself.
    256 
    257    Many programs are designed to be extensible: they include an
    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.
    261 
    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
    267 the GNU system.
    268 
    269 
    270 File: standards.info,  Node: Compatibility,  Next: Using Extensions,  Prev: Source Language,  Up: Design Advice
    271 
    272 3.2 Compatibility with Other Implementations
    273 ============================================
    274 
    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.
    279 
    280    When these standards conflict, it is useful to offer compatibility
    281 modes for each of them.
    282 
    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.
    289 
    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.
    294 
    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.)
    300 
    301    Additional useful features are welcome regardless of whether there
    302 is any precedent for them.
    303 
    304 
    305 File: standards.info,  Node: Using Extensions,  Next: Standard C,  Prev: Compatibility,  Up: Design Advice
    306 
    307 3.3 Using Non-standard Features
    308 ===============================
    309 
    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.
    313 
    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.
    318 
    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.
    323 
    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.
    327 
    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
    331 do that.
    332 
    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
    338 cases.
    339 
    340 
    341 File: standards.info,  Node: Standard C,  Next: Conditional Compilation,  Prev: Using Extensions,  Up: Design Advice
    342 
    343 3.4 Standard C and Pre-Standard C
    344 =================================
    345 
    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.
    349 
    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.
    352 
    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.
    356 
    357    To support pre-standard C, instead of writing function definitions in
    358 standard prototype form,
    359 
    360      int
    361      foo (int x, int y)
    362      ...
    363 
    364 write the definition in pre-standard style like this,
    365 
    366      int
    367      foo (x, y)
    368           int x, y;
    369      ...
    370 
    371 and use a separate declaration to specify the argument prototype:
    372 
    373      int foo (int, int);
    374 
    375    You need such a declaration anyway, in a header file, to get the
    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.
    379 
    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.
    383 
    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.
    393 
    394    In order to support pre-standard compilers that do not recognize
    395 prototypes, you may want to use a preprocessor macro like this:
    396 
    397      /* Declare the prototype for a general external function.  */
    398      #if defined (__STDC__) || defined (WINDOWSNT)
    399      #define P_(proto) proto
    400      #else
    401      #define P_(proto) ()
    402      #endif
    403 
    404 
    405 File: standards.info,  Node: Conditional Compilation,  Prev: Standard C,  Up: Design Advice
    406 
    407 3.5 Conditional Compilation
    408 ===========================
    409 
    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.
    414 
    415    For example, please write
    416 
    417        if (HAS_FOO)
    418          ...
    419        else
    420          ...
    421 
    422    instead of:
    423 
    424        #ifdef HAS_FOO
    425          ...
    426        #else
    427          ...
    428        #endif
    429 
    430    A modern compiler such as GCC will generate exactly the same code in
    431 both cases, and we have been using similar techniques with good success
    432 in several projects.
    433 
    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.
    437 
    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:
    442 
    443        #ifdef REVERSIBLE_CC_MODE
    444        #define HAS_REVERSIBLE_CC_MODE 1
    445        #else
    446        #define HAS_REVERSIBLE_CC_MODE 0
    447        #endif
    448 
    449 
    450 File: standards.info,  Node: Program Behavior,  Next: Writing C,  Prev: Design Advice,  Up: Top
    451 
    452 4 Program Behavior for All Programs
    453 ***********************************
    454 
    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.
    458 
    459 * Menu:
    460 
    461 * Semantics::                   Writing robust programs
    462 * Libraries::                   Library behavior
    463 * Errors::                      Formatting error messages
    464 * User Interfaces::             Standards about interfaces generally
    465 * Graphical Interfaces::        Standards for graphical interfaces
    466 * Command-Line Interfaces::     Standards for command line interfaces
    467 * Option Table::                Table of long options
    468 * Memory Usage::                When and how to care about memory needs
    469 * File Usage::                  Which files to use, and where
    470 
    471 
    472 File: standards.info,  Node: Semantics,  Next: Libraries,  Up: Program Behavior
    473 
    474 4.1 Writing Robust Programs
    475 ===========================
    476 
    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.
    481 
    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.
    489 
    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.
    495 
    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.
    500 
    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'.
    506 
    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
    509 calling `free'.
    510 
    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.
    516 
    517    Use `getopt_long' to decode arguments, unless the argument syntax
    518 makes this unreasonable.
    519 
    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.
    523 
    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.
    529 
    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.
    533 
    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
    539 give up on them.
    540 
    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
    547 elsewhere.
    548 
    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.
    554 
    555    If you make temporary files, check the `TMPDIR' environment
    556 variable; if that variable is defined, use the specified directory
    557 instead of `/tmp'.
    558 
    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:
    562 
    563      fd = open(filename, O_WRONLY | O_CREAT | O_EXCL, 0600);
    564 
    565 or by using the `mkstemps' function from libiberty.
    566 
    567    In bash, use `set -C' to avoid this problem.
    568 
    569 
    570 File: standards.info,  Node: Libraries,  Next: Errors,  Prev: Semantics,  Up: Program Behavior
    571 
    572 4.2 Library Behavior
    573 ====================
    574 
    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.
    578 
    579    Here are certain name conventions for libraries, to avoid name
    580 conflicts.
    581 
    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.
    586 
    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.
    590 
    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
    595 if you like.
    596 
    597    Static functions and variables can be used as you like and need not
    598 fit any naming convention.
    599 
    600 
    601 File: standards.info,  Node: Errors,  Next: User Interfaces,  Prev: Libraries,  Up: Program Behavior
    602 
    603 4.3 Formatting Error Messages
    604 =============================
    605 
    606 Error messages from compilers should look like this:
    607 
    608      SOURCE-FILE-NAME:LINENO: MESSAGE
    609 
    610 If you want to mention the column number, use this format:
    611 
    612      SOURCE-FILE-NAME:LINENO:COLUMN: MESSAGE
    613 
    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.
    619 
    620    Error messages from other noninteractive programs should look like
    621 this:
    622 
    623      PROGRAM:SOURCE-FILE-NAME:LINENO: MESSAGE
    624 
    625 when there is an appropriate source file, or like this:
    626 
    627      PROGRAM: MESSAGE
    628 
    629 when there is no relevant source file.
    630 
    631    If you want to mention the column number, use this format:
    632 
    633      PROGRAM:SOURCE-FILE-NAME:LINENO:COLUMN: MESSAGE
    634 
    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.)
    641 
    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
    644 a period.
    645 
    646    Error messages from interactive programs, and other messages such as
    647 usage messages, should start with a capital letter.  But they should not
    648 end with a period.
    649 
    650 
    651 File: standards.info,  Node: User Interfaces,  Next: Graphical Interfaces,  Prev: Errors,  Up: Program Behavior
    652 
    653 4.4 Standards for Interfaces Generally
    654 ======================================
    655 
    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.
    659 
    660    Instead, use a run time option or a compilation switch or both to
    661 select among the alternate behaviors.
    662 
    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.)
    669 
    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
    674 behavior.
    675 
    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
    682 format.
    683 
    684 
    685 File: standards.info,  Node: Graphical Interfaces,  Next: Command-Line Interfaces,  Prev: User Interfaces,  Up: Program Behavior
    686 
    687 4.5 Standards for Graphical Interfaces
    688 ======================================
    689 
    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").
    694 
    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.
    699 
    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.
    705 
    706 
    707 File: standards.info,  Node: Command-Line Interfaces,  Next: Option Table,  Prev: Graphical Interfaces,  Up: Program Behavior
    708 
    709 4.6 Standards for Command Line Interfaces
    710 =========================================
    711 
    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.
    717 
    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
    721 `getopt_long'.
    722 
    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::).
    729 
    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.
    736 
    737    All programs should support two standard options: `--version' and
    738 `--help'.
    739 
    740 `--version'
    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.
    746 
    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:
    750 
    751           GNU Emacs 19.30
    752 
    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'.
    757 
    758      If the program is a subsidiary part of a larger package, mention
    759      the package name in parentheses, like this:
    760 
    761           emacsserver (GNU Emacs) 19.30
    762 
    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.
    766 
    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.
    772 
    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.
    777 
    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.
    781 
    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
    786      permitted by law.
    787 
    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.
    790 
    791      Here's an example of output that follows these rules:
    792 
    793           GNU Emacs 19.34.5
    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.
    801 
    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
    805      necessary.
    806 
    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.
    812 
    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:
    817 
    818      (the official copyright symbol, which is the letter C in a circle);
    819 
    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.
    824 
    825 `--help'
    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.
    830 
    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:
    833 
    834           Report bugs to MAILING-ADDRESS.
    835 
    836 
    837 File: standards.info,  Node: Option Table,  Next: Memory Usage,  Prev: Command-Line Interfaces,  Up: Program Behavior
    838 
    839 4.7 Table of Long Options
    840 =========================
    841 
    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 (a] gnu.org> a list of them, with their
    846 meanings, so we can update the table.
    847 
    848 `after-date'
    849      `-N' in `tar'.
    850 
    851 `all'
    852      `-a' in `du', `ls', `nm', `stty', `uname', and `unexpand'.
    853 
    854 `all-text'
    855      `-a' in `diff'.
    856 
    857 `almost-all'
    858      `-A' in `ls'.
    859 
    860 `append'
    861      `-a' in `etags', `tee', `time'; `-r' in `tar'.
    862 
    863 `archive'
    864      `-a' in `cp'.
    865 
    866 `archive-name'
    867      `-n' in `shar'.
    868 
    869 `arglength'
    870      `-l' in `m4'.
    871 
    872 `ascii'
    873      `-a' in `diff'.
    874 
    875 `assign'
    876      `-v' in `gawk'.
    877 
    878 `assume-new'
    879      `-W' in Make.
    880 
    881 `assume-old'
    882      `-o' in Make.
    883 
    884 `auto-check'
    885      `-a' in `recode'.
    886 
    887 `auto-pager'
    888      `-a' in `wdiff'.
    889 
    890 `auto-reference'
    891      `-A' in `ptx'.
    892 
    893 `avoid-wraps'
    894      `-n' in `wdiff'.
    895 
    896 `background'
    897      For server programs, run in the background.
    898 
    899 `backward-search'
    900      `-B' in `ctags'.
    901 
    902 `basename'
    903      `-f' in `shar'.
    904 
    905 `batch'
    906      Used in GDB.
    907 
    908 `baud'
    909      Used in GDB.
    910 
    911 `before'
    912      `-b' in `tac'.
    913 
    914 `binary'
    915      `-b' in `cpio' and `diff'.
    916 
    917 `bits-per-code'
    918      `-b' in `shar'.
    919 
    920 `block-size'
    921      Used in `cpio' and `tar'.
    922 
    923 `blocks'
    924      `-b' in `head' and `tail'.
    925 
    926 `break-file'
    927      `-b' in `ptx'.
    928 
    929 `brief'
    930      Used in various programs to make output shorter.
    931 
    932 `bytes'
    933      `-c' in `head', `split', and `tail'.
    934 
    935 `c++'
    936      `-C' in `etags'.
    937 
    938 `catenate'
    939      `-A' in `tar'.
    940 
    941 `cd'
    942      Used in various programs to specify the directory to use.
    943 
    944 `changes'
    945      `-c' in `chgrp' and `chown'.
    946 
    947 `classify'
    948      `-F' in `ls'.
    949 
    950 `colons'
    951      `-c' in `recode'.
    952 
    953 `command'
    954      `-c' in `su'; `-x' in GDB.
    955 
    956 `compare'
    957      `-d' in `tar'.
    958 
    959 `compat'
    960      Used in `gawk'.
    961 
    962 `compress'
    963      `-Z' in `tar' and `shar'.
    964 
    965 `concatenate'
    966      `-A' in `tar'.
    967 
    968 `confirmation'
    969      `-w' in `tar'.
    970 
    971 `context'
    972      Used in `diff'.
    973 
    974 `copyleft'
    975      `-W copyleft' in `gawk'.
    976 
    977 `copyright'
    978      `-C' in `ptx', `recode', and `wdiff'; `-W copyright' in `gawk'.
    979 
    980 `core'
    981      Used in GDB.
    982 
    983 `count'
    984      `-q' in `who'.
    985 
    986 `count-links'
    987      `-l' in `du'.
    988 
    989 `create'
    990      Used in `tar' and `cpio'.
    991 
    992 `cut-mark'
    993      `-c' in `shar'.
    994 
    995 `cxref'
    996      `-x' in `ctags'.
    997 
    998 `date'
    999      `-d' in `touch'.
   1000 
   1001 `debug'
   1002      `-d' in Make and `m4'; `-t' in Bison.
   1003 
   1004 `define'
   1005      `-D' in `m4'.
   1006 
   1007 `defines'
   1008      `-d' in Bison and `ctags'.
   1009 
   1010 `delete'
   1011      `-D' in `tar'.
   1012 
   1013 `dereference'
   1014      `-L' in `chgrp', `chown', `cpio', `du', `ls', and `tar'.
   1015 
   1016 `dereference-args'
   1017      `-D' in `du'.
   1018 
   1019 `device'
   1020      Specify an I/O device (special file name).
   1021 
   1022 `diacritics'
   1023      `-d' in `recode'.
   1024 
   1025 `dictionary-order'
   1026      `-d' in `look'.
   1027 
   1028 `diff'
   1029      `-d' in `tar'.
   1030 
   1031 `digits'
   1032      `-n' in `csplit'.
   1033 
   1034 `directory'
   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
   1038      specially.
   1039 
   1040 `discard-all'
   1041      `-x' in `strip'.
   1042 
   1043 `discard-locals'
   1044      `-X' in `strip'.
   1045 
   1046 `dry-run'
   1047      `-n' in Make.
   1048 
   1049 `ed'
   1050      `-e' in `diff'.
   1051 
   1052 `elide-empty-files'
   1053      `-z' in `csplit'.
   1054 
   1055 `end-delete'
   1056      `-x' in `wdiff'.
   1057 
   1058 `end-insert'
   1059      `-z' in `wdiff'.
   1060 
   1061 `entire-new-file'
   1062      `-N' in `diff'.
   1063 
   1064 `environment-overrides'
   1065      `-e' in Make.
   1066 
   1067 `eof'
   1068      `-e' in `xargs'.
   1069 
   1070 `epoch'
   1071      Used in GDB.
   1072 
   1073 `error-limit'
   1074      Used in `makeinfo'.
   1075 
   1076 `error-output'
   1077      `-o' in `m4'.
   1078 
   1079 `escape'
   1080      `-b' in `ls'.
   1081 
   1082 `exclude-from'
   1083      `-X' in `tar'.
   1084 
   1085 `exec'
   1086      Used in GDB.
   1087 
   1088 `exit'
   1089      `-x' in `xargs'.
   1090 
   1091 `exit-0'
   1092      `-e' in `unshar'.
   1093 
   1094 `expand-tabs'
   1095      `-t' in `diff'.
   1096 
   1097 `expression'
   1098      `-e' in `sed'.
   1099 
   1100 `extern-only'
   1101      `-g' in `nm'.
   1102 
   1103 `extract'
   1104      `-i' in `cpio'; `-x' in `tar'.
   1105 
   1106 `faces'
   1107      `-f' in `finger'.
   1108 
   1109 `fast'
   1110      `-f' in `su'.
   1111 
   1112 `fatal-warnings'
   1113      `-E' in `m4'.
   1114 
   1115 `file'
   1116      `-f' in `info', `gawk', Make, `mt', and `tar'; `-n' in `sed'; `-r'
   1117      in `touch'.
   1118 
   1119 `field-separator'
   1120      `-F' in `gawk'.
   1121 
   1122 `file-prefix'
   1123      `-b' in Bison.
   1124 
   1125 `file-type'
   1126      `-F' in `ls'.
   1127 
   1128 `files-from'
   1129      `-T' in `tar'.
   1130 
   1131 `fill-column'
   1132      Used in `makeinfo'.
   1133 
   1134 `flag-truncation'
   1135      `-F' in `ptx'.
   1136 
   1137 `fixed-output-files'
   1138      `-y' in Bison.
   1139 
   1140 `follow'
   1141      `-f' in `tail'.
   1142 
   1143 `footnote-style'
   1144      Used in `makeinfo'.
   1145 
   1146 `force'
   1147      `-f' in `cp', `ln', `mv', and `rm'.
   1148 
   1149 `force-prefix'
   1150      `-F' in `shar'.
   1151 
   1152 `foreground'
   1153      For server programs, run in the foreground; in other words, don't
   1154      do anything special to run the server in the background.
   1155 
   1156 `format'
   1157      Used in `ls', `time', and `ptx'.
   1158 
   1159 `freeze-state'
   1160      `-F' in `m4'.
   1161 
   1162 `fullname'
   1163      Used in GDB.
   1164 
   1165 `gap-size'
   1166      `-g' in `ptx'.
   1167 
   1168 `get'
   1169      `-x' in `tar'.
   1170 
   1171 `graphic'
   1172      `-i' in `ul'.
   1173 
   1174 `graphics'
   1175      `-g' in `recode'.
   1176 
   1177 `group'
   1178      `-g' in `install'.
   1179 
   1180 `gzip'
   1181      `-z' in `tar' and `shar'.
   1182 
   1183 `hashsize'
   1184      `-H' in `m4'.
   1185 
   1186 `header'
   1187      `-h' in `objdump' and `recode'
   1188 
   1189 `heading'
   1190      `-H' in `who'.
   1191 
   1192 `help'
   1193      Used to ask for brief usage information.
   1194 
   1195 `here-delimiter'
   1196      `-d' in `shar'.
   1197 
   1198 `hide-control-chars'
   1199      `-q' in `ls'.
   1200 
   1201 `html'
   1202      In `makeinfo', output HTML.
   1203 
   1204 `idle'
   1205      `-u' in `who'.
   1206 
   1207 `ifdef'
   1208      `-D' in `diff'.
   1209 
   1210 `ignore'
   1211      `-I' in `ls'; `-x' in `recode'.
   1212 
   1213 `ignore-all-space'
   1214      `-w' in `diff'.
   1215 
   1216 `ignore-backups'
   1217      `-B' in `ls'.
   1218 
   1219 `ignore-blank-lines'
   1220      `-B' in `diff'.
   1221 
   1222 `ignore-case'
   1223      `-f' in `look' and `ptx'; `-i' in `diff' and `wdiff'.
   1224 
   1225 `ignore-errors'
   1226      `-i' in Make.
   1227 
   1228 `ignore-file'
   1229      `-i' in `ptx'.
   1230 
   1231 `ignore-indentation'
   1232      `-I' in `etags'.
   1233 
   1234 `ignore-init-file'
   1235      `-f' in Oleo.
   1236 
   1237 `ignore-interrupts'
   1238      `-i' in `tee'.
   1239 
   1240 `ignore-matching-lines'
   1241      `-I' in `diff'.
   1242 
   1243 `ignore-space-change'
   1244      `-b' in `diff'.
   1245 
   1246 `ignore-zeros'
   1247      `-i' in `tar'.
   1248 
   1249 `include'
   1250      `-i' in `etags'; `-I' in `m4'.
   1251 
   1252 `include-dir'
   1253      `-I' in Make.
   1254 
   1255 `incremental'
   1256      `-G' in `tar'.
   1257 
   1258 `info'
   1259      `-i', `-l', and `-m' in Finger.
   1260 
   1261 `init-file'
   1262      In some programs, specify the name of the file to read as the
   1263      user's init file.
   1264 
   1265 `initial'
   1266      `-i' in `expand'.
   1267 
   1268 `initial-tab'
   1269      `-T' in `diff'.
   1270 
   1271 `inode'
   1272      `-i' in `ls'.
   1273 
   1274 `interactive'
   1275      `-i' in `cp', `ln', `mv', `rm'; `-e' in `m4'; `-p' in `xargs';
   1276      `-w' in `tar'.
   1277 
   1278 `intermix-type'
   1279      `-p' in `shar'.
   1280 
   1281 `iso-8601'
   1282      Used in `date'
   1283 
   1284 `jobs'
   1285      `-j' in Make.
   1286 
   1287 `just-print'
   1288      `-n' in Make.
   1289 
   1290 `keep-going'
   1291      `-k' in Make.
   1292 
   1293 `keep-files'
   1294      `-k' in `csplit'.
   1295 
   1296 `kilobytes'
   1297      `-k' in `du' and `ls'.
   1298 
   1299 `language'
   1300      `-l' in `etags'.
   1301 
   1302 `less-mode'
   1303      `-l' in `wdiff'.
   1304 
   1305 `level-for-gzip'
   1306      `-g' in `shar'.
   1307 
   1308 `line-bytes'
   1309      `-C' in `split'.
   1310 
   1311 `lines'
   1312      Used in `split', `head', and `tail'.
   1313 
   1314 `link'
   1315      `-l' in `cpio'.
   1316 
   1317 `lint'
   1318 `lint-old'
   1319      Used in `gawk'.
   1320 
   1321 `list'
   1322      `-t' in `cpio'; `-l' in `recode'.
   1323 
   1324 `list'
   1325      `-t' in `tar'.
   1326 
   1327 `literal'
   1328      `-N' in `ls'.
   1329 
   1330 `load-average'
   1331      `-l' in Make.
   1332 
   1333 `login'
   1334      Used in `su'.
   1335 
   1336 `machine'
   1337      No listing of which programs already use this; someone should
   1338      check to see if any actually do, and tell <gnu (a] gnu.org>.
   1339 
   1340 `macro-name'
   1341      `-M' in `ptx'.
   1342 
   1343 `mail'
   1344      `-m' in `hello' and `uname'.
   1345 
   1346 `make-directories'
   1347      `-d' in `cpio'.
   1348 
   1349 `makefile'
   1350      `-f' in Make.
   1351 
   1352 `mapped'
   1353      Used in GDB.
   1354 
   1355 `max-args'
   1356      `-n' in `xargs'.
   1357 
   1358 `max-chars'
   1359      `-n' in `xargs'.
   1360 
   1361 `max-lines'
   1362      `-l' in `xargs'.
   1363 
   1364 `max-load'
   1365      `-l' in Make.
   1366 
   1367 `max-procs'
   1368      `-P' in `xargs'.
   1369 
   1370 `mesg'
   1371      `-T' in `who'.
   1372 
   1373 `message'
   1374      `-T' in `who'.
   1375 
   1376 `minimal'
   1377      `-d' in `diff'.
   1378 
   1379 `mixed-uuencode'
   1380      `-M' in `shar'.
   1381 
   1382 `mode'
   1383      `-m' in `install', `mkdir', and `mkfifo'.
   1384 
   1385 `modification-time'
   1386      `-m' in `tar'.
   1387 
   1388 `multi-volume'
   1389      `-M' in `tar'.
   1390 
   1391 `name-prefix'
   1392      `-a' in Bison.
   1393 
   1394 `nesting-limit'
   1395      `-L' in `m4'.
   1396 
   1397 `net-headers'
   1398      `-a' in `shar'.
   1399 
   1400 `new-file'
   1401      `-W' in Make.
   1402 
   1403 `no-builtin-rules'
   1404      `-r' in Make.
   1405 
   1406 `no-character-count'
   1407      `-w' in `shar'.
   1408 
   1409 `no-check-existing'
   1410      `-x' in `shar'.
   1411 
   1412 `no-common'
   1413      `-3' in `wdiff'.
   1414 
   1415 `no-create'
   1416      `-c' in `touch'.
   1417 
   1418 `no-defines'
   1419      `-D' in `etags'.
   1420 
   1421 `no-deleted'
   1422      `-1' in `wdiff'.
   1423 
   1424 `no-dereference'
   1425      `-d' in `cp'.
   1426 
   1427 `no-inserted'
   1428      `-2' in `wdiff'.
   1429 
   1430 `no-keep-going'
   1431      `-S' in Make.
   1432 
   1433 `no-lines'
   1434      `-l' in Bison.
   1435 
   1436 `no-piping'
   1437      `-P' in `shar'.
   1438 
   1439 `no-prof'
   1440      `-e' in `gprof'.
   1441 
   1442 `no-regex'
   1443      `-R' in `etags'.
   1444 
   1445 `no-sort'
   1446      `-p' in `nm'.
   1447 
   1448 `no-split'
   1449      Used in `makeinfo'.
   1450 
   1451 `no-static'
   1452      `-a' in `gprof'.
   1453 
   1454 `no-time'
   1455      `-E' in `gprof'.
   1456 
   1457 `no-timestamp'
   1458      `-m' in `shar'.
   1459 
   1460 `no-validate'
   1461      Used in `makeinfo'.
   1462 
   1463 `no-wait'
   1464      Used in `emacsclient'.
   1465 
   1466 `no-warn'
   1467      Used in various programs to inhibit warnings.
   1468 
   1469 `node'
   1470      `-n' in `info'.
   1471 
   1472 `nodename'
   1473      `-n' in `uname'.
   1474 
   1475 `nonmatching'
   1476      `-f' in `cpio'.
   1477 
   1478 `nstuff'
   1479      `-n' in `objdump'.
   1480 
   1481 `null'
   1482      `-0' in `xargs'.
   1483 
   1484 `number'
   1485      `-n' in `cat'.
   1486 
   1487 `number-nonblank'
   1488      `-b' in `cat'.
   1489 
   1490 `numeric-sort'
   1491      `-n' in `nm'.
   1492 
   1493 `numeric-uid-gid'
   1494      `-n' in `cpio' and `ls'.
   1495 
   1496 `nx'
   1497      Used in GDB.
   1498 
   1499 `old-archive'
   1500      `-o' in `tar'.
   1501 
   1502 `old-file'
   1503      `-o' in Make.
   1504 
   1505 `one-file-system'
   1506      `-l' in `tar', `cp', and `du'.
   1507 
   1508 `only-file'
   1509      `-o' in `ptx'.
   1510 
   1511 `only-prof'
   1512      `-f' in `gprof'.
   1513 
   1514 `only-time'
   1515      `-F' in `gprof'.
   1516 
   1517 `options'
   1518      `-o' in `getopt', `fdlist', `fdmount', `fdmountd', and `fdumount'.
   1519 
   1520 `output'
   1521      In various programs, specify the output file name.
   1522 
   1523 `output-prefix'
   1524      `-o' in `shar'.
   1525 
   1526 `override'
   1527      `-o' in `rm'.
   1528 
   1529 `overwrite'
   1530      `-c' in `unshar'.
   1531 
   1532 `owner'
   1533      `-o' in `install'.
   1534 
   1535 `paginate'
   1536      `-l' in `diff'.
   1537 
   1538 `paragraph-indent'
   1539      Used in `makeinfo'.
   1540 
   1541 `parents'
   1542      `-p' in `mkdir' and `rmdir'.
   1543 
   1544 `pass-all'
   1545      `-p' in `ul'.
   1546 
   1547 `pass-through'
   1548      `-p' in `cpio'.
   1549 
   1550 `port'
   1551      `-P' in `finger'.
   1552 
   1553 `portability'
   1554      `-c' in `cpio' and `tar'.
   1555 
   1556 `posix'
   1557      Used in `gawk'.
   1558 
   1559 `prefix-builtins'
   1560      `-P' in `m4'.
   1561 
   1562 `prefix'
   1563      `-f' in `csplit'.
   1564 
   1565 `preserve'
   1566      Used in `tar' and `cp'.
   1567 
   1568 `preserve-environment'
   1569      `-p' in `su'.
   1570 
   1571 `preserve-modification-time'
   1572      `-m' in `cpio'.
   1573 
   1574 `preserve-order'
   1575      `-s' in `tar'.
   1576 
   1577 `preserve-permissions'
   1578      `-p' in `tar'.
   1579 
   1580 `print'
   1581      `-l' in `diff'.
   1582 
   1583 `print-chars'
   1584      `-L' in `cmp'.
   1585 
   1586 `print-data-base'
   1587      `-p' in Make.
   1588 
   1589 `print-directory'
   1590      `-w' in Make.
   1591 
   1592 `print-file-name'
   1593      `-o' in `nm'.
   1594 
   1595 `print-symdefs'
   1596      `-s' in `nm'.
   1597 
   1598 `printer'
   1599      `-p' in `wdiff'.
   1600 
   1601 `prompt'
   1602      `-p' in `ed'.
   1603 
   1604 `proxy'
   1605      Specify an HTTP proxy.
   1606 
   1607 `query-user'
   1608      `-X' in `shar'.
   1609 
   1610 `question'
   1611      `-q' in Make.
   1612 
   1613 `quiet'
   1614      Used in many programs to inhibit the usual output.  *Note_* every
   1615      program accepting `--quiet' should accept `--silent' as a synonym.
   1616 
   1617 `quiet-unshar'
   1618      `-Q' in `shar'
   1619 
   1620 `quote-name'
   1621      `-Q' in `ls'.
   1622 
   1623 `rcs'
   1624      `-n' in `diff'.
   1625 
   1626 `re-interval'
   1627      Used in `gawk'.
   1628 
   1629 `read-full-blocks'
   1630      `-B' in `tar'.
   1631 
   1632 `readnow'
   1633      Used in GDB.
   1634 
   1635 `recon'
   1636      `-n' in Make.
   1637 
   1638 `record-number'
   1639      `-R' in `tar'.
   1640 
   1641 `recursive'
   1642      Used in `chgrp', `chown', `cp', `ls', `diff', and `rm'.
   1643 
   1644 `reference-limit'
   1645      Used in `makeinfo'.
   1646 
   1647 `references'
   1648      `-r' in `ptx'.
   1649 
   1650 `regex'
   1651      `-r' in `tac' and `etags'.
   1652 
   1653 `release'
   1654      `-r' in `uname'.
   1655 
   1656 `reload-state'
   1657      `-R' in `m4'.
   1658 
   1659 `relocation'
   1660      `-r' in `objdump'.
   1661 
   1662 `rename'
   1663      `-r' in `cpio'.
   1664 
   1665 `replace'
   1666      `-i' in `xargs'.
   1667 
   1668 `report-identical-files'
   1669      `-s' in `diff'.
   1670 
   1671 `reset-access-time'
   1672      `-a' in `cpio'.
   1673 
   1674 `reverse'
   1675      `-r' in `ls' and `nm'.
   1676 
   1677 `reversed-ed'
   1678      `-f' in `diff'.
   1679 
   1680 `right-side-defs'
   1681      `-R' in `ptx'.
   1682 
   1683 `same-order'
   1684      `-s' in `tar'.
   1685 
   1686 `same-permissions'
   1687      `-p' in `tar'.
   1688 
   1689 `save'
   1690      `-g' in `stty'.
   1691 
   1692 `se'
   1693      Used in GDB.
   1694 
   1695 `sentence-regexp'
   1696      `-S' in `ptx'.
   1697 
   1698 `separate-dirs'
   1699      `-S' in `du'.
   1700 
   1701 `separator'
   1702      `-s' in `tac'.
   1703 
   1704 `sequence'
   1705      Used by `recode' to chose files or pipes for sequencing passes.
   1706 
   1707 `shell'
   1708      `-s' in `su'.
   1709 
   1710 `show-all'
   1711      `-A' in `cat'.
   1712 
   1713 `show-c-function'
   1714      `-p' in `diff'.
   1715 
   1716 `show-ends'
   1717      `-E' in `cat'.
   1718 
   1719 `show-function-line'
   1720      `-F' in `diff'.
   1721 
   1722 `show-tabs'
   1723      `-T' in `cat'.
   1724 
   1725 `silent'
   1726      Used in many programs to inhibit the usual output.  *Note_* every
   1727      program accepting `--silent' should accept `--quiet' as a synonym.
   1728 
   1729 `size'
   1730      `-s' in `ls'.
   1731 
   1732 `socket'
   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.
   1737 
   1738 `sort'
   1739      Used in `ls'.
   1740 
   1741 `source'
   1742      `-W source' in `gawk'.
   1743 
   1744 `sparse'
   1745      `-S' in `tar'.
   1746 
   1747 `speed-large-files'
   1748      `-H' in `diff'.
   1749 
   1750 `split-at'
   1751      `-E' in `unshar'.
   1752 
   1753 `split-size-limit'
   1754      `-L' in `shar'.
   1755 
   1756 `squeeze-blank'
   1757      `-s' in `cat'.
   1758 
   1759 `start-delete'
   1760      `-w' in `wdiff'.
   1761 
   1762 `start-insert'
   1763      `-y' in `wdiff'.
   1764 
   1765 `starting-file'
   1766      Used in `tar' and `diff' to specify which file within a directory
   1767      to start processing with.
   1768 
   1769 `statistics'
   1770      `-s' in `wdiff'.
   1771 
   1772 `stdin-file-list'
   1773      `-S' in `shar'.
   1774 
   1775 `stop'
   1776      `-S' in Make.
   1777 
   1778 `strict'
   1779      `-s' in `recode'.
   1780 
   1781 `strip'
   1782      `-s' in `install'.
   1783 
   1784 `strip-all'
   1785      `-s' in `strip'.
   1786 
   1787 `strip-debug'
   1788      `-S' in `strip'.
   1789 
   1790 `submitter'
   1791      `-s' in `shar'.
   1792 
   1793 `suffix'
   1794      `-S' in `cp', `ln', `mv'.
   1795 
   1796 `suffix-format'
   1797      `-b' in `csplit'.
   1798 
   1799 `sum'
   1800      `-s' in `gprof'.
   1801 
   1802 `summarize'
   1803      `-s' in `du'.
   1804 
   1805 `symbolic'
   1806      `-s' in `ln'.
   1807 
   1808 `symbols'
   1809      Used in GDB and `objdump'.
   1810 
   1811 `synclines'
   1812      `-s' in `m4'.
   1813 
   1814 `sysname'
   1815      `-s' in `uname'.
   1816 
   1817 `tabs'
   1818      `-t' in `expand' and `unexpand'.
   1819 
   1820 `tabsize'
   1821      `-T' in `ls'.
   1822 
   1823 `terminal'
   1824      `-T' in `tput' and `ul'.  `-t' in `wdiff'.
   1825 
   1826 `text'
   1827      `-a' in `diff'.
   1828 
   1829 `text-files'
   1830      `-T' in `shar'.
   1831 
   1832 `time'
   1833      Used in `ls' and `touch'.
   1834 
   1835 `timeout'
   1836      Specify how long to wait before giving up on some operation.
   1837 
   1838 `to-stdout'
   1839      `-O' in `tar'.
   1840 
   1841 `total'
   1842      `-c' in `du'.
   1843 
   1844 `touch'
   1845      `-t' in Make, `ranlib', and `recode'.
   1846 
   1847 `trace'
   1848      `-t' in `m4'.
   1849 
   1850 `traditional'
   1851      `-t' in `hello'; `-W traditional' in `gawk'; `-G' in `ed', `m4',
   1852      and `ptx'.
   1853 
   1854 `tty'
   1855      Used in GDB.
   1856 
   1857 `typedefs'
   1858      `-t' in `ctags'.
   1859 
   1860 `typedefs-and-c++'
   1861      `-T' in `ctags'.
   1862 
   1863 `typeset-mode'
   1864      `-t' in `ptx'.
   1865 
   1866 `uncompress'
   1867      `-z' in `tar'.
   1868 
   1869 `unconditional'
   1870      `-u' in `cpio'.
   1871 
   1872 `undefine'
   1873      `-U' in `m4'.
   1874 
   1875 `undefined-only'
   1876      `-u' in `nm'.
   1877 
   1878 `update'
   1879      `-u' in `cp', `ctags', `mv', `tar'.
   1880 
   1881 `usage'
   1882      Used in `gawk'; same as `--help'.
   1883 
   1884 `uuencode'
   1885      `-B' in `shar'.
   1886 
   1887 `vanilla-operation'
   1888      `-V' in `shar'.
   1889 
   1890 `verbose'
   1891      Print more information about progress.  Many programs support this.
   1892 
   1893 `verify'
   1894      `-W' in `tar'.
   1895 
   1896 `version'
   1897      Print the version number.
   1898 
   1899 `version-control'
   1900      `-V' in `cp', `ln', `mv'.
   1901 
   1902 `vgrind'
   1903      `-v' in `ctags'.
   1904 
   1905 `volume'
   1906      `-V' in `tar'.
   1907 
   1908 `what-if'
   1909      `-W' in Make.
   1910 
   1911 `whole-size-limit'
   1912      `-l' in `shar'.
   1913 
   1914 `width'
   1915      `-w' in `ls' and `ptx'.
   1916 
   1917 `word-regexp'
   1918      `-W' in `ptx'.
   1919 
   1920 `writable'
   1921      `-T' in `who'.
   1922 
   1923 `zeros'
   1924      `-z' in `gprof'.
   1925 
   1926 
   1927 File: standards.info,  Node: Memory Usage,  Next: File Usage,  Prev: Option Table,  Up: Program Behavior
   1928 
   1929 4.8 Memory Usage
   1930 ================
   1931 
   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
   1936 on them.
   1937 
   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.
   1945 
   1946    If your program creates complicated data structures, just make them
   1947 in core and give a fatal error if `malloc' returns zero.
   1948 
   1949 
   1950 File: standards.info,  Node: File Usage,  Prev: Memory Usage,  Up: Program Behavior
   1951 
   1952 4.9 File Usage
   1953 ==============
   1954 
   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
   1959 `/etc'.
   1960 
   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
   1966 directory.
   1967 
   1968 
   1969 File: standards.info,  Node: Writing C,  Next: Documentation,  Prev: Program Behavior,  Up: Top
   1970 
   1971 5 Making The Best Use of C
   1972 **************************
   1973 
   1974 This node provides advice on how best to use the C language when
   1975 writing GNU software.
   1976 
   1977 * Menu:
   1978 
   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'.
   1988 
   1989 
   1990 File: standards.info,  Node: Formatting,  Next: Comments,  Up: Writing C
   1991 
   1992 5.1 Formatting Your Source Code
   1993 ===============================
   1994 
   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.
   2000 
   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:
   2005 
   2006      static char *
   2007      concat (s1, s2)        /* Name starts in column zero here */
   2008           char *s1, *s2;
   2009      {                     /* Open brace in column zero here */
   2010        ...
   2011      }
   2012 
   2013 or, if you want to use Standard C syntax, format the definition like
   2014 this:
   2015 
   2016      static char *
   2017      concat (char *s1, char *s2)
   2018      {
   2019        ...
   2020      }
   2021 
   2022    In Standard C, if the arguments don't fit nicely on one line, split
   2023 it like this:
   2024 
   2025      int
   2026      lots_of_args (int an_integer, long a_long, short a_short,
   2027                    double a_double, float a_float)
   2028      ...
   2029 
   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
   2033 
   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
   2036 
   2037    We don't think of these recommendations as requirements, because it
   2038 causes no problems for users if two different programs have different
   2039 formatting styles.
   2040 
   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
   2044 that program.
   2045 
   2046    For the body of the function, our recommended style looks like this:
   2047 
   2048      if (x < foo (y, z))
   2049        haha = bar[4] + 5;
   2050      else
   2051        {
   2052          while (z)
   2053            {
   2054              haha += foo (z, z);
   2055              z--;
   2056            }
   2057          return ++x + bar ();
   2058        }
   2059 
   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.
   2062 
   2063    When you split an expression into multiple lines, split it before an
   2064 operator, not after one.  Here is the right way:
   2065 
   2066      if (foo_this_is_long && bar > win (x, y, z)
   2067          && remaining_condition)
   2068 
   2069    Try to avoid having two operators of different precedence at the same
   2070 level of indentation.  For example, don't write this:
   2071 
   2072      mode = (inmode[j] == VOIDmode
   2073              || GET_MODE_SIZE (outmode[j]) > GET_MODE_SIZE (inmode[j])
   2074              ? outmode[j] : inmode[j]);
   2075 
   2076    Instead, use extra parentheses so that the indentation shows the
   2077 nesting:
   2078 
   2079      mode = ((inmode[j] == VOIDmode
   2080               || (GET_MODE_SIZE (outmode[j]) > GET_MODE_SIZE (inmode[j])))
   2081              ? outmode[j] : inmode[j]);
   2082 
   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,
   2085 
   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;
   2088 
   2089 but Emacs would alter it.  Adding a set of parentheses produces
   2090 something that looks equally nice, and which Emacs will preserve:
   2091 
   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);
   2094 
   2095    Format do-while statements like this:
   2096 
   2097      do
   2098        {
   2099          a = foo (a);
   2100        }
   2101      while (a > 0);
   2102 
   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.
   2107 
   2108 
   2109 File: standards.info,  Node: Comments,  Next: Syntactic Conventions,  Prev: Formatting,  Up: Writing C
   2110 
   2111 5.2 Commenting Your Work
   2112 ========================
   2113 
   2114 Every program should start with a comment saying briefly what it is for.
   2115 Example: `fmt - filter for simple filling of text'.
   2116 
   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.
   2123 
   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
   2133 to say so.
   2134 
   2135    Also explain the significance of the return value, if there is one.
   2136 
   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 ...").
   2144 
   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".
   2150 
   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.
   2155 
   2156    There should be a comment on each static variable as well, like this:
   2157 
   2158      /* Nonzero means truncate lines in the display;
   2159         zero means continue them.  */
   2160      int truncate_lines;
   2161 
   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:
   2167 
   2168      #ifdef foo
   2169        ...
   2170      #else /* not foo */
   2171        ...
   2172      #endif /* not foo */
   2173      #ifdef foo
   2174        ...
   2175      #endif /* foo */
   2176 
   2177 but, by contrast, write the comments this way for a `#ifndef':
   2178 
   2179      #ifndef foo
   2180        ...
   2181      #else /* foo */
   2182        ...
   2183      #endif /* foo */
   2184      #ifndef foo
   2185        ...
   2186      #endif /* not foo */
   2187 
   2188 
   2189 File: standards.info,  Node: Syntactic Conventions,  Next: Names,  Prev: Comments,  Up: Writing C
   2190 
   2191 5.3 Clean Use of C Constructs
   2192 =============================
   2193 
   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'.
   2197 
   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
   2203 your master.
   2204 
   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
   2209 functions.
   2210 
   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.
   2219 
   2220    Don't use local variables or parameters that shadow global
   2221 identifiers.
   2222 
   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
   2225 this:
   2226 
   2227      int    foo,
   2228             bar;
   2229 
   2230 write either this:
   2231 
   2232      int foo, bar;
   2233 
   2234 or this:
   2235 
   2236      int foo;
   2237      int bar;
   2238 
   2239 (If they are global variables, each should have a comment preceding it
   2240 anyway.)
   2241 
   2242    When you have an `if'-`else' statement nested in another `if'
   2243 statement, always put braces around the `if'-`else'.  Thus, never write
   2244 like this:
   2245 
   2246      if (foo)
   2247        if (bar)
   2248          win ();
   2249        else
   2250          lose ();
   2251 
   2252 always like this:
   2253 
   2254      if (foo)
   2255        {
   2256          if (bar)
   2257            win ();
   2258          else
   2259            lose ();
   2260        }
   2261 
   2262    If you have an `if' statement nested inside of an `else' statement,
   2263 either write `else if' on one line, like this,
   2264 
   2265      if (foo)
   2266        ...
   2267      else if (bar)
   2268        ...
   2269 
   2270 with its `then'-part indented like the preceding `then'-part, or write
   2271 the nested `if' within braces like this:
   2272 
   2273      if (foo)
   2274        ...
   2275      else
   2276        {
   2277          if (bar)
   2278            ...
   2279        }
   2280 
   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.
   2284 
   2285    Try to avoid assignments inside `if'-conditions.  For example, don't
   2286 write this:
   2287 
   2288      if ((foo = (char *) malloc (sizeof *foo)) == 0)
   2289        fatal ("virtual memory exhausted");
   2290 
   2291 instead, write this:
   2292 
   2293      foo = (char *) malloc (sizeof *foo);
   2294      if (foo == 0)
   2295        fatal ("virtual memory exhausted");
   2296 
   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.
   2300 
   2301 
   2302 File: standards.info,  Node: Names,  Next: System Portability,  Prev: Syntactic Conventions,  Up: Writing C
   2303 
   2304 5.4 Naming Variables, Functions, and Files
   2305 ==========================================
   2306 
   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
   2311 comments.
   2312 
   2313    Local variable names can be shorter, because they are used only
   2314 within one context, where (presumably) comments explain their purpose.
   2315 
   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.
   2319 
   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.
   2324 
   2325    For example, you should use names like `ignore_space_change_flag';
   2326 don't use names like `iCantReadThis'.
   2327 
   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,
   2332 
   2333      /* Ignore changes in horizontal whitespace (-b).  */
   2334      int ignore_space_change_flag;
   2335 
   2336    When you want to define names with constant integer values, use
   2337 `enum' rather than `#define'.  GDB knows about enumeration constants.
   2338 
   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.
   2342 
   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
   2348 characters.
   2349 
   2350 
   2351 File: standards.info,  Node: System Portability,  Next: CPU Portability,  Prev: Names,  Up: Writing C
   2352 
   2353 5.5 Portability between System Types
   2354 ====================================
   2355 
   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
   2358 not paramount.
   2359 
   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.
   2365 
   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
   2371 be hard.
   2372 
   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
   2377 written.
   2378 
   2379    Avoid using the format of semi-internal data bases (e.g.,
   2380 directories) when there is a higher-level alternative (`readdir').
   2381 
   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.
   2387 
   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.)
   2395 
   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.
   2399 
   2400 
   2401 File: standards.info,  Node: CPU Portability,  Next: System Functions,  Prev: System Portability,  Up: Writing C
   2402 
   2403 5.6 Portability between CPUs
   2404 ============================
   2405 
   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
   2411 GNU.
   2412 
   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:
   2416 
   2417      printf ("size = %lu\n", (unsigned long) sizeof array);
   2418      printf ("diff = %ld\n", (long) (pointer2 - pointer1));
   2419 
   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.
   2424 
   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.
   2429 
   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:
   2433 
   2434      int c;
   2435      ...
   2436      while ((c = getchar()) != EOF)
   2437        write(file_descriptor, &c, 1);
   2438 
   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.
   2445 
   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:
   2450 
   2451      error (s, a1, a2, a3)
   2452           char *s;
   2453           char *a1, *a2, *a3;
   2454      {
   2455        fprintf (stderr, "error: ");
   2456        fprintf (stderr, s, a1, a2, a3);
   2457      }
   2458 
   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
   2462 functions.
   2463 
   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'.
   2466 
   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
   2474 from zero.
   2475 
   2476 
   2477 File: standards.info,  Node: System Functions,  Next: Internationalization,  Prev: CPU Portability,  Up: Writing C
   2478 
   2479 5.7 Calling System Functions
   2480 ============================
   2481 
   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.
   2487 
   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.
   2490 
   2491    * Be aware that `vfprintf' is not always available.
   2492 
   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.
   2496 
   2497    * Don't declare system functions explicitly.
   2498 
   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.
   2503 
   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.
   2509 
   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
   2513      conflict.
   2514 
   2515    * In particular, don't unconditionally declare `malloc' or `realloc'.
   2516 
   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.
   2520 
   2521      Because `xmalloc' and `xrealloc' are defined in your program, you
   2522      can declare them in other files without any risk of type conflict.
   2523 
   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
   2529      systems.
   2530 
   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
   2535      either file.
   2536 
   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
   2539      usual way.
   2540 
   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
   2544      use are these:
   2545 
   2546           strcpy   strncpy   strcat   strncat
   2547           strlen   strcmp    strncmp
   2548           strchr   strrchr
   2549 
   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.
   2555 
   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
   2559      systems.
   2560 
   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.
   2567 
   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:
   2576 
   2577           #ifndef HAVE_STRCHR
   2578           #define strchr index
   2579           #endif
   2580           #ifndef HAVE_STRRCHR
   2581           #define strrchr rindex
   2582           #endif
   2583 
   2584           char *strchr ();
   2585           char *strrchr ();
   2586 
   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.
   2590 
   2591 
   2592 File: standards.info,  Node: Internationalization,  Next: Mmap,  Prev: System Functions,  Up: Writing C
   2593 
   2594 5.8 Internationalization
   2595 ========================
   2596 
   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
   2601 other languages.
   2602 
   2603    Using GNU gettext involves putting a call to the `gettext' macro
   2604 around each string that might need translation--like this:
   2605 
   2606      printf (gettext ("Processing file `%s'..."));
   2607 
   2608 This permits GNU gettext to replace the string `"Processing file
   2609 `%s'..."' with a translated version.
   2610 
   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.
   2613 
   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.
   2619 
   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
   2625 sentence framework.
   2626 
   2627    Here is an example of what not to do:
   2628 
   2629      printf ("%d file%s processed", nfiles,
   2630              nfiles != 1 ? "s" : "");
   2631 
   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,
   2634 
   2635      printf (gettext ("%d file%s processed"), nfiles,
   2636              nfiles != 1 ? "s" : "");
   2637 
   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:
   2640 
   2641      printf ((nfiles != 1 ? "%d files processed"
   2642               : "%d file processed"),
   2643              nfiles);
   2644 
   2645 This way, you can apply gettext to each of the two strings
   2646 independently:
   2647 
   2648      printf ((nfiles != 1 ? gettext ("%d files processed")
   2649               : gettext ("%d file processed")),
   2650              nfiles);
   2651 
   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
   2654 "processed".
   2655 
   2656    A similar problem appears at the level of sentence structure with
   2657 this code:
   2658 
   2659      printf ("#  Implicit rule search has%s been done.\n",
   2660              f->tried_implicit ? "" : " not");
   2661 
   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:
   2666 
   2667      printf (f->tried_implicit
   2668              ? "#  Implicit rule search has been done.\n",
   2669              : "#  Implicit rule search has not been done.\n");
   2670 
   2671 
   2672 File: standards.info,  Node: Mmap,  Prev: Internationalization,  Up: Writing C
   2673 
   2674 5.9 Mmap
   2675 ========
   2676 
   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.
   2679 
   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'.
   2683 
   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
   2688 of files.
   2689 
   2690 
   2691 File: standards.info,  Node: Documentation,  Next: Managing Releases,  Prev: Writing C,  Up: Top
   2692 
   2693 6 Documenting Programs
   2694 **********************
   2695 
   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.
   2700 
   2701 * Menu:
   2702 
   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
   2713                                 from other manuals.
   2714 
   2715 
   2716 File: standards.info,  Node: GNU Manuals,  Next: Doc Strings and Manuals,  Up: Documentation
   2717 
   2718 6.1 GNU Manuals
   2719 ===============
   2720 
   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').
   2729 
   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.
   2733 
   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.
   2738 
   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
   2747 alternatives.
   2748 
   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
   2753 understand.
   2754 
   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.
   2760 
   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
   2766 program does.
   2767 
   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
   2774 what we mean.
   2775 
   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._
   2782 
   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.
   2787 
   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.
   2795 
   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.
   2801 
   2802    Please include an email address in the manual for where to report
   2803 bugs _in the manual_.
   2804 
   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.
   2808 
   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.
   2812 
   2813 
   2814 File: standards.info,  Node: Doc Strings and Manuals,  Next: Manual Structure Details,  Prev: GNU Manuals,  Up: Documentation
   2815 
   2816 6.2 Doc Strings and Manuals
   2817 ===========================
   2818 
   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.
   2825 
   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.
   2829 
   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.
   2839 
   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.
   2842 
   2843 
   2844 File: standards.info,  Node: Manual Structure Details,  Next: License for Manuals,  Prev: Doc Strings and Manuals,  Up: Documentation
   2845 
   2846 6.3 Manual Structure Details
   2847 ============================
   2848 
   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.
   2854 
   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.
   2861 
   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.
   2865 
   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.
   2869 
   2870    If one manual describes several programs, it should have such a node
   2871 for each program described in the manual.
   2872 
   2873 
   2874 File: standards.info,  Node: License for Manuals,  Next: Manual Credits,  Prev: Manual Structure Details,  Up: Documentation
   2875 
   2876 6.4 License for Manuals
   2877 =======================
   2878 
   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.
   2884 
   2885    See `http://www.gnu.org/copyleft/fdl-howto.html' for more explanation
   2886 of how to employ the GFDL.
   2887 
   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
   2893 it.
   2894 
   2895 
   2896 File: standards.info,  Node: Manual Credits,  Next: Printed Manuals,  Prev: License for Manuals,  Up: Documentation
   2897 
   2898 6.5 Manual Credits
   2899 ==================
   2900 
   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.
   2905 
   2906 
   2907 File: standards.info,  Node: Printed Manuals,  Next: NEWS File,  Prev: Manual Credits,  Up: Documentation
   2908 
   2909 6.6 Printed Manuals
   2910 ===================
   2911 
   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.
   2918 
   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.
   2921 
   2922 
   2923 File: standards.info,  Node: NEWS File,  Next: Change Logs,  Prev: Printed Manuals,  Up: Documentation
   2924 
   2925 6.7 The NEWS File
   2926 =================
   2927 
   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.
   2934 
   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
   2937 that file.
   2938 
   2939 
   2940 File: standards.info,  Node: Change Logs,  Next: Man Pages,  Prev: NEWS File,  Up: Documentation
   2941 
   2942 6.8 Change Logs
   2943 ===============
   2944 
   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.
   2952 
   2953 * Menu:
   2954 
   2955 * Change Log Concepts::
   2956 * Style of Change Logs::
   2957 * Simple Changes::
   2958 * Conditional Changes::
   2959 * Indicating the Part Changed::
   2960 
   2961 
   2962 File: standards.info,  Node: Change Log Concepts,  Next: Style of Change Logs,  Up: Change Logs
   2963 
   2964 6.8.1 Change Log Concepts
   2965 -------------------------
   2966 
   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.
   2972 
   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.
   2976 
   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.
   2981 
   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.
   2989 
   2990    However, sometimes it is useful to write one line to describe the
   2991 overall purpose of a batch of changes.
   2992 
   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.
   2998 
   2999 
   3000 File: standards.info,  Node: Style of Change Logs,  Next: Simple Changes,  Prev: Change Log Concepts,  Up: Change Logs
   3001 
   3002 6.8.2 Style of Change Logs
   3003 --------------------------
   3004 
   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
   3008 and GCC.)
   3009 
   3010      1998-08-17  Richard Stallman  <rms (a] gnu.org>
   3011 
   3012      * register.el (insert-register): Return nil.
   3013      (jump-to-register): Likewise.
   3014 
   3015      * sort.el (sort-subr): Return nil.
   3016 
   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.
   3020 
   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.
   3024 
   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.
   3030 
   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.
   3035 
   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.
   3040 
   3041    Break long lists of function names by closing continued lines with
   3042 `)', rather than `,', and opening the continuation with `(' as in this
   3043 example:
   3044 
   3045      * keyboard.c (menu_bar_items, tool_bar_items)
   3046      (Fexecute_extended_command): Deal with `keymap' property.
   3047 
   3048 
   3049 File: standards.info,  Node: Simple Changes,  Next: Conditional Changes,  Prev: Style of Change Logs,  Up: Change Logs
   3050 
   3051 6.8.3 Simple Changes
   3052 --------------------
   3053 
   3054 Certain simple kinds of changes don't need much detail in the change
   3055 log.
   3056 
   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:
   3062 
   3063      * keyboard.c (Fcommand_execute): New arg SPECIAL.
   3064      All callers changed.
   3065 
   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.
   3069 
   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.
   3076 
   3077 
   3078 File: standards.info,  Node: Conditional Changes,  Next: Indicating the Part Changed,  Prev: Simple Changes,  Up: Change Logs
   3079 
   3080 6.8.4 Conditional Changes
   3081 -------------------------
   3082 
   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.
   3087 
   3088    Our convention for indicating conditional changes is to use square
   3089 brackets around the name of the condition.
   3090 
   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:
   3093 
   3094      * xterm.c [SOLARIS2]: Include string.h.
   3095 
   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:
   3099 
   3100      * frame.h [HAVE_X_WINDOWS] (FRAME_WINDOW_P): Macro defined.
   3101 
   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:
   3105 
   3106      * dispnew.c (init_display) [HAVE_LIBNCURSES]: If X, call tgetent.
   3107 
   3108    Here is an entry for a change that takes affect only when a certain
   3109 macro is _not_ defined:
   3110 
   3111      (gethostname) [!HAVE_SOCKETS]: Replace with winsock version.
   3112 
   3113 
   3114 File: standards.info,  Node: Indicating the Part Changed,  Prev: Conditional Changes,  Up: Change Logs
   3115 
   3116 6.8.5 Indicating the Part Changed
   3117 ---------------------------------
   3118 
   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
   3122 with `sh' commands:
   3123 
   3124      * progmodes/sh-script.el (sh-while-getopts) <sh>: Handle case that
   3125      user-specified option string is empty.
   3126 
   3127 
   3128 File: standards.info,  Node: Man Pages,  Next: Reading other Manuals,  Prev: Change Logs,  Up: Documentation
   3129 
   3130 6.9 Man Pages
   3131 =============
   3132 
   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.
   3136 
   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.
   3140 
   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,
   3143 if you have one.
   3144 
   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.
   3153 
   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
   3159 documentation.
   3160 
   3161 
   3162 File: standards.info,  Node: Reading other Manuals,  Prev: Man Pages,  Up: Documentation
   3163 
   3164 6.10 Reading other Manuals
   3165 ==========================
   3166 
   3167 There may be non-free books or documentation files that describe the
   3168 program you are documenting.
   3169 
   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.
   3178 
   3179 
   3180 File: standards.info,  Node: Managing Releases,  Next: References,  Prev: Documentation,  Up: Top
   3181 
   3182 7 The Release Process
   3183 *********************
   3184 
   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
   3191 GNU software.
   3192 
   3193 * Menu:
   3194 
   3195 * Configuration::               How Configuration Should Work
   3196 * Makefile Conventions::        Makefile Conventions
   3197 * Releases::                    Making Releases
   3198 
   3199 
   3200 File: standards.info,  Node: Configuration,  Next: Makefile Conventions,  Up: Managing Releases
   3201 
   3202 7.1 How Configuration Should Work
   3203 =================================
   3204 
   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.
   3208 
   3209    The `configure' script must record the configuration options so that
   3210 they affect compilation.
   3211 
   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.
   3217 
   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.
   3223 
   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'.
   3228 
   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.
   3233 
   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.
   3238 
   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
   3243 not modified.
   3244 
   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.
   3250 
   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.
   3256 
   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
   3259 like this:
   3260 
   3261      CPU-COMPANY-SYSTEM
   3262 
   3263    For example, a Sun 3 might be `m68k-sun-sunos4.1'.
   3264 
   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
   3270 distinguish them.
   3271 
   3272    There is a shell script called `config.sub' that you can use as a
   3273 subroutine to validate system types and canonicalize aliases.
   3274 
   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:
   3278 
   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.
   3284 
   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
   3289      or exclude it.
   3290 
   3291 `--with-PACKAGE'
   3292      The package PACKAGE will be installed, so configure this package
   3293      to work with PACKAGE.
   3294 
   3295      Possible values of PACKAGE include `gnu-as' (or `gas'), `gnu-ld',
   3296      `gnu-libc', `gdb', `x', and `x-toolkit'.
   3297 
   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'
   3300      options are for.
   3301 
   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.
   3307 
   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.
   3313 
   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.
   3317 
   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.
   3321 
   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:
   3326 
   3327      ./configure HOSTTYPE --target=TARGETTYPE
   3328 
   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.
   3332 
   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.
   3341 
   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.
   3345 
   3346 
   3347 File: standards.info,  Node: Makefile Conventions,  Next: Releases,  Prev: Configuration,  Up: Managing Releases
   3348 
   3349 7.2 Makefile Conventions
   3350 ========================
   3351 
   3352 This node describes conventions for writing the Makefiles for GNU
   3353 programs.  Using Automake will help you write a Makefile that follows
   3354 these conventions.
   3355 
   3356 * Menu:
   3357 
   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.
   3365 
   3366 
   3367 File: standards.info,  Node: Makefile Basics,  Next: Utilities in Makefiles,  Up: Makefile Conventions
   3368 
   3369 7.2.1 General Conventions for Makefiles
   3370 ---------------------------------------
   3371 
   3372 Every Makefile should contain this line:
   3373 
   3374      SHELL = /bin/sh
   3375 
   3376 to avoid trouble on systems where the `SHELL' variable might be
   3377 inherited from the environment.  (This is never a problem with GNU
   3378 `make'.)
   3379 
   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:
   3384 
   3385      .SUFFIXES:
   3386      .SUFFIXES: .c .o
   3387 
   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.
   3390 
   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
   3396 path is used.
   3397 
   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:
   3402 
   3403      foo.1 : foo.man sedscript
   3404              sed -e sedscript foo.man > foo.1
   3405 
   3406 will fail when the build directory is not the source directory, because
   3407 `foo.man' and `sedscript' are in the source directory.
   3408 
   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
   3414 
   3415      foo.o : bar.c
   3416              $(CC) -I. -I$(srcdir) $(CFLAGS) -c bar.c -o foo.o
   3417 
   3418 should instead be written as
   3419 
   3420      foo.o : bar.c
   3421              $(CC) -I. -I$(srcdir) $(CFLAGS) -c $< -o $@
   3422 
   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'
   3426 is best written as:
   3427 
   3428      foo.1 : foo.man sedscript
   3429              sed -e $(srcdir)/sedscript $(srcdir)/foo.man > $@
   3430 
   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.
   3437 
   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
   3441 in any way.
   3442 
   3443    Try to make the build and installation targets, at least (and all
   3444 their subtargets) work correctly with a parallel `make'.
   3445 
   3446 
   3447 File: standards.info,  Node: Utilities in Makefiles,  Next: Command Variables,  Prev: Makefile Basics,  Up: Makefile Conventions
   3448 
   3449 7.2.2 Utilities in Makefiles
   3450 ----------------------------
   3451 
   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'.
   3455 
   3456    The `configure' script and the Makefile rules for building and
   3457 installation should not use any utilities directly except these:
   3458 
   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
   3461 
   3462    The compression program `gzip' can be used in the `dist' rule.
   3463 
   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.
   3467 
   3468    It is a good idea to avoid creating symbolic links in makefiles,
   3469 since a few systems don't support them.
   3470 
   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
   3474 programs we mean:
   3475 
   3476      ar bison cc flex install ld ldconfig lex
   3477      make makeinfo ranlib texi2dvi yacc
   3478 
   3479    Use the following `make' variables to run those programs:
   3480 
   3481      $(AR) $(BISON) $(CC) $(FLEX) $(INSTALL) $(LD) $(LDCONFIG) $(LEX)
   3482      $(MAKE) $(MAKEINFO) $(RANLIB) $(TEXI2DVI) $(YACC)
   3483 
   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.)
   3489 
   3490    If you use symbolic links, you should implement a fallback for
   3491 systems that don't have symbolic links.
   3492 
   3493    Additional utilities that can be used via Make variables are:
   3494 
   3495      chgrp chmod chown mknod
   3496 
   3497    It is ok to use other utilities in Makefile portions (or scripts)
   3498 intended only for particular systems where you know those utilities
   3499 exist.
   3500 
   3501 
   3502 File: standards.info,  Node: Command Variables,  Next: Directory Variables,  Prev: Utilities in Makefiles,  Up: Makefile Conventions
   3503 
   3504 7.2.3 Variables for Specifying Commands
   3505 ---------------------------------------
   3506 
   3507 Makefiles should provide variables for overriding certain commands,
   3508 options, and so on.
   3509 
   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.
   3514 
   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.
   3518 
   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
   3527 of `ld'.
   3528 
   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:
   3535 
   3536      CFLAGS = -g
   3537      ALL_CFLAGS = -I. $(CFLAGS)
   3538      .c.o:
   3539              $(CC) -c $(CPPFLAGS) $(ALL_CFLAGS) $<
   3540 
   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.
   3546 
   3547    Put `CFLAGS' last in the compilation command, after other variables
   3548 containing compiler options, so the user can use `CFLAGS' to override
   3549 the others.
   3550 
   3551    `CFLAGS' should be used in every invocation of the C compiler, both
   3552 those which do compilation and those which do linking.
   3553 
   3554    Every Makefile should define the variable `INSTALL', which is the
   3555 basic command for installing a file into the system.
   3556 
   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:
   3563 
   3564      $(INSTALL_PROGRAM) foo $(bindir)/foo
   3565      $(INSTALL_DATA) libfoo.a $(libdir)/libfoo.a
   3566 
   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
   3572 become:
   3573 
   3574      $(INSTALL_PROGRAM) foo $(DESTDIR)$(bindir)/foo
   3575      $(INSTALL_DATA) libfoo.a $(DESTDIR)$(libdir)/libfoo.a
   3576 
   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
   3579 installed.
   3580 
   3581 
   3582 File: standards.info,  Node: Directory Variables,  Next: Standard Targets,  Prev: Command Variables,  Up: Makefile Conventions
   3583 
   3584 7.2.4 Variables for Installation Directories
   3585 --------------------------------------------
   3586 
   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.
   3592 
   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.
   3596 
   3597 `prefix'
   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@'.)
   3603 
   3604      Running `make install' with a different value of `prefix' from the
   3605      one used to build the program should _not_ recompile the program.
   3606 
   3607 `exec_prefix'
   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
   3611      `@exec_prefix@'.)
   3612 
   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
   3616      directories.
   3617 
   3618      Running `make install' with a different value of `exec_prefix'
   3619      from the one used to build the program should _not_ recompile the
   3620      program.
   3621 
   3622    Executable programs are installed in one of the following
   3623 directories.
   3624 
   3625 `bindir'
   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
   3629      `@bindir@'.)
   3630 
   3631 `sbindir'
   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@'.)
   3637 
   3638 `libexecdir'
   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@'.)
   3643 
   3644    Data files used by the program during its execution are divided into
   3645 categories in two ways.
   3646 
   3647    * Some files are normally modified by programs; others are never
   3648      normally modified (though users may edit some of these).
   3649 
   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.
   3654 
   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.
   3659 
   3660    Therefore, here are the variables Makefiles should use to specify
   3661 directories:
   3662 
   3663 `datadir'
   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.
   3669 
   3670 `sysconfdir'
   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@'.)
   3678 
   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)'.
   3684 
   3685 `sharedstatedir'
   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@'.)
   3690 
   3691 `localstatedir'
   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
   3699      `@localstatedir@'.)
   3700 
   3701 `libdir'
   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@'.)
   3707 
   3708 `infodir'
   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
   3712      `@infodir@'.)
   3713 
   3714 `lispdir'
   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'.
   3718 
   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:
   3722 
   3723           lispdir='${datadir}/emacs/site-lisp'
   3724           AC_SUBST(lispdir)
   3725 
   3726 `includedir'
   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
   3731      `@includedir@'.)
   3732 
   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'.
   3740 
   3741 `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@'.)
   3745 
   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.
   3749 
   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
   3755      Foo package.
   3756 
   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.
   3759 
   3760    Unix-style man pages are installed in one of the following:
   3761 
   3762 `mandir'
   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
   3766      as `@mandir@'.)
   3767 
   3768 `man1dir'
   3769      The directory for installing section 1 man pages.  Write it as
   3770      `$(mandir)/man1'.
   3771 
   3772 `man2dir'
   3773      The directory for installing section 2 man pages.  Write it as
   3774      `$(mandir)/man2'
   3775 
   3776 `...'
   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.*
   3781 
   3782 `manext'
   3783      The file name extension for the installed man page.  This should
   3784      contain a period followed by the appropriate digit; it should
   3785      normally be `.1'.
   3786 
   3787 `man1ext'
   3788      The file name extension for installed section 1 man pages.
   3789 
   3790 `man2ext'
   3791      The file name extension for installed section 2 man pages.
   3792 
   3793 `...'
   3794      Use these names instead of `manext' if the package needs to
   3795      install man pages in more than one section of the manual.
   3796 
   3797    And finally, you should set the following variable:
   3798 
   3799 `srcdir'
   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@'.)
   3803 
   3804    For example:
   3805 
   3806      # Common prefix for installation directories.
   3807      # NOTE: This directory must exist when you start the install.
   3808      prefix = /usr/local
   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
   3816 
   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.
   3821 
   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.
   3828 
   3829 
   3830 File: standards.info,  Node: Standard Targets,  Next: Install Command Categories,  Prev: Directory Variables,  Up: Makefile Conventions
   3831 
   3832 7.2.5 Standard Targets for Users
   3833 --------------------------------
   3834 
   3835 All GNU programs should have the following targets in their Makefiles:
   3836 
   3837 `all'
   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.
   3842 
   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.
   3846 
   3847 `install'
   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.
   3852 
   3853      Do not strip executables when installing them.  Devil-may-care
   3854      users can use the `install-strip' target to do that.
   3855 
   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
   3860      another.
   3861 
   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
   3867      below.
   3868 
   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.
   3872 
   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:
   3879 
   3880           $(DESTDIR)$(infodir)/foo.info: foo.info
   3881                   $(POST_INSTALL)
   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; \
   3895                   else true; fi
   3896 
   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
   3900      Categories::.
   3901 
   3902 `uninstall'
   3903      Delete all the installed files--the copies that the `install'
   3904      target creates.
   3905 
   3906      This rule should not modify the directories where compilation is
   3907      done, only the directories where files are installed.
   3908 
   3909      The uninstallation commands are divided into three categories,
   3910      just like the installation commands.  *Note Install Command
   3911      Categories::.
   3912 
   3913 `install-strip'
   3914      Like `install', but strip the executable files while installing
   3915      them.  In simple cases, this target can use the `install' target in
   3916      a simple way:
   3917 
   3918           install-strip:
   3919                   $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \
   3920                           install
   3921 
   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.
   3925 
   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.
   3929 
   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.
   3934 
   3935 `clean'
   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
   3940      with them.
   3941 
   3942      Delete `.dvi' files here if they are not part of the distribution.
   3943 
   3944 `distclean'
   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
   3949      distribution.
   3950 
   3951 `mostlyclean'
   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.
   3956 
   3957 `maintainer-clean'
   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.
   3962 
   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.
   3970 
   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.
   3978 
   3979      To help make users aware of this, the commands for the special
   3980      `maintainer-clean' target should start with these two:
   3981 
   3982           @echo 'This command is intended for maintainers to use; it'
   3983           @echo 'deletes files that may need special tools to rebuild.'
   3984 
   3985 `TAGS'
   3986      Update a tags table for this program.
   3987 
   3988 `info'
   3989      Generate any Info files needed.  The best way to write the rules
   3990      is as follows:
   3991 
   3992           info: foo.info
   3993 
   3994           foo.info: foo.texi chap1.texi chap2.texi
   3995                   $(MAKEINFO) $(srcdir)/foo.texi
   3996 
   3997      You must define the variable `MAKEINFO' in the Makefile.  It should
   3998      run the `makeinfo' program, which is part of the Texinfo
   3999      distribution.
   4000 
   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.
   4006 
   4007 `dvi'
   4008      Generate DVI files for all Texinfo documentation.  For example:
   4009 
   4010           dvi: foo.dvi
   4011 
   4012           foo.dvi: foo.texi chap1.texi chap2.texi
   4013                   $(TEXI2DVI) $(srcdir)/foo.texi
   4014 
   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.
   4019 
   4020 `dist'
   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.
   4025 
   4026      For example, the distribution tar file of GCC version 1.40 unpacks
   4027      into a subdirectory named `gcc-1.40'.
   4028 
   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.
   4032 
   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'.
   4035 
   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.
   4039 
   4040 `check'
   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.
   4045 
   4046    The following targets are suggested as conventional names, for
   4047 programs in which they are useful.
   4048 
   4049 `installcheck'
   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.
   4053 
   4054 `installdirs'
   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:
   4060 
   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) \
   4066                                           $(mandir)
   4067 
   4068      or, if you wish to support `DESTDIR',
   4069 
   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) \
   4076                       $(DESTDIR)$(mandir)
   4077 
   4078      This rule should not modify the directories where compilation is
   4079      done.  It should do nothing but create installation directories.
   4080 
   4081    ---------- Footnotes ----------
   4082 
   4083    (1) `texi2dvi' uses TeX to do the real work of formatting. TeX is
   4084 not distributed with Texinfo.
   4085 
   4086 
   4087 File: standards.info,  Node: Install Command Categories,  Prev: Standard Targets,  Up: Makefile Conventions
   4088 
   4089 7.2.6 Install Command Categories
   4090 --------------------------------
   4091 
   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.
   4095 
   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.
   4099 
   4100    Pre-installation and post-installation commands may alter other
   4101 files; in particular, they can edit global configuration files or data
   4102 bases.
   4103 
   4104    Pre-installation commands are typically executed before the normal
   4105 commands, and post-installation commands are typically run after the
   4106 normal commands.
   4107 
   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.
   4114 
   4115    Most programs don't need any pre-installation commands, but we have
   4116 the feature just in case it is needed.
   4117 
   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.
   4121 
   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).
   4128 
   4129    Here are the three possible category lines, each with a comment that
   4130 explains what it means:
   4131 
   4132              $(PRE_INSTALL)     # Pre-install commands follow.
   4133              $(POST_INSTALL)    # Post-install commands follow.
   4134              $(NORMAL_INSTALL)  # Normal commands follow.
   4135 
   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.
   4140 
   4141    These are the category lines for `uninstall':
   4142 
   4143              $(PRE_UNINSTALL)     # Pre-uninstall commands follow.
   4144              $(POST_UNINSTALL)    # Post-uninstall commands follow.
   4145              $(NORMAL_UNINSTALL)  # Normal commands follow.
   4146 
   4147    Typically, a pre-uninstall command would be used for deleting entries
   4148 from the Info directory.
   4149 
   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.
   4156 
   4157    Pre-installation and post-installation commands should not run any
   4158 programs except for these:
   4159 
   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
   4165 
   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.
   4172 
   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:
   4176 
   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
   4182 
   4183 where the file `pre-install.awk' could contain this:
   4184 
   4185      $0 ~ /^\t[ \t]*(normal_install|post_install)[ \t]*$/ {on = 0}
   4186      on {print $0}
   4187      $0 ~ /^\t[ \t]*pre_install[ \t]*$/ {on = 1}
   4188 
   4189    The resulting file of pre-installation commands is executed as a
   4190 shell script as part of installing the binary package.
   4191 
   4192 
   4193 File: standards.info,  Node: Releases,  Prev: Makefile Conventions,  Up: Managing Releases
   4194 
   4195 7.3 Making Releases
   4196 ===================
   4197 
   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'.
   4201 
   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.
   4208 
   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.
   4215 
   4216    The `README' file should refer to the file `INSTALL', which should
   4217 contain an explanation of the installation procedure.
   4218 
   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
   4222 `COPYING.LIB'.
   4223 
   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.
   4231 
   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.
   4236 
   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.
   4242 
   4243    Make sure that all the files in the distribution are world-readable.
   4244 
   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.
   4251 
   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.
   4257 
   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.
   4264 
   4265    Include in your distribution a copy of the `texinfo.tex' you used to
   4266 test print any `*.texinfo' or `*.texi' files.
   4267 
   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.
   4273 
   4274 
   4275 File: standards.info,  Node: References,  Next: Copying This Manual,  Prev: Managing Releases,  Up: Top
   4276 
   4277 8 References to Non-Free Software and Documentation
   4278 ***************************************************
   4279 
   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
   4285 problem.
   4286 
   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.
   4292 
   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.
   4302 
   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.)
   4308 
   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.
   4316 
   4317 
   4318 File: standards.info,  Node: Copying This Manual,  Next: Index,  Prev: References,  Up: Top
   4319 
   4320 Appendix A Copying This Manual
   4321 ******************************
   4322 
   4323 * Menu:
   4324 
   4325 * GNU Free Documentation License::  License for copying this manual
   4326 
   4327 
   4328 File: standards.info,  Node: GNU Free Documentation License,  Up: Copying This Manual
   4329 
   4330 Appendix B GNU Free Documentation License
   4331 *****************************************
   4332 
   4333                         Version 1.1, March 2000
   4334 
   4335      Copyright (C) 2000  Free Software Foundation, Inc.
   4336      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
   4337 
   4338      Everyone is permitted to copy and distribute verbatim copies
   4339      of this license document, but changing it is not allowed.
   4340 
   4341 
   4342   0. PREAMBLE
   4343 
   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.
   4351 
   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.
   4356 
   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.
   4365 
   4366 
   4367   1. APPLICABILITY AND DEFINITIONS
   4368 
   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."
   4374 
   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.
   4378 
   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.
   4389 
   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
   4393      License.
   4394 
   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.
   4398 
   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."
   4410 
   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.
   4420 
   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.
   4427 
   4428   2. VERBATIM COPYING
   4429 
   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.
   4440 
   4441      You may also lend copies, under the same conditions stated above,
   4442      and you may publicly display copies.
   4443 
   4444   3. COPYING IN QUANTITY
   4445 
   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
   4457      other respects.
   4458 
   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
   4462      adjacent pages.
   4463 
   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.
   4478 
   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.
   4483 
   4484   4. MODIFICATIONS
   4485 
   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:
   4493 
   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
   4499      gives permission.
   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
   4513      Addendum below.
   4514      G. Preserve in that license notice the full lists of Invariant
   4515      Sections    and required Cover Texts given in the Document's
   4516      license notice.
   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
   4525      sentence.
   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.
   4545 
   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.
   4553 
   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
   4558      of a standard.
   4559 
   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.
   4570 
   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.
   4574 
   4575   5. COMBINING DOCUMENTS
   4576 
   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.
   4583 
   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
   4592      combined work.
   4593 
   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."
   4599 
   4600   6. COLLECTIONS OF DOCUMENTS
   4601 
   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.
   4608 
   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
   4613      that document.
   4614 
   4615   7. AGGREGATION WITH INDEPENDENT WORKS
   4616 
   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.
   4626 
   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
   4632      aggregate.
   4633 
   4634   8. TRANSLATION
   4635 
   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.
   4646 
   4647   9. TERMINATION
   4648 
   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.
   4656 
   4657  10. FUTURE REVISIONS OF THIS LICENSE
   4658 
   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/.
   4664 
   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.
   4674 
   4675 
   4676 ADDENDUM: How to use this License for your documents
   4677 ====================================================
   4678 
   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:
   4682 
   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."
   4691 
   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.
   4696 
   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.
   4701 
   4702 
   4703 File: standards.info,  Node: Index,  Prev: Copying This Manual,  Up: Top
   4704 
   4705 Index
   4706 *****
   4707 
   4708 [index]
   4709 * Menu:
   4710 
   4711 * #endif, commenting:                    Comments.            (line  54)
   4712 * --help option:                         Command-Line Interfaces.
   4713                                                               (line 119)
   4714 * --version option:                      Command-Line Interfaces.
   4715                                                               (line  34)
   4716 * -Wall compiler option:                 Syntactic Conventions.
   4717                                                               (line  10)
   4718 * accepting contributions:               Contributions.       (line   6)
   4719 * address for bug reports:               Command-Line Interfaces.
   4720                                                               (line 125)
   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.
   4725                                                               (line   6)
   4726 * behavior, dependent on program's name: User Interfaces.     (line   6)
   4727 * binary packages:                       Install Command Categories.
   4728                                                               (line  80)
   4729 * bindir:                                Directory Variables. (line  45)
   4730 * braces, in C source:                   Formatting.          (line   6)
   4731 * bug reports:                           Command-Line Interfaces.
   4732                                                               (line 125)
   4733 * canonical name of a program:           Command-Line Interfaces.
   4734                                                               (line  41)
   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.
   4739                                                               (line   6)
   4740 * command-line arguments, decoding:      Semantics.           (line  46)
   4741 * command-line interface:                Command-Line Interfaces.
   4742                                                               (line   6)
   4743 * commenting:                            Comments.            (line   6)
   4744 * compatibility with C and POSIX standards: Compatibility.    (line   6)
   4745 * compiler warnings:                     Syntactic Conventions.
   4746                                                               (line  10)
   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.
   4752                                                               (line   6)
   4753 * corba:                                 Graphical Interfaces.
   4754                                                               (line  16)
   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.
   4771                                                               (line   6)
   4772 * function prototypes:                   Standard C.          (line  17)
   4773 * getopt:                                Command-Line Interfaces.
   4774                                                               (line   6)
   4775 * gettext:                               Internationalization.
   4776                                                               (line   6)
   4777 * gnome:                                 Graphical Interfaces.
   4778                                                               (line  16)
   4779 * graphical user interface:              Graphical Interfaces.
   4780                                                               (line   6)
   4781 * gtk:                                   Graphical Interfaces.
   4782                                                               (line   6)
   4783 * GUILE:                                 Source Language.     (line  38)
   4784 * implicit int:                          Syntactic Conventions.
   4785                                                               (line   6)
   4786 * impossible conditions:                 Semantics.           (line  70)
   4787 * internationalization:                  Internationalization.
   4788                                                               (line   6)
   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.
   4796                                                               (line 109)
   4797 * long option names:                     Option Table.        (line   6)
   4798 * long-named options:                    Command-Line Interfaces.
   4799                                                               (line  12)
   4800 * makefile, conventions for:             Makefile Conventions.
   4801                                                               (line   6)
   4802 * malloc return value:                   Semantics.           (line  25)
   4803 * man pages:                             Man Pages.           (line   6)
   4804 * manual structure:                      Manual Structure Details.
   4805                                                               (line   6)
   4806 * memory allocation failure:             Semantics.           (line  25)
   4807 * memory usage:                          Memory Usage.        (line   6)
   4808 * message text, and internationalization: Internationalization.
   4809                                                               (line  29)
   4810 * mmap:                                  Mmap.                (line   6)
   4811 * multiple variables in a line:          Syntactic Conventions.
   4812                                                               (line  35)
   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.
   4829                                                               (line   6)
   4830 * pre-installation commands:             Install Command Categories.
   4831                                                               (line   6)
   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.
   4837                                                               (line  41)
   4838 * programming languges:                  Source Language.     (line   6)
   4839 * proprietary programs:                  Reading Non-Free Code.
   4840                                                               (line   6)
   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.
   4848                                                               (line  31)
   4849 * standards for makefiles:               Makefile Conventions.
   4850                                                               (line   6)
   4851 * string library functions:              System Functions.    (line  55)
   4852 * syntactic conventions:                 Syntactic Conventions.
   4853                                                               (line   6)
   4854 * table of long options:                 Option Table.        (line   6)
   4855 * temporary files:                       Semantics.           (line  84)
   4856 * temporary variables:                   Syntactic Conventions.
   4857                                                               (line  23)
   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)
   4862 
   4863 
   4864 
   4865 Tag Table:
   4866 Node: Top696
   4867 Node: Preface1396
   4868 Node: Legal Issues3616
   4869 Node: Reading Non-Free Code4080
   4870 Node: Contributions5808
   4871 Node: Trademarks7962
   4872 Node: Design Advice9025
   4873 Node: Source Language9609
   4874 Node: Compatibility11621
   4875 Node: Using Extensions13249
   4876 Node: Standard C14825
   4877 Node: Conditional Compilation17228
   4878 Node: Program Behavior18527
   4879 Node: Semantics19446
   4880 Node: Libraries24139
   4881 Node: Errors25384
   4882 Node: User Interfaces27165
   4883 Node: Graphical Interfaces28770
   4884 Node: Command-Line Interfaces29805
   4885 Node: Option Table35876
   4886 Node: Memory Usage50885
   4887 Node: File Usage51910
   4888 Node: Writing C52658
   4889 Node: Formatting53508
   4890 Node: Comments57571
   4891 Node: Syntactic Conventions60873
   4892 Node: Names64285
   4893 Node: System Portability66494
   4894 Node: CPU Portability68879
   4895 Node: System Functions72135
   4896 Node: Internationalization77332
   4897 Node: Mmap80485
   4898 Node: Documentation81195
   4899 Node: GNU Manuals82300
   4900 Node: Doc Strings and Manuals87357
   4901 Node: Manual Structure Details88910
   4902 Node: License for Manuals90328
   4903 Node: Manual Credits91302
   4904 Node: Printed Manuals91695
   4905 Node: NEWS File92381
   4906 Node: Change Logs93059
   4907 Node: Change Log Concepts93813
   4908 Node: Style of Change Logs95677
   4909 Node: Simple Changes97712
   4910 Node: Conditional Changes98956
   4911 Node: Indicating the Part Changed100378
   4912 Node: Man Pages100905
   4913 Node: Reading other Manuals102529
   4914 Node: Managing Releases103320
   4915 Node: Configuration104083
   4916 Node: Makefile Conventions110988
   4917 Node: Makefile Basics111794
   4918 Node: Utilities in Makefiles114968
   4919 Node: Command Variables117113
   4920 Node: Directory Variables120690
   4921 Node: Standard Targets131584
   4922 Ref: Standard Targets-Footnote-1142824
   4923 Node: Install Command Categories142924
   4924 Node: Releases147506
   4925 Node: References151594
   4926 Node: Copying This Manual153879
   4927 Node: GNU Free Documentation License154115
   4928 Node: Index173816
   4929 
   4930 End Tag Table
   4931