From e31a79b1d67d76260a1024957a89ad1320575b97 Mon Sep 17 00:00:00 2001 From: Nick Clifton Date: Mon, 13 Aug 2007 09:45:22 +0000 Subject: [PATCH] * standards.texi: Import 22 July 2007 version. * fdl.texi: Import version 1.2. * make-stds.texi: Import 2006 version. --- etc/ChangeLog | 6 + etc/fdl.texi | 373 +++++++++------ etc/make-stds.texi | 374 +++++++++++---- etc/standards.texi | 1105 ++++++++++++++++++++++++++++++-------------- 4 files changed, 1276 insertions(+), 582 deletions(-) diff --git a/etc/ChangeLog b/etc/ChangeLog index 42e16c1ac..38d33aa0a 100644 --- a/etc/ChangeLog +++ b/etc/ChangeLog @@ -1,3 +1,9 @@ +2007-08-13 Nick Clifton + + * standards.texi: Import 22 July 2007 version. + * fdl.texi: Import version 1.2. + * make-stds.texi: Import 2006 version. + 2007-04-04 Eric Christopher Move from gcc: diff --git a/etc/fdl.texi b/etc/fdl.texi index 138705678..7b93651f1 100644 --- a/etc/fdl.texi +++ b/etc/fdl.texi @@ -1,28 +1,28 @@ -@c -*-texinfo-*- -@node GNU Free Documentation License, , , Copying This Manual +@c The GNU Free Documentation License. +@center Version 1.2, November 2002 -@appendix GNU Free Documentation License -@center Version 1.1, March 2000 +@c This file is intended to be included within another document, +@c hence no sectioning command or @node. @display -Copyright (C) 2000 Free Software Foundation, Inc. -59 Temple Place, Suite 330, Boston, MA 02111-1307 USA +Copyright @copyright{} 2000,2001,2002 Free Software Foundation, Inc. +51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. @end display -@sp 1 + @enumerate 0 @item PREAMBLE The purpose of this License is to make a manual, textbook, or other -written document ``free'' in the sense of freedom: to assure everyone -the effective freedom to copy and redistribute it, with or without -modifying it, either commercially or noncommercially. Secondarily, -this License preserves for the author and publisher a way to get -credit for their work, while not being considered responsible for -modifications made by others. +functional and useful document @dfn{free} in the sense of freedom: to +assure everyone the effective freedom to copy and redistribute it, +with or without modifying it, either commercially or noncommercially. +Secondarily, this License preserves for the author and publisher a way +to get credit for their work, while not being considered responsible +for modifications made by others. This License is a kind of ``copyleft'', which means that derivative works of the document must themselves be free in the same sense. It @@ -37,60 +37,72 @@ it can be used for any textual work, regardless of subject matter or whether it is published as a printed book. We recommend this License principally for works whose purpose is instruction or reference. -@sp 1 @item APPLICABILITY AND DEFINITIONS -This License applies to any manual or other work that contains a -notice placed by the copyright holder saying it can be distributed -under the terms of this License. The ``Document'', below, refers to any -such manual or work. Any member of the public is a licensee, and is -addressed as ``you.'' +This License applies to any manual or other work, in any medium, that +contains a notice placed by the copyright holder saying it can be +distributed under the terms of this License. Such a notice grants a +world-wide, royalty-free license, unlimited in duration, to use that +work under the conditions stated herein. The ``Document'', below, +refers to any such manual or work. Any member of the public is a +licensee, and is addressed as ``you''. You accept the license if you +copy, modify or distribute the work in a way requiring permission +under copyright law. A ``Modified Version'' of the Document means any work containing the Document or a portion of it, either copied verbatim, or with modifications and/or translated into another language. -A ``Secondary Section'' is a named appendix or a front-matter section of -the Document that deals exclusively with the relationship of the -publishers or authors of the Document to the Document's overall subject -(or to related matters) and contains nothing that could fall directly -within that overall subject. (For example, if the Document is in part a -textbook of mathematics, a Secondary Section may not explain any -mathematics.) The relationship could be a matter of historical +A ``Secondary Section'' is a named appendix or a front-matter section +of the Document that deals exclusively with the relationship of the +publishers or authors of the Document to the Document's overall +subject (or to related matters) and contains nothing that could fall +directly within that overall subject. (Thus, if the Document is in +part a textbook of mathematics, a Secondary Section may not explain +any mathematics.) The relationship could be a matter of historical connection with the subject or with related matters, or of legal, commercial, philosophical, ethical or political position regarding them. The ``Invariant Sections'' are certain Secondary Sections whose titles are designated, as being those of Invariant Sections, in the notice -that says that the Document is released under this License. +that says that the Document is released under this License. If a +section does not fit the above definition of Secondary then it is not +allowed to be designated as Invariant. The Document may contain zero +Invariant Sections. If the Document does not identify any Invariant +Sections then there are none. The ``Cover Texts'' are certain short passages of text that are listed, as Front-Cover Texts or Back-Cover Texts, in the notice that says that -the Document is released under this License. +the Document is released under this License. A Front-Cover Text may +be at most 5 words, and a Back-Cover Text may be at most 25 words. A ``Transparent'' copy of the Document means a machine-readable copy, represented in a format whose specification is available to the -general public, whose contents can be viewed and edited directly and +general public, that is suitable for revising the document straightforwardly with generic text editors or (for images composed of pixels) generic paint programs or (for drawings) some widely available drawing editor, and that is suitable for input to text formatters or for automatic translation to a variety of formats suitable for input to text formatters. A copy made in an otherwise Transparent file -format whose markup has been designed to thwart or discourage -subsequent modification by readers is not Transparent. A copy that is -not ``Transparent'' is called ``Opaque.'' +format whose markup, or absence of markup, has been arranged to thwart +or discourage subsequent modification by readers is not Transparent. +An image format is not Transparent if used for any substantial amount +of text. A copy that is not ``Transparent'' is called ``Opaque''. Examples of suitable formats for Transparent copies include plain -ASCII without markup, Texinfo input format, LaTeX input format, SGML -or XML using a publicly available DTD, and standard-conforming simple -HTML designed for human modification. Opaque formats include -PostScript, PDF, proprietary formats that can be read and edited only -by proprietary word processors, SGML or XML for which the DTD and/or -processing tools are not generally available, and the -machine-generated HTML produced by some word processors for output -purposes only. +@sc{ascii} without markup, Texinfo input format, La@TeX{} input +format, @acronym{SGML} or @acronym{XML} using a publicly available +@acronym{DTD}, and standard-conforming simple @acronym{HTML}, +PostScript or @acronym{PDF} designed for human modification. Examples +of transparent image formats include @acronym{PNG}, @acronym{XCF} and +@acronym{JPG}. Opaque formats include proprietary formats that can be +read and edited only by proprietary word processors, @acronym{SGML} or +@acronym{XML} for which the @acronym{DTD} and/or processing tools are +not generally available, and the machine-generated @acronym{HTML}, +PostScript or @acronym{PDF} produced by some word processors for +output purposes only. The ``Title Page'' means, for a printed book, the title page itself, plus such following pages as are needed to hold, legibly, the material @@ -98,7 +110,22 @@ this License requires to appear in the title page. For works in formats which do not have any title page as such, ``Title Page'' means the text near the most prominent appearance of the work's title, preceding the beginning of the body of the text. -@sp 1 + +A section ``Entitled XYZ'' means a named subunit of the Document whose +title either is precisely XYZ or contains XYZ in parentheses following +text that translates XYZ in another language. (Here XYZ stands for a +specific section name mentioned below, such as ``Acknowledgements'', +``Dedications'', ``Endorsements'', or ``History''.) To ``Preserve the Title'' +of such a section when you modify the Document means that it remains a +section ``Entitled XYZ'' according to this definition. + +The Document may include Warranty Disclaimers next to the notice which +states that this License applies to the Document. These Warranty +Disclaimers are considered to be included by reference in this +License, but only as regards disclaiming warranties: any other +implication that these Warranty Disclaimers may have is void and has +no effect on the meaning of this License. + @item VERBATIM COPYING @@ -114,13 +141,14 @@ number of copies you must also follow the conditions in section 3. You may also lend copies, under the same conditions stated above, and you may publicly display copies. -@sp 1 + @item COPYING IN QUANTITY -If you publish printed copies of the Document numbering more than 100, -and the Document's license notice requires Cover Texts, you must enclose -the copies in covers that carry, clearly and legibly, all these Cover +If you publish printed copies (or copies in media that commonly have +printed covers) of the Document, numbering more than 100, and the +Document's license notice requires Cover Texts, you must enclose the +copies in covers that carry, clearly and legibly, all these Cover Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on the back cover. Both covers must also clearly and legibly identify you as the publisher of these copies. The front cover must present @@ -138,21 +166,20 @@ pages. If you publish or distribute Opaque copies of the Document numbering more than 100, you must either include a machine-readable Transparent copy along with each Opaque copy, or state in or with each Opaque copy -a publicly-accessible computer-network location containing a complete -Transparent copy of the Document, free of added material, which the -general network-using public has access to download anonymously at no -charge using public-standard network protocols. If you use the latter -option, you must take reasonably prudent steps, when you begin -distribution of Opaque copies in quantity, to ensure that this -Transparent copy will remain thus accessible at the stated location -until at least one year after the last time you distribute an Opaque -copy (directly or through your agents or retailers) of that edition to -the public. +a computer-network location from which the general network-using +public has access to download using public-standard network protocols +a complete Transparent copy of the Document, free of added material. +If you use the latter option, you must take reasonably prudent steps, +when you begin distribution of Opaque copies in quantity, to ensure +that this Transparent copy will remain thus accessible at the stated +location until at least one year after the last time you distribute an +Opaque copy (directly or through your agents or retailers) of that +edition to the public. It is requested, but not required, that you contact the authors of the Document well before redistributing any large number of copies, to give them a chance to provide you with an updated version of the Document. -@sp 1 + @item MODIFICATIONS @@ -163,52 +190,85 @@ Version filling the role of the Document, thus licensing distribution and modification of the Modified Version to whoever possesses a copy of it. In addition, you must do these things in the Modified Version: -A. Use in the Title Page (and on the covers, if any) a title distinct - from that of the Document, and from those of previous versions - (which should, if there were any, be listed in the History section - of the Document). You may use the same title as a previous version - if the original publisher of that version gives permission.@* -B. List on the Title Page, as authors, one or more persons or entities - responsible for authorship of the modifications in the Modified - Version, together with at least five of the principal authors of the - Document (all of its principal authors, if it has less than five).@* -C. State on the Title page the name of the publisher of the - Modified Version, as the publisher.@* -D. Preserve all the copyright notices of the Document.@* -E. Add an appropriate copyright notice for your modifications - adjacent to the other copyright notices.@* -F. Include, immediately after the copyright notices, a license notice - giving the public permission to use the Modified Version under the - terms of this License, in the form shown in the Addendum below.@* -G. Preserve in that license notice the full lists of Invariant Sections - and required Cover Texts given in the Document's license notice.@* -H. Include an unaltered copy of this License.@* -I. Preserve the section entitled ``History'', and its title, and add to - it an item stating at least the title, year, new authors, and - publisher of the Modified Version as given on the Title Page. If - there is no section entitled ``History'' in the Document, create one - stating the title, year, authors, and publisher of the Document as - given on its Title Page, then add an item describing the Modified - Version as stated in the previous sentence.@* -J. Preserve the network location, if any, given in the Document for - public access to a Transparent copy of the Document, and likewise - the network locations given in the Document for previous versions - it was based on. These may be placed in the ``History'' section. - You may omit a network location for a work that was published at - least four years before the Document itself, or if the original - publisher of the version it refers to gives permission.@* -K. In any section entitled ``Acknowledgements'' or ``Dedications'', - preserve the section's title, and preserve in the section all the - substance and tone of each of the contributor acknowledgements - and/or dedications given therein.@* -L. Preserve all the Invariant Sections of the Document, - unaltered in their text and in their titles. Section numbers - or the equivalent are not considered part of the section titles.@* -M. Delete any section entitled ``Endorsements.'' Such a section - may not be included in the Modified Version.@* -N. Do not retitle any existing section as ``Endorsements'' - or to conflict in title with any Invariant Section.@* -@sp 1 +@enumerate A +@item +Use in the Title Page (and on the covers, if any) a title distinct +from that of the Document, and from those of previous versions +(which should, if there were any, be listed in the History section +of the Document). You may use the same title as a previous version +if the original publisher of that version gives permission. + +@item +List on the Title Page, as authors, one or more persons or entities +responsible for authorship of the modifications in the Modified +Version, together with at least five of the principal authors of the +Document (all of its principal authors, if it has fewer than five), +unless they release you from this requirement. + +@item +State on the Title page the name of the publisher of the +Modified Version, as the publisher. + +@item +Preserve all the copyright notices of the Document. + +@item +Add an appropriate copyright notice for your modifications +adjacent to the other copyright notices. + +@item +Include, immediately after the copyright notices, a license notice +giving the public permission to use the Modified Version under the +terms of this License, in the form shown in the Addendum below. + +@item +Preserve in that license notice the full lists of Invariant Sections +and required Cover Texts given in the Document's license notice. + +@item +Include an unaltered copy of this License. + +@item +Preserve the section Entitled ``History'', Preserve its Title, and add +to it an item stating at least the title, year, new authors, and +publisher of the Modified Version as given on the Title Page. If +there is no section Entitled ``History'' in the Document, create one +stating the title, year, authors, and publisher of the Document as +given on its Title Page, then add an item describing the Modified +Version as stated in the previous sentence. + +@item +Preserve the network location, if any, given in the Document for +public access to a Transparent copy of the Document, and likewise +the network locations given in the Document for previous versions +it was based on. These may be placed in the ``History'' section. +You may omit a network location for a work that was published at +least four years before the Document itself, or if the original +publisher of the version it refers to gives permission. + +@item +For any section Entitled ``Acknowledgements'' or ``Dedications'', Preserve +the Title of the section, and preserve in the section all the +substance and tone of each of the contributor acknowledgements and/or +dedications given therein. + +@item +Preserve all the Invariant Sections of the Document, +unaltered in their text and in their titles. Section numbers +or the equivalent are not considered part of the section titles. + +@item +Delete any section Entitled ``Endorsements''. Such a section +may not be included in the Modified Version. + +@item +Do not retitle any existing section to be Entitled ``Endorsements'' or +to conflict in title with any Invariant Section. + +@item +Preserve any Warranty Disclaimers. +@end enumerate + If the Modified Version includes new front-matter sections or appendices that qualify as Secondary Sections and contain no material copied from the Document, you may at your option designate some or all @@ -216,9 +276,9 @@ of these sections as invariant. To do this, add their titles to the list of Invariant Sections in the Modified Version's license notice. These titles must be distinct from any other section titles. -You may add a section entitled ``Endorsements'', provided it contains +You may add a section Entitled ``Endorsements'', provided it contains nothing but endorsements of your Modified Version by various -parties--for example, statements of peer review or that the text has +parties---for example, statements of peer review or that the text has been approved by an organization as the authoritative definition of a standard. @@ -235,7 +295,7 @@ permission from the previous publisher that added the old one. The author(s) and publisher(s) of the Document do not by this License give permission to use their names for publicity for or to assert or imply endorsement of any Modified Version. -@sp 1 + @item COMBINING DOCUMENTS @@ -244,7 +304,7 @@ License, under the terms defined in section 4 above for modified versions, provided that you include in the combination all of the Invariant Sections of all of the original documents, unmodified, and list them all as Invariant Sections of your combined work in its -license notice. +license notice, and that you preserve all their Warranty Disclaimers. The combined work need only contain one copy of this License, and multiple identical Invariant Sections may be replaced with a single @@ -255,12 +315,12 @@ author or publisher of that section if known, or else a unique number. Make the same adjustment to the section titles in the list of Invariant Sections in the license notice of the combined work. -In the combination, you must combine any sections entitled ``History'' -in the various original documents, forming one section entitled -``History''; likewise combine any sections entitled ``Acknowledgements'', -and any sections entitled ``Dedications.'' You must delete all sections -entitled ``Endorsements.'' -@sp 1 +In the combination, you must combine any sections Entitled ``History'' +in the various original documents, forming one section Entitled +``History''; likewise combine any sections Entitled ``Acknowledgements'', +and any sections Entitled ``Dedications''. You must delete all +sections Entitled ``Endorsements.'' + @item COLLECTIONS OF DOCUMENTS @@ -274,25 +334,27 @@ You may extract a single document from such a collection, and distribute it individually under this License, provided you insert a copy of this License into the extracted document, and follow this License in all other respects regarding verbatim copying of that document. -@sp 1 + @item AGGREGATION WITH INDEPENDENT WORKS A compilation of the Document or its derivatives with other separate and independent documents or works, in or on a volume of a storage or -distribution medium, does not as a whole count as a Modified Version -of the Document, provided no compilation copyright is claimed for the -compilation. Such a compilation is called an ``aggregate'', and this -License does not apply to the other self-contained works thus compiled -with the Document, on account of their being thus compiled, if they -are not themselves derivative works of the Document. +distribution medium, is called an ``aggregate'' if the copyright +resulting from the compilation is not used to limit the legal rights +of the compilation's users beyond what the individual works permit. +When the Document is included in an aggregate, this License does not +apply to the other works in the aggregate which are not themselves +derivative works of the Document. If the Cover Text requirement of section 3 is applicable to these -copies of the Document, then if the Document is less than one quarter -of the entire aggregate, the Document's Cover Texts may be placed on -covers that surround only the Document within the aggregate. -Otherwise they must appear on covers around the whole aggregate. -@sp 1 +copies of the Document, then if the Document is less than one half of +the entire aggregate, the Document's Cover Texts may be placed on +covers that bracket the Document within the aggregate, or the +electronic equivalent of covers if the Document is in electronic form. +Otherwise they must appear on printed covers that bracket the whole +aggregate. + @item TRANSLATION @@ -302,11 +364,18 @@ Replacing Invariant Sections with translations requires special permission from their copyright holders, but you may include translations of some or all Invariant Sections in addition to the original versions of these Invariant Sections. You may include a -translation of this License provided that you also include the -original English version of this License. In case of a disagreement -between the translation and the original English version of this -License, the original English version will prevail. -@sp 1 +translation of this License, and all the license notices in the +Document, and any Warranty Disclaimers, provided that you also include +the original English version of this License and the original versions +of those notices and disclaimers. In case of a disagreement between +the translation and the original version of this License or a notice +or disclaimer, the original version will prevail. + +If a section in the Document is Entitled ``Acknowledgements'', +``Dedications'', or ``History'', the requirement (section 4) to Preserve +its Title (section 1) will typically require changing the actual +title. + @item TERMINATION @@ -317,7 +386,7 @@ automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. -@sp 1 + @item FUTURE REVISIONS OF THIS LICENSE @@ -325,7 +394,7 @@ The Free Software Foundation may publish new, revised versions of the GNU Free Documentation License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. See -http://www.gnu.org/copyleft/. +@uref{http://www.gnu.org/copyleft/}. Each version of the License is given a distinguishing version number. If the Document specifies that a particular numbered version of this @@ -335,10 +404,10 @@ of any later version that has been published (not as a draft) by the Free Software Foundation. If the Document does not specify a version number of this License, you may choose any version ever published (not as a draft) by the Free Software Foundation. - @end enumerate -@unnumberedsec ADDENDUM: How to use this License for your documents +@page +@heading ADDENDUM: How to use this License for your documents To use this License in a document you have written, include a copy of the License in the document and put the following copyright and @@ -346,23 +415,37 @@ license notices just after the title page: @smallexample @group -Copyright (C) @var{year} @var{your name}. -Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU Free Documentation License, Version 1.1 -or any later version published by the Free Software Foundation; -with the Invariant Sections being @var{list their titles}, with the -Front-Cover Texts being @var{list}, and with the Back-Cover Texts being @var{list}. -A copy of the license is included in the section entitled "GNU -Free Documentation License." + Copyright (C) @var{year} @var{your name}. + Permission is granted to copy, distribute and/or modify this document + under the terms of the GNU Free Documentation License, Version 1.2 + or any later version published by the Free Software Foundation; + with no Invariant Sections, no Front-Cover Texts, and no Back-Cover + Texts. A copy of the license is included in the section entitled ``GNU + Free Documentation License''. @end group @end smallexample -If you have no Invariant Sections, write ``with no Invariant Sections'' -instead of saying which ones are invariant. If you have no -Front-Cover Texts, write ``no Front-Cover Texts'' instead of -``Front-Cover Texts being @var{list}''; likewise for Back-Cover Texts. +If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts, +replace the ``with@dots{}Texts.'' line with this: + +@smallexample +@group + with the Invariant Sections being @var{list their titles}, with + the Front-Cover Texts being @var{list}, and with the Back-Cover Texts + being @var{list}. +@end group +@end smallexample + +If you have Invariant Sections without Cover Texts, or some other +combination of the three, merge those two alternatives to suit the +situation. If your document contains nontrivial examples of program code, we recommend releasing these examples in parallel under your choice of free software license, such as the GNU General Public License, to permit their use in free software. + +@c Local Variables: +@c ispell-local-pdict: "ispell-dict" +@c End: + diff --git a/etc/make-stds.texi b/etc/make-stds.texi index 250867adf..91a1ed030 100644 --- a/etc/make-stds.texi +++ b/etc/make-stds.texi @@ -8,11 +8,11 @@ @cindex conventions for makefiles @cindex standards for makefiles -@c Copyright 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001 Free -@c Software Foundation, Inc. +@c Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 2000, 2001, +@c 2004, 2005, 2006 Free Software Foundation, Inc. @c Permission is granted to copy, distribute and/or modify this document -@c under the terms of the GNU Free Documentation License, Version 1.1 +@c under the terms of the GNU Free Documentation License, Version 1.2 @c or any later version published by the Free Software Foundation; @c with no Invariant Sections, with no @c Front-Cover Texts, and with no Back-Cover Texts. @@ -36,11 +36,12 @@ Using Automake will help you write a Makefile that follows these conventions. @menu -* Makefile Basics:: General Conventions for Makefiles -* Utilities in Makefiles:: Utilities in Makefiles -* Command Variables:: Variables for Specifying Commands -* Directory Variables:: Variables for Installation Directories -* Standard Targets:: Standard Targets for Users +* Makefile Basics:: General conventions for Makefiles. +* Utilities in Makefiles:: Utilities to be used in Makefiles. +* Command Variables:: Variables for specifying commands. +* DESTDIR:: Supporting staged installs. +* Directory Variables:: Variables for installation directories. +* Standard Targets:: Standard targets for users. * Install Command Categories:: Three categories of commands in the `install' rule: normal, pre-install and post-install. @end menu @@ -263,43 +264,102 @@ Every Makefile should also define the variables @code{INSTALL_PROGRAM} and @code{INSTALL_DATA}. (The default for @code{INSTALL_PROGRAM} should be @code{$(INSTALL)}; the default for @code{INSTALL_DATA} should be @code{$@{INSTALL@} -m 644}.) Then it should use those variables as the -commands for actual installation, for executables and nonexecutables -respectively. Use these variables as follows: +commands for actual installation, for executables and non-executables +respectively. Minimal use of these variables is as follows: @example $(INSTALL_PROGRAM) foo $(bindir)/foo $(INSTALL_DATA) libfoo.a $(libdir)/libfoo.a @end example -Optionally, you may prepend the value of @code{DESTDIR} to the target -filename. Doing this allows the installer to create a snapshot of the -installation to be copied onto the real target filesystem later. Do not -set the value of @code{DESTDIR} in your Makefile, and do not include it -in any installed files. With support for @code{DESTDIR}, the above -examples become: - -@example -$(INSTALL_PROGRAM) foo $(DESTDIR)$(bindir)/foo -$(INSTALL_DATA) libfoo.a $(DESTDIR)$(libdir)/libfoo.a -@end example +However, it is preferable to support a @code{DESTDIR} prefix on the +target files, as explained in the next section. @noindent Always use a file name, not a directory name, as the second argument of the installation commands. Use a separate command for each file to be installed. + +@node DESTDIR +@section @code{DESTDIR}: support for staged installs + +@vindex DESTDIR +@cindex staged installs +@cindex installations, staged + +@code{DESTDIR} is a variable prepended to each installed target file, +like this: + +@example +$(INSTALL_PROGRAM) foo $(DESTDIR)$(bindir)/foo +$(INSTALL_DATA) libfoo.a $(DESTDIR)$(libdir)/libfoo.a +@end example + +The @code{DESTDIR} variable is specified by the user on the @code{make} +command line. For example: + +@example +make DESTDIR=/tmp/stage install +@end example + +@noindent +@code{DESTDIR} should be supported only in the @code{install*} and +@code{uninstall*} targets, as those are the only targets where it is +useful. + +If your installation step would normally install +@file{/usr/local/bin/foo} and @file{/usr/local/lib/libfoo.a}, then an +installation invoked as in the example above would install +@file{/tmp/stage/usr/local/bin/foo} and +@file{/tmp/stage/usr/local/lib/libfoo.a} instead. + +Prepending the variable @code{DESTDIR} to each target in this way +provides for @dfn{staged installs}, where the installed files are not +placed directly into their expected location but are instead copied +into a temporary location (@code{DESTDIR}). However, installed files +maintain their relative directory structure and any embedded file names +will not be modified. + +You should not set the value of @code{DESTDIR} in your @file{Makefile} +at all; then the files are installed into their expected locations by +default. Also, specifying @code{DESTDIR} should not change the +operation of the software in any way, so its value should not be +included in any file contents. + +@code{DESTDIR} support is commonly used in package creation. It is +also helpful to users who want to understand what a given package will +install where, and to allow users who don't normally have permissions +to install into protected areas to build and install before gaining +those permissions. Finally, it can be useful with tools such as +@code{stow}, where code is installed in one place but made to appear +to be installed somewhere else using symbolic links or special mount +operations. So, we strongly recommend GNU packages support +@code{DESTDIR}, though it is not an absolute requirement. + + @node Directory Variables @section Variables for Installation Directories Installation directories should always be named by variables, so it is easy to install in a nonstandard place. The standard names for these -variables are described below. They are based on a standard filesystem -layout; variants of it are used in SVR4, 4.4BSD, GNU/Linux, Ultrix v4, -and other modern operating systems. +variables and the values they should have in GNU packages are +described below. They are based on a standard file system layout; +variants of it are used in GNU/Linux and other modern operating +systems. -These two variables set the root for the installation. All the other -installation directories should be subdirectories of one of these two, -and nothing should be directly installed into these two directories. +Installers are expected to override these values when calling +@command{make} (e.g., @kbd{make prefix=/usr install} or +@command{configure} (e.g., @kbd{configure --prefix=/usr}). GNU +packages should not try to guess which value should be appropriate for +these variables on the system they are being installed onto: use the +default settings specified here so that all GNU packages behave +identically, allowing the installer to achieve any desired layout. + +These first two variables set the root for the installation. All the +other installation directories should be subdirectories of one of +these two, and nothing should be directly installed into these two +directories. @table @code @item prefix @@ -355,6 +415,12 @@ The directory for installing executable programs to be run by other programs rather than by users. This directory should normally be @file{/usr/local/libexec}, but write it as @file{$(exec_prefix)/libexec}. (If you are using Autoconf, write it as @samp{@@libexecdir@@}.) + +The definition of @samp{libexecdir} is the same for all packages, so +you should install your data in a subdirectory thereof. Most packages +install their data under @file{$(libexecdir)/@var{package-name}/}, +possibly within additional subdirectories thereof, such as +@file{$(libexecdir)/@var{package-name}/@var{machine}/@var{version}}. @end table Data files used by the program during its execution are divided into @@ -377,17 +443,32 @@ discourage the use of architecture-dependent files, aside from object files and libraries. It is much cleaner to make other data files architecture-independent, and it is generally not hard. -Therefore, here are the variables Makefiles should use to specify -directories: +Here are the variables Makefiles should use to specify directories +to put these various kinds of files in: @table @samp +@item datarootdir +The root of the directory tree for read-only architecture-independent +data files. This should normally be @file{/usr/local/share}, but +write it as @file{$(prefix)/share}. (If you are using Autoconf, write +it as @samp{@@datarootdir@@}.) @samp{datadir}'s default value is +based on this variable; so are @samp{infodir}, @samp{mandir}, and +others. + @item datadir -The directory for installing read-only architecture independent data -files. This should normally be @file{/usr/local/share}, but write it as -@file{$(prefix)/share}. -(If you are using Autoconf, write it as @samp{@@datadir@@}.) -As a special exception, see @file{$(infodir)} -and @file{$(includedir)} below. +The directory for installing idiosyncratic read-only +architecture-independent data files for this program. This is usually +the same place as @samp{datarootdir}, but we use the two separate +variables so that you can move these program-specific files without +altering the location for Info files, man pages, etc. + +This should normally be @file{/usr/local/share}, but write it as +@file{$(datarootdir)}. (If you are using Autoconf, write it as +@samp{@@datadir@@}.) + +The definition of @samp{datadir} is the same for all packages, so you +should install your data in a subdirectory thereof. Most packages +install their data under @file{$(datadir)/@var{package-name}/}. @item sysconfdir The directory for installing read-only data files that pertain to a @@ -419,34 +500,14 @@ in @file{$(datadir)} or @file{$(sysconfdir)}. @file{$(localstatedir)} should normally be @file{/usr/local/var}, but write it as @file{$(prefix)/var}. (If you are using Autoconf, write it as @samp{@@localstatedir@@}.) +@end table -@item libdir -The directory for object files and libraries of object code. Do not -install executables here, they probably ought to go in @file{$(libexecdir)} -instead. The value of @code{libdir} should normally be -@file{/usr/local/lib}, but write it as @file{$(exec_prefix)/lib}. -(If you are using Autoconf, write it as @samp{@@libdir@@}.) - -@item infodir -The directory for installing the Info files for this package. By -default, it should be @file{/usr/local/info}, but it should be written -as @file{$(prefix)/info}. -(If you are using Autoconf, write it as @samp{@@infodir@@}.) - -@item lispdir -The directory for installing any Emacs Lisp files in this package. By -default, it should be @file{/usr/local/share/emacs/site-lisp}, but it -should be written as @file{$(prefix)/share/emacs/site-lisp}. - -If you are using Autoconf, write the default as @samp{@@lispdir@@}. -In order to make @samp{@@lispdir@@} work, you need the following lines -in your @file{configure.in} file: - -@example -lispdir='$@{datadir@}/emacs/site-lisp' -AC_SUBST(lispdir) -@end example +These variables specify the directory for installing certain specific +types of files, if your program has them. Every GNU package should +have Info files, so every program needs @samp{infodir}, but not all +need @samp{libdir} or @samp{lispdir}. +@table @samp @item includedir @c rewritten to avoid overfull hbox --roland The directory for installing header files to be included by user @@ -481,6 +542,62 @@ package. To tell whether @file{foo.h} came from the Foo package, put a magic string in the file---part of a comment---and @code{grep} for that string. + +@item docdir +The directory for installing documentation files (other than Info) for +this package. By default, it should be +@file{/usr/local/share/doc/@var{yourpkg}}, but it should be written as +@file{$(datarootdir)/doc/@var{yourpkg}}. (If you are using Autoconf, +write it as @samp{@@docdir@@}.) The @var{yourpkg} subdirectory, which +may include a version number, prevents collisions among files with +common names, such as @file{README}. + +@item infodir +The directory for installing the Info files for this package. By +default, it should be @file{/usr/local/share/info}, but it should be +written as @file{$(datarootdir)/info}. (If you are using Autoconf, +write it as @samp{@@infodir@@}.) @code{infodir} is separate from +@code{docdir} for compatibility with existing practice. + +@item htmldir +@itemx dvidir +@itemx pdfdir +@itemx psdir +Directories for installing documentation files in the particular +format. They should all be set to @code{$(docdir)} by default. (If +you are using Autoconf, write them as @samp{@@htmldir@@}, +@samp{@@dvidir@@}, etc.) Packages which supply several translations +of their documentation should install them in +@samp{$(htmldir)/}@var{ll}, @samp{$(pdfdir)/}@var{ll}, etc. where +@var{ll} is a locale abbreviation such as @samp{en} or @samp{pt_BR}. + +@item libdir +The directory for object files and libraries of object code. Do not +install executables here, they probably ought to go in @file{$(libexecdir)} +instead. The value of @code{libdir} should normally be +@file{/usr/local/lib}, but write it as @file{$(exec_prefix)/lib}. +(If you are using Autoconf, write it as @samp{@@libdir@@}.) + +@item lispdir +The directory for installing any Emacs Lisp files in this package. By +default, it should be @file{/usr/local/share/emacs/site-lisp}, but it +should be written as @file{$(datarootdir)/emacs/site-lisp}. + +If you are using Autoconf, write the default as @samp{@@lispdir@@}. +In order to make @samp{@@lispdir@@} work, you need the following lines +in your @file{configure.in} file: + +@example +lispdir='$@{datarootdir@}/emacs/site-lisp' +AC_SUBST(lispdir) +@end example + +@item localedir +The directory for installing locale-specific message catalogs for this +package. By default, it should be @file{/usr/local/share/locale}, but +it should be written as @file{$(datarootdir)/locale}. (If you are +using Autoconf, write it as @samp{@@localedir@@}.) This directory +usually has a subdirectory per locale. @end table Unix-style man pages are installed in one of the following: @@ -488,9 +605,9 @@ Unix-style man pages are installed in one of the following: @table @samp @item mandir The top-level directory for installing the man pages (if any) for this -package. It will normally be @file{/usr/local/man}, but you should -write it as @file{$(prefix)/man}. -(If you are using Autoconf, write it as @samp{@@mandir@@}.) +package. It will normally be @file{/usr/local/share/man}, but you +should write it as @file{$(datarootdir)/man}. (If you are using +Autoconf, write it as @samp{@@mandir@@}.) @item man1dir The directory for installing section 1 man pages. Write it as @@ -524,7 +641,7 @@ And finally, you should set the following variable: @item srcdir The directory for the sources being compiled. The value of this variable is normally inserted by the @code{configure} shell script. -(If you are using Autconf, use @samp{srcdir = @@srcdir@@}.) +(If you are using Autoconf, use @samp{srcdir = @@srcdir@@}.) @end table For example: @@ -535,13 +652,15 @@ For example: # Common prefix for installation directories. # NOTE: This directory must exist when you start the install. prefix = /usr/local +datarootdir = $(prefix)/share +datadir = $(datarootdir) exec_prefix = $(prefix) # Where to put the executable for the command `gcc'. bindir = $(exec_prefix)/bin # Where to put the directories used by the compiler. libexecdir = $(exec_prefix)/libexec # Where to put the Info files. -infodir = $(prefix)/info +infodir = $(datarootdir)/info @end smallexample If your program installs a large number of files into one of the @@ -556,6 +675,15 @@ specify the exact same values for several different GNU packages. In order for this to be useful, all the packages must be designed so that they will work sensibly when the user does so. +At times, not all of these variables may be implemented in the current +release of Autoconf and/or Automake; but as of Autoconf@tie{}2.60, we +believe all of them are. When any are missing, the descriptions here +serve as specifications for what Autoconf will implement. As a +programmer, you can either use a development version of Autoconf or +avoid using these variables until a stable release is made which +supports them. + + @node Standard Targets @section Standard Targets for Users @@ -565,8 +693,9 @@ All GNU programs should have the following targets in their Makefiles: @item all Compile the entire program. This should be the default target. This target need not rebuild any documentation files; Info files should -normally be included in the distribution, and DVI files should be made -only when explicitly asked for. +normally be included in the distribution, and DVI (and other +documentation format) files should be made only when explicitly asked +for. By default, the Make rules should compile and link with @samp{-g}, so that executable programs have debugging symbols. Users who don't mind @@ -605,7 +734,7 @@ menu entry for the given Info file; it is part of the Texinfo package. Here is a sample rule to install an Info file: @comment This example has been carefully formatted for the Make manual. -@comment Please do not reformat it without talking to roland@gnu.ai.mit.edu. +@comment Please do not reformat it without talking to bug-make@gnu.org. @smallexample $(DESTDIR)$(infodir)/foo.info: foo.info $(POST_INSTALL) @@ -630,9 +759,31 @@ commands into three categories: normal ones, @dfn{pre-installation} commands and @dfn{post-installation} commands. @xref{Install Command Categories}. +@item install-html +@itemx install-dvi +@itemx install-pdf +@itemx install-ps +These targets install documentation in formats other than Info; +they're intended to be called explicitly by the person installing the +package, if that format is desired. GNU prefers Info files, so these +must be installed by the @code{install} target. + +When you have many documentation files to install, we recommend that +you avoid collisions and clutter by arranging for these targets to +install in subdirectories of the appropriate installation directory, +such as @code{htmldir}. As one example, if your package has multiple +manuals, and you wish to install HTML documentation with many files +(such as the ``split'' mode output by @code{makeinfo --html}), you'll +certainly want to use subdirectories, or two nodes with the same name +in different manuals will overwrite each other. + +Please make these @code{install-@var{format}} targets invoke the +commands for the @var{format} target, for example, by making +@var{format} a dependency. + @item uninstall Delete all the installed files---the copies that the @samp{install} -target creates. +and @samp{install-*} targets create. This rule should not modify the directories where compilation is done, only the directories where files are installed. @@ -668,18 +819,24 @@ executable elsewhere in case there is a bug. @comment in the printed Make manual. Please leave it in. @item clean -Delete all files from the current directory that are normally created by -building the program. Don't delete the files that record the -configuration. Also preserve files that could be made by building, but -normally aren't because the distribution comes with them. +Delete all files in the current directory that are normally created by +building the program. Also delete files in other directories if they +are created by this makefile. However, don't delete the files that +record the configuration. Also preserve files that could be made by +building, but normally aren't because the distribution comes with +them. There is no need to delete parent directories that were created +with @samp{mkdir -p}, since they could have existed anyway. Delete @file{.dvi} files here if they are not part of the distribution. @item distclean -Delete all files from the current directory that are created by -configuring or building the program. If you have unpacked the source -and built the program without creating any other files, @samp{make -distclean} should leave only the files that were in the distribution. +Delete all files in the current directory (or created by this +makefile) that are created by configuring or building the program. If +you have unpacked the source and built the program without creating +any other files, @samp{make distclean} should leave only the files +that were in the distribution. However, there is no need to delete +parent directories that were created with @samp{mkdir -p}, since they +could have existed anyway. @item mostlyclean Like @samp{clean}, but may refrain from deleting a few files that people @@ -688,18 +845,21 @@ target for GCC does not delete @file{libgcc.a}, because recompiling it is rarely necessary and takes a lot of time. @item maintainer-clean -Delete almost everything from the current directory that can be -reconstructed with this Makefile. This typically includes everything -deleted by @code{distclean}, plus more: C source files produced by -Bison, tags tables, Info files, and so on. +Delete almost everything that can be reconstructed with this Makefile. +This typically includes everything deleted by @code{distclean}, plus +more: C source files produced by Bison, tags tables, Info files, and +so on. The reason we say ``almost everything'' is that running the command -@samp{make maintainer-clean} should not delete @file{configure} even if -@file{configure} can be remade using a rule in the Makefile. More generally, -@samp{make maintainer-clean} should not delete anything that needs to -exist in order to run @file{configure} and then begin to build the -program. This is the only exception; @code{maintainer-clean} should -delete everything else that can be rebuilt. +@samp{make maintainer-clean} should not delete @file{configure} even +if @file{configure} can be remade using a rule in the Makefile. More +generally, @samp{make maintainer-clean} should not delete anything +that needs to exist in order to run @file{configure} and then begin to +build the program. Also, there is no need to delete parent +directories that were created with @samp{mkdir -p}, since they could +have existed anyway. These are the only exceptions; +@code{maintainer-clean} should delete everything else that can be +rebuilt. The @samp{maintainer-clean} target is intended to be used by a maintainer of the package, not by ordinary users. You may need special tools to @@ -743,8 +903,15 @@ users build the package, ordinarily Make will not update the Info files because they will already be up to date. @item dvi -Generate DVI files for all Texinfo documentation. -For example: +@itemx html +@itemx pdf +@itemx ps +Generate documentation files in the given format. These targets +should always exist, but any or all can be a no-op if the given output +format cannot be generated. These targets should not be dependencies +of the @code{all} target; the user must manually invoke them. + +Here's an example rule for generating DVI files from Texinfo: @smallexample dvi: foo.dvi @@ -760,6 +927,20 @@ distribution.@footnote{@code{texi2dvi} uses @TeX{} to do the real work of formatting. @TeX{} is not distributed with Texinfo.} Alternatively, write just the dependencies, and allow GNU @code{make} to provide the command. +Here's another example, this one for generating HTML from Texinfo: + +@smallexample +html: foo.html + +foo.html: foo.texi chap1.texi chap2.texi + $(TEXI2HTML) $(srcdir)/foo.texi +@end smallexample + +@noindent +Again, you would define the variable @code{TEXI2HTML} in the Makefile; +for example, it might run @code{makeinfo --no-split --html} +(@command{makeinfo} is part of the Texinfo distribution). + @item dist Create a distribution tar file for this program. The tar file should be set up so that the file names in the tar file start with a subdirectory @@ -932,10 +1113,12 @@ execute the pre-installation and post-installation commands. Programs to build binary packages work by extracting the pre-installation and post-installation commands. Here is one way of -extracting the pre-installation commands: +extracting the pre-installation commands (the @option{-s} option to +@command{make} is needed to silence messages about entering +subdirectories): @smallexample -make -n install -o all \ +make -s -n install -o all \ PRE_INSTALL=pre-install \ POST_INSTALL=post-install \ NORMAL_INSTALL=normal-install \ @@ -946,10 +1129,7 @@ make -n install -o all \ where the file @file{pre-install.awk} could contain this: @smallexample -$0 ~ /^\t[ \t]*(normal_install|post_install)[ \t]*$/ @{on = 0@} +$0 ~ /^(normal-install|post-install)[ \t]*$/ @{on = 0@} on @{print $0@} -$0 ~ /^\t[ \t]*pre_install[ \t]*$/ @{on = 1@} +$0 ~ /^pre-install[ \t]*$/ @{on = 1@} @end smallexample - -The resulting file of pre-installation commands is executed as a shell -script as part of installing the binary package. diff --git a/etc/standards.texi b/etc/standards.texi index 490e15b15..821b60efe 100644 --- a/etc/standards.texi +++ b/etc/standards.texi @@ -3,16 +3,13 @@ @setfilename standards.info @settitle GNU Coding Standards @c This date is automagically updated when you save this file: -@set lastupdate February 14, 2002 +@set lastupdate July 22, 2007 @c %**end of header -@ifnottex -@format -START-INFO-DIR-ENTRY -* Standards: (standards). GNU coding standards. -END-INFO-DIR-ENTRY -@end format -@end ifnottex +@dircategory GNU organization +@direntry +* Standards: (standards). GNU coding standards. +@end direntry @c @setchapternewpage odd @setchapternewpage off @@ -28,59 +25,55 @@ END-INFO-DIR-ENTRY @iftex @set CHAPTER chapter @end iftex -@ifnottex +@ifinfo @set CHAPTER node -@end ifnottex +@end ifinfo -@ifnottex -GNU Coding Standards -Copyright (C) 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. +@copying +The GNU coding standards, last updated @value{lastupdate}. + +Copyright @copyright{} 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, +2000, 2001, 2002, 2003, 2004, 2005, 2006, 2007 Free Software +Foundation, Inc. Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU Free Documentation License, Version 1.1 +under the terms of the GNU Free Documentation License, Version 1.2 or any later version published by the Free Software Foundation; with no Invariant Sections, with no Front-Cover Texts, and with no Back-Cover Texts. A copy of the license is included in the section entitled ``GNU Free Documentation License''. -@end ifnottex +@end copying @titlepage @title GNU Coding Standards @author Richard Stallman, et al. @author last updated @value{lastupdate} @page - @vskip 0pt plus 1filll -Copyright @copyright{} 1992, 1993, 1994, 1995, 1996, 1997, 1998, 1999, 2000, 2001 Free Software Foundation, Inc. - -Permission is granted to copy, distribute and/or modify this document -under the terms of the GNU Free Documentation License, Version 1.1 -or any later version published by the Free Software Foundation; -with no Invariant Sections, with no -Front-Cover Texts, and with no Back-Cover Texts. -A copy of the license is included in the section entitled ``GNU -Free Documentation License''. +@insertcopying @end titlepage +@contents + @ifnottex @node Top, Preface, (dir), (dir) @top Version -Last updated @value{lastupdate}. +@insertcopying @end ifnottex @menu -* Preface:: About the GNU Coding Standards -* Legal Issues:: Keeping Free Software Free -* Design Advice:: General Program Design -* Program Behavior:: Program Behavior for All Programs -* Writing C:: Making The Best Use of C -* Documentation:: Documenting Programs -* Managing Releases:: The Release Process -* References:: References to Non-Free Software or Documentation -* Copying This Manual:: How to Make Copies of This Manual -* Index:: +* Preface:: About the GNU Coding Standards. +* Legal Issues:: Keeping free software free. +* Design Advice:: General program design. +* Program Behavior:: Program behavior for all programs +* Writing C:: Making the best use of C. +* Documentation:: Documenting programs. +* Managing Releases:: The release process. +* References:: Mentioning non-free software or documentation. +* GNU Free Documentation License:: Copying and sharing this manual. +* Index:: @end menu @@ -101,15 +94,10 @@ This release of the GNU Coding Standards was last updated @cindex where to obtain @code{standards.texi} @cindex downloading this manual If you did not obtain this file directly from the GNU project and -recently, please check for a newer version. You can ftp the GNU -Coding Standards from any GNU FTP host in the directory -@file{/pub/gnu/standards/}. The GNU Coding Standards are available -there in several different formats: @file{standards.text}, -@file{standards.info}, and @file{standards.dvi}, as well as the -Texinfo ``source'' which is divided in two files: -@file{standards.texi} and @file{make-stds.texi}. The GNU Coding -Standards are also available on the GNU World Wide Web server: -@uref{http://www.gnu.org/prep/standards_toc.html}. +recently, please check for a newer version. You can get the GNU +Coding Standards from the GNU web server in many +different formats, including the Texinfo source, PDF, HTML, DVI, plain +text, and more, at: @uref{http://www.gnu.org/prep/standards/}. Corrections or suggestions for this document should be sent to @email{bug-standards@@gnu.org}. If you make a suggestion, please include a @@ -118,7 +106,7 @@ diff to the @file{standards.texi} or @file{make-stds.texi} files, but if you don't have those files, please mail your suggestion anyway. These standards cover the minimum of what is important when writing a -GNU package. Likely, the needs for additional standards will come up. +GNU package. Likely, the need for additional standards will come up. Sometimes, you might suggest that such standards be added to this document. If you think your standards would be generally useful, please do suggest them. @@ -129,17 +117,21 @@ be self-consistent---try to stick to the conventions you pick, and try to document them as much as possible. That way, your program will be more maintainable by others. +The GNU Hello program serves as an example of how to follow the GNU +coding standards for a trivial program. +@uref{http://www.gnu.org/software/hello/hello.html}. + @node Legal Issues @chapter Keeping Free Software Free @cindex legal aspects -This @value{CHAPTER} discusses how you can make sure that GNU software +This chapter discusses how you can make sure that GNU software avoids legal difficulties, and other related issues. @menu -* Reading Non-Free Code:: Referring to Proprietary Programs -* Contributions:: Accepting Contributions -* Trademarks:: How We Deal with Trademark Issues +* Reading Non-Free Code:: Referring to proprietary programs. +* Contributions:: Accepting contributions. +* Trademarks:: How we deal with trademark issues. @end menu @node Reading Non-Free Code @@ -158,7 +150,7 @@ irrelevant and dissimilar to your results. For example, Unix utilities were generally optimized to minimize memory use; if you go for speed instead, your program will be very -different. You could keep the entire input file in core and scan it +different. You could keep the entire input file in memory and scan it there instead of using stdio. Use a smarter algorithm discovered more recently than the Unix program. Eliminate use of temporary files. Do it in one pass instead of two (we did this in the assembler). @@ -211,7 +203,7 @@ You might have to take that code out again! You don't need papers for changes of a few lines here or there, since they are not significant for copyright purposes. Also, you don't need papers if all you get from the suggestion is some ideas, not actual code -which you use. For example, if someone send you one implementation, but +which you use. For example, if someone sent you one implementation, but you write a different implementation of the same idea, you don't need to get papers. @@ -221,7 +213,8 @@ result. We have more detailed advice for maintainers of programs; if you have reached the stage of actually maintaining a program for GNU (whether -released or not), please ask us for a copy. +released or not), please ask us for a copy. It is also available +online for your perusal: @uref{http://www.gnu.org/prep/maintain/}. @node Trademarks @section Trademarks @@ -232,24 +225,33 @@ packages or documentation. Trademark acknowledgements are the statements that such-and-such is a trademark of so-and-so. The GNU Project has no objection to the basic -idea of trademarks, but these acknowledgements feel like kowtowing, so -we don't use them. There is no legal requirement for them. +idea of trademarks, but these acknowledgements feel like kowtowing, +and there is no legal requirement for them, so we don't use them. What is legally required, as regards other people's trademarks, is to -avoid using them in ways which a reader might read as naming or labeling -our own programs or activities. For example, since ``Objective C'' is -(or at least was) a trademark, we made sure to say that we provide a -``compiler for the Objective C language'' rather than an ``Objective C -compiler''. The latter is meant to be short for the former, but it does -not explicitly state the relationship, so it could be misinterpreted as -using ``Objective C'' as a label for the compiler rather than for the -language. +avoid using them in ways which a reader might reasonably understand as +naming or labeling our own programs or activities. For example, since +``Objective C'' is (or at least was) a trademark, we made sure to say +that we provide a ``compiler for the Objective C language'' rather +than an ``Objective C compiler''. The latter would have been meant as +a shorter way of saying the former, but it does not explicitly state +the relationship, so it could be misinterpreted as using ``Objective +C'' as a label for the compiler rather than for the language. + +Please don't use ``win'' as an abbreviation for Microsoft Windows in +GNU software or documentation. In hacker terminology, calling +something a ``win'' is a form of praise. If you wish to praise +Microsoft Windows when speaking on your own, by all means do so, but +not in GNU software. Usually we write the name ``Windows'' in full, +but when brevity is very important (as in file names and sometimes +symbol names), we abbreviate it to ``w''. For instance, the files and +functions in Emacs that deal with Windows start with @samp{w32}. @node Design Advice @chapter General Program Design @cindex program design -This @value{CHAPTER} discusses some of the issues you should take into +This chapter discusses some of the issues you should take into account when designing your program. @c Standard or ANSI C @@ -263,16 +265,16 @@ account when designing your program. @c A major revision of the C Standard appeared in 1999. @menu -* Source Language:: Which languges to use. -* Compatibility:: Compatibility with other implementations -* Using Extensions:: Using non-standard features -* Standard C:: Using Standard C features -* Conditional Compilation:: Compiling Code Only If A Conditional is True +* Source Language:: Which languages to use. +* Compatibility:: Compatibility with other implementations. +* Using Extensions:: Using non-standard features. +* Standard C:: Using standard C features. +* Conditional Compilation:: Compiling code only if a conditional is true. @end menu @node Source Language @section Which Languages to Use -@cindex programming languges +@cindex programming languages When you want to use a language that gets compiled and runs at high speed, the best language to use is C. Using another language is like @@ -310,12 +312,12 @@ is written in that language, too. The Emacs editor pioneered this technique. @cindex GUILE -The standard extensibility interpreter for GNU software is GUILE, which -implements the language Scheme (an especially clean and simple dialect -of Lisp). @uref{http://www.gnu.org/software/guile/}. We don't reject -programs written in other ``scripting languages'' such as Perl and -Python, but using GUILE is very important for the overall consistency of -the GNU system. +The standard extensibility interpreter for GNU software is GUILE +(@uref{http://www.gnu.org/software/guile/}), which implements the +language Scheme (an especially clean and simple dialect of Lisp). We +don't reject programs written in other ``scripting languages'' such as +Perl and Python, but using GUILE is very important for the overall +consistency of the GNU system. @node Compatibility @section Compatibility with Other Implementations @@ -476,6 +478,7 @@ For example, please write ... @end smallexample +@noindent instead of: @smallexample @@ -488,11 +491,12 @@ instead of: A modern compiler such as GCC will generate exactly the same code in both cases, and we have been using similar techniques with good success -in several projects. +in several projects. Of course, the former method assumes that +@code{HAS_FOO} is defined as either 0 or 1. While this is not a silver bullet solving all portability problems, -following this policy would have saved the GCC project alone many person -hours if not days per year. +and is not always appropriate, following this policy would have saved +GCC developers many hours, or even days, per year. In the case of function-like macros like @code{REVERSIBLE_CC_MODE} in GCC which cannot be simply used in @code{if( ...)} statements, there is @@ -510,22 +514,68 @@ an easy workaround. Simply introduce another macro @node Program Behavior @chapter Program Behavior for All Programs -This @value{CHAPTER} describes conventions for writing robust +This chapter describes conventions for writing robust software. It also describes general standards for error messages, the command line interface, and how libraries should behave. @menu -* Semantics:: Writing robust programs -* Libraries:: Library behavior -* Errors:: Formatting error messages -* User Interfaces:: Standards about interfaces generally -* Graphical Interfaces:: Standards for graphical interfaces -* Command-Line Interfaces:: Standards for command line interfaces -* Option Table:: Table of long options -* Memory Usage:: When and how to care about memory needs -* File Usage:: Which files to use, and where +* Non-GNU Standards:: We consider standards such as POSIX; + we don't "obey" them. +* Semantics:: Writing robust programs. +* Libraries:: Library behavior. +* Errors:: Formatting error messages. +* User Interfaces:: Standards about interfaces generally. +* Graphical Interfaces:: Standards for graphical interfaces. +* Command-Line Interfaces:: Standards for command line interfaces. +* Option Table:: Table of long options. +* Memory Usage:: When and how to care about memory needs. +* File Usage:: Which files to use, and where. @end menu +@node Non-GNU Standards +@section Non-GNU Standards + +The GNU Project regards standards published by other organizations as +suggestions, not orders. We consider those standards, but we do not +``obey'' them. In developing a GNU program, you should implement +an outside standard's specifications when that makes the GNU system +better overall in an objective sense. When it doesn't, you shouldn't. + +In most cases, following published standards is convenient for +users---it means that their programs or scripts will work more +portably. For instance, GCC implements nearly all the features of +Standard C as specified by that standard. C program developers would +be unhappy if it did not. And GNU utilities mostly follow +specifications of POSIX.2; shell script writers and users would be +unhappy if our programs were incompatible. + +But we do not follow either of these specifications rigidly, and there +are specific points on which we decided not to follow them, so as to +make the GNU system better for users. + +For instance, Standard C says that nearly all extensions to C are +prohibited. How silly! GCC implements many extensions, some of which +were later adopted as part of the standard. If you want these +constructs to give an error message as ``required'' by the standard, +you must specify @samp{--pedantic}, which was implemented only so that +we can say ``GCC is a 100% implementation of the standard,'' not +because there is any reason to actually use it. + +POSIX.2 specifies that @samp{df} and @samp{du} must output sizes by +default in units of 512 bytes. What users want is units of 1k, so +that is what we do by default. If you want the ridiculous behavior +``required'' by POSIX, you must set the environment variable +@samp{POSIXLY_CORRECT} (which was originally going to be named +@samp{POSIX_ME_HARDER}). + +GNU utilities also depart from the letter of the POSIX.2 specification +when they support long-named command-line options, and intermixing +options with ordinary arguments. This minor incompatibility with +POSIX is never a problem in practice, and it is very useful. + +In particular, don't reject a new feature, or remove an old one, +merely because a standard says it is ``forbidden'' or ``deprecated.'' + @node Semantics @section Writing Robust Programs @@ -679,10 +729,12 @@ Error messages from compilers should look like this: @end example @noindent -If you want to mention the column number, use this format: +If you want to mention the column number, use one of these formats: @example @var{source-file-name}:@var{lineno}:@var{column}: @var{message} +@var{source-file-name}:@var{lineno}.@var{column}: @var{message} + @end example @noindent @@ -692,6 +744,24 @@ of these conventions are chosen for compatibility.) Calculate column numbers assuming that space and all ASCII printing characters have equal width, and assuming tab stops every 8 columns. +The error message can also give both the starting and ending positions +of the erroneous text. There are several formats so that you can +avoid redundant information such as a duplicate line number. +Here are the possible formats: + +@example +@var{source-file-name}:@var{lineno-1}.@var{column-1}-@var{lineno-2}.@var{column-2}: @var{message} +@var{source-file-name}:@var{lineno-1}.@var{column-1}-@var{column-2}: @var{message} +@var{source-file-name}:@var{lineno-1}-@var{lineno-2}: @var{message} +@end example + +@noindent +When an error is spread over several files, you can use this format: + +@example +@var{file-1}:@var{lineno-1}.@var{column-1}-@var{file-2}:@var{lineno-2}.@var{column-2}: @var{message} +@end example + Error messages from other noninteractive programs should look like this: @example @@ -722,8 +792,9 @@ input from a source other than a terminal, it is not interactive and would do best to print error messages using the noninteractive style.) The string @var{message} should not begin with a capital letter when -it follows a program name and/or file name. Also, it should not end -with a period. +it follows a program name and/or file name, because that isn't the +beginning of a sentence. (The sentence conceptually starts at the +beginning of the line.) Also, it should not end with a period. Error messages from interactive programs, and other messages such as usage messages, should start with a capital letter. But they should not @@ -763,13 +834,14 @@ output device type. For example, we provide a @code{dir} program much like @code{ls} except that its default output format is always multi-column format. + @node Graphical Interfaces @section Standards for Graphical Interfaces @cindex graphical user interface -@cindex gtk +@cindex gtk+ When you write a program that provides a graphical user interface, -please make it work with X Windows and the GTK toolkit unless the +please make it work with X Windows and the GTK+ toolkit unless the functionality specifically requires some alternative (for example, ``displaying jpeg images while in console mode''). @@ -786,6 +858,7 @@ console interface (for use by users from console mode). Once you are doing the work to provide the functionality and the graphical interface, these won't be much extra work. + @node Command-Line Interfaces @section Standards for Command Line Interfaces @cindex command-line interface @@ -816,19 +889,34 @@ be input files only; any output files would be specified using options (preferably @samp{-o} or @samp{--output}). Even if you allow an output file name as an ordinary argument for compatibility, try to provide an option as another way to specify it. This will lead to more consistency -among GNU utilities, and fewer idiosyncracies for users to remember. +among GNU utilities, and fewer idiosyncrasies for users to remember. @cindex standard command-line options +@cindex options, standard command-line +@cindex CGI programs, standard options for +@cindex PATH_INFO, specifying standard options as All programs should support two standard options: @samp{--version} -and @samp{--help}. +and @samp{--help}. CGI programs should accept these as command-line +options, and also if given as the @env{PATH_INFO}; for instance, +visiting @url{http://example.org/p.cgi/--help} in a browser should +output the same information as invoking @samp{p.cgi --help} from the +command line. -@table @code -@cindex @samp{--version} option -@item --version -This option should direct the program to print information about its name, -version, origin and legal status, all on standard output, and then exit -successfully. Other options and arguments should be ignored once this -is seen, and the program should not perform its normal function. +@menu +* --version:: The standard output for --version. +* --help:: The standard output for --help. +@end menu + +@node --version +@subsection @option{--version} + +@cindex @samp{--version} output + +The standard @code{--version} option should direct the program to +print information about its name, version, origin and legal status, +all on standard output, and then exit successfully. Other options and +arguments should be ignored once this is seen, and the program should +not perform its normal function. @cindex canonical name of a program @cindex program's canonical name @@ -858,7 +946,7 @@ If the package has a version number which is different from this program's version number, you can mention the package version number just before the close-parenthesis. -If you @strong{need} to mention the version numbers of libraries which +If you @emph{need} to mention the version numbers of libraries which are distributed separately from the package which contains this program, you can do so by printing an additional line of version info for each library you want to mention. Use the same format for these lines as for @@ -873,10 +961,11 @@ The following line, after the version number line or lines, should be a copyright notice. If more than one copyright notice is called for, put each on a separate line. -Next should follow a brief statement that the program is free software, -and that users are free to copy and change it on certain conditions. If -the program is covered by the GNU GPL, say so here. Also mention that -there is no warranty, to the extent permitted by law. +Next should follow a line stating the license, preferably using one of +abbrevations below, and a brief statement that the program is free +software, and that users are free to copy and change it. Also mention +that there is no warranty, to the extent permitted by law. See +recommended wording below. It is ok to finish the output with a list of the major authors of the program, as a way of giving credit. @@ -884,14 +973,11 @@ program, as a way of giving credit. Here's an example of output that follows these rules: @smallexample -GNU Emacs 19.34.5 -Copyright (C) 1996 Free Software Foundation, Inc. -GNU Emacs comes with NO WARRANTY, -to the extent permitted by law. -You may redistribute copies of GNU Emacs -under the terms of the GNU General Public License. -For more information about these matters, -see the files named COPYING. +GNU hello 2.3 +Copyright (C) 2007 Free Software Foundation, Inc. +License GPLv3+: GNU GPL version 3 or later +This is free software: you are free to change and redistribute it. +There is NO WARRANTY, to the extent permitted by law. @end smallexample You should adapt this to your program, of course, filling in the proper @@ -902,32 +988,102 @@ This copyright notice only needs to mention the most recent year in which changes were made---there's no need to list the years for previous versions' changes. You don't have to mention the name of the program in these notices, if that is inconvenient, since it appeared in the first -line. +line. (The rules are different for copyright notices in source files; +@pxref{Copyright Notices,,,maintain,Information for GNU Maintainers}.) Translations of the above lines must preserve the validity of the copyright notices (@pxref{Internationalization}). If the translation's character set supports it, the @samp{(C)} should be replaced with the copyright symbol, as follows: -@ifinfo -(the official copyright symbol, which is the letter C in a circle); -@end ifinfo -@ifnotinfo +@ifinfo +(the official copyright symbol, which is the letter C in a circle); +@end ifinfo +@ifnotinfo @copyright{} -@end ifnotinfo +@end ifnotinfo Write the word ``Copyright'' exactly like that, in English. Do not translate it into another language. International treaties recognize the English word ``Copyright''; translations into other languages do not have legal significance. +Finally, here is the table of our suggested license abbreviations. +Any abbreviation can be followed by @samp{v@var{version}[+]}, meaning +that particular version, or later versions with the @samp{+}, as shown +above. -@cindex @samp{--help} option -@item --help -This option should output brief documentation for how to invoke the -program, on standard output, then exit successfully. Other options and -arguments should be ignored once this is seen, and the program should -not perform its normal function. +In the case of exceptions for extra permissions with the GPL, we use +@samp{/} for a separator; the version number can follow the license +abbreviation as usual, as in the examples below. + +@table @asis +@item GPL +GNU General Public License, @url{http://www.gnu.org/licenses/gpl.html}. + +@item LGPL +GNU Lesser General Public License, @url{http://www.gnu.org/licenses/lgpl.html}. + +@item GPL/Guile +GNU GPL with the exception for Guile; for example, GPLv3+/Guile means +the GNU GPL version 3 or later, with the extra exception for Guile. + +GNU GPL with the exception for Ada. + +@item Apache +The Apache Software Foundation license, +@url{http://www.apache.org/licenses}. + +@item Artistic +The Artistic license used for Perl, @url{http://www.perlfoundation.org/legal}. + +@item Expat +The Expat license, @url{http://www.jclark.com/xml/copying.txt}. + +@item MPL +The Mozilla Public License, @url{http://www.mozilla.org/MPL/}. + +@item OBSD +The original (4-clause) BSD license, incompatible with the GNU GPL +@url{http://www.xfree86.org/3.3.6/COPYRIGHT2.html#6}. + +@item PHP +The license used for PHP, @url{http://www.php.net/license/}. + +@item public domain +The non-license that is being in the public domain, +@url{http://www.gnu.org/licenses/license-list.html#PublicDomain}. + +@item Python +The license for Python, @url{http://www.python.org/2.0.1/license.html}. + +@item RBSD +The revised (3-clause) BSD, compatible with the GNU GPL, +@url{http://www.xfree86.org/3.3.6/COPYRIGHT2.html#5}. + +@item X11 +The simple non-copyleft license used for most versions of the X Window +system, @url{http://www.xfree86.org/3.3.6/COPYRIGHT2.html#3}. + +@item Zlib +The license for Zlib, @url{http://www.gzip.org/zlib/zlib_license.html}. + +@end table + +More information about these licenses and many more are on the GNU +licensing web pages, +@url{http://www.gnu.org/licenses/license-list.html}. + + +@node --help +@subsection @option{--help} + +@cindex @samp{--help} output + +The standard @code{--help} option should output brief documentation +for how to invoke the program, on standard output, then exit +successfully. Other options and arguments should be ignored once this +is seen, and the program should not perform its normal function. @cindex address for bug reports @cindex bug reports @@ -937,7 +1093,7 @@ that says where to mail bug reports. It should have this format: @example Report bugs to @var{mailing-address}. @end example -@end table + @node Option Table @section Table of Long Options @@ -1461,9 +1617,7 @@ Used in @code{gawk}. Used in @code{su}. @item machine -No listing of which programs already use this; -someone should check to -see if any actually do, and tell @email{gnu@@gnu.org}. +Used in @code{uname}. @item macro-name @samp{-M} in @code{ptx}. @@ -1573,6 +1727,9 @@ Used in GDB. @item no-sort @samp{-p} in @code{nm}. +@item no-splash +Don't print a startup splash screen. + @item no-split Used in @code{makeinfo}. @@ -1740,7 +1897,7 @@ Specify an HTTP proxy. @samp{-q} in Make. @item quiet -Used in many programs to inhibit the usual output. @strong{Note:} every +Used in many programs to inhibit the usual output. Every program accepting @samp{--quiet} should accept @samp{--silent} as a synonym. @@ -1855,7 +2012,7 @@ Used by @code{recode} to chose files or pipes for sequencing passes. @item silent Used in many programs to inhibit the usual output. -@strong{Note:} every program accepting +Every program accepting @samp{--silent} should accept @samp{--quiet} as a synonym. @item size @@ -1864,7 +2021,7 @@ Used in many programs to inhibit the usual output. @item socket Specify a file descriptor for a network server to use for its socket, instead of opening and binding a new socket. This provides a way to -run, in a nonpriveledged process, a server that normally needs a +run, in a non-privileged process, a server that normally needs a reserved port number. @item sort @@ -2065,7 +2222,7 @@ Print the version number. If a program typically uses just a few meg of memory, don't bother making any effort to reduce memory usage. For example, if it is impractical for other reasons to operate on files more than a few meg long, it is -reasonable to read entire input files into core to operate on them. +reasonable to read entire input files into memory to operate on them. However, for programs such as @code{cat} or @code{tail}, that can usefully operate on very large files, it is important to avoid using a @@ -2073,10 +2230,10 @@ technique that would artificially limit the size of files it can handle. If a program works by lines and could be applied to arbitrary user-supplied input files, it should keep only a line in memory, because this is not very hard and users will want to be able to operate on input -files that are bigger than will fit in core all at once. +files that are bigger than will fit in memory all at once. If your program creates complicated data structures, just make them in -core and give a fatal error if @code{malloc} returns zero. +memory and give a fatal error if @code{malloc} returns zero. @node File Usage @section File Usage @@ -2098,18 +2255,20 @@ directory. @node Writing C @chapter Making The Best Use of C -This @value{CHAPTER} provides advice on how best to use the C language +This chapter provides advice on how best to use the C language when writing GNU software. @menu -* Formatting:: Formatting Your Source Code -* Comments:: Commenting Your Work -* Syntactic Conventions:: Clean Use of C Constructs -* Names:: Naming Variables, Functions, and Files -* System Portability:: Portability between different operating systems -* CPU Portability:: Supporting the range of CPU types -* System Functions:: Portability and ``standard'' library functions -* Internationalization:: Techniques for internationalization +* Formatting:: Formatting your source code. +* Comments:: Commenting your work. +* Syntactic Conventions:: Clean use of C constructs. +* Names:: Naming variables, functions, and files. +* System Portability:: Portability among different operating systems. +* CPU Portability:: Supporting the range of CPU types. +* System Functions:: Portability and ``standard'' library functions. +* Internationalization:: Techniques for internationalization. +* Character Set:: Use ASCII by default. +* Quote Characters:: Use `...' in the C locale. * Mmap:: How you can safely use @code{mmap}. @end menu @@ -2120,28 +2279,19 @@ when writing GNU software. @cindex open brace @cindex braces, in C source It is important to put the open-brace that starts the body of a C -function in column zero, and avoid putting any other open-brace or -open-parenthesis or open-bracket in column zero. Several tools look -for open-braces in column zero to find the beginnings of C functions. -These tools will not work on code not formatted that way. +function in column one, so that they will start a defun. Several +tools look for open-braces in column one to find the beginnings of C +functions. These tools will not work on code not formatted that way. + +Avoid putting open-brace, open-parenthesis or open-bracket in column +one when they are inside a function, so that they won't start a defun. +The open-brace that starts a @code{struct} body can go in column one +if you find it useful to treat that definition as a defun. It is also important for function definitions to start the name of the -function in column zero. This helps people to search for function +function in column one. This helps people to search for function definitions, and may also help certain tools recognize them. Thus, -the proper format is this: - -@example -static char * -concat (s1, s2) /* Name starts in column zero here */ - char *s1, *s2; -@{ /* Open brace in column zero here */ - @dots{} -@} -@end example - -@noindent -or, if you want to use Standard C syntax, format the definition like -this: +using Standard C syntax, the format is this: @example static char * @@ -2151,6 +2301,19 @@ concat (char *s1, char *s2) @} @end example +@noindent +or, if you want to use traditional C syntax, format the definition like +this: + +@example +static char * +concat (s1, s2) /* Name starts in column one here */ + char *s1, *s2; +@{ /* Open brace in column one here */ + @dots{} +@} +@end example + In Standard C, if the arguments don't fit nicely on one line, split it like this: @@ -2264,7 +2427,13 @@ page. The formfeeds should appear alone on lines by themselves. @cindex commenting Every program should start with a comment saying briefly what it is for. -Example: @samp{fmt - filter for simple filling of text}. +Example: @samp{fmt - filter for simple filling of text}. This comment +should be at the top of the source file containing the @samp{main} +function of the program. + +Also, please write a brief comment at the start of each source file, +with the file name and a line or two about the overall purpose of the +file. Please write the comments in a GNU program in English, because English is the one language that nearly all programmers in all countries can @@ -2383,7 +2552,7 @@ functions. @cindex temporary variables It used to be common practice to use the same local variables (with names like @code{tem}) over and over for different values within one -function. Instead of doing this, it is better declare a separate local +function. Instead of doing this, it is better to declare a separate local variable for each distinct purpose, and give it a name which is meaningful. This not only makes programs easier to understand, it also facilitates optimization by good compilers. You can also move the @@ -2476,8 +2645,9 @@ Don't declare both a structure tag and variables or typedefs in the same declaration. Instead, declare the structure tag separately and then use it to declare the variables or typedefs. -Try to avoid assignments inside @code{if}-conditions. For example, -don't write this: +Try to avoid assignments inside @code{if}-conditions (assignments +inside @code{while}-conditions are ok). For example, don't write +this: @example if ((foo = (char *) malloc (sizeof *foo)) == 0) @@ -2542,7 +2712,7 @@ constants. @cindex file-name limitations @pindex doschk You might want to make sure that none of the file names would conflict -the files were loaded onto an MS-DOS file system which shortens the +if the files were loaded onto an MS-DOS file system which shortens the names. You can use the program @code{doschk} to test for this. Some GNU programs were designed to limit themselves to file names of 14 @@ -2584,11 +2754,20 @@ Avoid using the format of semi-internal data bases (e.g., directories) when there is a higher-level alternative (@code{readdir}). @cindex non-@sc{posix} systems, and portability -As for systems that are not like Unix, such as MSDOS, Windows, the -Macintosh, VMS, and MVS, supporting them is often a lot of work. When -that is the case, it is better to spend your time adding features that -will be useful on GNU and GNU/Linux, rather than on supporting other -incompatible systems. +As for systems that are not like Unix, such as MSDOS, Windows, VMS, MVS, +and older Macintosh systems, supporting them is often a lot of work. +When that is the case, it is better to spend your time adding features +that will be useful on GNU and GNU/Linux, rather than on supporting +other incompatible systems. + +If you do support Windows, please do not abbreviate it as ``win''. In +hacker terminology, calling something a ``win'' is a form of praise. +You're free to praise Microsoft Windows on your own if you want, but +please don't do this in GNU packages. Instead of abbreviating +``Windows'' to ``un'', you can write it in full or abbreviate it to +``woe'' or ``w''. In GNU Emacs, for instance, we use @samp{w32} in +file names of Windows-specific files, but the macro for Windows +conditionals is called @code{WINDOWSNT}. It is a good idea to define the ``feature test macro'' @code{_GNU_SOURCE} when compiling your C files. When you compile on GNU @@ -2624,7 +2803,7 @@ printf ("diff = %ld\n", (long) (pointer2 - pointer1)); @end example 1989 Standard C requires this to work, and we know of only one -counterexample: 64-bit programs on Microsoft Windows IA-64. We will +counterexample: 64-bit programs on Microsoft Windows. We will leave it to those who want to port GNU programs to that environment to figure out how to do it. @@ -2640,41 +2819,67 @@ machines. Thus, don't make the following mistake: @example int c; @dots{} -while ((c = getchar()) != EOF) - write(file_descriptor, &c, 1); +while ((c = getchar ()) != EOF) + write (file_descriptor, &c, 1); @end example -When calling functions, you need not worry about the difference between -pointers of various types, or between pointers and integers. On most -machines, there's no difference anyway. As for the few machines where -there is a difference, all of them support Standard C prototypes, so you can -use prototypes (perhaps conditionalized to be active only in Standard C) -to make the code work on those systems. - -In certain cases, it is ok to pass integer and pointer arguments -indiscriminately to the same function, and use no prototype on any -system. For example, many GNU programs have error-reporting functions -that pass their arguments along to @code{printf} and friends: +@noindent Instead, use @code{unsigned char} as follows. (The @code{unsigned} +is for portability to unusual systems where @code{char} is signed and +where there is integer overflow checking.) @example -error (s, a1, a2, a3) - char *s; - char *a1, *a2, *a3; -@{ - fprintf (stderr, "error: "); - fprintf (stderr, s, a1, a2, a3); -@} +int c; +while ((c = getchar ()) != EOF) + @{ + unsigned char u = c; + write (file_descriptor, &u, 1); + @} @end example -@noindent -In practice, this works on all machines, since a pointer is generally -the widest possible kind of argument; it is much simpler than any -``correct'' alternative. Be sure @emph{not} to use a prototype for such -functions. +It used to be ok to not worry about the difference between pointers +and integers when passing arguments to functions. However, on most +modern 64-bit machines pointers are wider than @code{int}. +Conversely, integer types like @code{long long int} and @code{off_t} +are wider than pointers on most modern 32-bit machines. Hence it's +often better nowadays to use prototypes to define functions whose +argument types are not trivial. -If you have decided to use Standard C, then you can instead define -@code{error} using @file{stdarg.h}, and pass the arguments along to -@code{vfprintf}. +In particular, if functions accept varying argument counts or types +they should be declared using prototypes containing @samp{...} and +defined using @file{stdarg.h}. For an example of this, please see the +@uref{http://www.gnu.org/software/gnulib/, Gnulib} error module, which +declares and defines the following function: + +@example +/* Print a message with `fprintf (stderr, FORMAT, ...)'; + if ERRNUM is nonzero, follow it with ": " and strerror (ERRNUM). + If STATUS is nonzero, terminate the program with `exit (STATUS)'. */ + +void error (int status, int errnum, const char *format, ...); +@end example + +A simple way to use the Gnulib error module is to obtain the two +source files @file{error.c} and @file{error.h} from the Gnulib library +source code repository at +@uref{http://savannah.gnu.org/cgi-bin/viewcvs/gnulib/gnulib/lib/}. +Here's a sample use: + +@example +#include "error.h" +#include +#include + +char *program_name = "myprogram"; + +FILE * +xfopen (char const *name) +@{ + FILE *fp = fopen (name, "r"); + if (! fp) + error (1, errno, "cannot read %s", name); + return fp; +@} +@end example @cindex casting pointers to integers Avoid casting pointers to integers if you can. Such casts greatly @@ -2843,7 +3048,7 @@ Using GNU gettext in a package involves specifying a @dfn{text domain name} for the package. The text domain name is used to separate the translations for this package from the translations for other packages. Normally, the text domain name should be the same as the name of the -package---for example, @samp{fileutils} for the GNU file utilities. +package---for example, @samp{coreutils} for the GNU core utilities. @cindex message text, and internationalization To enable gettext to work well, avoid writing code that makes @@ -2855,45 +3060,31 @@ sentence framework. Here is an example of what not to do: -@example -printf ("%d file%s processed", nfiles, - nfiles != 1 ? "s" : ""); -@end example +@smallexample +printf ("%s is full", capacity > 5000000 ? "disk" : "floppy disk"); +@end smallexample + +If you apply gettext to all strings, like this, + +@smallexample +printf (gettext ("%s is full"), + capacity > 5000000 ? gettext ("disk") : gettext ("floppy disk")); +@end smallexample @noindent -The problem with that example is that it assumes that plurals are made -by adding `s'. If you apply gettext to the format string, like this, +the translator will hardly know that "disk" and "floppy disk" are meant to +be substituted in the other string. Worse, in some languages (like French) +the construction will not work: the translation of the word "full" depends +on the gender of the first part of the sentence; it happens to be not the +same for "disk" as for "floppy disk". + +Complete sentences can be translated without problems: @example -printf (gettext ("%d file%s processed"), nfiles, - nfiles != 1 ? "s" : ""); +printf (capacity > 5000000 ? gettext ("disk is full") + : gettext ("floppy disk is full")); @end example -@noindent -the message can use different words, but it will still be forced to use -`s' for the plural. Here is a better way: - -@example -printf ((nfiles != 1 ? "%d files processed" - : "%d file processed"), - nfiles); -@end example - -@noindent -This way, you can apply gettext to each of the two strings -independently: - -@example -printf ((nfiles != 1 ? gettext ("%d files processed") - : gettext ("%d file processed")), - nfiles); -@end example - -@noindent -This can be any method of forming the plural of the word for ``file'', and -also handles languages that require agreement in the word for -``processed''. - A similar problem appears at the level of sentence structure with this code: @@ -2906,7 +3097,7 @@ printf ("# Implicit rule search has%s been done.\n", Adding @code{gettext} calls to this code cannot give correct results for all languages, because negation in some languages requires adding words at more than one place in the sentence. By contrast, adding -@code{gettext} calls does the job straightfowardly if the code starts +@code{gettext} calls does the job straightforwardly if the code starts out like this: @example @@ -2915,6 +3106,100 @@ printf (f->tried_implicit : "# Implicit rule search has not been done.\n"); @end example +Another example is this one: + +@example +printf ("%d file%s processed", nfiles, + nfiles != 1 ? "s" : ""); +@end example + +@noindent +The problem with this example is that it assumes that plurals are made +by adding `s'. If you apply gettext to the format string, like this, + +@example +printf (gettext ("%d file%s processed"), nfiles, + nfiles != 1 ? "s" : ""); +@end example + +@noindent +the message can use different words, but it will still be forced to use +`s' for the plural. Here is a better way, with gettext being applied to +the two strings independently: + +@example +printf ((nfiles != 1 ? gettext ("%d files processed") + : gettext ("%d file processed")), + nfiles); +@end example + +@noindent +But this still doesn't work for languages like Polish, which has three +plural forms: one for nfiles == 1, one for nfiles == 2, 3, 4, 22, 23, 24, ... +and one for the rest. The GNU @code{ngettext} function solves this problem: + +@example +printf (ngettext ("%d files processed", "%d file processed", nfiles), + nfiles); +@end example + + +@node Character Set +@section Character Set +@cindex character set +@cindex encodings +@cindex ASCII characters +@cindex non-ASCII characters + +Sticking to the ASCII character set (plain text, 7-bit characters) is +preferred in GNU source code comments, text documents, and other +contexts, unless there is good reason to do something else because of +the application domain. For example, if source code deals with the +French Revolutionary calendar, it is OK if its literal strings contain +accented characters in month names like ``Flor@'eal''. Also, it is OK +to use non-ASCII characters to represent proper names of contributors in +change logs (@pxref{Change Logs}). + +If you need to use non-ASCII characters, you should normally stick with +one encoding, as one cannot in general mix encodings reliably. + + +@node Quote Characters +@section Quote Characters +@cindex quote characters +@cindex locale-specific quote characters +@cindex left quote +@cindex grave accent + +In the C locale, GNU programs should stick to plain ASCII for quotation +characters in messages to users: preferably 0x60 (@samp{`}) for left +quotes and 0x27 (@samp{'}) for right quotes. It is ok, but not +required, to use locale-specific quotes in other locales. + +The @uref{http://www.gnu.org/software/gnulib/, Gnulib} @code{quote} and +@code{quotearg} modules provide a reasonably straightforward way to +support locale-specific quote characters, as well as taking care of +other issues, such as quoting a filename that itself contains a quote +character. See the Gnulib documentation for usage details. + +In any case, the documentation for your program should clearly specify +how it does quoting, if different than the preferred method of @samp{`} +and @samp{'}. This is especially important if the output of your +program is ever likely to be parsed by another program. + +Quotation characters are a difficult area in the computing world at +this time: there are no true left or right quote characters in Latin1; +the @samp{`} character we use was standardized there as a grave +accent. Moreover, Latin1 is still not universally usable. + +Unicode contains the unambiguous quote characters required, and its +common encoding UTF-8 is upward compatible with Latin1. However, +Unicode and UTF-8 are not universally well-supported, either. + +This may change over the next few years, and then we will revisit +this. + + @node Mmap @section Mmap @findex mmap @@ -2949,7 +3234,7 @@ extending it, as well as just using it. * Manual Credits:: Giving credit to documentation contributors. * Printed Manuals:: Mentioning the printed manual. * NEWS File:: NEWS files supplement manuals. -* Change Logs:: Recording Changes +* Change Logs:: Recording changes. * Man Pages:: Man pages are secondary. * Reading other Manuals:: How far you can go in learning from other manuals. @@ -2971,20 +3256,26 @@ Nowadays some other formats such as Docbook and Sgmltexi can be converted automatically into Texinfo. It is ok to produce the Texinfo documentation by conversion this way, as long as it gives good results. -Programmers often find it most natural to structure the documentation -following the structure of the implementation, which they know. But -this structure is not necessarily good for explaining how to use the -program; it may be irrelevant and confusing for a user. +Make sure your manual is clear to a reader who knows nothing about the +topic and reads it straight through. This means covering basic topics +at the beginning, and advanced topics only later. This also means +defining every specialized term when it is first used. -At every level, from the sentences in a paragraph to the grouping of -topics into separate manuals, the right way to structure documentation -is according to the concepts and questions that a user will have in mind -when reading it. Sometimes this structure of ideas matches the +Programmers tend to carry over the structure of the program as the +structure for its documentation. But this structure is not +necessarily good for explaining how to use the program; it may be +irrelevant and confusing for a user. + +Instead, the right way to structure documentation is according to the +concepts and questions that a user will have in mind when reading it. +This principle applies at every level, from the lowest (ordering +sentences in a paragraph) to the highest (ordering of chapter topics +within the manual). Sometimes this structure of ideas matches the structure of the implementation of the software being documented---but -often they are different. Often the most important part of learning to -write good documentation is learning to notice when you are structuring -the documentation like the implementation, and think about better -alternatives. +often they are different. An important part of learning to write good +documentation is to learn to notice when you have unthinkingly +structured the documentation like the implementation, stop yourself, +and look for better alternatives. For example, each program in the GNU system probably ought to be documented in one manual; but this does not mean each program should @@ -3000,10 +3291,13 @@ together, we can make the whole subject clearer. The manual which discusses a program should certainly document all of the program's command-line options and all of its commands. It should -give examples of their use. But don't organize the manual as a list of -features. Instead, organize it logically, by subtopics. Address the -questions that a user will ask when thinking about the job that the -program does. +give examples of their use. But don't organize the manual as a list +of features. Instead, organize it logically, by subtopics. Address +the questions that a user will ask when thinking about the job that +the program does. Don't just tell the reader what each feature can +do---say what jobs it is good for, and show how to use it for those +jobs. Explain what is recommended usage, and what kinds of usage +users should avoid. In general, a GNU manual should serve both as tutorial and reference. It should be set up for convenient access to each topic through Info, @@ -3030,9 +3324,9 @@ functions, variables, options, and important concepts that are part of the program. One combined Index should do for a short manual, but sometimes for a complex package it is better to use multiple indices. The Texinfo manual includes advice on preparing good index entries, see -@ref{Index Entries, , Making Index Entries, texinfo, The GNU Texinfo -Manual}, and see @ref{Indexing Commands, , Defining the Entries of an -Index, texinfo, The GNU Texinfo manual}. +@ref{Index Entries, , Making Index Entries, texinfo, GNU Texinfo}, and +see @ref{Indexing Commands, , Defining the Entries of an +Index, texinfo, GNU Texinfo}. Don't use Unix man pages as a model for how to write GNU documentation; most of them are terse, badly structured, and give inadequate @@ -3041,15 +3335,19 @@ exceptions.) Also, Unix man pages use a particular format which is different from what we use in GNU manuals. Please include an email address in the manual for where to report -bugs @emph{in the manual}. +bugs @emph{in the text of the manual}. Please do not use the term ``pathname'' that is used in Unix documentation; use ``file name'' (two words) instead. We use the term ``path'' only for search paths, which are lists of directory names. -Please do not use the term ``illegal'' to refer to erroneous input to a -computer program. Please use ``invalid'' for this, and reserve the term -``illegal'' for activities punishable by law. +Please do not use the term ``illegal'' to refer to erroneous input to +a computer program. Please use ``invalid'' for this, and reserve the +term ``illegal'' for activities prohibited by law. + +Please do not write @samp{()} after a function name just to indicate +it is a function. @code{foo ()} is not a function, it is a function +call with no arguments. @node Doc Strings and Manuals @section Doc Strings and Manuals @@ -3072,7 +3370,7 @@ should often make some general points that apply to several functions or variables. The previous descriptions of functions and variables in the section will also have given information about the topic. A description written to stand alone would repeat some of that information; this -redundance looks bad. Meanwhile, the informality that is acceptable in +redundancy looks bad. Meanwhile, the informality that is acceptable in a documentation string is totally unacceptable in a manual. The only good way to use documentation strings in writing a good manual @@ -3092,7 +3390,7 @@ Each program documented in the manual should have a node named @samp{@var{program} Invocation} or @samp{Invoking @var{program}}. This node (together with its subnodes, if any) should describe the program's command line arguments and how to run it (the sort of information people -would look in a man page for). Start with an @samp{@@example} +would look for in a man page). Start with an @samp{@@example} containing a template for all the options and arguments that the program uses. @@ -3176,10 +3474,10 @@ inconsistencies between different parts of a program, by giving you a history of how the conflicting concepts arose and who they came from. @menu -* Change Log Concepts:: -* Style of Change Logs:: -* Simple Changes:: -* Conditional Changes:: +* Change Log Concepts:: +* Style of Change Logs:: +* Simple Changes:: +* Conditional Changes:: * Indicating the Part Changed:: @end menu @@ -3210,6 +3508,11 @@ code. For example, ``New function'' is enough for the change log when you add a function, because there should be a comment before the function definition to explain what it does. +In the past, we recommended not mentioning changes in non-software +files (manuals, help files, etc.) in change logs. However, we've been +advised that it is a good idea to include them, for the sake of +copyright records. + However, sometimes it is useful to write one line to describe the overall purpose of a batch of changes. @@ -3224,9 +3527,9 @@ Then describe the changes you made to that function or variable. @cindex change logs, style Here are some simple examples of change log entries, starting with the -header line that says who made the change and when, followed by -descriptions of specific changes. (These examples are drawn from Emacs -and GCC.) +header line that says who made the change and when it was installed, +followed by descriptions of specific changes. (These examples are +drawn from Emacs and GCC.) @example 1998-08-17 Richard Stallman @@ -3270,6 +3573,27 @@ Break long lists of function names by closing continued lines with (Fexecute_extended_command): Deal with `keymap' property. @end example +When you install someone else's changes, put the contributor's name in +the change log entry rather than in the text of the entry. In other +words, write this: + +@example +2002-07-14 John Doe + + * sewing.c: Make it sew. +@end example + +@noindent +rather than this: + +@example +2002-07-14 Usual Maintainer + + * sewing.c: Make it sew. Patch by jdoe@@gnu.org. +@end example + +As for the date, that should be the date you applied the change. + @node Simple Changes @subsection Simple Changes @@ -3291,12 +3615,17 @@ When you change just comments or doc strings, it is enough to write an entry for the file, without mentioning the functions. Just ``Doc fixes'' is enough for the change log. -There's no need to make change log entries for documentation files. -This is because documentation is not susceptible to bugs that are hard -to fix. Documentation does not consist of parts that must interact in a -precisely engineered fashion. To correct an error, you need not know -the history of the erroneous passage; it is enough to compare what the -documentation says with the way the program actually works. +There's no technical need to make change log entries for documentation +files. This is because documentation is not susceptible to bugs that +are hard to fix. Documentation does not consist of parts that must +interact in a precisely engineered fashion. To correct an error, you +need not know the history of the erroneous passage; it is enough to +compare what the documentation says with the way the program actually +works. + +However, you should keep change logs for documentation files when the +project gets copyright assignments from its contributors, so as to +make the records of authorship more accurate. @node Conditional Changes @subsection Conditional Changes @@ -3387,6 +3716,25 @@ page explaining that you don't maintain it and that the Texinfo manual is more authoritative. The note should say how to access the Texinfo documentation. +Be sure that man pages include a copyright statement and free +license. The simple all-permissive license is appropriate for simple +man pages: + +@example +Copying and distribution of this file, with or without modification, +are permitted in any medium without royalty provided the copyright +notice and this notice are preserved. +@end example + +For long man pages, with enough explanation and documentation that +they can be considered true manuals, use the GFDL (@pxref{License for +Manuals}). + +Finally, the GNU help2man program +(@uref{http://www.gnu.org/software/help2man/}) is one way to automate +generation of a man page, in this case from @option{--help} output. +This is sufficient in many cases. + @node Reading other Manuals @section Reading other Manuals @@ -3415,9 +3763,9 @@ makes it easy to include your package into the larger framework of all GNU software. @menu -* Configuration:: How Configuration Should Work -* Makefile Conventions:: Makefile Conventions -* Releases:: Making Releases +* Configuration:: How configuration of GNU packages should work. +* Makefile Conventions:: Makefile conventions. +* Releases:: Making releases @end menu @node Configuration @@ -3486,23 +3834,31 @@ this: @var{cpu}-@var{company}-@var{system} @end example -For example, a Sun 3 might be @samp{m68k-sun-sunos4.1}. +For example, an Athlon-based GNU/Linux system might be +@samp{i686-pc-linux-gnu}. The @code{configure} script needs to be able to decode all plausible -alternatives for how to describe a machine. Thus, @samp{sun3-sunos4.1} -would be a valid alias. For many programs, @samp{vax-dec-ultrix} would -be an alias for @samp{vax-dec-bsd}, simply because the differences -between Ultrix and @sc{bsd} are rarely noticeable, but a few programs -might need to distinguish them. -@c Real 4.4BSD now runs on some Suns. +alternatives for how to describe a machine. Thus, +@samp{athlon-pc-gnu/linux} would be a valid alias. There is a shell +script called +@uref{http://savannah.gnu.org/@/cgi-bin/@/viewcvs/@/*checkout*/@/config/@/config/@/config.sub, +@file{config.sub}} that you can use as a subroutine to validate system +types and canonicalize aliases. -There is a shell script called @file{config.sub} that you can use -as a subroutine to validate system types and canonicalize aliases. +The @code{configure} script should also take the option +@option{--build=@var{buildtype}}, which should be equivalent to a +plain @var{buildtype} argument. For example, @samp{configure +--build=i686-pc-linux-gnu} is equivalent to @samp{configure +i686-pc-linux-gnu}. When the build type is not specified by an option +or argument, the @code{configure} script should normally guess it using +the shell script +@uref{http://savannah.gnu.org/@/cgi-bin/@/viewcvs/@/*checkout*/@/config/@/config/@/config.guess, +@file{config.guess}}. @cindex optional features, configure-time Other options are permitted to specify in more detail the software -or hardware present on the machine, and include or exclude optional -parts of the package: +or hardware present on the machine, to include or exclude optional parts +of the package, or to adjust the name of some tools or arguments to them: @table @samp @item --enable-@var{feature}@r{[}=@var{parameter}@r{]} @@ -3535,14 +3891,32 @@ and Do not use a @samp{--with} option to specify the file name to use to find certain files. That is outside the scope of what @samp{--with} options are for. + +@item @var{variable}=@var{value} +Set the value of the variable @var{variable} to @var{value}. This is +used to override the default values of commands or arguments in the +build process. For example, the user could issue @samp{configure +CFLAGS=-g CXXFLAGS=-g} to build with debugging information and without +the default optimization. + +Specifying variables as arguments to @code{configure}, like this: +@example +./configure CC=gcc +@end example +is preferable to setting them in environment variables: +@example +CC=gcc ./configure +@end example +as it helps to recreate the same configuration later with +@file{config.status}. @end table -All @code{configure} scripts should accept all of these ``detail'' -options, whether or not they make any difference to the particular -package at hand. In particular, they should accept any option that -starts with @samp{--with-} or @samp{--enable-}. This is so users will -be able to configure an entire GNU source tree at once with a single set -of options. +All @code{configure} scripts should accept all of the ``detail'' +options and the variable settings, whether or not they make any +difference to the particular package at hand. In particular, they +should accept any option that starts with @samp{--with-} or +@samp{--enable-}. This is so users will be able to configure an +entire GNU source tree at once with a single set of options. You will note that the categories @samp{--with-} and @samp{--enable-} are narrow: they @strong{do not} provide a place for any sort of option @@ -3558,6 +3932,11 @@ The @code{configure} script should normally treat the specified type of system as both the host and the target, thus producing a program which works for the same type of machine that it runs on. +To compile a program to run on a host type that differs from the build +type, use the configure option @option{--host=@var{hosttype}}, where +@var{hosttype} uses the same syntax as @var{buildtype}. The host type +normally defaults to the build type. + To configure a cross-compiler, cross-assembler, or what have you, you should specify a target different from the host, using the configure option @samp{--target=@var{targettype}}. The syntax for @@ -3565,22 +3944,14 @@ option @samp{--target=@var{targettype}}. The syntax for look like this: @example -./configure @var{hosttype} --target=@var{targettype} +./configure --host=@var{hosttype} --target=@var{targettype} @end example +The target type normally defaults to the host type. Programs for which cross-operation is not meaningful need not accept the @samp{--target} option, because configuring an entire operating system for cross-operation is not a meaningful operation. -Bootstrapping a cross-compiler requires compiling it on a machine other -than the host it will run on. Compilation packages accept a -configuration option @samp{--build=@var{buildtype}} for specifying the -configuration on which you will compile them, but the configure script -should normally guess the build machine type (using -@file{config.guess}), so this option is probably not necessary. The -host and target types normally default from the build type, so in -bootstrapping a cross-compiler you must specify them both explicitly. - Some programs have ways of configuring themselves automatically. If your program is set up to do this, your @code{configure} script can simply ignore most of its arguments. @@ -3596,6 +3967,10 @@ ignore most of its arguments. @section Making Releases @cindex packaging +You should identify each release with a pair of version numbers, a +major version and a minor. We have no objection to using more than +two numbers, but it is very unlikely that you really need them. + Package the distribution of @code{Foo version 69.96} up in a gzipped tar file with the name @file{foo-69.96.tar.gz}. It should unpack into a subdirectory named @file{foo-69.96}. @@ -3644,13 +4019,6 @@ able to extract all the files even if the user is unprivileged. Make sure that all the files in the distribution are world-readable. -Make sure that no file name in the distribution is more than 14 -characters long. Likewise, no file created by building the program -should have a name longer than 14 characters. The reason for this is -that some systems adhere to a foolish interpretation of the @sc{posix} -standard, and refuse to open a longer name, rather than truncating as -they did in the past. - Don't include any symbolic links in the distribution itself. If the tar file contains symbolic links, then people cannot even unpack it on systems that don't support symbolic links. Also, don't use multiple @@ -3682,16 +4050,29 @@ other files to get. A GNU program should not recommend use of any non-free program. We can't stop some people from writing proprietary programs, or stop -other people from using them, but we can and should avoid helping to +other people from using them, but we can and should refuse to advertise them to new potential customers. Proprietary software is a social and ethical problem, and the point of GNU is to solve that problem. +The GNU definition of free software is found on the GNU web site at +@url{http://www.gnu.org/philosophy/free-sw.html}, and the definition +of free documentation is found at +@url{http://www.gnu.org/philosophy/free-doc.html}. A list of +important licenses and whether they qualify as free is in +@url{http://www.gnu.org/@/licenses/@/license-list.html}. The terms +``free'' and ``non-free'', used in this document, refer to that +definition. If it is not clear whether a license qualifies as free +under this definition, please ask the GNU Project by writing to +@email{licensing@@gnu.org}. We will answer, and if the license is an +important one, we will add it to the list. + When a non-free program or system is well known, you can mention it in passing---that is harmless, since users who might want to use it probably already know about it. For instance, it is fine to explain -how to build your package on top of some non-free operating system, or -how to use it together with some widely used non-free program. +how to build your package on top of some widely used non-free +operating system, or how to use it together with some widely used +non-free program. However, you should give only the necessary information to help those who already use the non-free program to use your program with @@ -3700,8 +4081,8 @@ proprietary program, and don't imply that the proprietary program enhances your program, or that its existence is in any way a good thing. The goal should be that people already using the proprietary program will get the advice they need about how to use your free -program, while people who don't already use the proprietary program -will not see anything to lead them to take an interest in it. +program with it, while people who don't already use the proprietary +program will not see anything to lead them to take an interest in it. If a non-free program or system is obscure in your program's domain, your program should not mention or support it at all, since doing so @@ -3709,34 +4090,78 @@ would tend to popularize the non-free program more than it popularizes your program. (You cannot hope to find many additional users among the users of Foobar if the users of Foobar are few.) +Sometimes a program is free software in itself but depends on a +non-free platform in order to run. For instance, many Java programs +depend on the parts of Sun's Java implementation which are not yet +free software, and won't run on the GNU Java Compiler (which does not +yet have all the features) or won't run with the GNU Java libraries. +We hope this particular problem will be gone in a few months, when Sun +makes the standard Java libraries free software, but of course the +general principle remains: you should not recommend programs that +depend on non-free software to run. + +Some free programs encourage the use of non-free software. A typical +example is @command{mplayer}. It is free software in itself, and the +free code can handle some kinds of files. However, @command{mplayer} +recommends use of non-free codecs for other kinds of files, and users +that install @command{mplayer} are very likely to install those codecs +along with it. To recommend @command{mplayer} is, in effect, to +recommend the non-free codecs. We must not do that, so we cannot +recommend @command{mplayer} either. + +In general, you should also not recommend programs that themselves +strongly recommend the use of non-free software. + A GNU package should not refer the user to any non-free documentation for free software. Free documentation that can be included in free -operating systems is essential for completing the GNU system, so it is -a major focus of the GNU Project; to recommend use of documentation -that we are not allowed to use in GNU would undermine the efforts to -get documentation that we can include. So GNU packages should never -recommend non-free documentation. +operating systems is essential for completing the GNU system, or any +free operating system, so it is a major focus of the GNU Project; to +recommend use of documentation that we are not allowed to use in GNU +would weaken the impetus for the community to produce documentation +that we can include. So GNU packages should never recommend non-free +documentation. -@node Copying This Manual -@appendix Copying This Manual +By contrast, it is ok to refer to journal articles and textbooks in +the comments of a program for explanation of how it functions, even +though they be non-free. This is because we don't include such things +in the GNU system even if we are allowed to---they are outside the +scope of an operating system project. -@menu -* GNU Free Documentation License:: License for copying this manual -@end menu +Referring to a web site that describes or recommends a non-free +program is in effect promoting that software, so please do not make +links (or mention by name) web sites that contain such material. This +policy is relevant particularly for the web pages for a GNU package. +Following links from nearly any web site can lead to non-free +software; this is an inescapable aspect of the nature of the web, and +in itself is no objection to linking to a site. As long as the site +does not itself recommend a non-free program, there is no need be +concerned about the sites it links to for other reasons. + +Thus, for example, you should not make a link to AT&T's web site, +because that recommends AT&T's non-free software packages; you should +not make a link to a site that links to AT&T's site saying it is a +place to get a non-free program; but if a site you want to link to +refers to AT&T's web site in some other context (such as long-distance +telephone service), that is not a problem. + + +@node GNU Free Documentation License +@appendix GNU Free Documentation License + +@cindex FDL, GNU Free Documentation License @include fdl.texi @node Index @unnumbered Index @printindex cp -@contents - @bye -@c Local variables: -@c eval: (add-hook 'write-file-hooks 'time-stamp) -@c time-stamp-start: "@set lastupdate " -@c time-stamp-end: "$" -@c time-stamp-format: "%:b %:d, %:y" -@c compile-command: "make just-standards" -@c End: + +Local variables: +eval: (add-hook 'write-file-hooks 'time-stamp) +time-stamp-start: "@set lastupdate " +time-stamp-end: "$" +time-stamp-format: "%:b %:d, %:y" +compile-command: "make just-standards" +End: