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