doc/zh_TW.UTF-8/books/porters-handbook/book.xml
Li-Wen Hsu 163ba6b752 Convert zh_TW from Big5 to UTF-8.
Approved by:	bcr
2014-05-29 16:48:07 +00:00

12963 lines
430 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<?xml version="1.0" encoding="utf-8"?>
<!DOCTYPE book PUBLIC "-//FreeBSD//DTD DocBook XML V5.0-Based Extension//EN"
"http://www.FreeBSD.org/XML/share/xml/freebsd50.dtd">
<!--
The FreeBSD Documentation Project
$FreeBSD$
Original Revision: 1.954
-->
<book xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" xml:lang="zh_tw">
<info><title>FreeBSD Porter's Handbook</title>
<authorgroup>
<author><orgname>FreeBSD 文件計劃</orgname></author>
</authorgroup>
<pubdate>April 2000</pubdate>
<copyright>
<year>2000</year>
<year>2001</year>
<year>2002</year>
<year>2003</year>
<year>2004</year>
<year>2005</year>
<year>2006</year>
<year>2007</year>
<year>2008</year>
<holder role="mailto:doc@FreeBSD.org">FreeBSD 文件計劃</holder>
</copyright>
&trademarks;
&legalnotice;
<releaseinfo>$FreeBSD$</releaseinfo>
</info>
<chapter xml:id="why-port">
<title>楔子</title>
<para>幾乎每個 FreeBSD 愛用者都是透過 FreeBSD Ports Collection
來裝各式應用程式("ports")。如同 FreeBSD 的其他部分一樣,
這些 ports 都主要來自許多志工的努力成果,所以在閱讀這份文件時,
請務必感恩在心。</para>
<para>在 FreeBSD 上面,每個人都可以提交新的 port
或假如該 port 並沒有人維護的話,可以自願維護 &mdash;
這點並不需要任何 commit 的權限,就可以來做這件事情。</para>
</chapter>
<chapter xml:id="own-port">
<title>自行打造 port</title>
<para>那麼,開始對自行製作 port 或更新有一些興趣了嗎?太好囉!</para>
<para>下面將介紹一些建立 port 時該注意的事項。如果是想升級現有的 port
,那麼也請參閱 <xref linkend="port-upgrading"/> 說明。</para>
<para>因為這份文件可能講得不是十分詳細,可能需要參考
<filename>/usr/ports/Mk/bsd.port.mk</filename> 這檔是所有 port 的
Makefile 檔都會用到的。 就算你不是每天不斷 hacking Makefiles
,也都可以藉由它來對整個 port 機制、Makefile 更瞭解,
裡面的註釋相當詳細。 此外,若有其他特定 port 的問題,也可以到
&a.ports; 來獲得答案。</para>
<note>
<para>本文內所提及的環境變數
(<varname><replaceable>VAR</replaceable></varname>)部份,
只有一些可以替換(overridden)。大部份的環境變數(非全部)通常都會寫在
<filename>/usr/ports/Mk/bsd.port.mk</filename> 內,其他的也是差不多。
請注意:該檔並非使用一般的 tab 設定值,而是採用 1 個 tab 等於 4 個
space。 <application>Emacs</application>
<application>Vim</application> 應該都會在載入該檔時順便讀取相關設定值。
&man.vi.1;&man.ex.1; 這兩個程式也都可以打
<command>:set tabstop=4</command> 以修改設定值。</para>
</note>
</chapter>
<chapter xml:id="quick-porting">
<title>打造 Port 快速上手篇</title>
<para>本節主要介紹如何來快速打造 port然而
很多時候這些內容並不是很夠用,建議閱讀本文件中更深奧的地方。</para>
<para>首先取得該應用程式的原始程式碼壓縮檔(tarball),並把它放到
<varname>DISTDIR</varname>,預設路徑應該是
<filename>/usr/ports/distfiles</filename></para>
<note>
<para>下面的例子,是假設並不需要再修改該應用程式的原始碼,就可以在
FreeBSD 上編譯成功的;假如還需要另外修改才能成功編譯的話,
那麼請參考下一章的說明。</para>
</note>
<sect1 xml:id="porting-makefile">
<title>編寫 <filename>Makefile</filename></title>
<para>最簡單的 <filename>Makefile</filename> 大概是像這樣:</para>
<programlisting># New ports collection makefile for: oneko
# Date created: 5 December 1994
# Whom: asami
#
# &dollar;FreeBSD&dollar;
#
PORTNAME= oneko
PORTVERSION= 1.1b
CATEGORIES= games
MASTER_SITES= ftp://ftp.cs.columbia.edu/archives/X11R5/contrib/
MAINTAINER= asami@FreeBSD.org
COMMENT= A cat chasing a mouse all over the screen
MAN1= oneko.1
MANCOMPRESSED= yes
USE_IMAKE= yes
.include &lt;bsd.port.mk&gt;</programlisting>
<para>嗯,大致就是這樣,看看你已經領略多少了呢?
看到 <literal>&dollar;FreeBSD&dollar;</literal> 這一行的話,別想太多
,它是 RCS ID 用途,當該 port 正式進入 port tree 時,
CVS 就會自動轉換為相關字串囉。 有關這點的細節部份,可以參閱 <link linkend="porting-samplem">sample Makefile</link> 章節。</para>
</sect1>
<sect1 xml:id="porting-desc">
<title>撰寫該軟體的說明檔</title>
<para>無論是否打算再加工做成 package有 2 個檔案是任何實體 port (Slave
port則不一定)都必須要具備的。 這 2 個檔分別是
<filename>pkg-descr</filename> 檔及 <filename>pkg-plist</filename>
檔。 這兩個檔案檔名前面都有 <filename>pkg-</filename>
以跟其他檔案做區別。</para>
<sect2>
<title><filename>pkg-descr</filename></title>
<para>這是此 port 的詳細說明檔,請用一段或幾段文字來說明該 port
的作用,並附上 WWW 網址(若有的話)。</para>
<note>
<para>請注意,這檔絕非「該軟體的說明手冊」或是「如何編譯、使用該
port 的說明」。 若是從該軟體的 <filename>README</filename>
或 manpage 直接複製過來的話,請注意,因為它們通常都寫得太詳細、
格式較特別(比如 manpage 會自動調整空白)
請儘量避免這些冗長贅詞或採用特殊格式。若該軟體有官方版首頁的話,
請在此列出來。 每個網址請用 <literal>WWW:</literal> 作為開頭,
這樣子相關工具程式就會自動處理完畢。</para>
</note>
<para>該 port 的 <filename>pkg-descr</filename> 內容,大致如下面例子
</para>
<programlisting>This is a port of oneko, in which a cat chases a poor mouse all over
the screen.
:
(etc.)
WWW: http://www.oneko.org/</programlisting>
</sect2>
<sect2>
<title><filename>pkg-plist</filename></title>
<para>這是該 port 所會裝的所有檔案清單,另外因為 package
會由這清單所產生因此也被稱為『packing list
(打包清單)』。 以 <literal>${PREFIX}</literal> 為基準點,
而用相對路徑表示。(<literal>${PREFIX}</literal> 通常是
<filename>/usr/local</filename><filename>/usr/X11R6</filename>)
但是如果該程式有安裝 man page 的話,則要以類似
<varname>MAN<replaceable>n</replaceable>=</varname> 的方式寫在
<filename>Makefile</filename> 內,不能列在
<filename>pkg-plist</filename> 哦。
除了列出檔案以外,也要把該 port 所會建立的目錄也列進去,
方式有兩種:一種是寫在 <filename>pkg-plist</filename> 內的方式,
比如:<literal>@dirrm</literal>。 至於另外一種方式,則是寫在
<filename>Makefile</filename> 內,比如:
<literal>PLIST_FILES=</literal> 之類的方式。</para>
<para>該 port 的 <filename>pkg-plist</filename> 內容,
大致如下面例子:</para>
<programlisting>bin/oneko
lib/X11/app-defaults/Oneko
lib/X11/oneko/cat1.xpm
lib/X11/oneko/cat2.xpm
lib/X11/oneko/mouse.xpm
@dirrm lib/X11/oneko</programlisting>
<para>關於 packing list 方面,可以參閱 &man.pkg.create.1; 會有詳解
</para>
<note>
<para>建議清單內的檔名,依照字母順序作排序,那麼下次要升級時,
會比較清楚、方便來更新這份清單。 </para>
</note>
<note>
<para>手動生這份清單實在太苦了。尤其若該 port 會裝一大堆檔案的話,
請多善用 <link linkend="plist-autoplist">自動產生 packing
list</link> 會比較省時省力唷。</para>
</note>
<para>只有在一種情況下可以省略不用生 <filename>pkg-plist</filename>
檔: 若安裝的 port 相當單純,只有裝一些檔案,
以及都在同一目錄下的話,那麼可以在 <filename>Makefile</filename>
內改用 <varname>PLIST_FILES</varname>
<varname>PLIST_DIRS</varname> 來取代。
比如,可以在上述的 <filename>oneko</filename> port 內不必附上
<filename>pkg-plist</filename> ,而只需在
<filename>Makefile</filename> 內加入下列幾行:</para>
<programlisting>PLIST_FILES= bin/oneko \
lib/X11/app-defaults/Oneko \
lib/X11/oneko/cat1.xpm \
lib/X11/oneko/cat2.xpm \
lib/X11/oneko/mouse.xpm
PLIST_DIRS= lib/X11/oneko</programlisting>
<para>當然,若該 port 並無安裝自屬的目錄的話,就不必設
<varname>PLIST_DIRS</varname> 囉。</para>
<para>然而,使用 <varname>PLIST_FILES</varname>
<varname>PLIST_DIRS</varname> 是必須付出代價:
不能使用 &man.pkg.create.1; 內所說的 command sequences。
因此,這招僅適用於較簡單的 port ,以及簡化該 port 的作法。
此外,這招還有一個好處:可以減少 ports collection 的整體檔案總數。
所以,在考慮是否一定要用 <filename>pkg-plist</filename> 之前,
可以先斟酌這個替代方案看看。</para>
<para>後面會介紹到如何運用 <filename>pkg-plist</filename>
<varname>PLIST_FILES</varname> 這些技巧以因應 <link linkend="plist">更複雜的狀況</link></para>
</sect2>
</sect1>
<sect1 xml:id="porting-checksum">
<title>產生 checksum 用途的 distinfo 檔</title>
<para>只要打『<command>make makesum</command>』就好了,
接下來就會自動產生相對應的 <filename>distinfo</filename> 檔了唷
</para>
<para>若抓下來的檔案,它的 checksum 會經常變更,
而你也很確認所抓的來源是正確無誤的話,
(比如:來源是光碟或是每天自動產生的文件),那麼可以設定那些檔案為
<varname>IGNOREFILES</varname> 。 如此一來,在打
<command>make makesum</command> 的時候就不會計算那些檔案的 checksum
,而自動改為 <literal>IGNORE</literal> 囉。</para>
</sect1>
<sect1 xml:id="porting-testing">
<title>檢驗 port 是否完整、可行</title>
<para>接下來,必須檢驗是否有符合 port 的遊戲規則,包括打包該 port
為 package。 以下有幾個需要確認的重要地方:</para>
<itemizedlist>
<listitem>
<para>若該 port 沒裝的東西,不要列在 <filename>pkg-plist</filename>
內。</para>
</listitem>
<listitem>
<para>若該 port 有裝的東西,請務必列在
<filename>pkg-plist</filename> 內。</para>
</listitem>
<listitem>
<para>該 port 可以用 <command>reinstall</command> 來重新安裝
</para>
</listitem>
<listitem>
<para>該 port 在移除之後,確定都可 <link linkend="plist-cleaning">cleans up</link></para>
</listitem>
</itemizedlist>
<procedure>
<title>建議的測試步驟順序:</title>
<step>
<para><command>make install</command></para>
</step>
<step>
<para><command>make package</command></para>
</step>
<step>
<para><command>make deinstall</command></para>
</step>
<step>
<para><command>pkg_add package-name
</command></para>
</step>
<step>
<para><command>make deinstall</command></para>
</step>
<step>
<para><command>make reinstall</command></para>
</step>
<step>
<para><command>make package</command></para>
</step>
</procedure>
<para>確認在 <buildtarget>package</buildtarget>
<buildtarget>deinstall</buildtarget> 這兩個階段都沒有任何錯誤訊息出現。
完成第三步驟之後,檢查一下是否所裝的檔案、目錄都有移除完畢。 此外,
第四步驟完成後,也檢查一下以 package 裝的該軟體,是否都能正常運作
</para>
<para>最周密的自動方式就是透過裝
<application>ports tinderbox</application>。 它會建立
<literal>jails</literal> 並管理之,以便您可以測試上述所有步驟,
而不會真正影響您本身的作業系統。 詳情請參考
<filename>ports/ports-mgmt/tinderbox</filename></para>
</sect1>
<sect1 xml:id="porting-portlint">
<title><command>portlint</command> 來作檢驗</title>
<para>請用 <command>portlint</command> 來檢查該 port
是否有遵循上述遊戲規則。 說到這
<package>ports-mgmt/portlint</package>,它是
ports collection 的其中一個套件。 它主要可以用來檢驗 <link linkend="porting-samplem">Makefile</link> 內容是否正確以及 <link linkend="porting-pkgname">package</link> 是否有正確命名。</para>
</sect1>
<sect1 xml:id="porting-submitting">
<title>提交(Submit) port</title>
<para>首先,請確認是否有瞭解 <link linkend="porting-dads">DOs and DON'Ts</link> 該章部分。</para>
<para>現在你很高興終於打造出 port 來囉,唯一剩下要做的就是把它正式放到
FreeBSD ports tree 內,才能讓每個人都能分享使用這個 port。 請先拿掉
<filename>work</filename> 目錄或檔名像是
<filename>pkgname.tgz</filename> 的 package 可以砍掉。 接著,
只要用 <command>shar `find port_dir`</command> 來產生 shar 格式,
並配合 &man.send-pr.1; 程式以提交出去。(&man.send-pr.1;
的部分可以參閱 <link xlink:href="&url.articles.contributing;/contrib-how.html#CONTRIB-GENERAL">
錯誤報告和意見發表</link>)</para>
<para>記得在填寫 PR 時『分類(Category)』選 <literal>ports</literal>
還有『種類(Class)』填 <literal>change-request</literal>
(千萬別傻傻地把該 PR 的『Confidential(機密)』設為 yes)
此外在『描述(<quote>Description</quote>)』
那邊寫上該程式的簡潔說明,而 shar 檔則附在『修正(<quote>Fix</quote>)
』欄位內。</para>
<note>
<para>若 Synopsis 欄清楚描述該 PR 重點的話,那麼會讓整個流程更為順暢。
new ports 的話,我們習慣用:
<quote>New port: &lt;category&gt;/&lt;portname&gt;
&lt;該 port 的簡介&gt;</quote> ,而更新 port 的話,則是
<quote>Update port: &lt;category&gt;/&lt;portname&gt;
&lt;本次 update 的簡介&gt;</quote>
若你也採用這樣的格式的話,那麼會被受理的機會就會越高囉。</para>
</note>
<para>再次強調一點:<emphasis>不必附上原始 source 的 distfile
,也就是 <filename>work</filename> 目錄。 同時,也不必附上
<command>make package</command> 時產生的 package</emphasis></para>
<para>送出 port 之後,請耐心等候佳音。
有時候可能需要等個幾天或幾個月時間,才會在 FreeBSD ports tree
上正式出現。 此外,隨時可以查閱 <link xlink:href="http://www.FreeBSD.org/cgi/query-pr-summary.cgi?category=ports">
等待 committed to FreeBSD 的 port</link> 列表。</para>
<para>一旦我們開始處理你送來的 port 之後,如果有一些意見需要溝通的話,
那麼會先 feedback 給你,
之後確定都沒問題,就會放到 port tree 內囉!
你的大名會被記在 <link xlink:href="&url.articles.contributors;/contrib-additional.html">Additional FreeBSD Contributors</link>
列表上,以及其他檔案。聽起來,挺不賴的不是嗎!? <!-- smiley
-->:-)</para>
</sect1>
</chapter>
<chapter xml:id="slow">
<title>Slow Porting</title>
<para>Ok...事實上並不太可能這麼簡單port
方面可能需要作些修改才能正常使用。 因此,
本節將一步一步來介紹如何修改上一章的樣本以正常使用。</para>
<sect1 xml:id="slow-work">
<title>How things work</title>
<para>首先,先介紹一下在你所作的 port 目錄內打 <command>make</command>
時,所會作哪些事情的順序吧。
你可以另開一窗來看 <filename>bsd.port.mk</filename>
內容,以便瞭解我們下面在講什麼。</para>
<para>但別太擔心是否完全看懂
<filename>bsd.port.mk</filename> 在做啥,很多人都還沒完全看完...
<!-- smiley --><emphasis>:-&gt;</emphasis></para>
<procedure>
<step>
<para>首先,進行 <buildtarget>fetch</buildtarget> 階段。
<buildtarget>fetch</buildtarget> 是確認 tarball 檔有沒有已在
<varname>DISTDIR</varname> 內了?若 <buildtarget>fetch</buildtarget>
<varname>DISTDIR</varname> 找不到的話,它會搜尋 Makefile
內的 <varname>MASTER_SITES</varname> URL
,或者是主 FTP 站專門放備份 distfiles 的目錄 <uri xlink:href="ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/">ftp://ftp.FreeBSD.org/pub/FreeBSD/ports/distfiles/</uri>
。 假設都找不到的話,但是網路有接上 Internet 的話,它會試著用
<varname>FETCH</varname> 來抓所指定的檔案。
抓到之後,它會把檔案存到 <varname>DISTDIR</varname>
以便開始使用或日後運用。</para>
</step>
<step>
<para>其次,進行 <buildtarget>extract</buildtarget> 階段,它會從
<varname>DISTDIR</varname> 內找出該 port 所需的檔案(通常是 gzip
格式的 tarball),然後解壓縮到 <varname>WRKDIR</varname>
所設定的臨時目錄名稱(預設是 <filename>work</filename> 目錄)內
</para>
</step>
<step>
<para>之後,進行 <buildtarget>patch</buildtarget> 階段,
一開始會先套用 <varname>PATCHFILES</varname> 所指定的任何 patch
檔。 接著是 <varname>PATCHDIR</varname>(預設是
<filename>files</filename> 子目錄) 內的檔名為
<filename>patch-*</filename>
之類的檔案,會以字母順序而逐一套用 patch。</para>
</step>
<step>
<para>接著是 <buildtarget>configure</buildtarget> 階段,可以照 port
的類型來作各種不同設定以調整,比如:</para>
<orderedlist>
<listitem>
<para>若有放 <filename>scripts/configure</filename> 的話,
那麼就會跑裡面的設定。</para>
</listitem>
<listitem>
<para>若有設 <varname>HAS_CONFIGURE</varname> 或是
<varname>GNU_CONFIGURE</varname> 的話,那麼就會跑
<filename>WRKSRC/configure</filename></para>
</listitem>
<listitem>
<para>若有設 <varname>USE_IMAKE</varname> 的話,那麼就會跑
<varname>XMKMF</varname> (預設是 <command>xmkmf
-a</command>) 。</para>
</listitem>
</orderedlist>
</step>
<step>
<para>最後是 <buildtarget>build</buildtarget> 階段,它會在該
port 的 working directory(由 <varname>WRKSRC</varname> 所設定)
內開始編譯。 若有設 <varname>USE_GMAKE</varname> 的話,
那麼就會改用 GNU <command>make</command> 來編譯,
否則就用系統本身的 <command>make</command> 來編譯。</para>
</step>
</procedure>
<para>上面講的都是打 <command>make</command> 時的預設階段。
此外,還可以設定各階段之前、之後要作的事情:透過定義
<buildtarget>pre-<replaceable>something</replaceable></buildtarget>
<buildtarget>post-<replaceable>something</replaceable></buildtarget>
或者把這些檔名的 script 丟到 <filename>scripts</filename> 子目錄去,
這樣子它們就會在各預設階段的之前、之後進行囉。</para>
<para>舉例來說,若在 <filename>Makefile</filename> 內設定
<buildtarget>post-extract</buildtarget>,而且在
<filename>scripts</filename> 子目錄內又有
<filename>pre-build</filename> 檔的話,那麼在作解壓縮之後,就會開始
<buildtarget>post-extract</buildtarget> 階段以進行解壓縮後的後續動作,
而在跑 build 階段之前,就會先執行 <filename>pre-build</filename>
這隻 script 作先期準備。 通常較簡單的修改動作,建議直接放在
<filename>Makefile</filename> 內就好了,
因為這樣會比較方便加上這些原本沒有的階段,同時也方便他人協助除錯
</para>
<para>預設的各階段動作都是照 <filename>bsd.port.mk</filename> 內的
<buildtarget>do-<replaceable>something</replaceable></buildtarget>
之類所定義的。 舉例:<buildtarget>do-extract</buildtarget>
就是定義怎麼把檔案解壓縮的。
若對預設方式覺得不妥的話,都可以在該 port 的
<filename>Makefile</filename> 重新定義。</para>
<note>
<para>The <quote>main</quote> targets (e.g.,
<buildtarget>extract</buildtarget>,
<buildtarget>configure</buildtarget>, etc.) do nothing more than
make sure all the stages up to that one are completed and call
the real targets or scripts, and they are not intended to be
changed. If you want to fix the extraction, fix
<buildtarget>do-extract</buildtarget>, but never ever change
the way <buildtarget>extract</buildtarget> operates!</para>
</note>
<para>現在,你已經知道打 <command>make</command> 到底會作些什麼事囉,
接下來會教你如何作更完美的 port。</para>
</sect1>
<sect1 xml:id="slow-sources">
<title>取得原始的 source 檔</title>
<para>取得原始的 source 檔(通常檔名是
<filename>foo.tar.gz</filename>
<filename>foo.tar.Z</filename>
之類的壓縮檔),然後會把抓下來的檔案放在 <varname>DISTDIR</varname>
內。 記得:抓的時候,儘量使用『該軟體主要的正式網站』上面的來源檔
,以確保檔案有效、可信。</para>
<para>需要設 <varname>MASTER_SITES</varname> 以指定原始檔案是放在何處。
相關網址在 <filename>bsd.sites.mk</filename>
內有一些方便的速記表可以使用。 請盡可能多用對應這些網址的變數,
以避免同樣的一堆網址有重複很多次出現在 port tree 內。
否則,這些網址只要一有改變的話,那麼就會成為維護 port 的夢魘。</para>
<para>如果該檔並沒有放在公開的 FTP 站或網站(HTTP)上,
或者該檔並非一般標準格式的話,
那麼可以考慮複製該檔,然後放到你可掌握、可信任的 FTP 站或網站(HTTP)
上,比如:你自己的網頁空間。</para>
<para>若找不到地方(方便、可信任)來放檔案的話,
那麼可以 <quote>house(暫放)</quote>
<systemitem>ftp.FreeBSD.org</systemitem> 上的 committer 自屬空間內;
然而,這是最不理想的解法。
檔案要放到該 committer 的 <systemitem>freefall</systemitem> 上的
<filename>~/public_distfiles/</filename> 目錄內才可以。
請與協助 commit 你的 port 的那位 committer 聯繫,
以便把檔案放到他的目錄內。
那位 committer 同時也會把 <varname>MASTER_SITES</varname> 設為
<varname>MASTER_SITE_LOCAL</varname>,並且把
<varname>MASTER_SITE_SUBDIR</varname> 設為他自己的
<systemitem>freefall</systemitem> 帳號名稱。</para>
<para>若該 port 的原始檔打包會經常重包,但原作者卻沒更新版號的話,
請考慮把該檔改放到自己的網頁空間,並且把自己網頁空間列為
<varname>MASTER_SITES</varname> 的第一順位。
或者請與原作者聯繫:請他不要這樣做(不斷重包同樣的檔案);如此一來,
才有助於建立一定程度的 source code 版本控制。
把檔案另外複製一份放到自屬網頁空間的話,不但可有效防止使用者會發生
<errorname>checksum mismatch(檔案經檢查有問題)</errorname>
的錯誤訊息,也可降低我們 FTP 站維護者的工作量。此外,若該 port
的檔案僅有一個主要網址,
那麼建議:請在自屬網站上放上備份檔,並修改
<varname>MASTER_SITES</varname> 把你的網址列為第二順位。</para>
<para>若該 port 需要一些額外 `patches'(可透過 Internet 下載),並放在
<varname>DISTDIR</varname> 內,不必擔心這些 patch
檔是否得都跟原始檔一樣來自同一網站,
這些情況有另外的解法(請看下面的 <link linkend="porting-patchfiles">PATCHFILES</link> 介紹部分)。</para>
</sect1>
<sect1 xml:id="slow-modifying">
<title>量身打造 port</title>
<para>解開壓縮檔,然後開始逐一修改,使該 port 在目前所用的 FreeBSD
版本上得以順利編譯。
所做的每個動作請都 <emphasis>仔細記錄</emphasis>
如此一來才能迅速自動套用這些修改。
在完成 port 之後,每項動作包括:對於檔案的刪除、增加、修改,
要記得存為自動化的 script 或者 patch 檔形式,以利他人直接套用。</para>
<para>若該 port 需要使用者的互動、自訂功能來編譯、安裝的話,
那麼建議揣摩看看 Larry Wall 的經典之作
<application>Configure</application> scripts 來完成類似效果。
Ports collection 的目的之一,就是讓每個 port 儘量用最小空間,
來做出軟體的 <quote>plug-and-play(即插即用)</quote></para>
<note>
<para>除非有明確聲明,否則你所提交給 FreeBSD ports collection 的
patch 檔、相關 script 檔及其他檔案,都會假設是以標準的 BSD
版權形式來發佈。</para>
</note>
</sect1>
<sect1 xml:id="slow-patch">
<title>Patching</title>
<para>在 port 的準備過程中,新增或變更過的檔案,
可以利用 &man.diff.1; 將這些變動列出,
以便後續讓 &man.patch.1; 使用。
所有你想套用的 patch 都應該命名為
<filename>patch-*</filename>,其中
<replaceable>*</replaceable> 表示要 patch 檔案的路徑及檔名名稱,
例如 <filename>patch-Imakefile</filename>
<filename>patch-src-config.h</filename>
這些檔案都應該儲存在 <varname>PATCHDIR</varname>
(通常是 <filename>files/</filename>,放在其內的檔案都會自動被套用。
所有 patch 檔路徑都是相對於
<varname>WRKSRC</varname> (通常會將 port 的 tarball 解壓到裡面,
port 的建置也會在這裡完成)。
為了能讓修正和更新更順利,你應該避免多個 patch 修正同一個檔案
(舉例來說,<filename>patch-file</filename>
<filename>patch-file2</filename> 同時更動
<filename>WRKSRC/foobar.c</filename>)。</para>
<para>請只使用 <literal>[-+._a-zA-Z0-9]</literal> 這些字元來命名
patch 檔,不要使用這些字元以外的字元。
千萬不要將你的 patch 檔命名成 <filename>patch-aa</filename> 或是
<filename>patch-ab</filename> 等名稱,
請使用路徑和名稱相關的命名。</para>
<para>不要將 RCS 字串放進你的 patch 檔。CVS 會在這些檔案送入
ports tree 的時候弄亂檔案內容,而且在將它們重新 check out
出來後,會因檔案內容的差異造成 patch 失敗。
RCS 字串是以錢字號 (<literal>&dollar;</literal>) 括起來的,
通常以 <literal>&dollar;Id</literal>
<literal>&dollar;RCS</literal> 為開頭。</para>
<para>你可以使用 &man.diff.1; 搭配 recurse (<option>-r</option>) 選項
來產生 patch 檔,但請再次檢視產生出的 patch 檔,確保你沒有產生
任何不必要的垃圾資訊在裡面。特別是對那些經由
<command>Imake</command> 或 GNU <command>configure</command>
所產生的 <filename>Makefile</filename> 檔產生 patch
都是不必要的,這類的 patch 檔都應該被刪除。假如你必須透過修改
<command>configure.in</command> 再執行
<command>autoconf</command> 來重新產生
<command>configure</command>,不要對
<command>configure</command> 產生 patch 檔 (這往往會長成數千行!)
請定義 <literal>USE_AUTOTOOLS=autoconf:261</literal> 並對
<filename>configure.in</filename> 產生 patch 檔。</para>
<para>請儘量不要對無用的 whitespace 作修改,因為在 Open Source 界各個
project 都會使用很多相同的 code base這些可能卻是採用不同的編排方式
、coding style。 若要試圖改變這些編排風格的話,請小心:
這些只會是徒勞無功的更改。 此外不僅會造成 CVS repository 空間浪費,
也會讓人難以找出真正問題癥結所在,以及分辨不出這段 patch 到底在作什麼
</para>
<para>假如你必須刪除一個檔案,那麼你可以在
<buildtarget>post-extract</buildtarget> 階段做這件事,
而不是在 patch 階段。</para>
<para>你可以直接在 port 的
<filename>Makefile</filename> 中完成簡單的置換工作,只需使用
&man.sed.1; 的 in-place mode 即可。這在只需 patch 一個變數的值時相當有用。
例如:</para>
<programlisting>post-patch:
@${REINPLACE_CMD} -e 's|for Linux|for FreeBSD|g' ${WRKSRC}/README
@${REINPLACE_CMD} -e 's|-pthread|${PTHREAD_LIBS}|' ${WRKSRC}/configure</programlisting>
<para>在移植軟體時,特別是那些在 &windows; 平台開發的軟體,
時常會遇到一種情況,就是在大部份的 source file 中,
使用 CR/LF 做為斷行。這會影響往後的 patching、compiler warnings、以及
scripts execution (找不到 <command>/bin/sh^M</command> 的情況) 等。
為了快速轉換 CR/LF 為 LF可以把
<literal>USE_DOS2UNIX=yes</literal> 加到 port 的
<filename>Makefile</filename> 檔中。
你也可以設定成只針對指定的檔案做轉換:</para>
<programlisting>USE_DOS2UNIX= util.c util.h</programlisting>
<para>若想要轉換所有子目錄內的某類別檔案,可以使用
<varname>DOS2UNIX_REGEX</varname>。 它的參數是
<command>find</command> 相容的正規表達式。 相關格式可參閱
&man.re.format.7;。 對於所指定副檔名的檔案之轉換而言,這相當好用,
舉例來說,只動所有原始碼部分而不改 binary 檔案:</para>
<programlisting>USE_DOS2UNIX= yes
DOS2UNIX_REGEX= .*\.(c|cpp|h)</programlisting>
</sect1>
<sect1 xml:id="slow-configure">
<title>設定</title>
<para>將任何額外的自訂指令包含進你的
<filename>configure</filename> script 中,且將它儲存在
<filename>scripts</filename> 的子資料夾裡。 如同上面提到的,
你也可以在 <filename>Makefile</filename> 或者是在
名稱為 <filename>pre-configure</filename>
<filename>post-configure</filename> 的 script 檔中做同樣的事。</para>
</sect1>
<sect1 xml:id="slow-user-input">
<title>處理使用者輸入</title>
<para>如果該 port 需要使用者作出選擇才能安裝的話,
則必須在 <filename>Makefile</filename> 加上
<varname>IS_INTERACTIVE</varname> 變數。 如此一來若使用者有設定
<envar>BATCH</envar> 環境變數的話,就會略過該 port 而繼續
<quote>overnight builds</quote>(若使用者把該環境變數值設為
<envar>BATCH</envar> 的話,那麼 <emphasis>只有</emphasis>
那些需要與使用者互動的 port 才會編譯。)。
這使得那些需要不停編譯 port 的機器會省下許多時間(後面會說明這點)
</para>
<para>此外建議,若是這些互動問題有合適的預設選項的話,
那應確認一下 <varname>PACKAGE_BUILDING</varname> 變數該如何設,
才能配合該變數而決定是否停止互動。 如此一來才可以自動編譯出
CDROM 與 FTP 上的套件。</para>
</sect1>
</chapter>
<chapter xml:id="makefile">
<title>設定 Makefile</title>
<para>設定 <filename>Makefile</filename> 是件非常簡單的事,
建議您在開始前先看看範例。Also, there is a
<link linkend="porting-samplem">sample Makefile</link> in this
handbook, so take a look and please follow the ordering of variables
and sections in that template to make your port easier for others to
read.</para>
<para>Now, consider the following problems in sequence as you design
your new <filename>Makefile</filename>:</para>
<sect1 xml:id="makefile-source">
<title>The original source</title>
<para>Does it live in <varname>DISTDIR</varname> as a standard
gzip'd tarball named something like
<filename>foozolix-1.2.tar.gz</filename>? If so, you can go on
to the next step. If not, you should look at overriding any of
the <varname>DISTVERSION</varname>, <varname>DISTNAME</varname>,
<varname>EXTRACT_CMD</varname>,
<varname>EXTRACT_BEFORE_ARGS</varname>,
<varname>EXTRACT_AFTER_ARGS</varname>,
<varname>EXTRACT_SUFX</varname>, or <varname>DISTFILES</varname>
variables, depending on how alien a format your port's
distribution file is. (The most common case is
<literal>EXTRACT_SUFX=.tar.Z</literal>, when the tarball is
condensed by regular <command>compress</command>, not
<command>gzip</command>.)</para>
<para>In the worst case, you can simply create your own
<buildtarget>do-extract</buildtarget> target to override the
default, though this should be rarely, if ever,
necessary.</para>
</sect1>
<sect1 xml:id="makefile-naming">
<title>Naming</title>
<para>The first part of the port's <filename>Makefile</filename> names
the port, describes its version number, and lists it in the correct
category.</para>
<sect2>
<title><varname>PORTNAME</varname> and <varname>PORTVERSION</varname></title>
<para>You should set <varname>PORTNAME</varname> to the
base name of your port, and <varname>PORTVERSION</varname>
to the version number of the port.</para>
</sect2>
<sect2 xml:id="makefile-naming-revepoch">
<title><varname>PORTREVISION</varname> and
<varname>PORTEPOCH</varname></title>
<sect3>
<title><varname>PORTREVISION</varname></title>
<para>The <varname>PORTREVISION</varname> variable is a
monotonically increasing value which is reset to 0 with
every increase of <varname>PORTVERSION</varname> (i.e.
every time a new official vendor release is made), and
appended to the package name if non-zero.
Changes to <varname>PORTREVISION</varname> are
used by automated tools (e.g. &man.pkg.version.1;)
to highlight the fact that a new package is
available.</para>
<para><varname>PORTREVISION</varname> should be increased
each time a change is made to the port which significantly
affects the content or structure of the derived
package.</para>
<para>Examples of when <varname>PORTREVISION</varname>
should be bumped:</para>
<itemizedlist>
<listitem>
<para>Addition of patches to correct security
vulnerabilities, bugs, or to add new functionality to
the port.</para>
</listitem>
<listitem>
<para>Changes to the port <filename>Makefile</filename> to enable or disable
compile-time options in the package.</para>
</listitem>
<listitem>
<para>Changes in the packing list or the install-time
behavior of the package (e.g. change to a script
which generates initial data for the package, like ssh
host keys).</para>
</listitem>
<listitem>
<para>Version bump of a port's shared library dependency
(in this case, someone trying to install the old
package after installing a newer version of the
dependency will fail since it will look for the old
libfoo.x instead of libfoo.(x+1)).</para>
</listitem>
<listitem>
<para>Silent changes to the port distfile which have
significant functional differences, i.e. changes to
the distfile requiring a correction to
<filename>distinfo</filename> with no corresponding change to
<varname>PORTVERSION</varname>, where a <command>diff
-ru</command> of the old and new versions shows
non-trivial changes to the code.</para>
</listitem>
</itemizedlist>
<para>Examples of changes which do not require a
<varname>PORTREVISION</varname> bump:</para>
<itemizedlist>
<listitem>
<para>Style changes to the port skeleton with no
functional change to what appears in the resulting
package.</para>
</listitem>
<listitem>
<para>Changes to <varname>MASTER_SITES</varname> or
other functional changes to the port which do not
affect the resulting package.</para>
</listitem>
<listitem>
<para>Trivial patches to the distfile such as correction
of typos, which are not important enough that users of
the package should go to the trouble of
upgrading.</para>
</listitem>
<listitem>
<para>Build fixes which cause a package to become
compilable where it was previously failing (as long as
the changes do not introduce any functional change on
any other platforms on which the port did previously
build). Since <varname>PORTREVISION</varname> reflects
the content of the package, if the package was not
previously buildable then there is no need to increase
<varname>PORTREVISION</varname> to mark a
change.</para>
</listitem>
</itemizedlist>
<para>A rule of thumb is to ask yourself whether a change
committed to a port is something which everyone
would benefit from having (either because of an
enhancement, fix, or by virtue that the new package will
actually work at all), and weigh that against that fact
that it will cause everyone who regularly updates their
ports tree to be compelled to update. If yes, the
<varname>PORTREVISION</varname> should be bumped.</para>
</sect3>
<sect3>
<title><varname>PORTEPOCH</varname></title>
<para>From time to time a software vendor or FreeBSD porter
will do something silly and release a version of their
software which is actually numerically less than the
previous version. An example of this is a port which goes
from foo-20000801 to foo-1.0 (the former will be
incorrectly treated as a newer version since 20000801 is a
numerically greater value than 1).</para>
<para>In situations such as this, the
<varname>PORTEPOCH</varname> version should be increased.
If <varname>PORTEPOCH</varname> is nonzero it is appended
to the package name as described in section 0 above.
<varname>PORTEPOCH</varname> must never be decreased or reset
to zero, because that would cause comparison to a package
from an earlier epoch to fail (i.e. the package would not
be detected as out of date): the new version number (e.g.
<literal>1.0,1</literal> in the above example) is still
numerically less than the previous version (20000801), but
the <literal>,1</literal> suffix is treated specially by
automated tools and found to be greater than the implied
suffix <literal>,0</literal> on the earlier package.</para>
<para>Dropping or resetting <varname>PORTEPOCH</varname>
incorrectly leads
to no end of grief; if you do not understand the above discussion,
please keep after it until you do, or ask questions on
the mailing lists.</para>
<para>It is expected that <varname>PORTEPOCH</varname> will
not be used for the majority of ports, and that sensible
use of <varname>PORTVERSION</varname> can often pre-empt
it becoming necessary if a future release of the software
should change the version structure. However, care is
needed by FreeBSD porters when a vendor release is made
without an official version number &mdash; such as a code
<quote>snapshot</quote> release. The temptation is to label the
release with the release date, which will cause problems
as in the example above when a new <quote>official</quote> release is
made.</para>
<para>For example, if a snapshot release is made on the date
20000917, and the previous version of the software was
version 1.2, the snapshot release should be given a
<varname>PORTVERSION</varname> of 1.2.20000917 or similar,
not 20000917, so that the succeeding release, say 1.3, is
still a numerically greater value.</para>
</sect3>
<sect3>
<title>Example of <varname>PORTREVISION</varname> and
<varname>PORTEPOCH</varname> usage</title>
<para>The <literal>gtkmumble</literal> port, version
<literal>0.10</literal>, is committed to the ports
collection:</para>
<programlisting>PORTNAME= gtkmumble
PORTVERSION= 0.10</programlisting>
<para><varname>PKGNAME</varname> becomes
<literal>gtkmumble-0.10</literal>.</para>
<para>A security hole is discovered which requires a local
FreeBSD patch. <varname>PORTREVISION</varname> is bumped
accordingly.</para>
<programlisting>PORTNAME= gtkmumble
PORTVERSION= 0.10
PORTREVISION= 1</programlisting>
<para><varname>PKGNAME</varname> becomes
<literal>gtkmumble-0.10_1</literal></para>
<para>A new version is released by the vendor, numbered <literal>0.2</literal>
(it turns out the author actually intended
<literal>0.10</literal> to actually mean
<literal>0.1.0</literal>, not <quote>what comes after
0.9</quote> - oops, too late now). Since the new minor
version <literal>2</literal> is numerically less than the
previous version <literal>10</literal>, the
<varname>PORTEPOCH</varname> must be bumped to manually
force the new package to be detected as <quote>newer</quote>. Since it
is a new vendor release of the code,
<varname>PORTREVISION</varname> is reset to 0 (or removed
from the <filename>Makefile</filename>).</para>
<programlisting>PORTNAME= gtkmumble
PORTVERSION= 0.2
PORTEPOCH= 1</programlisting>
<para><varname>PKGNAME</varname> becomes
<literal>gtkmumble-0.2,1</literal></para>
<para>The next release is 0.3. Since
<varname>PORTEPOCH</varname> never decreases, the version
variables are now:</para>
<programlisting>PORTNAME= gtkmumble
PORTVERSION= 0.3
PORTEPOCH= 1</programlisting>
<para><varname>PKGNAME</varname> becomes
<literal>gtkmumble-0.3,1</literal></para>
<note>
<para>If <varname>PORTEPOCH</varname> were reset
to <literal>0</literal> with this upgrade, someone who had
installed the <literal>gtkmumble-0.10_1</literal> package would not detect
the <literal>gtkmumble-0.3</literal> package as newer, since
<literal>3</literal> is still numerically less than
<literal>10</literal>. Remember, this is the whole point of
<varname>PORTEPOCH</varname> in the first place.</para>
</note>
</sect3>
</sect2>
<sect2>
<title><varname>PKGNAMEPREFIX</varname> and <varname>PKGNAMESUFFIX</varname></title>
<para>Two optional variables, <varname>PKGNAMEPREFIX</varname> and
<varname>PKGNAMESUFFIX</varname>, are combined with
<varname>PORTNAME</varname> and
<varname>PORTVERSION</varname> to
form <varname>PKGNAME</varname> as
<literal>${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}-${PORTVERSION}</literal>.
Make sure this conforms to our <link linkend="porting-pkgname">guidelines for a good package
name</link>. In particular, you are <emphasis>not</emphasis> allowed to use a
hyphen (<literal>-</literal>) in
<varname>PORTVERSION</varname>. Also, if the package name
has the <replaceable>language-</replaceable> or the
<replaceable>-compiled.specifics</replaceable> part (see below), use
<varname>PKGNAMEPREFIX</varname> and
<varname>PKGNAMESUFFIX</varname>, respectively. Do not make
them part of <varname>PORTNAME</varname>.</para>
</sect2>
<sect2>
<title><varname>LATEST_LINK</varname></title>
<para>在某些情況,可能會同時存在有不同版本的同一程式。
由於它們可能會有同樣的 <varname>PORTNAME</varname>
<varname>PKGNAMEPREFIX</varname>,甚至
<varname>PKGNAMESUFFIX</varname> 也相同,所以得讓這些程式有所不同,
才能讓 port 的 index 以及 package 能順利產生。 遇到這類情況,
the optional <varname>LATEST_LINK</varname> variable should be set to
a different value for all ports except the <quote>main</quote>
one &mdash; see the <filename>editors/vim5</filename> and
<filename>editors/vim</filename> ports, and the
<filename>www/apache*</filename> family for examples of its use.
Note that how to choose a <quote>main</quote> version &mdash;
<quote>most popular</quote>, <quote>best supported</quote>,
<quote>least patched</quote>, and so on &mdash; is outside the
scope of this handbook's recommendations; we only tell you how to
specify the other ports' versions after you have picked a
<quote>main</quote> one.</para>
</sect2>
<sect2 xml:id="porting-pkgname">
<title>Package Naming Conventions</title>
<para>The following are the conventions you should follow in naming your
packages. This is to have our package directory easy to scan, as
there are already thousands of packages and users are going to
turn away if they hurt their eyes!</para>
<para>The package name should look like
<filename>language_region-name-compiled.specifics-version.numbers</filename>.</para>
<para>The package name is defined as
<literal>${PKGNAMEPREFIX}${PORTNAME}${PKGNAMESUFFIX}-${PORTVERSION}</literal>.
Make sure to set the variables to conform to that format.</para>
<orderedlist>
<listitem>
<para>FreeBSD strives to support the native language of its users.
The <replaceable>language-</replaceable> part should be a two
letter abbreviation of the natural language defined by ISO-639 if
the port is specific to a certain language. Examples are
<literal>ja</literal> for Japanese, <literal>ru</literal> for
Russian, <literal>vi</literal> for Vietnamese,
<literal>zh</literal> for Chinese, <literal>ko</literal> for
Korean and <literal>de</literal> for German.</para>
<para>If the port is specific to a certain region within the
language area, add the two letter country code as well.
Examples are <literal>en_US</literal> for US English and
<literal>fr_CH</literal> for Swiss French.</para>
<para>The <replaceable>language-</replaceable> part should
be set in the <varname>PKGNAMEPREFIX</varname> variable.</para>
</listitem>
<listitem>
<para>The first letter of the <filename>name</filename> part
should be lowercase. (The rest of the name may contain
capital letters, so use your own discretion when you are
converting a software name that has some capital letters in it.)
There is a tradition of naming <literal>Perl 5</literal> modules by
prepending <literal>p5-</literal> and converting the double-colon
separator to a hyphen; for example, the
<literal>Data::Dumper</literal> module becomes
<literal>p5-Data-Dumper</literal>.</para>
</listitem>
<listitem>
<para>Make sure that the port's name and version are clearly
separated and placed into the <varname>PORTNAME</varname> and
<varname>PORTVERSION</varname> variables. The only reason for
<varname>PORTNAME</varname> to contain a version part is if
the upstream distribution is really named that way, as in
the <filename>textproc/libxml2</filename> or
<filename>japanese/kinput2-freewnn</filename> ports. Otherwise,
the <varname>PORTNAME</varname> should not contain any
version-specific information. It is quite normal for several
ports to have the same <varname>PORTNAME</varname>, as the
<filename>www/apache*</filename> ports do; in that case,
different versions (and different index entries) are
distinguished by the <varname>PKGNAMEPREFIX</varname>,
<varname>PKGNAMESUFFIX</varname>, and
<varname>LATEST_LINK</varname> values.</para>
</listitem>
<listitem>
<para>If the port can be built with different <link linkend="makefile-masterdir">hardcoded defaults</link> (usually
part of the directory name in a family of ports), the
<replaceable>-compiled.specifics</replaceable> part should state
the compiled-in defaults (the hyphen is optional). Examples are
papersize and font units.</para>
<para>The <replaceable>-compiled.specifics</replaceable> part
should be set in the <varname>PKGNAMESUFFIX</varname>
variable.</para>
</listitem>
<listitem>
<para>The version string should follow a dash
(<literal>-</literal>) and be a period-separated list of
integers and single lowercase alphabetics. In particular,
it is not permissible to have another dash inside the
version string. The only exception is the string
<literal>pl</literal> (meaning <quote>patchlevel</quote>), which can be
used <emphasis>only</emphasis> when there are no major and
minor version numbers in the software. If the software
version has strings like <quote>alpha</quote>, <quote>beta</quote>, <quote>rc</quote>, or <quote>pre</quote>, take
the first letter and put it immediately after a period.
If the version string continues after those names, the
numbers should follow the single alphabet without an extra
period between them.</para>
<para>The idea is to make it easier to sort ports by looking
at the version string. In particular, make sure version
number components are always delimited by a period, and
if the date is part of the string, use the
<literal>yyyy.mm.dd</literal>
format, not
<literal>dd.mm.yyyy</literal>
or the non-Y2K compliant
<literal>yy.mm.dd</literal>
format.</para>
</listitem>
</orderedlist>
<para>Here are some (real) examples on how to convert the name
as called by the software authors to a suitable package
name:</para>
<informaltable frame="none" pgwide="1">
<tgroup cols="6">
<thead>
<row>
<entry>Distribution Name</entry>
<entry><varname>PKGNAMEPREFIX</varname></entry>
<entry><varname>PORTNAME</varname></entry>
<entry><varname>PKGNAMESUFFIX</varname></entry>
<entry><varname>PORTVERSION</varname></entry>
<entry>Reason</entry>
</row>
</thead>
<tbody>
<row>
<entry>mule-2.2.2</entry>
<entry>(empty)</entry>
<entry>mule</entry>
<entry>(empty)</entry>
<entry>2.2.2</entry>
<entry>No changes required</entry>
</row>
<row>
<entry>EmiClock-1.0.2</entry>
<entry>(empty)</entry>
<entry>emiclock</entry>
<entry>(empty)</entry>
<entry>1.0.2</entry>
<entry>No uppercase names for single programs</entry>
</row>
<row>
<entry>rdist-1.3alpha</entry>
<entry>(empty)</entry>
<entry>rdist</entry>
<entry>(empty)</entry>
<entry>1.3.a</entry>
<entry>No strings like <literal>alpha</literal>
allowed</entry>
</row>
<row>
<entry>es-0.9-beta1</entry>
<entry>(empty)</entry>
<entry>es</entry>
<entry>(empty)</entry>
<entry>0.9.b1</entry>
<entry>No strings like <literal>beta</literal>
allowed</entry>
</row>
<row>
<entry>mailman-2.0rc3</entry>
<entry>(empty)</entry>
<entry>mailman</entry>
<entry>(empty)</entry>
<entry>2.0.r3</entry>
<entry>No strings like <literal>rc</literal>
allowed</entry>
</row>
<row>
<entry>v3.3beta021.src</entry>
<entry>(empty)</entry>
<entry>tiff</entry>
<entry>(empty)</entry>
<entry>3.3</entry>
<entry>What the heck was that anyway?</entry>
</row>
<row>
<entry>tvtwm</entry>
<entry>(empty)</entry>
<entry>tvtwm</entry>
<entry>(empty)</entry>
<entry>pl11</entry>
<entry>Version string always required</entry>
</row>
<row>
<entry>piewm</entry>
<entry>(empty)</entry>
<entry>piewm</entry>
<entry>(empty)</entry>
<entry>1.0</entry>
<entry>Version string always required</entry>
</row>
<row>
<entry>xvgr-2.10pl1</entry>
<entry>(empty)</entry>
<entry>xvgr</entry>
<entry>(empty)</entry>
<entry>2.10.1</entry>
<entry><literal>pl</literal> allowed only when no
major/minor version numbers</entry>
</row>
<row>
<entry>gawk-2.15.6</entry>
<entry>ja-</entry>
<entry>gawk</entry>
<entry>(empty)</entry>
<entry>2.15.6</entry>
<entry>Japanese language version</entry>
</row>
<row>
<entry>psutils-1.13</entry>
<entry>(empty)</entry>
<entry>psutils</entry>
<entry>-letter</entry>
<entry>1.13</entry>
<entry>Papersize hardcoded at package build time</entry>
</row>
<row>
<entry>pkfonts</entry>
<entry>(empty)</entry>
<entry>pkfonts</entry>
<entry>300</entry>
<entry>1.0</entry>
<entry>Package for 300dpi fonts</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<para>If there is absolutely no trace of version information in the
original source and it is unlikely that the original author will ever
release another version, just set the version string to
<literal>1.0</literal> (like the <literal>piewm</literal> example above). Otherwise, ask
the original author or use the date string
(<literal>yyyy.mm.dd</literal>)
as the version.</para>
</sect2>
</sect1>
<sect1 xml:id="makefile-categories">
<title>Categorization</title>
<sect2>
<title><varname>CATEGORIES</varname></title>
<para>When a package is created, it is put under
<filename>/usr/ports/packages/All</filename> and links are made from
one or more subdirectories of
<filename>/usr/ports/packages</filename>. The names of these
subdirectories are specified by the variable
<varname>CATEGORIES</varname>. It is intended to make life easier
for the user when he is wading through the pile of packages on the
FTP site or the CDROM. Please take a look at the <link linkend="porting-categories">current list of categories</link> and pick the ones
that are suitable for your port.</para>
<para>This list also determines where in the ports tree the port is
imported. If you put more than one category here, it is assumed
that the port files will be put in the subdirectory with the name in
the first category. See <link linkend="choosing-categories">below</link> for more
discussion about how to pick the right categories.</para>
</sect2>
<sect2 xml:id="porting-categories">
<title>Current list of categories</title>
<para>Here is the current list of port categories. Those
marked with an asterisk (<literal>*</literal>) are
<emphasis>virtual</emphasis> categories&mdash;those that do not have
a corresponding subdirectory in the ports tree. They are only
used as secondary categories, and only for search purposes.</para>
<note>
<para>For non-virtual categories, you will find a one-line
description in the <varname>COMMENT</varname> in that
subdirectory's <filename>Makefile</filename>.</para>
</note>
<informaltable frame="none" pgwide="1">
<tgroup cols="3">
<thead>
<row>
<entry>Category</entry>
<entry>Description</entry>
<entry>Notes</entry>
</row>
</thead>
<tbody>
<row>
<entry><filename>accessibility</filename></entry>
<entry>Ports to help disabled users.</entry>
<entry/>
</row>
<row>
<entry><filename>afterstep*</filename></entry>
<entry>Ports to support the
<link xlink:href="http://www.afterstep.org">AfterStep</link>
window manager.</entry>
<entry/>
</row>
<row>
<entry><filename>arabic</filename></entry>
<entry>Arabic language support.</entry>
<entry/>
</row>
<row>
<entry><filename>archivers</filename></entry>
<entry>Archiving tools.</entry>
<entry/>
</row>
<row>
<entry><filename>astro</filename></entry>
<entry>Astronomical ports.</entry>
<entry/>
</row>
<row>
<entry><filename>audio</filename></entry>
<entry>Sound support.</entry>
<entry/>
</row>
<row>
<entry><filename>benchmarks</filename></entry>
<entry>Benchmarking utilities.</entry>
<entry/>
</row>
<row>
<entry><filename>biology</filename></entry>
<entry>Biology-related software.</entry>
<entry/>
</row>
<row>
<entry><filename>cad</filename></entry>
<entry>Computer aided design tools.</entry>
<entry/>
</row>
<row>
<entry><filename>chinese</filename></entry>
<entry>Chinese language support.</entry>
<entry/>
</row>
<row>
<entry><filename>comms</filename></entry>
<entry>Communication software.</entry>
<entry>Mostly software to talk to your serial port.</entry>
</row>
<row>
<entry><filename>converters</filename></entry>
<entry>Character code converters.</entry>
<entry/>
</row>
<row>
<entry><filename>databases</filename></entry>
<entry>Databases.</entry>
<entry/>
</row>
<row>
<entry><filename>deskutils</filename></entry>
<entry>Things that used to be on the desktop before
computers were invented.</entry>
<entry/>
</row>
<row>
<entry><filename>devel</filename></entry>
<entry>Development utilities.</entry>
<entry>Do not put libraries here just because they are
libraries&mdash;unless they truly do not belong anywhere
else, they should not be in this category.</entry>
</row>
<row>
<entry><filename>dns</filename></entry>
<entry>DNS-related software.</entry>
<entry/>
</row>
<row>
<entry><filename>editors</filename></entry>
<entry>General editors.</entry>
<entry>Specialized editors go in the section for those
tools (e.g., a mathematical-formula editor will go
in <filename>math</filename>).</entry>
</row>
<row>
<entry><filename>elisp*</filename></entry>
<entry>Emacs-lisp ports.</entry>
<entry/>
</row>
<row>
<entry><filename>emulators</filename></entry>
<entry>Emulators for other operating systems.</entry>
<entry>Terminal emulators do <emphasis>not</emphasis> belong
here&mdash;X-based ones should go to
<filename>x11</filename> and text-based ones to either
<filename>comms</filename> or <filename>misc</filename>,
depending on the exact functionality.</entry>
</row>
<row>
<entry><filename>finance</filename></entry>
<entry>Monetary, financial and related applications.</entry>
<entry/>
</row>
<row>
<entry><filename>french</filename></entry>
<entry>French language support.</entry>
<entry/>
</row>
<row>
<entry><filename>ftp</filename></entry>
<entry>FTP client and server utilities.</entry>
<entry>If your port speaks both FTP and HTTP, put it in
<filename>ftp</filename> with a secondary
category of <filename>www</filename>.</entry>
</row>
<row>
<entry><filename>games</filename></entry>
<entry>遊戲。</entry>
<entry/>
</row>
<row>
<entry><filename>geography*</filename></entry>
<entry>地理圖資相關的軟體。</entry>
<entry/>
</row>
<row>
<entry><filename>german</filename></entry>
<entry>德文相關支援。</entry>
<entry/>
</row>
<row>
<entry><filename>gnome*</filename></entry>
<entry>Ports from the <link xlink:href="http://www.gnome.org">GNOME</link>
Project.</entry>
<entry/>
</row>
<row>
<entry><filename>gnustep*</filename></entry>
<entry>GNUstep 桌面環境相關的軟體。</entry>
<entry/>
</row>
<row>
<entry><filename>graphics</filename></entry>
<entry>圖形處理的工具軟體。</entry>
<entry/>
</row>
<row>
<entry><filename>hamradio*</filename></entry>
<entry>Software for amateur radio.</entry>
<entry/>
</row>
<row>
<entry><filename>haskell*</filename></entry>
<entry>Software related to the Haskell language.</entry>
<entry/>
</row>
<row>
<entry><filename>hebrew</filename></entry>
<entry>Hebrew language support.</entry>
<entry/>
</row>
<row>
<entry><filename>hungarian</filename></entry>
<entry>Hungarian language support.</entry>
<entry/>
</row>
<row>
<entry><filename>ipv6*</filename></entry>
<entry>IPv6 related software.</entry>
<entry/>
</row>
<row>
<entry><filename>irc</filename></entry>
<entry>Internet Relay Chat utilities.</entry>
<entry/>
</row>
<row>
<entry><filename>japanese</filename></entry>
<entry>Japanese language support.</entry>
<entry/>
</row>
<row>
<entry><filename>java</filename></entry>
<entry>Software related to the Java language.</entry>
<entry>The <filename>java</filename> category shall not be
the only one for a port. Save for ports directly related to
the Java language, porters are also encouraged not to
use <filename>java</filename> as the main category of a
port.</entry>
</row>
<row>
<entry><filename>kde*</filename></entry>
<entry>Ports from the <link xlink:href="http://www.kde.org">K Desktop Environment (KDE)</link>
Project.</entry>
<entry/>
</row>
<row>
<entry><filename>kld*</filename></entry>
<entry>Kernel loadable modules。</entry>
<entry/>
</row>
<row>
<entry><filename>korean</filename></entry>
<entry>Korean language support.</entry>
<entry/>
</row>
<row>
<entry><filename>lang</filename></entry>
<entry>Programming languages.</entry>
<entry/>
</row>
<row>
<entry><filename>linux*</filename></entry>
<entry>Linux applications and support utilities.</entry>
<entry/>
</row>
<row>
<entry><filename>lisp*</filename></entry>
<entry>Software related to the Lisp language.</entry>
<entry/>
</row>
<row>
<entry><filename>mail</filename></entry>
<entry>Mail software.</entry>
<entry/>
</row>
<row>
<entry><filename>math</filename></entry>
<entry>Numerical computation software and other utilities
for mathematics.</entry>
<entry/>
</row>
<row>
<entry><filename>mbone</filename></entry>
<entry>MBone applications.</entry>
<entry/>
</row>
<row>
<entry><filename>misc</filename></entry>
<entry>Miscellaneous utilities</entry>
<entry>Basically things that
do not belong anywhere else.
If at all possible, try to
find a better category for your port than
<literal>misc</literal>, as ports tend to get overlooked
in here.</entry>
</row>
<row>
<entry><filename>multimedia</filename></entry>
<entry>Multimedia software.</entry>
<entry/>
</row>
<row>
<entry><filename>net</filename></entry>
<entry>Miscellaneous networking software.</entry>
<entry/>
</row>
<row>
<entry><filename>net-im</filename></entry>
<entry>Instant messaging software.</entry>
<entry/>
</row>
<row>
<entry><filename>net-mgmt</filename></entry>
<entry>Networking management software.</entry>
<entry/>
</row>
<row>
<entry><filename>net-p2p</filename></entry>
<entry>Peer to peer network applications.</entry>
<entry/>
</row>
<row>
<entry><filename>news</filename></entry>
<entry>USENET news software.</entry>
<entry/>
</row>
<row>
<entry><filename>palm</filename></entry>
<entry>Software support for the <link xlink:href="http://www.palm.com/">Palm&trade;</link> series.</entry>
<entry/>
</row>
<row>
<entry><filename>parallel*</filename></entry>
<entry>Applications dealing with parallelism in computing.</entry>
<entry/>
</row>
<row>
<entry><filename>pear*</filename></entry>
<entry>Ports related to the Pear PHP framework.</entry>
<entry/>
</row>
<row>
<entry><filename>perl5*</filename></entry>
<entry>Ports that require <application>Perl</application> version 5 to run.</entry>
<entry/>
</row>
<row>
<entry><filename>plan9*</filename></entry>
<entry>Various programs from <link xlink:href="http://www.cs.bell-labs.com/plan9dist/">Plan9</link>.</entry>
<entry/>
</row>
<row>
<entry><filename>polish</filename></entry>
<entry>Polish language support.</entry>
<entry/>
</row>
<row>
<entry><filename>ports-mgmt</filename></entry>
<entry>FreeBSD ports 及 packages 的管理、安裝、開發。</entry>
</row>
<row>
<entry><filename>portuguese</filename></entry>
<entry>Portuguese language support.</entry>
<entry/>
</row>
<row>
<entry><filename>print</filename></entry>
<entry>Printing software.</entry>
<entry>Desktop publishing tools
(previewers, etc.) belong here too.</entry>
</row>
<row>
<entry><filename>python*</filename></entry>
<entry>Software related to the <link xlink:href="http://www.python.org/">Python</link> language.</entry>
<entry/>
</row>
<row>
<entry><filename>ruby*</filename></entry>
<entry>Software related to the <link xlink:href="http://www.ruby-lang.org/">Ruby</link> language.</entry>
<entry/>
</row>
<row>
<entry><filename>rubygems*</filename></entry>
<entry>Ports of <link xlink:href="http://www.rubygems.org/">RubyGems</link> packages.</entry>
<entry/>
</row>
<row>
<entry><filename>russian</filename></entry>
<entry>Russian language support.</entry>
<entry/>
</row>
<row>
<entry><filename>scheme*</filename></entry>
<entry>Software related to the Scheme language.</entry>
<entry/>
</row>
<row>
<entry><filename>science</filename></entry>
<entry>Scientific ports that do not fit into other
categories such as <filename>astro</filename>,
<filename>biology</filename> and
<filename>math</filename>.</entry>
<entry/>
</row>
<row>
<entry><filename>security</filename></entry>
<entry>Security utilities.</entry>
<entry/>
</row>
<row>
<entry><filename>shells</filename></entry>
<entry>Command line shells.</entry>
<entry/>
</row>
<row>
<entry><filename>spanish*</filename></entry>
<entry>西班牙文的相關支援。</entry>
<entry/>
</row>
<row>
<entry><filename>sysutils</filename></entry>
<entry>System utilities.</entry>
<entry/>
</row>
<row>
<entry><filename>tcl*</filename></entry>
<entry>使用 Tcl 語言的軟體。</entry>
<entry/>
</row>
<row>
<entry><filename>textproc</filename></entry>
<entry>Text processing utilities.</entry>
<entry>It does not include
desktop publishing tools, which go to <filename>print</filename>.</entry>
</row>
<row>
<entry><filename>tk*</filename></entry>
<entry>使用 Tk 語言的程式。</entry>
<entry/>
</row>
<row>
<entry><filename>ukrainian</filename></entry>
<entry>Ukrainian language support.</entry>
<entry/>
</row>
<row>
<entry><filename>vietnamese</filename></entry>
<entry>Vietnamese language support.</entry>
<entry/>
</row>
<row>
<entry><filename>windowmaker*</filename></entry>
<entry>Ports to support the WindowMaker window
manager.</entry>
<entry/>
</row>
<row>
<entry><filename>www</filename></entry>
<entry>Software related to the World Wide Web.</entry>
<entry>HTML language
support belongs here too.</entry>
</row>
<row>
<entry><filename>x11</filename></entry>
<entry>The X Window System and friends.</entry>
<entry>This category is only
for software that directly supports the window system. Do not
put regular X applications here; most of them should go
into other <filename>x11-*</filename> categories (see below).
If your port <emphasis>is</emphasis> an X
application, define <varname>USE_XLIB</varname> (implied by
<varname>USE_IMAKE</varname>) and put it in the appropriate
category.</entry>
</row>
<row>
<entry><filename>x11-clocks</filename></entry>
<entry>X11 clocks.</entry>
<entry/>
</row>
<row>
<entry><filename>x11-drivers</filename></entry>
<entry>X11 驅動程式。</entry>
<entry/>
</row>
<row>
<entry><filename>x11-fm</filename></entry>
<entry>X11 file managers.</entry>
<entry/>
</row>
<row>
<entry><filename>x11-fonts</filename></entry>
<entry>X11 fonts and font utilities.</entry>
<entry/>
</row>
<row>
<entry><filename>x11-servers</filename></entry>
<entry>X11 servers.</entry>
<entry/>
</row>
<row>
<entry><filename>x11-themes</filename></entry>
<entry>X11 themes.</entry>
<entry/>
</row>
<row>
<entry><filename>x11-toolkits</filename></entry>
<entry>X11 toolkits.</entry>
<entry/>
</row>
<row>
<entry><filename>x11-wm</filename></entry>
<entry>X11 window managers.</entry>
<entry/>
</row>
<row>
<entry><filename>xfce*</filename></entry>
<entry><link xlink:href="http://www.xfce.org/">Xfce</link>
桌面環境的相關軟體。</entry>
<entry/>
</row>
<row>
<entry><filename>zope*</filename></entry>
<entry><link xlink:href="http://www.zope.org/">Zope</link> support.</entry>
<entry/>
</row>
</tbody>
</tgroup>
</informaltable>
</sect2>
<sect2 xml:id="choosing-categories">
<title>Choosing the right category</title>
<para>As many of the categories overlap, you often have to choose
which of the categories should be the primary category of your port.
There are several rules that govern this issue. Here is the list of
priorities, in decreasing order of precedence:</para>
<itemizedlist>
<listitem>
<para>The first category must be a physical category (see
<link linkend="porting-categories">above</link>). This is
necessary to make the packaging work. Virtual categories and
physical categories may be intermixed after that.</para>
</listitem>
<listitem>
<para>Language specific categories always come first. For
example, if your port installs Japanese X11 fonts, then your
<varname>CATEGORIES</varname> line would read <filename>japanese
x11-fonts</filename>.</para>
</listitem>
<listitem>
<para>Specific categories are listed before less-specific ones. For
instance, an HTML editor should be listed as <filename>www
editors</filename>, not the other way around. Also, you should not
list <filename>net</filename> when the port belongs to
any of <filename>irc</filename>, <filename>mail</filename>,
<filename>mbone</filename>, <filename>news</filename>,
<filename>security</filename>, or <filename>www</filename>, as
<filename>net</filename> is included implicitly.</para>
</listitem>
<listitem>
<para><filename>x11</filename> is used as a secondary category only
when the primary category is a natural language. In particular,
you should not put <filename>x11</filename> in the category line
for X applications.</para>
</listitem>
<listitem>
<para><application>Emacs</application> modes should be
placed in the same ports category as the application
supported by the mode, not in
<filename>editors</filename>. For example, an
<application>Emacs</application> mode to edit source
files of some programming language should go into
<filename>lang</filename>.
</para>
</listitem>
<listitem>
<para>會安裝 kernel loadable modules 的 port 請在
<varname>CATEGORIES</varname> 內加上 <filename>kld</filename>
這個虛擬目錄。</para>
</listitem>
<listitem>
<para><filename>misc</filename>
should not appear with any other non-virtual category.
If you have <literal>misc</literal> with something else in
your <varname>CATEGORIES</varname> line, that means you can
safely delete <literal>misc</literal> and just put the port
in that other subdirectory!</para>
</listitem>
<listitem>
<para>If your port truly does not belong anywhere else, put it in
<filename>misc</filename>.</para>
</listitem>
</itemizedlist>
<para>If you are not sure about the category, please put a comment to
that effect in your &man.send-pr.1; submission so we can
discuss it before we import it. If you are a committer, send a note
to the &a.ports; so we can discuss it first. Too often, new ports are
imported to the wrong category only to be moved right away.
This causes unnecessary and undesirable bloat in the master
source repository.</para>
</sect2>
<sect2 xml:id="proposing-categories">
<title>Proposing a new category</title>
<para>As the Ports Collection has grown over time, various new
categories have been introduced. New categories can either
be <emphasis>virtual</emphasis> categories&mdash;those that do
not have a corresponding subdirectory in the ports tree&mdash;
or <emphasis>physical</emphasis> categories&mdash;those that
do. The following text discusses the issues involved in creating
a new physical category so that you can understand them before
you propose one.</para>
<para>Our existing practice has been to avoid creating a new
physical category unless either a large number of ports would
logically belong to it, or the ports that would belong to it
are a logically distinct group that is of limited general
interest (for instance, categories related to spoken human
languages), or preferably both.</para>
<para>The rationale for this is that such a change creates a
<link xlink:href="&url.articles.committers-guide;/#ports">
fair amount of work</link> for both the committers and also
for all users who track changes to the Ports Collection. In
addition, proposed category changes just naturally seem to
attract controversy. (Perhaps this is because there is no
clear consensus on when a category is <quote>too big</quote>,
nor whether categories should lend themselves to browsing (and
thus what number of categories would be an ideal number), and
so forth.)</para>
<para>Here is the procedure:</para>
<procedure>
<step>
<para>Propose the new category on &a.ports;. You should
include a detailed rationale for the new category,
including why you feel the existing categories are not
sufficient, and the list of existing ports proposed to move.
(If there are new ports pending in
<application>GNATS</application> that would fit this
category, list them too.) If you are the maintainer and/or
submitter, respectively, mention that as it may help you
to make your case.</para>
</step>
<step>
<para>Participate in the discussion.</para>
</step>
<step>
<para>If it seems that there is support for your idea,
file a PR which includes both the rationale and the list
of existing ports that need to be moved. Ideally, this
PR should also include patches for the following:</para>
<itemizedlist>
<listitem>
<para><filename>Makefile</filename>s for the
new ports once they are repocopied</para>
</listitem>
<listitem>
<para><filename>Makefile</filename> for the
new category</para>
</listitem>
<listitem>
<para><filename>Makefile</filename> for the
old ports' categories</para>
</listitem>
<listitem>
<para><filename>Makefile</filename>s for ports
that depend on the old ports</para>
</listitem>
<listitem>
<para>(for extra credit, you can include the other
files that have to change, as per the procedure
in the Committer's Guide.)</para>
</listitem>
</itemizedlist>
</step>
<step>
<para>Since it affects the ports infrastructure and involves
not only performing repo-copies but also possibly running
regression tests on the build cluster, the PR should be
assigned to the &a.portmgr;.</para>
</step>
<step>
<para>If that PR is approved, a committer will need to follow
the rest of the procedure that is
<link xlink:href="&url.articles.committers-guide;/#ports">
outlined in the Committer's Guide</link>.</para>
</step>
</procedure>
<para>Proposing a new virtual category should be similar to
the above but much less involved, since no ports will
actually have to move. In this case, the only patches to
include in the PR would be those to add the new category to the
<varname>CATEGORIES</varname> of the affected ports.</para>
</sect2>
<sect2 xml:id="proposing-reorg">
<title>Proposing reorganizing all the categories</title>
<para>Occasionally someone proposes reorganizing the categories
with either a 2-level structure, or some other kind of keyword
structure. To date, nothing has come of any of these proposals
because, while they are very easy to make, the effort involved to
retrofit the entire existing ports collection with any kind of
reorganization is daunting to say the very least. Please read
the history of these proposals in the mailing list archives before
you post this idea; furthermore, you should be prepared to be
challenged to offer a working prototype.</para>
</sect2>
</sect1>
<sect1 xml:id="makefile-distfiles">
<title>The distribution files</title>
<para>The second part of the <filename>Makefile</filename> describes the
files that must be downloaded in order to build the port, and where
they can be downloaded from.</para>
<sect2>
<title><varname>DISTVERSION/DISTNAME</varname></title>
<para><varname>DISTNAME</varname> is the name of the port as
called by the authors of the software.
<varname>DISTNAME</varname> defaults to
<literal>${PORTNAME}-${PORTVERSION}</literal>, so override it only if necessary.
<varname>DISTNAME</varname> is only used in two places.
First, the distribution file list
(<varname>DISTFILES</varname>) defaults to
<varname>${DISTNAME}</varname><varname>${EXTRACT_SUFX}</varname>.
Second, the distribution file is expected to extract into a
subdirectory named <varname>WRKSRC</varname>, which defaults
to <filename>work/${DISTNAME}</filename>.</para>
<para>Some vendor's distribution names which do not fit into the
<literal>${PORTNAME}-${PORTVERSION}</literal>-scheme can be handled
automatically by setting <varname>DISTVERSION</varname>.
<varname>PORTVERSION</varname> and <varname>DISTNAME</varname> will be
derived automatically, but can of course be overridden. The following
table lists some examples:</para>
<informaltable frame="none" pgwide="1">
<tgroup cols="2">
<thead>
<row>
<entry><varname>DISTVERSION</varname></entry>
<entry><varname>PORTVERSION</varname></entry>
</row>
</thead>
<tbody>
<row>
<entry>0.7.1d</entry>
<entry>0.7.1.d</entry>
</row>
<row>
<entry>10Alpha3</entry>
<entry>10.a3</entry>
</row>
<row>
<entry>3Beta7-pre2</entry>
<entry>3.b7.p2</entry>
</row>
<row>
<entry>8:f_17</entry>
<entry>8f.17</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<note>
<para><varname>PKGNAMEPREFIX</varname> and
<varname>PKGNAMESUFFIX</varname> do not affect
<varname>DISTNAME</varname>. Also note that if
<varname>WRKSRC</varname> is equal to
<filename>work/${PORTNAME}-${PORTVERSION}</filename>
while the original source archive is named something other than
<varname>${PORTNAME}-${PORTVERSION}${EXTRACT_SUFX}</varname>,
you should probably leave <varname>DISTNAME</varname>
alone&mdash; you are better off defining
<varname>DISTFILES</varname> than having to set both
<varname>DISTNAME</varname> and <varname>WRKSRC</varname>
(and possibly <varname>EXTRACT_SUFX</varname>).</para>
</note>
</sect2>
<sect2>
<title><varname>MASTER_SITES</varname></title>
<para>Record the directory part of the FTP/HTTP-URL pointing at the
original tarball in <varname>MASTER_SITES</varname>. Do not forget
the trailing slash (<filename>/</filename>)!</para>
<para>The <command>make</command> macros will try to use this
specification for grabbing the distribution file with
<varname>FETCH</varname> if they cannot find it already on the
system.</para>
<para>It is recommended that you put multiple sites on this list,
preferably from different continents. This will safeguard against
wide-area network problems. We are even planning to add support
for automatically determining the closest master site and fetching
from there; having multiple sites will go a long way towards
helping this effort.</para>
<para>If the original tarball is part of one of the popular
archives such as X-contrib, GNU, or Perl CPAN, you may be able
refer to those sites in an easy compact form using
<varname>MASTER_SITE_<replaceable>*</replaceable></varname>
(比如:<varname>MASTER_SITE_XCONTRIB</varname>
<varname>MASTER_SITE_GNU</varname>
<varname>MASTER_SITE_PERL_CPAN</varname>)。 Simply set
<varname>MASTER_SITES</varname> to one of these variables and
<varname>MASTER_SITE_SUBDIR</varname> to the path within the
archive. Here is an example:</para>
<programlisting>MASTER_SITES= ${MASTER_SITE_XCONTRIB}
MASTER_SITE_SUBDIR= applications</programlisting>
<para>These variables are defined in
<filename>/usr/ports/Mk/bsd.sites.mk</filename>. There are
new entries added all the time, so make sure to check the
latest version of this file before submitting a port.</para>
<para>The user can also set the <varname>MASTER_SITE_*</varname>
variables in <filename>/etc/make.conf</filename> to override our
choices, and use their favorite mirrors of these popular archives
instead.</para>
</sect2>
<sect2>
<title><varname>EXTRACT_SUFX</varname></title>
<para>If you have one distribution file, and it uses an odd suffix to
indicate the compression mechanism, set
<varname>EXTRACT_SUFX</varname>.</para>
<para>For example, if the distribution file was named
<filename>foo.tgz</filename> instead of the more normal
<filename>foo.tar.gz</filename>, you would write:</para>
<programlisting>DISTNAME= foo
EXTRACT_SUFX= .tgz</programlisting>
<para>The <varname>USE_BZIP2</varname> and <varname>USE_ZIP</varname>
variables automatically set <varname>EXTRACT_SUFX</varname> to
<literal>.tar.bz2</literal> or <literal>.zip</literal> as necessary. If
neither of these are set then <varname>EXTRACT_SUFX</varname>
defaults to <literal>.tar.gz</literal>.</para>
<note>
<para>You never need to set both <varname>EXTRACT_SUFX</varname> and
<varname>DISTFILES</varname>.</para>
</note>
</sect2>
<sect2>
<title><varname>DISTFILES</varname></title>
<para>Sometimes the names of the files to be downloaded have no
resemblance to the name of the port. For example, it might be
called <filename>source.tar.gz</filename> or similar. In other
cases the application's source code might be in several different
archives, all of which must be downloaded.</para>
<para>If this is the case, set <varname>DISTFILES</varname> to be a
space separated list of all the files that must be
downloaded.</para>
<programlisting>DISTFILES= source1.tar.gz source2.tar.gz</programlisting>
<para>If not explicitly set, <varname>DISTFILES</varname> defaults to
<literal>${DISTNAME}${EXTRACT_SUFX}</literal>.</para>
</sect2>
<sect2>
<title><varname>EXTRACT_ONLY</varname></title>
<para>If only some of the <varname>DISTFILES</varname> must be
extracted&mdash;for example, one of them is the source code, while
another is an uncompressed document&mdash;list the filenames that
must be extracted in <varname>EXTRACT_ONLY</varname>.</para>
<programlisting>DISTFILES= source.tar.gz manual.html
EXTRACT_ONLY= source.tar.gz</programlisting>
<para>If <emphasis>none</emphasis> of the <varname>DISTFILES</varname>
should be uncompressed then set <varname>EXTRACT_ONLY</varname> to
the empty string.</para>
<programlisting>EXTRACT_ONLY=</programlisting>
</sect2>
<sect2 xml:id="porting-patchfiles">
<title><varname>PATCHFILES</varname></title>
<para>If your port requires some additional patches that are available
by FTP or HTTP, set <varname>PATCHFILES</varname> to the names of
the files and <varname>PATCH_SITES</varname> to the URL of the
directory that contains them (the format is the same as
<varname>MASTER_SITES</varname>).</para>
<para>If the patch is not relative to the top of the source tree
(i.e., <varname>WRKSRC</varname>) because it contains some extra
pathnames, set <varname>PATCH_DIST_STRIP</varname> accordingly. For
instance, if all the pathnames in the patch have an extra
<literal>foozolix-1.0/</literal> in front of the filenames, then set
<literal>PATCH_DIST_STRIP=-p1</literal>.</para>
<para>Do not worry if the patches are compressed; they will be
decompressed automatically if the filenames end with
<filename>.gz</filename> or <filename>.Z</filename>.</para>
<para>If the patch is distributed with some other files, such as
documentation, in a gzip'd tarball, you cannot just use
<varname>PATCHFILES</varname>. If that is the case, add the name
and the location of the patch tarball to
<varname>DISTFILES</varname> and <varname>MASTER_SITES</varname>.
Then, use the <varname>EXTRA_PATCHES</varname> variable to
point to those files and <filename>bsd.port.mk</filename>
will automatically apply them for you. In particular, do
<emphasis>not</emphasis> copy patch files into the
<varname>PATCHDIR</varname> directory&mdash;that directory may
not be writable.</para>
<note>
<para>The tarball will have been extracted alongside the
regular source by then, so there is no need to explicitly extract
it if it is a regular gzip'd or compress'd tarball. If you do the
latter, take extra care not to overwrite something that already
exists in that directory. Also, do not forget to add a command to
remove the copied patch in the <buildtarget>pre-clean</buildtarget>
target.</para>
</note>
</sect2>
<sect2 xml:id="porting-master-sites-n">
<title>Multiple distribution files or patches from different
sites and subdirectories
(<literal>MASTER_SITES:n</literal>)</title>
<para>(Consider this to be a somewhat <quote>advanced topic</quote>;
those new to this document may wish to skip this section at first).
</para>
<para>This section has information on the fetching mechanism
known as both <literal>MASTER_SITES:n</literal> and
<literal>MASTER_SITES_NN</literal>. We will refer to this
mechanism as <literal>MASTER_SITES:n</literal>
hereon.</para>
<para>A little background first. OpenBSD has a neat feature
inside both <varname>DISTFILES</varname> and
<varname>PATCHFILES</varname> variables, both files and
patches can be postfixed with <literal>:n</literal>
identifiers where <literal>n</literal> both can be
<literal>[0-9]</literal> and denote a group designation.
For example:</para>
<programlisting>DISTFILES= alpha:0 beta:1</programlisting>
<para>In OpenBSD, distribution file <filename>alpha</filename>
will be associated with variable
<varname>MASTER_SITES0</varname> instead of our common
<varname>MASTER_SITES</varname> and
<filename>beta</filename> with
<varname>MASTER_SITES1</varname>.</para>
<para>This is a very interesting feature which can decrease
that endless search for the correct download site.</para>
<para>Just picture 2 files in <varname>DISTFILES</varname> and
20 sites in <varname>MASTER_SITES</varname>, the sites slow
as hell where <filename>beta</filename> is carried by all
sites in <varname>MASTER_SITES</varname>, and
<filename>alpha</filename> can only be found in the 20th
site. It would be such a waste to check all of them if
maintainer knew this beforehand, would it not? Not a good
start for that lovely weekend!</para>
<para>Now that you have the idea, just imagine more
<varname>DISTFILES</varname> and more
<varname>MASTER_SITES</varname>. Surely our
<quote>distfiles survey meister</quote> would appreciate the
relief to network strain that this would bring.</para>
<para>In the next sections, information will follow on the
FreeBSD implementation of this idea. We improved a bit on
OpenBSD's concept.</para>
<sect3>
<title>Simplified information</title>
<para>This section tells you how to quickly prepare fine
grained fetching of multiple distribution files and
patches from different sites and subdirectories. We
describe here a case of simplified
<literal>MASTER_SITES:n</literal> usage. This will be
sufficient for most scenarios. However, if you need
further information, you will have to refer to the next
section.</para>
<para>Some applications consist of multiple distribution
files that must be downloaded from a number of different
sites. For example,
<application>Ghostscript</application> consists of the
core of the program, and then a large number of driver
files that are used depending on the user's printer. Some
of these driver files are supplied with the core, but many
others must be downloaded from a variety of different
sites.</para>
<para>To support this, each entry in
<varname>DISTFILES</varname> may be followed by a colon
and a <quote>tag name</quote>. Each site listed in
<varname>MASTER_SITES</varname> is then followed by a
colon, and the tag that indicates which distribution files
should be downloaded from this site.</para>
<para>For example, consider an application with the source
split in two parts, <filename>source1.tar.gz</filename>
and <filename>source2.tar.gz</filename>, which must be
downloaded from two different sites. The port's
<filename>Makefile</filename> would include lines like
<xref linkend="ports-master-sites-n-example-simple-use-one-file-per-site"/>.</para>
<example xml:id="ports-master-sites-n-example-simple-use-one-file-per-site">
<title>Simplified use of <literal>MASTER_SITES:n</literal>
with 1 file per site</title>
<programlisting>MASTER_SITES= ftp://ftp.example1.com/:source1 \
ftp://ftp.example2.com/:source2
DISTFILES= source1.tar.gz:source1 \
source2.tar.gz:source2</programlisting>
</example>
<para>Multiple distribution files can have the same tag.
Continuing the previous example, suppose that there was a
third distfile, <filename>source3.tar.gz</filename>, that
should be downloaded from
<systemitem>ftp.example2.com</systemitem>. The
<filename>Makefile</filename> would then be written like
<xref linkend="ports-master-sites-n-example-simple-use-more-than-one-file-per-site"/>.</para>
<example xml:id="ports-master-sites-n-example-simple-use-more-than-one-file-per-site">
<title>Simplified use of <literal>MASTER_SITES:n</literal>
with more than 1 file per site</title>
<programlisting>MASTER_SITES= ftp://ftp.example1.com/:source1 \
ftp://ftp.example2.com/:source2
DISTFILES= source1.tar.gz:source1 \
source2.tar.gz:source2 \
source3.tar.gz:source2</programlisting>
</example>
</sect3>
<sect3>
<title>Detailed information</title>
<para>Okay, so the previous section example did not reflect
your needs? In this section we will explain in detail how
the fine grained fetching mechanism
<literal>MASTER_SITES:n</literal> works and how you can
modify your ports to use it.</para>
<orderedlist>
<listitem>
<para>Elements can be postfixed with
<literal>:n</literal> where
<replaceable>n</replaceable> is
<literal>[^:,]+</literal>, i.e.,
<replaceable>n</replaceable> could conceptually be any
alphanumeric string but we will limit it to
<literal>[a-zA-Z_][0-9a-zA-Z_]+</literal> for
now.</para>
<para>Moreover, string matching is case sensitive;
i.e., <literal>n</literal> is different from
<literal>N</literal>.</para>
<para>However, the following words cannot be used for
postfixing purposes since they yield special meaning:
<literal>default</literal>, <literal>all</literal> and
<literal>ALL</literal> (they are used internally in
item <xref linkend="porting-master-sites-n-what-changes-in-port-targets"/>).
Furthermore, <literal>DEFAULT</literal> is a special
purpose word (check item <xref linkend="porting-master-sites-n-DEFAULT-group"/>).</para>
</listitem>
<listitem>
<para>Elements postfixed with <literal>:n</literal>
belong to the group <literal>n</literal>,
<literal>:m</literal> belong to group
<literal>m</literal> and so forth.</para>
</listitem>
<listitem xml:id="porting-master-sites-n-DEFAULT-group">
<para>Elements without a postfix are groupless, i.e.,
they all belong to the special group
<literal>DEFAULT</literal>. If you postfix any
elements with <literal>DEFAULT</literal>, you are just
being redundant unless you want to have an element
belonging to both <literal>DEFAULT</literal> and other
groups at the same time (check item <xref linkend="porting-master-sites-n-comma-operator"/>).</para>
<para>The following examples are equivalent but the
first one is preferred:</para>
<programlisting>MASTER_SITES= alpha
MASTER_SITES= alpha:DEFAULT</programlisting>
</listitem>
<listitem>
<para>Groups are not exclusive, an element may belong to
several different groups at the same time and a group
can either have either several different elements or
none at all. Repeated elements within the same group
will be simply that, repeated elements.</para>
</listitem>
<listitem xml:id="porting-master-sites-n-comma-operator">
<para>When you want an element to belong to several
groups at the same time, you can use the comma
operator (<literal>,</literal>).</para>
<para>Instead of repeating it several times, each time
with a different postfix, we can list several groups
at once in a single postfix. For instance,
<literal>:m,n,o</literal> marks an element that
belongs to group <literal>m</literal>,
<literal>n</literal> and <literal>o</literal>.</para>
<para>All the following examples are equivalent but the
last one is preferred:</para>
<programlisting>MASTER_SITES= alpha alpha:SOME_SITE
MASTER_SITES= alpha:DEFAULT alpha:SOME_SITE
MASTER_SITES= alpha:SOME_SITE,DEFAULT
MASTER_SITES= alpha:DEFAULT,SOME_SITE</programlisting>
</listitem>
<listitem>
<para>All sites within a given group are sorted
according to <varname>MASTER_SORT_AWK</varname>. All
groups within <varname>MASTER_SITES</varname> and
<varname>PATCH_SITES</varname> are sorted as
well.</para>
</listitem>
<listitem xml:id="porting-master-sites-n-group-semantics">
<para>Group semantics can be used in any of the
following variables <varname>MASTER_SITES</varname>,
<varname>PATCH_SITES</varname>,
<varname>MASTER_SITE_SUBDIR</varname>,
<varname>PATCH_SITE_SUBDIR</varname>,
<varname>DISTFILES</varname>, and
<varname>PATCHFILES</varname> according to the
following syntax:</para>
<orderedlist>
<listitem>
<para>All <varname>MASTER_SITES</varname>,
<varname>PATCH_SITES</varname>,
<varname>MASTER_SITE_SUBDIR</varname> and
<varname>PATCH_SITE_SUBDIR</varname> elements must
be terminated with the forward slash
<literal>/</literal> character. If any elements
belong to any groups, the group postfix
<literal>:n</literal>
must come right after the terminator
<literal>/</literal>. The
<literal>MASTER_SITES:n</literal> mechanism relies
on the existence of the terminator
<literal>/</literal> to avoid confusing elements
where a <literal>:n</literal> is a valid part of
the element with occurrences where
<literal>:n</literal> denotes group
<literal>n</literal>. For compatibility purposes,
since the <literal>/</literal> terminator was not
required before in both
<varname>MASTER_SITE_SUBDIR</varname> and
<varname>PATCH_SITE_SUBDIR</varname> elements, if
the postfix immediate preceding character is not
a <literal>/</literal> then <literal>:n</literal>
will be considered a valid part of the element
instead of a group postfix even if an element is
postfixed with <literal>:n</literal>. See both
<xref linkend="ports-master-sites-n-example-detailed-use-master-site-subdir"/>
and <xref linkend="ports-master-sites-n-example-detailed-use-complete-example-master-sites"/>.</para>
<example xml:id="ports-master-sites-n-example-detailed-use-master-site-subdir">
<title>Detailed use of
<literal>MASTER_SITES:n</literal> in
<varname>MASTER_SITE_SUBDIR</varname></title>
<programlisting>MASTER_SITE_SUBDIR= old:n new/:NEW</programlisting>
<itemizedlist>
<listitem>
<para>Directories within group
<literal>DEFAULT</literal> -&gt; old:n</para>
</listitem>
<listitem>
<para>Directories within group
<literal>NEW</literal> -&gt; new</para>
</listitem>
</itemizedlist>
</example>
<example xml:id="ports-master-sites-n-example-detailed-use-complete-example-master-sites">
<title>Detailed use of
<literal>MASTER_SITES:n</literal> with comma
operator, multiple files, multiple sites and
multiple subdirectories</title>
<programlisting>MASTER_SITES= http://site1/%SUBDIR%/ http://site2/:DEFAULT \
http://site3/:group3 http://site4/:group4 \
http://site5/:group5 http://site6/:group6 \
http://site7/:DEFAULT,group6 \
http://site8/%SUBDIR%/:group6,group7 \
http://site9/:group8
DISTFILES= file1 file2:DEFAULT file3:group3 \
file4:group4,group5,group6 file5:grouping \
file6:group7
MASTER_SITE_SUBDIR= directory-trial:1 directory-n/:groupn \
directory-one/:group6,DEFAULT \
directory</programlisting>
<para>The previous example results in the
following fine grained fetching. Sites are
listed in the exact order they will be
used.</para>
<itemizedlist>
<listitem>
<para><filename>file1</filename> will be
fetched from</para>
<itemizedlist>
<listitem>
<para><varname>MASTER_SITE_OVERRIDE</varname></para>
</listitem>
<listitem>
<para>http://site1/directory-trial:1/</para>
</listitem>
<listitem>
<para>http://site1/directory-one/</para>
</listitem>
<listitem>
<para>http://site1/directory/</para>
</listitem>
<listitem>
<para>http://site2/</para>
</listitem>
<listitem>
<para>http://site7/</para>
</listitem>
<listitem>
<para><varname>MASTER_SITE_BACKUP</varname></para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para><filename>file2</filename> will be
fetched exactly as
<filename>file1</filename> since they
both belong to the same group</para>
<itemizedlist>
<listitem>
<para><varname>MASTER_SITE_OVERRIDE</varname></para>
</listitem>
<listitem>
<para>http://site1/directory-trial:1/</para>
</listitem>
<listitem>
<para>http://site1/directory-one/</para>
</listitem>
<listitem>
<para>http://site1/directory/</para>
</listitem>
<listitem>
<para>http://site2/</para>
</listitem>
<listitem>
<para>http://site7/</para>
</listitem>
<listitem>
<para><varname>MASTER_SITE_BACKUP</varname></para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para><filename>file3</filename> will be
fetched from</para>
<itemizedlist>
<listitem>
<para><varname>MASTER_SITE_OVERRIDE</varname></para>
</listitem>
<listitem>
<para>http://site3/</para>
</listitem>
<listitem>
<para><varname>MASTER_SITE_BACKUP</varname></para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para><filename>file4</filename> will be
fetched from</para>
<itemizedlist>
<listitem>
<para><varname>MASTER_SITE_OVERRIDE</varname></para>
</listitem>
<listitem>
<para>http://site4/</para>
</listitem>
<listitem>
<para>http://site5/</para>
</listitem>
<listitem>
<para>http://site6/</para>
</listitem>
<listitem>
<para>http://site7/</para>
</listitem>
<listitem>
<para>http://site8/directory-one/</para>
</listitem>
<listitem>
<para><varname>MASTER_SITE_BACKUP</varname></para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para><filename>file5</filename> will be
fetched from</para>
<itemizedlist>
<listitem>
<para><varname>MASTER_SITE_OVERRIDE</varname></para>
</listitem>
<listitem>
<para><varname>MASTER_SITE_BACKUP</varname></para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para><filename>file6</filename> will be
fetched from</para>
<itemizedlist>
<listitem>
<para><varname>MASTER_SITE_OVERRIDE</varname></para>
</listitem>
<listitem>
<para>http://site8/</para>
</listitem>
<listitem>
<para><varname>MASTER_SITE_BACKUP</varname></para>
</listitem>
</itemizedlist>
</listitem>
</itemizedlist>
</example>
</listitem>
</orderedlist>
</listitem>
<listitem>
<para>How do I group one of the special variables from
<filename>bsd.sites.mk</filename>, e.g.,
<varname>MASTER_SITE_SOURCEFORGE</varname>?</para>
<para>See <xref linkend="ports-master-sites-n-example-detailed-use-master-site-sourceforge"/>.</para>
<example xml:id="ports-master-sites-n-example-detailed-use-master-site-sourceforge">
<title>Detailed use of
<literal>MASTER_SITES:n</literal> with
<varname>MASTER_SITE_SOURCEFORGE</varname></title>
<programlisting>MASTER_SITES= http://site1/ ${MASTER_SITE_SOURCEFORGE:S/$/:sourceforge,TEST/}
DISTFILES= something.tar.gz:sourceforge</programlisting>
</example>
<para><filename>something.tar.gz</filename> will be
fetched from all sites within
<varname>MASTER_SITE_SOURCEFORGE</varname>.</para>
</listitem>
<listitem>
<para>How do I use this with <varname>PATCH*</varname>
variables?</para>
<para>All examples were done with
<varname>MASTER*</varname> variables but they work
exactly the same for <varname>PATCH*</varname> ones as
can be seen in <xref linkend="ports-master-sites-n-example-detailed-use-patch-sites"/>.</para>
<example xml:id="ports-master-sites-n-example-detailed-use-patch-sites">
<title>Simplified use of
<literal>MASTER_SITES:n</literal> with
<varname>PATCH_SITES</varname>.</title>
<programlisting>PATCH_SITES= http://site1/ http://site2/:test
PATCHFILES= patch1:test</programlisting>
</example>
</listitem>
</orderedlist>
</sect3>
<sect3>
<title>What does change for ports? What does not?</title>
<orderedlist numeration="lowerroman">
<listitem>
<para>All current ports remain the same. The
<literal>MASTER_SITES:n</literal> feature code is only
activated if there are elements postfixed with
<literal>:n</literal> like
elements according to the aforementioned syntax rules,
especially as shown in item <xref linkend="porting-master-sites-n-group-semantics"/>.</para>
</listitem>
<listitem xml:id="porting-master-sites-n-what-changes-in-port-targets">
<para>The port targets remain the same:
<buildtarget>checksum</buildtarget>,
<buildtarget>makesum</buildtarget>,
<buildtarget>patch</buildtarget>,
<buildtarget>configure</buildtarget>,
<buildtarget>build</buildtarget>, etc. With the obvious
exceptions of <buildtarget>do-fetch</buildtarget>,
<buildtarget>fetch-list</buildtarget>,
<buildtarget>master-sites</buildtarget> and
<buildtarget>patch-sites</buildtarget>.</para>
<itemizedlist>
<listitem>
<para><buildtarget>do-fetch</buildtarget>: deploys the
new grouping postfixed
<varname>DISTFILES</varname> and
<varname>PATCHFILES</varname> with their matching
group elements within both
<varname>MASTER_SITES</varname> and
<varname>PATCH_SITES</varname> which use matching
group elements within both
<varname>MASTER_SITE_SUBDIR</varname> and
<varname>PATCH_SITE_SUBDIR</varname>. Check <xref linkend="ports-master-sites-n-example-detailed-use-complete-example-master-sites"/>.</para>
</listitem>
<listitem>
<para><buildtarget>fetch-list</buildtarget>: works
like old <buildtarget>fetch-list</buildtarget> with
the exception that it groups just like
<buildtarget>do-fetch</buildtarget>.</para>
</listitem>
<listitem>
<para><buildtarget>master-sites</buildtarget> and
<buildtarget>patch-sites</buildtarget>:
(incompatible with older versions) only return the
elements of group <literal>DEFAULT</literal>; in
fact, they execute targets
<buildtarget>master-sites-default</buildtarget> and
<buildtarget>patch-sites-default</buildtarget>
respectively.</para>
<para>Furthermore, using target either
<buildtarget>master-sites-all</buildtarget> or
<buildtarget>patch-sites-all</buildtarget> is
preferred to directly checking either
<buildtarget>MASTER_SITES</buildtarget> or
<buildtarget>PATCH_SITES</buildtarget>. Also,
directly checking is not guaranteed to work in any
future versions. Check item <xref linkend="porting-master-sites-n-new-port-targets-master-sites-all"/>
for more information on these new port
targets.</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para>New port targets</para>
<orderedlist>
<listitem>
<para>There are
<buildtarget>master-sites-<replaceable>n</replaceable></buildtarget>
and
<buildtarget>patch-sites-<replaceable>n</replaceable></buildtarget>
targets which will list the elements of the
respective group <replaceable>n</replaceable>
within <varname>MASTER_SITES</varname> and
<varname>PATCH_SITES</varname> respectively. For
instance, both
<buildtarget>master-sites-DEFAULT</buildtarget> and
<buildtarget>patch-sites-DEFAULT</buildtarget> will
return the elements of group
<literal>DEFAULT</literal>,
<buildtarget>master-sites-test</buildtarget> and
<buildtarget>patch-sites-test</buildtarget> of group
<literal>test</literal>, and thereon.</para>
</listitem>
<listitem xml:id="porting-master-sites-n-new-port-targets-master-sites-all">
<para>There are new targets
<buildtarget>master-sites-all</buildtarget> and
<buildtarget>patch-sites-all</buildtarget> which do
the work of the old
<buildtarget>master-sites</buildtarget> and
<buildtarget>patch-sites</buildtarget> ones. They
return the elements of all groups as if they all
belonged to the same group with the caveat that it
lists as many
<varname>MASTER_SITE_BACKUP</varname> and
<varname>MASTER_SITE_OVERRIDE</varname> as there
are groups defined within either
<varname>DISTFILES</varname> or
<varname>PATCHFILES</varname>; respectively for
<buildtarget>master-sites-all</buildtarget> and
<buildtarget>patch-sites-all</buildtarget>.</para>
</listitem>
</orderedlist>
</listitem>
</orderedlist>
</sect3>
</sect2>
<sect2>
<title><varname>DIST_SUBDIR</varname></title>
<para>Do not let your port clutter
<filename>/usr/ports/distfiles</filename>. If your port requires a
lot of files to be fetched, or contains a file that has a name that
might conflict with other ports (e.g.,
<filename>Makefile</filename>), set <varname>DIST_SUBDIR</varname>
to the name of the port (<literal>${PORTNAME}</literal> or
<literal>${PKGNAMEPREFIX}${PORTNAME}</literal>
should work fine). This will change
<varname>DISTDIR</varname> from the default
<filename>/usr/ports/distfiles</filename> to
<filename>/usr/ports/distfiles/DIST_SUBDIR</filename>,
and in effect puts everything that is required for your port into
that subdirectory.</para>
<para>It will also look at the subdirectory with the same name on the
backup master site at <filename>ftp.FreeBSD.org</filename>.
(Setting <varname>DISTDIR</varname> explicitly in your
<varname>Makefile</varname> will not accomplish this, so please use
<varname>DIST_SUBDIR</varname>.)</para>
<note>
<para>This does not affect the <varname>MASTER_SITES</varname> you
define in your <filename>Makefile</filename>.</para>
</note>
</sect2>
<sect2>
<title><varname>ALWAYS_KEEP_DISTFILES</varname></title>
<para>If your port uses binary distfiles and has a license that
requires that the source code is provided with packages distributed
in binary form, e.g. GPL, <varname>ALWAYS_KEEP_DISTFILES</varname>
will instruct the &os; build cluster to keep a copy of the files
specified in <varname>DISTFILES</varname>. Users of these ports
will generally not need these files, so it is a good idea to only
add the source distfiles to <varname>DISTFILES</varname> when
<varname>PACKAGE_BUILDING</varname> is defined.
</para>
<example xml:id="ports-master-sites-n-example-always-keep-distfiles">
<title>Use of <varname>ALWAYS_KEEP_DISTFILES</varname>.</title>
<programlisting>.if defined(PACKAGE_BUILDING)
DISTFILES+= <replaceable>foo.tar.gz</replaceable>
ALWAYS_KEEP_DISTFILES= yes
.endif</programlisting>
</example>
<para>When adding extra files to <varname>DISTFILES</varname>,
make sure you also add them to <filename>distinfo</filename>.
Also, the additional files will normally be extracted into
<varname>WRKDIR</varname> as well, which for some ports may
lead to undesirable sideeffects and require special handling.</para>
</sect2>
</sect1>
<sect1 xml:id="makefile-maintainer">
<title><varname>MAINTAINER</varname></title>
<para>Set your mail-address here. Please. <!-- smiley
--><emphasis>:-)</emphasis></para>
<para>Note that only a single address without the comment part is
allowed as a <varname>MAINTAINER</varname> value.
The format used should be <literal>user@hostname.domain</literal>.
Please do not include any descriptive text such as your real
name in this entry&mdash;that merely confuses
<filename>bsd.port.mk</filename>.</para>
<para>The maintainer is responsible for keeping the port up to
date, and ensuring the port works correctly.
For a detailed description of the responsibilities of a port
maintainer, refer to the <link xlink:href="&url.articles.contributing-ports;/maintain-port.html">The
challenge for port maintainers</link> section.</para>
<para>Changes to the port will be sent to the maintainer of
a port for a review and an approval before being committed.
If the maintainer does not respond to an update
request after two weeks (excluding major public
holidays), then that is considered a maintainer timeout, and the
update may be made without explicit maintainer approval. If the
maintainer does not respond within three months, then that
maintainer is considered absent without leave, and can be
replaced as the maintainer of the particular port in question.
Exceptions to this are anything maintained by the &a.portmgr;, or
the &a.security-officer;. No unauthorized commits may ever be
made to ports maintained by those groups.</para>
<para>We reserve the right to modify the maintainer's submission
to better match existing policies and style of the Ports
Collection without explicit blessing from the submitter.
Also, large infrastructural changes can result in
a port being modified without maintainer's consent.
This kind of changes will never affect the port's
functionality.</para>
<para>The &a.portmgr; reserves the right to revoke or override
anyone's maintainership for any reason, and the &a.security-officer;
reserves the right to revoke or override maintainership for security
reasons.</para>
</sect1>
<sect1 xml:id="makefile-comment">
<title><varname>COMMENT</varname></title>
<para>This is a one-line description of the port.
<emphasis>Please</emphasis> do not include the package name (or
version number of the software) in the comment. The comment
should begin with a capital and end without a period. Here
is an example:</para>
<programlisting>COMMENT= A cat chasing a mouse all over the screen</programlisting>
<para>The COMMENT variable should immediately follow the MAINTAINER
variable in the <filename>Makefile</filename>.</para>
<para>Please try to keep the COMMENT line less than 70
characters, as it is displayed to users as a one-line
summary of the port.</para>
</sect1>
<sect1 xml:id="makefile-depend">
<title>Dependencies</title>
<para>Many ports depend on other ports. There are seven variables that
you can use to ensure that all the required bits will be on the
user's machine. There are also some pre-supported dependency
variables for common cases, plus a few more to control the behavior
of dependencies.</para>
<sect2>
<title><varname>LIB_DEPENDS</varname></title>
<para>This variable specifies the shared libraries this port depends
on. It is a list of
<replaceable>lib</replaceable>:<replaceable>dir</replaceable><optional>:target</optional>
tuples where <replaceable>lib</replaceable> is the name of the
shared library, <replaceable>dir</replaceable> is the
directory in which to find it in case it is not available, and
<replaceable>target</replaceable> is the target to call in that
directory. For example,
<programlisting>LIB_DEPENDS= jpeg.9:${PORTSDIR}/graphics/jpeg</programlisting>
will check for a shared jpeg library with major version 9, and
descend into the <filename>graphics/jpeg</filename> subdirectory
of your ports tree to build and install it if it is not found.
The <replaceable>target</replaceable> part can be omitted if it is
equal to <varname>DEPENDS_TARGET</varname> (which defaults to
<literal>install</literal>).</para>
<note>
<para>The <replaceable>lib</replaceable> part is a regular
expression which is being looked up in the
<command>ldconfig -r</command> output. Values such as
<literal>intl.[5-7]</literal> and <literal>intl</literal> are
allowed. The first pattern,
<literal>intl.[5-7]</literal>, will match any of:
<literal>intl.5</literal>, <literal>intl.6</literal> or
<literal>intl.7</literal>. The second pattern,
<literal>intl</literal>, will match any version of the
<literal>intl</literal> library.</para>
</note>
<para>The dependency is checked twice, once from within the
<buildtarget>extract</buildtarget> target and then from within the
<buildtarget>install</buildtarget> target. Also, the name of the
dependency is put into the package so that
&man.pkg.add.1; will automatically install it if it is
not on the user's system.</para>
</sect2>
<sect2>
<title><varname>RUN_DEPENDS</varname></title>
<para>This variable specifies executables or files this port depends
on during run-time. It is a list of
<replaceable>path</replaceable>:<replaceable>dir</replaceable><optional>:target</optional>
tuples where <replaceable>path</replaceable> is the name of the
executable or file, <replaceable>dir</replaceable> is the
directory in which to find it in case it is not available, and
<replaceable>target</replaceable> is the target to call in that
directory. If <replaceable>path</replaceable> starts with a slash
(<literal>/</literal>), it is treated as a file and its existence
is tested with <command>test -e</command>; otherwise, it is
assumed to be an executable, and <command>which -s</command> is
used to determine if the program exists in the search path.</para>
<para>For example,</para>
<programlisting>RUN_DEPENDS= ${LOCALBASE}/etc/innd:${PORTSDIR}/news/inn \
xmlcatmgr:${PORTSDIR}/textproc/xmlcatmgr</programlisting>
<para>will check if the file or directory
<filename>/usr/local/etc/innd</filename> exists, and build and
install it from the <filename>news/inn</filename> subdirectory of
the ports tree if it is not found. It will also see if an
executable called <command>xmlcatmgr</command> is in the search
path, and descend into the <filename>textproc/xmlcatmgr</filename>
subdirectory of your ports tree to build and install it if it is
not found.</para>
<note>
<para>In this case, <command>innd</command> is actually an
executable; if an executable is in a place that is not expected
to be in the search path, you should use the full
pathname.</para>
</note>
<note>
<para>The official search <envar>PATH</envar> used on the ports
build cluster is</para>
<programlisting>/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin:/usr/X11R6/bin</programlisting>
</note>
<para>The dependency is checked from within the
<buildtarget>install</buildtarget> target. Also, the name of the
dependency is put into the package so that
&man.pkg.add.1; will automatically install it if it is
not on the user's system. The <replaceable>target</replaceable>
part can be omitted if it is the same as
<varname>DEPENDS_TARGET</varname>.</para>
</sect2>
<sect2>
<title><varname>BUILD_DEPENDS</varname></title>
<para>This variable specifies executables or files this port
requires to build. Like <varname>RUN_DEPENDS</varname>, it is a
list of
<replaceable>path</replaceable>:<replaceable>dir</replaceable><optional>:target</optional>
tuples. For example, <programlisting> BUILD_DEPENDS=
unzip:${PORTSDIR}/archivers/unzip</programlisting> will check
for an executable called <command>unzip</command>, and descend
into the <filename>archivers/unzip</filename> subdirectory of your
ports tree to build and install it if it is not found.</para>
<note>
<para><quote>build</quote> here means everything from extraction to
compilation. The dependency is checked from within the
<buildtarget>extract</buildtarget> target. The
<replaceable>target</replaceable> part can be omitted if it is
the same as <varname>DEPENDS_TARGET</varname></para>
</note>
</sect2>
<sect2>
<title><varname>FETCH_DEPENDS</varname></title>
<para>This variable specifies executables or files this port
requires to fetch. Like the previous two, it is a list of
<replaceable>path</replaceable>:<replaceable>dir</replaceable><optional>:target</optional>
tuples. For example, <programlisting> FETCH_DEPENDS=
ncftp2:${PORTSDIR}/net/ncftp2</programlisting> will check for an
executable called <command>ncftp2</command>, and descend into the
<filename>net/ncftp2</filename> subdirectory of your ports tree to
build and install it if it is not found.</para>
<para>The dependency is checked from within the
<buildtarget>fetch</buildtarget> target. The
<replaceable>target</replaceable> part can be omitted if it is the
same as <varname>DEPENDS_TARGET</varname>.</para>
</sect2>
<sect2>
<title><varname>EXTRACT_DEPENDS</varname></title>
<para>This variable specifies executables or files this port
requires for extraction. Like the previous, it is a list of
<replaceable>path</replaceable>:<replaceable>dir</replaceable><optional>:target</optional>
tuples. For example, <programlisting>EXTRACT_DEPENDS=
unzip:${PORTSDIR}/archivers/unzip</programlisting> will check
for an executable called <command>unzip</command>, and descend
into the <filename>archivers/unzip</filename> subdirectory of
your ports tree to build and install it if it is not found.</para>
<para>The dependency is checked from within the
<buildtarget>extract</buildtarget> target. The
<replaceable>target</replaceable> part can be omitted if it is the
same as <varname>DEPENDS_TARGET</varname>.</para>
<note>
<para>Use this variable only if the extraction does not already
work (the default assumes <command>gzip</command>) and cannot
be made to work using <varname>USE_ZIP</varname> or
<varname>USE_BZIP2</varname> described in <xref linkend="use-vars"/>.</para>
</note>
</sect2>
<sect2>
<title><varname>PATCH_DEPENDS</varname></title>
<para>This variable specifies executables or files this port
requires to patch. Like the previous, it is a list of
<replaceable>path</replaceable>:<replaceable>dir</replaceable><optional>:target</optional>
tuples. For example, <programlisting> PATCH_DEPENDS=
${NONEXISTENT}:${PORTSDIR}/java/jfc:extract
</programlisting>will descend into the
<filename>java/jfc</filename> subdirectory of your ports tree to
extract it.</para>
<para>The dependency is checked from within the
<buildtarget>patch</buildtarget> target. The
<replaceable>target</replaceable> part can be omitted if it is the
same as <varname>DEPENDS_TARGET</varname>.</para>
</sect2>
<sect2 xml:id="use-vars">
<title><varname>USE_<replaceable>*</replaceable></varname></title>
<para>A number of variables exist in order to encapsulate common
dependencies that many ports have. Although their use is
optional, they can help to reduce the verbosity of the port
<filename>Makefile</filename>s. Each of them is styled
as <varname>USE_<replaceable>*</replaceable></varname>. The
usage of these variables is restricted to the port
<filename>Makefile</filename>s and
<filename>ports/Mk/bsd.*.mk</filename> and is not designed
to encapsulate user-settable options &mdash; use
<varname>WITH_<replaceable>*</replaceable></varname> and
<varname>WITHOUT_<replaceable>*</replaceable></varname>
for that purpose.</para>
<note>
<para>It is <emphasis>always</emphasis> incorrect to set
any <varname>USE_<replaceable>*</replaceable></varname>
in <filename>/etc/make.conf</filename>. For instance,
setting <programlisting>USE_GCC=3.2</programlisting>
would adds a dependency on gcc32 for every port,
including gcc32 itself!</para>
</note>
<table frame="none">
<title>The <varname>USE_<replaceable>*</replaceable></varname>
variables</title>
<tgroup cols="2">
<thead>
<row>
<entry>Variable</entry>
<entry>Means</entry>
</row>
</thead>
<tbody>
<row>
<entry><varname>USE_BZIP2</varname></entry>
<entry>The port's tarballs are compressed with
<command>bzip2</command>.</entry>
</row>
<row>
<entry><varname>USE_ZIP</varname></entry>
<entry>The port's tarballs are compressed with
<command>zip</command>.</entry>
</row>
<row>
<entry><varname>USE_BISON</varname></entry>
<entry>The port uses <command>bison</command> for
building.</entry>
</row>
<row>
<entry><varname>USE_CDRTOOLS</varname></entry>
<entry>該 port 需要 <application>cdrecord</application>
無論是 <package>sysutils/cdrtools</package><package>sysutils/cdrtools-cjk</package> 哪一種的
<application>cdrecord</application> 皆可,視使用者偏好而定
</entry>
</row>
<row>
<entry><varname>USE_GCC</varname></entry>
<entry>The port requires a specific version of
<command>gcc</command> to build. The exact version can be
specified with value such as <literal>3.2</literal>.
The minimal required version can be specified as
<literal>3.2+</literal>. The <command>gcc</command> from
the base system is used when it satisfies the requested
version, otherwise an appropriate <command>gcc</command> is
compiled from ports and the <varname>CC</varname> and
<varname>CXX</varname> variables are adjusted.</entry>
</row>
</tbody>
</tgroup>
</table>
<para>Variables related to <application>gmake</application> and
the <filename>configure</filename> script are described in
<xref linkend="building"/>, while
<application>autoconf</application>,
<application>automake</application> and
<application>libtool</application> are described in
<xref linkend="using-autotools"/>. <application>Perl</application>
related variables are described in <xref linkend="using-perl"/>.
X11 variables are listed in <xref linkend="using-x11"/>. <xref linkend="using-gnome"/> deals with GNOME and <xref linkend="using-kde"/> with KDE related variables. <xref linkend="using-java"/> documents Java variables, while <xref linkend="using-php"/> contains information on
<application>Apache</application>, <application>PHP</application>
and PEAR modules. <application>Python</application> is discussed
in <xref linkend="using-python"/>, while
<application>Ruby</application> in <xref linkend="using-ruby"/>.
<xref linkend="using-sdl"/> provides variables used for
<application>SDL</application> applications and finally,
<xref linkend="using-xfce"/> contains information on
<application>Xfce</application>.</para>
</sect2>
<sect2>
<title>Minimal version of a dependency</title>
<para>A minimal version of a dependency can be specified in any
<varname>*_DEPENDS</varname> variable except
<varname>LIB_DEPENDS</varname> using the following
syntax:</para>
<programlisting>p5-Spiffy&gt;=0.26:${PORTSDIR}/devel/p5-Spiffy</programlisting>
<para>The first field contains a dependent package name,
which must match the entry in the package database,
a comparison sign, and a package version. The dependency
is satisfied if p5-Spiffy-0.26 or newer is installed on
the machine.</para>
</sect2>
<sect2>
<title>Notes on dependencies</title>
<para>As mentioned above, the default target to call when a
dependency is required is <buildtarget>DEPENDS_TARGET</buildtarget>.
It defaults to <literal>install</literal>. This is a user
variable; it is never defined in a port's
<filename>Makefile</filename>. If your port needs a special way
to handle a dependency, use the <literal>:target</literal> part of
the <varname>*_DEPENDS</varname> variables instead of redefining
<varname>DEPENDS_TARGET</varname>.</para>
<para>When you type <command>make clean</command>, its dependencies
are automatically cleaned too. If you do not wish this to happen,
define the variable <varname>NOCLEANDEPENDS</varname> in your
environment. This may be particularly desirable if the port
has something that takes a long time to rebuild in its
dependency list, such as KDE, GNOME or Mozilla.</para>
<para>To depend on another port unconditionally, use the
variable <varname>${NONEXISTENT}</varname> as the first field
of <varname>BUILD_DEPENDS</varname> or
<varname>RUN_DEPENDS</varname>. Use this only when you need to
get the source of the other port. You can often save
compilation time by specifying the target too. For
instance
<programlisting>BUILD_DEPENDS= ${NONEXISTENT}:${PORTSDIR}/graphics/jpeg:extract</programlisting>
will always descend to the <literal>jpeg</literal> port and extract it.</para>
</sect2>
<sect2>
<title>Circular dependencies are fatal</title>
<important>
<para>Do not introduce any circular dependencies into the
ports tree!</para>
</important>
<para>The ports building technology does not tolerate
circular dependencies. If you introduce one, you will have
someone, somewhere in the world, whose FreeBSD installation will
break almost immediately, with many others quickly to follow.
These can really be hard to detect; if in doubt, before
you make that change, make sure you have done the following:
<command>cd /usr/ports; make index</command>. That process
can be quite slow on older machines, but you may be able to
save a large number of people&mdash;including yourself&mdash;
a lot of grief in the process.</para>
</sect2>
</sect1>
<sect1 xml:id="makefile-masterdir">
<title><varname>MASTERDIR</varname></title>
<para>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
<filename>Makefile</filename> in all but one of the directories if you
use variables cleverly. In the sole <filename>Makefile</filename>,
you can use <varname>MASTERDIR</varname> to specify the directory
where the rest of the files are. Also, use a variable as part of
<link linkend="porting-pkgname"><varname>PKGNAMESUFFIX</varname></link> so
the packages will have different names.</para>
<para>This will be best demonstrated by an example. This is part of
<filename>japanese/xdvi300/Makefile</filename>;</para>
<programlisting>PORTNAME= xdvi
PORTVERSION= 17
PKGNAMEPREFIX= ja-
PKGNAMESUFFIX= ${RESOLUTION}
:
# default
RESOLUTION?= 300
.if ${RESOLUTION} != 118 &amp;&amp; ${RESOLUTION} != 240 &amp;&amp; \
${RESOLUTION} != 300 &amp;&amp; ${RESOLUTION} != 400
@${ECHO_MSG} "Error: invalid value for RESOLUTION: \"${RESOLUTION}\""
@${ECHO_MSG} "Possible values are: 118, 240, 300 (default) and 400."
@${FALSE}
.endif</programlisting>
<para><package>japanese/xdvi300</package> also has all the regular
patches, package files, etc. If you type <command>make</command>
there, it will take the default value for the resolution (300) and
build the port normally.</para>
<para>As for other resolutions, this is the <emphasis>entire</emphasis>
<filename>xdvi118/Makefile</filename>:</para>
<programlisting>RESOLUTION= 118
MASTERDIR= ${.CURDIR}/../xdvi300
.include "${MASTERDIR}/Makefile"</programlisting>
<para>(<filename>xdvi240/Makefile</filename> and
<filename>xdvi400/Makefile</filename> are similar). The
<varname>MASTERDIR</varname> definition tells
<filename>bsd.port.mk</filename> that the regular set of
subdirectories like <varname>FILESDIR</varname> and
<varname>SCRIPTDIR</varname> are to be found under
<filename>xdvi300</filename>. The <literal>RESOLUTION=118</literal>
line will override the <literal>RESOLUTION=300</literal> line in
<filename>xdvi300/Makefile</filename> and the port will be built with
resolution set to 118.</para>
</sect1>
<sect1 xml:id="makefile-manpages">
<title>Manpages</title>
<para>The <varname>MAN[1-9LN]</varname> variables will automatically add
any manpages to <filename>pkg-plist</filename> (this means you must
<emphasis>not</emphasis> list manpages in the
<filename>pkg-plist</filename>&mdash;see <link linkend="plist-sub">generating PLIST</link> for more). It also
makes the install stage automatically compress or uncompress manpages
depending on the setting of <varname>NOMANCOMPRESS</varname> in
<filename>/etc/make.conf</filename>.</para>
<para>If your port tries to install multiple names for manpages using
symlinks or hardlinks, you must use the <varname>MLINKS</varname>
variable to identify these. The link installed by your port will
be destroyed and recreated by <filename>bsd.port.mk</filename>
to make sure it points to the correct file. Any manpages
listed in MLINKS must not be listed in the
<filename>pkg-plist</filename>.</para>
<para>To specify whether the manpages are compressed upon installation,
use the <varname>MANCOMPRESSED</varname> variable. This variable can
take three values, <literal>yes</literal>, <literal>no</literal> and
<literal>maybe</literal>. <literal>yes</literal> means manpages are
already installed compressed, <literal>no</literal> means they are
not, and <literal>maybe</literal> means the software already respects
the value of <varname>NOMANCOMPRESS</varname> so
<filename>bsd.port.mk</filename> does not have to do anything
special.</para>
<para><varname>MANCOMPRESSED</varname> is automatically set to
<literal>yes</literal> if <varname>USE_IMAKE</varname> is set and
<varname>NO_INSTALL_MANPAGES</varname> is not set, and to
<literal>no</literal> otherwise. You do not have to explicitly define
it unless the default is not suitable for your port.</para>
<para>If your port anchors its man tree somewhere other than
<varname>MANPREFIX</varname>, you can use the
<varname>MANPREFIX</varname> to set it. Also, if only manpages in
certain sections go in a non-standard place, such as some <literal>perl</literal> modules
ports, you can set individual man paths using
<varname>MAN<replaceable>sect</replaceable>PREFIX</varname> (where
<replaceable>sect</replaceable> is one of <literal>1-9</literal>,
<literal>L</literal> or <literal>N</literal>).</para>
<para>If your manpages go to language-specific subdirectories, set the
name of the languages to <varname>MANLANG</varname>. The value of
this variable defaults to <literal>""</literal> (i.e., English
only).</para>
<para>Here is an example that puts it all together.</para>
<programlisting>MAN1= foo.1
MAN3= bar.3
MAN4= baz.4
MLINKS= foo.1 alt-name.8
MANLANG= "" ja
MAN3PREFIX= ${PREFIX}/share/foobar
MANCOMPRESSED= yes</programlisting>
<para>This states that six files are installed by this port;</para>
<programlisting>${MANPREFIX}/man/man1/foo.1.gz
${MANPREFIX}/man/ja/man1/foo.1.gz
${PREFIX}/share/foobar/man/man3/bar.3.gz
${PREFIX}/share/foobar/man/ja/man3/bar.3.gz
${MANPREFIX}/man/man4/baz.4.gz
${MANPREFIX}/man/ja/man4/baz.4.gz</programlisting>
<para>Additionally <filename>${MANPREFIX}/man/man8/alt-name.8.gz</filename>
may or may not be installed by your port. Regardless, a
symlink will be made to join the foo(1) manpage and
alt-name(8) manpage.</para>
<para>If only some manpages are translated, you can use several variables
dynamically created from <varname>MANLANG</varname> content:</para>
<programlisting>MANLANG= "" de ja
MAN1= foo.1
MAN1_EN= bar.1
MAN3_DE= baz.3</programlisting>
<para>This translates into this list of files:</para>
<programlisting>${MANPREFIX}/man/man1/foo.1.gz
${MANPREFIX}/man/de/man1/foo.1.gz
${MANPREFIX}/man/ja/man1/foo.1.gz
${MANPREFIX}/man/man1/bar.1.gz
${MANPREFIX}/man/de/man3/baz.3.gz</programlisting>
</sect1>
<sect1 xml:id="makefile-info">
<title>Info files</title>
<para>If your package needs to install GNU info files, they should be
listed in the <varname>INFO</varname> variable (without the trailing
<literal>.info</literal>), one entry per document. These files
are assumed to be installed to
<filename>PREFIX/INFO_PATH</filename>.
You can change <varname>INFO_PATH</varname> if your package uses
a different location. However, this is not recommended. These entries
contain just the path relative to
<filename>PREFIX/INFO_PATH</filename>.
For example, <package>lang/gcc33</package> installs
info files to
<filename>PREFIX/INFO_PATH/gcc33</filename>,
and <varname>INFO</varname> will be something like this:
<programlisting>INFO= gcc33/cpp gcc33/cppinternals gcc33/g77 ...
</programlisting>
Appropriate installation/de-installation code will be automatically
added to the temporary <filename>pkg-plist</filename> before package
registration.</para>
</sect1>
<sect1 xml:id="makefile-options">
<title>Makefile Options</title>
<para>Some large applications can be built in a number of
configurations, adding functionality if one of a number of
libraries or applications is available. Examples include
choice of natural (human) language, GUI versus command-line,
or type of database to support. Since not all users
want those libraries or applications, the ports system
provides hooks that the port author can use to control which
configuration should be built. Supporting these properly will
make users happy, and effectively provide 2 or more ports for the
price of one.</para>
<sect2>
<title>Knobs</title>
<sect3>
<title><varname>WITH_<replaceable>*</replaceable></varname> and
<varname>WITHOUT_<replaceable>*</replaceable></varname></title>
<para>These variables are designed to be set by the system
administrator. There are many that are standardized in
<link xlink:href="http://www.freebsd.org/cgi/cvsweb.cgi/ports/KNOBS?rev=HEAD&amp;content-type=text/x-cvsweb-markup"><filename>ports/KNOBS</filename></link>
file.</para>
<para>When creating a port, do not make knob names specific to a
given application. For example in Avahi port, use
<varname>WITHOUT_MDNS</varname> instead of
<varname>WITHOUT_AVAHI_MDNS</varname>.</para>
<note>
<para>You should not assume that a
<varname>WITH_<replaceable>*</replaceable></varname>
necessarily has a corresponding
<varname>WITHOUT_<replaceable>*</replaceable></varname>
variable and vice versa. In general, the default is
simply assumed.</para>
</note>
<note>
<para>Unless otherwise specified, these variables are only
tested for being set or not set, rather than being set to
some kind of variable such as <literal>YES</literal> or
<literal>NO</literal>.</para>
</note>
<table frame="none">
<title>Common <varname>WITH_<replaceable>*</replaceable></varname>
and <varname>WITHOUT_<replaceable>*</replaceable></varname>
variables</title>
<tgroup cols="2">
<thead>
<row>
<entry>Variable</entry>
<entry>Means</entry>
</row>
</thead>
<tbody>
<row xml:id="knobs-without-nls">
<entry><varname>WITHOUT_NLS</varname></entry>
<entry>If set, says that internationalization is not
needed, which can save compile time. By default,
internationalization is used.</entry>
</row>
<row>
<entry><varname>WITH_OPENSSL_BASE</varname></entry>
<entry>Use the version of OpenSSL in the base system.</entry>
</row>
<row>
<entry><varname>WITH_OPENSSL_PORT</varname></entry>
<entry>Installs the version of OpenSSL from
<package>security/openssl</package>,
even if the base is up to date.</entry>
</row>
<row>
<entry><varname>WITHOUT_X11</varname></entry>
<entry>If the port can be built both with and without
X support, then it should normally be built with
X support. If this variable is defined, then
the version that does not have X support should
be built instead.</entry>
</row>
</tbody>
</tgroup>
</table>
</sect3>
<sect3>
<title>Knob naming</title>
<para>It is recommended that porters use like-named knobs, for the
benefit of end-users and to help keep the number of knob names down.
A list of popular knob names can be found in the
<link xlink:href="http://www.freebsd.org/cgi/cvsweb.cgi/ports/KNOBS?rev=HEAD&amp;content-type=text/x-cvsweb-markup">KNOBS</link>
file.</para>
<para>Knob names should reflect what the knob is and does.
When a port has a lib-prefix in the <varname>PORTNAME</varname>
the lib-prefix should be dropped in knob naming.</para>
</sect3>
</sect2>
<sect2>
<title><varname>OPTIONS</varname></title>
<sect3>
<title>Background</title>
<para>The <varname>OPTIONS</varname> variable gives the user who
installs the port a dialog with the available options and saves
them to <filename>/var/db/ports/portname/options</filename>.
Next time when the port has to be rebuild, the options are reused.
Never again you will have to remember all the twenty
<varname>WITH_<replaceable>*</replaceable></varname> and
<varname>WITHOUT_<replaceable>*</replaceable></varname> options you
used to build this port!</para>
<para>When the user runs <command>make config</command> (or runs
<command>make build</command> for the first time), the framework will
check for
<filename>/var/db/ports/portname/options</filename>.
If that file does not exist, it will use the values of
<varname>OPTIONS</varname> to create a dialogbox where the options
can be enabled or disabled. Then the
<filename>options</filename> file is saved and the selected
variables will be used when building the port.</para>
<para>If a new version of the port adds new
<varname>OPTIONS</varname>, the dialog will be presented to the
user, with the saved values of old <varname>OPTIONS</varname>
prefilled.</para>
<para>Use <command>make showconfig</command> to see the saved
configuration. Use <command>make rmconfig</command> to remove the
saved configuration.</para>
</sect3>
<sect3>
<title>Syntax</title>
<para>The syntax for the <varname>OPTIONS</varname> variable is:
<programlisting>OPTIONS= OPTION "descriptive text" default ...
</programlisting>
The value for default is either <literal>ON</literal> or
<literal>OFF</literal>. Multiple repetitions of these three fields
are allowed.</para>
<para><varname>OPTIONS</varname> definition must appear before
the inclusion of <filename>bsd.port.pre.mk</filename>.
The <varname>WITH_*</varname> and <varname>WITHOUT_*</varname>
variables can only be tested after the inclusion of
<filename>bsd.port.pre.mk</filename>.</para>
</sect3>
<sect3>
<title>Example</title>
<example xml:id="ports-options-simple-use">
<title>Simple use of <varname>OPTIONS</varname></title>
<para><programlisting>OPTIONS= FOO "Enable option foo" On \
BAR "Support feature bar" Off
.include &lt;bsd.port.pre.mk&gt;
.if defined(WITHOUT_FOO)
CONFIGURE_ARGS+= --without-foo
.else
CONFIGURE_ARGS+= --with-foo
.endif
.if defined(WITH_BAR)
RUN_DEPENDS+= bar:${PORTSDIR}/bar/bar
.endif
.include &lt;bsd.port.post.mk&gt;</programlisting></para>
</example>
</sect3>
</sect2>
<sect2>
<title>Feature auto-activation</title>
<para>When using a GNU configure script, keep an eye on which optional
features are activated by auto-detection. Explicitly disable
optional features you do not wish to be used by passing respective
<literal>--without-xxx</literal> or <literal>--disable-xxx</literal>
in <varname>CONFIGURE_ARGS</varname>.</para>
<example>
<title>Wrong handling of an option</title>
<programlisting>.if defined(WITH_FOO)
LIB_DEPENDS+= foo.0:${PORTSDIR}/devel/foo
CONFIGURE_ARGS+= --enable-foo
.endif</programlisting>
</example>
<para>In the example above, imagine a library libfoo is installed on
the system. User does not want this application to use libfoo, so he
toggled the option off in the <literal>make config</literal> dialog.
But the application's configure script detects the library present in
the system and includes its support in the resulting executable. Now
when user decides to remove libfoo from the system, the ports system
does not protest (no dependency on libfoo was recorded) but the
application breaks.</para>
<example>
<title>Correct handling of an option</title>
<programlisting>.if defined(WITH_FOO)
LIB_DEPENDS+= foo.0:${PORTSDIR}/devel/foo
CONFIGURE_ARGS+= --enable-foo
.else
CONFIGURE_ARGS+= --disable-foo
.endif</programlisting>
</example>
<para>In the second example, the library libfoo is explicitly disabled.
The configure script does not enable related features in the
application, despite library's presence in the system.</para>
</sect2>
</sect1>
<sect1 xml:id="makefile-wrkdir">
<title>Specifying the working directory</title>
<para>Each port is extracted in to a working directory, which must be
writable. The ports system defaults to having the
<varname>DISTFILES</varname> unpack in to a directory called
<literal>${DISTNAME}</literal>. In other words, if you have
set:</para>
<programlisting>PORTNAME= foo
PORTVERSION= 1.0</programlisting>
<para>then the port's distribution files contain a top-level directory,
<filename>foo-1.0</filename>, and the rest of the files are located
under that directory.</para>
<para>There are a number of variables you can override if that is not the
case.</para>
<sect2>
<title><varname>WRKSRC</varname></title>
<para>The variable lists the name of the directory that is created when
the application's distfiles are extracted. If our previous example
extracted into a directory called <filename>foo</filename> (and not
<filename>foo-1.0</filename>) you would write:</para>
<programlisting>WRKSRC= ${WRKDIR}/foo</programlisting>
<para>or possibly</para>
<programlisting>WRKSRC= ${WRKDIR}/${PORTNAME}</programlisting>
</sect2>
<sect2>
<title><varname>NO_WRKSUBDIR</varname></title>
<para>If the port does not extract in to a subdirectory at all then
you should set <varname>NO_WRKSUBDIR</varname> to indicate
that.</para>
<programlisting>NO_WRKSUBDIR= yes</programlisting>
</sect2>
</sect1>
<sect1 xml:id="conflicts">
<title><varname>CONFLICTS</varname></title>
<para>If your package cannot coexist with other packages
(because of file conflicts, runtime incompatibility, etc.),
list the other package names in the <varname>CONFLICTS</varname>
variable. You can use shell globs like <literal>*</literal> and
<literal>?</literal> here. Packages names should be
enumerated the same way they appear in
<filename>/var/db/pkg</filename>. Please make sure that
<varname>CONFLICTS</varname> does not match this port's
package itself, or else forcing its installation with
<varname>FORCE_PKG_REGISTER</varname> will no longer work.
</para>
<note>
<para><varname>CONFLICTS</varname> automatically sets
<varname>IGNORE</varname>, which is more fully documented
in <xref linkend="dads-noinstall"/>.</para>
</note>
<para>When removing one of several conflicting ports, it is advisable to
retain the <varname>CONFLICTS</varname> entries in those other ports
for a few months to cater for users who only update once in a
while.</para>
</sect1>
<sect1 xml:id="install">
<title>Installing files</title>
<sect2 xml:id="install-macros">
<title>INSTALL_* macros</title>
<para>Do use the macros provided in <filename>bsd.port.mk</filename>
to ensure correct modes and ownership of files in your own
<buildtarget>*-install</buildtarget> targets.</para>
<itemizedlist>
<listitem>
<para><varname>INSTALL_PROGRAM</varname> is a command to install
binary executables.</para>
</listitem>
<listitem>
<para><varname>INSTALL_SCRIPT</varname> is a command to install
executable scripts.</para>
</listitem>
<listitem>
<para><varname>INSTALL_KLD</varname> is a command to install
kernel loadable modules. Some architectures don't like it when
the modules are stripped, therefor use this command instead
of <varname>INSTALL_PROGRAM</varname>.</para>
</listitem>
<listitem>
<para><varname>INSTALL_DATA</varname> is a command to install
sharable data.</para>
</listitem>
<listitem>
<para><varname>INSTALL_MAN</varname> is a command to install
manpages and other documentation (it does not compress
anything).</para>
</listitem>
</itemizedlist>
<para>These are basically the <command>install</command> command with
all the appropriate flags.</para>
</sect2>
<sect2 xml:id="install-strip">
<title>Stripping Binaries</title>
<para>Do not strip binaries manually unless you have to. All binaries
should be stripped, but the <buildtarget>INSTALL_PROGRAM</buildtarget>
macro will install and strip a binary at the same time (see the next
section).</para>
<para>If you need to strip a file, but do not wish to use the
<varname>INSTALL_PROGRAM</varname> macro,
<varname>${STRIP_CMD}</varname> will strip your program. This is
typically done within the <literal>post-install</literal>
target. For example:</para>
<programlisting>post-install:
${STRIP_CMD} ${PREFIX}/bin/xdl</programlisting>
<para>Use the &man.file.1; command on the installed executable to
check whether the binary is stripped or not. If it does not say
<literal>not stripped</literal>, it is stripped. Additionally,
&man.strip.1; will not strip a previously stripped program; it
will instead exit cleanly.</para>
</sect2>
<sect2 xml:id="install-copytree">
<title>Installing a whole tree of files</title>
<para>Sometimes, there is a need to install a big number of files,
preserving their hierarchical organization, ie. copying over a whole
directory tree from <varname>WRKSRC</varname> to a target directory
under <varname>PREFIX</varname>.</para>
<para>Two macros exists for this situation. The advantage of using
these macros instead of <command>cp</command> is that they guarantee
proper file ownership and permissions on target files. First macro,
<varname>COPYTREE_BIN</varname>, will set all the installed files to
be executable, thus being suitable for installing into
<filename>PREFIX/bin</filename>. The second
macro, <varname>COPYTREE_SHARE</varname>, does not set executable
permissions on files, and is therefore suitable for installing files
under <filename>PREFIX/share</filename>
target.</para>
<programlisting>post-install:
${MKDIR} ${EXAMPLESDIR}
(cd ${WRKSRC}/examples/ &amp;&amp; ${COPYTREE_SHARE} \* ${EXAMPLESDIR})</programlisting>
<para>This example will install the contents of
<filename>examples</filename> directory in the vendor distfile to the
proper examples location of your port.</para>
<programlisting>post-install:
${MKDIR} ${DATADIR}/summer
(cd ${WRKSRC}/temperatures/ &amp;&amp; ${COPYTREE_SHARE} "June July August" ${DATADIR}/summer/)</programlisting>
<para>And this example will install the data of summer months to the
<filename>summer</filename> subdirectory of a
<filename>DATADIR</filename>.</para>
<para>Additional <command>find</command> arguments can be passed via
the third argument to the <varname>COPYTREE_*</varname> macros.
For example, to install all files from the first example except
Makefiles, one can use the following command.</para>
<programlisting>post-install:
${MKDIR} ${EXAMPLESDIR}
(cd ${WRKSRC}/examples/ &amp;&amp; \
${COPYTREE_SHARE} \* ${EXAMPLESDIR} "! -name Makefile")</programlisting>
<para>Note that these macros does not add the installed files to
<filename>pkg-plist</filename>. You still need to list them.</para>
</sect2>
<sect2 xml:id="install-documentation">
<title>Install additional documentation</title>
<para>If your software has some documentation other than the standard
man and info pages that you think is useful for the user, install it
under <filename>PREFIX/share/doc</filename>.
This can be done, like the previous item, in the
<buildtarget>post-install</buildtarget> target.</para>
<para>Create a new directory for your port. The directory name should
reflect what the port is. This usually means
<varname>PORTNAME</varname>. However, if you
think the user might want different versions of the port to be
installed at the same time, you can use the whole
<varname>PKGNAME</varname>.</para>
<para>Make the installation dependent on the variable
<varname>NOPORTDOCS</varname> so that users can disable it in
<filename>/etc/make.conf</filename>, like this:</para>
<programlisting>post-install:
.if !defined(NOPORTDOCS)
${MKDIR} ${DOCSDIR}
${INSTALL_MAN} ${WRKSRC}/docs/xvdocs.ps ${DOCSDIR}
.endif</programlisting>
<para>Here are some handy variables and how they are expanded
by default when used
in the <filename>Makefile</filename>:</para>
<itemizedlist>
<listitem>
<para><varname>DATADIR</varname> gets expanded to
<filename>PREFIX/share/PORTNAME</filename>.</para>
</listitem>
<listitem>
<para><varname>DATADIR_REL</varname> gets expanded to
<filename>share/PORTNAME</filename>.</para>
</listitem>
<listitem>
<para><varname>DOCSDIR</varname> gets expanded to
<filename>PREFIX/share/doc/PORTNAME</filename>.</para>
</listitem>
<listitem>
<para><varname>DOCSDIR_REL</varname> gets expanded to
<filename>share/doc/PORTNAME</filename>.</para>
</listitem>
<listitem>
<para><varname>EXAMPLESDIR</varname> gets expanded to
<filename>PREFIX/share/examples/PORTNAME</filename>.</para>
</listitem>
<listitem>
<para><varname>EXAMPLESDIR_REL</varname> gets expanded to
<filename>share/examples/PORTNAME</filename>.</para>
</listitem>
</itemizedlist>
<note>
<para><varname>NOPORTDOCS</varname> only controls additional
documentation installed in <varname>DOCSDIR</varname>. It does not
apply to standard man pages and info pages. Things installed in
<varname>DATADIR</varname> and <varname>EXAMPLESDIR</varname>
are controlled by <varname>NOPORTDATA</varname> and
<varname>NOPORTEXAMPLES</varname>, respectively.</para>
</note>
<para>These variables are exported to <varname>PLIST_SUB</varname>.
Their values will appear there as pathnames relative to
<filename>PREFIX</filename> if possible.
That is, <filename>share/doc/PORTNAME</filename>
will be substituted for <literal>%%DOCSDIR%%</literal>
in the packing list by default, and so on.
(See more on <filename>pkg-plist</filename> substitution
<link linkend="plist-sub">here</link>.)</para>
<para>All conditionally installed documentation files and directories should
be included in <filename>pkg-plist</filename> with the
<literal>%%PORTDOCS%%</literal> prefix, for example:</para>
<programlisting>%%PORTDOCS%%%%DOCSDIR%%/AUTHORS
%%PORTDOCS%%%%DOCSDIR%%/CONTACT
%%PORTDOCS%%@dirrm %%DOCSDIR%%</programlisting>
<para>As an alternative to enumerating the documentation files
in <filename>pkg-plist</filename>, a port can set the variable
<varname>PORTDOCS</varname> to a list of file names and shell
glob patterns to add to the final packing list.
The names will be relative to <varname>DOCSDIR</varname>.
Therefore, a port that utilizes <varname>PORTDOCS</varname> and
uses a non-default location for its documentation should set
<varname>DOCSDIR</varname> accordingly.
If a directory is listed in <varname>PORTDOCS</varname>
or matched by a glob pattern from this variable,
the entire subtree of contained files and directories will be
registered in the final packing list. If <varname>NOPORTDOCS</varname>
is defined then files and directories listed in
<varname>PORTDOCS</varname> would not be installed and neither
would be added to port packing list.
Installing the documentation at <varname>PORTDOCS</varname>
as shown above remains up to the port itself.
A typical example of utilizing <varname>PORTDOCS</varname>
looks as follows:</para>
<programlisting>PORTDOCS= README.* ChangeLog docs/*</programlisting>
<note>
<para>The equivalents of <varname>PORTDOCS</varname> for files
installed under <varname>DATADIR</varname> and
<varname>EXAMPLESDIR</varname> are <varname>PORTDATA</varname>
and <varname>PORTEXAMPLES</varname>, respectively.</para>
<para>You can also use the <filename>pkg-message</filename> file to
display messages upon installation. See <link linkend="porting-message">the section on using
<filename>pkg-message</filename></link> for details.
The <filename>pkg-message</filename> file does not need to be
added to <filename>pkg-plist</filename>.</para>
</note>
</sect2>
<sect2 xml:id="install-subdirs">
<title>Subdirectories under PREFIX</title>
<para>Try to let the port put things in the right subdirectories of
<varname>PREFIX</varname>. Some ports lump everything and put it in
the subdirectory with the port's name, which is incorrect. Also,
many ports put everything except binaries, header files and manual
pages in a subdirectory of <filename>lib</filename>, which does
not work well with the BSD paradigm. Many of the files should be
moved to one of the following: <filename>etc</filename>
(setup/configuration files), <filename>libexec</filename>
(executables started internally), <filename>sbin</filename>
(executables for superusers/managers), <filename>info</filename>
(documentation for info browser) or <filename>share</filename>
(architecture independent files). See &man.hier.7; for details;
the rules governing
<filename>/usr</filename> pretty much apply to
<filename>/usr/local</filename> too. The exception are ports
dealing with USENET <quote>news</quote>. They may use
<filename>PREFIX/news</filename> as a destination
for their files.</para>
</sect2>
</sect1>
</chapter>
<chapter xml:id="special">
<title>Special considerations</title>
<para>There are some more things you have to take into account when you
create a port. This section explains the most common of those.</para>
<sect1 xml:id="porting-shlibs">
<title>Shared Libraries</title>
<para>If your port installs one or more shared libraries, define a
<varname>USE_LDCONFIG</varname> make variable, which will instruct
a <filename>bsd.port.mk</filename> to run
<literal>&dollar;{LDCONFIG} -m</literal> on the directory where the
new library is installed (usually
<filename>PREFIX/lib</filename>) during
<buildtarget>post-install</buildtarget> target to register it into the
shared library cache. This variable, when defined, will also
facilitate addition of an appropriate
<literal>@exec /sbin/ldconfig -m</literal> and
<literal>@unexec /sbin/ldconfig -R</literal> pair into your
<filename>pkg-plist</filename> file, so that a user who installed
the package can start using the shared library immediately and
de-installation will not cause the system to still believe the
library is there.</para>
<programlisting>USE_LDCONFIG= yes</programlisting>
<para>If you need, you can override the default directory
by setting the <varname>USE_LDCONFIG</varname>
value to a list of directories into which
shared libraries are to be installed. For example if your port
installs shared libraries into
<filename>PREFIX/lib/foo</filename> and
<filename>PREFIX/lib/bar</filename> directories
you could use the following in your
<filename>Makefile</filename>:</para>
<programlisting>USE_LDCONFIG= ${PREFIX}/lib/foo ${PREFIX}/lib/bar</programlisting>
<para>Please
double-check, often this is not necessary at all or can be avoided
through <literal>-rpath</literal> or setting <envar>LD_RUN_PATH</envar>
during linking (see <package>lang/moscow_ml</package>
for an example), or through a shell-wrapper which sets
<varname>LD_LIBRARY_PATH</varname> before invoking the binary, like
<package>www/mozilla</package> does.</para>
<para>When installing 32-bit libraries on 64-bit system, use
<varname>USE_LDCONFIG32</varname> instead.</para>
<para>Try to keep shared library version numbers in the
<filename>libfoo.so.0</filename> format. Our runtime linker only
cares for the major (first) number.</para>
<para>When the major library version number increments in the update
to the new port version, all other ports that link to the affected
library should have their <varname>PORTREVISION</varname> incremented,
to force recompilation with the new library version.</para>
</sect1>
<sect1 xml:id="porting-restrictions">
<title>Ports with distribution restrictions</title>
<para>Licenses vary, and some of them place restrictions on how the
application can be packaged, whether it can be sold for profit, and so
on.</para>
<important>
<para>It is your responsibility as a porter to read the licensing
terms of the software and make sure that the FreeBSD project will
not be held accountable for violating them by redistributing the
source or compiled binaries either via FTP/HTTP or CD-ROM. If in doubt,
please contact the &a.ports;.</para>
</important>
<para>In situations like this, the variables described in the following
sections can be set.</para>
<sect2>
<title><varname>NO_PACKAGE</varname></title>
<para>This variable indicates that we may not generate a binary
package of the application. For instance, the license may
disallow binary redistribution, or it may prohibit distribution
of packages created from patched sources.</para>
<para>However, the port's <varname>DISTFILES</varname> may be
freely mirrored on FTP/HTTP. They may also be distributed on
a CD-ROM (or similar media) unless <varname>NO_CDROM</varname>
is set as well.</para>
<para><varname>NO_PACKAGE</varname> should also be used if the binary
package is not generally useful, and the application should always
be compiled from the source code. For example, if the application
has configuration information that is site specific hard coded in to
it at compile time, set <varname>NO_PACKAGE</varname>.</para>
<para><varname>NO_PACKAGE</varname> should be set to a string
describing the reason why the package should not be
generated.</para>
</sect2>
<sect2>
<title><varname>NO_CDROM</varname></title>
<para>This variable alone indicates that, although we are allowed
to generate binary packages, we may put neither those packages
nor the port's <varname>DISTFILES</varname> onto a CD-ROM (or
similar media) for resale. However, the binary packages and
the port's <varname>DISTFILES</varname> will still be available
via FTP/HTTP.</para>
<para>If this variable is set along with
<varname>NO_PACKAGE</varname>, then only the port's
<varname>DISTFILES</varname> will be available, and only via
FTP/HTTP.</para>
<para><varname>NO_CDROM</varname> should be set to a string
describing the reason why the port cannot be redistributed
on CD-ROM. For instance, this should be used if the port's license
is for <quote>non-commercial</quote> use only.</para>
</sect2>
<sect2>
<title><varname>NOFETCHFILES</varname></title>
<para>Files defined in the <varname>NOFETCHFILES</varname>
variable are not fetchable from any of the
<varname>MASTER_SITES</varname>. An example of such a
file is when the file is supplied on CD-ROM by the
vendor.</para>
<para>Tools which check for the availability of these files
on the <varname>MASTER_SITES</varname> should ignore these
files and not report about them.</para>
</sect2>
<sect2>
<title><varname>RESTRICTED</varname></title>
<para>Set this variable alone if the application's license permits
neither mirroring the application's <varname>DISTFILES</varname>
nor distributing the binary package in any way.</para>
<para><varname>NO_CDROM</varname> or <varname>NO_PACKAGE</varname>
should not be set along with <varname>RESTRICTED</varname>
since the latter variable implies the former ones.</para>
<para><varname>RESTRICTED</varname> should be set to a string
describing the reason why the port cannot be redistributed.
Typically, this indicates that the port contains proprietary
software and that the user will need to manually download the
<varname>DISTFILES</varname>, possibly after registering for the
software or agreeing to accept the terms of an
<acronym>EULA</acronym>.</para>
</sect2>
<sect2>
<title><varname>RESTRICTED_FILES</varname></title>
<para>When <varname>RESTRICTED</varname> or <varname>NO_CDROM</varname>
is set, this variable defaults to <literal>${DISTFILES}
${PATCHFILES}</literal>, otherwise it is empty. If only some of the
distribution files are restricted, then set this variable to list
them.</para>
<para>Note that the port committer should add an entry to
<filename>/usr/ports/LEGAL</filename> for every listed distribution
file, describing exactly what the restriction entails.</para>
</sect2>
</sect1>
<sect1 xml:id="building">
<title>Building mechanisms</title>
<sect2 xml:id="using-make">
<title><command>make</command>, <command>gmake</command>, and
<command>imake</command></title>
<para>If your port uses <application>GNU make</application>, set
<literal>USE_GMAKE=yes</literal>.</para>
<table frame="none">
<title>Variables for ports related to gmake</title>
<tgroup cols="2">
<thead>
<row>
<entry>Variable</entry>
<entry>Means</entry>
</row>
</thead>
<tbody>
<row>
<entry><varname>USE_GMAKE</varname></entry>
<entry>The port requires <command>gmake</command> to
build.</entry>
</row>
<row>
<entry><varname>GMAKE</varname></entry>
<entry>The full path for <command>gmake</command> if it is not
in the <envar>PATH</envar>.</entry>
</row>
</tbody>
</tgroup>
</table>
<para>If your port is an X application that creates
<filename>Makefile</filename> files from
<filename>Imakefile</filename> files using
<application>imake</application>, then set
<literal>USE_IMAKE=yes</literal>. This will cause the
configure stage to automatically do an <command>xmkmf -a</command>.
If the <option>-a</option> flag is a problem for your port, set
<literal>XMKMF=xmkmf</literal>. If the port uses
<application>imake</application> but does not understand the
<buildtarget>install.man</buildtarget> target,
<literal>NO_INSTALL_MANPAGES=yes</literal> should be set.</para>
<para>If your port's source <filename>Makefile</filename> has
something else than <buildtarget>all</buildtarget> as the main build
target, set <varname>ALL_TARGET</varname> accordingly. Same goes
for <buildtarget>install</buildtarget> and
<varname>INSTALL_TARGET</varname>.</para>
</sect2>
<sect2 xml:id="using-configure">
<title><command>configure</command> script</title>
<para>If your port uses the <command>configure</command> script to
generate <filename>Makefile</filename> files from
<filename>Makefile.in</filename> files, set
<literal>GNU_CONFIGURE=yes</literal>. If you want to give extra
arguments to the <command>configure</command> script (the default
argument is <literal>--prefix=&dollar;{PREFIX}
--infodir=&dollar;{PREFIX}/&dollar;{INFO_PATH}
--mandir=&dollar;{MANPREFIX}/man
--build=&dollar;{CONFIGURE_TARGET}</literal>), set those
extra arguments in <varname>CONFIGURE_ARGS</varname>. Extra
environment variables can be passed using
<varname>CONFIGURE_ENV</varname> variable.</para>
<table frame="none">
<title>Variables for ports that use configure</title>
<tgroup cols="2">
<thead>
<row>
<entry>Variable</entry>
<entry>Means</entry>
</row>
</thead>
<tbody>
<row>
<entry><varname>GNU_CONFIGURE</varname></entry>
<entry>The port uses <command>configure</command> script to
prepare build.</entry>
</row>
<row>
<entry><varname>HAS_CONFIGURE</varname></entry>
<entry>Same as <varname>GNU_CONFIGURE</varname>, except
default configure target is not added to
<varname>CONFIGURE_ARGS</varname>.</entry>
</row>
<row>
<entry><varname>CONFIGURE_ARGS</varname></entry>
<entry>Additional arguments passed to
<command>configure</command> script.</entry>
</row>
<row>
<entry><varname>CONFIGURE_ENV</varname></entry>
<entry>Additional environment variables to be set
for <command>configure</command> script run.</entry>
</row>
<row>
<entry><varname>CONFIGURE_TARGET</varname></entry>
<entry>Override default configure target. Default value is
<literal>&dollar;{MACHINE_ARCH}-portbld-freebsd&dollar;{OSREL}</literal>.</entry>
</row>
</tbody>
</tgroup>
</table>
</sect2>
<sect2 xml:id="using-scons">
<title>Using <command>scons</command></title>
<para>If your port uses <application>SCons</application>, define
<literal>USE_SCONS=yes</literal>.</para>
<table frame="none">
<title>Variables for ports that use <command>scons</command></title>
<tgroup cols="2">
<thead>
<row>
<entry>Variable</entry>
<entry>Means</entry>
</row>
</thead>
<tbody>
<row>
<entry><varname>SCONS_ARGS</varname></entry>
<entry>Port specific SCons flags passed to the SCons
environment.</entry>
</row>
<row>
<entry><varname>SCONS_BUILDENV</varname></entry>
<entry>Variables to be set in system environment.</entry>
</row>
<row>
<entry><varname>SCONS_ENV</varname></entry>
<entry>Variables to be set in SCons environment.</entry>
</row>
<row>
<entry><varname>SCONS_TARGET</varname></entry>
<entry>Last argument passed to SCons, similar to
<varname>MAKE_TARGET</varname>.</entry>
</row>
</tbody>
</tgroup>
</table>
</sect2>
</sect1>
<sect1 xml:id="using-autotools">
<title>Using GNU autotools</title>
<sect2 xml:id="using-autotools-introduction">
<title>Introduction</title>
<para>The various GNU autotools provide an abstraction mechanism for
building a piece of software over a wide variety of operating
systems and machine architectures. Within the Ports Collection,
an individual port can make use of these tools via a simple
construct:</para>
<programlisting>USE_AUTOTOOLS= <replaceable>tool</replaceable>:<replaceable>version</replaceable>[:<replaceable>operation</replaceable>] ...</programlisting>
<para>At the time of writing, <replaceable>tool</replaceable> can be
one of <literal>libtool</literal>, <literal>libltdl</literal>,
<literal>autoconf</literal>, <literal>autoheader</literal>,
<literal>automake</literal> or <literal>aclocal</literal>.</para>
<para><replaceable>version</replaceable> specifies the particular
tool revision to be used (see
<literal>devel/{automake,autoconf,libtool}[0-9]+</literal> for
valid versions).</para>
<para><replaceable>operation</replaceable> is an optional extension
to modify how the tool is used.</para>
<para>Multiple tools can be specified at once, either by including
them all on a single line, or using the <literal>+=</literal>
Makefile construct.</para>
<para>Finally, there is the special tool, called
<literal>autotools</literal>, which is a convenience function
to bring in all available versions of the autotools to allow
for cross-development work. This can also be accomplished
by installing the <literal>devel/autotools</literal> port.</para>
</sect2>
<sect2 xml:id="using-libtool">
<title><command>libtool</command></title>
<para>Shared libraries using the GNU building framework usually use
<command>libtool</command> to adjust the compilation and
installation of shared libraries to match the specifics of the
underlying operating system. The usual practice is to use copy of
<command>libtool</command> bundled with the application. In case
you need to use external <command>libtool</command>, you can use
the version provided by The Ports Collection:</para>
<programlisting>USE_AUTOTOOLS= libtool:<replaceable>version</replaceable>[:env]</programlisting>
<para>With no additional operations,
<literal>libtool:version</literal> tells
the building framework to patch the configure script with the
system-installed copy of <command>libtool</command>.
The <varname>GNU_CONFIGURE</varname> is implied.
Further, a number of make and shell
variables will be assigned for onward use by the port. See
<filename>bsd.autotools.mk</filename> for details.</para>
<para>With the <literal>:env</literal> operation, only the
environment will be set up.</para>
<para>Finally, <varname>LIBTOOLFLAGS</varname> and
<varname>LIBTOOLFILES</varname> can be optionally set to override
the most likely arguments to, and files patched by,
<command>libtool</command>. Most ports are unlikely to need this.
See <filename>bsd.autotools.mk</filename> for further
details.</para>
</sect2>
<sect2 xml:id="using-libltdl">
<title><command>libltdl</command></title>
<para>Some ports make use of the <command>libltdl</command> library
package, which is part of the <command>libtool</command> suite.
Use of this library does not automatically necessitate the use of
<command>libtool</command> itself, so a separate construct is
provided.</para>
<programlisting>USE_AUTOTOOLS= libltdl:<replaceable>version</replaceable></programlisting>
<para>Currently, all this does is to bring in a
<varname>LIB_DEPENDS</varname> on the appropriate
<command>libltdl</command> port, and is provided as a convenience
function to help eliminate any dependencies on the autotools ports
outside of the <varname>USE_AUTOTOOLS</varname> framework. There
are no optional operations for this tool.</para>
</sect2>
<sect2 xml:id="using-autoconf">
<title><command>autoconf</command> and
<command>autoheader</command></title>
<para>Some ports do not contain a configure script, but do contain an
autoconf template in the <filename>configure.ac</filename> file.
You can use the following assignments to let
<command>autoconf</command> create the configure script, and also
have <command>autoheader</command> create template headers for use
by the configure script.</para>
<programlisting>USE_AUTOTOOLS= autoconf:<replaceable>version</replaceable>[:env]</programlisting>
<para>and</para>
<programlisting>USE_AUTOTOOLS= autoheader:<replaceable>version</replaceable></programlisting>
<para>which also implies the use of
<literal>autoconf:version</literal>.</para>
<para>Similarly to <command>libtool</command>, the inclusion of the
optional <literal>:env</literal> operation simply sets up the
environment for further use. Without it, patching and
reconfiguration of the port is carried out.</para>
<para>The additional optional variables
<varname>AUTOCONF_ARGS</varname> and
<varname>AUTOHEADER_ARGS</varname> can be overridden by the port
<filename>Makefile</filename> if specifically requested. As with
the <command>libtool</command> equivalents, most ports are unlikely
to need this.</para>
</sect2>
<sect2 xml:id="using-automake">
<title><command>automake</command> and
<command>aclocal</command></title>
<para>Some packages only contain <filename>Makefile.am</filename>
files. These have to be converted into
<filename>Makefile.in</filename> files using
<command>automake</command>, and the further processed by
<command>configure</command> to generate an actual
<filename>Makefile</filename>.</para>
<para>Similarly, packages occasionally do not ship with included
<filename>aclocal.m4</filename> files, again required to build the
software. This can be achieved with <command>aclocal</command>,
which scans <filename>configure.ac</filename> or
<filename>configure.in</filename>.</para>
<para><command>aclocal</command> has a similar relationship to
<command>automake</command> as <command>autoheader</command> does
to <command>autoconf</command>, described in the previous section.
<command>aclocal</command> implies the use of
<command>automake</command>, thus we have:</para>
<programlisting>USE_AUTOTOOLS= automake:<replaceable>version</replaceable>[:<replaceable>env</replaceable>]</programlisting>
<para>and</para>
<programlisting>USE_AUTOTOOLS= aclocal:<replaceable>version</replaceable></programlisting>
<para>which also implies the use of
<literal>automake:version</literal>.</para>
<para>Similarly to <command>libtool</command> and
<command>autoconf</command>, the inclusion of the optional
<literal>:env</literal> operation simply sets up the environment
for further use. Without it, reconfiguration of the port is
carried out.</para>
<para>As with
<command>autoconf</command> and <command>autoheader</command>, both
<command>automake</command> and <command>aclocal</command> have
optional argument variables, <varname>AUTOMAKE_ARGS</varname> and
<varname>ACLOCAL_ARGS</varname> respectively, which may be
overriden by the port <filename>Makefile</filename> if
required.</para>
</sect2>
</sect1>
<sect1 xml:id="using-gettext">
<title>Using GNU <literal>gettext</literal></title>
<sect2>
<title>Basic usage</title>
<para>If your port requires <literal>gettext</literal>,
just set <varname>USE_GETTEXT</varname> to <literal>yes</literal>,
and your port will grow the dependency on <package>devel/gettext</package>. The value of
<varname>USE_GETTEXT</varname> can also specify the required
version of the <literal>libintl</literal> library, the basic
part of <literal>gettext</literal>, but using this
feature is <emphasis>strongly discouraged</emphasis>:
Your port should work with just the current version of
<package>devel/gettext</package>.</para>
<para>A rather common case is a port using
<literal>gettext</literal> and <command>configure</command>.
Generally, GNU <command>configure</command> should be
able to locate <literal>gettext</literal> automatically.
If it ever fails to, hints at the location of
<literal>gettext</literal> can be passed in
<envar>CPPFLAGS</envar> and <envar>LDFLAGS</envar> as
follows:</para>
<programlisting>USE_GETTEXT= yes
CPPFLAGS+= -I${LOCALBASE}/include
LDFLAGS+= -L${LOCALBASE}/lib
GNU_CONFIGURE= yes
CONFIGURE_ENV= CPPFLAGS="${CPPFLAGS}" \
LDFLAGS="${LDFLAGS}"</programlisting>
<para>Of course, the code can be more compact if there are no
more flags to pass to <command>configure</command>:</para>
<programlisting>USE_GETTEXT= yes
GNU_CONFIGURE= yes
CONFIGURE_ENV= CPPFLAGS="-I${LOCALBASE}/include" \
LDFLAGS="-L${LOCALBASE}/lib"</programlisting>
</sect2>
<sect2>
<title>Optional usage</title>
<para>Some software products allow for disabling NLS,
e.g., through passing <option>--disable-nls</option> to
<command>configure</command>. In that case, your port
should use <literal>gettext</literal> conditionally,
depending on the status of <link linkend="knobs-without-nls"><varname>WITHOUT_NLS</varname></link>.
For ports of low to medium complexity, you can rely on the
following idiom:</para>
<programlisting>GNU_CONFIGURE= yes
.if !defined(WITHOUT_NLS)
USE_GETTEXT= yes
PLIST_SUB+= NLS=""
.else
CONFIGURE_ARGS+= --disable-nls
PLIST_SUB+= NLS="@comment "
.endif</programlisting>
<para>The next item on your to-do list is to arrange so that
the message catalog files are included in the packing list
conditionally. The <filename>Makefile</filename> part of
this task is already provided by the idiom. It is explained
in the section on <link linkend="plist-sub">advanced
<filename>pkg-plist</filename> practices</link>. In a
nutshell, each occurrence of <literal>%%NLS%%</literal> in
<filename>pkg-plist</filename> will be replaced by
<quote><literal>@comment&nbsp;</literal></quote> if NLS is
disabled, or by a null string if NLS is enabled. Consequently,
the lines prefixed by <literal>%%NLS%%</literal> will become
mere comments in the final packing list if NLS is off;
otherwise the prefix will be just left out. All you need
to do now is insert <literal>%%NLS%%</literal> before each
path to a message catalog file in <filename>pkg-plist</filename>.
For example:</para>
<programlisting>%%NLS%%share/locale/fr/LC_MESSAGES/foobar.mo
%%NLS%%share/locale/no/LC_MESSAGES/foobar.mo</programlisting>
<para>In high complexity cases, you may need to use more advanced
techniques than the recipe given here, such as <link linkend="plist-dynamic">dynamic packing list generation</link>.</para>
</sect2>
<sect2>
<title>Handling message catalog directories</title>
<para>There is a point to note about installing message catalog
files. The target directories for them, which reside under
<filename>LOCALBASE/share/locale</filename>,
should rarely be created and removed by your port. The
most popular languages have their respective directories
listed in <filename>/etc/mtree/BSD.local.dist</filename>;
that is, they are a part of the base system. The directories
for many other languages are governed by the <package>devel/gettext</package> port. You may want
to consult its <filename>pkg-plist</filename> and see whether
your port is going to install a message catalog file for a
unique language.</para>
</sect2>
</sect1>
<sect1 xml:id="using-perl">
<title>Using <literal>perl</literal></title>
<para>If <varname>MASTER_SITES</varname> is set to
<varname>MASTER_SITE_PERL_CPAN</varname>, then preferred value of
<varname>MASTER_SITE_SUBDIR</varname> is top-level hierarchy name.
For example, the recommend value for <literal>p5-Module-Name</literal>
is <literal>Module</literal>. The top-level hierarchy can be examined
at <link xlink:href="http://cpan.org/modules/by-module/">cpan.org</link>.
This keeps the port working when the author of the module
changes.</para>
<para>The exception to this rule is when the relevant directory does not
exist or the distfile does not exist in the directory. In such case, using
author's id as <varname>MASTER_SITE_SUBDIR</varname> is allowed.</para>
<para>All of the tunable knobs below accept both <literal>YES</literal>
and a version string, like <literal>5.8.0+</literal>. Using
<literal>YES</literal> means that the port can be used with all
of the supported <application>Perl</application> versions. If a port
only works with specific versions of <application>Perl</application>,
it can be indicated with a version string, specifying a minimal version
(e.g. <literal>5.7.3+</literal>), a maximal version (e.g.
<literal>5.8.0-</literal>) or an exact version (e.g.
<literal>5.8.3</literal>).</para>
<table frame="none">
<title>Variables for ports that use <literal>perl</literal></title>
<tgroup cols="2">
<thead>
<row>
<entry>Variable</entry>
<entry>Means</entry>
</row>
</thead>
<tbody>
<row>
<entry><varname>USE_PERL5</varname></entry>
<entry>Says that the port uses <literal>perl 5</literal> to build and run.</entry>
</row>
<row>
<entry><varname>USE_PERL5_BUILD</varname></entry>
<entry>Says that the port uses <literal>perl 5</literal> to build.</entry>
</row>
<row>
<entry><varname>USE_PERL5_RUN</varname></entry>
<entry>Says that the port uses <literal>perl 5</literal> to run.</entry>
</row>
<row>
<entry><varname>PERL</varname></entry>
<entry>The full path of <literal>perl 5</literal>, either in the
system or installed from a port, but without the version
number. Use this if you need to replace
<quote><literal>#!</literal></quote>lines in scripts.</entry>
</row>
<row>
<entry><varname>PERL_CONFIGURE</varname></entry>
<entry>Configure using Perl's MakeMaker. It implies
<varname>USE_PERL5</varname>.</entry>
</row>
<row>
<entry><varname>PERL_MODBUILD</varname></entry>
<entry>Configure, build and install using Module::Build. It
implies <varname>PERL_CONFIGURE</varname>.</entry>
</row>
</tbody>
</tgroup>
<tgroup cols="2">
<thead>
<row>
<entry>Read only variables</entry>
<entry>Means</entry>
</row>
</thead>
<tbody>
<row>
<entry><varname>PERL_VERSION</varname></entry>
<entry>The full version of <literal>perl</literal> installed (e.g.,
<literal>5.00503</literal>).</entry>
</row>
<row>
<entry><varname>PERL_VER</varname></entry>
<entry>The short version of <literal>perl</literal> installed (e.g.,
<literal>5.005</literal>).</entry>
</row>
<row>
<entry><varname>PERL_LEVEL</varname></entry>
<entry>The installed <literal>perl</literal> version as an integer of the form <literal>MNNNPP</literal>
(e.g., <literal>500503</literal>).</entry>
</row>
<row>
<entry><varname>PERL_ARCH</varname></entry>
<entry>Where <literal>perl</literal> stores architecture dependent libraries.
Defaults to <literal>${ARCH}-freebsd</literal>.</entry>
</row>
<row>
<entry><varname>PERL_PORT</varname></entry>
<entry>Name of the <literal>perl</literal> port that is
installed (e.g., <literal>perl5</literal>).</entry>
</row>
<row>
<entry><varname>SITE_PERL</varname></entry>
<entry>Directory name where site specific
<literal>perl</literal> packages go.
This value is added to PLIST_SUB.</entry>
</row>
</tbody>
</tgroup>
</table>
<note>
<para>Perl 模組的 port由於沒有正式的網站所以
<filename>pkg-descr</filename> 內的 WWW 應該指向至
<systemitem>cpan.org</systemitem>。 比較好的 URL 格式是
<literal>http://search.cpan.org/dist/Module-Name/</literal>
(包括結尾的 / 斜線符號)。</para>
</note>
</sect1>
<sect1 xml:id="using-x11">
<title>Using X11</title>
<sect2 xml:id="x11-variables">
<title>X.Org components</title>
<para>The X11 implementation available in The Ports Collection is X.Org.
If your application depends on X components, set
<varname>USE_XORG</varname> to the list of required components.
Available components, at the time of writing, are:</para>
<para><literal>bigreqsproto compositeproto damageproto dmx dmxproto
evieproto fixesproto fontcacheproto fontenc fontsproto fontutil
glproto ice inputproto kbproto libfs oldx printproto randrproto
recordproto renderproto resourceproto scrnsaverproto sm trapproto
videoproto x11 xau xaw xaw6 xaw7 xaw8 xbitmaps xcmiscproto xcomposite
xcursor xdamage xdmcp xevie xext xextproto xf86bigfontproto
xf86dgaproto xf86driproto xf86miscproto xf86rushproto
xf86vidmodeproto xfixes xfont xfontcache xft xi xinerama
xineramaproto xkbfile xkbui xmu xmuu xorg-server xp xpm xprintapputil
xprintutil xpr oto xproxymngproto xrandr xrender xres xscrnsaver xt
xtrans xtrap xtst xv xvmc xxf86dga xxf86misc xxf86vm</literal>.</para>
<para>Always up-to-date list can be found in
<filename>/usr/ports/Mk/bsd.xorg.mk</filename>.</para>
<para>The Mesa Project is an effort to provide free OpenGL
implementation. You can specify a dependency on various components
of this project with <varname>USE_GL</varname> variable.
Valid options are: <literal>glut, glu, glw, gl</literal> and
<literal>linux</literal>. For backwards compatibility, the value
of <literal>yes</literal> maps to <literal>glu</literal>.</para>
<example xml:id="use-xorg-example">
<title>USE_XORG example</title>
<programlisting>USE_XORG= xrender xft xkbfile xt xaw
USE_GL= glu</programlisting>
</example>
<para>Many ports define <varname>USE_XLIB</varname>, which makes
the port depend on all the 50 or so libraries. This variable
exists for backwards compatibility, as it predates modular X.Org,
and should not be used on new ports.</para>
<table frame="none">
<title>Variables for ports that use X</title>
<tgroup cols="2">
<tbody>
<row>
<entry><varname>USE_XLIB</varname></entry>
<entry>The port uses the X libraries. Deprecated - use a list of
X.Org components in <varname>USE_XORG</varname> variable
instead.</entry>
</row>
<row>
<entry><varname>USE_IMAKE</varname></entry>
<entry>會用到 <command>imake</command> 的 port。</entry>
</row>
<row>
<entry><varname>USE_X_PREFIX</varname></entry>
<entry>Deprecated. Today it is equivalent to
<varname>USE_XLIB</varname> and can be replaced by it
freely.</entry>
</row>
<row>
<entry><varname>XMKMF</varname></entry>
<entry>Set to the path of <command>xmkmf</command> if not in the
<envar>PATH</envar>. Defaults to <literal>xmkmf
-a</literal>.</entry>
</row>
</tbody>
</tgroup>
</table>
<table frame="none">
<title>Variables for depending on individual parts of X11</title>
<tgroup cols="2">
<tbody>
<row>
<entry><varname>X_IMAKE_PORT</varname></entry>
<entry>Port providing <command>imake</command> and several
other utilities used to build X11.</entry>
</row>
<row>
<entry><varname>X_LIBRARIES_PORT</varname></entry>
<entry>Port providing X11 libraries.</entry>
</row>
<row>
<entry><varname>X_CLIENTS_PORT</varname></entry>
<entry>Port providing X clients.</entry>
</row>
<row>
<entry><varname>X_SERVER_PORT</varname></entry>
<entry>Port providing X server.</entry>
</row>
<row>
<entry><varname>X_FONTSERVER_PORT</varname></entry>
<entry>Port providing font server.</entry>
</row>
<row>
<entry><varname>X_PRINTSERVER_PORT</varname></entry>
<entry>Port providing print server.</entry>
</row>
<row>
<entry><varname>X_VFBSERVER_PORT</varname></entry>
<entry>Port providing virtual framebuffer server.</entry>
</row>
<row>
<entry><varname>X_NESTSERVER_PORT</varname></entry>
<entry>Port providing a nested X server.</entry>
</row>
<row>
<entry><varname>X_FONTS_ENCODINGS_PORT</varname></entry>
<entry>Port providing encodings for fonts.</entry>
</row>
<row>
<entry><varname>X_FONTS_MISC_PORT</varname></entry>
<entry>Port providing miscellaneous bitmap fonts.</entry>
</row>
<row>
<entry><varname>X_FONTS_100DPI_PORT</varname></entry>
<entry>Port providing 100dpi bitmap fonts.</entry>
</row>
<row>
<entry><varname>X_FONTS_75DPI_PORT</varname></entry>
<entry>Port providing 75dpi bitmap fonts.</entry>
</row>
<row>
<entry><varname>X_FONTS_CYRILLIC_PORT</varname></entry>
<entry>Port providing cyrillic bitmap fonts.</entry>
</row>
<row>
<entry><varname>X_FONTS_TTF_PORT</varname></entry>
<entry>Port providing &truetype; fonts.</entry>
</row>
<row>
<entry><varname>X_FONTS_TYPE1_PORT</varname></entry>
<entry>Port providing Type1 fonts.</entry>
</row>
<row>
<entry><varname>X_MANUALS_PORT</varname></entry>
<entry>Port providing developer oriented manual pages</entry>
</row>
</tbody>
</tgroup>
</table>
<example xml:id="using-x11-vars">
<title>Using some X11 related variables in port</title>
<programlisting># Use X11 libraries and depend on
# font server as well as cyrillic fonts.
RUN_DEPENDS= ${LOCALBASE}/bin/xfs:${X_FONTSERVER_PORT} \
${LOCALBASE}/lib/X11/fonts/cyrillic/crox1c.pcf.gz:${X_FONTS_CYRILLIC_PORT}
USE_XORG= yes</programlisting>
</example>
</sect2>
<sect2 xml:id="x11-motif">
<title>Ports that require Motif</title>
<para>If your port requires a Motif library, define
<varname>USE_MOTIF</varname> in the <filename>Makefile</filename>.
Default Motif implementation is
<package>x11-toolkits/open-motif</package>.
Users can choose
<package>x11-toolkits/lesstif</package> instead
by setting <varname>WANT_LESSTIF</varname> variable.</para>
<para>The <varname>MOTIFLIB</varname> variable will be set by
<filename>bsd.port.mk</filename> to reference the appropriate
Motif library. Please patch the source of your port to
use <literal>&dollar;{MOTIFLIB}</literal> wherever the Motif library is referenced in the original
<filename>Makefile</filename> or
<filename>Imakefile</filename>.</para>
<para>There are two common cases:</para>
<itemizedlist>
<listitem>
<para>If the port refers to the Motif library as
<literal>-lXm</literal> in its <filename>Makefile</filename> or
<filename>Imakefile</filename>, simply substitute
<literal>&dollar;{MOTIFLIB}</literal> for it.</para>
</listitem>
<listitem>
<para>If the port uses <literal>XmClientLibs</literal> in its
<filename>Imakefile</filename>, change it to
<literal>&dollar;{MOTIFLIB} &dollar;{XTOOLLIB}
&dollar;{XLIB}</literal>.</para>
</listitem>
</itemizedlist>
<para>Note that <varname>MOTIFLIB</varname> (usually) expands to
<literal>-L/usr/X11R6/lib -lXm</literal> or
<literal>/usr/X11R6/lib/libXm.a</literal>, so there is no need to
add <literal>-L</literal> or <literal>-l</literal> in front.</para>
</sect2>
<sect2>
<title>X11 fonts</title>
<para>If your port installs fonts for the X Window System, put them in
<filename>LOCALBASE/lib/X11/fonts/local</filename>.</para>
</sect2>
<sect2>
<title>Getting fake <envar>DISPLAY</envar> using Xvfb</title>
<para>Some applications require a working X11 display for compilation to
succeed. This pose a problem for machines which operates headless.
When the following variable is used, the build infrastructure will
start the virtual framebuffer
X server. The working <envar>DISPLAY</envar> is then passed
to the build.</para>
<programlisting>USE_DISPLAY= yes</programlisting>
</sect2>
<sect2 xml:id="desktop-entries">
<title>Desktop entries</title>
<para>可藉由設定
<varname>DESKTOP_ENTRIES</varname> 變數,以輕鬆設定 port 的 X 選單項目
(Desktop Entries請參閱 <link xlink:href="http://standards.freedesktop.org/desktop-entry-spec/latest/">
Freedesktop standard</link>)。 這些項目會在相應的桌面環境如 GNOME
或 KDE 的應用程式選單中出現。 <filename>.desktop</filename> 檔案
將會被建立、安裝以及自動加入 <filename>pkg-plist</filename>
中。語法為:</para>
<programlisting>DESKTOP_ENTRIES= "NAME" "COMMENT" "ICON" "COMMAND" "CATEGORY" StartupNotify</programlisting>
<para>可供使用的分類可參考 <link xlink:href="http://standards.freedesktop.org/menu-spec/latest/apa.html">
Freedesktop 網站</link>。 而 <varname>StartupNotify</varname>
變數會決定程式,是否支援 startup noficication 的環境。
</para>
<para>範例:</para>
<programlisting>DESKTOP_ENTRIES= "ToME" "Roguelike game based on JRR Tolkien's work" \
"${DATADIR}/xtra/graf/tome-128.png" \
"tome -v -g" "Application;Game;RolePlaying" \
false</programlisting>
</sect2>
</sect1>
<sect1 xml:id="using-gnome">
<title>Using GNOME</title>
<para>The FreeBSD/GNOME project uses its own set of variables
to define which GNOME components a
particular port uses. A
<link xlink:href="http://www.FreeBSD.org/gnome/docs/porting.html">comprehensive
list of these variables</link> exists within the FreeBSD/GNOME
project's homepage.</para>
</sect1>
<sect1 xml:id="using-kde">
<title>Using KDE</title>
<sect2 xml:id="kde-variables">
<title>Variable definitions</title>
<table frame="none">
<title>Variables for ports that use KDE</title>
<tgroup cols="2">
<tbody>
<row>
<entry><varname>USE_KDELIBS_VER</varname></entry>
<entry>The port uses KDE libraries. It specifies the
major version of KDE to use and implies
<varname>USE_QT_VER</varname> of the appropriate
version. The only possible value is
<literal>3</literal>.</entry>
</row>
<row>
<entry><varname>USE_KDEBASE_VER</varname></entry>
<entry>The port uses KDE base. It specifies the major
version of KDE to use and implies
<varname>USE_QT_VER</varname> of the appropriate version.
The only possible value is <literal>3</literal>.</entry>
</row>
</tbody>
</tgroup>
</table>
</sect2>
<sect2 xml:id="kde-qt">
<title>Ports that require Qt</title>
<table frame="none">
<title>Variables for ports that use Qt</title>
<tgroup cols="2">
<tbody>
<row>
<entry><varname>USE_QT_VER</varname></entry>
<entry>The port uses the Qt toolkit. Possible values
are <literal>3</literal> and <literal>4</literal>;
each specify the major version of Qt to use. Appropriate
parameters are passed to <command>configure</command>
script and <command>make</command>.</entry>
</row>
<row>
<entry><varname>QT_PREFIX</varname></entry>
<entry>Set to the path where Qt installed to (read-only
variable).</entry>
</row>
<row>
<entry><varname>MOC</varname></entry>
<entry>Set to the path of <command>moc</command>
(read-only variable). Default set according to
<varname>USE_QT_VER</varname> value.</entry>
</row>
<row>
<entry><varname>QTCPPFLAGS</varname></entry>
<entry>Additional compiler flags passed via
<varname>CONFIGURE_ENV</varname> for Qt toolkit.
Default set according to
<varname>USE_QT_VER</varname>.</entry>
</row>
<row>
<entry><varname>QTCFGLIBS</varname></entry>
<entry>Additional libraries for linking passed via
<varname>CONFIGURE_ENV</varname> for Qt toolkit.
Default set according to
<varname>USE_QT_VER</varname>.</entry>
</row>
<row>
<entry><varname>QTNONSTANDARD</varname></entry>
<entry>Suppress modification of
<varname>CONFIGURE_ENV</varname>,
<varname>CONFIGURE_ARGS</varname>, and
<varname>MAKE_ENV</varname>.</entry>
</row>
</tbody>
</tgroup>
</table>
<table frame="none">
<title>Additional variables for ports that use Qt 4.x</title>
<tgroup cols="2">
<tbody>
<row>
<entry><varname>QT_COMPONENTS</varname></entry>
<entry>Specify tool and library dependencies for Qt4.
See below for details.</entry>
</row>
<row>
<entry><varname>UIC</varname></entry>
<entry>Set to the path of <command>uic</command> (read-only
variable). Default set according to
<varname>USE_QT_VER</varname> value.</entry>
</row>
<row>
<entry><varname>QMAKE</varname></entry>
<entry>Set to the path of <command>qmake</command>
(read-only variable). Default set according to
<varname>USE_QT_VER</varname> value.</entry>
</row>
<row>
<entry><varname>QMAKESPEC</varname></entry>
<entry>Set to the path of configuration file for
<command>qmake</command> (read-only variable). Default
set according to <varname>USE_QT_VER</varname>
value.</entry>
</row>
</tbody>
</tgroup>
</table>
<para>When <varname>USE_QT_VER</varname> is set, some useful
settings are passed to <command>configure</command> script:</para>
<programlisting>CONFIGURE_ARGS+= --with-qt-includes=${QT_PREFIX}/include \
--with-qt-libraries=${QT_PREFIX}/lib \
--with-extra-libs=${LOCALBASE}/lib \
--with-extra-includes=${LOCALBASE}/include
CONFIGURE_ENV+= MOC="${MOC}" CPPFLAGS="${CPPFLAGS} ${QTCPPFLAGS}" LIBS="${QTCFGLIBS}" \
QTDIR="${QT_PREFIX}" KDEDIR="${KDE_PREFIX}"</programlisting>
<para>If <varname>USE_QT_VER</varname> is set to <literal>4</literal>,
the following settings are also deployed:</para>
<programlisting>CONFIGURE_ENV+= UIC="${UIC}" QMAKE="${QMAKE}" QMAKESPEC="${QMAKESPEC}"
MAKE_ENV+= QMAKESPEC="${QMAKESPEC}"</programlisting>
</sect2>
<sect2 xml:id="qt4-components">
<title>Component selection (Qt 4.x only)</title>
<para>When <varname>USE_QT_VER</varname> is set to 4, individual
Qt4 tool and library dependencies can be specified in the
<varname>QT_COMPONENTS</varname> variable. Every component
can be suffixed by either <literal>_build</literal> or <literal>_run</literal>,
the suffix indicating whether the component should be depended on at
buildtime or runtime, respectively. If unsuffixed, the component will be
depended on at both build- and runtime. Usually, library components
should be specified unsuffixed, tool components should be
specified with the <literal>_build</literal> suffix and plugin components
should be specified with the <literal>_run</literal> suffix. The most commonly
used components are listed below (all available components are
listed in <varname>_QT_COMPONENTS_ALL</varname> in
<filename>/usr/ports/Mk/bsd.qt.mk</filename>):</para>
<table frame="none">
<title>Available Qt4 library components</title>
<tgroup cols="2">
<thead>
<row>
<entry>Name</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>corelib</literal></entry>
<entry>core library (can be omitted unless the port
uses nothing but <literal>corelib</literal>)</entry>
</row>
<row>
<entry><literal>gui</literal></entry>
<entry>graphical user interface library</entry>
</row>
<row>
<entry><literal>network</literal></entry>
<entry>network library</entry>
</row>
<row>
<entry><literal>opengl</literal></entry>
<entry>OpenGL library</entry>
</row>
<row>
<entry><literal>qt3support</literal></entry>
<entry>Qt3 compatibility library</entry>
</row>
<row>
<entry><literal>qtestlib</literal></entry>
<entry>unit testing library</entry>
</row>
<row>
<entry><literal>script</literal></entry>
<entry>script library</entry>
</row>
<row>
<entry><literal>sql</literal></entry>
<entry>SQL library</entry>
</row>
<row>
<entry><literal>xml</literal></entry>
<entry>XML library</entry>
</row>
</tbody>
</tgroup>
</table>
<para>You can determine which libraries the application depends
on, by running <command>ldd</command> on the main executable
after a successful compilation.</para>
<table frame="none">
<title>Available Qt4 tool components</title>
<tgroup cols="2">
<thead>
<row>
<entry>Name</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>moc</literal></entry>
<entry>meta object compiler (needed for almost
every Qt application at buildtime)</entry>
</row>
<row>
<entry><literal>qmake</literal></entry>
<entry>Makefile generator / build utility</entry>
</row>
<row>
<entry><literal>rcc</literal></entry>
<entry>resource compiler (need if the application comes
with <filename>*.rc</filename> or <filename>*.qrc</filename>
files)</entry>
</row>
<row>
<entry><literal>uic</literal></entry>
<entry>user interface compiler (needed if the application
comes with <filename>*.ui</filename> files created by Qt Designer
- in practice, every Qt application with a GUI)</entry>
</row>
</tbody>
</tgroup>
</table>
<table frame="none">
<title>Available Qt4 plugin components</title>
<tgroup cols="2">
<thead>
<row>
<entry>Name</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>iconengines</literal></entry>
<entry>SVG icon engine plugin (if the application
ships SVG icons)</entry>
</row>
<row>
<entry><literal>imageformats</literal></entry>
<entry>imageformat plugins for GIF, JPEG, MNG and
SVG (if the application ships image files)</entry>
</row>
</tbody>
</tgroup>
</table>
<example xml:id="qt4-components-example">
<title>Selecting Qt4 components</title>
<para>In this example, the ported application uses the
Qt4 graphical user interface library, the Qt4 core
library, all of the Qt4 code generation tools and Qt4's
Makefile generator. Since the gui library implies a
dependency on the core library, corelib does
not need to be specified. The Qt4 code generation
tools moc, uic and rcc, as well as the Makefile generator
qmake are only needed at buildtime, thus they are specified
with the <literal>_build</literal> suffix:</para>
<programlisting>USE_QT_VER= 4
QT_COMPONENTS= gui moc_build qmake_build rcc_build uic_build</programlisting>
</example>
</sect2>
<sect2 xml:id="qt-additional">
<title>Additional considerations</title>
<para>If the application does not provide a
<filename>configure</filename> file but a <filename>.pro</filename>
file, you can use the following:</para>
<programlisting>HAS_CONFIGURE= yes
do-configure:
@cd ${WRKSRC} &amp;&amp; ${SETENV} ${CONFIGURE_ENV} \
${QMAKE} -unix PREFIX=${PREFIX} texmaker.pro</programlisting>
<para>Note the similarity to the <command>qmake</command> line
from the provided <filename>BUILD.sh</filename> script. Passing
<varname>CONFIGURE_ENV</varname> ensures <command>qmake</command>
will see the <varname>QMAKESPEC</varname> variable, without which
it cannot work. <command>qmake</command> generates standard
Makefiles, so it is not necessary to write our own
<buildtarget>build</buildtarget> target.</para>
<para>Qt applications often are written to be cross-platform
and often X11/Unix isn't the platform they are developed on,
which in turn often leads to certain loose ends, like:</para>
<itemizedlist>
<listitem>
<para><emphasis>Missing additional includepaths.</emphasis>
Many applications come with system tray icon support, but
neglect to look for includes and/or libraries in the X11
directories. You can tell <command>qmake</command> to
add directories to the include and library searchpaths
via the commandline, for example:</para>
<programlisting>${QMAKE} -unix PREFIX=${PREFIX} INCLUDEPATH+=${LOCALBASE}/include \
LIBS+=-L${LOCALBASE}/lib sillyapp.pro</programlisting>
</listitem>
<listitem>
<para><emphasis>Bogus installation paths.</emphasis>
Sometimes data such as icons or .desktop files are by
default installed into directories which aren't scanned by
XDG-compatible applications. <package>editors/texmaker</package>
is an example for this - look at <filename>patch-texmaker.pro</filename>
in the <filename>files</filename> directory of that port
for a template on how to remedy this directly in the Qmake
project file.</para>
</listitem>
</itemizedlist>
</sect2>
</sect1>
<sect1 xml:id="using-java">
<title>Using Java</title>
<sect2 xml:id="java-variables">
<title>Variable definitions</title>
<para>If your port needs a Java&trade; Development Kit (JDK) to
either build, run or even extract the distfile, then it should
define <varname>USE_JAVA</varname>.</para>
<para>There are several JDKs in the ports collection, from various
vendors, and in several versions. If your port must use one of
these versions, you can define which one. The most current
version is <package>java/jdk15</package>.</para>
<table frame="none">
<title>Variables that may be set by ports that use Java</title>
<tgroup cols="2">
<thead>
<row>
<entry>Variable</entry>
<entry>Means</entry>
</row>
</thead>
<tbody>
<row>
<entry><varname>USE_JAVA</varname></entry>
<entry>Should be defined for the remaining variables to have any
effect.</entry>
</row>
<row>
<entry><varname>JAVA_VERSION</varname></entry>
<entry>List of space-separated suitable Java versions for
the port. An optional <literal>"+"</literal> allows you to
specify a range of versions (allowed values:
<literal>1.1[+] 1.2[+] 1.3[+] 1.4[+]</literal>).</entry>
</row>
<row>
<entry><varname>JAVA_OS</varname></entry>
<entry>List of space-separated suitable JDK port operating
systems for the port (allowed values: <literal>native
linux</literal>).</entry>
</row>
<row>
<entry><varname>JAVA_VENDOR</varname></entry>
<entry>List of space-separated suitable JDK port vendors for
the port (allowed values: <literal>freebsd bsdjava sun ibm
blackdown</literal>).</entry>
</row>
<row>
<entry><varname>JAVA_BUILD</varname></entry>
<entry>When set, it means that the selected JDK port should
be added to the build dependencies of the port.</entry>
</row>
<row>
<entry><varname>JAVA_RUN</varname></entry>
<entry>When set, it means that the selected JDK port should
be added to the run dependencies of the port.</entry>
</row>
<row>
<entry><varname>JAVA_EXTRACT</varname></entry>
<entry>When set, it means that the selected JDK port should
be added to the extract dependencies of the port.</entry>
</row>
<row>
<entry><varname>USE_JIKES</varname></entry>
<entry>Whether the port should or should not use the
<command>jikes</command> bytecode compiler to build. When
no value is set for this variable, the port will use
<command>jikes</command> to build if available. You may
also explicitly forbid or enforce the use of
<command>jikes</command> (by setting <literal>'no'</literal>
or <literal>'yes'</literal>). In the later case, <package>devel/jikes</package> will be added to build
dependencies of the port. In any case that <command>jikes</command>
is actually used in place of <command>javac</command>, then the
<varname>HAVE_JIKES</varname> variable is defined by
<filename>bsd.java.mk</filename>.</entry>
</row>
</tbody>
</tgroup>
</table>
<para>Below is the list of all settings a port will receive after
setting <varname>USE_JAVA</varname>:</para>
<table frame="none">
<title>Variables provided to ports that use Java</title>
<tgroup cols="2">
<thead>
<row>
<entry>Variable</entry>
<entry>Value</entry>
</row>
</thead>
<tbody>
<row>
<entry><varname>JAVA_PORT</varname></entry>
<entry>The name of the JDK port (e.g.
<literal>'java/jdk14'</literal>).</entry>
</row>
<row>
<entry><varname>JAVA_PORT_VERSION</varname></entry>
<entry>The full version of the JDK port (e.g.
<literal>'1.4.2'</literal>). If you only need the first
two digits of this version number, use
<varname>${JAVA_PORT_VERSION:C/^([0-9])\.([0-9])(.*)$/\1.\2/}</varname>.</entry>
</row>
<row>
<entry><varname>JAVA_PORT_OS</varname></entry>
<entry>The operating system used by the JDK port (e.g.
<literal>'linux'</literal>).</entry>
</row>
<row>
<entry><varname>JAVA_PORT_VENDOR</varname></entry>
<entry>The vendor of the JDK port (e.g.
<literal>'sun'</literal>).</entry>
</row>
<row>
<entry><varname>JAVA_PORT_OS_DESCRIPTION</varname></entry>
<entry>Description of the operating system used by the JDK port
(e.g. <literal>'Linux'</literal>).</entry>
</row>
<row>
<entry><varname>JAVA_PORT_VENDOR_DESCRIPTION</varname></entry>
<entry>Description of the vendor of the JDK port (e.g.
<literal>'FreeBSD Foundation'</literal>).</entry>
</row>
<row>
<entry><varname>JAVA_HOME</varname></entry>
<entry>Path to the installation directory of the JDK (e.g.
<filename>'/usr/local/jdk1.3.1'</filename>).</entry>
</row>
<row>
<entry><varname>JAVAC</varname></entry>
<entry>Path to the Java compiler to use (e.g.
<filename>'/usr/local/jdk1.1.8/bin/javac'</filename> or
<filename>'/usr/local/bin/jikes'</filename>).</entry>
</row>
<row>
<entry><varname>JAR</varname></entry>
<entry>Path to the <command>jar</command> tool to use (e.g.
<filename>'/usr/local/jdk1.2.2/bin/jar'</filename> or
<filename>'/usr/local/bin/fastjar'</filename>).</entry>
</row>
<row>
<entry><varname>APPLETVIEWER</varname></entry>
<entry>Path to the <command>appletviewer</command> utility (e.g.
<filename>'/usr/local/linux-jdk1.2.2/bin/appletviewer'</filename>).</entry>
</row>
<row>
<entry><varname>JAVA</varname></entry>
<entry>Path to the <command>java</command> executable. Use
this for executing Java programs (e.g.
<filename>'/usr/local/jdk1.3.1/bin/java'</filename>).</entry>
</row>
<row>
<entry><varname>JAVADOC</varname></entry>
<entry>Path to the <command>javadoc</command> utility
program.</entry>
</row>
<row>
<entry><varname>JAVAH</varname></entry>
<entry>Path to the <command>javah</command> program.</entry>
</row>
<row>
<entry><varname>JAVAP</varname></entry>
<entry>Path to the <command>javap</command> program.</entry>
</row>
<row>
<entry><varname>JAVA_KEYTOOL</varname></entry>
<entry>Path to the <command>keytool</command> utility program.
This variable is available only if the JDK is Java 1.2 or
higher.</entry>
</row>
<row>
<entry><varname>JAVA_N2A</varname></entry>
<entry>Path to the <command>native2ascii</command> tool.</entry>
</row>
<row>
<entry><varname>JAVA_POLICYTOOL</varname></entry>
<entry>Path to the <command>policytool</command> program.
This variable is available only if the JDK is Java 1.2 or
higher.</entry>
</row>
<row>
<entry><varname>JAVA_SERIALVER</varname></entry>
<entry>Path to the <command>serialver</command> utility
program.</entry>
</row>
<row>
<entry><varname>RMIC</varname></entry>
<entry>Path to the RMI stub/skeleton generator,
<command>rmic</command>.</entry>
</row>
<row>
<entry><varname>RMIREGISTRY</varname></entry>
<entry>Path to the RMI registry program,
<command>rmiregistry</command>.</entry>
</row>
<row>
<entry><varname>RMID</varname></entry>
<entry>Path to the RMI daemon program <command>rmid</command>.
This variable is only available if the JDK is Java 1.2
or higher.</entry>
</row>
<row>
<entry><varname>JAVA_CLASSES</varname></entry>
<entry>Path to the archive that contains the JDK class
files. On JDK 1.2 or later, this is
<filename>${JAVA_HOME}/jre/lib/rt.jar</filename>. Earlier
JDKs used
<filename>${JAVA_HOME}/lib/classes.zip</filename>.</entry>
</row>
<row>
<entry><varname>HAVE_JIKES</varname></entry>
<entry>Defined whenever <command>jikes</command> is used by
the port (see <varname>USE_JIKES</varname> above).</entry>
</row>
</tbody>
</tgroup>
</table>
<para>You may use the <literal>java-debug</literal> make target
to get information for debugging your port. It will display the
value of many of the forecited variables.</para>
<para>Additionally, the following constants are defined so all
Java ports may be installed in a consistent way:</para>
<table frame="none">
<title>Constants defined for ports that use Java</title>
<tgroup cols="2">
<thead>
<row>
<entry>Constant</entry>
<entry>Value</entry>
</row>
</thead>
<tbody>
<row>
<entry><varname>JAVASHAREDIR</varname></entry>
<entry>The base directory for everything related to Java.
Default: <filename>${PREFIX}/share/java</filename>.
</entry>
</row>
<row>
<entry><varname>JAVAJARDIR</varname></entry>
<entry>The directory where JAR files should be installed.
Default:
<filename>${JAVASHAREDIR}/classes</filename>.</entry>
</row>
<row>
<entry><varname>JAVALIBDIR</varname></entry>
<entry>The directory where JAR files installed by other
ports are located. Default:
<filename>${LOCALBASE}/share/java/classes</filename>.</entry>
</row>
</tbody>
</tgroup>
</table>
<para>The related entries are defined in both
<varname>PLIST_SUB</varname> (documented in
<xref linkend="plist-sub"/>) and
<varname>SUB_LIST</varname>.</para>
</sect2>
<sect2 xml:id="java-building-with-ant">
<title>Building with Ant</title>
<para>When the port is to be built using Apache Ant, it has to
define <varname>USE_ANT</varname>. Ant is thus considered to be
the sub-make command. When no <literal>do-build</literal> target
is defined by the port, a default one will be set that simply
runs Ant according to <varname>MAKE_ENV</varname>,
<varname>MAKE_ARGS</varname> and <varname>ALL_TARGETS</varname>.
This is similar to the <varname>USE_GMAKE</varname> mechanism,
which is documented in <xref linkend="building"/>.</para>
<para>If <command>jikes</command> is used in place of
<command>javac</command> (see <varname>USE_JIKES</varname> in
<xref linkend="java-variables"/>), then Ant will automatically
use it to build the port.</para>
</sect2>
<sect2 xml:id="java-best-practices">
<title>Best practices</title>
<para>When porting a Java library, your port should install the
JAR file(s) in <filename>${JAVAJARDIR}</filename>, and everything
else under <filename>${JAVASHAREDIR}/${PORTNAME}</filename>
(except for the documentation, see below). In order to reduce
the packing file size, you may reference the JAR file(s) directly
in the <filename>Makefile</filename>. Just use the following
statement (where <filename>myport.jar</filename> is the name
of the JAR file installed as part of the port):</para>
<programlisting>PLIST_FILES+= %%JAVAJARDIR%%/myport.jar</programlisting>
<para>When porting a Java application, the port usually installs
everything under a single directory (including its JAR
dependencies). The use of
<filename>${JAVASHAREDIR}/${PORTNAME}</filename> is strongly
encouraged in this regard. It is up the porter to decide
whether the port should install the additional JAR dependencies
under this directory or directly use the already installed ones
(from <filename>${JAVAJARDIR}</filename>).</para>
<para>Regardless of the type of your port (library or application),
the additional documentation should be installed in the
<link linkend="install-documentation">same location</link> as for
any other port. The JavaDoc tool is known to produce a
different set of files depending on the version of the JDK that
is used. For ports that do not enforce the use of a particular
JDK, it is therefore a complex task to specify the packing list
(<filename>pkg-plist</filename>). This is one reason why
porters are strongly encouraged to use the
<varname>PORTDOCS</varname> macro. Moreover, even if you can
predict the set of files that will be generated by
<command>javadoc</command>, the size of the resulting
<filename>pkg-plist</filename> advocates for the use of
<varname>PORTDOCS</varname>.</para>
<para>The default value for <varname>DATADIR</varname> is
<filename>${PREFIX}/share/${PORTNAME}</filename>. It is a good
idea to override <varname>DATADIR</varname> to
<filename>${JAVASHAREDIR}/${PORTNAME}</filename> for Java ports.
Indeed, <varname>DATADIR</varname> is automatically added to
<varname>PLIST_SUB</varname> (documented in <xref linkend="plist-sub"/>) so you may use
<literal>%%DATADIR%%</literal> directly in
<filename>pkg-plist</filename>.</para>
<para>As for the choice of building Java ports from source or
directly installing them from a binary distribution, there is
no defined policy at the time of writing. However, people from
the <link xlink:href="http://www.freebsd.org/java/">&os; Java Project</link>
encourage porters to have their ports built from source whenever
it is a trivial task.</para>
<para>All the features that have been presented in this section
are implemented in <filename>bsd.java.mk</filename>. If you
ever think that your port needs more sophisticated Java support,
please first have a look at the <link xlink:href="http://www.freebsd.org/cgi/cvsweb.cgi/ports/Mk/bsd.java.mk">
bsd.java.mk CVS log</link> as it usually takes some time to
document the latest features. Then, if you think the support
you are lacking would be beneficial to many other Java ports,
feel free to discuss it on the &a.java;.</para>
<para>Although there is a <literal>java</literal> category for
PRs, it refers to the JDK porting effort from the &os; Java
project. Therefore, you should submit your Java port in the
<literal>ports</literal> category as for any other port, unless
the issue you are trying to resolve is related to either a JDK
implementation or <filename>bsd.java.mk</filename>.</para>
<para>Similarly, there is a defined policy regarding the
<varname>CATEGORIES</varname> of a Java port, which is detailed
in <xref linkend="makefile-categories"/>.</para>
</sect2>
</sect1>
<sect1 xml:id="using-php">
<title>Web applications, Apache and PHP</title>
<sect2 xml:id="using-apache">
<title>Apache</title>
<table frame="none">
<title>Variables for ports that use Apache</title>
<tgroup cols="2">
<tbody>
<row>
<entry><varname>USE_APACHE</varname></entry>
<entry>The port requires Apache. Possible values:
<literal>yes</literal> (gets any version),
<literal>1.3</literal>, <literal>2.0</literal>,
<literal>2.2</literal>, <literal>2.0+</literal>,
etc. Default dependency is on version
<literal>1.3</literal>.</entry>
</row>
<row>
<entry><varname>WITH_APACHE2</varname></entry>
<entry>The port requires Apache 2.0. Without this variable,
the port will depend on Apache 1.3. This variable is
deprecated and should not be used anymore.</entry>
</row>
<row>
<entry><varname>APXS</varname></entry>
<entry>Full path to the <command>apxs</command> binary.
Can be overriden in your port.</entry>
</row>
<row>
<entry><varname>HTTPD</varname></entry>
<entry>Full path to the <command>httpd</command> binary.
Can be overriden in your port.</entry>
</row>
<row>
<entry><varname>APACHE_VERSION</varname></entry>
<entry>The version of present Apache installation (read-only
variable). This variable is only available after inclusion
of <filename>bsd.port.pre.mk</filename>. Possible values:
<literal>13</literal>, <literal>20</literal>,
<literal>22</literal>.</entry>
</row>
<row>
<entry><varname>APACHEMODDIR</varname></entry>
<entry>Directory for Apache modules. This variable is
automatically expanded in pkg-plist.</entry>
</row>
<row>
<entry><varname>APACHEINCLUDEDIR</varname></entry>
<entry>Directory for Apache headers. This variable is
automatically expanded in pkg-plist.</entry>
</row>
<row>
<entry><varname>APACHEETCDIR</varname></entry>
<entry>Directory for Apache configuration files. This
variable is automatically expanded in pkg-plist.</entry>
</row>
</tbody>
</tgroup>
</table>
<table frame="none">
<title>port Apache 模組時好用的變數</title>
<tgroup cols="2">
<tbody>
<row>
<entry><varname>MODULENAME</varname></entry>
<entry>模組名稱。 預設值為
<varname>PORTNAME</varname>. 範例:
<literal>mod_hello</literal></entry>
</row>
<row>
<entry><varname>SHORTMODNAME</varname></entry>
<entry>簡化的模組名稱。 自動地由變數
<varname>MODULENAME</varname> 產生,不過可以覆蓋它。
範例: <literal>hello</literal></entry>
</row>
<row>
<entry><varname>AP_FAST_BUILD</varname></entry>
<entry>使用 <command>apxs</command>
來編譯及安裝這個模組。</entry>
</row>
<row>
<entry><varname>AP_GENPLIST</varname></entry>
<entry>同樣地,也是自動產生
<filename>pkg-plist</filename></entry>
</row>
<row>
<entry><varname>AP_INC</varname></entry>
<entry>在編譯時間加入一個目錄到標頭檔搜尋路徑。</entry>
</row>
<row>
<entry><varname>AP_LIB</varname></entry>
<entry>在編譯時間加入一個目錄到函式庫搜尋路徑。</entry>
</row>
<row>
<entry><varname>AP_EXTRAS</varname></entry>
<entry>傳給
<command>apxs</command> 額外的 flags。</entry>
</row>
</tbody>
</tgroup>
</table>
</sect2>
<sect2 xml:id="web-apps">
<title>Web 應用程式</title>
<para>Web 應用程式應該安裝到
<filename>PREFIX/www/appname</filename>
。 For your convenience, this path is available both in
<filename>Makefile</filename> and in <filename>pkg-plist</filename>
as <varname>WWWDIR</varname>, and the path relative to
<varname>PREFIX</varname> is available in
<filename>Makefile</filename> as
<varname>WWWDIR_REL</varname>.</para>
<para>The user and group of web server process are available as
<varname>WWWOWN</varname> and <varname>WWWGRP</varname>, in case you
need to change the ownership of some files. The default values of
both are <literal>www</literal>. If you want different values for
your port, use <literal>WWWOWN?= myuser</literal> notation, to allow
user to override it easily.</para>
<para>請別過於相依 Apache除非這些程式有明確需要而得相依 Apache
。也許有些使用者,會想在其他非 Apache 的 Web 伺服器上執行這些網頁程式。</para>
</sect2>
<sect2 xml:id="php-variables">
<title>PHP</title>
<table frame="none">
<title>Variables for ports that use PHP</title>
<tgroup cols="2">
<tbody>
<row>
<entry><varname>USE_PHP</varname></entry>
<entry>The port requires PHP. The value <literal>yes</literal>
adds a dependency on PHP. The list of required PHP extensions
can be specified instead. Example: <literal>pcre xml
gettext</literal></entry>
</row>
<row>
<entry><varname>DEFAULT_PHP_VER</varname></entry>
<entry>Selects which major version of PHP will be installed as
a dependency when no PHP is installed yet. Default is
<literal>4</literal>. Possible values: <literal>4</literal>,
<literal>5</literal></entry>
</row>
<row>
<entry><varname>IGNORE_WITH_PHP</varname></entry>
<entry>The port does not work with PHP of the given version.
Possible values: <literal>4</literal>,
<literal>5</literal></entry>
</row>
<row>
<entry><varname>USE_PHPIZE</varname></entry>
<entry>The port will be built as a PHP extension.</entry>
</row>
<row>
<entry><varname>USE_PHPEXT</varname></entry>
<entry>The port will be treated as a PHP extension, including
installation and registration in the extension registry.</entry>
</row>
<row>
<entry><varname>USE_PHP_BUILD</varname></entry>
<entry>Set PHP as a build dependency.</entry>
</row>
<row>
<entry><varname>WANT_PHP_CLI</varname></entry>
<entry>Want the CLI (command line) version of PHP.</entry>
</row>
<row>
<entry><varname>WANT_PHP_CGI</varname></entry>
<entry>Want the CGI version of PHP.</entry>
</row>
<row>
<entry><varname>WANT_PHP_MOD</varname></entry>
<entry>Want the Apache module version of PHP.</entry>
</row>
<row>
<entry><varname>WANT_PHP_SCR</varname></entry>
<entry>Want the CLI or the CGI version of PHP.</entry>
</row>
<row>
<entry><varname>WANT_PHP_WEB</varname></entry>
<entry>Want the Apache module or the CGI version of PHP.</entry>
</row>
</tbody>
</tgroup>
</table>
</sect2>
<sect2>
<title>PEAR modules</title>
<para>Porting PEAR modules is a very simple process.</para>
<para>Use the variables <varname>FILES</varname>,
<varname>TESTS</varname>, <varname>DATA</varname>,
<varname>SQLS</varname>, <varname>SCRIPTFILES</varname>,
<varname>DOCS</varname> and <varname>EXAMPLES</varname> to list the
files you want to install. All listed files will be automatically
installed into the appropriate locations and added to
<filename>pkg-plist</filename>.</para>
<para>Include
<filename>&dollar;{PORTSDIR}/devel/pear/bsd.pear.mk</filename>
on the last line of the <filename>Makefile</filename>.</para>
<example xml:id="pear-makefile">
<title>Example Makefile for PEAR class</title>
<programlisting>PORTNAME= Date
PORTVERSION= 1.4.3
CATEGORIES= devel www pear
MAINTAINER= example@domain.com
COMMENT= PEAR Date and Time Zone Classes
BUILD_DEPENDS= ${PEARDIR}/PEAR.php:${PORTSDIR}/devel/pear-PEAR
RUN_DEPENDS= ${BUILD_DEPENDS}
FILES= Date.php Date/Calc.php Date/Human.php Date/Span.php \
Date/TimeZone.php
TESTS= test_calc.php test_date_methods_span.php testunit.php \
testunit_date.php testunit_date_span.php wknotest.txt \
bug674.php bug727_1.php bug727_2.php bug727_3.php \
bug727_4.php bug967.php weeksinmonth_4_monday.txt \
weeksinmonth_4_sunday.txt weeksinmonth_rdm_monday.txt \
weeksinmonth_rdm_sunday.txt
DOCS= TODO
_DOCSDIR= .
.include &lt;bsd.port.pre.mk&gt;
.include "&dollar;{PORTSDIR}/devel/pear/bsd.pear.mk"
.include &lt;bsd.port.post.mk&gt;</programlisting>
</example>
</sect2>
</sect1>
<sect1 xml:id="using-python">
<title>Using Python</title>
<para>The Ports Collection supports parallel installation of multiple
Python versions. Ports should make sure to use a correct
<command>python</command> interpreter, according to the user-settable
<varname>PYTHON_VERSION</varname> variable. Most prominently, this
means replacing the path to <command>python</command> executable in
scripts with the value of <varname>PYTHON_CMD</varname>
variable.</para>
<para>Ports that install files under <varname>PYTHON_SITELIBDIR</varname>
should use the <literal>pyXY-</literal> package name prefix, so their
package name embeds the version of Python they are installed
into.</para>
<programlisting>PKGNAMEPREFIX= ${PYTHON_PKGNAMEPREFIX}</programlisting>
<table frame="none">
<title>Most useful variables for ports that use Python</title>
<tgroup cols="2">
<tbody>
<row>
<entry><varname>USE_PYTHON</varname></entry>
<entry>The port needs Python. Minimal required version can be
specified with values such as <literal>2.3+</literal>.
Version ranges can also be specified, by separating two version
numbers with a dash, e.g.: <literal>2.1-2.3</literal></entry>
</row>
<row>
<entry><varname>USE_PYDISTUTILS</varname></entry>
<entry>Use Python distutils for configuring, compiling and
installing. This is required when the port comes with
<filename>setup.py</filename>. This overrides the
<buildtarget>do-build</buildtarget> and
<buildtarget>do-install</buildtarget> targets
and may also override <buildtarget>do-configure</buildtarget> if
<varname>GNU_CONFIGURE</varname> is not defined.</entry>
</row>
<row>
<entry><varname>PYTHON_PKGNAMEPREFIX</varname></entry>
<entry>Used as a <varname>PKGNAMEPREFIX</varname> to distinguish
packages for different Python versions.
Example: <literal>py24-</literal></entry>
</row>
<row>
<entry><varname>PYTHON_SITELIBDIR</varname></entry>
<entry>Location of the site-packages tree, that contains
installation path of Python (usually <varname>LOCALBASE</varname>).
The <varname>PYTHON_SITELIBDIR</varname> variable can be very
useful when installing Python modules.</entry>
</row>
<row>
<entry><varname>PYTHONPREFIX_SITELIBDIR</varname></entry>
<entry>The PREFIX-clean variant of PYTHON_SITELIBDIR.
Always use
<literal>%%PYTHON_SITELIBDIR%%</literal> in
<filename>pkg-plist</filename> when possible. The default value of
<literal>%%PYTHON_SITELIBDIR%%</literal> is
<literal>lib/python%%PYTHON_VERSION%%/site-packages</literal></entry>
</row>
<row>
<entry><varname>PYTHON_CMD</varname></entry>
<entry>Python interpreter command line, including version
number.</entry>
</row>
<row>
<entry><varname>PYNUMERIC</varname></entry>
<entry>Dependency line for numeric extension.</entry>
</row>
<row>
<entry><varname>PYNUMPY</varname></entry>
<entry>Dependency line for the new numeric extension, numpy.
(PYNUMERIC is deprecated by upstream vendor).</entry>
</row>
<row>
<entry><varname>PYXML</varname></entry>
<entry>Dependency line for XML extension (not needed for
Python 2.0 and higher as it is also in base distribution).</entry>
</row>
<row>
<entry><varname>USE_TWISTED</varname></entry>
<entry>Add dependency on twistedCore. The list of required
components can be specified as a value of this
variable. Example: <literal>web lore pair
flow</literal></entry>
</row>
<row>
<entry><varname>USE_ZOPE</varname></entry>
<entry>Add dependency on Zope, a web application platform.
Change Python dependency to Python 2.3. Set
<varname>ZOPEBASEDIR</varname> containing a directory with
Zope installation.</entry>
</row>
</tbody>
</tgroup>
</table>
<para>A complete list of available variables can be found in
<filename>/usr/ports/Mk/bsd.python.mk</filename>.</para>
</sect1>
<sect1 xml:id="using-emacs">
<title>Using Emacs</title>
<para>This section is yet to be written.</para>
</sect1>
<sect1 xml:id="using-ruby">
<title>Using Ruby</title>
<table frame="none">
<title>Useful variables for ports that use Ruby</title>
<tgroup cols="2">
<thead>
<row>
<entry>Variable</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><varname>USE_RUBY</varname></entry>
<entry>The port requires Ruby.</entry>
</row>
<row>
<entry><varname>USE_RUBY_EXTCONF</varname></entry>
<entry>The port uses <filename>extconf.rb</filename> to
configure.</entry>
</row>
<row>
<entry><varname>USE_RUBY_SETUP</varname></entry>
<entry>The port uses <filename>setup.rb</filename> to
configure.</entry>
</row>
<row>
<entry><varname>RUBY_SETUP</varname></entry>
<entry>Set to the alternative name of
<filename>setup.rb</filename>. Common value is
<filename>install.rb</filename>.</entry>
</row>
</tbody>
</tgroup>
</table>
<para>The following table shows the selected variables available to port
authors via the ports infrastructure. These variables should be used
to install files into their proper locations. Use them in
<filename>pkg-plist</filename> as much as possible. These variables
should not be redefined in the port.</para>
<table frame="none">
<title>Selected read-only variables for ports that use Ruby</title>
<tgroup cols="3">
<thead>
<row>
<entry>Variable</entry>
<entry>Description</entry>
<entry>Example value</entry>
</row>
</thead>
<tbody>
<row>
<entry><varname>RUBY_PKGNAMEPREFIX</varname></entry>
<entry>Used as a <varname>PKGNAMEPREFIX</varname> to distinguish
packages for different Ruby versions.</entry>
<entry><literal>ruby18-</literal></entry>
</row>
<row>
<entry><varname>RUBY_VERSION</varname></entry>
<entry>Full version of Ruby in the form of
<literal>x.y.z</literal>.</entry>
<entry><literal>1.8.2</literal></entry>
</row>
<row>
<entry><varname>RUBY_SITELIBDIR</varname></entry>
<entry>Architecture independent libraries installation
path.</entry>
<entry><literal>/usr/local/lib/ruby/site_ruby/1.8</literal></entry>
</row>
<row>
<entry><varname>RUBY_SITEARCHLIBDIR</varname></entry>
<entry>Architecture dependent libraries installation
path.</entry>
<entry><literal>/usr/local/lib/ruby/site_ruby/1.8/amd64-freebsd6</literal></entry>
</row>
<row>
<entry><varname>RUBY_MODDOCDIR</varname></entry>
<entry>Module documentation installation path.</entry>
<entry><literal>/usr/local/share/doc/ruby18/patsy</literal></entry>
</row>
<row>
<entry><varname>RUBY_MODEXAMPLESDIR</varname></entry>
<entry>Module examples installation path.</entry>
<entry><literal>/usr/local/share/examples/ruby18/patsy</literal></entry>
</row>
</tbody>
</tgroup>
</table>
<para>A complete list of available variables can be found in
<filename>/usr/ports/Mk/bsd.ruby.mk</filename>.</para>
</sect1>
<sect1 xml:id="using-sdl">
<title>Using SDL</title>
<para>The <varname>USE_SDL</varname> variable is used to autoconfigure
the dependencies for ports which use an SDL based library like
<package>devel/sdl12</package> and
<package>x11-toolkits/sdl_gui</package>.</para>
<para>The following SDL libraries are recognized at the moment:</para>
<itemizedlist>
<listitem>
<para>sdl: <package>devel/sdl12</package></para>
</listitem>
<listitem>
<para>gfx: <package>graphics/sdl_gfx</package></para>
</listitem>
<listitem>
<para>gui: <package>x11-toolkits/sdl_gui</package></para>
</listitem>
<listitem>
<para>image: <package>graphics/sdl_image</package></para>
</listitem>
<listitem>
<para>ldbad: <package>devel/sdl_ldbad</package></para>
</listitem>
<listitem>
<para>mixer: <package>audio/sdl_mixer</package></para>
</listitem>
<listitem>
<para>mm: <package>devel/sdlmm</package></para>
</listitem>
<listitem>
<para>net: <package>net/sdl_net</package></para>
</listitem>
<listitem>
<para>sound: <package>audio/sdl_sound</package></para>
</listitem>
<listitem>
<para>ttf: <package>graphics/sdl_ttf</package></para>
</listitem>
</itemizedlist>
<para>Therefore, if a port has a dependency on
<package>net/sdl_net</package> and
<package>audio/sdl_mixer</package>,
the syntax will be:</para>
<programlisting>USE_SDL= net mixer</programlisting>
<para>The dependency <package>devel/sdl12</package>,
which is required by <package>net/sdl_net</package> and
<package>audio/sdl_mixer</package>, is automatically
added as well.</para>
<para>If you use <varname>USE_SDL</varname>, it will automatically:</para>
<itemizedlist>
<listitem>
<para>Add a dependency on <application>sdl12-config</application> to
<varname>BUILD_DEPENDS</varname></para>
</listitem>
<listitem>
<para>Add the variable <varname>SDL_CONFIG</varname> to
<varname>CONFIGURE_ENV</varname></para>
</listitem>
<listitem>
<para>Add the dependencies of the selected libraries to the
<varname>LIB_DEPENDS</varname></para>
</listitem>
</itemizedlist>
<para>To check whether an SDL library is available, you can do it
with the <varname>WANT_SDL</varname> variable:</para>
<programlisting>WANT_SDL=yes
.include &lt;bsd.port.pre.mk&gt;
.if ${HAVE_SDL:Mmixer}!=""
USE_SDL+= mixer
.endif
.include &lt;bsd.port.post.mk&gt;</programlisting>
</sect1>
<sect1 xml:id="using-wx">
<title>Using <application>wxWidgets</application></title>
<para>This section describes the status of the
<application>wxWidgets</application> libraries in the ports tree and
its integration with the ports system.</para>
<sect2 xml:id="wx-introduction">
<title>Introduction</title>
<para>There are many versions of the
<application>wxWidgets</application> libraries which conflict
between them (install files under the same name). In the ports tree
this problem has been solved by installing each version under a
different name using version number suffixes.</para>
<para>The obvious disadvantage of this is that each application has to
be modified to find the expected version. Fortunately, most of the
applications call the <command>wx-config</command> script to
determine the necessary compiler and linker flags. The script is
named differently for every available version. Majority of
applications respect an environment variable, or accept a configure
argument, to specify which <command>wx-config</command> script to
call. Otherwise they have to be patched.</para>
</sect2>
<sect2 xml:id="wx-version">
<title>Version selection</title>
<para>To make your port use a specific version of
<application>wxWidgets</application> there are two variables
available for defining (if only one is defined the other will be set
to a default value):</para>
<table xml:id="wx-ver-sel-table" frame="none">
<title>Variables to select <application>wxWidgets</application>
versions</title>
<tgroup cols="3">
<thead>
<row>
<entry>Variable</entry>
<entry>Description</entry>
<entry>Default value</entry>
</row>
</thead>
<tbody>
<row>
<entry><varname>USE_WX</varname></entry>
<entry>List of versions the port can use</entry>
<entry>All available versions</entry>
</row>
<row>
<entry><varname>USE_WX_NOT</varname></entry>
<entry>List of versions the port can not use</entry>
<entry>None</entry>
</row>
</tbody>
</tgroup>
</table>
<para>The following is a list of available
<application>wxWidgets</application> versions and the corresponding
ports in the tree:</para>
<table frame="none">
<title>Available <application>wxWidgets</application>
versions</title>
<tgroup cols="2">
<thead>
<row>
<entry>Version</entry>
<entry>Port</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>2.4</literal></entry>
<entry><package>x11-toolkits/wxgtk24</package></entry>
</row>
<row>
<entry><literal>2.6</literal></entry>
<entry><package>x11-toolkits/wxgtk26</package></entry>
</row>
<row>
<entry><literal>2.8</literal></entry>
<entry><package>x11-toolkits/wxgtk28</package></entry>
</row>
</tbody>
</tgroup>
</table>
<note>
<para>The versions starting from <literal>2.5</literal> also come in
Unicode version and are installed by a slave port named like the
normal one plus a <literal>-unicode</literal> suffix, but this can
be handled with variables (see <xref linkend="wx-unicode"/>).</para>
</note>
<para>The variables in <xref linkend="wx-ver-sel-table"/> can be set
to one or more of the following combinations separated by
spaces:</para>
<table frame="none">
<title><application>wxWidgets</application> version
specifications</title>
<tgroup cols="2">
<thead>
<row>
<entry>Description</entry>
<entry>Example</entry>
</row>
</thead>
<tbody>
<row>
<entry>Single version</entry>
<entry><literal>2.4</literal></entry>
</row>
<row>
<entry>Ascending range</entry>
<entry><literal>2.4+</literal></entry>
</row>
<row>
<entry>Descending range</entry>
<entry><literal>2.6-</literal></entry>
</row>
<row>
<entry>Full range (must be ascending)</entry>
<entry><literal>2.4-2.6</literal></entry>
</row>
</tbody>
</tgroup>
</table>
<para>There are also some variables to select the preferred versions
from the available ones. They can be set to a list of versions, the
first ones will have higher priority.</para>
<table frame="none">
<title>Variables to select preferred
<application>wxWidgets</application> versions</title>
<tgroup cols="2">
<thead>
<row>
<entry>Name</entry>
<entry>Designed for</entry>
</row>
</thead>
<tbody>
<row>
<entry><varname>WANT_WX_VER</varname></entry>
<entry>the port</entry>
</row>
<row>
<entry><varname>WITH_WX_VER</varname></entry>
<entry>the user</entry>
</row>
</tbody>
</tgroup>
</table>
</sect2>
<sect2 xml:id="wx-components">
<title>Component selection</title>
<para>There are other applications that, while not being
<application>wxWidgets</application> libraries, are related to them.
These applications can be specified in the
<varname>WX_COMPS</varname> variable. The following components are
available:</para>
<table frame="none">
<title>Available <application>wxWidgets</application>
components</title>
<tgroup cols="3">
<thead>
<row>
<entry>Name</entry>
<entry>Description</entry>
<entry>Version restriction</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>wx</literal></entry>
<entry>main library</entry>
<entry>none</entry>
</row>
<row>
<entry><literal>contrib</literal></entry>
<entry>contributed libraries</entry>
<entry><literal>none</literal></entry>
</row>
<row>
<entry><literal>python</literal></entry>
<entry><application>wxPython</application>
(<application>Python</application> bindings)</entry>
<entry><literal>2.4-2.6</literal></entry>
</row>
<row>
<entry><literal>mozilla</literal></entry>
<entry><application>wxMozilla</application></entry>
<entry><literal>2.4</literal></entry>
</row>
<row>
<entry><literal>svg</literal></entry>
<entry><application>wxSVG</application></entry>
<entry><literal>2.6</literal></entry>
</row>
</tbody>
</tgroup>
</table>
<para>The dependency type can be selected for each component by adding
a suffix separated by a semicolon. If not present then a default
type will be used (see <xref linkend="wx-def-dep-types"/>). The
following types are available:</para>
<table frame="none">
<title>Available <application>wxWidgets</application> dependency
types</title>
<tgroup cols="2">
<thead>
<row>
<entry>Name</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>build</literal></entry>
<entry>Component is required for building, equivalent to
<varname>BUILD_DEPENDS</varname></entry>
</row>
<row>
<entry><literal>run</literal></entry>
<entry>Component is required for running, equivalent to
<varname>RUN_DEPENDS</varname></entry>
</row>
<row>
<entry><literal>lib</literal></entry>
<entry>Component is required for building and running,
equivalent to <varname>LIB_DEPENDS</varname></entry>
</row>
</tbody>
</tgroup>
</table>
<para>The default values for the components are detailed in the
following table:</para>
<table xml:id="wx-def-dep-types" frame="none">
<title>Default <application>wxWidgets</application> dependency
types</title>
<tgroup cols="2">
<thead>
<row>
<entry>Component</entry>
<entry>Dependency type</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>wx</literal></entry>
<entry><literal>lib</literal></entry>
</row>
<row>
<entry><literal>contrib</literal></entry>
<entry><literal>lib</literal></entry>
</row>
<row>
<entry><literal>python</literal></entry>
<entry><literal>run</literal></entry>
</row>
<row>
<entry><literal>mozilla</literal></entry>
<entry><literal>lib</literal></entry>
</row>
<row>
<entry><literal>svg</literal></entry>
<entry><literal>lib</literal></entry>
</row>
</tbody>
</tgroup>
</table>
<example xml:id="wx-components-example">
<title>Selecting <application>wxWidgets</application>
components</title>
<para>The following fragment corresponds to a port which uses
<application>wxWidgets</application> version
<literal>2.4</literal> and its contributed libraries.</para>
<programlisting>USE_WX= 2.4
WX_COMPS= wx contrib</programlisting>
</example>
</sect2>
<sect2 xml:id="wx-unicode">
<title>Unicode</title>
<para>The <application>wxWidgets</application> library supports
Unicode since version <literal>2.5</literal>. In the ports tree
both versions are available and can be selected with the following
variables:</para>
<table xml:id="wx-unicode-var-table" frame="none">
<title>Variables to select Unicode in
<application>wxWidgets</application>
versions</title>
<tgroup cols="3">
<thead>
<row>
<entry>Variable</entry>
<entry>Description</entry>
<entry>Designed for</entry>
</row>
</thead>
<tbody>
<row>
<entry><varname>WX_UNICODE</varname></entry>
<entry>The port works <emphasis>only</emphasis> with the
Unicode version</entry>
<entry>the port</entry>
</row>
<row>
<entry><varname>WANT_UNICODE</varname></entry>
<entry>The port works with both versions but prefers the
Unicode one</entry>
<entry>the port</entry>
</row>
<row>
<entry><varname>WITH_UNICODE</varname></entry>
<entry>The port will use the Unicode version</entry>
<entry>the user</entry>
</row>
<row>
<entry><varname>WITHOUT_UNICODE</varname></entry>
<entry>The port will use the normal version if
supported (when <varname>WX_UNICODE</varname> is not
defined)</entry>
<entry>the user</entry>
</row>
</tbody>
</tgroup>
</table>
<warning>
<para>Do not use <varname>WX_UNICODE</varname> for ports that can
use both Unicode and normal versions. If you want the port to use
Unicode by default define <varname>WANT_UNICODE</varname>
instead.</para>
</warning>
</sect2>
<sect2 xml:id="wx-version-detection">
<title>Detecting installed versions</title>
<para>To detect an installed version you have to define
<varname>WANT_WX</varname>. If you do not set it to a specific
version then the components will have a version suffix. The
<varname>HAVE_WX</varname> variable will be filled after
detection.</para>
<example xml:id="wx-ver-det-example">
<title>Detecting installed <application>wxWidgets</application>
versions and components</title>
<para>The following fragment can be used in a port that uses
<application>wxWidgets</application> if it is installed, or an
option is selected.</para>
<programlisting>WANT_WX= yes
.include &lt;bsd.port.pre.mk&gt;
.if defined(WITH_WX) || ${HAVE_WX:Mwx-2.4} != ""
USE_WX= 2.4
CONFIGURE_ARGS+=--enable-wx
.endif</programlisting>
<para>The following fragment can be used in a port that enables
<application>wxPython</application> support if it is installed or
if an option is selected, in addition to
<application>wxWidgets</application>, both version
<literal>2.6</literal>.</para>
<programlisting>USE_WX= 2.6
WX_COMPS= wx
WANT_WX= 2.6
.include &lt;bsd.port.pre.mk&gt;
.if defined(WITH_WXPYTHON) || ${HAVE_WX:Mpython} != ""
WX_COMPS+= python
CONFIGURE_ARGS+=--enable-wxpython
.endif</programlisting>
</example>
</sect2>
<sect2 xml:id="wx-defined-variables">
<title>Defined variables</title>
<para>The following variables are available in the port (after
defining one from <xref linkend="wx-ver-sel-table"/>).</para>
<table frame="none">
<title>Variables defined for ports that use
<application>wxWidgets</application></title>
<tgroup cols="2">
<thead>
<row>
<entry>Name</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><varname>WX_CONFIG</varname></entry>
<entry>The path to the <application>wxWidgets</application>
<command>wx-config</command> script (with different
name)</entry>
</row>
<row>
<entry><varname>WXRC_CMD</varname></entry>
<entry>The path to the <application>wxWidgets</application>
<command>wxrc</command> program (with different
name)</entry>
</row>
<row>
<entry><varname>WX_VERSION</varname></entry>
<entry>The <application>wxWidgets</application> version that
is going to be used (e.g., <literal>2.6</literal>)</entry>
</row>
<row>
<entry><varname>WX_UNICODE</varname></entry>
<entry>If not defined but Unicode is going to be used then it
will be defined</entry>
</row>
</tbody>
</tgroup>
</table>
</sect2>
<sect2 xml:id="wx-premk">
<title>Processing in <filename>bsd.port.pre.mk</filename></title>
<para>If you need to use the variables for running commands right
after including <filename>bsd.port.pre.mk</filename> you need to
define <varname>WX_PREMK</varname>.</para>
<important>
<para>If you define <varname>WX_PREMK</varname>, then the version,
dependencies, components and defined variables will not change if
you modify the <application>wxWidgets</application> port variables
<emphasis>after</emphasis> including
<filename>bsd.port.pre.mk</filename>.</para>
</important>
<example xml:id="wx-premk-example">
<title>Using <application>wxWidgets</application> variables in
commands</title>
<para>The following fragment illustrates the use of
<varname>WX_PREMK</varname> by running the
<command>wx-config</command> script to obtain the full version
string, assign it to a variable and pass it to the program.</para>
<programlisting>USE_WX= 2.4
WX_PREMK= yes
.include &lt;bsd.port.pre.mk&gt;
.if exists(${WX_CONFIG})
VER_STR!= ${WX_CONFIG} --release
PLIST_SUB+= VERSION="${VER_STR}"
.endif</programlisting>
</example>
<note>
<para>The <application>wxWidgets</application> variables can be
safely used in commands when they are inside targets without the
need of <varname>WX_PREMK</varname>.</para>
</note>
</sect2>
<sect2 xml:id="wx-additional-config-args">
<title>Additional <command>configure</command> arguments</title>
<para>Some GNU <command>configure</command> scripts can not find
<application>wxWidgets</application> with just the
<literal>WX_CONFIG</literal> environment variable set, requiring
additional arguments. The <varname>WX_CONF_ARGS</varname> variable
can be used for provide them.</para>
<table frame="none">
<title>Legal values for <varname>WX_CONF_ARGS</varname></title>
<tgroup cols="2">
<thead>
<row>
<entry>Possible value</entry>
<entry>Resulting argument</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>absolute</literal></entry>
<entry><literal>--with-wx-config=${WX_CONFIG}</literal></entry>
</row>
<row>
<entry><literal>relative</literal></entry>
<entry><literal>--with-wx=${LOCALBASE}
--with-wx-config=${WX_CONFIG:T}</literal></entry>
</row>
</tbody>
</tgroup>
</table>
</sect2>
</sect1>
<sect1 xml:id="using-lua">
<title>Using <application>Lua</application></title>
<para>This section describes the status of the
<application>Lua</application> libraries in the ports tree and its
integration with the ports system.</para>
<sect2 xml:id="lua-introduction">
<title>Introduction</title>
<para>There are many versions of the <application>Lua</application>
libraries and corresponding interpreters, which conflict between
them (install files under the same name). In the ports tree this
problem has been solved by installing each version under a different
name using version number suffixes.</para>
<para>The obvious disadvantage of this is that each application has to
be modified to find the expected version. But it can be solved by
adding some additional flags to the compiler and linker.</para>
</sect2>
<sect2 xml:id="lua-version">
<title>Version selection</title>
<para>To make your port use a specific version of
<application>Lua</application> there are two variables available
for defining (if only one is defined the other will be set to a
default value):</para>
<table xml:id="lua-ver-sel-table" frame="none">
<title>Variables to select <application>Lua</application>
versions</title>
<tgroup cols="3">
<thead>
<row>
<entry>Variable</entry>
<entry>Description</entry>
<entry>Default value</entry>
</row>
</thead>
<tbody>
<row>
<entry><varname>USE_LUA</varname></entry>
<entry>List of versions the port can use</entry>
<entry>All available versions</entry>
</row>
<row>
<entry><varname>USE_LUA_NOT</varname></entry>
<entry>List of versions the port can not use</entry>
<entry>None</entry>
</row>
</tbody>
</tgroup>
</table>
<para>The following is a list of available
<application>Lua</application> versions and the corresponding ports
in the tree:</para>
<table frame="none">
<title>Available <application>Lua</application> versions</title>
<tgroup cols="2">
<thead>
<row>
<entry>Version</entry>
<entry>Port</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>4.0</literal></entry>
<entry><package>lang/lua4</package></entry>
</row>
<row>
<entry><literal>5.0</literal></entry>
<entry><package>lang/lua50</package></entry>
</row>
<row>
<entry><literal>5.1</literal></entry>
<entry><package>lang/lua</package></entry>
</row>
</tbody>
</tgroup>
</table>
<para>The variables in <xref linkend="lua-ver-sel-table"/> can be set
to one or more of the following combinations separated by
spaces:</para>
<table frame="none">
<title><application>Lua</application> version specifications</title>
<tgroup cols="2">
<thead>
<row>
<entry>Description</entry>
<entry>Example</entry>
</row>
</thead>
<tbody>
<row>
<entry>Single version</entry>
<entry><literal>4.0</literal></entry>
</row>
<row>
<entry>Ascending range</entry>
<entry><literal>5.0+</literal></entry>
</row>
<row>
<entry>Descending range</entry>
<entry><literal>5.0-</literal></entry>
</row>
<row>
<entry>Full range (must be ascending)</entry>
<entry><literal>5.0-5.1</literal></entry>
</row>
</tbody>
</tgroup>
</table>
<para>There are also some variables to select the preferred versions
from the available ones. They can be set to a list of versions, the
first ones will have higher priority.</para>
<table frame="none">
<title>Variables to select preferred <application>Lua</application>
versions</title>
<tgroup cols="2">
<thead>
<row>
<entry>Name</entry>
<entry>Designed for</entry>
</row>
</thead>
<tbody>
<row>
<entry><varname>WANT_LUA_VER</varname></entry>
<entry>the port</entry>
</row>
<row>
<entry><varname>WITH_LUA_VER</varname></entry>
<entry>the user</entry>
</row>
</tbody>
</tgroup>
</table>
<example xml:id="lua-version-example">
<title>Selecting the <application>Lua</application> version</title>
<para>The following fragment is from a port which can use
<application>Lua</application> version <literal>5.0</literal> or
<literal>5.1</literal>, and uses <literal>5.0</literal> by
default. It can be overriden by the user using
<varname>WITH_LUA_VER</varname>.</para>
<programlisting>USE_LUA= 5.0-5.1
WANT_LUA_VER= 5.0</programlisting>
</example>
</sect2>
<sect2 xml:id="lua-components">
<title>Component selection</title>
<para>There are other applications that, while not being
<application>Lua</application> libraries, are related to them.
These applications can be specified in the
<varname>LUA_COMPS</varname> variable. The following components are
available:</para>
<table frame="none">
<title>Available <application>Lua</application> components</title>
<tgroup cols="3">
<thead>
<row>
<entry>Name</entry>
<entry>Description</entry>
<entry>Version restriction</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>lua</literal></entry>
<entry>main library</entry>
<entry>none</entry>
</row>
<row>
<entry><literal>tolua</literal></entry>
<entry>Library for accesing C/C++ code</entry>
<entry><literal>4.0-5.0</literal></entry>
</row>
<row>
<entry><literal>ruby</literal></entry>
<entry>Ruby bindings</entry>
<entry><literal>4.0-5.0</literal></entry>
</row>
</tbody>
</tgroup>
</table>
<note>
<para>There are more components but they are modules for the
interpreter, not used by applications (only by other
modules).</para>
</note>
<para>The dependency type can be selected for each component by adding
a suffix separated by a semicolon. If not present then a default
type will be used (see <xref linkend="lua-def-dep-types"/>). The
following types are available:</para>
<table frame="none">
<title>Available <application>Lua</application> dependency
types</title>
<tgroup cols="2">
<thead>
<row>
<entry>Name</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>build</literal></entry>
<entry>Component is required for building, equivalent to
<varname>BUILD_DEPENDS</varname></entry>
</row>
<row>
<entry><literal>run</literal></entry>
<entry>Component is required for running, equivalent to
<varname>RUN_DEPENDS</varname></entry>
</row>
<row>
<entry><literal>lib</literal></entry>
<entry>Component is required for building and running,
equivalent to <varname>LIB_DEPENDS</varname></entry>
</row>
</tbody>
</tgroup>
</table>
<para>The default values for the components are detailed in the
following table:</para>
<table xml:id="lua-def-dep-types" frame="none">
<title>Default <application>Lua</application> dependency
types</title>
<tgroup cols="2">
<thead>
<row>
<entry>Component</entry>
<entry>Dependency type</entry>
</row>
</thead>
<tbody>
<row>
<entry><literal>lua</literal></entry>
<entry><literal>lib</literal> for <literal>4.0-5.0</literal>
(shared) and <literal>build</literal> for
<literal>5.1</literal> (static)</entry>
</row>
<row>
<entry><literal>tolua</literal></entry>
<entry><literal>build</literal> (static)</entry>
</row>
<row>
<entry><literal>ruby</literal></entry>
<entry><literal>lib</literal> (shared)</entry>
</row>
</tbody>
</tgroup>
</table>
<example xml:id="lua-components-example">
<title>Selecting <application>Lua</application> components</title>
<para>The following fragment corresponds to a port which uses
<application>Lua</application> version <literal>4.0</literal> and
its <application>Ruby</application> bindings.</para>
<programlisting>USE_LUA= 4.0
LUA_COMPS= lua ruby</programlisting>
</example>
</sect2>
<sect2 xml:id="lua-version-detection">
<title>Detecting installed versions</title>
<para>To detect an installed version you have to define
<varname>WANT_LUA</varname>. If you do not set it to a specific
version then the components will have a version suffix. The
<varname>HAVE_LUA</varname> variable will be filled after
detection.</para>
<example xml:id="lua-ver-det-example">
<title>Detecting installed <application>Lua</application> versions
and components</title>
<para>The following fragment can be used in a port that uses
<application>Lua</application> if it is installed, or an option is
selected.</para>
<programlisting>WANT_LUA= yes
.include &lt;bsd.port.pre.mk&gt;
.if defined(WITH_LUA5) || ${HAVE_LUA:Mlua-5.[01]} != ""
USE_LUA= 5.0-5.1
CONFIGURE_ARGS+=--enable-lua5
.endif</programlisting>
<para>The following fragment can be used in a port that enables
<application>tolua</application> support if it is installed or if
an option is selected, in addition to
<application>Lua</application>, both version
<literal>4.0</literal>.</para>
<programlisting>USE_LUA= 4.0
LUA_COMPS= lua
WANT_LUA= 4.0
.include &lt;bsd.port.pre.mk&gt;
.if defined(WITH_TOLUA) || ${HAVE_LUA:Mtolua} != ""
LUA_COMPS+= tolua
CONFIGURE_ARGS+=--enable-tolua
.endif</programlisting>
</example>
</sect2>
<sect2 xml:id="lua-defined-variables">
<title>Defined variables</title>
<para>The following variables are available in the port (after
defining one from <xref linkend="lua-ver-sel-table"/>).</para>
<table frame="none">
<title>Variables defined for ports that use
<application>Lua</application></title>
<tgroup cols="2">
<thead>
<row>
<entry>Name</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><varname>LUA_VER</varname></entry>
<entry>The <application>Lua</application> version that is
going to be used (e.g., <literal>5.1</literal>)</entry>
</row>
<row>
<entry><varname>LUA_VER_SH</varname></entry>
<entry>The <application>Lua</application> shared library major
version (e.g., <literal>1</literal>)</entry>
</row>
<row>
<entry><varname>LUA_VER_STR</varname></entry>
<entry>The <application>Lua</application> version without the
dots (e.g., <literal>51</literal>)</entry>
</row>
<row>
<entry><varname>LUA_PREFIX</varname></entry>
<entry>The prefix where <application>Lua</application> (and
components) is installed</entry>
</row>
<row>
<entry><varname>LUA_SUBDIR</varname></entry>
<entry>The directory under <filename>${PREFIX}/bin</filename>,
<filename>${PREFIX}/share</filename> and
<filename>${PREFIX}/lib</filename> where
<application>Lua</application> is installed</entry>
</row>
<row>
<entry><varname>LUA_INCDIR</varname></entry>
<entry>The directory where <application>Lua</application> and
<application>tolua</application> header files are
installed</entry>
</row>
<row>
<entry><varname>LUA_LIBDIR</varname></entry>
<entry>The directory where <application>Lua</application> and
<application>tolua</application> libraries are
installed</entry>
</row>
<row>
<entry><varname>LUA_MODLIBDIR</varname></entry>
<entry>The directory where <application>Lua</application>
module libraries (<filename>.so</filename>) are
installed</entry>
</row>
<row>
<entry><varname>LUA_MODSHAREDIR</varname></entry>
<entry>The directory where <application>Lua</application>
modules (<filename>.lua</filename>) are installed</entry>
</row>
<row>
<entry><varname>LUA_PKGNAMEPREFIX</varname></entry>
<entry>The package name prefix used by
<application>Lua</application> modules</entry>
</row>
<row>
<entry><varname>LUA_CMD</varname></entry>
<entry>The path to the <application>Lua</application>
interpreter</entry>
</row>
<row>
<entry><varname>LUAC_CMD</varname></entry>
<entry>The path to the <application>Lua</application>
compiler</entry>
</row>
<row>
<entry><varname>TOLUA_CMD</varname></entry>
<entry>The path to the <application>tolua</application>
program</entry>
</row>
</tbody>
</tgroup>
</table>
<example xml:id="lua-variables-example">
<title>Telling the port where to find
<application>Lua</application></title>
<para>The following fragment shows how to tell a port that uses a
configure script where the <application>Lua</application> header
files and libraries are.</para>
<programlisting>
USE_LUA= 4.0
GNU_CONFIGURE= yes
CONFIGURE_ENV= CPPFLAGS="-I${LUA_INCDIR}" LDFLAGS="-L${LUA_LIBDIR}"</programlisting>
</example>
</sect2>
<sect2 xml:id="lua-premk">
<title>Processing in <filename>bsd.port.pre.mk</filename></title>
<para>If you need to use the variables for running commands right
after including <filename>bsd.port.pre.mk</filename> you need to
define <varname>LUA_PREMK</varname>.</para>
<important>
<para>If you define <varname>LUA_PREMK</varname>, then the version,
dependencies, components and defined variables will not change if
you modify the <application>Lua</application> port variables
<emphasis>after</emphasis> including
<filename>bsd.port.pre.mk</filename>.</para>
</important>
<example xml:id="lua-premk-example">
<title>Using <application>Lua</application> variables in
commands</title>
<para>The following fragment illustrates the use of
<varname>LUA_PREMK</varname> by running the
<application>Lua</application> interpreter to obtain the full
version string, assign it to a variable and pass it to the
program.</para>
<programlisting>USE_LUA= 5.0
LUA_PREMK= yes
.include &lt;bsd.port.pre.mk&gt;
.if exists(${LUA_CMD})
VER_STR!= ${LUA_CMD} -v
CFLAGS+= -DLUA_VERSION_STRING="${VER_STR}"
.endif</programlisting>
</example>
<note>
<para>The <application>Lua</application> variables can be safely
used in commands when they are inside targets without the need of
<varname>LUA_PREMK</varname>.</para>
</note>
</sect2>
</sect1>
<sect1 xml:id="using-xfce">
<title>Using Xfce</title>
<para>The <varname>USE_XFCE</varname> variable is used to autoconfigure
the dependencies for ports which use an Xfce based library or application
like
<package>x11-toolkits/libxfce4gui</package> and
<package>x11-wm/xfce4-panel</package>.</para>
<para>The following Xfce libraries and applications are recognized at
the moment:</para>
<itemizedlist>
<listitem>
<para>libexo: <package>x11/libexo</package></para>
</listitem>
<listitem>
<para>libgui: <package>x11-toolkits/libxfce4gui</package></para>
</listitem>
<listitem>
<para>libutil: <package>x11/libxfce4util</package></para>
</listitem>
<listitem>
<para>libmcs: <package>x11/libxfce4mcs</package></para>
</listitem>
<listitem>
<para>mcsmanager: <package>sysutils/xfce4-mcs-manager</package></para>
</listitem>
<listitem>
<para>panel: <package>x11-wm/xfce4-panel</package></para>
</listitem>
<listitem>
<para>thunar: <package>x11-fm/thunar</package></para>
</listitem>
<listitem>
<para>wm: <package>x11-wm/xfce4-wm</package></para>
</listitem>
<listitem>
<para>xfdev: <package>dev/xfce4-dev-tools</package></para>
</listitem>
</itemizedlist>
<para>The following additional parameters are recognized:</para>
<itemizedlist>
<listitem>
<para>configenv: Use this if your port requires a special modified
<varname>CONFIGURE_ENV</varname> to find it's required libraries.
<programlisting>-I&dollar;{LOCALBASE}/include -L&dollar;{LOCALBASE}/lib</programlisting>
gets added to CPPFLAGS to <varname>CONFIGURE_ENV</varname>.</para>
</listitem>
</itemizedlist>
<para>Therefore, if a port has a dependency on
<package>sysutils/xfce4-mcs-manager</package> and
requires the special CPPFLAGS in its configure environment,
the syntax will be:</para>
<programlisting>USE_XFCE= mcsmanager configenv</programlisting>
</sect1>
<sect1 xml:id="using-databases">
<title>Using databases</title>
<table frame="none">
<title>Variables for ports using databases</title>
<tgroup cols="2">
<thead>
<row>
<entry>Variable</entry>
<entry>Means</entry>
</row>
</thead>
<tbody>
<row>
<entry><varname>USE_BDB</varname></entry>
<entry>If variable is set to <literal>yes</literal>,
add dependency on <package>databases/db41</package>
port. The variable may also be set to values: 2, 3, 40, 41,
42, 43, 44, 45 46, or 47. You can declare a range of
acceptable values, <varname>USE_BDB</varname>=42+ will find
the highest installed version, and fall back to 42 if nothing
else is installed.</entry>
</row>
<row>
<entry><varname>USE_MYSQL</varname></entry>
<entry>If variable is set to <literal>yes</literal>, add
dependency on <package>databases/mysql50-server</package>
port. An associated variable,
<varname>WANT_MYSQL_VER</varname>, may be
set to values such as 323, 40, 41, 50, 51 or 60.</entry>
</row>
<row>
<entry><varname>USE_PGSQL</varname></entry>
<entry>If set to <literal>yes</literal>, add dependency on
<package>databases/postgresql82</package>
port. An associated variable,
<varname>WANT_PGSQL_VER</varname>, may be set to values such
as 73, 74, 80, 81, 82, or 83.</entry>
</row>
</tbody>
</tgroup>
</table>
</sect1>
<sect1 xml:id="rc-scripts">
<title>Starting and stopping services (rc scripts)</title>
<para><filename>rc.d</filename> scripts are used to start services on system
startup, and to give administrators a standard way of stopping,
starting and restarting the service. Ports integrate into
the system <filename>rc.d</filename> framework. Details on its usage
can be found in
<link xlink:href="&url.books.handbook;/configtuning-rcd.html">the rc.d Handbook
chapter</link>. Detailed explanation of available commands is
provided in
&man.rc.8; and &man.rc.subr.8;. Finally, there is
<link xlink:href="&url.articles.rc-scripting.en;">an article</link>
on practical aspects of <filename>rc.d</filename> scripting.</para>
<para>One or more rc scripts can be installed:</para>
<programlisting>USE_RC_SUBR= doormand</programlisting>
<para>Scripts must be placed in the <filename>files</filename>
subdirectory and a <literal>.in</literal> suffix must be added to their
filename. The only difference from a base system <filename>rc.d</filename> script is that the
<literal>.&nbsp;/etc/rc.subr</literal> line must be replaced with the
<literal>.&nbsp;%%RC_SUBR%%</literal>, because older versions of &os;
do not have an <filename>/etc/rc.subr</filename> file. Standard
<varname>SUB_LIST</varname> expansions are used too.
Use of the <literal>%%PREFIX%%</literal> and
<literal>%%LOCALBASE%%</literal> expansions is strongly encouraged as well.
More on
<varname>SUB_LIST</varname> in <link linkend="using-sub-files">the relevant section</link>.</para>
<para>Prior to &os;&nbsp;6.1-RELEASE, integration with &man.rcorder.8; is available by using
<varname>USE_RCORDER</varname> instead of
<varname>USE_RC_SUBR</varname>.
However, use of this method is deprecated.</para>
<para>As of &os;&nbsp;6.1-RELEASE, local <filename>rc.d</filename>
scripts (including those installed by ports) are included in
the overall &man.rcorder.8; of the base system.</para>
<para>Example simple <filename>rc.d</filename> script:</para>
<programlisting>#!/bin/sh
# PROVIDE: doormand
# REQUIRE: LOGIN
#
# Add the following lines to /etc/rc.conf.local or /etc/rc.conf
# to enable this service:
#
# doormand_enable (bool): Set to NO by default.
# Set it to YES to enable doormand.
# doormand_config (path): Set to %%PREFIX%%/etc/doormand/doormand.cf
# by default.
#
. %%RC_SUBR%%
name="doormand"
rcvar=${name}_enable
command=%%PREFIX%%/sbin/${name}
pidfile=/var/run/${name}.pid
load_rc_config $name
: ${doormand_enable="NO"}
: ${doormand_config="%%PREFIX%%/etc/doormand/doormand.cf"}
command_args="-p $pidfile -f $doormand_config"
run_rc_command "$1"</programlisting>
<para>The &quot;=&quot; style of default variable assignment
is preferable to the &quot;:=&quot; style here, since the
former sets a default value only if the variable is unset,
and the latter sets one if the variable is unset
<emphasis>or</emphasis> null.
A user might very well include something like
<programlisting>doormand_flags=""</programlisting> in their
<filename>rc.conf.local</filename> file, and a variable
substitution using &quot;:=&quot; would inappropriately
override the user's intention.</para>
<para>The suffix of the rc script is provided in
<varname>RC_SUBR_SUFFIX</varname> for further use in the port's
<filename>Makefile</filename>. Current versions of &os; do not add
any suffix to the script name, but older versions used to add
<filename>.sh</filename> suffix.</para>
<note>
<para>No new scripts should be added with the <filename>.sh</filename>
suffix. At some point there will be a mass repocopy of all the
scripts that still have that suffix.</para>
</note>
<sect2>
<title>Stopping services at deinstall</title>
<para>It is possible to have a service stopped automatically as part of
the deinstall routine. We advise using this feature only when it's
absolutely necessary to stop a service before it's files go
away. Usually, it's up to the administrator's discretion to decide,
whether to stop the service on deinstall or not. Also note this
affects upgrades, too.</para>
<para>Line like this goes to the <filename>pkg-plist</filename>:</para>
<programlisting>@stopdaemon doormand</programlisting>
<para>The argument must match the content of
<varname>USE_RC_SUBR</varname> variable.</para>
</sect2>
</sect1>
</chapter>
<chapter xml:id="plist">
<title>Advanced <filename>pkg-plist</filename> practices</title>
<sect1 xml:id="plist-sub">
<title>Changing <filename>pkg-plist</filename> based on make
variables</title>
<para>Some ports, particularly the <literal>p5-</literal> ports,
need to change their <filename>pkg-plist</filename> depending on
what options they are configured with (or version of
<literal>perl</literal>, in the case of <literal>p5-</literal>
ports). To make this easy, any instances in the
<filename>pkg-plist</filename> of <literal>%%OSREL%%</literal>,
<literal>%%PERL_VER%%</literal>, and
<literal>%%PERL_VERSION%%</literal> will be substituted for
appropriately. The value of <literal>%%OSREL%%</literal> is the
numeric revision of the operating system (e.g.,
<literal>4.9</literal>). <literal>%%PERL_VERSION%%</literal> is
the full version number of <command>perl</command> (e.g.,
<literal>5.00502</literal>) and <literal>%%PERL_VER%%</literal>
is the <command>perl</command> version number minus
the patchlevel (e.g., <literal>5.005</literal>). Several other
<literal>%%VARS%%</literal> related to
port's documentation files are described in <link linkend="install-documentation">the relevant section</link>.</para>
<para>If you need to make other substitutions, you can set the
<varname>PLIST_SUB</varname> variable with a list of
<literal>VAR=VALUE</literal>
pairs and instances of
<literal>%%VAR%%</literal> will be
substituted with <replaceable>VALUE</replaceable> in the
<filename>pkg-plist</filename>.</para>
<para>For instance, if you have a port that installs many files in a
version-specific subdirectory, you can put something like</para>
<programlisting>OCTAVE_VERSION= 2.0.13
PLIST_SUB= OCTAVE_VERSION=${OCTAVE_VERSION}</programlisting>
<para>in the <filename>Makefile</filename> and use
<literal>%%OCTAVE_VERSION%%</literal> wherever the version shows up
in <filename>pkg-plist</filename>. That way, when you upgrade the port,
you will not have to change dozens (or in some cases, hundreds) of
lines in the <filename>pkg-plist</filename>.</para>
<para>This substitution (as well as addition of any <link linkend="makefile-manpages">manual pages</link>) will be done between
the <buildtarget>pre-install</buildtarget> and
<buildtarget>do-install</buildtarget> targets, by reading from
<filename>PLIST</filename> and writing to
<filename>TMPPLIST</filename>
(default:
<filename>WRKDIR/.PLIST.mktmp</filename>). So if
your port builds <filename>PLIST</filename>
on the fly, do so in or
before <buildtarget>pre-install</buildtarget>. Also, if your port
needs to edit the resulting file, do so in
<buildtarget>post-install</buildtarget> to a file named
<filename>TMPPLIST</filename>.</para>
<para>Another possibility to modify port's packing list is based
on setting the variables <varname>PLIST_FILES</varname> and
<varname>PLIST_DIRS</varname>. The value of each variable
is regarded as a list of pathnames to
write to <filename>TMPPLIST</filename>
along with <filename>PLIST</filename>
contents. Names listed in <varname>PLIST_FILES</varname>
and <varname>PLIST_DIRS</varname> are subject to
<literal>%%VAR%%</literal>
substitution, as described above.
Except for that, names from <varname>PLIST_FILES</varname>
will appear in the final packing list unchanged,
while <literal>@dirrm</literal> will be
prepended to names from <varname>PLIST_DIRS</varname>.
To take effect, <varname>PLIST_FILES</varname> and
<varname>PLIST_DIRS</varname> must be set before
<filename>TMPPLIST</filename> is written,
i.e. in <buildtarget>pre-install</buildtarget> or earlier.</para>
</sect1>
<sect1 xml:id="plist-cleaning">
<title>Empty directories</title>
<sect2 xml:id="plist-dir-cleaning">
<title>Cleaning up empty directories</title>
<para>Do make your ports remove empty directories when they are
de-installed. This is usually accomplished by adding
<literal>@dirrm</literal> lines for all directories that are
specifically created by the port. You need to delete subdirectories
before you can delete parent directories.</para>
<programlisting> :
lib/X11/oneko/pixmaps/cat.xpm
lib/X11/oneko/sounds/cat.au
:
@dirrm lib/X11/oneko/pixmaps
@dirrm lib/X11/oneko/sounds
@dirrm lib/X11/oneko</programlisting>
<para>However, sometimes <literal>@dirrm</literal> will give you
errors because other ports share the same directory. You
can use <literal>@dirrmtry</literal> to
remove only empty directories without warning.</para>
<programlisting>@dirrmtry share/doc/gimp</programlisting>
<para>This will neither print any error messages nor cause
&man.pkg.delete.1; to exit abnormally even if
<filename>${PREFIX}/share/doc/gimp</filename> is not
empty due to other ports installing some files in there.</para>
</sect2>
<sect2 xml:id="plist-dir-empty">
<title>Creating empty directories</title>
<para>Empty directories created during port installation need special
attention. They will not get created when installing the package,
because packages only store the files, and &man.pkg.add.1; creates
directories for them as needed. To make sure the empty directory
is created when installing the package, add this line to
<filename>pkg-plist</filename> above the corresponding
<literal>@dirrm</literal> line:</para>
<programlisting>@exec mkdir -p %D/share/foo/templates</programlisting>
</sect2>
</sect1>
<sect1 xml:id="plist-config">
<title>Configuration files</title>
<para>If your port requires some configuration files in
<filename>PREFIX/etc</filename>, do
<emphasis>not</emphasis> just install them and list them in
<filename>pkg-plist</filename>. That will cause
&man.pkg.delete.1; to delete files carefully edited by
the user and a new installation to wipe them out.</para>
<para>Instead, install sample files with a suffix
(<filename>filename.sample</filename>
will work well). Copy the sample file as the real configuration
file, if it does not exist. On deinstall, delete the configuration
file, but only if it was not modified by the user. You need to
handle this both in the port <filename>Makefile</filename>, and in
the <filename>pkg-plist</filename> (for installation from
the package).</para>
<para>Example of the <filename>Makefile</filename> part:</para>
<programlisting>post-install:
@if [ ! -f ${PREFIX}/etc/orbit.conf ]; then \
${CP} -p ${PREFIX}/etc/orbit.conf.sample ${PREFIX}/etc/orbit.conf ; \
fi</programlisting>
<para>Example of the <filename>pkg-plist</filename> part:</para>
<programlisting>@unexec if cmp -s %D/etc/orbit.conf.sample %D/etc/orbit.conf; then rm -f %D/etc/orbit.conf; fi
etc/orbit.conf.sample
@exec if [ ! -f %D/etc/orbit.conf ] ; then cp -p %D/%F %B/orbit.conf; fi</programlisting>
<para>Alternatively, print out a <link linkend="porting-message">message</link> pointing out that the
user has to copy and edit the file before the software can be made
to work.</para>
</sect1>
<sect1 xml:id="plist-dynamic">
<title>Dynamic vs. static package list</title>
<para>A <emphasis>static package list</emphasis> is a package list
which is available in the Ports Collection either as a
<filename>pkg-plist</filename> file (with or without variable
substitution), or embedded into the <filename>Makefile</filename>
via <varname>PLIST_FILES</varname> and <varname>PLIST_DIRS</varname>.
Even if the contents are auto-generated by a tool or a target
in the Makefile <emphasis>before</emphasis> the inclusion into the
Ports Collection by a committer, this is still considered a
static list, since it is possible to examine it without having
to download or compile the distfile.</para>
<para>A <emphasis>dynamic package list</emphasis> is a package list
which is generated at the time the port is compiled based upon the
files and directories which are installed. It is not possible to
examine it before the source code of the ported application
is downloaded and compiled, or after running a <literal>make
clean</literal>.</para>
<para>While the use of dynamic package lists is not forbidden,
maintainers should use static package lists wherever possible, as it
enables users to &man.grep.1; through available ports to discover,
for example, which port installs a certain file. Dynamic lists
should be primarily used for
complex ports where the package list changes drastically based upon
optional features of the port (and thus maintaining a static package
list is infeasible), or ports which change the
package list based upon the version of dependent software used (e.g.
ports which generate docs with
<application>Javadoc</application>).</para>
<para>Maintainers who prefer dynamic package lists are encouraged to
add a new target to their port which generates the
<filename>pkg-plist</filename> file so that users may examine
the contents.</para>
</sect1>
<sect1 xml:id="plist-autoplist">
<title>自動產生 package list</title>
<para>首先,先確認您的 port 除了 <filename>pkg-plist</filename>
尚未搞定之外,其他都完成了。</para>
<para>接著,建立臨時目錄以供該 port 安裝,並且把所有相依套件都裝好
</para>
<screen>&prompt.root; <userinput>mkdir /var/tmp/$(make -V PORTNAME)</userinput>
&prompt.root; <userinput>mtree -U -f $(make -V MTREE_FILE) -d -e -p /var/tmp/$(make -V PORTNAME)</userinput>
&prompt.root; <userinput>make depends PREFIX=/var/tmp/$(make -V PORTNAME)</userinput></screen>
<para>把這目錄架構存到新檔案。</para>
<screen>&prompt.root; <userinput>(cd /var/tmp/$(make -V PORTNAME) &amp;&amp; find -d * -type d) | sort &gt; OLD-DIRS</userinput></screen>
<para>新增空的 <filename>pkg-plist</filename> 檔案:</para>
<screen>&prompt.root; <userinput>:&gt;pkg-plist</userinput></screen>
<para>若該 port 有遵循 <varname>PREFIX</varname>(也應該要遵循)
接著就可以安裝該 port 並產生檔案清單。</para>
<screen>&prompt.root; <userinput>make install PREFIX=/var/tmp/$(make -V PORTNAME)</userinput>
&prompt.root; <userinput>(cd /var/tmp/$(make -V PORTNAME) &amp;&amp; find -d * \! -type d) | sort &gt; pkg-plist</userinput></screen>
<para>這時要記得把新建的目錄,也加到檔案清單內。</para>
<screen>&prompt.root; <userinput>(cd /var/tmp/$(make -V PORTNAME) &amp;&amp; find -d * -type d) | sort | comm -13 OLD-DIRS - | sort -r | sed -e 's#^#@dirrm #' &gt;&gt; pkg-plist</userinput></screen>
<para>最後您應該手動整理檔案清單這不是全部自動化處理的。Man page 則應該利用 <varname>MAN<replaceable>n</replaceable></varname> 的方式
寫在 port 的 <filename>Makefile</filename> 而不是寫在檔案清單中。
使用者設定檔應該移除,或更名為<filename>filename.sample</filename>
The <filename>info/dir</filename> file should not be listed
and appropriate <filename>install-info</filename> lines should
be added as noted in the <link linkend="makefile-info">info
files</link> section. Any
libraries installed by the port should be listed as specified in the
<link linkend="porting-shlibs">shared libraries</link> section.</para>
<para>Alternatively, use the <command>plist</command> script in
<filename>/usr/ports/Tools/scripts/</filename> to build the
package list automatically. The first step is the same as
above: take the first three lines, that is,
<command>mkdir</command>, <command>mtree</command> and
<command>make depends</command>. Then build and install the
port:</para>
<screen>&prompt.root; <userinput>make install PREFIX=/var/tmp/port-name</userinput></screen>
<para>And let <command>plist</command> create the
<filename>pkg-plist</filename> file:</para>
<screen>&prompt.root; <userinput>/usr/ports/Tools/scripts/plist -Md -m /etc/mtree/BSD.port-type.dist /var/tmp/port-name &gt; pkg-plist</userinput></screen>
<para>The packing list still has to be tidied up by hand as
stated above.</para>
</sect1>
</chapter>
<chapter xml:id="pkg-files">
<title>The <filename>pkg-*</filename> files</title>
<para>There are some tricks we have not mentioned yet about the
<filename>pkg-*</filename> files
that come in handy sometimes.</para>
<sect1 xml:id="porting-message">
<title><filename>pkg-message</filename></title>
<para>If you need to display a message to the installer, you may place
the message in <filename>pkg-message</filename>. This capability is
often useful to display additional installation steps to be taken
after a &man.pkg.add.1; or to display licensing
information.</para>
<para>When some lines about the build-time knobs or warnings
have to be displayed, use <varname>ECHO_MSG</varname>. The
<filename>pkg-message</filename> file is only for
post-installation steps. Likewise, the distinction between
<varname>ECHO_MSG</varname> and <varname>ECHO_CMD</varname>
should be kept in mind. The former is for printing
informational text to the screen, while the latter is for
command pipelining.</para>
<para>A good example for both can be found in
<filename>shells/bash2/Makefile</filename>:</para>
<programlisting>update-etc-shells:
@${ECHO_MSG} "updating /etc/shells"
@${CP} /etc/shells /etc/shells.bak
@( ${GREP} -v ${PREFIX}/bin/bash /etc/shells.bak; \
${ECHO_CMD} ${PREFIX}/bin/bash) &gt;/etc/shells
@${RM} /etc/shells.bak</programlisting>
<note>
<para>The <filename>pkg-message</filename> file does not need to be
added to <filename>pkg-plist</filename>. Also, it will not get
automatically printed if the user is using the port, not the
package, so you should probably display it from the
<buildtarget>post-install</buildtarget> target yourself.</para>
</note>
</sect1>
<sect1 xml:id="pkg-install">
<title><filename>pkg-install</filename></title>
<para>If your port needs to execute commands when the binary package
is installed with &man.pkg.add.1; you can do this via the
<filename>pkg-install</filename> script. This script will
automatically be added to the package, and will be run twice by
&man.pkg.add.1;: the first time as
<literal>&dollar;{SH} pkg-install &dollar;{PKGNAME}
PRE-INSTALL</literal> and the second time as
<literal>&dollar;{SH} pkg-install &dollar;{PKGNAME} POST-INSTALL</literal>.
<literal>&dollar;2</literal> can be tested to determine which mode
the script is being run in. The <envar>PKG_PREFIX</envar>
environmental variable will be set to the package installation
directory. See &man.pkg.add.1; for
additional information.</para>
<note>
<para>This script is not run automatically if you install the port
with <command>make install</command>. If you are depending on it
being run, you will have to explicitly call it from your port's
<filename>Makefile</filename>, with a line like
<literal>PKG_PREFIX=&dollar;{PREFIX} &dollar;{SH} &dollar;{PKGINSTALL}
&dollar;{PKGNAME} PRE-INSTALL</literal>.</para>
</note>
</sect1>
<sect1 xml:id="pkg-deinstall">
<title><filename>pkg-deinstall</filename></title>
<para>This script executes when a package is removed.</para>
<para>
This script will be run twice by &man.pkg.delete.1;.
The first time as <literal>&dollar;{SH} pkg-deinstall &dollar;{PKGNAME}
DEINSTALL</literal> and the second time as
<literal>&dollar;{SH} pkg-deinstall &dollar;{PKGNAME} POST-DEINSTALL</literal>.
</para>
</sect1>
<sect1 xml:id="pkg-req">
<title><filename>pkg-req</filename></title>
<para>If your port needs to determine if it should install or not, you
can create a <filename>pkg-req</filename> <quote>requirements</quote>
script. It will be invoked automatically at
installation/de-installation time to determine whether or not
installation/de-installation should proceed.</para>
<para>The script will be run at installation time by
&man.pkg.add.1; as
<literal>pkg-req &dollar;{PKGNAME} INSTALL</literal>.
At de-installation time it will be run by
&man.pkg.delete.1; as
<literal>pkg-req &dollar;{PKGNAME} DEINSTALL</literal>.</para>
</sect1>
<sect1 xml:id="pkg-names">
<title xml:id="porting-pkgfiles">Changing the names of
<filename>pkg-*</filename> files</title>
<para>All the names of <filename>pkg-*</filename> files
are defined using variables so you can change them in your
<filename>Makefile</filename> if need be. This is especially useful
when you are sharing the same <filename>pkg-*</filename> files
among several ports or have to write to one of the above files (see
<link linkend="porting-wrkdir">writing to places other than
<varname>WRKDIR</varname></link> for why it is a bad idea to write
directly into the <filename>pkg-*</filename> subdirectory).</para>
<para>Here is a list of variable names and their default
values. (<varname>PKGDIR</varname> defaults to
<varname>${MASTERDIR}</varname>.)</para>
<informaltable frame="none" pgwide="1">
<tgroup cols="2">
<thead>
<row>
<entry>Variable</entry>
<entry>Default value</entry>
</row>
</thead>
<tbody>
<row>
<entry><varname>DESCR</varname></entry>
<entry><literal>${PKGDIR}/pkg-descr</literal></entry>
</row>
<row>
<entry><varname>PLIST</varname></entry>
<entry><literal>${PKGDIR}/pkg-plist</literal></entry>
</row>
<row>
<entry><varname>PKGINSTALL</varname></entry>
<entry><literal>${PKGDIR}/pkg-install</literal></entry>
</row>
<row>
<entry><varname>PKGDEINSTALL</varname></entry>
<entry><literal>${PKGDIR}/pkg-deinstall</literal></entry>
</row>
<row>
<entry><varname>PKGREQ</varname></entry>
<entry><literal>${PKGDIR}/pkg-req</literal></entry>
</row>
<row>
<entry><varname>PKGMESSAGE</varname></entry>
<entry><literal>${PKGDIR}/pkg-message</literal></entry>
</row>
</tbody>
</tgroup>
</informaltable>
<para>Please change these variables rather than overriding
<varname>PKG_ARGS</varname>. If you change
<varname>PKG_ARGS</varname>, those files will not correctly be
installed in <filename>/var/db/pkg</filename> upon install from a
port.</para>
</sect1>
<sect1 xml:id="using-sub-files">
<title>Making use of <varname>SUB_FILES</varname> and
<varname>SUB_LIST</varname></title>
<para>The <varname>SUB_FILES</varname> and <varname>SUB_LIST</varname>
variables are useful for dynamic values in port files, such as the
installation <varname>PREFIX</varname> in
<filename>pkg-message</filename>.</para>
<para>The <varname>SUB_FILES</varname> variable specifies a list
of files to be automatically modified. Each
<replaceable>file</replaceable> in the
<varname>SUB_FILES</varname> list must have a corresponding
<filename>file.in</filename> present
in <varname>FILESDIR</varname>. A modified version will
be created in <varname>WRKDIR</varname>. Files defined as a
value of <varname>USE_RC_SUBR</varname> (or the deprecated
<varname>USE_RCORDER</varname>)
are automatically added to the
<varname>SUB_FILES</varname>. For the files
<filename>pkg-message</filename>,
<filename>pkg-install</filename>, <filename>pkg-deinstall</filename>
and <filename>pkg-reg</filename>, the corresponding Makefile variable
is automatically set to point to the processed version.</para>
<para>The <varname>SUB_LIST</varname> variable is a list of
<literal>VAR=VALUE</literal> pairs. For each pair
<literal>%%VAR%%</literal> will get replaced
with <literal>VALUE</literal> in each file listed in
<varname>SUB_FILES</varname>. Several common pairs are
automatically defined: <varname>PREFIX</varname>,
<varname>LOCALBASE</varname>,
<varname>DATADIR</varname>, <varname>DOCSDIR</varname>,
<varname>EXAMPLESDIR</varname>. Any line beginning with
<literal>@comment</literal> will be deleted from resulting files
after a variable substitution.</para>
<para>The following example will replace <literal>%%ARCH%%</literal>
with the system architecture
in a <filename>pkg-message</filename>:</para>
<programlisting>SUB_FILES= pkg-message
SUB_LIST= ARCH=${ARCH}</programlisting>
<para>Note that for this example, the
<filename>pkg-message.in</filename> file must exist in
<varname>FILESDIR</varname>.</para>
<para>Example of a good <filename>pkg-message.in</filename>:</para>
<programlisting>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.</programlisting>
</sect1>
</chapter>
<chapter xml:id="testing">
<title>Testing your port</title>
<sect1 xml:id="make-describe">
<title>Running <command>make describe</command></title>
<para>Several of the &os; port maintenance tools, such as
&man.portupgrade.1;, rely on a database called
<filename>/usr/ports/INDEX</filename> which keeps track of such
items as port dependencies. <filename>INDEX</filename> is created
by the top-level <filename>ports/Makefile</filename> via
<command>make index</command>, which descends into each
port subdirectory and executes <command>make describe</command>
there. Thus, if <command>make describe</command> fails in any
port, no one can generate <filename>INDEX</filename>, and many
people will quickly become unhappy.</para>
<note>
<para>It is important to be able to generate this file no
matter what options are present in <filename>make.conf</filename>,
so please avoid doing things such as using <literal>.error</literal>
statements when (for instance) a dependency is not satisfied.
(See <xref linkend="dads-dot-error"/>.)</para>
</note>
<para>If <command>make describe</command> produces a string
rather than an error message, you are probably safe. See
<filename>bsd.port.mk</filename> for the meaning of the
string produced.</para>
<para>Also note that running a recent version of
<command>portlint</command> (as specified in the next section)
will cause <command>make describe</command> to be run
automatically.</para>
</sect1>
<sect1 xml:id="testing-portlint">
<title>Portlint</title>
<para>Do check your work with <link linkend="porting-portlint"><command>portlint</command></link>
before you submit or commit it. <command>portlint</command>
warns you about many common errors, both functional and
stylistic. For a new (or repocopied) port,
<command>portlint -A</command> is the most thorough; for an
existing port, <command>portlint -C</command> is sufficient.</para>
<para>Since <command>portlint</command> uses heuristics to
try to figure out errors, it can produce false positive
warnings. In addition, occasionally something that is
flagged as a problem really cannot be done in any other
way due to limitations in the ports framework. When in
doubt, the best thing to do is ask on &a.ports;.</para>
</sect1>
<sect1 xml:id="testing-porttools">
<title>Port Tools</title>
<para>The <package>ports-mgmt/porttools</package>
program is part of the Ports Collection.</para>
<para><command>port</command> is the front-end script,
which can help you simplify the testing job. Whenever you want
to test a new port or update an existing one, you can use
<command>port test</command> to test your port, including the
<link linkend="testing-portlint"><command>portlint</command></link>
checking. This command also detects and lists any files that
are not listed in <filename>pkg-plist</filename>. See the
following example:</para>
<screen>&prompt.root; <userinput>port test /usr/ports/net/csup</userinput></screen>
</sect1>
<sect1 xml:id="porting-prefix">
<title><varname>PREFIX</varname> 以及 <varname>DESTDIR</varname></title>
<para><varname>PREFIX</varname> 變數會決定該 port 所會安裝的位置,
通常是 <filename>/usr/local</filename><filename>/opt</filename>
。 使用者可以藉由設定 <varname>PREFIX</varname> 決定要裝在哪邊,
而你所維護的 port 必須遵循該規則。</para>
<para>若使用者有設定 <varname>DESTDIR</varname> 變數,
那麼它會採用所設定的環境,通常可能是 jail 環境或者是並非掛載於
<filename>/</filename> 上的系統。 通常 port 會裝在
<varname>DESTDIR</varname>/<varname>PREFIX</varname> 底下,
並且會紀錄在 <varname>DESTDIR</varname>/var/db/pkg 內的套件資料庫。
由於事實上 <varname>DESTDIR</varname> 會由 ports 架構透過
&man.chroot.8; 來自動處理,所以您不需去作相關修改或刻意維護
<varname>DESTDIR</varname> 相容的 ports。</para>
<para><varname>PREFIX</varname> 變數若無特別設定,會與
<varname>LOCALBASE</varname> 相同 (預設為
<filename>/usr/local</filename>)。 若有設定
<varname>USE_LINUX_PREFIX</varname>
那麼 <varname>PREFIX</varname> 則為 <varname>LINUXBASE</varname> (
預設為 <filename>/compat/linux</filename>)。</para>
<para>Avoiding the hard-coding of <filename>/usr/local</filename> or
<filename>/usr/X11R6</filename> anywhere in the source will make the
port much more flexible and able to cater to the needs of other
sites. For X ports that use <command>imake</command>, this is
automatic; otherwise, this can often be done by simply replacing the
occurrences of <filename>/usr/local</filename> (or
<filename>/usr/X11R6</filename> for X ports that do not use imake)
in the various <filename>Makefile</filename>s in the port to read
<varname>${PREFIX}</varname>, as this variable is automatically passed
down to every stage of the build and install processes.</para>
<para>Make sure your application is not installing things in
<filename>/usr/local</filename> instead of <varname>PREFIX</varname>.
A quick test for this is to do this is:</para>
<screen>&prompt.root; <userinput>make clean; make package PREFIX=/var/tmp/port-name</userinput></screen>
<para>If anything is installed outside of <varname>PREFIX</varname>,
the package creation process will complain that it
cannot find the files.</para>
<!-- XXX This paragraph is confusing and poorly indented. -->
<para>This does not test for the existence of internal references,
or correct use of <varname>LOCALBASE</varname> for references to
files from other ports. Testing the installation in
<filename>/var/tmp/port-name</filename>
to do that while you have it installed would do that.</para>
<para>The variable <varname>PREFIX</varname> can be reassigned in your
<filename>Makefile</filename> or in the user's environment.
However, it is strongly discouraged for individual ports to set this
variable explicitly in the <filename>Makefile</filename>s.</para>
<para>Also, refer to programs/files from other ports with the
variables mentioned above, not explicit pathnames. For instance, if
your port requires a macro <literal>PAGER</literal> to be the full
pathname of <command>less</command>, use the compiler flag:
<programlisting>-DPAGER=\"&dollar;{LOCALBASE}/bin/less\"</programlisting>
instead of
<literal>-DPAGER=\"/usr/local/bin/less\"</literal>. This way it will
have a better chance of working if the system administrator has
moved the whole <filename>/usr/local</filename> tree somewhere else.</para>
</sect1>
<sect1 xml:id="testing-tinderbox">
<title>Tinderbox</title>
<para>If you're an avid ports contributor, you might want to take a
look at <application>Tinderbox</application>. It is a powerful
system for building and testing ports based on the scripts used on
<link linkend="build-cluster">Pointyhat</link>. You can install
<application>Tinderbox</application> using
<package>ports-mgmt/tinderbox</package> port. Be sure
to read supplied documentation since the configuration is not
trivial.</para>
<para>Visit the <link xlink:href="http://tinderbox.marcuscom.com/">Tinderbox website</link>
for more details.</para>
</sect1>
</chapter>
<chapter xml:id="port-upgrading">
<title>Upgrading</title>
<para>When you notice that a port is out of date compared to the latest
version from the original authors, you should first ensure that you
have the latest
port. You can find them in the
<filename>ports/ports-current</filename> directory of the &os; FTP mirror
sites. However, if you are working with more than a few
ports, you will probably find it easier to use
<application>CVSup</application> to keep your whole ports collection
up-to-date, as described in the
<link xlink:href="&url.books.handbook;/synching.html#CVSUP-CONFIG">Handbook</link>.
This will have the added benefit of tracking all the ports'
dependencies.</para>
<para>The next step is to see if there is an update already pending.
To do this, you have two options. There is a searchable interface
to the
<link xlink:href="http://www.FreeBSD.org/cgi/query-pr-summary.cgi?query">
FreeBSD Problem Report (PR) database</link> (also known as
<literal>GNATS</literal>). Select <literal>ports</literal> in the
dropdown, and enter the name of the port.</para>
<para>However, sometimes people forget to put the name of the port
into the Synopsis field in an unambiguous fashion. In that case,
you can try the <link linkend="portsmon">
FreeBSD Ports Monitoring System</link> (also known as
<literal>portsmon</literal>). This system attempts to classify
port PRs by portname. To search for PRs about a particular port,
use the <link xlink:href="http://portsmon.FreeBSD.org/portoverview.py">
Overview of One Port</link>.</para>
<para>If there is no pending PR, the next step is to send an email
to the port's maintainer, as shown by
<command>make maintainer</command>. That person may
already be working on an upgrade, or have a reason to not upgrade the
port right now (because of, for example, stability problems of the new
version); you would not want to duplicate their work. Note that
unmaintained ports are listed with a maintainer of
<literal>ports@FreeBSD.org</literal>, which is just the general
ports mailing list, so sending mail there
probably will not help in this case.</para>
<para>If the maintainer asks you to do the upgrade or there is
no maintainer, then you have a chance to help out &os; by
preparing the update yourself! Please make the changes and save
the result of the
recursive <command>diff</command> output
of the new and old
ports directories (e.g., if your modified port directory is
called <filename>superedit</filename> and the original is in our tree
as <filename>superedit.bak</filename>, then save the result of
<command>diff -ruN superedit.bak superedit</command>). Either
unified or context diff is fine, but port committers generally
prefer unified diffs. Note the use of the <literal>-N</literal>
option&mdash;this is the accepted way to force diff to properly
deal with the case of new files being added or old files being
deleted. Before sending us the diff, please examine the
output to make sure all the changes make sense. To
simplify common operations with patch files, you can use
<filename>/usr/ports/Tools/scripts/patchtool.py</filename>.
Before using it, please read
<filename>/usr/ports/Tools/scripts/README.patchtool</filename>.</para>
<para>If the port is unmaintained, and you are actively using
it yourself, please consider volunteering to become its
maintainer. &os; has over 2000 ports without maintainers,
and this is an area where more volunteers are always needed.
(For a detailed description of the responsibilities of maintainers,
refer to the section in the
<link xlink:href="&url.books.developers-handbook;/policies.html#POLICIES-MAINTAINER">
Developer's Handbook</link>.)</para>
<para>最好的方式是使用 &man.send-pr.1; 並附上 diff 一併回報(類別請選
<literal>ports</literal>)。 若你是該 port 的維護者,請記得在 synopsis
那行的開頭註明 <literal>[maintainer update]</literal>,並且在 PR 的
<quote>Class</quote> 分類填上 <literal>maintainer-update</literal>
否則,該 PR 的 <quote>Class</quote> 處就是填
<literal>change-request</literal>
Please mention any added or
deleted files in the message, as they have to be explicitly specified
to &man.cvs.1; when doing a commit. If the diff is more than about 20KB,
please compress and uuencode it; otherwise, just include it in the PR
as is.</para>
<para>Before you &man.send-pr.1;, you should review the
<link xlink:href="&url.articles.problem-reports;/pr-writing.html">
Writing the problem report</link> section in the Problem
Reports article; it contains far more information about how to write
useful problem reports.</para>
<important>
<para>If your upgrade is motivated by security concerns or a
serious fault in the currently committed port, please notify
the &a.portmgr; to request immediate rebuilding and
redistribution of your port's package. Unsuspecting users
of &man.pkg.add.1; will otherwise continue to install the
old version via <command>pkg_add -r</command> for several
weeks.</para>
</important>
<note>
<para>Once again, please use &man.diff.1; and not &man.shar.1; to send
updates to existing ports!</para>
</note>
<para>Now that you have done all that, you will want to read about
how to keep up-to-date in <xref linkend="keeping-up"/>.</para>
</chapter>
<chapter xml:id="security">
<title>Ports security</title>
<sect1 xml:id="security-intro">
<title>Why security is so important</title>
<para>Bugs are occasionally introduced to the software.
Arguably, the most dangerous of them are those opening
security vulnerabilities. From the technical viewpoint,
such vulnerabilities are to be closed by exterminating
the bugs that caused them. However, the policies for
handling mere bugs and security vulnerabilities are
very different.</para>
<para>A typical small bug affects only those users who have
enabled some combination of options triggering the bug.
The developer will eventually release a patch followed
by a new version of the software, free of the bug, but
the majority of users will not take the trouble of upgrading
immediately because the bug has never vexed them. A
critical bug that may cause data loss represents a graver
issue. Nevertheless, prudent users know that a lot of
possible accidents, besides software bugs, are likely to
lead to data loss, and so they make backups of important
data; in addition, a critical bug will be discovered
really soon.</para>
<para>A security vulnerability is all different. First,
it may remain unnoticed for years because often it does
not cause software malfunction. Second, a malicious party
can use it to gain unauthorized access to a vulnerable
system, to destroy or alter sensitive data; and in the
worst case the user will not even notice the harm caused.
Third, exposing a vulnerable system often assists attackers
to break into other systems that could not be compromised
otherwise. Therefore closing a vulnerability alone is
not enough: the audience should be notified of it in most
clear and comprehensive manner, which will allow to
evaluate the danger and take appropriate actions.</para>
</sect1>
<sect1 xml:id="security-fix">
<title>Fixing security vulnerabilities</title>
<para>While on the subject of ports and packages, a security
vulnerability may initially appear in the original
distribution or in the port files. In the former case,
the original software developer is likely to release a
patch or a new version instantly, and you will
only need to update the port promptly with respect to
the author's fix. If the fix is delayed for some reason,
you should either <link linkend="dads-noinstall">mark the port as
<varname>FORBIDDEN</varname></link>
or introduce a patch file of your own to the port. In
the case of a vulnerable port, just fix the port as soon as
possible. In either case, <link linkend="port-upgrading">the
standard procedure for submitting your change</link> should
be followed unless you have rights to commit it directly
to the ports tree.</para>
<important>
<para>Being a ports committer is not enough to commit to
an arbitrary port. Remember that ports usually have
maintainers, whom you should respect.</para>
</important>
<para>Please make sure that the port's revision is bumped
as soon as the vulnerability has been closed.
That is how the users who upgrade installed packages
on a regular basis will see they need to run an update.
Besides, a new package will be built and distributed
over FTP and WWW mirrors, replacing the vulnerable one.
<varname>PORTREVISION</varname> should be bumped unless
<varname>PORTVERSION</varname> has changed in the course
of correcting the vulnerability. That is you should
bump <varname>PORTREVISION</varname> if you have added a
patch file to the port, but you should not if you have updated
the port to the latest software version and thus already
touched <varname>PORTVERSION</varname>. Please refer to the
<link linkend="makefile-naming-revepoch">corresponding section</link>
for more information.</para>
</sect1>
<sect1 xml:id="security-notify">
<title>Keeping the community informed</title>
<sect2 xml:id="security-notify-vuxml-db">
<title>The VuXML database</title>
<para>A very important and urgent step to take as early as
a security vulnerability is discovered is to notify the
community of port users about the jeopardy. Such
notification serves two purposes. First, should the danger
be really severe, it will be wise to apply an instant workaround,
e.g., stop the affected network service or even deinstall
the port completely, until the vulnerability is closed.
Second, a lot of users tend to upgrade installed packages
just occasionally. They will know from the notification
that they <emphasis>must</emphasis> update the package
without delay as soon as a corrected version is available.</para>
<para>Given the huge number of ports in the tree,
a security advisory cannot be issued on each incident
without creating a flood and losing the attention of
the audience by the time it comes to really serious
matters. Therefore security vulnerabilities found in
ports are recorded in <link xlink:href="http://vuxml.freebsd.org/">the FreeBSD VuXML
database</link>. The Security Officer Team members
are monitoring it for issues requiring their
intervention.</para>
<para>If you have committer rights, you can update the VuXML
database by yourself. So you will both help the Security
Officer Team and deliver the crucial information to the
community earlier. However, if you are not a committer,
or you believe you have found an exceptionally severe
vulnerability, or whatever, please do not hesitate to
contact the Security Officer Team directly as described
on the <link xlink:href="http://www.freebsd.org/security/#how">FreeBSD
Security Information</link> page.</para>
<para>All right, you elected the hard way. As it may be obvious
from its title, the VuXML database is essentially an
XML document. Its source file <filename>vuln.xml</filename>
is kept right inside the port <package>security/vuxml</package>. Therefore
the file's full pathname will be
<filename>PORTSDIR/security/vuxml/vuln.xml</filename>.
Each time you discover a security vulnerability in a
port, please add an entry for it to that file.
Until you are familiar with VuXML, the best thing you can
do is to find an existing entry fitting your case, then copy
it and use as a template.</para>
</sect2>
<sect2 xml:id="security-notify-vuxml-intro">
<title>A short introduction to VuXML</title>
<para>The full-blown XML is complex and far beyond the scope of
this book. However, to gain basic insight on the structure
of a VuXML entry, you need only the notion of tags. XML
tag names are enclosed in angle brackets. Each opening
&lt;tag&gt; must have a matching closing &lt;/tag&gt;.
Tags may be nested. If nesting, the inner tags must be
closed before the outer ones. There is a hierarchy of
tags, i.e. more complex rules of nesting them. Sounds
very similar to HTML, doesn't it? The major difference
is that XML is e<emphasis>X</emphasis>tensible, i.e. based
on defining custom tags. Due to its intrinsic structure,
XML puts otherwise amorphous data into shape. VuXML is
particularly tailored to mark up descriptions of security
vulnerabilities.</para>
<para>Now let's consider a realistic VuXML entry:</para>
<programlisting>&lt;vuln vid="f4bc80f4-da62-11d8-90ea-0004ac98a7b9"&gt; <co xml:id="co-vx-vid"/>
&lt;topic&gt;Several vulnerabilities found in Foo&lt;/topic&gt; <co xml:id="co-vx-top"/>
&lt;affects&gt;
&lt;package&gt;
&lt;name&gt;foo&lt;/name&gt; <co xml:id="co-vx-nam"/>
&lt;name&gt;foo-devel&lt;/name&gt;
&lt;name&gt;ja-foo&lt;/name&gt;
&lt;range&gt;&lt;ge&gt;1.6&lt;/ge&gt;&lt;lt&gt;1.9&lt;/lt&gt;&lt;/range&gt; <co xml:id="co-vx-rng"/>
&lt;range&gt;&lt;ge&gt;2.*&lt;/ge&gt;&lt;lt&gt;2.4_1&lt;/lt&gt;&lt;/range&gt;
&lt;range&gt;&lt;eq&gt;3.0b1&lt;/eq&gt;&lt;/range&gt;
&lt;/package&gt;
&lt;package&gt;
&lt;name&gt;openfoo&lt;/name&gt; <co xml:id="co-vx-nm2"/>
&lt;range&gt;&lt;lt&gt;1.10_7&lt;/lt&gt;&lt;/range&gt; <co xml:id="co-vx-epo"/>
&lt;range&gt;&lt;ge&gt;1.2,1&lt;/ge&gt;&lt;lt&gt;1.3_1,1&lt;/lt&gt;&lt;/range&gt;
&lt;/package&gt;
&lt;/affects&gt;
&lt;description&gt;
&lt;body xmlns="http://www.w3.org/1999/xhtml"&gt;
&lt;p&gt;J. Random Hacker reports:&lt;/p&gt; <co xml:id="co-vx-bdy"/>
&lt;blockquote
cite="http://j.r.hacker.com/advisories/1"&gt;
&lt;p&gt;Several issues in the Foo software may be exploited
via carefully crafted QUUX requests. These requests will
permit the injection of Bar code, mumble theft, and the
readability of the Foo administrator account.&lt;/p&gt;
&lt;/blockquote&gt;
&lt;/body&gt;
&lt;/description&gt;
&lt;references&gt; <co xml:id="co-vx-ref"/>
&lt;freebsdsa&gt;SA-10:75.foo&lt;/freebsdsa&gt; <co xml:id="co-vx-fsa"/>
&lt;freebsdpr&gt;ports/987654&lt;/freebsdpr&gt; <co xml:id="co-vx-fpr"/>
&lt;cvename&gt;CAN-2010-0201&lt;/cvename&gt; <co xml:id="co-vx-cve"/>
&lt;cvename&gt;CAN-2010-0466&lt;/cvename&gt;
&lt;bid&gt;96298&lt;/bid&gt; <co xml:id="co-vx-bid"/>
&lt;certsa&gt;CA-2010-99&lt;/certsa&gt; <co xml:id="co-vx-cts"/>
&lt;certvu&gt;740169&lt;/certvu&gt; <co xml:id="co-vx-ctv"/>
&lt;uscertsa&gt;SA10-99A&lt;/uscertsa&gt; <co xml:id="co-vx-ucs"/>
&lt;uscertta&gt;SA10-99A&lt;/uscertta&gt; <co xml:id="co-vx-uct"/>
&lt;mlist msgid="201075606@hacker.com"&gt;http://marc.theaimsgroup.com/?l=bugtraq&amp;amp;m=203886607825605&lt;/mlist&gt; <co xml:id="co-vx-mls"/>
&lt;url&gt;http://j.r.hacker.com/advisories/1&lt;/url&gt; <co xml:id="co-vx-url"/>
&lt;/references&gt;
&lt;dates&gt;
&lt;discovery&gt;2010-05-25&lt;/discovery&gt; <co xml:id="co-vx-dsc"/>
&lt;entry&gt;2010-07-13&lt;/entry&gt; <co xml:id="co-vx-ent"/>
&lt;modified&gt;2010-09-17&lt;/entry&gt; <co xml:id="co-vx-mod"/>
&lt;/dates&gt;
&lt;/vuln&gt;</programlisting>
<para>The tag names are supposed to be self-descriptive,
so we shall take a closer look only at fields you will need
to fill in by yourself:</para>
<calloutlist>
<callout arearefs="co-vx-vid">
<para>This is the top-level tag of a VuXML entry. It has
a mandatory attribute, <literal>vid</literal>,
specifying a universally unique identifier (UUID) for
this entry (in quotes). You should generate a UUID
for each new VuXML entry (and do not forget to substitute
it for the template UUID unless you are writing the
entry from scratch). You can use &man.uuidgen.1; to
generate a VuXML UUID; alternatively, if you are using
FreeBSD 4.x, you may install the port <package>devel/p5-Data-UUID</package> and issue
the following command:</para>
<programlisting>perl -MData::UUID -le 'print lc new Data::UUID-&gt;create_str'</programlisting>
</callout>
<callout arearefs="co-vx-top">
<para>This is a one-line description of the issue found.</para>
</callout>
<callout arearefs="co-vx-nam">
<para>The names of packages affected are listed there.
Multiple names can be given since several packages may be
based on a single master port or software product. This
may include stable and development branches, localized
versions, and slave ports featuring different choices of
important build-time configuration options.</para>
<important>
<para>It is your responsibility to find all such related
packages when writing a VuXML entry. Keep in mind that
<literal>make search name=foo</literal> is your friend.
The primary points to look for are as follows:</para>
<itemizedlist>
<listitem>
<para>the <filename>foo-devel</filename> variant
for a <filename>foo</filename> port;</para>
</listitem>
<listitem>
<para>other variants with a suffix like
<literal>-a4</literal> (for print-related packages),
<literal>-without-gui</literal> (for packages with X
support disabled), or similar;</para>
</listitem>
<listitem>
<para><literal>jp-</literal>, <literal>ru-</literal>,
<literal>zh-</literal>, and other possible localized
variants in the corresponding national categories of
the ports collection.</para>
</listitem>
</itemizedlist>
</important>
</callout>
<callout arearefs="co-vx-rng">
<para>Affected versions of the package(s) are specified
there as one or more ranges using a combination of
<literal>&lt;lt&gt;</literal>, <literal>&lt;le&gt;</literal>,
<literal>&lt;eq&gt;</literal>, <literal>&lt;ge&gt;</literal>,
and <literal>&lt;gt&gt;</literal> elements. The
version ranges given should not overlap.</para>
<para>In a range specification, <literal>*</literal> (asterisk)
denotes the smallest version number. In particular,
<literal>2.*</literal> is less than <literal>2.a</literal>.
Therefore an asterisk may be used for a range to match all
possible <literal>alpha</literal>, <literal>beta</literal>,
and <literal>RC</literal> versions. For instance,
<literal>&lt;ge&gt;2.*&lt;/ge&gt;&lt;lt&gt;3.*&lt;/lt&gt;</literal>
will selectively match every <literal>2.x</literal> version while
<literal>&lt;ge&gt;2.0&lt;/ge&gt;&lt;lt&gt;3.0&lt;/lt&gt;</literal>
will obviously not since the latter misses
<literal>2.r3</literal> and matches
<literal>3.b</literal>.</para>
<para>The above example
specifies that affected are versions from <literal>1.6</literal>
to <literal>1.9</literal> inclusive, versions
<literal>2.x</literal> before <literal>2.4_1</literal>,
and version <literal>3.0b1</literal>.</para>
</callout>
<callout arearefs="co-vx-nm2">
<para>Several related package groups (essentially, ports)
can be listed in the <literal>&lt;affected&gt;</literal>
section. This can be used if several software products
(say FooBar, FreeBar and OpenBar) grow from the same code base
and still share its bugs and vulnerabilities. Note the
difference from listing multiple names within a single
&lt;package&gt; section.</para>
</callout>
<callout arearefs="co-vx-epo">
<para>The version ranges should allow for
<varname>PORTEPOCH</varname> and
<varname>PORTREVISION</varname> if applicable.
Please remember that according to the collation rules,
a version with a non-zero <varname>PORTEPOCH</varname> is
greater than any version without
<varname>PORTEPOCH</varname>, e.g., <literal>3.0,1</literal>
is greater than <literal>3.1</literal> or even than
<literal>8.9</literal>.</para>
</callout>
<callout arearefs="co-vx-bdy">
<para>This is a summary of the issue.
XHTML is used in this field. At least enclosing
<literal>&lt;p&gt;</literal> and <literal>&lt;/p&gt;</literal>
should appear. More complex mark-up may be used, but only for
the sake of accuracy and clarity: No eye candy please.</para>
</callout>
<callout arearefs="co-vx-ref">
<para>This section contains references to relevant documents.
As many references as apply are encouraged.</para>
</callout>
<callout arearefs="co-vx-fsa">
<para>This is a
<link xlink:href="http://www.freebsd.org/security/#adv">FreeBSD
security advisory</link>.</para>
</callout>
<callout arearefs="co-vx-fpr">
<para>This is a
<link xlink:href="http://www.freebsd.org/support.html#gnats">FreeBSD
problem report</link>.</para>
</callout>
<callout arearefs="co-vx-cve">
<para>This is a <link xlink:href="http://www.cve.mitre.org/">Mitre
CVE</link> identifier.</para>
</callout>
<callout arearefs="co-vx-bid">
<para>This is a
<link xlink:href="http://www.securityfocus.com/bid">SecurityFocus
Bug ID</link>.</para>
</callout>
<callout arearefs="co-vx-cts">
<para>This is a
<link xlink:href="http://www.cert.org/">US-CERT</link>
security advisory.</para>
</callout>
<callout arearefs="co-vx-ctv">
<para>This is a
<link xlink:href="http://www.cert.org/">US-CERT</link>
vulnerability note.</para>
</callout>
<callout arearefs="co-vx-ucs">
<para>This is a
<link xlink:href="http://www.cert.org/">US-CERT</link>
Cyber Security Alert.</para>
</callout>
<callout arearefs="co-vx-uct">
<para>This is a
<link xlink:href="http://www.cert.org/">US-CERT</link>
Technical Cyber Security Alert.</para>
</callout>
<callout arearefs="co-vx-mls">
<para>This is a URL to an archived posting in a mailing list.
The attribute <literal>msgid</literal> is optional and
may specify the message ID of the posting.</para>
</callout>
<callout arearefs="co-vx-url">
<para>This is a generic URL. It should be used only if none of
the other reference categories apply.</para>
</callout>
<callout arearefs="co-vx-dsc">
<para>This is the date when the issue was disclosed
(<replaceable>YYYY-MM-DD</replaceable>).</para>
</callout>
<callout arearefs="co-vx-ent">
<para>This is the date when the entry was added
(<replaceable>YYYY-MM-DD</replaceable>).</para>
</callout>
<callout arearefs="co-vx-mod">
<para>This is the date when any information in the entry
was last modified (<replaceable>YYYY-MM-DD</replaceable>).
New entries must not include this field. It should be added
upon editing an existing entry.</para>
</callout>
</calloutlist>
</sect2>
<sect2 xml:id="security-notify-vuxml-testing">
<title>Testing your changes to the VuXML database</title>
<para>Assume you just wrote or filled in an entry for a
vulnerability in the package <literal>clamav</literal>
that has been fixed in version <literal>0.65_7</literal>.</para>
<para>As a prerequisite, you need to install fresh versions of the
ports <package>ports-mgmt/portaudit</package> and
<package>ports-mgmt/portaudit-db</package>.</para>
<para>First, check whether there already is an entry for this
vulnerability. If there were such entry, it would match the
previous version of the package,
<literal>0.65_6</literal>:</para>
<screen>&prompt.user; <userinput>packaudit</userinput>
&prompt.user; <userinput>portaudit clamav-0.65_6</userinput></screen>
<note>
<para>To run <command>packaudit</command>, you must have
permission to write to its
<filename>DATABASEDIR</filename>,
typically <filename>/var/db/portaudit</filename>.</para>
</note>
<para>If there is none found, you get the green light to add
a new entry for this vulnerability. Now you can generate
a brand-new UUID (assume it's
<literal>74a9541d-5d6c-11d8-80e3-0020ed76ef5a</literal>) and
add your new entry to the VuXML database. Please verify
its syntax after that as follows:</para>
<screen>&prompt.user; <userinput>cd ${PORTSDIR}/security/vuxml &amp;&amp; make validate</userinput></screen>
<note>
<para>You will need at least one of the following packages
installed: <package>textproc/libxml2</package>,
<package>textproc/jade</package>.</para>
</note>
<para>Now rebuild the <command>portaudit</command> database
from the VuXML file:</para>
<screen>&prompt.user; <userinput>packaudit</userinput></screen>
<para>To verify that the <literal>&lt;affected&gt;</literal>
section of your entry will match correct package(s), issue
the following command:</para>
<screen>&prompt.user; <userinput>portaudit -f /usr/ports/INDEX -r 74a9541d-5d6c-11d8-80e3-0020ed76ef5a</userinput></screen>
<note>
<para>Please refer to &man.portaudit.1; for better understanding
of the command syntax.</para>
</note>
<para>Make sure that your entry produces no spurious matches
in the output.</para>
<para>Now check whether the right package versions are matched
by your entry:</para>
<screen>&prompt.user; <userinput>portaudit clamav-0.65_6 clamav-0.65_7</userinput>
Affected package: clamav-0.65_6 (matched by clamav&lt;0.65_7)
Type of problem: clamav remote denial-of-service.
Reference: &lt;http://www.freebsd.org/ports/portaudit/74a9541d-5d6c-11d8-80e3-0020ed76ef5a.html&gt;
1 problem(s) found.</screen>
<para>Obviously, the former version should match while the
latter one should not.</para>
<para>Finally, verify whether the web page generated from the
VuXML database looks like expected:</para>
<screen>&prompt.user; <userinput>mkdir -p ~/public_html/portaudit</userinput>
&prompt.user; <userinput>packaudit</userinput>
&prompt.user; <userinput>lynx ~/public_html/portaudit/74a9541d-5d6c-11d8-80e3-0020ed76ef5a.html</userinput></screen>
</sect2>
</sect1>
</chapter>
<chapter xml:id="porting-dads">
<title>Dos and Don'ts</title>
<sect1 xml:id="dads-intro">
<title>Introduction</title>
<para>Here is a list of common dos and don'ts that you encounter during
the porting process. You should check your own port against this list,
but you can also check ports in the <link xlink:href="http://www.FreeBSD.org/cgi/query-pr-summary.cgi?query">PR database</link> that others have
submitted. Submit any comments on ports you check as described in
<link xlink:href="&url.articles.contributing;/contrib-how.html#CONTRIB-GENERAL">Bug Reports and General
Commentary</link>. Checking ports in the PR database will both make
it faster for us to commit them, and prove that you know what you are
doing.</para>
</sect1>
<sect1 xml:id="porting-wrkdir">
<title><varname>WRKDIR</varname></title>
<para>Do not write anything to files outside
<varname>WRKDIR</varname>. <varname>WRKDIR</varname> is the only
place that is guaranteed to be writable during the port build (see
<link xlink:href="&url.books.handbook;/ports-using.html#PORTS-CD">
installing ports from a CDROM</link> for an
example of building ports from a read-only tree). If you need to
modify one of the <filename>pkg-*</filename>
files, do so by <link linkend="porting-pkgfiles">redefining a variable</link>, not by
writing over it.</para>
</sect1>
<sect1 xml:id="porting-wrkdirprefix">
<title><varname>WRKDIRPREFIX</varname></title>
<para>Make sure your port honors <varname>WRKDIRPREFIX</varname>.
Most ports do not have to worry about this. In particular, if you
are referring to a <varname>WRKDIR</varname> of another port, note
that the correct location is
<filename>WRKDIRPREFIXPORTSDIR/subdir/name/work</filename> not <filename>PORTSDIR/subdir/name/work</filename> or <filename>.CURDIR/../../subdir/name/work</filename> or some such.</para>
<para>Also, if you are defining <varname>WRKDIR</varname> yourself,
make sure you prepend
<literal>&dollar;{WRKDIRPREFIX}&dollar;{.CURDIR}</literal> in the
front.</para>
</sect1>
<sect1 xml:id="porting-versions">
<title>Differentiating operating systems and OS versions</title>
<para>You may come across code that needs modifications or conditional
compilation based upon what version of Unix it is running under. If
you need to make such changes to the code for conditional
compilation, make sure you make the changes as general as possible
so that we can back-port code to older FreeBSD systems and cross-port
to other BSD systems such as 4.4BSD from CSRG, BSD/386, 386BSD,
NetBSD, and OpenBSD.</para>
<para>The preferred way to tell 4.3BSD/Reno (1990) and newer versions
of the BSD code apart is by using the <literal>BSD</literal> macro
defined in
<link xlink:href="http://cvsweb.freebsd.org/src/sys/sys/param.h">sys/param.h</link>.
Hopefully that
file is already included; if not, add the code:</para>
<programlisting>#if (defined(__unix__) || defined(unix)) &amp;&amp; !defined(USG)
#include &lt;sys/param.h&gt;
#endif</programlisting>
<para>to the proper place in the <filename>.c</filename> file. We
believe that every system that defines these two symbols has
<filename>sys/param.h</filename>. If you find a system that
does not, we would like to know. Please send mail to the
&a.ports;.</para>
<para>Another way is to use the GNU Autoconf style of doing
this:</para>
<programlisting>#ifdef HAVE_SYS_PARAM_H
#include &lt;sys/param.h&gt;
#endif</programlisting>
<para>Do not forget to add <literal>-DHAVE_SYS_PARAM_H</literal> to the
<varname>CFLAGS</varname> in the <filename>Makefile</filename> for
this method.</para>
<para>Once you have <filename>sys/param.h</filename> included, you may
use:</para>
<programlisting>#if (defined(BSD) &amp;&amp; (BSD &gt;= 199103))</programlisting>
<para>to detect if the code is being compiled on a 4.3 Net2 code base
or newer (e.g. FreeBSD 1.x, 4.3/Reno, NetBSD 0.9, 386BSD, BSD/386
1.1 and below).</para>
<para>Use:</para>
<programlisting>#if (defined(BSD) &amp;&amp; (BSD &gt;= 199306))</programlisting>
<para>to detect if the code is being compiled on a 4.4 code base or
newer (e.g. FreeBSD 2.x, 4.4, NetBSD 1.0, BSD/386 2.0 or
above).</para>
<para>The value of the <literal>BSD</literal> macro is
<literal>199506</literal> for the 4.4BSD-Lite2 code base. This is
stated for informational purposes only. It should not be used to
distinguish between versions of FreeBSD based only on 4.4-Lite vs.
versions that have merged in changes from 4.4-Lite2. The
<literal>__FreeBSD__</literal> macro should be used instead.</para>
<para>Use sparingly:</para>
<itemizedlist>
<listitem>
<para><literal>__FreeBSD__</literal> is defined in all versions of
FreeBSD. Use it if the change you are making
<emphasis>only</emphasis> affects FreeBSD. Porting gotchas like
the use of <literal>sys_errlist[]</literal> vs
<function>strerror()</function> are Berkeley-isms, not FreeBSD
changes.</para>
</listitem>
<listitem>
<para>In FreeBSD 2.x, <literal>__FreeBSD__</literal> is defined to
be <literal>2</literal>. In earlier versions, it is
<literal>1</literal>. Later versions always bump it to match
their major version number.</para>
</listitem>
<listitem>
<para>If you need to tell the difference between a FreeBSD 1.x
system and a FreeBSD 2.x or above system, usually the right answer
is to use the <literal>BSD</literal> macros described above. If
there actually is a FreeBSD specific change (such as special
shared library options when using <command>ld</command>) then it
is OK to use <literal>__FreeBSD__</literal> and <literal>#if
__FreeBSD__ &gt; 1</literal> to detect a FreeBSD 2.x and later
system. If you need more granularity in detecting FreeBSD
systems since 2.0-RELEASE you can use the following:</para>
<programlisting>#if __FreeBSD__ &gt;= 2
#include &lt;osreldate.h&gt;
# if __FreeBSD_version &gt;= 199504
/* 2.0.5+ release specific code here */
# endif
#endif</programlisting>
</listitem>
</itemizedlist>
<para>In the hundreds of ports that have been done, there have only
been one or two cases where <literal>__FreeBSD__</literal> should
have been used. Just because an earlier port screwed up and used it
in the wrong place does not mean you should do so too.</para>
</sect1>
<sect1 xml:id="freebsd-versions">
<title>FreeBSD 版本速查表(__FreeBSD_version)</title>
<para>以下是 <link xlink:href="http://cvsweb.freebsd.org/src/sys/sys/param.h">sys/param.h</link> 內的 <literal>__FreeBSD_version</literal> 版本速查表:</para>
<table frame="none">
<title>__FreeBSD_version values</title>
<tgroup cols="2">
<thead>
<row>
<entry>Release</entry>
<entry><literal>__FreeBSD_version</literal></entry>
</row>
</thead>
<tbody>
<row>
<entry>2.0-RELEASE</entry>
<entry>119411</entry>
</row>
<row>
<entry>2.1-CURRENT</entry>
<entry>199501, 199503</entry>
</row>
<row>
<entry>2.0.5-RELEASE</entry>
<entry>199504</entry>
</row>
<row>
<entry>2.2-CURRENT before 2.1</entry>
<entry>199508</entry>
</row>
<row>
<entry>2.1.0-RELEASE</entry>
<entry>199511</entry>
</row>
<row>
<entry>2.2-CURRENT before 2.1.5</entry>
<entry>199512</entry>
</row>
<row>
<entry>2.1.5-RELEASE</entry>
<entry>199607</entry>
</row>
<row>
<entry>2.2-CURRENT before 2.1.6</entry>
<entry>199608</entry>
</row>
<row>
<entry>2.1.6-RELEASE</entry>
<entry>199612</entry>
</row>
<row>
<entry>2.1.7-RELEASE</entry>
<entry>199612</entry>
</row>
<row>
<entry>2.2-RELEASE</entry>
<entry>220000</entry>
</row>
<row>
<entry>2.2.1-RELEASE</entry>
<entry>220000 (no change)</entry>
</row>
<row>
<entry>2.2-STABLE after 2.2.1-RELEASE</entry>
<entry>220000 (no change)</entry>
</row>
<row>
<entry>2.2-STABLE after texinfo-3.9</entry>
<entry>221001</entry>
</row>
<row>
<entry>2.2-STABLE after top</entry>
<entry>221002</entry>
</row>
<row>
<entry>2.2.2-RELEASE</entry>
<entry>222000</entry>
</row>
<row>
<entry>2.2-STABLE after 2.2.2-RELEASE</entry>
<entry>222001</entry>
</row>
<row>
<entry>2.2.5-RELEASE</entry>
<entry>225000</entry>
</row>
<row>
<entry>2.2-STABLE after 2.2.5-RELEASE</entry>
<entry>225001</entry>
</row>
<row>
<entry>2.2-STABLE after ldconfig -R merge</entry>
<entry>225002</entry>
</row>
<row>
<entry>2.2.6-RELEASE</entry>
<entry>226000</entry>
</row>
<row>
<entry>2.2.7-RELEASE</entry>
<entry>227000</entry>
</row>
<row>
<entry>2.2-STABLE after 2.2.7-RELEASE</entry>
<entry>227001</entry>
</row>
<row>
<entry>2.2-STABLE after &man.semctl.2; change</entry>
<entry>227002</entry>
</row>
<row>
<entry>2.2.8-RELEASE</entry>
<entry>228000</entry>
</row>
<row>
<entry>2.2-STABLE after 2.2.8-RELEASE</entry>
<entry>228001</entry>
</row>
<row>
<entry>3.0-CURRENT before &man.mount.2; change</entry>
<entry>300000</entry>
</row>
<row>
<entry>3.0-CURRENT after &man.mount.2; change</entry>
<entry>300001</entry>
</row>
<row>
<entry>3.0-CURRENT after &man.semctl.2; change</entry>
<entry>300002</entry>
</row>
<row>
<entry>3.0-CURRENT after ioctl arg changes</entry>
<entry>300003</entry>
</row>
<row>
<entry>3.0-CURRENT after ELF conversion</entry>
<entry>300004</entry>
</row>
<row>
<entry>3.0-RELEASE</entry>
<entry>300005</entry>
</row>
<row>
<entry>3.0-CURRENT after 3.0-RELEASE</entry>
<entry>300006</entry>
</row>
<row>
<entry>3.0-STABLE after 3/4 branch</entry>
<entry>300007</entry>
</row>
<row>
<entry>3.1-RELEASE</entry>
<entry>310000</entry>
</row>
<row>
<entry>3.1-STABLE after 3.1-RELEASE</entry>
<entry>310001</entry>
</row>
<row>
<entry>3.1-STABLE after C++ constructor/destructor order
change</entry>
<entry>310002</entry>
</row>
<row>
<entry>3.2-RELEASE</entry>
<entry>320000</entry>
</row>
<row>
<entry>3.2-STABLE</entry>
<entry>320001</entry>
</row>
<row>
<entry>3.2-STABLE after binary-incompatible IPFW and
socket changes</entry>
<entry>320002</entry>
</row>
<row>
<entry>3.3-RELEASE</entry>
<entry>330000</entry>
</row>
<row>
<entry>3.3-STABLE</entry>
<entry>330001</entry>
</row>
<row>
<entry>3.3-STABLE after adding &man.mkstemp.3;
to libc</entry>
<entry>330002</entry>
</row>
<row>
<entry>3.4-RELEASE</entry>
<entry>340000</entry>
</row>
<row>
<entry>3.4-STABLE</entry>
<entry>340001</entry>
</row>
<row>
<entry>3.5-RELEASE</entry>
<entry>350000</entry>
</row>
<row>
<entry>3.5-STABLE</entry>
<entry>350001</entry>
</row>
<row>
<entry>4.0-CURRENT after 3.4 branch</entry>
<entry>400000</entry>
</row>
<row>
<entry>4.0-CURRENT after change in dynamic linker
handling</entry>
<entry>400001</entry>
</row>
<row>
<entry>4.0-CURRENT after C++ constructor/destructor
order change</entry>
<entry>400002</entry>
</row>
<row>
<entry>4.0-CURRENT after functioning &man.dladdr.3;</entry>
<entry>400003</entry>
</row>
<row>
<entry>4.0-CURRENT after __deregister_frame_info dynamic
linker bug fix (also 4.0-CURRENT after EGCS 1.1.2
integration)
</entry>
<entry>400004</entry>
</row>
<row>
<entry>4.0-CURRENT after &man.suser.9; API change
(also 4.0-CURRENT after newbus)</entry>
<entry>400005</entry>
</row>
<row>
<entry>4.0-CURRENT after cdevsw registration change</entry>
<entry>400006</entry>
</row>
<row>
<entry>4.0-CURRENT after the addition of so_cred for
socket level credentials</entry>
<entry>400007</entry>
</row>
<row>
<entry>4.0-CURRENT after the addition of a poll syscall
wrapper to libc_r</entry>
<entry>400008</entry>
</row>
<row>
<entry>4.0-CURRENT after the change of the kernel's
<literal>dev_t</literal> type to <literal>struct
specinfo</literal> pointer</entry>
<entry>400009</entry>
</row>
<row>
<entry>4.0-CURRENT after fixing a hole
in &man.jail.2;</entry>
<entry>400010</entry>
</row>
<row>
<entry>4.0-CURRENT after the <literal>sigset_t</literal>
datatype change</entry>
<entry>400011</entry>
</row>
<row>
<entry>4.0-CURRENT after the cutover to the GCC 2.95.2
compiler</entry>
<entry>400012</entry>
</row>
<row>
<entry>4.0-CURRENT after adding pluggable linux-mode
ioctl handlers</entry>
<entry>400013</entry>
</row>
<row>
<entry>4.0-CURRENT after importing OpenSSL</entry>
<entry>400014</entry>
</row>
<row>
<entry>4.0-CURRENT after the C++ ABI change in GCC 2.95.2
from -fvtable-thunks to -fno-vtable-thunks by
default</entry>
<entry>400015</entry>
</row>
<row>
<entry>4.0-CURRENT after importing OpenSSH</entry>
<entry>400016</entry>
</row>
<row>
<entry>4.0-RELEASE</entry>
<entry>400017</entry>
</row>
<row>
<entry>4.0-STABLE after 4.0-RELEASE</entry>
<entry>400018</entry>
</row>
<row>
<entry>4.0-STABLE after the introduction of delayed
checksums.</entry>
<entry>400019</entry>
</row>
<row>
<entry>4.0-STABLE after merging libxpg4 code into
libc.</entry>
<entry>400020</entry>
</row>
<row>
<entry>4.0-STABLE after upgrading Binutils to 2.10.0, ELF
branding changes, and tcsh in the base system.</entry>
<entry>400021</entry>
</row>
<row>
<entry>4.1-RELEASE</entry>
<entry>410000</entry>
</row>
<row>
<entry>4.1-STABLE after 4.1-RELEASE</entry>
<entry>410001</entry>
</row>
<row>
<entry>4.1-STABLE after &man.setproctitle.3; moved from
libutil to libc.</entry>
<entry>410002</entry>
</row>
<row>
<entry>4.1.1-RELEASE</entry>
<entry>411000</entry>
</row>
<row>
<entry>4.1.1-STABLE after 4.1.1-RELEASE</entry>
<entry>411001</entry>
</row>
<row>
<entry>4.2-RELEASE</entry>
<entry>420000</entry>
</row>
<row>
<entry>4.2-STABLE after combining libgcc.a and
libgcc_r.a, and associated GCC linkage changes.</entry>
<entry>420001</entry>
</row>
<row>
<entry>4.3-RELEASE</entry>
<entry>430000</entry>
</row>
<row>
<entry>4.3-STABLE after wint_t introduction.</entry>
<entry>430001</entry>
</row>
<row>
<entry>4.3-STABLE after PCI powerstate API merge.</entry>
<entry>430002</entry>
</row>
<row>
<entry>4.4-RELEASE</entry>
<entry>440000</entry>
</row>
<row>
<entry>4.4-STABLE after d_thread_t introduction.</entry>
<entry>440001</entry>
</row>
<row>
<entry>4.4-STABLE after mount structure changes (affects
filesystem klds).</entry>
<entry>440002</entry>
</row>
<row>
<entry>4.4-STABLE after the userland components of smbfs
were imported.</entry>
<entry>440003</entry>
</row>
<row>
<entry>4.5-RELEASE</entry>
<entry>450000</entry>
</row>
<row>
<entry>4.5-STABLE after the usb structure element rename.</entry>
<entry>450001</entry>
</row>
<row>
<entry>4.5-STABLE after the
<literal>sendmail_enable</literal> &man.rc.conf.5;
variable was made to take the value
<literal>NONE</literal>.</entry>
<entry>450004</entry>
</row>
<row>
<entry>4.5-STABLE after moving to XFree86 4 by default
for package builds.</entry>
<entry>450005</entry>
</row>
<row>
<entry>4.5-STABLE after accept filtering was fixed so
that is no longer susceptible to an easy DoS.</entry>
<entry>450006</entry>
</row>
<row>
<entry>4.6-RELEASE</entry>
<entry>460000</entry>
</row>
<row>
<entry>4.6-STABLE &man.sendfile.2; fixed to comply with
documentation, not to count any headers sent against
the amount of data to be sent from the file.</entry>
<entry>460001</entry>
</row>
<row>
<entry>4.6.2-RELEASE</entry>
<entry>460002</entry>
</row>
<row>
<entry>4.6-STABLE</entry>
<entry>460100</entry>
</row>
<row>
<entry>4.6-STABLE after MFC of `sed -i'.</entry>
<entry>460101</entry>
</row>
<row>
<entry>4.6-STABLE after MFC of many new pkg_install
features from the HEAD.</entry>
<entry>460102</entry>
</row>
<row>
<entry>4.7-RELEASE</entry>
<entry>470000</entry>
</row>
<row>
<entry>4.7-STABLE</entry>
<entry>470100</entry>
</row>
<row>
<entry>Start generated __std{in,out,err}p references rather
than __sF. This changes std{in,out,err} from a
compile time expression to a runtime one.</entry>
<entry>470101</entry>
</row>
<row>
<entry>4.7-STABLE after MFC of mbuf changes to replace
m_aux mbufs by m_tag's</entry>
<entry>470102</entry>
</row>
<row>
<entry>4.7-STABLE gets OpenSSL 0.9.7</entry>
<entry>470103</entry>
</row>
<row>
<entry>4.8-RELEASE</entry>
<entry>480000</entry>
</row>
<row>
<entry>4.8-STABLE</entry>
<entry>480100</entry>
</row>
<row>
<entry>4.8-STABLE after &man.realpath.3; has been made
thread-safe</entry>
<entry>480101</entry>
</row>
<row>
<entry>4.8-STABLE 3ware API changes to twe.</entry>
<entry>480102</entry>
</row>
<row>
<entry>4.9-RELEASE</entry>
<entry>490000</entry>
</row>
<row>
<entry>4.9-STABLE</entry>
<entry>490100</entry>
</row>
<row>
<entry>4.9-STABLE after e_sid was added to struct
kinfo_eproc.</entry>
<entry>490101</entry>
</row>
<row>
<entry>4.9-STABLE after MFC of libmap functionality
for rtld.</entry>
<entry>490102</entry>
</row>
<row>
<entry>4.10-RELEASE</entry>
<entry>491000</entry>
</row>
<row>
<entry>4.10-STABLE</entry>
<entry>491100</entry>
</row>
<row>
<entry>4.10-STABLE after MFC of revision 20040629 of
the package tools</entry>
<entry>491101</entry>
</row>
<row>
<entry>4.10-STABLE after VM fix dealing with unwiring
of fictitious pages</entry>
<entry>491102</entry>
</row>
<row>
<entry>4.11-RELEASE</entry>
<entry>492000</entry>
</row>
<row>
<entry>4.11-STABLE</entry>
<entry>492100</entry>
</row>
<row>
<entry>4.11-STABLE after adding libdata/ldconfig directories
to mtree files.</entry>
<entry>492101</entry>
</row>
<row>
<entry>5.0-CURRENT</entry>
<entry>500000</entry>
</row>
<row>
<entry>5.0-CURRENT after adding addition ELF header fields,
and changing our ELF binary branding method.</entry>
<entry>500001</entry>
</row>
<row>
<entry>5.0-CURRENT after kld metadata changes.</entry>
<entry>500002</entry>
</row>
<row>
<entry>5.0-CURRENT after buf/bio changes.</entry>
<entry>500003</entry>
</row>
<row>
<entry>5.0-CURRENT after binutils upgrade.</entry>
<entry>500004</entry>
</row>
<row>
<entry>5.0-CURRENT after merging libxpg4 code into
libc and after TASKQ interface introduction.</entry>
<entry>500005</entry>
</row>
<row>
<entry>5.0-CURRENT after the addition of AGP
interfaces.</entry>
<entry>500006</entry>
</row>
<row>
<entry>5.0-CURRENT after Perl upgrade to 5.6.0</entry>
<entry>500007</entry>
</row>
<row>
<entry>5.0-CURRENT after the update of KAME code to
2000/07 sources.</entry>
<entry>500008</entry>
</row>
<row>
<entry>5.0-CURRENT after ether_ifattach() and
ether_ifdetach() changes.</entry>
<entry>500009</entry>
</row>
<row>
<entry>5.0-CURRENT after changing mtree defaults
back to original variant, adding -L to follow
symlinks.</entry>
<entry>500010</entry>
</row>
<row>
<entry>5.0-CURRENT after kqueue API changed.</entry>
<entry>500011</entry>
</row>
<row>
<entry>5.0-CURRENT after &man.setproctitle.3; moved from
libutil to libc.</entry>
<entry>500012</entry>
</row>
<row>
<entry>5.0-CURRENT after the first SMPng commit.</entry>
<entry>500013</entry>
</row>
<row>
<entry>5.0-CURRENT after &lt;sys/select.h&gt; moved to
&lt;sys/selinfo.h&gt;.</entry>
<entry>500014</entry>
</row>
<row>
<entry>5.0-CURRENT after combining libgcc.a and
libgcc_r.a, and associated GCC linkage changes.</entry>
<entry>500015</entry>
</row>
<row>
<entry>5.0-CURRENT after change allowing libc and libc_r
to be linked together, deprecating -pthread
option.</entry>
<entry>500016</entry>
</row>
<row>
<entry>5.0-CURRENT after switch from struct ucred to
struct xucred to stabilize kernel-exported API for
mountd et al.</entry>
<entry>500017</entry>
</row>
<row>
<entry>5.0-CURRENT after addition of CPUTYPE make variable
for controlling CPU-specific optimizations.</entry>
<entry>500018</entry>
</row>
<row>
<entry>5.0-CURRENT after moving machine/ioctl_fd.h to
sys/fdcio.h</entry>
<entry>500019</entry>
</row>
<row>
<entry>5.0-CURRENT after locale names renaming.</entry>
<entry>500020</entry>
</row>
<row>
<entry>5.0-CURRENT after Bzip2 import.
Also signifies removal of S/Key.</entry>
<entry>500021</entry>
</row>
<row>
<entry>5.0-CURRENT after SSE support.</entry>
<entry>500022</entry>
</row>
<row>
<entry>5.0-CURRENT after KSE Milestone 2.</entry>
<entry>500023</entry>
</row>
<row>
<entry>5.0-CURRENT after d_thread_t,
and moving UUCP to ports.</entry>
<entry>500024</entry>
</row>
<row>
<entry>5.0-CURRENT after ABI change for descriptor
and creds passing on 64 bit platforms.</entry>
<entry>500025</entry>
</row>
<row>
<entry>5.0-CURRENT after moving to XFree86 4 by default for
package builds, and after the new libc strnstr() function
was added.</entry>
<entry>500026</entry>
</row>
<row>
<entry>5.0-CURRENT after the new libc strcasestr() function
was added.</entry>
<entry>500027</entry>
</row>
<row>
<entry>5.0-CURRENT after the userland components of smbfs
were imported.</entry>
<entry>500028</entry>
</row>
<row>
<entry>5.0-CURRENT after the new C99 specific-width
integer types were added.</entry>
<entry>(Not incremented.)</entry>
</row>
<row>
<entry>5.0-CURRENT after a change was made in the return
value of &man.sendfile.2;.</entry>
<entry>500029</entry>
</row>
<row>
<entry>5.0-CURRENT after the introduction of the
type <literal>fflags_t</literal>, which is the
appropriate size for file flags.</entry>
<entry>500030</entry>
</row>
<row>
<entry>5.0-CURRENT after the usb structure element rename.</entry>
<entry>500031</entry>
</row>
<row>
<entry>5.0-CURRENT after the introduction of
Perl 5.6.1.</entry>
<entry>500032</entry>
</row>
<row>
<entry>5.0-CURRENT after the
<literal>sendmail_enable</literal> &man.rc.conf.5;
variable was made to take the value
<literal>NONE</literal>.</entry>
<entry>500033</entry>
</row>
<row>
<entry>5.0-CURRENT after mtx_init() grew a third argument.</entry>
<entry>500034</entry>
</row>
<row>
<entry>5.0-CURRENT with Gcc 3.1.</entry>
<entry>500035</entry>
</row>
<row>
<entry>5.0-CURRENT without Perl in /usr/src</entry>
<entry>500036</entry>
</row>
<row>
<entry>5.0-CURRENT after the addition of &man.dlfunc.3;</entry>
<entry>500037</entry>
</row>
<row>
<entry>5.0-CURRENT after the types of some struct
sockbuf members were changed and the structure was
reordered.</entry>
<entry>500038</entry>
</row>
<row>
<entry>5.0-CURRENT after GCC 3.2.1 import.
Also after headers stopped using
_BSD_FOO_T_ and started using _FOO_T_DECLARED.
This value can also be used as a conservative
estimate of the start of &man.bzip2.1; package
support.</entry>
<entry>500039</entry>
</row>
<row>
<entry>5.0-CURRENT after various changes to disk functions
were made in the name of removing dependency on disklabel
structure internals.</entry>
<entry>500040</entry>
</row>
<row>
<entry>5.0-CURRENT after the addition of &man.getopt.long.3;
to libc.</entry>
<entry>500041</entry>
</row>
<row>
<entry>5.0-CURRENT after Binutils 2.13 upgrade, which
included new FreeBSD emulation, vec, and output format.
</entry>
<entry>500042</entry>
</row>
<row>
<entry>5.0-CURRENT after adding weak pthread_XXX stubs
to libc, obsoleting libXThrStub.so. 5.0-RELEASE.</entry>
<entry>500043</entry>
</row>
<row>
<entry>5.0-CURRENT after branching for RELENG_5_0</entry>
<entry>500100</entry>
</row>
<row>
<entry>&lt;sys/dkstat.h&gt; is empty and should
not be included.</entry>
<entry>500101</entry>
</row>
<row>
<entry>5.0-CURRENT after the d_mmap_t interface
change.</entry>
<entry>500102</entry>
</row>
<row>
<entry>5.0-CURRENT after taskqueue_swi changed to run
without Giant, and taskqueue_swi_giant added to run
with Giant.</entry>
<entry>500103</entry>
</row>
<row>
<entry>cdevsw_add() and cdevsw_remove() no
longer exists.
Appearance of MAJOR_AUTO allocation facility.</entry>
<entry>500104</entry>
</row>
<row>
<entry>5.0-CURRENT after new cdevsw initialization method.</entry>
<entry>500105</entry>
</row>
<row>
<entry>devstat_add_entry() has been replaced by
devstat_new_entry()</entry>
<entry>500106</entry>
</row>
<row>
<entry>Devstat interface change; see sys/sys/param.h 1.149</entry>
<entry>500107</entry>
</row>
<row>
<entry>Token-Ring interface changes.</entry>
<entry>500108</entry>
</row>
<row>
<entry>Addition of vm_paddr_t.</entry>
<entry>500109</entry>
</row>
<row>
<entry>5.0-CURRENT after &man.realpath.3; has been made
thread-safe</entry>
<entry>500110</entry>
</row>
<row>
<entry>5.0-CURRENT after &man.usbhid.3; has been synced with
NetBSD</entry>
<entry>500111</entry>
</row>
<row>
<entry>5.0-CURRENT after new NSS implementation
and addition of POSIX.1 getpw*_r, getgr*_r
functions</entry>
<entry>500112</entry>
</row>
<row>
<entry>5.0-CURRENT after removal of the old rc system.</entry>
<entry>500113</entry>
</row>
<row>
<entry>5.1-RELEASE.</entry>
<entry>501000</entry>
</row>
<row>
<entry>5.1-CURRENT after branching for RELENG_5_1.</entry>
<entry>501100</entry>
</row>
<row>
<entry>5.1-CURRENT after correcting the semantics of
sigtimedwait(2) and sigwaitinfo(2).</entry>
<entry>501101</entry>
</row>
<row>
<entry>5.1-CURRENT after adding the lockfunc and lockfuncarg
fields to &man.bus.dma.tag.create.9;.</entry>
<entry>501102</entry>
</row>
<row>
<entry>5.1-CURRENT after GCC 3.3.1-pre 20030711 snapshot
integration.</entry>
<entry>501103</entry>
</row>
<row>
<entry>5.1-CURRENT 3ware API changes to twe.</entry>
<entry>501104</entry>
</row>
<row>
<entry>5.1-CURRENT dynamically-linked /bin and /sbin
support and movement of libraries to /lib.</entry>
<entry>501105</entry>
</row>
<row>
<entry>5.1-CURRENT after adding kernel support for
Coda 6.x.</entry>
<entry>501106</entry>
</row>
<row>
<entry>5.1-CURRENT after 16550 UART constants moved from
<filename>&lt;dev/sio/sioreg.h&gt;</filename> to
<filename>&lt;dev/ic/ns16550.h&gt;</filename>.
Also when libmap functionality was unconditionally
supported by rtld.</entry>
<entry>501107</entry>
</row>
<row>
<entry>5.1-CURRENT after PFIL_HOOKS API update</entry>
<entry>501108</entry>
</row>
<row>
<entry>5.1-CURRENT after adding kiconv(3)</entry>
<entry>501109</entry>
</row>
<row>
<entry>5.1-CURRENT after changing default operations
for open and close in cdevsw</entry>
<entry>501110</entry>
</row>
<row>
<entry>5.1-CURRENT after changed layout of cdevsw</entry>
<entry>501111</entry>
</row>
<row>
<entry> 5.1-CURRENT after adding kobj multiple inheritance
</entry>
<entry>501112</entry>
</row>
<row>
<entry> 5.1-CURRENT after the if_xname change in
struct ifnet</entry>
<entry>501113</entry>
</row>
<row>
<entry> 5.1-CURRENT after changing /bin and /sbin to
be dynamically linked</entry>
<entry>501114</entry>
</row>
<row>
<entry>5.2-RELEASE</entry>
<entry>502000</entry>
</row>
<row>
<entry>5.2.1-RELEASE</entry>
<entry>502010</entry>
</row>
<row>
<entry>5.2-CURRENT after branching for RELENG_5_2</entry>
<entry>502100</entry>
</row>
<row>
<entry>5.2-CURRENT after __cxa_atexit/__cxa_finalize
functions were added to libc.</entry>
<entry>502101</entry>
</row>
<row>
<entry>5.2-CURRENT after change of default thread library
from libc_r to libpthread.</entry>
<entry>502102</entry>
</row>
<row>
<entry>5.2-CURRENT after device driver API megapatch.
</entry>
<entry>502103</entry>
</row>
<row>
<entry>5.2-CURRENT after getopt_long_only() addition.
</entry>
<entry>502104</entry>
</row>
<row>
<entry>5.2-CURRENT after NULL is made into ((void *)0)
for C, creating more warnings.
</entry>
<entry>502105</entry>
</row>
<row>
<entry>5.2-CURRENT after pf is linked to the build and
install.
</entry>
<entry>502106</entry>
</row>
<row>
<entry>5.2-CURRENT after time_t is changed to a
64-bit value on sparc64.
</entry>
<entry>502107</entry>
</row>
<row>
<entry>5.2-CURRENT after Intel C/C++ compiler support in some headers and execve(2) changes to be more strictly conforming to POSIX.
</entry>
<entry>502108</entry>
</row>
<row>
<entry>5.2-CURRENT after the introduction of the
bus_alloc_resource_any API
</entry>
<entry>502109</entry>
</row>
<row>
<entry>5.2-CURRENT after the addition of UTF-8 locales
</entry>
<entry>502110</entry>
</row>
<row>
<entry>5.2-CURRENT after the removal of the getvfsent(3)
API
</entry>
<entry>502111</entry>
</row>
<row>
<entry>5.2-CURRENT after the addition of the .warning
directive for make.</entry>
<entry>502112</entry>
</row>
<row>
<entry>5.2-CURRENT after ttyioctl() was made mandatory
for serial drivers.</entry>
<entry>502113</entry>
</row>
<row>
<entry>5.2-CURRENT after import of the ALTQ framework.
</entry>
<entry>502114</entry>
</row>
<row>
<entry>5.2-CURRENT after changing sema_timedwait(9) to
return 0 on success and a non-zero error code on
failure.
</entry>
<entry>502115</entry>
</row>
<row>
<entry>5.2-CURRENT after changing kernel dev_t to
be pointer to struct cdev *.
</entry>
<entry>502116</entry>
</row>
<row>
<entry>5.2-CURRENT after changing kernel udev_t to dev_t.
</entry>
<entry>502117</entry>
</row>
<row>
<entry>5.2-CURRENT after adding support for CLOCK_VIRTUAL
and CLOCK_PROF to clock_gettime(2) and clock_getres(2).
</entry>
<entry>502118</entry>
</row>
<row>
<entry>5.2-CURRENT after changing network interface
cloning overhaul.
</entry>
<entry>502119</entry>
</row>
<row>
<entry>5.2-CURRENT after the update of the package tools
to revision 20040629.
</entry>
<entry>502120</entry>
</row>
<row>
<entry>5.2-CURRENT after marking Bluetooth code as
non-i386 specific.
</entry>
<entry>502121</entry>
</row>
<row>
<entry>5.2-CURRENT after the introduction of the KDB
debugger framework, the conversion of DDB into a
backend and the introduction of the GDB backend.
</entry>
<entry>502122</entry>
</row>
<row>
<entry>5.2-CURRENT after change to make
VFS_ROOT take a struct
thread argument as does vflush. Struct kinfo_proc
now has a user data pointer.
The switch of the default X implementation to
<literal>xorg</literal> was also made at this time.
</entry>
<entry>502123</entry>
</row>
<row>
<entry>5.2-CURRENT after the change to separate the way
ports rc.d and legacy scripts are started.
</entry>
<entry>502124</entry>
</row>
<row>
<entry>5.2-CURRENT after the backout of the
previous change.
</entry>
<entry>502125</entry>
</row>
<row>
<entry>5.2-CURRENT after the removal of
kmem_alloc_pageable() and the import of gcc 3.4.2.
</entry>
<entry>502126</entry>
</row>
<row>
<entry>5.2-CURRENT after changing the UMA kernel
API to allow ctors/inits to fail.
</entry>
<entry>502127</entry>
</row>
<row>
<entry>5.2-CURRENT after the change of the
vfs_mount signature as well as global replacement of
PRISON_ROOT with SUSER_ALLOWJAIL for the suser(9)
API.
</entry>
<entry>502128</entry>
</row>
<row>
<entry>5.3-BETA/RC before the pfil API change</entry>
<entry>503000</entry>
</row>
<row>
<entry>5.3-RELEASE</entry>
<entry>503001</entry>
</row>
<row>
<entry>5.3-STABLE after branching for RELENG_5_3</entry>
<entry>503100</entry>
</row>
<row>
<entry>5.3-STABLE after addition of glibc style
&man.strftime.3; padding options.</entry>
<entry>503101</entry>
</row>
<row>
<entry>5.3-STABLE after OpenBSD's nc(1) import MFC.</entry>
<entry>503102</entry>
</row>
<row>
<entry>5.4-PRERELEASE after the MFC of the fixes in
<filename>&lt;src/include/stdbool.h&gt;</filename> and
<filename>&lt;src/sys/i386/include/_types.h&gt;</filename>
for using the GCC-compatibility of the Intel C/C++ compiler.</entry>
<entry>503103</entry>
</row>
<row>
<entry>5.4-PRERELEASE after the MFC of the change of
ifi_epoch from wall clock time to uptime.</entry>
<entry>503104</entry>
</row>
<row>
<entry>5.4-PRERELEASE after the MFC of the fix of EOVERFLOW check in vswprintf(3).</entry>
<entry>503105</entry>
</row>
<row>
<entry>5.4-RELEASE.</entry>
<entry>504000</entry>
</row>
<row>
<entry>5.4-STABLE after branching for RELENG_5_4</entry>
<entry>504100</entry>
</row>
<row>
<entry>5.4-STABLE after increasing the default
thread stacksizes</entry>
<entry>504101</entry>
</row>
<row>
<entry>5.4-STABLE after the addition of sha256</entry>
<entry>504102</entry>
</row>
<row>
<entry>5.4-STABLE after the MFC of if_bridge</entry>
<entry>504103</entry>
</row>
<row>
<entry>5.4-STABLE after the MFC of bsdiff and portsnap</entry>
<entry>504104</entry>
</row>
<row>
<entry>5.4-STABLE after MFC of ldconfig_local_dirs
change.</entry>
<entry>504105</entry>
</row>
<row>
<entry>5.5-RELEASE.</entry>
<entry>505000</entry>
</row>
<row>
<entry>5.5-STABLE after branching for RELENG_5_5</entry>
<entry>505100</entry>
</row>
<row>
<entry>6.0-CURRENT</entry>
<entry>600000</entry>
</row>
<row>
<entry>6.0-CURRENT after permanently enabling PFIL_HOOKS
in the kernel.
</entry>
<entry>600001</entry>
</row>
<row>
<entry>6.0-CURRENT after initial addition of
ifi_epoch to struct if_data. Backed out after a
few days. Do not use this value.
</entry>
<entry>600002</entry>
</row>
<row>
<entry>6.0-CURRENT after the re-addition of the
ifi_epoch member of struct if_data.
</entry>
<entry>600003</entry>
</row>
<row>
<entry>6.0-CURRENT after addition of the struct inpcb
argument to the pfil API.
</entry>
<entry>600004</entry>
</row>
<row>
<entry>6.0-CURRENT after addition of the "-d
DESTDIR" argument to newsyslog.
</entry>
<entry>600005</entry>
</row>
<row>
<entry>6.0-CURRENT after addition of glibc style
&man.strftime.3; padding options.
</entry>
<entry>600006</entry>
</row>
<row>
<entry>6.0-CURRENT after addition of 802.11 framework
updates.
</entry>
<entry>600007</entry>
</row>
<row>
<entry>6.0-CURRENT after changes to VOP_*VOBJECT() functions
and introduction of MNTK_MPSAFE flag for Giantfree filesystems.
</entry>
<entry>600008</entry>
</row>
<row>
<entry>6.0-CURRENT after addition of the cpufreq framework
and drivers.
</entry>
<entry>600009</entry>
</row>
<row>
<entry>6.0-CURRENT after importing OpenBSD's nc(1).</entry>
<entry>600010</entry>
</row>
<row>
<entry>6.0-CURRENT after removing semblance of SVID2
<literal>matherr()</literal> support.</entry>
<entry>600011</entry>
</row>
<row>
<entry>6.0-CURRENT after increase of default thread stacks'
size.</entry>
<entry>600012</entry>
</row>
<row>
<entry>6.0-CURRENT after fixes in
<filename>&lt;src/include/stdbool.h&gt;</filename> and
<filename>&lt;src/sys/i386/include/_types.h&gt;</filename>
for using the GCC-compatibility of the Intel C/C++ compiler.</entry>
<entry>600013</entry>
</row>
<row>
<entry>6.0-CURRENT after EOVERFLOW checks in vswprintf(3) fixed.</entry>
<entry>600014</entry>
</row>
<row>
<entry>6.0-CURRENT after changing the struct if_data
member, ifi_epoch, from wall clock time to uptime.</entry>
<entry>600015</entry>
</row>
<row>
<entry>6.0-CURRENT after LC_CTYPE disk format changed.</entry>
<entry>600016</entry>
</row>
<row>
<entry>6.0-CURRENT after NLS catalogs disk format changed.</entry>
<entry>600017</entry>
</row>
<row>
<entry>6.0-CURRENT after LC_COLLATE disk format changed.</entry>
<entry>600018</entry>
</row>
<row>
<entry>Installation of acpica includes into /usr/include.</entry>
<entry>600019</entry>
</row>
<row>
<entry>Addition of MSG_NOSIGNAL flag to send(2) API.</entry>
<entry>600020</entry>
</row>
<row>
<entry>Addition of fields to cdevsw</entry>
<entry>600021</entry>
</row>
<row>
<entry>Removed gtar from base system.</entry>
<entry>600022</entry>
</row>
<row>
<entry>LOCAL_CREDS, LOCAL_CONNWAIT socket options added to unix(4).</entry>
<entry>600023</entry>
</row>
<row>
<entry>&man.hwpmc.4; and related tools added to 6.0-CURRENT.</entry>
<entry>600024</entry>
</row>
<row>
<entry>struct icmphdr added to 6.0-CURRENT.</entry>
<entry>600025</entry>
</row>
<row>
<entry>pf updated to 3.7.</entry>
<entry>600026</entry>
</row>
<row>
<entry>Kernel libalias and ng_nat introduced.</entry>
<entry>600027</entry>
</row>
<row>
<entry>POSIX ttyname_r(3) made available through unistd.h and libc.</entry>
<entry>600028</entry>
</row>
<row>
<entry>6.0-CURRENT after libpcap updated to v0.9.1 alpha 096.</entry>
<entry>600029</entry>
</row>
<row>
<entry>6.0-CURRENT after importing NetBSD's if_bridge(4).</entry>
<entry>600030</entry>
</row>
<row>
<entry>6.0-CURRENT after struct ifnet was broken out
of the driver softcs.</entry>
<entry>600031</entry>
</row>
<row>
<entry>6.0-CURRENT after the import of libpcap v0.9.1.</entry>
<entry>600032</entry>
</row>
<row>
<entry>6.0-STABLE after bump of all shared library
versions that had not been changed since
RELENG_5.</entry>
<entry>600033</entry>
</row>
<row>
<entry>6.0-STABLE after credential argument is added to
dev_clone event handler. 6.0-RELEASE.</entry>
<entry>600034</entry>
</row>
<row>
<entry>6.0-STABLE after 6.0-RELEASE</entry>
<entry>600100</entry>
</row>
<row>
<entry>6.0-STABLE after incorporating scripts from the
local_startup directories into the base &man.rcorder.8;.</entry>
<entry>600101</entry>
</row>
<row>
<entry>6.0-STABLE after updating the ELF types and
constants.</entry>
<entry>600102</entry>
</row>
<row>
<entry>6.0-STABLE after MFC of pidfile(3) API.</entry>
<entry>600103</entry>
</row>
<row>
<entry>6.0-STABLE after MFC of ldconfig_local_dirs
change.</entry>
<entry>600104</entry>
</row>
<row>
<entry>6.0-STABLE after NLS catalog support of
csh(1).</entry>
<entry>600105</entry>
</row>
<row>
<entry>6.1-RELEASE</entry>
<entry>601000</entry>
</row>
<row>
<entry>6.1-STABLE after 6.1-RELEASE.</entry>
<entry>601100</entry>
</row>
<row>
<entry>6.1-STABLE after the import of csup.</entry>
<entry>601101</entry>
</row>
<row>
<entry>6.1-STABLE after the iwi(4) update.</entry>
<entry>601102</entry>
</row>
<row>
<entry>6.1-STABLE after the resolver update to
BIND9, and exposure of reentrant version of
netdb functions.</entry>
<entry>601103</entry>
</row>
<row>
<entry>6.1-STABLE after DSO (dynamic shared
objects) support has been enabled in
OpenSSL.</entry>
<entry>601104</entry>
</row>
<row>
<entry>6.1-STABLE after 802.11 fixups changed the
api for the IEEE80211_IOC_STA_INFO ioctl.</entry>
<entry>601105</entry>
</row>
<row>
<entry>6.2-RELEASE</entry>
<entry>602000</entry>
</row>
<row>
<entry>6.2-STABLE after 6.2-RELEASE.</entry>
<entry>602100</entry>
</row>
<row>
<entry>6.2-STABLE after the addition of Wi-Spy
quirk.</entry>
<entry>602101</entry>
</row>
<row>
<entry>6.2-STABLE after pci_find_extcap() addition.</entry>
<entry>602102</entry>
</row>
<row>
<entry>6.2-STABLE after MFC of dlsym change to look
for a requested symbol both
in specified dso and its implicit dependencies.</entry>
<entry>602103</entry>
</row>
<row>
<entry>6.2-STABLE after MFC of ng_deflate(4) and
ng_pred1(4) netgraph nodes and new compression and
encryption modes for ng_ppp(4) node.</entry>
<entry>602104</entry>
</row>
<row>
<entry>6.2-STABLE after MFC of BSD licensed version of &man.gzip.1;
ported from NetBSD.</entry>
<entry>602105</entry>
</row>
<row>
<entry>6.2-STABLE after MFC of PCI MSI and MSI-X
support.</entry>
<entry>602106</entry>
</row>
<row>
<entry>6.2-STABLE after MFC of ncurses 5.6 and wide
character support.</entry>
<entry>602107</entry>
</row>
<row>
<entry>6.2-STABLE after MFC of CAM 'SG' peripheral device,
which implements a subset of Linux SCSI SG passthrough device API.</entry>
<entry>602108</entry>
</row>
<row>
<entry>6.2-STABLE after MFC of readline 5.2 patchset 002.</entry>
<entry>602109</entry>
</row>
<row>
<entry>6.2-STABLE after MFC of pmap_invalidate_cache(),
pmap_change_attr(), pmap_mapbios(), pmap_mapdev_attr(),
and pmap_unmapbios() for amd64 and i386.</entry>
<entry>602110</entry>
</row>
<row>
<entry>6.2-STABLE after MFC of BOP_BDFLUSH and caused
breakage of the filesystem modules KBI.</entry>
<entry>602111</entry>
</row>
<row>
<entry>6.2-STABLE after libutil(3) MFC's.</entry>
<entry>602112</entry>
</row>
<row>
<entry>6.2-STABLE after MFC of wide and single byte
ctype separation. Newly compiled binary that references
to ctype.h may require a new symbol, __mb_sb_limit,
which is not available on older systems.</entry>
<entry>602113</entry>
</row>
<row>
<entry>6.2-STABLE after ctype ABI forward compatibility
restored.</entry>
<entry>602114</entry>
</row>
<row>
<entry>6.2-STABLE after back out of wide and single byte
ctype separation.</entry>
<entry>602115</entry>
</row>
<row>
<entry>6.3-RELEASE</entry>
<entry>603000</entry>
</row>
<row>
<entry>6.3-STABLE after 6.3-RELEASE.</entry>
<entry>603100</entry>
</row>
<row>
<entry>6.3-STABLE after fixing
multibyte type support in bit macro.</entry>
<entry>603101</entry>
</row>
<row>
<entry>6.3-STABLE after adding l_sysid to struct flock.</entry>
<entry>603102</entry>
</row>
<row>
<entry>6.3-STABLE after MFC of the
<function>memrchr</function> function.</entry>
<entry>603103</entry>
</row>
<row>
<entry>6.3-STABLE after MFC of support for
<literal>:u</literal> variable modifier in make(1).</entry>
<entry>603104</entry>
</row>
<row>
<entry>6.4-RELEASE</entry>
<entry>604000</entry>
</row>
<row>
<entry>6.4-STABLE after 6.4-RELEASE.</entry>
<entry>604100</entry>
</row>
<row>
<entry>7.0-CURRENT.</entry>
<entry>700000</entry>
</row>
<row>
<entry>7.0-CURRENT after bump of all shared library
versions that had not been changed since
RELENG_5.</entry>
<entry>700001</entry>
</row>
<row>
<entry>7.0-CURRENT after credential argument is added to
dev_clone event handler.</entry>
<entry>700002</entry>
</row>
<row>
<entry>7.0-CURRENT after memmem(3) is added to libc.</entry>
<entry>700003</entry>
</row>
<row>
<entry>7.0-CURRENT after solisten(9) kernel arguments
are modified to accept a backlog parameter.</entry>
<entry>700004</entry>
</row>
<row>
<entry>7.0-CURRENT after IFP2ENADDR() was changed to return
a pointer to IF_LLADDR().</entry>
<entry>700005</entry>
</row>
<row>
<entry>7.0-CURRENT after addition of <literal>if_addr</literal>
member to <literal>struct ifnet</literal> and IFP2ENADDR()
removal.</entry>
<entry>700006</entry>
</row>
<row>
<entry>7.0-CURRENT after incorporating scripts from the
local_startup directories into the base &man.rcorder.8;.</entry>
<entry>700007</entry>
</row>
<row>
<entry>7.0-CURRENT after removal of MNT_NODEV mount
option.</entry>
<entry>700008</entry>
</row>
<row>
<entry>7.0-CURRENT after ELF-64 type changes and symbol
versioning.</entry>
<entry>700009</entry>
</row>
<row>
<entry>7.0-CURRENT after addition of hostb and vgapci
drivers, addition of pci_find_extcap(), and changing
the AGP drivers to no longer map the aperture.</entry>
<entry>700010</entry>
</row>
<row>
<entry>7.0-CURRENT after tv_sec was made time_t on
all platforms but Alpha.</entry>
<entry>700011</entry>
</row>
<row>
<entry>7.0-CURRENT after ldconfig_local_dirs change.</entry>
<entry>700012</entry>
</row>
<row>
<entry>7.0-CURRENT after changes to
<filename>/etc/rc.d/abi</filename> to support
<filename>/compat/linux/etc/ld.so.cache</filename>
being a symlink in a readonly filesystem.</entry>
<entry>700013</entry>
</row>
<row>
<entry>7.0-CURRENT after pts import.</entry>
<entry>700014</entry>
</row>
<row>
<entry>7.0-CURRENT after the introduction of version 2
of &man.hwpmc.4;'s ABI.</entry>
<entry>700015</entry>
</row>
<row>
<entry>7.0-CURRENT after addition of &man.fcloseall.3;
to libc.</entry>
<entry>700016</entry>
</row>
<row>
<entry>7.0-CURRENT after removal of ip6fw.</entry>
<entry>700017</entry>
</row>
<row>
<entry>7.0-CURRENT after import of snd_emu10kx.</entry>
<entry>700018</entry>
</row>
<row>
<entry>7.0-CURRENT after import of OpenSSL 0.9.8b.</entry>
<entry>700019</entry>
</row>
<row>
<entry>7.0-CURRENT after addition of bus_dma_get_tag
function</entry>
<entry>700020</entry>
</row>
<row>
<entry>7.0-CURRENT after libpcap 0.9.4 and
tcpdump 3.9.4 import.</entry>
<entry>700021</entry>
</row>
<row>
<entry>7.0-CURRENT after dlsym change to look
for a requested symbol both
in specified dso and its implicit dependencies.</entry>
<entry>700022</entry>
</row>
<row>
<entry>7.0-CURRENT after adding new sound IOCTLs.</entry>
<entry>700023</entry>
</row>
<row>
<entry>7.0-CURRENT after import of OpenSSL 0.9.8d.</entry>
<entry>700024</entry>
</row>
<row>
<entry>7.0-CURRENT after the addition of libelf.</entry>
<entry>700025</entry>
</row>
<row>
<entry>7.0-CURRENT after major changes on sound
sysctls.</entry>
<entry>700026</entry>
</row>
<row>
<entry>7.0-CURRENT after the addition of Wi-Spy
quirk.</entry>
<entry>700027</entry>
</row>
<row>
<entry>7.0-CURRENT after the addition of sctp calls to libc
</entry>
<entry>700028</entry>
</row>
<row>
<entry>7.0-CURRENT after the GNU &man.gzip.1; implementation was
replaced with a BSD licensed version ported from NetBSD.</entry>
<entry>700029</entry>
</row>
<row>
<entry>7.0-CURRENT after the removal of IPIP tunnel encapsulation (VIFF_TUNNEL) from the IPv4 multicast forwarding code.
</entry>
<entry>700030</entry>
</row>
<row>
<entry>7.0-CURRENT after the modification of bus_setup_intr() (newbus).
</entry>
<entry>700031</entry>
</row>
<row>
<entry>7.0-CURRENT after the inclusion of ipw(4) and iwi(4) firmwares.
</entry>
<entry>700032</entry>
</row>
<row>
<entry>7.0-CURRENT after the inclusion of ncurses wide character support.
</entry>
<entry>700033</entry>
</row>
<row>
<entry>7.0-CURRENT after changes to how insmntque(),
getnewvnode(), and vfs_hash_insert() work.
</entry>
<entry>700034</entry>
</row>
<row>
<entry>7.0-CURRENT after addition of a notify mechanism
for CPU frequency changes.
</entry>
<entry>700035</entry>
</row>
<row>
<entry>7.0-CURRENT after import of the ZFS filesystem.</entry>
<entry>700036</entry>
</row>
<row>
<entry>7.0-CURRENT after addition of CAM 'SG' peripheral device,
which implements a subset of Linux SCSI SG passthrough device API.</entry>
<entry>700037</entry>
</row>
<row>
<entry>7.0-CURRENT after changing &man.getenv.3;, &man.putenv.3;,
&man.setenv.3; and &man.unsetenv.3; to be POSIX
conformant.</entry>
<entry>700038</entry>
</row>
<row>
<entry>7.0-CURRENT after the changes in 700038 were
backed out.</entry>
<entry>700039</entry>
</row>
<row>
<entry>7.0-CURRENT after the addition of &man.flopen.3;
to libutil.</entry>
<entry>700040</entry>
</row>
<row>
<entry>7.0-CURRENT after enabling symbol versioning, and changing
the default thread library to libthr.</entry>
<entry>700041</entry>
</row>
<row>
<entry>7.0-CURRENT after the import of gcc 4.2.0.</entry>
<entry>700042</entry>
</row>
<row>
<entry>7.0-CURRENT after bump of all shared library
versions that had not been changed since
RELENG_6.</entry>
<entry>700043</entry>
</row>
<row>
<entry>7.0-CURRENT after changing the argument for
vn_open()/VOP_OPEN() from filedescriptor index to the
struct file *.</entry>
<entry>700044</entry>
</row>
<row>
<entry>7.0-CURRENT after changing &man.pam.nologin.8; to
provide an account management function instead of an
authentication function to the PAM framework.</entry>
<entry>700045</entry>
</row>
<row>
<entry>7.0-CURRENT after updated 802.11 wireless
support.</entry>
<entry>700046</entry>
</row>
<row>
<entry>7.0-CURRENT after adding TCP LRO interface
capabilities.</entry>
<entry>700047</entry>
</row>
<row>
<entry>7.0-CURRENT after
RFC 3678 API support added to the IPv4 stack.
Legacy RFC 1724 behaviour of the IP_MULTICAST_IF
ioctl has now been removed; 0.0.0.0/8 may no longer
be used to specify an interface index.
struct ipmreqn should be used instead.</entry>
<entry>700048</entry>
</row>
<row>
<entry>7.0-CURRENT after importing pf from OpenBSD
4.1</entry>
<entry>700049</entry>
</row>
<row>
<entry>7.0-CURRENT after adding IPv6 support for
FAST_IPSEC, deleting KAME IPSEC, and renaming
FAST_IPSEC to IPSEC.</entry>
<entry>(not changed)</entry>
</row>
<row>
<entry>7.0-CURRENT after converting setenv/putenv/etc.
calls from traditional BSD to POSIX.</entry>
<entry>700050</entry>
</row>
<row>
<entry>7.0-CURRENT after adding new mmap/lseek/etc
syscalls.</entry>
<entry>700051</entry>
</row>
<row>
<entry>7.0-CURRENT after moving I4B headers to
include/i4b.</entry>
<entry>700052</entry>
</row>
<row>
<entry>7.0-CURRENT after the addition of support for
PCI domains</entry>
<entry>700053</entry>
</row>
<row>
<entry>7.0-CURRENT after MFC of wide and single byte
ctype separation.</entry>
<entry>700054</entry>
</row>
<row>
<entry>7.0-RELEASE, and 7.0-CURRENT after ABI backwards compatibility
to the FreeBSD 4/5/6 versions of the PCIOCGETCONF,
PCIOCREAD and PCIOCWRITE IOCTLs was MFC'ed, which
required the ABI of the PCIOCGETCONF IOCTL to be
broken again</entry>
<entry>700055</entry>
</row>
<row>
<entry>7.0-STABLE after 7.0-RELEASE</entry>
<entry>700100</entry>
</row>
<row>
<entry>7.0-STABLE after the MFC of m_collapse().</entry>
<entry>700101</entry>
</row>
<row>
<entry>7.0-STABLE after the MFC of kdb_enter_why().</entry>
<entry>700102</entry>
</row>
<row>
<entry>7.0-STABLE after adding l_sysid to struct flock.</entry>
<entry>700103</entry>
</row>
<row>
<entry>7.0-STABLE after the MFC of procstat(1).</entry>
<entry>700104</entry>
</row>
<row>
<entry>7.0-STABLE after the MFC of umtx features. </entry>
<entry>700105</entry>
</row>
<row>
<entry>7.0-STABLE after the MFC of &man.write.2; support
to &man.psm.4;.</entry>
<entry>700106</entry>
</row>
<row>
<entry>7.0-STABLE after the MFC of F_DUP2FD command
to &man.fcntl.2;.</entry>
<entry>700107</entry>
</row>
<row>
<entry>7.0-STABLE after some &man.lockmgr.9; changes, which
makes it necessary to include
<filename>sys/lock.h</filename> in order to use
&man.lockmgr.9;.</entry>
<entry>700108</entry>
</row>
<row>
<entry>7.0-STABLE after MFC of the
<function>memrchr</function> function.</entry>
<entry>700109</entry>
</row>
<row>
<entry>7.0-STABLE after MFC of kernel NFS lockd client.
</entry>
<entry>700110</entry>
</row>
<row>
<entry>7.0-STABLE after addition of physically contiguous
jumbo frame support.</entry>
<entry>700111</entry>
</row>
<row>
<entry>7.0-STABLE after MFC of kernel DTrace support.
</entry>
<entry>700112</entry>
</row>
<row>
<entry>7.1-RELEASE</entry>
<entry>701000</entry>
</row>
<row>
<entry>7.1-STABLE after 7.1-RELEASE.</entry>
<entry>701100</entry>
</row>
<row>
<entry>8.0-CURRENT. Separating wide and single byte
ctype.</entry>
<entry>800000</entry>
</row>
<row>
<entry>8.0-CURRENT after libpcap 0.9.8 and tcpdump 3.9.8
import.</entry>
<entry>800001</entry>
</row>
<row>
<entry>8.0-CURRENT after renaming kthread_create()
and friends to kproc_create() etc.</entry>
<entry>800002</entry>
</row>
<row>
<entry>8.0-CURRENT after ABI backwards compatibility
to the FreeBSD 4/5/6 versions of the PCIOCGETCONF,
PCIOCREAD and PCIOCWRITE IOCTLs was added, which
required the ABI of the PCIOCGETCONF IOCTL to be
broken again</entry>
<entry>800003</entry>
</row>
<row>
<entry>8.0-CURRENT after agp(4) driver moved from
src/sys/pci to src/sys/dev/agp</entry>
<entry>800004</entry>
</row>
<row>
<entry>8.0-CURRENT after
<link xlink:href="http://www.freebsd.org/cgi/cvsweb.cgi/src/sys/kern/kern_mbuf.c#rev1.35">changes
to the jumbo frame allocator</link>.</entry>
<entry>800005</entry>
</row>
<row>
<entry>8.0-CURRENT after the addition of callgraph
capture functionality to &man.hwpmc.4;.</entry>
<entry>800006</entry>
</row>
<row>
<entry>8.0-CURRENT after kdb_enter() gains a "why"
argument.</entry>
<entry>800007</entry>
</row>
<row>
<entry>8.0-CURRENT after LK_EXCLUPGRADE option
removal.</entry>
<entry>800008</entry>
</row>
<row>
<entry>8.0-CURRENT after introduction of
&man.lockmgr.disown.9;</entry>
<entry>800009</entry>
</row>
<row>
<entry>8.0-CURRENT after the &man.vn.lock.9; prototype
change.</entry>
<entry>800010</entry>
</row>
<row>
<entry>8.0-CURRENT after the &man.VOP.LOCK.9; and
&man.VOP.UNLOCK.9; prototype changes.</entry>
<entry>800011</entry>
</row>
<row>
<entry>8.0-CURRENT after introduction of
&man.lockmgr.recursed.9;, &man.BUF.RECURSED.9; and
&man.BUF.ISLOCKED.9; and the removal of
<function>BUF_REFCNT()</function>.</entry>
<entry>800012</entry>
</row>
<row>
<entry>8.0-CURRENT after introduction of the
<quote>ASCII</quote> encoding.</entry>
<entry>800013</entry>
</row>
<row>
<entry>8.0-CURRENT after changing the prototype of
&man.lockmgr.9; and removal of
<function>lockcount()</function> and
<function>LOCKMGR_ASSERT()</function>.</entry>
<entry>800014</entry>
</row>
<row>
<entry>8.0-CURRENT after extending the types
of the &man.fts.3; structures.</entry>
<entry>800015</entry>
</row>
<row>
<entry>8.0-CURRENT after adding an argumentt to MEXTADD(9)
</entry>
<entry>800016</entry>
</row>
<row>
<entry>8.0-CURRENT after the introduction of
LK_NODUP and LK_NOWITNESS options in the
&man.lockmgr.9; space.</entry>
<entry>800017</entry>
</row>
<row>
<entry>8.0-CURRENT after the addition of
m_collapse.</entry>
<entry>800018</entry>
</row>
<row>
<entry>8.0-CURRENT after the addition of current
working directory, root directory, and jail
directory support to the kern.proc.filedesc
sysctl.</entry>
<entry>800019</entry>
</row>
<row>
<entry>8.0-CURRENT after introduction of
&man.lockmgr.assert.9; and
<function>BUF_ASSERT</function> functions.</entry>
<entry>800020</entry>
</row>
<row>
<entry>8.0-CURRENT after introduction of
&man.lockmgr.args.9; and LK_INTERNAL flag
removal.</entry>
<entry>800021</entry>
</row>
<row>
<entry>8.0-CURRENT after changing the default system ar
to BSD &man.ar.1;.</entry>
<entry>800022</entry>
</row>
<row>
<entry>8.0-CURRENT after changing the prototypes of
&man.lockstatus.9; and &man.VOP.ISLOCKED.9;, more
specifically retiring the
<literal>struct thread</literal> argument.</entry>
<entry>800023</entry>
</row>
<row>
<entry>8.0-CURRENT after axing out the
<function>lockwaiters</function> and
<function>BUF_LOCKWAITERS</function> functions,
changing the return value fo <function>brelvp</function>
from void to int and introducing new flags for
&man.lockinit.9;.</entry>
<entry>800024</entry>
</row>
<row>
<entry>8.0-CURRENT after adding F_DUP2FD command
to &man.fcntl.2;.</entry>
<entry>800025</entry>
</row>
<row>
<entry>8.0-CURRENT after changing the priority parameter
to cv_broadcastpri such that 0 means no priority.
</entry>
<entry>800026</entry>
</row>
<row>
<entry>8.0-CURRENT after changing the bpf monitoring ABI
when zerocopy bpf buffers were added.
</entry>
<entry>800027</entry>
</row>
<row>
<entry>8.0-CURRENT after adding l_sysid to struct flock.
</entry>
<entry>800028</entry>
</row>
<row>
<entry>8.0-CURRENT after reintegration of the
<function>BUF_LOCKWAITERS</function> function and the
addition of &man.lockmgr.waiters.9;.</entry>
<entry>800029</entry>
</row>
<row>
<entry>8.0-CURRENT after the introduction of the
&man.rw.try.rlock.9; and &man.rw.try.wlock.9; functions.
</entry>
<entry>800030</entry>
</row>
<row>
<entry>8.0-CURRENT after the introduction of the
<function>lockmgr_rw</function> and
<function>lockmgr_args_rw</function> functions.</entry>
<entry>800031</entry>
</row>
<row>
<entry>8.0-CURRENT after the implementation of the
openat and related syscalls, introduction of the O_EXEC
flag for the &man.open.2;, and providing the
corresponding linux compatibility syscalls.</entry>
<entry>800032</entry>
</row>
<row>
<entry>8.0-CURRENT after added &man.write.2; support for
&man.psm.4; in native operation level. Now arbitrary
commands can be written to <filename>/dev/psm%d</filename>
and status can be read back from it.</entry>
<entry>800033</entry>
</row>
<row>
<entry>8.0-CURRENT after introduction of the
<function>memrchr</function> function.</entry>
<entry>800034</entry>
</row>
<row>
<entry>8.0-CURRENT after introduction of the
<function>fdopendir</function> function.</entry>
<entry>800035</entry>
</row>
<row>
<entry>8.0-CURRENT after switchover of 802.11 wireless
to multi-bss support (aka vaps).</entry>
<entry>800036</entry>
</row>
<row>
<entry>8.0-CURRENT after addition of multi routing
table support (a.k.a. setfib(1), setfib(2)).</entry>
<entry>800037</entry>
</row>
<row>
<entry>8.0-CURRENT after removal of netatm and
ISDN4BSD.</entry>
<entry>800038</entry>
</row>
<row>
<entry>8.0-CURRENT after removal of sgtty.</entry>
<entry>800039</entry>
</row>
<row>
<entry>8.0-CURRENT with kernel NFS lockd client.</entry>
<entry>800040</entry>
</row>
<row>
<entry>8.0-CURRENT after addition of arc4random_buf(3)
and arc4random_uniform(3).</entry>
<entry>800041</entry>
</row>
<row>
<entry>8.0-CURRENT after addition of cpuctl(4).</entry>
<entry>800042</entry>
</row>
<row>
<entry>8.0-CURRENT after changing bpf(4) to use a
single device node, instead of device cloning.</entry>
<entry>800043</entry>
</row>
<row>
<entry>8.0-CURRENT after the commit of the first step of
the vimage project renaming global variables to be
virtualized with a V_ prefix with macros to map them
back to their global names.</entry>
<entry>800044</entry>
</row>
<row>
<entry>8.0-CURRENT after the integration of the
MPSAFE TTY layer, including changes to various
drivers and utilities that interact with it.</entry>
<entry>800045</entry>
</row>
<row>
<entry>8.0-CURRENT after the separation of the GDT
per CPU on amd64 architecture.</entry>
<entry>800046</entry>
</row>
<row>
<entry>8.0-CURRENT after removal of VSVTX, VSGID
and VSUID.</entry>
<entry>800047</entry>
</row>
<row>
<entry>8.0-CURRENT after converting the kernel NFS mount
code to accept individual mount options in the
nmount() iovec, not just one big
struct nfs_args.</entry>
<entry>800048</entry>
</row>
<row>
<entry>8.0-CURRENT after the removal of &man.suser.9; and
&man.suser.cred.9;.</entry>
<entry>800049</entry>
</row>
</tbody>
</tgroup>
</table>
<note>
<para>Note that 2.2-STABLE sometimes identifies itself as
<quote>2.2.5-STABLE</quote> after the 2.2.5-RELEASE. The pattern
used to be year followed by the month, but we decided to change it
to a more straightforward major/minor system starting from 2.2.
This is because the parallel development on several branches made
it infeasible to classify the releases simply by their real
release dates. If you are making a port now, you do not have to
worry about old -CURRENTs; they are listed here just for your
reference.</para>
</note>
</sect1>
<sect1 xml:id="dads-after-port-mk">
<title>Writing something after
<filename>bsd.port.mk</filename></title>
<para>Do not write anything after the <literal>.include
&lt;bsd.port.mk&gt;</literal> line. It usually can be avoided by
including <filename>bsd.port.pre.mk</filename> somewhere in the
middle of your <filename>Makefile</filename> and
<filename>bsd.port.post.mk</filename> at the end.</para>
<note>
<para>You need to include either the
<filename>bsd.port.pre.mk</filename>/<filename>bsd.port.post.mk</filename> pair or
<filename>bsd.port.mk</filename> only; do not mix these two usages.</para>
</note>
<para><filename>bsd.port.pre.mk</filename> only defines a few
variables, which can be used in tests in the
<filename>Makefile</filename>, <filename>bsd.port.post.mk</filename>
defines the rest.</para>
<para>Here are some important variables defined in
<filename>bsd.port.pre.mk</filename> (this is not the complete list,
please read <filename>bsd.port.mk</filename> for the complete
list).</para>
<informaltable frame="none" pgwide="1">
<tgroup cols="2">
<thead>
<row>
<entry>Variable</entry>
<entry>Description</entry>
</row>
</thead>
<tbody>
<row>
<entry><varname>ARCH</varname></entry>
<entry>The architecture as returned by <command>uname
-m</command> (e.g., <literal>i386</literal>)</entry>
</row>
<row>
<entry><varname>OPSYS</varname></entry>
<entry>The operating system type, as returned by
<command>uname -s</command> (e.g.,
<literal>FreeBSD</literal>)</entry>
</row>
<row>
<entry><varname>OSREL</varname></entry>
<entry>The release version of the operating system (e.g.,
<literal>2.1.5</literal> or
<literal>2.2.7</literal>)</entry>
</row>
<row>
<entry><varname>OSVERSION</varname></entry>
<entry>The numeric version of the operating system; the same as
<link linkend="freebsd-versions"><literal>__FreeBSD_version</literal></link>.</entry>
</row>
<row>
<entry><varname>PORTOBJFORMAT</varname></entry>
<entry>The object format of the system
(<literal>elf</literal> or <literal>aout</literal>;
note that for <quote>modern</quote> versions of FreeBSD,
<literal>aout</literal> is deprecated.)</entry>
</row>
<row>
<entry><varname>LOCALBASE</varname></entry>
<entry>The base of the <quote>local</quote> tree (e.g.,
<literal>/usr/local/</literal>)</entry>
</row>
<row>
<entry><varname>PREFIX</varname></entry>
<entry>Where the port installs itself (see <link linkend="porting-prefix">more on
<varname>PREFIX</varname></link>).</entry>
</row>
</tbody>
</tgroup>
</informaltable>
<note>
<para>If you have to define the variables
<varname>USE_IMAKE</varname>, <varname>USE_X_PREFIX</varname>, or
<varname>MASTERDIR</varname>, do so before including
<filename>bsd.port.pre.mk</filename>.</para>
</note>
<para>Here are some examples of things you can write after
<filename>bsd.port.pre.mk</filename>:</para>
<programlisting># no need to compile lang/perl5 if perl5 is already in system
.if ${OSVERSION} &gt; 300003
BROKEN= perl is in system
.endif
# only one shlib version number for ELF
.if ${PORTOBJFORMAT} == "elf"
TCL_LIB_FILE= ${TCL_LIB}.${SHLIB_MAJOR}
.else
TCL_LIB_FILE= ${TCL_LIB}.${SHLIB_MAJOR}.${SHLIB_MINOR}
.endif
# software already makes link for ELF, but not for a.out
post-install:
.if ${PORTOBJFORMAT} == "aout"
${LN} -sf liblinpack.so.1.0 ${PREFIX}/lib/liblinpack.so
.endif</programlisting>
<para>You did remember to use tab instead of spaces after
<literal>BROKEN=</literal> and
<literal>TCL_LIB_FILE=</literal>, did you not?
<!-- smiley -->:-).</para>
</sect1>
<sect1 xml:id="dads-sh-exec">
<title>在 wrapper scripts 中使用 <function>exec</function> 述句</title>
<para>若某 port 為了執行其他程式而安裝了一個 shell script
而該程式同時也是該 script 最後一個動作,那麼需要確定該 script
是用 <function>exec</function> 述句statement舉例而言</para>
<programlisting>#!/bin/sh
exec %%LOCALBASE%%/bin/java -jar %%DATADIR%%/foo.jar "$@"</programlisting>
<para><function>exec</function> 述句以所指定的程式取代了該 shell
的程序。 若省略 <function>exec</function> ,那麼該 shell 程序
將會在程式執行中一直存在於記憶體,這無疑地浪費了系統資源。</para>
</sect1>
<sect1 xml:id="dads-uid-and-gids">
<title>UIDs 及 GIDs</title>
<para>The current list of reserved UIDs and GIDs can be found
in <filename>ports/UIDs</filename> and
<filename>ports/GIDs</filename>.</para>
<para>If your port requires a certain user to be on the installed
system, let the <filename>pkg-install</filename> script call
<command>pw</command> to create it automatically. Look at
<package>net/cvsup-mirror</package> for an example.
Please note that this is strongly discouraged, please register
user/group ID numbers as stated below.</para>
<para>If your port must use the same user/group ID number when it is
installed as a binary package as when it was compiled, then you must
choose a free UID from 50 to 999 and register it either in
<filename>ports/UIDs</filename> (for users) or in
<filename>ports/GIDs</filename> (for groups). Look at
<package>japanese/Wnn6</package> for an example.</para>
<para>Make sure you do not use a UID already used by the system or
other ports.</para>
<para>Please include a patch against these two files when you
require a new user or group to be created for your
port.</para>
</sect1>
<sect1 xml:id="dads-rational">
<title>Do things rationally</title>
<para>The <filename>Makefile</filename> should do things simply and
reasonably. If you can make it a couple of lines shorter or more
readable, then do so. Examples include using a make
<literal>.if</literal> construct instead of a shell
<literal>if</literal> construct, not redefining
<buildtarget>do-extract</buildtarget> if you can redefine
<varname>EXTRACT*</varname> instead, and using
<varname>GNU_CONFIGURE</varname> instead of <literal>CONFIGURE_ARGS
+= --prefix=&dollar;{PREFIX}</literal>.</para>
<para>If you find yourself having to write a lot
of new code to try to do something, please go back and review
<filename>bsd.port.mk</filename> to see if it contains an
existing implementation of what you are trying to do. While
hard to read, there are a great many seemingly-hard problems for
which <filename>bsd.port.mk</filename> already provides a
shorthand solution.</para>
</sect1>
<sect1 xml:id="dads-cc">
<title>Respect both <varname>CC</varname> and
<varname>CXX</varname></title>
<para>The port should respect both <varname>CC</varname>
and <varname>CXX</varname> variables. What we mean by this
is that the port should not set the values of these variables
absolutely, overriding existing values; instead, it should append
whatever values it needs to the existing values. This is so that
build options that affect all ports can be set globally.</para>
<para>If the port does not respect these variables,
please add <literal>NO_PACKAGE=ignores either cc or
cxx</literal> to the <filename>Makefile</filename>.</para>
<para>An example of a <filename>Makefile</filename> respecting
both <varname>CC</varname> and <varname>CXX</varname>
variables follows. Note the <varname>?=</varname>:</para>
<programlisting>CC?= gcc</programlisting>
<programlisting>CXX?= g++</programlisting>
<para>Here is an example which respects neither
<varname>CC</varname> nor <varname>CXX</varname>
variables:</para>
<programlisting>CC= gcc</programlisting>
<programlisting>CXX= g++</programlisting>
<para>Both <varname>CC</varname> and <varname>CXX</varname>
variables can be defined on FreeBSD systems in
<filename>/etc/make.conf</filename>. The first example
defines a value if it was not previously set in
<filename>/etc/make.conf</filename>, preserving any
system-wide definitions. The second example clobbers
anything previously defined.</para>
</sect1>
<sect1 xml:id="dads-cflags">
<title>Respect <varname>CFLAGS</varname></title>
<para>The port should respect the <varname>CFLAGS</varname> variable.
What we mean by this is that the port should not set the value of
this variable absolutely, overriding the existing value; instead,
it should append whatever values it needs to the existing value.
This is so that build options that affect all ports can be set
globally.</para>
<para>If it does not, please add <literal>NO_PACKAGE=ignores
cflags</literal> to the <filename>Makefile</filename>.</para>
<para>An example of a <filename>Makefile</filename> respecting
the <varname>CFLAGS</varname> variable follows. Note the
<varname>+=</varname>:</para>
<programlisting>CFLAGS+= -Wall -Werror</programlisting>
<para>Here is an example which does not respect the
<varname>CFLAGS</varname> variable:</para>
<programlisting>CFLAGS= -Wall -Werror</programlisting>
<para>The <varname>CFLAGS</varname> variable is defined on
FreeBSD systems in <filename>/etc/make.conf</filename>. The
first example appends additional flags to the
<varname>CFLAGS</varname> variable, preserving any system-wide
definitions. The second example clobbers anything previously
defined.</para>
<para>You should remove optimization flags from the third party
<filename>Makefile</filename>s. System <varname>CFLAGS</varname>
contains system-wide optimization flags. An example from
an unmodified <filename>Makefile</filename>:</para>
<programlisting>CFLAGS= -O3 -funroll-loops -DHAVE_SOUND</programlisting>
<para>Using system optimization flags, the
<filename>Makefile</filename> would look similar to the
following example:</para>
<programlisting>CFLAGS+= -DHAVE_SOUND</programlisting>
</sect1>
<sect1 xml:id="dads-pthread">
<title>Threading libraries</title>
<para>The threading library must be linked to the binaries
using a special linker flag <literal>-pthread</literal> on
&os;. If a port insists on linking
<literal>-lpthread</literal> or <literal>-lc_r</literal>
directly, patch it to use <varname>PTHREAD_LIBS</varname>
variable provided by the ports framework. This variable
usually has the value of <literal>-pthread</literal>, but
on certain architectures and &os; versions it can have
different values, so do not just hardcode
<literal>-pthread</literal> into patches and always use
<varname>PTHREAD_LIBS</varname>.</para>
<note>
<para>If building the port errors out with <literal>unrecognized
option '-pthread'</literal> when setting
<varname>PTHREAD_LIBS</varname>, it may be desirable to use
<command>gcc</command> as linker by setting
<varname>CONFIGURE_ENV</varname> to <literal>LD=${CC}</literal>.
The <literal>-pthread</literal> option is not supported by
<command>ld</command> directly.</para>
</note>
</sect1>
<sect1 xml:id="dads-freedback">
<title>Feedback</title>
<para>Do send applicable changes/patches to the original
author/maintainer for inclusion in next release of the code. This
will only make your job that much easier for the next
release.</para>
</sect1>
<sect1 xml:id="dads-readme">
<title><filename>README.html</filename></title>
<para>Do not include the <filename>README.html</filename> file. This
file is not part of the cvs collection but is generated using the
<command>make readme</command> command.
</para>
</sect1>
<sect1 xml:id="dads-noinstall">
<title>Marking a port not installable with <varname>BROKEN</varname>,
<varname>FORBIDDEN</varname>, or <varname>IGNORE</varname></title>
<para>In certain cases users should be prevented from installing
a port. To tell a user that
a port should not be installed, there are several
<command>make</command> variables that can be used in a port's
<filename>Makefile</filename>. The value of the following
<command>make</command> variables will be the reason that is
given back to users for why the port refuses to install itself.
Please use the correct <command>make</command> variable as
each make variable conveys radically different meanings to
both users, and to automated systems that depend on the
<filename>Makefile</filename>s, such as
<link linkend="build-cluster">the ports build cluster</link>,
<link linkend="freshports">FreshPorts</link>, and
<link linkend="portsmon">portsmon</link>.</para>
<sect2 xml:id="dads-noinstall-variables">
<title>Variables</title>
<itemizedlist>
<listitem>
<para><varname>BROKEN</varname> is reserved for ports that
currently do not compile, install, or deinstall correctly.
It should be used for ports where the problem is
believed to be temporary.</para>
<para>If instructed, the build cluster will still attempt to
try to build
them to see if the underlying problem has been
resolved. (However, in general, the cluster is run without
this.)</para>
<para>For instance, use
<varname>BROKEN</varname> when a port:</para>
<itemizedlist>
<listitem>
<para>does not compile</para>
</listitem>
<listitem>
<para>fails its configuration or installation process</para>
</listitem>
<listitem>
<para>installs files outside of
<filename>${LOCALBASE}</filename></para>
</listitem>
<listitem>
<para>does not remove all its files cleanly upon
deinstall (however, it may be acceptable, and desirable,
for the port to leave user-modified files behind)</para>
</listitem>
</itemizedlist>
</listitem>
<listitem>
<para><varname>FORBIDDEN</varname> is used for ports that
do contain a security vulnerability or induce grave
concern regarding the security of a FreeBSD system with
a given port installed (ex: a reputably insecure program
or a program that provides easily exploitable services).
Ports should be marked as <varname>FORBIDDEN</varname>
as soon as a particular piece of software has a
vulnerability and there is no released upgrade. Ideally
ports should be upgraded as soon as possible when a
security vulnerability is discovered so as to reduce the
number of vulnerable FreeBSD hosts (we like being known
for being secure), however sometimes there is a
noticeable time gap between disclosure of a
vulnerability and an updated release of the
vulnerable software. Do not mark a port
<varname>FORBIDDEN</varname> for any reason other than
security.</para>
</listitem>
<listitem>
<para><varname>IGNORE</varname> is reserved for ports that
should not be built for some other reason.
It should be used for ports where the problem is
believed to be structural.
The build
cluster will not, under any
circumstances, build ports marked as
<varname>IGNORE</varname>. For instance, use
<varname>IGNORE</varname> when a port:</para>
<itemizedlist>
<listitem>
<para>compiles but does not run properly</para>
</listitem>
<listitem>
<para>does not work on the installed version of &os;</para>
</listitem>
<listitem>
<para>requires &os; kernel sources to build, but the
user does not have them installed</para>
</listitem>
<listitem>
<para>has a distfile which may not be automatically
fetched due to licensing restrictions</para>
</listitem>
<listitem>
<para>does not work with some other currently installed
port (for instance, the port depends on
<package>www/apache21</package> but
<package>www/apache13</package>
is installed)</para>
</listitem>
</itemizedlist>
<note>
<para>If a port would conflict with a currently installed
port (for example, if they install a file in the same
place that perfoms a different function),
<link linkend="conflicts">use
<varname>CONFLICTS</varname> instead</link>.
<varname>CONFLICTS</varname> will set
<varname>IGNORE</varname> by itself.</para>
</note>
</listitem>
<listitem>
<para>If a port should be marked <varname>IGNORE</varname>
only on certain architectures, there are two other
convenience variables that will automatically set
<varname>IGNORE</varname> for you:
<varname>ONLY_FOR_ARCHS</varname> and
<varname>NOT_FOR_ARCHS</varname>. Examples:</para>
<programlisting>ONLY_FOR_ARCHS= i386 amd64</programlisting>
<programlisting>NOT_FOR_ARCHS= alpha ia64 sparc64</programlisting>
<para>A custom <varname>IGNORE</varname> message can be set
using <varname>ONLY_FOR_ARCHS_REASON</varname> and
<varname>NOT_FOR_ARCHS_REASON</varname>. Per architecture
entries are possible with
<varname>ONLY_FOR_ARCHS_REASON_<replaceable>ARCH</replaceable></varname>
and
<varname>NOT_FOR_ARCHS_REASON_<replaceable>ARCH</replaceable></varname>.</para>
</listitem>
<listitem>
<para>If a port fetches i386 binaries and installs them,
<varname>IA32_BINARY_PORT</varname> should be set. If this
variable is set, it will be checked whether the
<filename>/usr/lib32</filename> directory is available for
IA32 versions of libraries and whether the kernel
has IA32 compatibility compiled in. If one of these two
dependencies is not satisfied, <varname>IGNORE</varname> will
be set automatically.</para>
</listitem>
</itemizedlist>
</sect2>
<sect2 xml:id="dads-noinstall-notes">
<title>Implementation Notes</title>
<para>The strings should not be quoted.
Also, the wording of the string should be somewhat
different due to the way the information is shown to the
user. Examples:</para>
<programlisting>BROKEN= this port is unsupported on FreeBSD 5.x</programlisting>
<programlisting>IGNORE= is unsupported on FreeBSD 5.x</programlisting>
<para>resulting in the following output from
<command>make describe</command>:</para>
<programlisting>===&gt; foobar-0.1 is marked as broken: this port is unsupported on FreeBSD 5.x.</programlisting>
<programlisting>===&gt; foobar-0.1 is unsupported on FreeBSD 5.x.</programlisting>
</sect2>
</sect1>
<sect1 xml:id="dads-deprecated">
<title>Marking a port for removal with <varname>DEPRECATED</varname>
or <varname>EXPIRATION_DATE</varname></title>
<para>Do remember that <varname>BROKEN</varname> and
<varname>FORBIDDEN</varname> are to be used as a
temporary resort if a port is not working. Permanently
broken ports should be removed from the tree
entirely.</para>
<para>When it makes sense to do so, users can be warned about
a pending port removal with <varname>DEPRECATED</varname>
and <varname>EXPIRATION_DATE</varname>. The former is
simply a string stating why the port is scheduled for removal;
the latter is a string in ISO 8601 format (YYYY-MM-DD). Both
will be shown to the user.</para>
<para>It is possible to set <varname>DEPRECATED</varname>
without an <varname>EXPIRATION_DATE</varname> (for
instance, recommending a newer version of the port), but
the converse does not make any sense.</para>
<para>There is no set policy on how much notice to give.
Current practice seems to be one month for security-related
issues and two months for build issues. This also gives any
interested committers a little time to fix the problems.</para>
</sect1>
<sect1 xml:id="dads-dot-error">
<title>Avoid use of the <literal>.error</literal> construct</title>
<para>The correct way for a <filename>Makefile</filename> to
signal that the port can not be installed due to some external
factor (for instance, the user has specified an illegal
combination of build options) is to set a nonblank value to
<varname>IGNORE</varname>. This value will be formatted and
shown to the user by <command>make install</command>.</para>
<para>It is a common mistake to use <literal>.error</literal>
for this purpose. The problem with this is that many
automated tools that work with the ports tree will fail in
this situation. The most common occurrence of this is seen
when trying to build <filename>/usr/ports/INDEX</filename>
(see <xref linkend="make-describe"/>). However, even more
trivial commands such as <command>make -V maintainer</command>
also fail in this scenario. This is not acceptable.</para>
<example xml:id="dot-error-breaks-index">
<title>How to avoid using <literal>.error</literal></title>
<para>Assume that someone has the line
<programlisting>USE_POINTYHAT=yes</programlisting>
in <filename>make.conf</filename>. The first of
the next two <filename>Makefile</filename> snippets will
cause <command>make index</command> to fail, while the
second one will not:</para>
<programlisting>.if USE_POINTYHAT
.error "POINTYHAT is not supported"
.endif</programlisting>
<programlisting>.if USE_POINTYHAT
IGNORE=POINTYHAT is not supported
.endif</programlisting>
</example>
</sect1>
<sect1 xml:id="dads-sysctl">
<title><filename>sysctl</filename> 使用時機</title>
<para><filename>sysctl</filename> 除了在 targets 之外,都不鼓勵使用。
這是因為任何 <literal>makevar</literal>
的評估都有可能會使得程序執行速度變慢。例如在
<command>make index</command> 的過程中就會需要用到
<filename>sysctl</filename></para>
<para>若要使用 &man.sysctl.8; 則必須透過 <varname>SYSCTL</varname>
此一變數才可,因為這樣才會包含完整路徑,
同時也可以隨時因應使用者需求而替換為其他路徑。</para>
</sect1>
<sect1 xml:id="dads-rerolling-distfiles">
<title>Rerolling distfiles</title>
<para>Sometimes the authors of software change the content of
released distfiles without changing the file's name. You have
to verify that the changes are official and have been performed
by the author. It has happened in the past that the distfile
was silently altered on the download servers with the intent
to cause harm or compromise end user security.</para>
<para>Put the old distfile aside, download the new one, unpack
them and compare the content with &man.diff.1;. If you see
nothing suspicious, you can update <filename>distinfo</filename>.
Be sure to summarize the differences in your PR or commit log,
so that other people know that you have taken care to ensure
that nothing bad has happened.</para>
<para>You might also want to contact the authors of the software
and confirm the changes with them.</para>
</sect1>
<sect1 xml:id="dads-workarounds">
<title>Necessary workarounds</title>
<para>Sometimes it is necessary to work around bugs in
software included with older versions of &os;.</para>
<itemizedlist>
<listitem>
<para>Some versions of &man.make.1; were broken
on at least 4.8 and 5.0 with respect to handling
comparisons based on <varname>OSVERSION</varname>.
This would often lead to failures during
<command>make describe</command> (and thus, the overall
ports <command>make index</command>). The workaround is
to enclose the conditional comparison in spaces, e.g.:
<programlisting>if ( ${OSVERSION} &gt; 500023 )</programlisting>
Be aware that test-installing a port on 4.9 or 5.2
will <emphasis>not</emphasis> detect this problem.</para>
</listitem>
</itemizedlist>
</sect1>
<sect1 xml:id="dads-misc">
<title>Miscellanea</title>
<para>The files
<filename>pkg-descr</filename> and <filename>pkg-plist</filename>
should each be double-checked. If you are reviewing a port and feel
they can be worded better, do so.</para>
<para>Do not copy more copies of the GNU General Public License into
our system, please.</para>
<para>Please be careful to note any legal issues! Do not let us
illegally distribute software!</para>
</sect1>
</chapter>
<chapter xml:id="porting-samplem">
<title>A Sample <filename>Makefile</filename></title>
<para>Here is a sample <filename>Makefile</filename> that you can use to
create a new port. Make sure you remove all the extra comments (ones
between brackets)!</para>
<para>It is recommended that you follow this format (ordering of
variables, empty lines between sections, etc.). This format is
designed so that the most important information is easy to locate. We
recommend that you use <link linkend="porting-portlint">portlint</link> to check the
<filename>Makefile</filename>.</para>
<programlisting>[the header...just to make it easier for us to identify the ports.]
# New ports collection makefile for: xdvi
[the "version required" line is only needed when the PORTVERSION
variable is not specific enough to describe the port.]
# Date created: 26 May 1995
[this is the person who did the original port to FreeBSD, in particular, the
person who wrote the first version of this Makefile. Remember, this should
not be changed when upgrading the port later.]
# Whom: Satoshi Asami &lt;asami@FreeBSD.org&gt;
#
# &dollar;FreeBSD&dollar;
[ ^^^^^^^^^ This will be automatically replaced with RCS ID string by CVS
when it is committed to our repository. If upgrading a port, do not alter
this line back to "&dollar;FreeBSD&dollar;". CVS deals with it automatically.]
#
[section to describe the port itself and the master site - PORTNAME
and PORTVERSION are always first, followed by CATEGORIES,
and then MASTER_SITES, which can be followed by MASTER_SITE_SUBDIR.
PKGNAMEPREFIX and PKGNAMESUFFIX, if needed, will be after that.
Then comes DISTNAME, EXTRACT_SUFX and/or DISTFILES, and then
EXTRACT_ONLY, as necessary.]
PORTNAME= xdvi
PORTVERSION= 18.2
CATEGORIES= print
[do not forget the trailing slash ("/")!
if you are not using MASTER_SITE_* macros]
MASTER_SITES= ${MASTER_SITE_XCONTRIB}
MASTER_SITE_SUBDIR= applications
PKGNAMEPREFIX= ja-
DISTNAME= xdvi-pl18
[set this if the source is not in the standard ".tar.gz" form]
EXTRACT_SUFX= .tar.Z
[section for distributed patches -- can be empty]
PATCH_SITES= ftp://ftp.sra.co.jp/pub/X11/japanese/
PATCHFILES= xdvi-18.patch1.gz xdvi-18.patch2.gz
[maintainer; *mandatory*! This is the person who is volunteering to
handle port updates, build breakages, and to whom a users can direct
questions and bug reports. To keep the quality of the Ports Collection
as high as possible, we no longer accept new ports that are assigned to
"ports@FreeBSD.org".]
MAINTAINER= asami@FreeBSD.org
COMMENT= A DVI Previewer for the X Window System
[dependencies -- can be empty]
RUN_DEPENDS= gs:${PORTSDIR}/print/ghostscript
LIB_DEPENDS= Xpm.5:${PORTSDIR}/graphics/xpm
[this section is for other standard bsd.port.mk variables that do not
belong to any of the above]
[If it asks questions during configure, build, install...]
IS_INTERACTIVE= yes
[If it extracts to a directory other than ${DISTNAME}...]
WRKSRC= ${WRKDIR}/xdvi-new
[If the distributed patches were not made relative to ${WRKSRC}, you
may need to tweak this]
PATCH_DIST_STRIP= -p1
[If it requires a "configure" script generated by GNU autoconf to be run]
GNU_CONFIGURE= yes
[If it requires GNU make, not /usr/bin/make, to build...]
USE_GMAKE= yes
[If it is an X application and requires "xmkmf -a" to be run...]
USE_IMAKE= yes
[et cetera.]
[non-standard variables to be used in the rules below]
MY_FAVORITE_RESPONSE= "yeah, right"
[then the special rules, in the order they are called]
pre-fetch:
i go fetch something, yeah
post-patch:
i need to do something after patch, great
pre-install:
and then some more stuff before installing, wow
[and then the epilogue]
.include &lt;bsd.port.mk&gt;</programlisting>
</chapter>
<chapter xml:id="keeping-up">
<title>Keeping Up</title>
<para>The &os; Ports Collection is constantly changing. Here is
some information on how to keep up.</para>
<sect1 xml:id="freshports">
<title>FreshPorts</title>
<para>One of the easiest ways to learn about updates that have
already been committed is by subscribing to
<link xlink:href="http://www.FreshPorts.org/">FreshPorts</link>.
You can select multiple ports to monitor. Maintainers are
strongly encouraged to subscribe, because they will receive
notification of not only their own changes, but also any
changes that any other &os; committer has made. (These are
often necessary to keep up with changes in the underlying
ports framework&mdash;although it would be most polite to
receive an advance heads-up from those committing such changes,
sometimes this is overlooked or just simply impractical.
Also, in some cases, the changes are very minor in nature.
We expect everyone to use their best judgement in these
cases.)</para>
<para>If you wish to use FreshPorts, all you need is an
account. If your registered email address is
<literal>@FreeBSD.org</literal>, you will see the opt-in link on the
right hand side of the webpages.
For those of you who already have a FreshPorts account, but are not
using your <literal>@FreeBSD.org</literal> email address,
just change your email to <literal>@FreeBSD.org</literal>, subscribe,
then change it back again.</para>
<para>FreshPorts also has
a sanity test feature which automatically tests each commit to the
FreeBSD ports tree. If subscribed to this service, you will be
notified of any errors which FreshPorts detects during sanity
testing of your commits.</para>
</sect1>
<sect1 xml:id="cvsweb">
<title>The Web Interface to the Source Repository</title>
<para>It is possible to browse the files in the source repository by
using a web interface. Changes that affect the entire port system
are now documented in the
<link xlink:href="http://cvsweb.FreeBSD.org/ports/CHANGES">
CHANGES</link> file. Changes that affect individual ports
are now documented in the
<link xlink:href="http://cvsweb.FreeBSD.org/ports/UPDATING">
UPDATING</link> file. However, the definitive answer to any
question is undoubtedly to read the source code of <link xlink:href="http://cvsweb.FreeBSD.org/ports/Mk/bsd.port.mk">
bsd.port.mk</link>, and associated files.</para>
</sect1>
<sect1 xml:id="ports-mailling-list">
<title>The &os; Ports Mailing List</title>
<para>If you maintain ports, you should consider following the
&a.ports;. Important changes to the way ports work will be announced
there, and then committed to <filename>CHANGES</filename>.</para>
</sect1>
<sect1 xml:id="build-cluster">
<title>The &os; Port Building Cluster on
<systemitem class="fqdomainname">pointyhat.FreeBSD.org</systemitem></title>
<para>One of the least-publicized strengths of &os; is that
an entire cluster of machines is dedicated to continually
building the Ports Collection, for each of the major OS
releases and for each Tier-1 architecture. You can find
the results of these builds at
<link xlink:href="http://pointyhat.FreeBSD.org/">package building logs
and errors</link>.</para>
<para>Individual ports are built unless they are specifically
marked with <varname>IGNORE</varname>. Ports that are
marked with <varname>BROKEN</varname> will still be attempted,
to see if the underlying problem has been resolved. (This
is done by passing <varname>TRYBROKEN</varname> to the
port's <filename>Makefile</filename>.)</para>
</sect1>
<sect1 xml:id="distfile-survey">
<title>The &os; Port Distfile Survey</title>
<para>The build cluster is dedicated to building the latest
release of each port with distfiles that have already been
fetched. However, as the Internet continually changes,
distfiles can quickly go missing. The <link xlink:href="http://people.FreeBSD.org/~fenner/portsurvey/">FreeBSD
Ports distfiles survey</link> attempts to query every
download site for every port to find out if each distfile
is still currently available. Maintainers are asked to
check this report periodically, not only to speed up the
building process for users, but to help avoid wasting
bandwidth of the sites that volunteer to host all these
distfiles.</para>
</sect1>
<sect1 xml:id="portsmon">
<title>The &os; Ports Monitoring System</title>
<para>Another handy resource is the
<link xlink:href="http://portsmon.FreeBSD.org">
FreeBSD Ports Monitoring System</link> (also known as
<literal>portsmon</literal>). This system comprises a
database that processes information from several sources
and allows its to be browsed via a web interface. Currently,
the ports Problem Reports (PRs), the error logs from
the build cluster, and individual files from the ports
collection are used. In the future, this will be expanded
to include the distfile survey, as well as other sources.</para>
<para>To get started, you can view all information about a
particular port by using the
<link xlink:href="http://portsmon.FreeBSD.org/portoverview.py">
Overview of One Port</link>.</para>
<para>As of this writing, this is the only resource available
that maps GNATS PR entries to portnames. (PR submitters
do not always include the portname in their Synopsis, although
we would prefer that they did.) So, <literal>portsmon</literal>
is a good place to start if you want to find out whether an
existing port has any PRs filed against it and/or any build
errors; or, to find out if a new port that you may be thinking
about creating has already been submitted.</para>
</sect1>
</chapter>
</book>