# 9.5.使用 SUB\_FILES 和 SUB\_LIST

`SUB_FILES` 和 `SUB_LIST` 是用于在 port 文件中动态插入值的工具，例如在 **pkg-message** 中插入安装的 `PREFIX`。

`SUB_FILES` 指定一个文件列表，这些文件会被自动修改。`SUB_FILES` 列表中的每个文件必须在 `FILESDIR` 中有对应的 **file.in** 文件。修改后的文件将创建在 **${WRKDIR}/file** 中。定义为 `USE_RC_SUBR` 值的文件会自动添加到 `SUB_FILES` 中。对于文件 **pkg-message**、**pkg-install** 和 **pkg-deinstall**，相应的 Makefile 变量会自动设置为指向处理过的版本。

`SUB_LIST` 是一组 `VAR=VALUE` 键值对。在每个文件中的 `%%VAR%%` 会被替换为 `VALUE`。几个常见的键值对会自动定义：`PREFIX`、`LOCALBASE`、`DATADIR`、`DOCSDIR`、`EXAMPLESDIR`、`WWWDIR` 和 `ETCDIR`。任何以 `@comment` 开头并后跟空格的行，在变量替换后将从结果文件中删除。

以下示例将 `%%ARCH%%` 替换为系统架构，并插入到 **pkg-message** 中：

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

注意：在这个例子中，**pkg-message.in** 必须存在于 `FILESDIR` 中。

一个良好的 **pkg-message.in** 示例：

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


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://porters-handbook.bsdcn.org/di-9-zhang-pkg/9.5.-shi-yong-subfiles-he-sublist.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
