8.6. Making use of `SUB_FILES` and `SUB_LIST`
前一頁 | 章 8. The `pkg-`*`` files | 下一頁

## 8.6. Making use of `SUB_FILES` and `SUB_LIST`

The `SUB_FILES` and `SUB_LIST` variables are useful for dynamic values in port files, such as the installation `PREFIX` in `pkg-message`.

The `SUB_FILES` variable specifies a list of files to be automatically modified. Each `file` in the `SUB_FILES` list must have a corresponding ``file`.in` present in `FILESDIR`. A modified version will be created in `WRKDIR`. Files defined as a value of `USE_RC_SUBR` (or the deprecated `USE_RCORDER`) are automatically added to the `SUB_FILES`. For the files `pkg-message`, `pkg-install`, `pkg-deinstall` and `pkg-reg`, the corresponding Makefile variable is automatically set to point to the processed version.

The `SUB_LIST` variable is a list of `VAR=VALUE` pairs. For each pair `%%VAR%%` will get replaced with `VALUE` in each file listed in `SUB_FILES`. Several common pairs are automatically defined: `PREFIX`, `LOCALBASE`, `DATADIR`, `DOCSDIR`, `EXAMPLESDIR`. Any line beginning with `@comment` will be deleted from resulting files after a variable substitution.

The following example will replace `%%ARCH%%` with the system architecture in a `pkg-message`:

SUB_FILES= pkg-message SUB_LIST= ARCH=${ARCH}

Note that for this example, the `pkg-message.in` file must exist in `FILESDIR`.

Example of a good `pkg-message.in`:

Now it is time to configure this package. Copy %%PREFIX%%/share/examples/putsy/%%ARCH%%.conf into your home directory as .putsy.conf and edit it.

前一頁 | 上一層 | 下一頁
8.5. Changing the names of `pkg-`*`` files | 起始頁 | 章 9. Testing your port

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

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