Debian Codegraph @

doc/standards.info

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