# External configuration via environment variables
To control the programs and flags used for building, the builder can set a number of different environment variables.
To control the programs and flags used for building, the builder can set a
number of different environment variables.
* `CFLAGS` - a series of space seperated flags passed to "gcc". Note that
individual flags cannot currently contain spaces, so doing
something like: "-L=foo\ bar" is not possible.
@ -30,35 +32,50 @@ To control the programs and flags used for building, the builder can set a numbe
common is `-fPIC`).
* `AR` - the `ar` (archiver) executable to use to build the static library.
Each of these variables can also be supplied with certain prefixes and suffixes, in the following prioritized order:
Each of these variables can also be supplied with certain prefixes and suffixes,
in the following prioritized order:
1. `<var>_<target>` - for example, `CC_x86_64-unknown-linux-gnu`
1. `<var>_<target_with_underscores>` - for example, `CC_x86_64_unknown_linux_gnu`
1. `<build-kind>_<var>` - for example, `HOST_CC` or `TARGET_CFLAGS`
1. `<var>` - a plain `CC`, `AR` as above.
2. `<var>_<target_with_underscores>` - for example, `CC_x86_64_unknown_linux_gnu`
3. `<build-kind>_<var>` - for example, `HOST_CC` or `TARGET_CFLAGS`
4. `<var>` - a plain `CC`, `AR` as above.
If none of these varaibles exist, gcc-rs uses built-in defaults
In addition to the the above optional environment variables, `gcc-rs` has some functions with hard requirements on some variables supplied by [cargo's build-script driver][cargo] that it has the `TARGET`, `OUT_DIR`, `OPT_LEVEL`, and `HOST` variables
In addition to the the above optional environment variables, `gcc-rs` has some
functions with hard requirements on some variables supplied by [cargo's
build-script driver][cargo] that it has the `TARGET`, `OUT_DIR`, `OPT_LEVEL`,
`gcc-rs` supports C++ libraries compilation by using the `cpp` method on `Config`:
`gcc-rs` supports C++ libraries compilation by using the `cpp` method on
`Config`:
```rust,no_run
extern crate gcc;
@ -71,7 +88,9 @@ fn main() {
}
```
When using C++ library compilation switch, the `CXX` and `CXXFLAGS` env variables are used instead of `CC` and `CFLAGS` and the C++ standard library is linked to the crate target.
When using C++ library compilation switch, the `CXX` and `CXXFLAGS` env
variables are used instead of `CC` and `CFLAGS` and the C++ standard library is