| || |
A `configure' script for a cross compilation tool will use the `--target' option to control how it is built, so that the resulting program will produce programs which run on the appropriate system. In this section we explain how you can write your own configure scripts to support the `--target' option.
You must start by putting `AC_CANONICAL_SYSTEM' in `configure.in' .
The host and target type will be recorded in the following shell variables :
Note that if `host' and `target' are the same string, you can assume a native configuration. If they are different, you can assume a cross configuration.
It is possible for `host' and `target' to represent the same system, but for the strings to not be identical. For example, if `config.guess' returns `sparc-sun-sunos4.1.4' , and somebody configures with `--target sparc-sun-sunos4.1' , then the slight differences between the two versions of SunOS may be unimportant for your tool. However, in the general case it can be quite difficult to determine whether the differences between two configuration names are significant or not. Therefore, by convention, if the user specifies a `--target' option without specifying a `--host' option, it is assumed that the user wants to configure a cross compilation tool.
The `target' variable should not be handled in the same way as the `target_alias' variable. In general, whenever the user may actually see a string, `target_alias' should be used. This includes anything which may appear in 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 the canonical target configuration name. This permits the user to use the `--target' option to specify how the tool will appear to the outside world. On the other hand, when checking for characteristics of the target system, `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 the argument used with the `--target' option, also known as `target_alias' . If the user does not use the `--target' option, and thus is building a native tool, no prefix is used. For example, if
The Autoconf macro `AC_ARG_PROGRAM' will handle the names of binaries for you. If you are using Automake, no more need be done; the programs will automatically be installed with the correct prefixes. Otherwise, see the Autoconf documentation for `AC_ARG_PROGRAM' .