📄 make-stds.texi
字号:
$(DESTDIR)$(infodir)/foo.info; \ else true; fi@end smallexampleWhen writing the @code{install} target, you must classify all thecommands into three categories: normal ones, @dfn{pre-installation}commands and @dfn{post-installation} commands. @xref{Install CommandCategories}.@item install-html@itemx install-dvi@itemx install-pdf@itemx install-psThese targets install documentation in formats other than Info;they're intended to be called explicitly by the person installing thepackage, if that format is desired. GNU prefers Info files, so thesemust be installed by the @code{install} target.When you have many documentation files to install, we recommend thatyou avoid collisions and clutter by arranging for these targets toinstall in subdirectories of the appropriate installation directory,such as @code{htmldir}. As one example, if your package has multiplemanuals, and you wish to install HTML documentation with many files(such as the ``split'' mode output by @code{makeinfo --html}), you'llcertainly want to use subdirectories, or two nodes with the same namein different manuals will overwrite each other.@item uninstallDelete all the installed files---the copies that the @samp{install}and @samp{install-*} targets create.This rule should not modify the directories where compilation is done,only the directories where files are installed.The uninstallation commands are divided into three categories, just likethe installation commands. @xref{Install Command Categories}.@item install-stripLike @code{install}, but strip the executable files while installingthem. In simple cases, this target can use the @code{install} target ina simple way:@smallexampleinstall-strip: $(MAKE) INSTALL_PROGRAM='$(INSTALL_PROGRAM) -s' \ install@end smallexampleBut if the package installs scripts as well as real executables, the@code{install-strip} target can't just refer to the @code{install}target; it has to strip the executables but not the scripts.@code{install-strip} should not strip the executables in the builddirectory which are being copied for installation. It should only stripthe copies that are installed.Normally we do not recommend stripping an executable unless you are surethe program has no bugs. However, it can be reasonable to install astripped executable for actual execution while saving the unstrippedexecutable elsewhere in case there is a bug.@comment The gratuitous blank line here is to make the table look better@comment in the printed Make manual. Please leave it in.@item cleanDelete all files in the current directory that are normally created bybuilding the program. Also delete files in other directories if theyare created by this makefile. However, don't delete the files thatrecord the configuration. Also preserve files that could be made bybuilding, but normally aren't because the distribution comes withthem. There is no need to delete parent directories that were createdwith @samp{mkdir -p}, since they could have existed anyway.Delete @file{.dvi} files here if they are not part of the distribution.@item distcleanDelete all files in the current directory (or created by thismakefile) that are created by configuring or building the program. Ifyou have unpacked the source and built the program without creatingany other files, @samp{make distclean} should leave only the filesthat were in the distribution. However, there is no need to deleteparent directories that were created with @samp{mkdir -p}, since theycould have existed anyway.@item mostlycleanLike @samp{clean}, but may refrain from deleting a few files that peoplenormally don't want to recompile. For example, the @samp{mostlyclean}target for GCC does not delete @file{libgcc.a}, because recompiling itis rarely necessary and takes a lot of time.@item maintainer-cleanDelete almost everything that can be reconstructed with this Makefile.This typically includes everything deleted by @code{distclean}, plusmore: C source files produced by Bison, tags tables, Info files, andso on.The reason we say ``almost everything'' is that running the command@samp{make maintainer-clean} should not delete @file{configure} evenif @file{configure} can be remade using a rule in the Makefile. Moregenerally, @samp{make maintainer-clean} should not delete anythingthat needs to exist in order to run @file{configure} and then begin tobuild the program. Also, there is no need to delete parentdirectories that were created with @samp{mkdir -p}, since they couldhave existed anyway. These are the only exceptions;@code{maintainer-clean} should delete everything else that can berebuilt.The @samp{maintainer-clean} target is intended to be used by a maintainer ofthe package, not by ordinary users. You may need special tools toreconstruct some of the files that @samp{make maintainer-clean} deletes.Since these files are normally included in the distribution, we don'ttake care to make them easy to reconstruct. If you find you need tounpack the full distribution again, don't blame us.To help make users aware of this, the commands for the special@code{maintainer-clean} target should start with these two:@smallexample@@echo 'This command is intended for maintainers to use; it'@@echo 'deletes files that may need special tools to rebuild.'@end smallexample@item TAGSUpdate a tags table for this program.@c ADR: how?@item infoGenerate any Info files needed. The best way to write the rules is asfollows:@smallexampleinfo: foo.infofoo.info: foo.texi chap1.texi chap2.texi $(MAKEINFO) $(srcdir)/foo.texi@end smallexample@noindentYou must define the variable @code{MAKEINFO} in the Makefile. It shouldrun the @code{makeinfo} program, which is part of the Texinfodistribution.Normally a GNU distribution comes with Info files, and that means theInfo files are present in the source directory. Therefore, the Makerule for an info file should update it in the source directory. Whenusers build the package, ordinarily Make will not update the Info filesbecause they will already be up to date.@item dvi@itemx html@itemx pdf@itemx psGenerate documentation files in the given format, if possible.Here's an example rule for generating DVI files from Texinfo:@smallexampledvi: foo.dvifoo.dvi: foo.texi chap1.texi chap2.texi $(TEXI2DVI) $(srcdir)/foo.texi@end smallexample@noindentYou must define the variable @code{TEXI2DVI} in the Makefile. It shouldrun the program @code{texi2dvi}, which is part of the Texinfodistribution.@footnote{@code{texi2dvi} uses @TeX{} to do the real workof 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:@smallexamplehtml: foo.htmlfoo.html: foo.texi chap1.texi chap2.texi $(TEXI2HTML) $(srcdir)/foo.texi@end smallexample@noindentAgain, 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 distCreate a distribution tar file for this program. The tar file should beset up so that the file names in the tar file start with a subdirectoryname which is the name of the package it is a distribution for. Thisname can include the version number.For example, the distribution tar file of GCC version 1.40 unpacks intoa subdirectory named @file{gcc-1.40}.The easiest way to do this is to create a subdirectory appropriatelynamed, use @code{ln} or @code{cp} to install the proper files in it, andthen @code{tar} that subdirectory.Compress the tar file with @code{gzip}. For example, the actualdistribution file for GCC version 1.40 is called @file{gcc-1.40.tar.gz}.The @code{dist} target should explicitly depend on all non-source filesthat are in the distribution, to make sure they are up to date in thedistribution.@ifset CODESTD@xref{Releases, , Making Releases}.@end ifset@ifclear CODESTD@xref{Releases, , Making Releases, standards, GNU Coding Standards}.@end ifclear@item checkPerform self-tests (if any). The user must build the program beforerunning the tests, but need not install the program; you should writethe self-tests so that they work when the program is built but notinstalled.@end tableThe following targets are suggested as conventional names, for programsin which they are useful.@table @code@item installcheckPerform installation tests (if any). The user must build and installthe program before running the tests. You should not assume that@file{$(bindir)} is in the search path.@item installdirsIt's useful to add a target named @samp{installdirs} to create thedirectories where files are installed, and their parent directories.There is a script called @file{mkinstalldirs} which is convenient forthis; you can find it in the Texinfo package.@c It's in /gd/gnu/lib/mkinstalldirs.You can use a rule like this:@comment This has been carefully formatted to look decent in the Make manual.@comment Please be sure not to make it extend any further to the right.--roland@smallexample# Make sure all installation directories (e.g. $(bindir))# actually exist by making them if necessary.installdirs: mkinstalldirs $(srcdir)/mkinstalldirs $(bindir) $(datadir) \ $(libdir) $(infodir) \ $(mandir)@end smallexample@noindentor, if you wish to support @env{DESTDIR},@smallexample# Make sure all installation directories (e.g. $(bindir))# actually exist by making them if necessary.installdirs: mkinstalldirs $(srcdir)/mkinstalldirs \ $(DESTDIR)$(bindir) $(DESTDIR)$(datadir) \ $(DESTDIR)$(libdir) $(DESTDIR)$(infodir) \ $(DESTDIR)$(mandir)@end smallexampleThis rule should not modify the directories where compilation is done.It should do nothing but create installation directories.@end table@node Install Command Categories@section Install Command Categories@cindex pre-installation commands@cindex post-installation commandsWhen writing the @code{install} target, you must classify all thecommands into three categories: normal ones, @dfn{pre-installation}commands and @dfn{post-installation} commands.Normal commands move files into their proper places, and set theirmodes. They may not alter any files except the ones that come entirelyfrom the package they belong to.Pre-installation and post-installation commands may alter other files;in particular, they can edit global configuration files or data bases.Pre-installation commands are typically executed before the normalcommands, and post-installation commands are typically run after thenormal commands.The most common use for a post-installation command is to run@code{install-info}. This cannot be done with a normal command, sinceit alters a file (the Info directory) which does not come entirely andsolely from the package being installed. It is a post-installationcommand because it needs to be done after the normal command whichinstalls the package's Info files.Most programs don't need any pre-installation commands, but we have thefeature just in case it is needed.To classify the commands in the @code{install} rule into these threecategories, insert @dfn{category lines} among them. A category linespecifies the category for the commands that follow.A category line consists of a tab and a reference to a special Makevariable, plus an optional comment at the end. There are threevariables you can use, one for each category; the variable namespecifies the category. Category lines are no-ops in ordinary executionbecause these three Make variables are normally undefined (and you@emph{should not} define them in the makefile).Here are the three possible category lines, each with a comment thatexplains what it means:@smallexample $(PRE_INSTALL) # @r{Pre-install commands follow.} $(POST_INSTALL) # @r{Post-install commands follow.} $(NORMAL_INSTALL) # @r{Normal commands follow.}@end smallexampleIf you don't use a category line at the beginning of the @code{install}rule, all the commands are classified as normal until the first categoryline. If you don't use any category lines, all the commands areclassified as normal.These are the category lines for @code{uninstall}:@smallexample $(PRE_UNINSTALL) # @r{Pre-uninstall commands follow.} $(POST_UNINSTALL) # @r{Post-uninstall commands follow.} $(NORMAL_UNINSTALL) # @r{Normal commands follow.}@end smallexampleTypically, a pre-uninstall command would be used for deleting entriesfrom the Info directory.If the @code{install} or @code{uninstall} target has any dependencieswhich act as subroutines of installation, then you should start@emph{each} dependency's commands with a category line, and start themain target's commands with a category line also. This way, you canensure that each command is placed in the right category regardless ofwhich of the dependencies actually run.Pre-installation and post-installation commands should not run anyprograms except for these:@example[ basename bash cat chgrp chmod chown cmp cp dd diff echoegrep expand expr false fgrep find getopt grep gunzip gziphostname install install-info kill ldconfig ln ls md5summkdir mkfifo mknod mv printenv pwd rm rmdir sed sort teetest touch true uname xargs yes@end example@cindex binary packagesThe reason for distinguishing the commands in this way is for the sakeof making binary packages. Typically a binary package contains all theexecutables and other files that need to be installed, and has its ownmethod of installing them---so it does not need to run the normalinstallation commands. But installing the binary package does need toexecute the pre-installation and post-installation commands.Programs to build binary packages work by extracting thepre-installation and post-installation commands. Here is one way ofextracting the pre-installation commands (the @option{-s} option to@command{make} is needed to silence messages about enteringsubdirectories):@smallexamplemake -s -n install -o all \ PRE_INSTALL=pre-install \ POST_INSTALL=post-install \ NORMAL_INSTALL=normal-install \ | gawk -f pre-install.awk@end smallexample@noindentwhere the file @file{pre-install.awk} could contain this:@smallexample$0 ~ /^(normal-install|post-install)[ \t]*$/ @{on = 0@}on @{print $0@}$0 ~ /^pre-install[ \t]*$/ @{on = 1@}@end smallexample
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -