12.10. Respect both `CC` and `CXX`
前一頁 | 章 12. Dos and Don'ts | 下一頁

## 12.10. Respect both `CC` and `CXX`

The port should respect both `CC` and `CXX` variables. What we mean by this is that the port should not set the values of these variables absolutely, overriding existing values; instead, it should append whatever values it needs to the existing values. This is so that build options that affect all ports can be set globally.

If the port does not respect these variables, please add `NO_PACKAGE=ignores either cc or cxx` to the `Makefile`.

An example of a `Makefile` respecting both `CC` and `CXX` variables follows. Note the `?=`:

CC?= gcc
CXX?= g++

Here is an example which respects neither `CC` nor `CXX` variables:

CC= gcc
CXX= g++

Both `CC` and `CXX` variables can be defined on FreeBSD systems in `/etc/make.conf`. The first example defines a value if it was not previously set in `/etc/make.conf`, preserving any system-wide definitions. The second example clobbers anything previously defined.

前一頁 | 上一層 | 下一頁
12.9. Do things rationally | 起始頁 | 12.11. Respect `CFLAGS`

本文及其他文件，可由此下載： ftp://ftp.FreeBSD.org/pub/FreeBSD/doc/。

若有 FreeBSD 方面疑問，請先閱讀 FreeBSD 相關文件，如不能解決的話，再洽詢 <questions@FreeBSD.org>。
關於本文件的問題，請洽詢 <doc@FreeBSD.org>。