# 3.1.编写 Makefile

本节说明了如何快速创建一个新的 Port。对于那些快速方法不够充分的应用程序，完整的“慢速移植”过程在 [慢速移植](https://docs.freebsd.org/en/books/porters-handbook/slow-porting/#slow-porting) 中有详细说明。

首先，获取原始的 tarball 文件并将其放入 `DISTDIR`，默认路径为 **/usr/ports/distfiles**。

> **注意**
>
> 这些步骤假设软件可以开箱即用编译运行。换句话说，应用程序在 FreeBSD 系统上工作时完全不需要修改。如果需要修改，请参考 [慢速移植](https://docs.freebsd.org/en/books/porters-handbook/slow-porting/#slow-porting)。

> **注意**
>
> 建议在进行移植之前，在 `/etc/make.conf` 中设置 make(1) 变量 `DEVELOPER` 。
>
> ```makefile
> # echo DEVELOPER=yes >> /etc/make.conf
> ```
>
> 此设置启用“开发者模式”，该模式会显示弃用警告，并在调用 make 时激活一些额外的质量检查。

***

**Makefile** 的最简版本看起来如下所示：

```makefile
PORTNAME=	oneko
DISTVERSION=	1.1b
CATEGORIES=	games
MASTER_SITES=	ftp://ftp.rediris.es/sites/ftp.freebsd.org/pub/FreeBSD/

MAINTAINER=	youremail@example.com
COMMENT=	Cat chasing a mouse all over the screen
WWW=		http://www.daidouji.com/oneko/

.include <bsd.port.mk>
```

尝试理解它。更详细的示例请参见 [示例 Makefile](https://docs.freebsd.org/en/books/porters-handbook/porting-samplem/#porting-samplem) 部分。


---

# 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-3-zhang-jian-dan-de-port/3.1.-bian-xie-makefile.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.
