FreeBSD Porter's Handbook
前一頁 | 章 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 節). 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

前一頁 | 內容 | 下一頁
Marking a port for removal with `DEPRECATED` or `EXPIRATION_DATE` | 上一層 | `sysctl` 使用時機

For questions about the FreeBSD ports system, e-mail <ports@FreeBSD.org>.
For questions about this documentation, e-mail <doc@FreeBSD.org>.