# 5.15.特殊的工作目录

每个 Port 都会被提取到一个工作目录中，该目录必须是可写的。Ports 系统默认将 `DISTFILES` 解压到一个名为 `${DISTNAME}` 的目录中。换句话说，如果 **Makefile** 中有：

```makefile
PORTNAME=	foo
DISTVERSION=	1.0
```

那么该 Port 的分发文件会包含一个顶级目录 **foo-1.0**，其余的文件都位于该目录下。

如果不是这种情况，可以覆盖一些变量。

## 5.15.1. `WRKSRC`

该变量列出了提取时创建的目录名。如果我们之前的例子中，文件解压到了一个名为 **foo** 的目录（而不是 **foo-1.0**），那么可以写：

```makefile
WRKSRC=	${WRKDIR}/foo
```

或者可能是：

```makefile
WRKSRC=	${WRKDIR}/${PORTNAME}
```

## 5.15.2. `WRKSRC_SUBDIR`

如果所需的源文件位于提取的分发文件的子目录中，请将 `WRKSRC_SUBDIR` 设置为该目录。

```makefile
WRKSRC_SUBDIR=	src
```

## 5.15.3. `NO_WRKSUBDIR`

如果 Port 完全没有提取到子目录中，则将 `NO_WRKSUBDIR` 设置为 `yes` 来指示这一点。

```makefile
NO_WRKSUBDIR=	yes
```

> **注意**
>
> 由于 `WRKDIR` 是构建过程中唯一应当可写的目录，并且用于存储记录构建状态的许多文件，因此 Port 的提取将被强制进入一个子目录。


---

# 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-5-zhang-pei-zhi-makefile/5.15.-te-shu-de-gong-zuo-mu-lu.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.
