URL
https://opencores.org/ocsvn/or1k/or1k/trunk
Subversion Repositories or1k
[/] [or1k/] [trunk/] [insight/] [etc/] [configure.info-2] - Rev 1771
Go to most recent revision | Compare with Previous | Blame | View Log
This is configure.info, produced by makeinfo version 4.0 from./configure.texi.INFO-DIR-SECTION GNU adminSTART-INFO-DIR-ENTRY* configure: (configure). The GNU configure and build systemEND-INFO-DIR-ENTRYThis file documents the GNU configure and build system.Copyright (C) 1998 Cygnus Solutions.Permission is granted to make and distribute verbatim copies of thismanual provided the copyright notice and this permission notice arepreserved on all copies.Permission is granted to copy and distribute modified versions ofthis manual under the conditions for verbatim copying, provided thatthe entire resulting derived work is distributed under the terms of apermission notice identical to this one.Permission is granted to copy and distribute translations of thismanual into another language, under the above conditions for modifiedversions, except that this permission notice may be stated in atranslation approved by the Foundation.File: configure.info, Node: Configuration Name Definition, Next: Using Configuration Names, Up: Configuration NamesConfiguration Name Definition=============================This is a string of the form CPU-MANUFACTURER-OPERATING_SYSTEM. Insome cases, this is extended to a four part form:CPU-MANUFACTURER-KERNEL-OPERATING_SYSTEM.When using a configuration name in a configure option, it is normallynot necessary to specify an entire name. In particular, theMANUFACTURER field is often omitted, leading to strings such as`i386-linux' or `sparc-sunos'. The shell script `config.sub' willtranslate these shortened strings into the canonical form. autoconfwill arrange for `config.sub' to be run automatically when it is needed.The fields of a configuration name are as follows:CPUThe type of processor. This is typically something like `i386' or`sparc'. More specific variants are used as well, such as`mipsel' to indicate a little endian MIPS processor.MANUFACTURERA somewhat freeform field which indicates the manufacturer of thesystem. This is often simply `unknown'. Other common strings are`pc' for an IBM PC compatible system, or the name of a workstationvendor, such as `sun'.OPERATING_SYSTEMThe name of the operating system which is run on the system. Thiswill be something like `solaris2.5' or `irix6.3'. There is noparticular restriction on the version number, and strings like`aix4.1.4.0' are seen. For an embedded system, which has nooperating system, this field normally indicates the type of objectfile format, such as `elf' or `coff'.KERNELThis is used mainly for GNU/Linux. A typical GNU/Linuxconfiguration name is `i586-pc-linux-gnulibc1'. In this case thekernel, `linux', is separated from the operating system,`gnulibc1'.The shell script `config.guess' will normally print the correctconfiguration name for the system on which it is run. It does byrunning `uname' and by examining other characteristics of the system.Because `config.guess' can normally determine the configuration namefor a machine, it is normally only necessary to specify a configurationname when building a cross-compiler or when building using across-compiler.File: configure.info, Node: Using Configuration Names, Prev: Configuration Name Definition, Up: Configuration NamesUsing Configuration Names=========================A configure script will sometimes have to make a decision based on aconfiguration name. You will need to do this if you have to compilecode differently based on something which can not be tested using astandard autoconf feature test.It is normally better to test for particular features, rather than totest for a particular system. This is because as Unix evolves,different systems copy features from one another. Even if you need todetermine whether the feature is supported based on a configurationname, you should define a macro which describes the feature, rather thandefining a macro which describes the particular system you are on.Testing for a particular system is normally done using a casestatement in `configure.in'. The case statement might look somethinglike the following, assuming that `host' is a shell variable holding acanonical configuration name (which will be the case if `configure.in'uses the `AC_CANONICAL_HOST' or `AC_CANONICAL_SYSTEM' macro).case "${host}" ini[3456]86-*-linux-gnu*) do something ;;sparc*-sun-solaris2.[56789]*) do something ;;sparc*-sun-solaris*) do something ;;mips*-*-elf*) do something ;;esacIt is particularly important to use `*' after the operating systemfield, in order to match the version number which will be generated by`config.guess'.In most cases you must be careful to match a range of processortypes. For most processor families, a trailing `*' suffices, as in`mips*' above. For the i386 family, something along the lines of`i[3456]86' suffices at present. For the m68k family, you will needsomething like `m68*'. Of course, if you do not need to match on theprocessor, it is simpler to just replace the entire field by a `*', asin `*-*-irix*'.File: configure.info, Node: Cross Compilation Tools, Next: Canadian Cross, Prev: Configuration Names, Up: TopCross Compilation Tools***********************The GNU configure and build system can be used to build "crosscompilation" tools. A cross compilation tool is a tool which runs onone system and produces code which runs on another system.* Menu:* Cross Compilation Concepts:: Cross Compilation Concepts.* Host and Target:: Host and Target.* Using the Host Type:: Using the Host Type.* Specifying the Target:: Specifying the Target.* Using the Target Type:: Using the Target Type.* Cross Tools in the Cygnus Tree:: Cross Tools in the Cygnus TreeFile: configure.info, Node: Cross Compilation Concepts, Next: Host and Target, Up: Cross Compilation ToolsCross Compilation Concepts==========================A compiler which produces programs which run on a different systemis a cross compilation compiler, or simply a "cross compiler".Similarly, we speak of cross assemblers, cross linkers, etc.In the normal case, a compiler produces code which runs on the samesystem as the one on which the compiler runs. When it is necessary todistinguish this case from the cross compilation case, such a compileris called a "native compiler". Similarly, we speak of nativeassemblers, etc.Although the debugger is not strictly speaking a compilation tool,it is nevertheless meaningful to speak of a cross debugger: a debuggerwhich is used to debug code which runs on another system. Everythingthat is said below about configuring cross compilation tools applies tothe debugger as well.File: configure.info, Node: Host and Target, Next: Using the Host Type, Prev: Cross Compilation Concepts, Up: Cross Compilation ToolsHost and Target===============When building cross compilation tools, there are two differentsystems involved: the system on which the tools will run, and thesystem for which the tools generate code.The system on which the tools will run is called the "host" system.The system for which the tools generate code is called the "target"system.For example, suppose you have a compiler which runs on a GNU/Linuxsystem and generates ELF programs for a MIPS embedded system. In thiscase the GNU/Linux system is the host, and the MIPS ELF system is thetarget. Such a compiler could be called a GNU/Linux cross MIPS ELFcompiler, or, equivalently, a `i386-linux-gnu' cross `mips-elf'compiler.Naturally, most programs are not cross compilation tools. For thoseprograms, it does not make sense to speak of a target. It only makessense to speak of a target for tools like `gcc' or the `binutils' whichactually produce running code. For example, it does not make sense tospeak of the target of a tool like `bison' or `make'.Most cross compilation tools can also serve as native tools. For anative compilation tool, it is still meaningful to speak of a target.For a native tool, the target is the same as the host. For example, fora GNU/Linux native compiler, the host is GNU/Linux, and the target isalso GNU/Linux.File: configure.info, Node: Using the Host Type, Next: Specifying the Target, Prev: Host and Target, Up: Cross Compilation ToolsUsing the Host Type===================In almost all cases the host system is the system on which you runthe `configure' script, and on which you build the tools (for the casewhen they differ, *note Canadian Cross::).If your configure script needs to know the configuration name of thehost system, and the package is not a cross compilation tool andtherefore does not have a target, put `AC_CANONICAL_HOST' in`configure.in'. This macro will arrange to define a few shellvariables when the `configure' script is run.`host'The canonical configuration name of the host. This will normallybe determined by running the `config.guess' shell script, althoughthe user is permitted to override this by using an explicit`--host' option.`host_alias'In the unusual case that the user used an explicit `--host' option,this will be the argument to `--host'. In the normal case, thiswill be the same as the `host' variable.`host_cpu'`host_vendor'`host_os'The first three parts of the canonical configuration name.The shell variables may be used by putting shell code in`configure.in'. For an example, see *Note Using Configuration Names::.File: configure.info, Node: Specifying the Target, Next: Using the Target Type, Prev: Using the Host Type, Up: Cross Compilation ToolsSpecifying the Target=====================By default, the `configure' script will assume that the target isthe same as the host. This is the more common case; for example, itleads to a native compiler rather than a cross compiler.If you want to build a cross compilation tool, you must specify thetarget explicitly by using the `--target' option when you run`configure'. The argument to `--target' is the configuration name ofthe system for which you wish to generate code. *Note ConfigurationNames::.For example, to build tools which generate code for a MIPS ELFembedded system, you would use `--target mips-elf'.File: configure.info, Node: Using the Target Type, Next: Cross Tools in the Cygnus Tree, Prev: Specifying the Target, Up: Cross Compilation ToolsUsing the Target Type=====================When writing `configure.in' for a cross compilation tool, you willneed to use information about the target. To do this, put`AC_CANONICAL_SYSTEM' in `configure.in'.`AC_CANONICAL_SYSTEM' will look for a `--target' option andcanonicalize it using the `config.sub' shell script. It will also run`AC_CANONICAL_HOST' (*note Using the Host Type::).The target type will be recorded in the following shell variables.Note that the host versions of these variables will also be defined by`AC_CANONICAL_HOST'.`target'The canonical configuration name of the target.`target_alias'The argument to the `--target' option. If the user did not specifya `--target' option, this will be the same as `host_alias'.`target_cpu'`target_vendor'`target_os'The first three parts of the canonical target configuration name.Note that if `host' and `target' are the same string, you can assumea native configuration. If they are different, you can assume a crossconfiguration.It is arguably possible for `host' and `target' to represent thesame system, but for the strings to not be identical. For example, if`config.guess' returns `sparc-sun-sunos4.1.4', and somebody configureswith `--target sparc-sun-sunos4.1', then the slight differences betweenthe two versions of SunOS may be unimportant for your tool. However,in the general case it can be quite difficult to determine whether thedifferences between two configuration names are significant or not.Therefore, by convention, if the user specifies a `--target' optionwithout specifying a `--host' option, it is assumed that the user wantsto configure a cross compilation tool.The variables `target' and `target_alias' should be handleddifferently.In general, whenever the user may actually see a string,`target_alias' should be used. This includes anything which may appearin the file system, such as a directory name or part of a tool name.It also includes any tool output, unless it is clearly labelled as thecanonical target configuration name. This permits the user to use the`--target' option to specify how the tool will appear to the outsideworld.On the other hand, when checking for characteristics of the targetsystem, `target' should be used. This is because a wide variety of`--target' options may map into the same canonical configuration name.You should not attempt to duplicate the canonicalization done by`config.sub' in your own code.By convention, cross tools are installed with a prefix of theargument used with the `--target' option, also known as `target_alias'(*note Using the Target Type::). If the user does not use the`--target' option, and thus is building a native tool, no prefix isused.For example, if gcc is configured with `--target mips-elf', then theinstalled binary will be named `mips-elf-gcc'. If gcc is configuredwithout a `--target' option, then the installed binary will be named`gcc'.The autoconf macro `AC_ARG_PROGRAM' will handle this for you. Ifyou are using automake, no more need be done; the programs willautomatically be installed with the correct prefixes. Otherwise, seethe autoconf documentation for `AC_ARG_PROGRAM'.File: configure.info, Node: Cross Tools in the Cygnus Tree, Prev: Using the Target Type, Up: Cross Compilation ToolsCross Tools in the Cygnus Tree==============================The Cygnus tree is used for various packages including gdb, the GNUbinutils, and egcs. It is also, of course, used for Cygnus releases.In the Cygnus tree, the top level `configure' script uses the oldCygnus configure system, not autoconf. The top level `Makefile.in' iswritten to build packages based on what is in the source tree, andsupports building a large number of tools in a single`configure'/`make' step.The Cygnus tree may be configured with a `--target' option. The`--target' option applies recursively to every subdirectory, andpermits building an entire set of cross tools at once.* Menu:* Host and Target Libraries:: Host and Target Libraries.* Target Library Configure Scripts:: Target Library Configure Scripts.* Make Targets in Cygnus Tree:: Make Targets in Cygnus Tree.* Target libiberty:: Target libibertyFile: configure.info, Node: Host and Target Libraries, Next: Target Library Configure Scripts, Up: Cross Tools in the Cygnus TreeHost and Target Libraries-------------------------The Cygnus tree distinguishes host libraries from target libraries.Host libraries are built with the compiler used to build the programswhich run on the host, which is called the host compiler. This includeslibraries such as `bfd' and `tcl'. These libraries are built with thehost compiler, and are linked into programs like the binutils or gccwhich run on the host.Target libraries are built with the target compiler. If gcc ispresent in the source tree, then the target compiler is the gcc that isbuilt using the host compiler. Target libraries are libraries such as`newlib' and `libstdc++'. These libraries are not linked into the hostprograms, but are instead made available for use with programs builtwith the target compiler.For the rest of this section, assume that gcc is present in thesource tree, so that it will be used to build the target libraries.There is a complication here. The configure process needs to knowwhich compiler you are going to use to build a tool; otherwise, thefeature tests will not work correctly. The Cygnus tree handles this bynot configuring the target libraries until the target compiler isbuilt. In order to permit everything to build using a single`configure'/`make', the configuration of the target libraries isactually triggered during the make step.When the target libraries are configured, the `--target' option isnot used. Instead, the `--host' option is used with the argument ofthe `--target' option for the overall configuration. If no `--target'option was used for the overall configuration, the `--host' option willbe passed with the output of the `config.guess' shell script. Any`--build' option is passed down unchanged.This translation of configuration options is done because since thetarget libraries are compiled with the target compiler, they are beingbuilt in order to run on the target of the overall configuration. Bythe definition of host, this means that their host system is the same asthe target system of the overall configuration.The same process is used for both a native configuration and a crossconfiguration. Even when using a native configuration, the targetlibraries will be configured and built using the newly built compiler.This is particularly important for the C++ libraries, since there is noreason to assume that the C++ compiler used to build the host tools (ifthere even is one) uses the same ABI as the g++ compiler which will beused to build the target libraries.There is one difference between a native configuration and a crossconfiguration. In a native configuration, the target libraries arenormally configured and built as siblings of the host tools. In a crossconfiguration, the target libraries are normally built in a subdirectorywhose name is the argument to `--target'. This is mainly forhistorical reasons.To summarize, running `configure' in the Cygnus tree configures allthe host libraries and tools, but does not configure any of the targetlibraries. Running `make' then does the following steps:* Build the host libraries.* Build the host programs, including gcc. Note that we call gccboth a host program (since it runs on the host) and a targetcompiler (since it generates code for the target).* Using the newly built target compiler, configure the targetlibraries.* Build the target libraries.The steps need not be done in precisely this order, since they areactually controlled by `Makefile' targets.File: configure.info, Node: Target Library Configure Scripts, Next: Make Targets in Cygnus Tree, Prev: Host and Target Libraries, Up: Cross Tools in the Cygnus TreeTarget Library Configure Scripts--------------------------------There are a few things you must know in order to write a configurescript for a target library. This is just a quick sketch, and beginnersshouldn't worry if they don't follow everything here.The target libraries are configured and built using a newly builttarget compiler. There may not be any startup files or libraries forthis target compiler. In fact, those files will probably be built aspart of some target library, which naturally means that they will notexist when your target library is configured.This means that the configure script for a target library may not useany test which requires doing a link. This unfortunately includes manyuseful autoconf macros, such as `AC_CHECK_FUNCS'. autoconf macroswhich do a compile but not a link, such as `AC_CHECK_HEADERS', may beused.This is a severe restriction, but normally not a fatal one, as targetlibraries can often assume the presence of other target libraries, andthus know which functions will be available.As of this writing, the autoconf macro `AC_PROG_CC' does a link tomake sure that the compiler works. This may fail in a target library,so target libraries must use a different set of macros to locate thecompiler. See the `configure.in' file in a directory like `libiberty'or `libgloss' for an example.As noted in the previous section, target libraries are sometimesbuilt in directories which are siblings to the host tools, and aresometimes built in a subdirectory. The `--with-target-subdir' configureoption will be passed when the library is configured. Its value will bean empty string if the target library is a sibling. Its value will bethe name of the subdirectory if the target library is in a subdirectory.If the overall build is not a native build (i.e., the overallconfigure used the `--target' option), then the library will beconfigured with the `--with-cross-host' option. The value of thisoption will be the host system of the overall build. Recall that thehost system of the library will be the target of the overall build. Ifthe overall build is a native build, the `--with-cross-host' optionwill not be used.A library which can be built both standalone and as a target librarymay want to install itself into different directories depending upon thecase. When built standalone, or when built native, the library shouldbe installed in `$(libdir)'. When built as a target library which isnot native, the library should be installed in `$(tooldir)/lib'. The`--with-cross-host' option may be used to distinguish these cases.This same test of `--with-cross-host' may be used to see whether itis OK to use link tests in the configure script. If the`--with-cross-host' option is not used, then the library is being builteither standalone or native, and a link should work.File: configure.info, Node: Make Targets in Cygnus Tree, Next: Target libiberty, Prev: Target Library Configure Scripts, Up: Cross Tools in the Cygnus TreeMake Targets in Cygnus Tree---------------------------The top level `Makefile' in the Cygnus tree defines targets forevery known subdirectory.For every subdirectory DIR which holds a host library or program,the `Makefile' target `all-DIR' will build that library or program.There are dependencies among host tools. For example, building gccrequires first building gas, because the gcc build process invokes thetarget assembler. These dependencies are reflected in the top level`Makefile'.For every subdirectory DIR which holds a target library, the`Makefile' target `configure-target-DIR' will configure that library.The `Makefile' target `all-target-DIR' will build that library.Every `configure-target-DIR' target depends upon `all-gcc', sincegcc, the target compiler, is required to configure the tool. Every`all-target-DIR' target depends upon the corresponding`configure-target-DIR' target.There are several other targets which may be of interest for eachdirectory: `install-DIR', `clean-DIR', and `check-DIR'. There are alsocorresponding `target' versions of these for the target libraries ,such as `install-target-DIR'.File: configure.info, Node: Target libiberty, Prev: Make Targets in Cygnus Tree, Up: Cross Tools in the Cygnus TreeTarget libiberty----------------The `libiberty' subdirectory is currently a special case, in that itis the only directory which is built both using the host compiler andusing the target compiler.This is because the files in `libiberty' are used when building thehost tools, and they are also incorporated into the `libstdc++' targetlibrary as support code.This duality does not pose any particular difficulties. It meansthat there are targets for both `all-libiberty' and`all-target-libiberty'.In a native configuration, when target libraries are not built in asubdirectory, the same objects are normally used as both the host buildand the target build. This is normally OK, since libiberty containsonly C code, and in a native configuration the results of the hostcompiler and the target compiler are normally interoperable.Irix 6 is again an exception here, since the SGI native compilerdefaults to using the `O32' ABI, and gcc defaults to using the `N32'ABI. On Irix 6, the target libraries are built in a subdirectory evenfor a native configuration, avoiding this problem.There are currently no other libraries built for both the host andthe target, but there is no conceptual problem with adding more.File: configure.info, Node: Canadian Cross, Next: Cygnus Configure, Prev: Cross Compilation Tools, Up: TopCanadian Cross**************It is possible to use the GNU configure and build system to build aprogram which will run on a system which is different from the system onwhich the tools are built. In other words, it is possible to buildprograms using a cross compiler.This is referred to as a "Canadian Cross".* Menu:* Canadian Cross Example:: Canadian Cross Example.* Canadian Cross Concepts:: Canadian Cross Concepts.* Build Cross Host Tools:: Build Cross Host Tools.* Build and Host Options:: Build and Host Options.* CCross not in Cygnus Tree:: Canadian Cross not in Cygnus Tree.* CCross in Cygnus Tree:: Canadian Cross in Cygnus Tree.* Supporting Canadian Cross:: Supporting Canadian Cross.File: configure.info, Node: Canadian Cross Example, Next: Canadian Cross Concepts, Up: Canadian CrossCanadian Cross Example======================Here is an example of a Canadian Cross.While running on a GNU/Linux, you can build a program which will runon a Solaris system. You would use a GNU/Linux cross Solaris compilerto build the program.Of course, you could not run the resulting program on your GNU/Linuxsystem. You would have to copy it over to a Solaris system before youwould run it.Of course, you could also simply build the programs on the Solarissystem in the first place. However, perhaps the Solaris system is notavailable for some reason; perhaps you actually don't have one, but youwant to build the tools for somebody else to use. Or perhaps yourGNU/Linux system is much faster than your Solaris system.A Canadian Cross build is most frequently used when buildingprograms to run on a non-Unix system, such as DOS or Windows. It maybe simpler to configure and build on a Unix system than to support theconfiguration machinery on a non-Unix system.File: configure.info, Node: Canadian Cross Concepts, Next: Build Cross Host Tools, Prev: Canadian Cross Example, Up: Canadian CrossCanadian Cross Concepts=======================When building a Canadian Cross, there are at least two differentsystems involved: the system on which the tools are being built, andthe system on which the tools will run.The system on which the tools are being built is called the "build"system.The system on which the tools will run is called the host system.For example, if you are building a Solaris program on a GNU/Linuxsystem, as in the previous section, the build system would be GNU/Linux,and the host system would be Solaris.It is, of course, possible to build a cross compiler using a CanadianCross (i.e., build a cross compiler using a cross compiler). In thiscase, the system for which the resulting cross compiler generates codeis called the target system. (For a more complete discussion of hostand target systems, *note Host and Target::).An example of building a cross compiler using a Canadian Cross wouldbe building a Windows cross MIPS ELF compiler on a GNU/Linux system. Inthis case the build system would be GNU/Linux, the host system would beWindows, and the target system would be MIPS ELF.The name Canadian Cross comes from the case when the build, host, andtarget systems are all different. At the time that these issues wereall being hashed out, Canada had three national political parties.File: configure.info, Node: Build Cross Host Tools, Next: Build and Host Options, Prev: Canadian Cross Concepts, Up: Canadian CrossBuild Cross Host Tools======================In order to configure a program for a Canadian Cross build, you mustfirst build and install the set of cross tools you will use to build theprogram.These tools will be build cross host tools. That is, they will runon the build system, and will produce code that runs on the host system.It is easy to confuse the meaning of build and host here. Alwaysremember that the build system is where you are doing the build, and thehost system is where the resulting program will run. Therefore, youneed a build cross host compiler.In general, you must have a complete cross environment in order to dothe build. This normally means a cross compiler, cross assembler, andso forth, as well as libraries and include files for the host system.File: configure.info, Node: Build and Host Options, Next: CCross not in Cygnus Tree, Prev: Build Cross Host Tools, Up: Canadian CrossBuild and Host Options======================When you run `configure', you must use both the `--build' and`--host' options.The `--build' option is used to specify the configuration name ofthe build system. This can normally be the result of running the`config.guess' shell script, and it is reasonable to use`--build=`config.guess`'.The `--host' option is used to specify the configuration name of thehost system.As we explained earlier, `config.guess' is used to set the defaultvalue for the `--host' option (*note Using the Host Type::). We cannow see that since `config.guess' returns the type of system on whichit is run, it really identifies the build system. Since the hostsystem is normally the same as the build system (i.e., people do notnormally build using a cross compiler), it is reasonable to use theresult of `config.guess' as the default for the host system when the`--host' option is not used.It might seem that if the `--host' option were used without the`--build' option that the configure script could run `config.guess' todetermine the build system, and presume a Canadian Cross if the resultof `config.guess' differed from the `--host' option. However, forhistorical reasons, some configure scripts are routinely run using anexplicit `--host' option, rather than using the default from`config.guess'. As noted earlier, it is difficult or impossible toreliably compare configuration names (*note Using the Target Type::).Therefore, by convention, if the `--host' option is used, but the`--build' option is not used, then the build system defaults to thehost system.File: configure.info, Node: CCross not in Cygnus Tree, Next: CCross in Cygnus Tree, Prev: Build and Host Options, Up: Canadian CrossCanadian Cross not in Cygnus Tree.==================================If you are not using the Cygnus tree, you must explicitly specify thecross tools which you want to use to build the program. This is done bysetting environment variables before running the `configure' script.You must normally set at least the environment variables `CC', `AR',and `RANLIB' to the cross tools which you want to use to build.For some programs, you must set additional cross tools as well, suchas `AS', `LD', or `NM'.You would set these environment variables to the build cross toolswhich you are going to use.For example, if you are building a Solaris program on a GNU/Linuxsystem, and your GNU/Linux cross Solaris compiler were named`solaris-gcc', then you would set the environment variable `CC' to`solaris-gcc'.File: configure.info, Node: CCross in Cygnus Tree, Next: Supporting Canadian Cross, Prev: CCross not in Cygnus Tree, Up: Canadian CrossCanadian Cross in Cygnus Tree=============================This section describes configuring and building a Canadian Cross whenusing the Cygnus tree.* Menu:* Standard Cygnus CCross:: Building a Normal Program.* Cross Cygnus CCross:: Building a Cross Program.File: configure.info, Node: Standard Cygnus CCross, Next: Cross Cygnus CCross, Up: CCross in Cygnus TreeBuilding a Normal Program-------------------------When configuring a Canadian Cross in the Cygnus tree, all theappropriate environment variables are automatically set to `HOST-TOOL',where HOST is the value used for the `--host' option, and TOOL is thename of the tool (e.g., `gcc', `as', etc.). These tools must be onyour `PATH'.Adding a prefix of HOST will give the usual name for the build crosshost tools. To see this, consider that when these cross tools werebuilt, they were configured to run on the build system and to producecode for the host system. That is, they were configured with a`--target' option that is the same as the system which we are nowcalling the host. Recall that the default name for installed crosstools uses the target system as a prefix (*note Using the TargetType::). Since that is the system which we are now calling the host,HOST is the right prefix to use.For example, if you configure with `--build=i386-linux-gnu' and`--host=solaris', then the Cygnus tree will automatically default tousing the compiler `solaris-gcc'. You must have previously built andinstalled this compiler, probably by doing a build with no `--host'option and with a `--target' option of `solaris'.File: configure.info, Node: Cross Cygnus CCross, Prev: Standard Cygnus CCross, Up: CCross in Cygnus TreeBuilding a Cross Program------------------------There are additional considerations if you want to build a crosscompiler, rather than a native compiler, in the Cygnus tree using aCanadian Cross.When you build a cross compiler using the Cygnus tree, then thetarget libraries will normally be built with the newly built targetcompiler (*note Host and Target Libraries::). However, this will notwork when building with a Canadian Cross. This is because the newlybuilt target compiler will be a program which runs on the host system,and therefore will not be able to run on the build system.Therefore, when building a cross compiler with the Cygnus tree, youmust first install a set of build cross target tools. These tools willbe used when building the target libraries.Note that this is not a requirement of a Canadian Cross in general.For example, it would be possible to build just the host cross targettools on the build system, to copy the tools to the host system, and tobuild the target libraries on the host system. The requirement forbuild cross target tools is imposed by the Cygnus tree, which expectsto be able to build both host programs and target libraries in a single`configure'/`make' step. Because it builds these in a single step, itexpects to be able to build the target libraries on the build system,which means that it must use a build cross target toolchain.For example, suppose you want to build a Windows cross MIPS ELFcompiler on a GNU/Linux system. You must have previously installedboth a GNU/Linux cross Windows compiler and a GNU/Linux cross MIPS ELFcompiler.In order to build the Windows (configuration name `i386-cygwin32')cross MIPS ELF (configure name `mips-elf') compiler, you might executethe following commands (long command lines are broken across lines witha trailing backslash as a continuation character).mkdir linux-x-cygwin32cd linux-x-cygwin32SRCDIR/configure --target i386-cygwin32 --prefix=INSTALLDIR \--exec-prefix=INSTALLDIR/H-i386-linuxmakemake installcd ..mkdir linux-x-mips-elfcd linux-x-mips-elfSRCDIR/configure --target mips-elf --prefix=INSTALLDIR \--exec-prefix=INSTALLDIR/H-i386-linuxmakemake installcd ..mkdir cygwin32-x-mips-elfcd cygwin32-x-mips-elfSRCDIR/configure --build=i386-linux-gnu --host=i386-cygwin32 \--target=mips-elf --prefix=WININSTALLDIR \--exec-prefix=WININSTALLDIR/H-i386-cygwin32makemake installYou would then copy the contents of WININSTALLDIR over to theWindows machine, and run the resulting programs.File: configure.info, Node: Supporting Canadian Cross, Prev: CCross in Cygnus Tree, Up: Canadian CrossSupporting Canadian Cross=========================If you want to make it possible to build a program you are developingusing a Canadian Cross, you must take some care when writing yourconfigure and make rules. Simple cases will normally work correctly.However, it is not hard to write configure and make tests which willfail in a Canadian Cross.* Menu:* CCross in Configure:: Supporting Canadian Cross in Configure Scripts.* CCross in Make:: Supporting Canadian Cross in Makefiles.File: configure.info, Node: CCross in Configure, Next: CCross in Make, Up: Supporting Canadian CrossSupporting Canadian Cross in Configure Scripts----------------------------------------------In a `configure.in' file, after calling `AC_PROG_CC', you can findout whether this is a Canadian Cross configure by examining the shellvariable `cross_compiling'. In a Canadian Cross, which means that thecompiler is a cross compiler, `cross_compiling' will be `yes'. In anormal configuration, `cross_compiling' will be `no'.You ordinarily do not need to know the type of the build system in aconfigure script. However, if you do need that information, you can getit by using the macro `AC_CANONICAL_SYSTEM', the same macro that isused to determine the target system. This macro will set the variables`build', `build_alias', `build_cpu', `build_vendor', and `build_os',which correspond to the similar `target' and `host' variables, exceptthat they describe the build system.When writing tests in `configure.in', you must remember that youwant to test the host environment, not the build environment.Macros like `AC_CHECK_FUNCS' which use the compiler will test thehost environment. That is because the tests will be done by running thecompiler, which is actually a build cross host compiler. If thecompiler can find the function, that means that the function is presentin the host environment.Tests like `test -f /dev/ptyp0', on the other hand, will test thebuild environment. Remember that the configure script is running on thebuild system, not the host system. If your configure scripts examinesfiles, those files will be on the build system. Whatever you determinebased on those files may or may not be the case on the host system.Most autoconf macros will work correctly for a Canadian Cross. Themain exception is `AC_TRY_RUN'. This macro tries to compile and run atest program. This will fail in a Canadian Cross, because the programwill be compiled for the host system, which means that it will not runon the build system.The `AC_TRY_RUN' macro provides an optional argument to tell theconfigure script what to do in a Canadian Cross. If that argument isnot present, you will get a warning when you run `autoconf':warning: AC_TRY_RUN called without default to allow cross compilingThis tells you that the resulting `configure' script will not work witha Canadian Cross.In some cases while it may better to perform a test at configuretime, it is also possible to perform the test at run time. In such acase you can use the cross compiling argument to `AC_TRY_RUN' to tellyour program that the test could not be performed at configure time.There are a few other autoconf macros which will not work correctlywith a Canadian Cross: a partial list is `AC_FUNC_GETPGRP',`AC_FUNC_SETPGRP', `AC_FUNC_SETVBUF_REVERSED', and`AC_SYS_RESTARTABLE_SYSCALLS'. The `AC_CHECK_SIZEOF' macro isgenerally not very useful with a Canadian Cross; it permits an optionalargument indicating the default size, but there is no way to know whatthe correct default should be.File: configure.info, Node: CCross in Make, Prev: CCross in Configure, Up: Supporting Canadian CrossSupporting Canadian Cross in Makefiles.---------------------------------------The main Canadian Cross issue in a `Makefile' arises when you wantto use a subsidiary program to generate code or data which you will theninclude in your real program.If you compile this subsidiary program using `$(CC)' in the usualway, you will not be able to run it. This is because `$(CC)' willbuild a program for the host system, but the program is being built onthe build system.You must instead use a compiler for the build system, rather than thehost system. In the Cygnus tree, this make variable `$(CC_FOR_BUILD)'will hold a compiler for the build system.Note that you should not include `config.h' in a file you arecompiling with `$(CC_FOR_BUILD)'. The `configure' script will build`config.h' with information for the host system. However, you arecompiling the file using a compiler for the build system (a nativecompiler). Subsidiary programs are normally simple filters which do nouser interaction, and it is normally possible to write them in a highlyportable fashion so that the absence of `config.h' is not crucial.The gcc `Makefile.in' shows a complex situation in which certainfiles, such as `rtl.c', must be compiled into both subsidiary programsrun on the build system and into the final program. This approach maybe of interest for advanced build system hackers. Note that the buildsystem compiler is rather confusingly called `HOST_CC'.File: configure.info, Node: Cygnus Configure, Next: Multilibs, Prev: Canadian Cross, Up: TopCygnus Configure****************The Cygnus configure script predates autoconf. All of itsinteresting features have been incorporated into autoconf. No newprograms should be written to use the Cygnus configure script.However, the Cygnus configure script is still used in a few places:at the top of the Cygnus tree and in a few target libraries in theCygnus tree. Until those uses have been replaced with autoconf, somebrief notes are appropriate here. This is not complete documentation,but it should be possible to use this as a guide while examining thescripts themselves.* Menu:* Cygnus Configure Basics:: Cygnus Configure Basics.* Cygnus Configure in C++ Libraries:: Cygnus Configure in C++ Libraries.File: configure.info, Node: Cygnus Configure Basics, Next: Cygnus Configure in C++ Libraries, Up: Cygnus ConfigureCygnus Configure Basics=======================Cygnus configure does not use any generated files; there is noprogram corresponding to `autoconf'. Instead, there is a single shellscript named `configure' which may be found at the top of the Cygnustree. This shell script was written by hand; it was not generated byautoconf, and it is incorrect, and indeed harmful, to run `autoconf' inthe top level of a Cygnus tree.Cygnus configure works in a particular directory by examining thefile `configure.in' in that directory. That file is broken into fourseparate shell scripts.The first is the contents of `configure.in' up to a line that startswith `# per-host:'. This is the common part.The second is the rest of `configure.in' up to a line that startswith `# per-target:'. This is the per host part.The third is the rest of `configure.in' up to a line that startswith `# post-target:'. This is the per target part.The fourth is the remainder of `configure.in'. This is the posttarget part.If any of these comment lines are missing, the corresponding shellscript is empty.Cygnus configure will first execute the common part. This must setthe shell variable `srctrigger' to the name of a source file, toconfirm that Cygnus configure is looking at the right directory. Thismay set the shell variables `package_makefile_frag' and`package_makefile_rules_frag'.Cygnus configure will next set the `build' and `host' shellvariables, and execute the per host part. This may set the shellvariable `host_makefile_frag'.Cygnus configure will next set the `target' variable, and executethe per target part. This may set the shell variable`target_makefile_frag'.Any of these scripts may set the `subdirs' shell variable. Thisvariable is a list of subdirectories where a `Makefile.in' file may befound. Cygnus configure will automatically look for a `Makefile.in'file in the current directory. The `subdirs' shell variable is notnormally used, and I believe that the only directory which uses it atpresent is `newlib'.For each `Makefile.in', Cygnus configure will automatically create a`Makefile' by adding definitions for `make' variables such as `host'and `target', and automatically editing the values of `make' variablessuch as `prefix' if they are present.Also, if any of the `makefile_frag' shell variables are set, Cygnusconfigure will interpret them as file names relative to either theworking directory or the source directory, and will read the contents ofthe file into the generated `Makefile'. The file contents will be readin after the first line in `Makefile.in' which starts with `####'.These `Makefile' fragments are used to customize behaviour for aparticular host or target. They serve to select particular files tocompile, and to define particular preprocessor macros by providingvalues for `make' variables which are then used during compilation.Cygnus configure, unlike autoconf, normally does not do feature tests,and normally requires support to be added manually for each new host.The `Makefile' fragment support is similar to the autoconf`AC_SUBST_FILE' macro.After creating each `Makefile', the post target script will be run(i.e., it may be run several times). This script may further customizethe `Makefile'. When it is run, the shell variable `Makefile' willhold the name of the `Makefile', including the appropriate directorycomponent.Like an autoconf generated `configure' script, Cygnus configure willcreate a file named `config.status' which, when run, will automaticallyrecreate the configuration. The `config.status' file will simplyexecute the Cygnus configure script again with the appropriatearguments.Any of the parts of `configure.in' may set the shell variables`files' and `links'. Cygnus configure will set up symlinks from thenames in `links' to the files named in `files'. This is similar to theautoconf `AC_LINK_FILES' macro.Finally, any of the parts of `configure.in' may set the shellvariable `configdirs' to a set of subdirectories. If it is set, Cygnusconfigure will recursively run the configure process in eachsubdirectory. If the subdirectory uses Cygnus configure, it willcontain a `configure.in' file but no `configure' file, in which caseCygnus configure will invoke itself recursively. If the subdirectoryhas a `configure' file, Cygnus configure assumes that it is an autoconfgenerated `configure' script, and simply invokes it directly.File: configure.info, Node: Cygnus Configure in C++ Libraries, Prev: Cygnus Configure Basics, Up: Cygnus ConfigureCygnus Configure in C++ Libraries=================================The C++ library configure system, written by Per Bothner, deservesspecial mention. It uses Cygnus configure, but it does feature testinglike that done by autoconf generated `configure' scripts. Thisapproach is used in the libraries `libio', `libstdc++', and `libg++'.Most of the `Makefile' information is written out by the shellscript `libio/config.shared'. Each `configure.in' file sets certainshell variables, and then invokes `config.shared' to create two package`Makefile' fragments. These fragments are then incorporated into theresulting `Makefile' by the Cygnus configure script.The file `_G_config.h' is created in the `libio' object directory byrunning the shell script `libio/gen-params'. This shell script usesfeature tests to define macros and typedefs in `_G_config.h'.File: configure.info, Node: Multilibs, Next: FAQ, Prev: Cygnus Configure, Up: TopMultilibs*********For some targets gcc may have different processor requirementsdepending upon command line options. An obvious example is the`-msoft-float' option supported on several processors. This optionmeans that the floating point registers are not available, which meansthat floating point operations must be done by calling an emulationsubroutine rather than by using machine instructions.For such options, gcc is often configured to compile target librariestwice: once with `-msoft-float' and once without. When gcc compilestarget libraries more than once, the resulting libraries are called"multilibs".Multilibs are not really part of the GNU configure and build system,but we discuss them here since they require support in the `configure'scripts and `Makefile's used for target libraries.* Menu:* Multilibs in gcc:: Multilibs in gcc.* Multilibs in Target Libraries:: Multilibs in Target Libraries.File: configure.info, Node: Multilibs in gcc, Next: Multilibs in Target Libraries, Up: MultilibsMultilibs in gcc================In gcc, multilibs are defined by setting the variable`MULTILIB_OPTIONS' in the target `Makefile' fragment. Several other`MULTILIB' variables may also be defined there. *Note The TargetMakefile Fragment: (gcc)Target Fragment.If you have built gcc, you can see what multilibs it uses by runningit with the `-print-multi-lib' option. The output `.;' means that nomultilibs are used. In general, the output is a sequence of lines, oneper multilib. The first part of each line, up to the `;', is the nameof the multilib directory. The second part is a list of compileroptions separated by `@' characters.Multilibs are built in a tree of directories. The top of the tree,represented by `.' in the list of multilib directories, is the defaultlibrary to use when no special compiler options are used. Thesubdirectories of the tree hold versions of the library to use whenparticular compiler options are used.
Go to most recent revision | Compare with Previous | Blame | View Log
