12.17. Avoid use of the `.error` construct
前一頁 | 章 12. Dos and Don'ts | 下一頁

## 12.17. Avoid use of the `.error` construct

The correct way for a `Makefile` to signal that the port can not be installed due to some external factor (for instance, the user has specified an illegal combination of build options) is to set a nonblank value to `IGNORE`. This value will be formatted and shown to the user by `make install`.

It is a common mistake to use `.error` for this purpose. The problem with this is that many automated tools that work with the ports tree will fail in this situation. The most common occurrence of this is seen when trying to build `/usr/ports/INDEX` (see 節 9.1, “Running `make describe`”). However, even more trivial commands such as `make -V maintainer` also fail in this scenario. This is not acceptable.

範例 12.1. How to avoid using `.error`

Assume that someone has the line

USE_POINTYHAT=yes

in `make.conf`. The first of the next two `Makefile` snippets will cause `make index` to fail, while the second one will not:

.if USE_POINTYHAT .error "POINTYHAT is not supported" .endif
.if USE_POINTYHAT IGNORE=POINTYHAT is not supported .endif

前一頁 | 上一層 | 下一頁
12.16. Marking a port for removal with `DEPRECATED` or `EXPIRATION_DATE` | 起始頁 | 12.18. `sysctl` 使用時機

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

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