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