📄 make-stds.texi
字号:
(If you are using Autoconf, write it as @samp{@@exec_prefix@@}.)Generally, @code{$(exec_prefix)} is used for directories that containmachine-specific files (such as executables and subroutine libraries),while @code{$(prefix)} is used directly for other directories.Running @samp{make install} with a different value of @code{exec_prefix}from the one used to build the program should @var{not} recompile theprogram.@end tableExecutable programs are installed in one of the following directories.@table @samp@item bindirThe directory for installing executable programs that users can run.This should normally be @file{/usr/local/bin}, but write it as@file{$(exec_prefix)/bin}.(If you are using Autoconf, write it as @samp{@@bindir@@}.)@item sbindirThe directory for installing executable programs that can be run fromthe shell, but are only generally useful to system administrators. Thisshould normally be @file{/usr/local/sbin}, but write it as@file{$(exec_prefix)/sbin}.(If you are using Autoconf, write it as @samp{@@sbindir@@}.)@item libexecdir@comment This paragraph adjusted to avoid overfull hbox --roland 5jul94The directory for installing executable programs to be run by otherprograms 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@@}.)@end tableData files used by the program during its execution are divided intocategories in two ways.@itemize @bullet@itemSome files are normally modified by programs; others are never normallymodified (though users may edit some of these).@itemSome files are architecture-independent and can be shared by allmachines at a site; some are architecture-dependent and can be sharedonly by machines of the same kind and operating system; others may neverbe shared between two machines.@end itemizeThis makes for six different possibilities. However, we want todiscourage the use of architecture-dependent files, aside from objectfiles and libraries. It is much cleaner to make other data filesarchitecture-independent, and it is generally not hard.Therefore, here are the variables Makefiles should use to specifydirectories:@table @samp@item datadirThe directory for installing read-only architecture independent datafiles. 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.@item sysconfdirThe directory for installing read-only data files that pertain to asingle machine--that is to say, files for configuring a host. Mailerand network configuration files, @file{/etc/passwd}, and so forth belonghere. All the files in this directory should be ordinary ASCII textfiles. This directory should normally be @file{/usr/local/etc}, butwrite it as @file{$(prefix)/etc}.(If you are using Autoconf, write it as @samp{@@sysconfdir@@}.)Do not install executables here in this directory (they probably belongin @file{$(libexecdir)} or @file{$(sbindir)}). Also do not installfiles that are modified in the normal course of their use (programswhose purpose is to change the configuration of the system excluded).Those probably belong in @file{$(localstatedir)}.@item sharedstatedirThe directory for installing architecture-independent data files whichthe programs modify while they run. This should normally be@file{/usr/local/com}, but write it as @file{$(prefix)/com}.(If you are using Autoconf, write it as @samp{@@sharedstatedir@@}.)@item localstatedirThe directory for installing data files which the programs modify whilethey run, and that pertain to one specific machine. Users should neverneed to modify files in this directory to configure the package'soperation; put such configuration information in separate files that goin @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@@}.)@item libdirThe directory for object files and libraries of object code. Do notinstall 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 infodirThe directory for installing the Info files for this package. Bydefault, it should be @file{/usr/local/info}, but it should be writtenas @file{$(prefix)/info}.(If you are using Autoconf, write it as @samp{@@infodir@@}.)@item lispdirThe directory for installing any Emacs Lisp files in this package. Bydefault, it should be @file{/usr/local/share/emacs/site-lisp}, but itshould 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 linesin your @file{configure.in} file:@examplelispdir='$@{datadir@}/emacs/site-lisp'AC_SUBST(lispdir)@end example@item includedir@c rewritten to avoid overfull hbox --rolandThe directory for installing header files to be included by userprograms with the C @samp{#include} preprocessor directive. Thisshould normally be @file{/usr/local/include}, but write it as@file{$(prefix)/include}.(If you are using Autoconf, write it as @samp{@@includedir@@}.)Most compilers other than GCC do not look for header files in directory@file{/usr/local/include}. So installing the header files this way isonly useful with GCC. Sometimes this is not a problem because somelibraries are only really intended to work with GCC. But some librariesare intended to work with other compilers. They should install theirheader files in two places, one specified by @code{includedir} and onespecified by @code{oldincludedir}.@item oldincludedirThe directory for installing @samp{#include} header files for use withcompilers other than GCC. This should normally be @file{/usr/include}.(If you are using Autoconf, you can write it as @samp{@@oldincludedir@@}.)The Makefile commands should check whether the value of@code{oldincludedir} is empty. If it is, they should not try to useit; they should cancel the second installation of the header files.A package should not replace an existing header in this directory unlessthe header came from the same package. Thus, if your Foo packageprovides a header file @file{foo.h}, then it should install the headerfile in the @code{oldincludedir} directory if either (1) there is no@file{foo.h} there or (2) the @file{foo.h} that exists came from the Foopackage.To tell whether @file{foo.h} came from the Foo package, put a magicstring in the file---part of a comment---and @code{grep} for that string.@end tableUnix-style man pages are installed in one of the following:@table @samp@item mandirThe top-level directory for installing the man pages (if any) for thispackage. It will normally be @file{/usr/local/man}, but you shouldwrite it as @file{$(prefix)/man}.(If you are using Autoconf, write it as @samp{@@mandir@@}.)@item man1dirThe directory for installing section 1 man pages. Write it as@file{$(mandir)/man1}.@item man2dirThe directory for installing section 2 man pages. Write it as@file{$(mandir)/man2}@item @dots{}@strong{Don't make the primary documentation for any GNU software be aman page. Write a manual in Texinfo instead. Man pages are just forthe sake of people running GNU software on Unix, which is a secondaryapplication only.}@item manextThe file name extension for the installed man page. This should containa period followed by the appropriate digit; it should normally be @samp{.1}.@item man1extThe file name extension for installed section 1 man pages.@item man2extThe file name extension for installed section 2 man pages.@item @dots{}Use these names instead of @samp{manext} if the package needs to install manpages in more than one section of the manual.@end tableAnd finally, you should set the following variable:@table @samp@item srcdirThe directory for the sources being compiled. The value of thisvariable is normally inserted by the @code{configure} shell script.(If you are using Autconf, use @samp{srcdir = @@srcdir@@}.)@end tableFor example:@smallexample@c I have changed some of the comments here slightly to fix an overfull@c hbox, so the make manual can format correctly. --roland# Common prefix for installation directories.# NOTE: This directory must exist when you start the install.prefix = /usr/localexec_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@end smallexampleIf your program installs a large number of files into one of thestandard user-specified directories, it might be useful to group theminto a subdirectory particular to that program. If you do this, youshould write the @code{install} rule to create these subdirectories.Do not expect the user to include the subdirectory name in the value ofany of the variables listed above. The idea of having a uniform set ofvariable names for installation directories is to enable the user tospecify the exact same values for several different GNU packages. Inorder for this to be useful, all the packages must be designed so thatthey will work sensibly when the user does so.@node Standard Targets@section Standard Targets for UsersAll GNU programs should have the following targets in their Makefiles:@table @samp@item allCompile the entire program. This should be the default target. Thistarget need not rebuild any documentation files; Info files shouldnormally be included in the distribution, and DVI files should be madeonly when explicitly asked for.By default, the Make rules should compile and link with @samp{-g}, sothat executable programs have debugging symbols. Users who don't mindbeing helpless can strip the executables later if they wish.@item installCompile the program and copy the executables, libraries, and so on tothe file names where they should reside for actual use. If there is asimple test to verify that a program is properly installed, this targetshould run that test.Do not strip executables when installing them. Devil-may-care users canuse the @code{install-strip} target to do that.If possible, write the @code{install} target rule so that it does notmodify anything in the directory where the program was built, provided@samp{make all} has just been done. This is convenient for building theprogram under one user name and installing it under another.The commands should create all the directories in which files are to beinstalled, if they don't already exist. This includes the directoriesspecified as the values of the variables @code{prefix} and@code{exec_prefix}, as well as all subdirectories that are needed.One way to do this is by means of an @code{installdirs} targetas described below.Use @samp{-} before any command for installing a man page, so that@code{make} will ignore any errors. This is in case there are systemsthat don't have the Unix man page documentation system installed.The way to install Info files is to copy them into @file{$(infodir)}with @code{$(INSTALL_DATA)} (@pxref{Command Variables}), and then runthe @code{install-info} program if it is present. @code{install-info}is a program that edits the Info @file{dir} file to add or update themenu 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.@smallexample$(DESTDIR)$(infodir)/foo.info: foo.info $(POST_INSTALL)# There may be a newer info file in . than in srcdir. -if test -f foo.info; then d=.; \ else d=$(srcdir); fi; \ $(INSTALL_DATA) $$d/foo.info $(DESTDIR)$@@; \# Run install-info only if it exists.# Use `if' instead of just prepending `-' to the# line so we notice real errors from install-info.# We use `$(SHELL) -c' because some shells do not# fail gracefully when there is an unknown command. if $(SHELL) -c 'install-info --version' \ >/dev/null 2>&1; then \ install-info --dir-file=$(DESTDIR)$(infodir)/dir \ $(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}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -