# 5.8. MASTERDIR

5.8. `MASTERDIR`
前一頁 | 章 5. 設定 Makefile | 下一頁

## 5.8. `MASTERDIR`

If your port needs to build slightly different versions of packages by having a variable (for instance, resolution, or paper size) take different values, create one subdirectory per package to make it easier for users to see what to do, but try to share as many files as possible between ports. Typically you only need a very short `Makefile` in all but one of the directories if you use variables cleverly. In the sole `Makefile`, you can use `MASTERDIR` to specify the directory where the rest of the files are. Also, use a variable as part of `PKGNAMESUFFIX` so the packages will have different names.

This will be best demonstrated by an example. This is part of `japanese/xdvi300/Makefile`;

PORTNAME= xdvi PORTVERSION= 17 PKGNAMEPREFIX= ja- PKGNAMESUFFIX= ${RESOLUTION} : # default RESOLUTION?= 300 .if ${RESOLUTION} != 118 && ${RESOLUTION} != 240 && \ ${RESOLUTION} != 300 && ${RESOLUTION} != 400 @${ECHO_MSG} "Error: invalid value for RESOLUTION: \"${RESOLUTION}\"" @${ECHO_MSG} "Possible values are: 118, 240, 300 (default) and 400." @${FALSE} .endif

`japanese/xdvi300` also has all the regular patches, package files, etc. If you type `make` there, it will take the default value for the resolution (300) and build the port normally.

As for other resolutions, this is the entire `xdvi118/Makefile`:

RESOLUTION= 118 MASTERDIR= ${.CURDIR}/../xdvi300 .include "${MASTERDIR}/Makefile"

(`xdvi240/Makefile` and `xdvi400/Makefile` are similar). The `MASTERDIR` definition tells `bsd.port.mk` that the regular set of subdirectories like `FILESDIR` and `SCRIPTDIR` are to be found under `xdvi300`. The `RESOLUTION=118` line will override the `RESOLUTION=300` line in `xdvi300/Makefile` and the port will be built with resolution set to 118.

前一頁 | 上一層 | 下一頁
5.7. Dependencies | 起始頁 | 5.9. Manpages

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

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