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