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