configure.texi
来自「基于4个mips核的noc设计」· TEXI 代码 · 共 1,744 行 · 第 1/5 页
TEXI
1,744 行
help identify potential portability problems, and hence configure teststhat you will want to use.@ifnothtml@xref{Invoking autoscan, , , autoconf, the autoconf manual}.@end ifnothtml@ifhtmlSee @uref{http://www.delorie.com/gnu/docs/autoconf/autoconf_4.html, theautoscan documentation}.@end ifhtmlAnother handy tool for an existing body of code is @samp{ifnames}. Thiswill show you all the preprocessor conditionals that the code alreadyuses.@ifnothtml@xref{Invoking ifnames, , , autoconf, the autoconf manual}.@end ifnothtml@ifhtmlSee @uref{http://www.delorie.com/gnu/docs/autoconf/autoconf_5.html, theifnames documentation}.@end ifhtmlBesides the portability tests which are specific to your particularpackage, every @file{configure.in} file should contain the followingmacros.@table @samp@item AC_INIT@cindex @samp{AC_INIT}This macro takes a single argument, which is the name of a file in yourpackage. For example, @samp{AC_INIT(foo.c)}.@item AC_PREREQ(@var{VERSION})@cindex @samp{AC_PREREQ}This macro is optional. It may be used to indicate the version of@samp{autoconf} that you are using. This will prevent users fromrunning an earlier version of @samp{autoconf} and perhaps getting aninvalid @file{configure} script. For example, @samp{AC_PREREQ(2.12)}.@item AM_INIT_AUTOMAKE@cindex @samp{AM_INIT_AUTOMAKE}This macro takes two arguments: the name of the package, and a versionnumber. For example, @samp{AM_INIT_AUTOMAKE(foo, 1.0)}. (This macro isnot needed if you are not using automake).@item AM_CONFIG_HEADER@cindex @samp{AM_CONFIG_HEADER}This macro names the header file which will hold the preprocessor macrodefinitions at run time. Normally this should be @file{config.h}. Yoursources would then use @samp{#include "config.h"} to include it.This macro may optionally name the input file for that header file; bydefault, this is @file{config.h.in}, but that file name works poorly onDOS filesystems. Therefore, it is often better to name it explicitly as@file{config.in}.This is what you should normally put in @file{configure.in}:@exampleAM_CONFIG_HEADER(config.h:config.in)@end example@cindex @samp{AC_CONFIG_HEADER}(If you are not using automake, use @samp{AC_CONFIG_HEADER} rather than@samp{AM_CONFIG_HEADER}).@item AM_MAINTAINER_MODE@cindex @samp{AM_MAINTAINER_MODE}This macro always appears in Cygnus configure scripts. Other programsmay or may not use it.If this macro is used, the @samp{--enable-maintainer-mode} option isrequired to enable automatic rebuilding of generated files used by theconfigure system. This of course requires that developers be aware of,and use, that option.If this macro is not used, then the generated files will always berebuilt automatically. This will cause problems if the wrong versionsof autoconf, automake, or others are in the builder's @samp{PATH}.(If you are not using automake, you do not need to use this macro).@item AC_EXEEXT@cindex @samp{AC_EXEEXT}@cindex @samp{AM_EXEEXT}Either this macro or @samp{AM_EXEEXT} always appears in Cygnus configurefiles. Other programs may or may not use one of them.This macro looks for the executable suffix used on the host system. OnUnix systems, this is the empty string. On Windows systems, this is@samp{.exe}. This macro directs automake to use the executable suffixas appropriate when creating programs. This macro does not take anyarguments.The @samp{AC_EXEEXT} form is new, and is part of a Cygnus patch toautoconf to support compiling with Visual C++. Older programs use@samp{AM_EXEEXT} instead.(Programs which do not use automake use neither @samp{AC_EXEEXT} nor@samp{AM_EXEEXT}).@item AC_PROG_CC@cindex @samp{AC_PROG_CC}If you are writing C code, you will normally want to use this macro. Itlocates the C compiler to use. It does not take any arguments.However, if this @file{configure.in} file is for a library which is tobe compiled by a cross compiler which may not fully work, then you willnot want to use @samp{AC_PROG_CC}. Instead, you will want to use avariant which does not call the macro @samp{AC_PROG_CC_WORKS}. Examplescan be found in various @file{configure.in} files for libraries that arecompiled with cross compilers, such as libiberty or libgloss. This isessentially a bug in autoconf, and there will probably be a betterworkaround at some point.@item AC_PROG_CXX@cindex @samp{AC_PROG_CXX}If you are writing C++ code, you will want to use this macro. Itlocates the C++ compiler to use. It does not take any arguments. Thesame cross compiler comments apply as for @samp{AC_PROG_CC}.@item AM_PROG_LIBTOOL@cindex @samp{AM_PROG_LIBTOOL}If you want to build libraries, and you want to permit them to beshared, or you want to link against libraries which were built usinglibtool, then you will need this macro. This macro is required in orderto use libtool.@cindex @samp{AM_DISABLE_SHARED}By default, this will cause all libraries to be built as sharedlibraries. To prevent this--to change the default--use@samp{AM_DISABLE_SHARED} before @samp{AM_PROG_LIBTOOL}. The configureoptions @samp{--enable-shared} and @samp{--disable-shared} may be usedto override the default at build time.@item AC_DEFINE(_GNU_SOURCE)@cindex @samp{_GNU_SOURCE}GNU packages should normally include this line before any other featuretests. This defines the macro @samp{_GNU_SOURCE} when compiling, whichdirects the libc header files to provide the standard GNU systeminterfaces including all GNU extensions. If this macro is not defined,certain GNU extensions may not be available.@item AC_OUTPUT@cindex @samp{AC_OUTPUT}This macro takes a list of file names which the configure process shouldproduce. This is normally a list of one or more @file{Makefile} filesin different directories. If your package lives entirely in a singledirectory, you would use simply @samp{AC_OUTPUT(Makefile)}. If you alsohave, for example, a @file{lib} subdirectory, you would use@samp{AC_OUTPUT(Makefile lib/Makefile)}.@end tableIf you want to use locally defined macros in your @file{configure.in}file, then you will need to write a @file{acinclude.m4} file whichdefines them (if not using automake, this file is called@file{aclocal.m4}). Alternatively, you can put separate macros in an@file{m4} subdirectory, and put @samp{ACLOCAL_AMFLAGS = -I m4} in your@file{Makefile.am} file so that the @samp{aclocal} program will be ableto find them.The different macro prefixes indicate which tool defines the macro.Macros which start with @samp{AC_} are part of autoconf. Macros whichstart with @samp{AM_} are provided by automake or libtool.@node Write Makefile.am@section Write Makefile.am@cindex @file{Makefile.am}, writingYou must write the file @file{Makefile.am}. This is an automake inputfile, and the automake manual describes in detail what this file shouldlook like.The automake commands in @file{Makefile.am} mostly look like variableassignments in a @file{Makefile}. automake recognizes special variablenames, and automatically add make rules to the output as needed.There will be one @file{Makefile.am} file for each directory in yourpackage. For each directory with subdirectories, the @file{Makefile.am}file should contain the line@smallexampleSUBDIRS = @var{dir} @var{dir} @dots{}@end smallexample@noindentwhere each @var{dir} is the name of a subdirectory.For each @file{Makefile.am}, there should be a corresponding@file{Makefile} in the @samp{AC_OUTPUT} macro in @file{configure.in}.Every @file{Makefile.am} written at Cygnus should contain the line@smallexampleAUTOMAKE_OPTIONS = cygnus@end smallexample@noindentThis puts automake into Cygnus mode. See the automake manual fordetails.You may to include the version number of @samp{automake} that you areusing on the @samp{AUTOMAKE_OPTIONS} line. For example,@smallexampleAUTOMAKE_OPTIONS = cygnus 1.3@end smallexample@noindentThis will prevent users from running an earlier version of@samp{automake} and perhaps getting an invalid @file{Makefile.in}.If your package builds a program, then in the directory where thatprogram is built you will normally want a line like@smallexamplebin_PROGRAMS = @var{program}@end smallexample@noindentwhere @var{program} is the name of the program. You will then want aline like@smallexample@var{program}_SOURCES = @var{file} @var{file} @dots{}@end smallexample@noindentwhere each @var{file} is the name of a source file to link into theprogram (e.g., @samp{foo.c}).If your package builds a library, and you do not want the library toever be built as a shared library, then in the directory where thatlibrary is built you will normally want a line like@smallexamplelib_LIBRARIES = lib@var{name}.a@end smallexample@noindentwhere @samp{lib@var{name}.a} is the name of the library. You will thenwant a line like@smallexamplelib@var{name}_a_SOURCES = @var{file} @var{file} @dots{}@end smallexample@noindentwhere each @var{file} is the name of a source file to add to thelibrary.If your package builds a library, and you want to permit building thelibrary as a shared library, then in the directory where that library isbuilt you will normally want a line like@smallexamplelib_LTLIBRARIES = lib@var{name}.la@end smallexampleThe use of @samp{LTLIBRARIES}, and the @samp{.la} extension, indicate alibrary to be built using libtool. As usual, you will then want a linelike@smallexamplelib@var{name}_la_SOURCES = @var{file} @var{file} @dots{}@end smallexampleThe strings @samp{bin} and @samp{lib} that appear above in@samp{bin_PROGRAMS} and @samp{lib_LIBRARIES} are not arbitrary. Theyrefer to particular directories, which may be set by the @samp{--bindir}and @samp{--libdir} options to @file{configure}. If those options arenot used, the default values are based on the @samp{--prefix} or@samp{--exec-prefix} options to @file{configure}. It is possible to useother names if the program or library should be installed in some otherdirectory.The @file{Makefile.am} file may also contain almost anything that mayappear in a normal @file{Makefile}. automake also supports many otherspecial variables, as well as conditionals.See the automake manual for more information.@node Write acconfig.h@section Write acconfig.h@cindex @file{acconfig.h}, writingIf you are generating a portability header file, (i.e., you are using@samp{AM_CONFIG_HEADER} in @file{configure.in}), then you will have towrite a @file{acconfig.h} file. It will have to contain the followinglines.@smallexample/* Name of package. */#undef PACKAGE/* Version of package. */#undef VERSION@end smallexampleThis requirement is really a bug in the system, and the requirement maybe eliminated at some later date.The @file{acconfig.h} file will also similar comment and @samp{#undef}lines for any unusual macros in the @file{configure.in} file, includingany macro which appears in a @samp{AC_DEFINE} macro.In particular, if you are writing a GNU package and therefore include@samp{AC_DEFINE(_GNU_SOURCE)} in @file{configure.in} as suggested above,you will need lines like this in @file{acconfig.h}:@smallexample/* Enable GNU extensions. */#undef _GNU_SOURCE@end smallexampleNormally the @samp{autoheader} program will inform you of any suchrequirements by printing an error message when it is run. However, ifyou do anything particular odd in your @file{configure.in} file, youwill have to make sure that the right entries appear in@file{acconfig.h}, since otherwise the results of the tests may not beavailable in the @file{config.h} file which your code will use.(Thee @samp{PACKAGE} and @samp{VERSION} lines are not required if youare not using automake, and in that case you may not need a@file{acconfig.h} file at all).@node Generate files@section Generate filesOnce you have written @file{configure.in}, @file{Makefile.am},@file{acconfig.h}, and possibly @file{acinclude.m4}, you must useautoconf and automake programs to produce the first versions of thegenerated files. This is done by executing the following sequence ofcommands.@smallexampleaclocalautoconfautoheaderautomake@end smallexampleThe @samp{aclocal} and @samp{automake} commands are part of the automakepackage, and the @samp{autoconf} and @samp{autoheader} commands are partof the autoconf package.If you are using a @file{m4} subdirectory for your macros, you will needto use the @samp{-I m4} option when you run @samp{aclocal}.If you are not using the Cygnus tree, use the @samp{-a} option whenrunning @samp{automake} command in order to copy the required supportfiles into your source directory.If you are using libtool, you must build and install the libtool packagewith the same @samp{--prefix} and @samp{--exec-prefix} options as youused with the autoconf and automake packages. You must do this beforerunning any of the above commands. If you are not using the Cygnustree, you will need to run the @samp{libtoolize} program to copy thelibtool support files into your directory.Once you have managed to run these commands without getting any errors,you should create a new empty directory, and run the @samp{configure}script which will have been created by @samp{autoconf} with the@samp{--enable-maintainer-mode} option. This will give you a set ofMakefiles which will include rules to automatically rebuild all thegenerated files.After doing that, whenever you have changed some of the input files andwant to regenerated the other files, go to your object directory and run
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?