⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 standards.texi

📁 早期freebsd实现
💻 TEXI
📖 第 1 页 / 共 4 页
字号:
Delete @file{.dvi} files here if they are not part of the distribution.@item distcleanDelete all files from the current directory that are created byconfiguring or building the program.  If you have unpacked the sourceand built the program without creating any other files, @samp{makedistclean} should leave only the files that were in the distribution.@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 realcleanDelete everything from the current directory that can be reconstructedwith this Makefile.  This typically includes everything deleted bydistclean, plus more: C source files produced by Bison, tags tables,info files, and so on.@item TAGSUpdate a tags table for this program.@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.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.  @xref{Releases}.@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 table@node Command Variables@section Variables for Specifying CommandsMakefiles should provide variables for overriding certain commands, options,and so on.In particular, you should run most utility programs via variables.Thus, if you use Bison, have a variable named @code{BISON} whose defaultvalue is set with @samp{BISON = bison}, and refer to it with@code{$(BISON)} whenever you need to use Bison.File management utilities such as @code{ln}, @code{rm}, @code{mv}, andso on, need not be referred to through variables in this way, since usersdon't need to replace them with other programs.Each program-name variable should come with an options variable that isused to supply options to the program.  Append @samp{FLAGS} to theprogram-name variable name to get the options variable name---forexample, @code{BISONFLAGS}.  (The name @code{CFLAGS} is an exception tothis rule, but we keep it because it is standard.)  Use @code{CPPFLAGS}in any compilation command that runs the preprocessor, and use@code{LDFLAGS} in any compilation command that does linking as well asin any direct use of @code{ld}.If there are C compiler options that @emph{must} be used for propercompilation of certain files, do not include them in @code{CFLAGS}.Users expect to be able to specify @code{CFLAGS} freely themselves.Instead, arrange to pass the necessary options to the C compilerindependently of @code{CFLAGS}, by writing them explicitly in thecompilation commands or by defining an implicit rule, like this:@exampleCFLAGS = -gALL_CFLAGS = $(CFLAGS) -I..c.o:	$(CC) -c $(ALL_CFLAGS) $(CPPFLAGS) $<@end exampleDo include the @samp{-g} option in @code{CFLAGS}, because that is not@emph{required} for proper compilation.  You can consider it a defaultthat is only recommended.  If the package is set up so that it iscompiled with GCC by default, then you might as well include @samp{-O}in the default value of @code{CFLAGS} as well.Every Makefile should define the variable @code{INSTALL}, which is thebasic command for installing a file into the system.Every Makefile should also define variables @code{INSTALL_PROGRAM} and@code{INSTALL_DATA}.  (The default for each of these should be@code{$(INSTALL)}.)  Then it should use those variables as the commandsfor actual installation, for executables and nonexecutablesrespectively.  Use these variables as follows:@example$(INSTALL_PROGRAM) foo $(bindir)/foo$(INSTALL_DATA) libfoo.a $(libdir)/libfoo.a@end example@noindentAlways use a file name, not a directory name, as the second argument ofthe installation commands.  Use a separate command for each file to beinstalled.@node Directory Variables@section Variables for Installation DirectoriesInstallation directories should always be named by variables, so it iseasy to install in a nonstandard place.  The standard names for thesevariables are:@table @samp@item prefixA prefix used in constructing the default values of the variables listedbelow.  The default value of @code{prefix} should be @file{/usr/local}(at least for now).@item exec_prefixA prefix used in constructing the default values of the some of thevariables listed below.  The default value of @code{exec_prefix} shouldbe @code{$(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.@item bindirThe directory for installing executable programs that users can run.This should normally be @file{/usr/local/bin}, but it should be writtenas @file{$(exec_prefix)/bin}.@item libdirThe directory for installing executable files to be run by the programrather than by users.  Object files and libraries of object code shouldalso go in this directory.  The idea is that this directory is used forfiles that pertain to a specific machine architecture, but need not bein the path for commands.  The value of @code{libdir} should normally be@file{/usr/local/lib}, but it should be written as@file{$(exec_prefix)/lib}.@item datadirThe directory for installing read-only data files which the programsrefer to while they run.  This directory is used for files which areindependent of the type of machine being used.  This should normally be@file{/usr/local/lib}, but it should be written as@file{$(prefix)/lib}.@item statedirThe directory for installing data files which the programs modify whilethey run.  These files should be independent of the type of machinebeing used, and it should be possible to share them among machines at anetwork installation.  This should normally be @file{/usr/local/lib},but it should be written as @file{$(prefix)/lib}.@item includedirThe directory for installing @samp{#include} header files to be includedby user programs.  This should normally be @file{/usr/local/include},but it should be written as @file{$(prefix)/include}.Most compilers other than GCC do not look for header files in@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}.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.@item mandirThe directory for installing the man pages (if any) for this package.It should include the suffix for the proper section of themanual---usually @samp{1} for a utility.@item man1dirThe directory for installing section 1 man pages.@item man2dirThe directory for installing section 2 man pages.@item @dots{}Use these names instead of @samp{mandir} if the package needs to install manpages in more than one section of the manual.@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.@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}.@item srcdirThe directory for the sources being compiled.  The value of thisvariable is normally inserted by the @code{configure} shell script.@end tableFor example:@example# Common prefix for installation directories.# NOTE: This directory must exist when you start installation.prefix = /usr/localexec_prefix = $(prefix)# Directory in which to put the executable for the command `gcc'bindir = $(exec_prefix)/bin# Directory in which to put the directories used by the compiler.libdir = $(exec_prefix)/lib# Directory in which to put the Info files.infodir = $(prefix)/info@end exampleIf 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 Configuration@chapter How Configuration Should WorkEach GNU distribution should come with a shell script named@code{configure}.  This script is given arguments which describe thekind of machine and system you want to compile the program for.The @code{configure} script must record the configuration options sothat they affect compilation.One way to do this is to make a link from a standard name such as@file{config.h} to the proper configuration file for the chosen system.If you use this technique, the distribution should @emph{not} contain afile named @file{config.h}.  This is so that people won't be able tobuild the program without configuring it first.Another thing that @code{configure} can do is to edit the Makefile.  Ifyou do this, the distribution should @emph{not} contain a file named@file{Makefile}.  Instead, include a file @file{Makefile.in} whichcontains the input used for editing.  Once again, this is so that peoplewon't be able to build the program without configuring it first.If @code{configure} does write the @file{Makefile}, then @file{Makefile}should have a target named @file{Makefile} which causes @code{configure}to be rerun, setting up the same configuration that was set up lasttime.  The files that @code{configure} reads should be listed asdependencies of @file{Makefile}.All the files which are output from the @code{configure} script shouldhave comments at the beginning explaining that they were generatedautomatically using @code{configure}.  This is so that users won't thinkof trying to edit them by hand.The @code{configure} script should write a file named @file{config.status}which describes which configuration options were specified when theprogram was last configured.  This file should be a shell script which,if run, will recreate the same configuration.The @code{configure} script should accept an option of the form@samp{--srcdir=@var{dirname}} to specify the directory where sources are found(if it is not the current directory).  This makes it possible to buildthe program in a separate directory, so that the actual source directoryis not modified.If the user does not specify @samp{--srcdir}, then @code{configure} shouldcheck both @file{.} and @file{..} to see if it can find the sources.  Ifit finds the sources in one of these places, it should use them fromthere.  Otherwise, it should report that it cannot find the sources, andshould exit with nonzero status.Usually the easy way to support @samp{--srcdir} is by editing adefinition of @code{VPATH} into the Makefile.  Some rules may need torefer explicitly to the specified source directory.  To make thispossible, @code{configure} can add to the Makefile a variable named@code{srcdir} whose value is precisely the specified directory.The @code{configure} script should also take an argument which specifies thetype of system to build the program for.  This argument should look likethis:@example@var{cpu}-@var{company}-@var{system}@end exampleFor example, a Sun 3 might be @samp{m68k-sun-sunos4.1}.The @code{configure} script needs to be able to decode all plausiblealternatives for how to describe a machine.  Thus, @samp{sun3-sunos4.1}would be a valid alias.  So would @samp{sun3-bsd4.2}, since SunOS isbasically @sc{BSD} and no other @sc{BSD} system is used on a Sun.  For manyprograms, @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 distinguishthem.There is a shell script called @file{config.sub} that you can useas a subroutine to validate system types and canonicalize aliases.Other options are permitted to specify in more detail the softwareor hardware are present on the machine:@table @samp@item --with-@var{package}The package @var{package} will be installed, so configure this packageto work with @var{package}.Possible values of @var{package} include @samp{x}, @samp{gnu-as} (or@samp{gas}), @samp{gnu-ld}, @samp{gnu-libc}, and @samp{gdb}.@item --nfpThe target machine has no floating point processor.@item --gasThe target machine assembler is GAS, the GNU assembler.This is obsolete; use @samp{--with-gnu-as} instead.@item --xThe target machine has the X Window system installed.This is obsolete; use @samp{--with-x} instead.@end tableAll @code{configure} scripts should accept all of these ``detail''options, whether or not they make any difference to the particularpackage at hand.  In particular, they should accept any option thatstarts with @samp{--with-}.  This is so users will be able to configurean entire GNU source tree at once with a single set of options.Packages that perform part of compilation may support cross-compilation.In such a case, the host and target machines for the program may bedifferent.  The @code{configure} script should normally treat thespecified type of system as both the host and the target, thus producinga program which works for the same type of machine that it runs on.The way to build a cross-compiler, cross-assembler, or what have you, isto specify the option @samp{--host=@var{hosttype}} when running@code{configure}.  This specifies the host system without changing thetype of target system.  The syntax for @var{hosttype} is the same asdescribed above.Programs for which cross-operation is not meaningful need not accept the@samp{--host} option, because configuring an entire operating system for

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -