12.6. Writing something after `bsd.port.mk`
前一頁 | 章 12. Dos and Don'ts | 下一頁

## 12.6. Writing something after `bsd.port.mk`

Do not write anything after the `.include <bsd.port.mk>` line. It usually can be avoided by including `bsd.port.pre.mk` somewhere in the middle of your `Makefile` and `bsd.port.post.mk` at the end.

### 注意:

You need to include either the `bsd.port.pre.mk`/`bsd.port.post.mk` pair or `bsd.port.mk` only; do not mix these two usages.

`bsd.port.pre.mk` only defines a few variables, which can be used in tests in the `Makefile`, `bsd.port.post.mk` defines the rest.

Here are some important variables defined in `bsd.port.pre.mk` (this is not the complete list, please read `bsd.port.mk` for the complete list).

Variable | Description
--- | ---
`ARCH` | The architecture as returned by `uname -m` (e.g., `i386`)
`OPSYS` | The operating system type, as returned by `uname -s` (e.g., `FreeBSD`)
`OSREL` | The release version of the operating system (e.g., `2.1.5` or `2.2.7`)
`OSVERSION` | The numeric version of the operating system; the same as `__FreeBSD_version`.
`PORTOBJFORMAT` | The object format of the system (`elf` or `aout`; note that for “modern” versions of FreeBSD, `aout` is deprecated.)
`LOCALBASE` | The base of the “local” tree (e.g., `/usr/local/`)
`PREFIX` | Where the port installs itself (see more on `PREFIX`).

### 注意:

If you have to define the variables `USE_IMAKE`, `USE_X_PREFIX`, or `MASTERDIR`, do so before including `bsd.port.pre.mk`.

Here are some examples of things you can write after `bsd.port.pre.mk`:

# no need to compile lang/perl5 if perl5 is already in system .if ${OSVERSION} > 300003 BROKEN= perl is in system .endif # only one shlib version number for ELF .if ${PORTOBJFORMAT} == "elf" TCL_LIB_FILE= ${TCL_LIB}.${SHLIB_MAJOR} .else TCL_LIB_FILE= ${TCL_LIB}.${SHLIB_MAJOR}.${SHLIB_MINOR} .endif # software already makes link for ELF, but not for a.out post-install: .if ${PORTOBJFORMAT} == "aout" ${LN} -sf liblinpack.so.1.0 ${PREFIX}/lib/liblinpack.so .endif

You did remember to use tab instead of spaces after `BROKEN=` and `TCL_LIB_FILE=`, did you not? :-).

前一頁 | 上一層 | 下一頁
12.5. FreeBSD 版本速查表(__FreeBSD_version) | 起始頁 | 12.7. 在 wrapper scripts 中使用 `exec` 述句

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

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