Index: head/en_US.ISO8859-1/books/porters-handbook/makefiles/chapter.xml =================================================================== --- head/en_US.ISO8859-1/books/porters-handbook/makefiles/chapter.xml (revision 46444) +++ head/en_US.ISO8859-1/books/porters-handbook/makefiles/chapter.xml (revision 46445) @@ -1,4836 +1,4879 @@ <?xml version="1.0" encoding="iso-8859-1"?> <!-- The FreeBSD Documentation Project $FreeBSD$ --> <chapter xmlns="http://docbook.org/ns/docbook" xmlns:xlink="http://www.w3.org/1999/xlink" version="5.0" xml:id="makefiles"> <title>Configuring the Makefile</title> <para>Configuring the <filename>Makefile</filename> is pretty simple, and again we suggest looking at existing examples before starting. 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 the port easier for others to read.</para> <para>Consider these problems in sequence during the design of the 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 <command>gzip</command>ped tarball named something like <filename>foozolix-1.2.tar.gz</filename>? If so, go on to the next step. If not, the distribution file format might require overriding one or more of <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>.</para> <para>In the worst case, create a custom <buildtarget>do-extract</buildtarget> target to override the default. This is 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 xml:id="makefile-portname"> <title><varname>PORTNAME</varname> and <varname>PORTVERSION</varname></title> <para>Set <varname>PORTNAME</varname> to the base name of the port, and <varname>PORTVERSION</varname> to the version number of the port.</para> <important> <para>The package name must be unique among all of the ports tree. Make sure that there is not already a port with the same <varname>PORTNAME</varname> and if there is add one of <link linkend="porting-pkgnameprefix-suffix"><varname>PKGNAMEPREFIX</varname> or <varname>PKGNAMESUFFIX</varname></link>.</para> </important> </sect2> <sect2 xml:id="makefile-naming-revepoch"> <title><varname>PORTREVISION</varname> and <varname>PORTEPOCH</varname></title> <sect3 xml:id="makefile-portrevision"> <title><varname>PORTREVISION</varname></title> <para><varname>PORTREVISION</varname> is a monotonically increasing value which is reset to 0 with every increase of <varname>PORTVERSION</varname>, typically every time there is a new official vendor release. If <varname>PORTREVISION</varname> is non-zero, the value is appended to the package name. Changes to <varname>PORTREVISION</varname> are used by automated tools like &man.pkg-version.8; to determine that a new package is available.</para> <para><varname>PORTREVISION</varname> must be increased each time a change is made to the port that changes the generated package in any way. That includes changes that only affect a package built with non-default <link linkend="makefile-options">options</link>.</para> <para>Examples of when <varname>PORTREVISION</varname> must 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. For example, a change to a script which generates initial data for the package, like &man.ssh.1; 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. For example, 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 have to 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 decide whether a change committed to a port is something which <emphasis>some</emphasis> people would benefit from having. Either because of an enhancement, fix, or by virtue that the new package will actually work at all. Then weigh that against that fact that it will cause everyone who regularly updates their ports tree to be compelled to update. If yes, <varname>PORTREVISION</varname> must be bumped.</para> <note> <para>People using binary packages will <emphasis>never</emphasis> see the update if <varname>PORTREVISION</varname> is not bumped. Without increasing <varname>PORTREVISION</varname>, the package builders have no way to detect the change and thus, will not rebuild the package.</para> </note> </sect3> <sect3 xml:id="makefile-portepoch"> <title><varname>PORTEPOCH</varname></title> <para>From time to time a software vendor or &os; 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> <tip> <para>The results of version number comparisons are not always obvious. <command>pkg version</command> (see &man.pkg-version.8;) can be used to test the comparison of two version number strings. For example:</para> <screen>&prompt.user; <userinput>pkg version -t 0.031 0.29</userinput> ></screen> <para>The <literal>></literal> output indicates that version 0.031 is considered greater than version 0.29, which may not have been obvious to the porter.</para> </tip> <para>In situations such as this, <varname>PORTEPOCH</varname> must 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. For example, the package would not be detected as out of date. The new version number, <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 the discussion above was not clear enough, please consult the &a.ports;.</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 preempt it becoming necessary if a future release of the software changes the version structure. However, care is needed by &os; porters when a vendor release is made without an official version number — 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 <literal>20000917</literal>, and the previous version of the software was version <literal>1.2</literal>, do not use <literal>20000917</literal> for <varname>PORTVERSION</varname>. The correct way is a <varname>PORTVERSION</varname> of <literal>1.2.20000917</literal>, or similar, so that the succeeding release, say <literal>1.3</literal>, is still a numerically greater value.</para> </sect3> <sect3 xml:id="makefile-portrevision-example"> <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 &os; 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>, <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 xml:id="porting-pkgnameprefix-suffix"> <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, the use of a hyphen (<literal>-</literal>) in <varname>PORTVERSION</varname> is <emphasis>not</emphasis> allowed. 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 xml:id="porting-pkgname"> <title>Package Naming Conventions</title> <para>These are the conventions to follow when naming packages. This is to make the 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>Package names take the form of <filename><replaceable>language_region-name-compiled.specifics-version.numbers</replaceable></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> <variablelist xml:id="porting-pkgname-format"> <varlistentry xml:id="porting-pkgname-language"> <term><filename><replaceable>language_region-</replaceable></filename></term> <listitem> <para>&os; strives to support the native language of its users. The <replaceable>language-</replaceable> part is a two letter abbreviation of the natural language defined by ISO-639 when 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 is set in <varname>PKGNAMEPREFIX</varname>.</para> </listitem> </varlistentry> <varlistentry xml:id="porting-pkgname-name"> <term><filename><replaceable>name</replaceable></filename></term> <listitem> <para>Make sure that the port's name and version are clearly separated and placed into <varname>PORTNAME</varname> and <varname>PORTVERSION</varname>. 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 <package role="port">textproc/libxml2</package> or <package role="port">japanese/kinput2-freewnn</package> ports. Otherwise, <varname>PORTNAME</varname> cannot contain any version-specific information. It is quite normal for several ports to have the same <varname>PORTNAME</varname>, as the <package role="port">www/apache*</package> ports do; in that case, different versions (and different index entries) are distinguished by <varname>PKGNAMEPREFIX</varname> and <varname>PKGNAMESUFFIX</varname> values.</para> <para>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> </varlistentry> <varlistentry xml:id="porting-pkgname-compiled-specifics"> <term><filename><replaceable>-compiled.specifics</replaceable></filename></term> <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 states the compiled-in defaults. The hyphen is optional. Examples are paper size and font units.</para> <para>The <replaceable>-compiled.specifics</replaceable> part is set in <varname>PKGNAMESUFFIX</varname>.</para> </listitem> </varlistentry> <varlistentry xml:id="porting-pkgname-version-numbers"> <term><filename><replaceable>-version.numbers</replaceable></filename></term> <listitem> <para>The version string follows a dash (<literal>-</literal>) and is 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 follow the single alphabet without an extra period between them (for example, <literal>1.0b2</literal>).</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>0.0.<replaceable>yyyy</replaceable>.<replaceable>mm</replaceable>.<replaceable>dd</replaceable></literal> format, not <literal><replaceable>dd</replaceable>.<replaceable>mm</replaceable>.<replaceable>yyyy</replaceable></literal> or the non-Y2K compliant <literal><replaceable>yy</replaceable>.<replaceable>mm</replaceable>.<replaceable>dd</replaceable></literal> format. It is important to prefix the version with <literal>0.0.</literal> in case a release with an actual version number is made, which would be numerically less than <literal><replaceable>yyyy</replaceable></literal>.</para> </listitem> </varlistentry> </variablelist> <important> <para>Package name must be unique among all of the ports tree, check that there is not already a port with the same <varname>PORTNAME</varname> and if there is add one of <link linkend="porting-pkgnameprefix-suffix"><varname>PKGNAMEPREFIX</varname> or <varname>PKGNAMESUFFIX</varname></link>.</para> </important> <para>Here are some (real) examples on how to convert the name as called by the software authors to a suitable package name:</para> <table frame="none" pgwide="1"> <title>Package Naming Examples</title> <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>mule-1.0.1</entry> <entry>(empty)</entry> <entry>mule</entry> <entry>1</entry> <entry>1.0.1</entry> <entry><literal>mule</literal> already exists</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>Paper size 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> </table> <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 the source file was released on (<literal>0.0.<replaceable>yyyy</replaceable>.<replaceable>mm</replaceable>.<replaceable>dd</replaceable></literal>) as the version.</para> </sect2> </sect1> <sect1 xml:id="makefile-categories"> <title>Categorization</title> <sect2 xml:id="makefile-categories-definition"> <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 the port.</para> <para>This list also determines where in the ports tree the port is imported. If there is more than one category here, the port files must be put in the subdirectory with the name of 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—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, there is a one-line description in <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 the 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. They should <emphasis>not</emphasis> be in this category unless they truly do not belong anywhere else.</entry> </row> <row> <entry><filename>dns</filename></entry> <entry>DNS-related software.</entry> <entry/> </row> <row> <entry><filename>docs*</filename></entry> <entry>Meta-ports for &os; documentation.</entry> <entry/> </row> <row> <entry><filename>editors</filename></entry> <entry>General editors.</entry> <entry>Specialized editors go in the section for those tools. For example, a mathematical-formula editor will go in <filename>math</filename>, and have <filename>editors</filename> as a second category.</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. X-based ones 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><acronym>FTP</acronym> client and server utilities.</entry> <entry>If the port speaks both <acronym>FTP</acronym> and <acronym>HTTP</acronym>, put it in <filename>ftp</filename> with a secondary category of <filename>www</filename>.</entry> </row> <row> <entry><filename>games</filename></entry> <entry>Games.</entry> <entry/> </row> <row> <entry><filename>geography*</filename></entry> <entry>Geography-related software.</entry> <entry/> </row> <row> <entry><filename>german</filename></entry> <entry>German language support.</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>Software related to the GNUstep desktop environment.</entry> <entry/> </row> <row> <entry><filename>graphics</filename></entry> <entry>Graphics utilities.</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 must 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">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>Things that do not belong anywhere else. If at all possible, try to find a better category for the port than <literal>misc</literal>, as ports tend to be 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™</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>Ports for managing, installing and developing &os; ports and 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>Spanish language support.</entry> <entry/> </row> <row> <entry><filename>sysutils</filename></entry> <entry>System utilities.</entry> <entry/> </row> <row> <entry><filename>tcl*</filename></entry> <entry>Ports that use Tcl to run.</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>Ports that use Tk to run.</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 go into other <filename>x11-*</filename> categories (see below).</entry> </row> <row> <entry><filename>x11-clocks</filename></entry> <entry>X11 clocks.</entry> <entry/> </row> <row> <entry><filename>x11-drivers</filename></entry> <entry>X11 drivers.</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>Ports related to the <link xlink:href="http://www.xfce.org/">Xfce</link> desktop environment.</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, choosing which of the categories will be the primary category of the port can be tedious. 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 the port installs Japanese X11 fonts, then the <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 is listed as <filename>www editors</filename>, not the other way around. Also, do not list <filename>net</filename> when the port belongs to any of <filename>irc</filename>, <filename>mail</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, do not put <filename>x11</filename> in the category line for X applications.</para> </listitem> <listitem> <para><application>Emacs</application> modes are 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 goes into <filename>lang</filename>.</para> </listitem> <listitem> <para>Ports installing loadable kernel modules also have the virtual category <filename>kld</filename> in their <varname>CATEGORIES</varname> line. This is one of the things handled automatically by adding <literal>USES=kmod</literal>.</para> </listitem> <listitem> <para><filename>misc</filename> does not appear with any other non-virtual category. If there is <literal>misc</literal> with something else in <varname>CATEGORIES</varname>, that means <literal>misc</literal> can safely be deleted and the port placed only in the other subdirectory.</para> </listitem> <listitem> <para>If the port truly does not belong anywhere else, put it in <filename>misc</filename>.</para> </listitem> </itemizedlist> <para>If the category is not clearly defined, please put a comment to that effect in the <link xlink:href="https://bugs.freebsd.org/submit/">port submission</link> in the bug database so we can discuss it before we import it. As 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—those that do not have a corresponding subdirectory in the ports tree— or <emphasis>physical</emphasis> categories—those that do. This section discusses the issues involved in creating a new physical category. Read it thouroughly before proposing a new 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;. Include a detailed rationale for the new category, including why the existing categories are not sufficient, and the list of existing ports proposed to move. (If there are new ports pending in <application>Bugzilla</application> that would fit this category, list them too.) If you are the maintainer and/or submitter, respectively, mention that as it may help the case.</para> </step> <step> <para>Participate in the discussion.</para> </step> <step> <para>If it seems that there is support for the idea, file a PR which includes both the rationale and the list of existing ports that need to be moved. Ideally, this PR would also include these patches:</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, 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 moving and patching many ports but also possibly running regression tests on the build cluster, assign the PR 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;/article.html#PORTS">outlined in the Committer's Guide</link>.</para> </step> </procedure> <para>Proposing a new virtual category is 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 <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 posting this idea. Furthermore, 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 to build the port, and where they can be downloaded.</para> <sect2 xml:id="makefile-distversion"> <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}-${DISTVERSIONPREFIX}${DISTVERSION}${DISTVERSIONSUFFIX}</literal>, and <varname>DISTVERSION</varname> defaults to <literal>${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 <literal>${DISTNAME}</literal><literal>${EXTRACT_SUFX}</literal>. 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> will be derived from it automatically.</para> <note> <para>Only one of <varname>PORTVERSION</varname> and <varname>DISTVERSION</varname> can be set at a time. If <varname>DISTVERSION</varname> does not derive a correct <varname>PORTVERSION</varname>, do not use <varname>DISTVERSION</varname>, set <varname>PORTVERSION</varname> to the right value and set <varname>DISTNAME</varname> with <varname>PORTNAME</varname> with either some computation of <varname>PORTVERSION</varname> or the verbatim upstream version.</para> </note> <table frame="none" pgwide="0"> <title>Examples of <varname>DISTVERSION</varname> and the Derived <varname>PORTVERSION</varname></title> <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> </table> <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>${WRKDIR}/${DISTNAME}</filename> while the original source archive is named something other than <literal>${PORTNAME}-${PORTVERSION}${EXTRACT_SUFX}</literal>, leave <varname>DISTNAME</varname> alone— defining only <varname>DISTFILES</varname> is easier than both <varname>DISTNAME</varname> and <varname>WRKSRC</varname> (and possibly <varname>EXTRACT_SUFX</varname>).</para> </note> </sect2> <sect2 xml:id="makefile-master_sites"> <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 multiple sites are included 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> <important> <para><varname>MASTER_SITES</varname> must not be blank. It must point to the actual site hosting the distribution files. It cannot point to web archives, or the &os; distribution files cache sites. The only exception to this rule is ports that do not have any distribution files. For example, meta-ports do not have any distribution files, so <varname>MASTER_SITES</varname> does not need to be set.</para> </important> - <para>If the original tarball is part of one of the popular - archives such as SourceForge, GNU, or Perl CPAN, it may be - possible refer to those sites in an easy compact form using - predefined macros (for example, <literal>SF</literal>, - <literal>GNU</literal> or <literal>CPAN</literal>). - Set <varname>MASTER_SITES</varname> to one of these values. - Here is an example:</para> + <sect3 xml:id="makefile-master_sites-shorthand"> + <title>Using + <varname>MASTER_SITE_<replaceable>*</replaceable></varname> + Variables</title> + <para>Shortcut abbreviations are available for popular archives + like SourceForge (<literal>SF</literal>), GNU + (<literal>GNU</literal>), or Perl CPAN + (<literal>CPAN</literal>). <varname>MASTER_SITES</varname> can + use them directly:</para> + <programlisting>MASTER_SITES= GNU/make</programlisting> - <para>The older expanded format can still be used, although there - really is no reason to do so:</para> + <para>The older expanded format still works, but all ports + should be converted to the compact format. The expanded + format looks like this:</para> <programlisting>MASTER_SITES= ${MASTER_SITE_GNU} MASTER_SITE_SUBDIR= make</programlisting> - <para>These values and 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>These values and variables are defined in <link + xlink:href="https://svnweb.freebsd.org/ports/head/Mk/bsd.sites.mk?view=markup"><filename>Mk/bsd.sites.mk</filename></link>. + New entries are added often, so make sure to check the latest + version of this file before submitting a port.</para> + <tip> + <para>For any + <varname>MASTER_SITE_<replaceable>FOO</replaceable></varname> + variable, the shorthand + <literal><replaceable>FOO</replaceable></literal> can be + used. For example, use:</para> + + <programlisting>MASTER_SITES= <replaceable>FOO</replaceable></programlisting> + + <para>If <varname>MASTER_SITE_SUBDIR</varname> is needed, use + this:</para> + + <programlisting>MASTER_SITES= <replaceable>FOO</replaceable>/<replaceable>bar</replaceable></programlisting> + </tip> + </sect3> + + <sect3 xml:id="makefile-master_sites-magic"> + <title>Magic MASTER_SITES Macros</title> + <para>Several <emphasis>magic</emphasis> macros exist for popular sites with a predictable directory structure. For these, just use the abbreviation and the system will try to - guess the correct subdirectory automatically.</para> + guess the correct subdirectory automatically. For a port + named <literal>Stardict</literal>, of version + <literal>1.2.3</literal>, and hosted on SourceForge, adding + this line:</para> <programlisting>MASTER_SITES= SF</programlisting> - <para>If the guess is incorrect, it can be overridden as - follows.</para> + <para>Will infer a subdirectory named + <literal>/project/stardict/stardict/1.2.3</literal>. If the + guess is incorrect, it can be overridden as follows.</para> <programlisting>MASTER_SITES= SF/stardict/WyabdcRealPeopleTTS/${PORTVERSION}</programlisting> <para>This can also be written as</para> <programlisting>MASTER_SITES= SF MASTER_SITE_SUBDIR= stardict/WyabdcRealPeopleTTS/${PORTVERSION}</programlisting> <table frame="none" xml:id="makefile-master_sites-popular"> <title>Popular Magic <varname>MASTER_SITES</varname> Macros</title> <tgroup cols="2"> <thead> <row> <entry>Macro</entry> <entry>Assumed subdirectory</entry> </row> </thead> <tbody> <row> <entry><varname>APACHE_JAKARTA</varname></entry> - <entry><literal>/dist/jakarta/${PORTNAME:S,-,,/,}/source</literal></entry> + <entry><literal>${PORTNAME:S,-,/,}/source</literal></entry> </row> <row> <entry><varname>BERLIOS</varname></entry> - <entry><literal>/${PORTNAME:L}</literal></entry> + <entry><literal>${PORTNAME:tl}.berlios</literal></entry> </row> <row> <entry><varname>CHEESESHOP</varname></entry> - <entry><literal>/packages/source/source/${DISTNAME:C/(.).*/\1/}/${DISTNAME:C/(.*)-[0-9].*/\1/}</literal></entry> + <entry><literal>source/${DISTNAME:C/(.).*/\1/}/${DISTNAME:C/(.*)-[0-9].*/\1/}</literal></entry> </row> <row> <entry><varname>DEBIAN</varname></entry> - <entry><literal>/debian/pool/main/${PORTNAME:C/^((lib)?.).*$/\1/}/${PORTNAME}</literal></entry> + <entry><literal>pool/main/${PORTNAME:C/^((lib)?.).*$/\1/}/${PORTNAME}</literal></entry> </row> <row> + <entry><varname>FARSIGHT</varname></entry> + <entry><literal>${PORTNAME}</literal></entry> + </row> + + <row> <entry><varname>GCC</varname></entry> - <entry><literal>/pub/gcc/releases/${DISTNAME}</literal></entry> + <entry><literal>releases/${DISTNAME}</literal></entry> </row> <row> <entry><varname>GH</varname></entry> - <entry><literal>/${GH_ACCOUNT}/${GH_PROJECT}/tar.gz/${GH_TAGNAME}</literal></entry> + <entry><literal>${GH_ACCOUNT}/${GH_PROJECT}/tar.gz/${GH_TAGNAME}?dummy=/</literal></entry> </row> <row> <entry><varname>GHC</varname></entry> - <entry><literal>/downloads/${GH_ACCOUNT}/${GH_PROJECT}/</literal></entry> + <entry><literal>${GH_ACCOUNT}/${GH_PROJECT}/</literal></entry> </row> <row> + <entry><varname>GHL</varname></entry> + <entry><literal>${GH_ACCOUNT}/${GH_PROJECT}/legacy.tar.gz/${GH_TAGNAME}?dummy=/</literal></entry> + </row> + + <row> <entry><varname>GNOME</varname></entry> - <entry><literal>/pub/GNOME/sources/${PORTNAME}/${PORTVERSION:C/^([0-9]+\.[0-9]+).*/\1/}</literal></entry> + <entry><literal>sources/${PORTNAME}/${PORTVERSION:C/^([0-9]+\.[0-9]+).*/\1/}</literal></entry> </row> <row> + <entry><varname>GIMP</varname></entry> + <entry><literal>${PORTNAME}/${PORTVERSION:R}/</literal></entry> + </row> + + <row> <entry><varname>GNU</varname></entry> - <entry><literal>/gnu/${PORTNAME}</literal></entry> + <entry><literal>${PORTNAME}</literal></entry> </row> <row> + <entry><varname>GNU_ALPHA</varname></entry> + <entry><literal>${PORTNAME}</literal></entry> + </row> + + <row> <entry><varname>HORDE</varname></entry> - <entry><literal>/pub/${PORTNAME}</literal></entry> + <entry><literal>${PORTNAME}</literal></entry> </row> <row> - <entry><varname>LOGILAB</varname></entry> - <entry><literal>/pub/${PORTNAME}</literal></entry> + <entry><varname>LODEV</varname></entry> + <entry><literal>${PORTNAME}</literal></entry> </row> <row> <entry><varname>MATE</varname></entry> - <entry><literal>/releases/${PORTVERSION:C/^([0-9]+\.[0-9]+).*/\1/}</literal></entry> + <entry><literal>${PORTVERSION:C/^([0-9]+\.[0-9]+).*/\1/}</literal></entry> </row> <row> <entry><varname>MOZDEV</varname></entry> - <entry><literal>/pub/mozdev/${PORTNAME:L}</literal></entry> + <entry><literal>${PORTNAME:tl}</literal></entry> </row> <row> - <entry><varname>CPAN</varname></entry> - <entry><literal>/pub/CPAN/modules/by-module/${PORTNAME:C/-.*//}</literal></entry> + <entry><varname>NL</varname></entry> + <entry><literal>${PORTNAME}</literal></entry> </row> <row> - <entry><varname>PYTHON</varname></entry> - <entry><literal>/ftp/python/${PYTHON_PORTVERSION:C/rc[0-9]//}</literal></entry> + <entry><varname>CPAN</varname></entry> + <entry><literal>${PORTNAME:C/-.*//}</literal></entry> </row> <row> - <entry><varname>RUBYFORGE</varname></entry> - <entry><literal>/${PORTNAME:L}</literal></entry> - </row> - - <row> <entry><varname>SAVANNAH</varname></entry> - <entry><literal>/${PORTNAME:L}</literal></entry> + <entry><literal>${PORTNAME:tl}</literal></entry> </row> <row> <entry><varname>SF</varname></entry> - <entry><literal>/project/${PORTNAME:L}/${PORTNAME:L}/${PORTVERSION}</literal></entry> + <entry><literal>${PORTNAME:tl}/${PORTNAME:tl}/${PORTVERSION}</literal></entry> </row> </tbody> </tgroup> </table> + </sect3> <sect3 xml:id="makefile-master_sites-github"> <title><varname>USE_GITHUB</varname></title> <para>If the distribution file comes from a specific commit or tag on <link xlink:href="https://github.com">GitHub</link> for which there is no officially released file, there is an easy way to set the right <varname>DISTNAME</varname> and <varname>MASTER_SITES</varname> automatically. These variables are available:</para> <table xml:id="makefile-master_sites-github-description"> <title><varname>USE_GITHUB</varname> Description</title> <tgroup cols="3"> <thead> <row> <entry>Variable</entry> <entry>Description</entry> <entry>Default</entry> </row> </thead> <tbody> <row> <entry><varname>GH_ACCOUNT</varname></entry> <entry>Account name of the GitHub user hosting the project</entry> <entry><literal>${PORTNAME}</literal></entry> </row> <row> <entry><varname>GH_PROJECT</varname></entry> <entry>Name of the project on GitHub</entry> <entry><literal>${PORTNAME}</literal></entry> </row> <row> <entry><varname>GH_TAGNAME</varname></entry> <entry>Name of the tag to download (2.0.1, hash, ...) Using the name of a branch here is incorrect. It is also possible to use the hash of a commit id to do a snapshot.</entry> <entry><literal>${DISTVERSIONPREFIX}${DISTVERSION}${DISTVERSIONSUFFIX}</literal></entry> </row> </tbody> </tgroup> </table> <example xml:id="makefile-master_sites-github-ex1"> <title>Simple Use of <varname>USE_GITHUB</varname></title> <para>While trying to make a port for version <literal>1.2.7</literal> of <application>pkg</application> from the &os; user on github, at <link xlink:href="https://github.com/freebsd/pkg"/>, The <filename>Makefile</filename> would end up looking like this (slightly stripped for the example):</para> <programlisting>PORTNAME= pkg PORTVERSION= 1.2.7 USE_GITHUB= yes GH_ACCOUNT= freebsd</programlisting> <para>It will automatically have <varname>MASTER_SITES</varname> set to <literal>GH GHC</literal> and <varname>WRKSRC</varname> to <literal>${WRKDIR}/pkg-1.2.7</literal>.</para> </example> <example xml:id="makefile-master_sites-github-ex2"> <title>More Complete Use of <varname>USE_GITHUB</varname></title> <para>While trying to make a port for the bleeding edge version of <application>pkg</application> from the &os; user on github, at <link xlink:href="https://github.com/freebsd/pkg"/>, The <filename>Makefile</filename> would end up looking like this (slightly stripped for the example):</para> <programlisting>PORTNAME= pkg-devel PORTVERSION= 1.3.0.a.20140411 USE_GITHUB= yes GH_ACCOUNT= freebsd GH_PROJECT= pkg GH_TAGNAME= 6dbb17b</programlisting> <para>It will automatically have <varname>MASTER_SITES</varname> set to <literal>GH GHC</literal> and <varname>WRKSRC</varname> to <literal>${WRKDIR}/pkg-6dbb17b</literal>.</para> </example> <example xml:id="makefile-master_sites-github-ex3"> <title>Use of <varname>USE_GITHUB</varname> with <varname>DISTVERSIONPREFIX</varname></title> <para>From time to time, <varname>GH_TAGNAME</varname> is a slight variation from <varname>PORTREVISION</varname>. For example, if the version is <literal>1.0.2</literal>, the tag is <literal>v1.0.2</literal>. In those cases, it is possible to use <varname>DISTVERSIONPREFIX</varname> or <varname>DISTVERSIONSUFFIX</varname>:</para> <programlisting>PORTNAME= foo PORTVERSION= 1.0.2 DISTVERSIONPREFIX= v USE_GITHUB= yes</programlisting> <para>It will automatically set <varname>GH_TAGNAME</varname> to <literal>v1.0.2</literal>, while <varname>WRKSRC</varname> will be kept to <varname>${WRKDIR}/foo-1.0.2</varname>.</para> </example> </sect3> </sect2> <sect2 xml:id="makefile-extract_sufx"> <title><varname>EXTRACT_SUFX</varname></title> <para>If there is 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.tar.gzip</filename> instead of the more normal <filename>foo.tar.gz</filename>, write:</para> <programlisting>DISTNAME= foo EXTRACT_SUFX= .tar.gzip</programlisting> <para>The <literal>USES=tar[:<replaceable>xxx</replaceable>]</literal>, <literal>USES=lha</literal> or <literal>USES=zip</literal> automatically set <varname>EXTRACT_SUFX</varname> to the most common archives extensions as necessary, see <xref linkend="uses-values"/> for more details. If neither of these are set then <varname>EXTRACT_SUFX</varname> defaults to <literal>.tar.gz</literal>.</para> <note> <para>As <varname>EXTRACT_SUFX</varname> is only used in <varname>DISTFILES</varname>, only set one of them..</para> </note> </sect2> <sect2 xml:id="makefile-distfiles-definition"> <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 xml:id="makefile-extract_only"> <title><varname>EXTRACT_ONLY</varname></title> <para>If only some of the <varname>DISTFILES</varname> must be extracted—for example, one of them is the source code, while another is an uncompressed document—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>When none of the <varname>DISTFILES</varname> need to be uncompressed, 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 the port requires some additional patches that are available by <acronym>FTP</acronym> or <acronym>HTTP</acronym>, 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 (that is, <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>.Z</filename>, <filename>.gz</filename>, <filename>.bz2</filename> or <filename>.xz</filename>.</para> <para>If the patch is distributed with some other files, such as documentation, in a <command>gzip</command>ped tarball, using <varname>PATCHFILES</varname> is not possible. 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 <varname>EXTRA_PATCHES</varname> to point to those files and <filename>bsd.port.mk</filename> will automatically apply them. In particular, do <emphasis>not</emphasis> copy patch files into <filename>${PATCHDIR}</filename>. That directory may not be writable.</para> <tip> <para>If there are multiple patches and they need mixed values for the strip parameter, it can be added alongside the patch name in <varname>PATCHFILES</varname>, e.g:</para> <programlisting>PATCHFILES= patch1 patch2:-p1</programlisting> <para>This does not conflict with <link linkend="porting-master-sites-n">the master site grouping feature</link>, adding a group also works:</para> <programlisting>PATCHFILES= patch2:-p1:source2</programlisting> </tip> <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 <command>gzip</command>ped or <command>compress</command>ed tarball. Take extra care not to overwrite something that already exists in that directory if extracting it manually. 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>.</para> <para>A little background first. OpenBSD has a neat feature inside <varname>DISTFILES</varname> and <varname>PATCHFILES</varname> which allows files and patches to be postfixed with <literal>:n</literal> identifiers. Here, <literal>n</literal> can be both <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 the 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 &os; implementation of this idea. We improved a bit on OpenBSD's concept.</para> <sect3 xml:id="porting-master-sites-n-simplified"> <title>Simplified Information</title> <para>This section explains 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. More detailed information are available in <xref linkend="ports-master-sites-n-detailed"/>.</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 are 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 One File Per Site</title> <programlisting>MASTER_SITES= ftp://ftp1.example.com/:source1 \ http://www.example.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 is 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 One File Per Site</title> <programlisting>MASTER_SITES= ftp://ftp.example.com/:source1 \ http://www.example.com/:source2 DISTFILES= source1.tar.gz:source1 \ source2.tar.gz:source2 \ source3.tar.gz:source2</programlisting> </example> </sect3> <sect3 xml:id="ports-master-sites-n-detailed"> <title>Detailed Information</title> <para>Okay, so the previous example did not reflect the new port's needs? In this section we will explain in detail how the fine grained fetching mechanism <literal>MASTER_SITES:n</literal> works and how it can be used.</para> <orderedlist> <listitem> <para>Elements can be postfixed with <literal>:<replaceable>n</replaceable></literal> where <replaceable>n</replaceable> is <literal>[^:,]+</literal>, that is, <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; that is, <literal>n</literal> is different from <literal>N</literal>.</para> <para>However, these 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, they all belong to the special group <literal>DEFAULT</literal>. Any elements postfixed with <literal>DEFAULT</literal>, is just being redundant unless an element belongs to both <literal>DEFAULT</literal> and other groups at the same time (check item <xref linkend="porting-master-sites-n-comma-operator"/>).</para> <para>These examples are equivalent but the first one is preferred:</para> <programlisting>MASTER_SITES= alpha</programlisting> <programlisting>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.</para> </listitem> <listitem xml:id="porting-master-sites-n-comma-operator"> <para>When an element belongs to several groups at the same time, 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 these examples are equivalent but the last one is preferred:</para> <programlisting>MASTER_SITES= alpha alpha:SOME_SITE</programlisting> <programlisting>MASTER_SITES= alpha:DEFAULT alpha:SOME_SITE</programlisting> <programlisting>MASTER_SITES= alpha:SOME_SITE,DEFAULT</programlisting> <programlisting>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 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 this 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>:<replaceable>n</replaceable></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> -> old:n</para> </listitem> <listitem> <para>Directories within group <literal>NEW</literal> -> 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 this 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>, for example, <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<replaceable>*</replaceable></varname>?</para> <para>All examples were done with <varname>MASTER<replaceable>*</replaceable></varname> but they work exactly the same for <varname>PATCH<replaceable>*</replaceable></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 xml:id="port-master-sites-n-what-changed"> <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>:<replaceable>n</replaceable></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 xml:id="makefile-dist_subdir"> <title><varname>DIST_SUBDIR</varname></title> <para>Do not let the port clutter <filename>/usr/ports/distfiles</filename>. If the port requires a lot of files to be fetched, or contains a file that has a name that might conflict with other ports (for example, <filename>Makefile</filename>), set <varname>DIST_SUBDIR</varname> to the name of the port (<literal>${PORTNAME}</literal> or <literal>${PKGNAMEPREFIX}${PORTNAME}</literal> are 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 the 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 <filename>Makefile</filename> will not accomplish this, so please use <varname>DIST_SUBDIR</varname>.)</para> <note> <para>This does not affect <varname>MASTER_SITES</varname> defined in the <filename>Makefile</filename>.</para> </note> </sect2> <sect2 xml:id="makefile-always_keep_distfiles"> <title><varname>ALWAYS_KEEP_DISTFILES</varname></title> <para>If the port uses binary distfiles and has a license that requires that the source code is provided with packages distributed in binary form, like <acronym>GPL</acronym>, <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 to 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 side effects 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>Only a single address without the comment part is allowed as a <varname>MAINTAINER</varname> value. The format used is <literal>user@hostname.domain</literal>. Please do not include any descriptive text such as a real name in this entry. That merely confuses the Ports infrastructure and most tools using it.</para> <para>The maintainer is responsible for keeping the port up to date and making sure that it works correctly. For a detailed description of the responsibilities of a port maintainer, refer to <link xlink:href="&url.articles.contributing-ports;/maintain-port.html">The challenge for port maintainers</link>.</para> <note> <para>A maintainer volunteers to keep a port in good working order. Maintainers have the primary responsibility for their ports, but not exclusive ownership. Ports exist for the benefit of the community and, in reality, belong to the community. What this means is that people other than the maintainer can make changes to a port. Large changes to the Ports Collection might require changes to many ports. The &os; Ports Management Team or members of other teams might modify ports to fix dependency issues or other problems, like a version bump for a shared library update.</para> <para>Some types of fixes have <quote>blanket approval</quote> from the &a.portmgr;, allowing any committer to fix those categories of problems on any port. These fixes do not need approval from the maintainer. Blanket approval does not apply to ports that are maintained by teams like <email role="nolink">autotools@FreeBSD.org</email>, <email role="nolink">x11@FreeBSD.org</email>, <email role="nolink">gnome@FreeBSD.org</email>, or <email role="nolink">kde@FreeBSD.org</email>. These teams use external repositories and can have work that would conflict with changes that would normally fall under blanket approval.</para> <para>Blanket approval for most ports applies to these types of fixes:</para> <itemizedlist> <listitem> <para>Most infrastructure changes to a port (that is, modernizing, but not changing the functionality). For example, converting to staging, <varname>USE_GMAKE</varname> to <literal>USES=gmake</literal>, the new <varname>LIB_DEPENDS</varname> format...</para> </listitem> <listitem> <para>Trivial and <emphasis>tested</emphasis> build and runtime fixes.</para> </listitem> </itemizedlist> </note> <para>Other changes to the port will be sent to the maintainer for review and 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, or if there have been three consecutive timeouts, 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 or the maintainer. Also, large infrastructural changes can result in a port being modified without the maintainer's consent. These kinds 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. Please respect these rules:</para> <orderedlist> <listitem> <para>Try to keep the COMMENT value at no longer than 70 characters, as this line will be used by <command>pkg info</command> (see &man.pkg-info.8;) to display a one-line summary of the port;</para> </listitem> <listitem> <para>Do <emphasis>not</emphasis> include the package name (or version number of the software);</para> </listitem> <listitem> <para>The comment must begin with a capital and end without a period;</para> </listitem> <listitem> <para>Do not start with an indefinite article (that is, A or An);</para> </listitem> <listitem> <para>Names are capitalized (for example, Apache, JavaScript, Perl);</para> </listitem> <listitem> <para>For lists of words, use the Oxford comma (for example, green, red<emphasis>,</emphasis> and blue);</para> </listitem> <listitem> <para>Spell check the text.</para> </listitem> </orderedlist> <para>Here is an example:</para> <programlisting>COMMENT= Cat chasing a mouse all over the screen</programlisting> <para>The COMMENT variable immediately follows the MAINTAINER variable in the <filename>Makefile</filename>.</para> </sect1> <sect1 xml:id="makefile-portscout"> <title><varname>PORTSCOUT</varname></title> <para><application>Portscout</application> is an automated distfile check utility for the &os; Ports Collection, described in detail in <xref linkend="distfile-survey"/>.</para> <para><varname>PORTSCOUT</varname> defines special conditions within which the <application>Portscout</application> distfile scanner is restricted.</para> <para>Situations where <varname>PORTSCOUT</varname> is set include:</para> <itemizedlist> <listitem> <para>When distfiles have to be ignored, whether for specific versions, or specific minor revisions. For example, to exclude version <replaceable>8.2</replaceable> from distfile version checks because it is known to be broken, add:</para> <programlisting>PORTSCOUT= ignore:8.2</programlisting> </listitem> <listitem> <para>When specific versions or specific major and minor revisions of a distfile must be checked. For example, if only version <replaceable>0.6.4</replaceable> must be monitored because newer versions have compatibility issues with &os;, add:</para> <programlisting>PORTSCOUT= limit:^0\.6\.4</programlisting> </listitem> <listitem> <para>When URLs listing the available versions differ from the download URLs. For example, to limit distfile version checks to the download page for the <package role="port">databases/pgtune</package> port, add:</para> <programlisting>PORTSCOUT= site:http://pgfoundry.org/frs/?group_id=1000416</programlisting> </listitem> </itemizedlist> </sect1> <sect1 xml:id="makefile-depend"> <title>Dependencies</title> <para>Many ports depend on other ports. This is a very convenient feature of most Unix-like operating systems, including &os;. Multiple ports can share a common dependency, rather than bundling that dependency with every port or package that needs it. There are seven variables that can be used 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 xml:id="makefile-lib_depends"> <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> 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. For example,</para> <programlisting>LIB_DEPENDS= libjpeg.so:${PORTSDIR}/graphics/jpeg</programlisting> <para>will check for a shared jpeg library with any version, and descend into the <filename>graphics/jpeg</filename> subdirectory of the ports tree to build and install it if it is not found.</para> <para>The dependency is checked twice, once from within the <buildtarget>build</buildtarget> target and then from within the <buildtarget>install</buildtarget> target. Also, the name of the dependency is put into the package so that <command>pkg install</command> (see &man.pkg-install.8;) will automatically install it if it is not on the user's system.</para> </sect2> <sect2 xml:id="makefile-run_depends"> <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>:<replaceable>target</replaceable></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}/news/bin/innd:${PORTSDIR}/news/inn \ xmlcatmgr:${PORTSDIR}/textproc/xmlcatmgr</programlisting> <para>will check if the file or directory <filename>/usr/local/news/bin/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 <filename>textproc/xmlcatmgr</filename> 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, 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</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 <command>pkg install</command> (see &man.pkg-install.8;) 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> <para>A quite common situation is when <varname>RUN_DEPENDS</varname> is literally the same as <varname>BUILD_DEPENDS</varname>, especially if ported software is written in a scripted language or if it requires the same build and run-time environment. In this case, it is both tempting and intuitive to directly assign one to the other:</para> <programlisting>RUN_DEPENDS= ${BUILD_DEPENDS}</programlisting> <para>However, such assignment can pollute run-time dependencies with entries not defined in the port's original <varname>BUILD_DEPENDS</varname>. This happens because of &man.make.1;'s lazy evaluation of variable assignment. Consider a <filename>Makefile</filename> with <varname>USE_<replaceable>*</replaceable></varname>, which are processed by <filename>ports/Mk/bsd.*.mk</filename> to augment initial build dependencies. For example, <literal>USES= gmake</literal> adds <package role="port">devel/gmake</package> to <varname>BUILD_DEPENDS</varname>. To prevent such additional dependencies from polluting <varname>RUN_DEPENDS</varname>, take care to assign with expansion, that is, expand the value before assigning it to the variable:</para> <programlisting>RUN_DEPENDS:= ${BUILD_DEPENDS}</programlisting> </sect2> <sect2 xml:id="makefile-build_depends"> <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>:<replaceable>target</replaceable></optional> tuples. For example,</para> <programlisting>BUILD_DEPENDS= unzip:${PORTSDIR}/archivers/unzip</programlisting> <para>will check for an executable called <command>unzip</command>, and descend into the <filename>archivers/unzip</filename> subdirectory of the 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 xml:id="makefile-fetch_depends"> <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>:<replaceable>target</replaceable></optional> tuples. For example,</para> <programlisting>FETCH_DEPENDS= ncftp2:${PORTSDIR}/net/ncftp2</programlisting> <para>will check for an executable called <command>ncftp2</command>, and descend into the <filename>net/ncftp2</filename> subdirectory of the 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 xml:id="makefile-extract_depends"> <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>:<replaceable>target</replaceable></optional> tuples. For example,</para> <programlisting>EXTRACT_DEPENDS= unzip:${PORTSDIR}/archivers/unzip</programlisting> <para>will check for an executable called <command>unzip</command>, and descend into the <filename>archivers/unzip</filename> subdirectory of the 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>tar</command>) and cannot be made to work using <literal>USES=tar</literal>, <literal>USES=lha</literal> or <literal>USES=zip</literal> described in <xref linkend="uses-values"/>.</para> </note> </sect2> <sect2 xml:id="makefile-patch_depends"> <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>:<replaceable>target</replaceable></optional> tuples. For example,</para> <programlisting>PATCH_DEPENDS= ${NONEXISTENT}:${PORTSDIR}/java/jfc:extract</programlisting> <para>will descend into the <filename>java/jfc</filename> subdirectory of the 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="makefile-uses"> <title><varname>USES</varname></title> <para>Parameters can be added to define different features and dependencies used by the port. They are specified by adding this line to the <filename>Makefile</filename>:</para> <programlisting>USES= feature[:arguments]</programlisting> <para>For the complete list of values, please see <xref linkend="uses-values"/>.</para> <warning> <para><varname>USES</varname> cannot be assigned after inclusion of <filename>bsd.port.pre.mk</filename>.</para> </warning> </sect2> <sect2 xml:id="makefile-use-vars"> <title><varname>USE_<replaceable>*</replaceable></varname></title> <para>Several variables exist to define common dependencies shared by many ports. Their use is optional, but helps to reduce the verbosity of the port <filename>Makefile</filename>s. Each of them is styled as <varname>USE_<replaceable>*</replaceable></varname>. These variables may be used only in the port <filename>Makefile</filename>s and <filename>ports/Mk/bsd.*.mk</filename>. They are not meant for user-settable options — use <varname>PORT_OPTIONS</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</para> <programlisting>USE_GCC=X.Y</programlisting> <para>(where X.Y is version number) would add a dependency on gccXY for every port, including <literal>lang/gccXY</literal> itself!</para> </note> <table frame="none" xml:id="makefile-use-vars-table"> <title><varname>USE_<replaceable>*</replaceable></varname></title> <tgroup cols="2"> <thead> <row> <entry>Variable</entry> <entry>Means</entry> </row> </thead> <tbody> <row> <entry><varname>USE_GCC</varname></entry> <entry>The port requires GCC (<command>gcc</command> or <command>g++</command>) to build. Some ports need any GCC version, some require modern, recent versions. It is typically set to <literal>any</literal> (in this case, GCC from base would be used on versions of &os; that still have it, or <literal>lang/gcc</literal> port would be installed when default C/C++ compiler is Clang); or <literal>yes</literal> (means always use stable, modern GCC from <literal>lang/gcc</literal> port). The exact version can also be specified, with a value such as <literal>4.7</literal>. The minimal required version can be specified as <literal>4.6+</literal>. The GCC from the base system is used when it satisfies the requested version, otherwise an appropriate compiler is built from the port, and <varname>CC</varname> and <varname>CXX</varname> are adjusted accordingly.</entry> </row> </tbody> </tgroup> </table> <para>Variables related to <application>gmake</application> and <filename>configure</filename> 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 xml:id="makefile-version-dependency"> <title>Minimal Version of a Dependency</title> <para>A minimal version of a dependency can be specified in any <varname><replaceable>*</replaceable>_DEPENDS</varname> except <varname>LIB_DEPENDS</varname> using this syntax:</para> <programlisting>p5-Spiffy>=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 xml:id="makefile-note-on-dependencies"> <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 the port needs a special way to handle a dependency, use the <literal>:target</literal> part of <varname><replaceable>*</replaceable>_DEPENDS</varname> instead of redefining <varname>DEPENDS_TARGET</varname>.</para> <para>When running <command>make clean</command>, the port dependencies are automatically cleaned too. If this is not desirable, define <varname>NOCLEANDEPENDS</varname> in the 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 <literal>${NONEXISTENT}</literal> as the first field of <varname>BUILD_DEPENDS</varname> or <varname>RUN_DEPENDS</varname>. Use this only when the source of the other port is needed. Compilation time can be saved by specifying the target too. For instance</para> <programlisting>BUILD_DEPENDS= ${NONEXISTENT}:${PORTSDIR}/graphics/jpeg:extract</programlisting> <para>will always descend to the <literal>jpeg</literal> port and extract it.</para> </sect2> <sect2 xml:id="makefile-circular-dependencies"> <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 one is introduced, someone, somewhere in the world, will have their &os; installation broken almost immediately, with many others quickly to follow. These can really be hard to detect. If in doubt, before making that change, make sure to run: <command>cd /usr/ports; make index</command>. That process can be quite slow on older machines, but it may be able to save a large number of people, including yourself, a lot of grief in the process.</para> </sect2> <sect2 xml:id="makefile-automatic-dependencies"> <title>Problems Caused by Automatic Dependencies</title> <para>Dependencies must be declared either explicitly or by using the <link linkend="makefile-options">OPTIONS framework</link>. Using other methods like automatic detection complicates indexing, which causes problems for port and package management.</para> <example xml:id="makefile-automatic-dependencies-bad"> <title>Wrong Declaration of an Optional Dependency</title> <programlisting>.include <bsd.port.pre.mk> .if exists(${LOCALBASE}/bin/foo) LIB_DEPENDS= libbar.so:${PORTSDIR}/foo/bar .endif</programlisting> </example> <para>The problem with trying to automatically add dependencies is that files and settings outside an individual port can change at any time. For example: an index is built, then a batch of ports are installed. But one of the ports installs the tested file. The index is now incorrect, because an installed port unexpectedly has a new dependency. The index may still be wrong even after rebuilding if other ports also determine their need for dependencies based on the existence of other files.</para> <example xml:id="makefile-automatic-dependencies-good"> <title>Correct Declaration of an Optional Dependency</title> <programlisting>OPTIONS_DEFINE= BAR BAR_DESC= Calling cellphones via bar BAR_LIB_DEPENDS= libbar.so:${PORTSDIR}/foo/bar</programlisting> </example> <para>Testing option variables is the correct method. It will not cause inconsistencies in the index of a batch of ports, provided the options were defined prior to the index build. Simple scripts can then be used to automate the building, installation, and updating of these ports and their packages.</para> </sect2> <sect2 xml:id="use-want"> <title><varname>USE_<replaceable>*</replaceable></varname> and <varname>WANT_<replaceable>*</replaceable></varname></title> <para><varname>USE_<replaceable>*</replaceable></varname> are set by the port maintainer to define software on which this port depends. A port that needs Firefox would set</para> <programlisting>USE_FIREFOX= yes</programlisting> <para>Some <varname>USE_<replaceable>*</replaceable></varname> can accept version numbers or other parameters. For example, a port that requires Apache 2.2 would set</para> <programlisting>USE_APACHE= 22</programlisting> <para>For more control over dependencies in some cases, <varname>WANT_<replaceable>*</replaceable></varname> are available to more precisely specify what is needed. For example, consider the <package role="port">mail/squirrelmail</package> port. This port needs some PHP modules, which are listed in <varname>USE_PHP</varname>:</para> <programlisting>USE_PHP= session mhash gettext mbstring pcre openssl xml</programlisting> <para>Those modules may be available in CLI or web versions, so the web version is selected with <varname>WANT_<replaceable>*</replaceable></varname>:</para> <programlisting>WANT_PHP_WEB= yes</programlisting> <para>Available <varname>USE_<replaceable>*</replaceable></varname> and <varname>WANT_<replaceable>*</replaceable></varname> are defined in the files in <filename>/usr/ports/Mk</filename>.</para> </sect2> </sect1> <sect1 xml:id="makefile-masterdir"> <title><varname>MASTERDIR</varname></title> <para>If the 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, by using variables cleverly, only a very short <filename>Makefile</filename> is needed in all but one of the directories. In the sole <filename>Makefile</filename>, 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 && ${RESOLUTION} != 240 && \ ${RESOLUTION} != 300 && ${RESOLUTION} != 400 @${ECHO_MSG} "Error: invalid value for RESOLUTION: \"${RESOLUTION}\"" @${ECHO_MSG} "Possible values are: 118, 240, 300 (default) and 400." @${FALSE} .endif</programlisting> <para><package role="port">japanese/xdvi300</package> also has all the regular patches, package files, etc. Running <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). <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>Man Pages</title> <para>If the port anchors its man tree somewhere other than <varname>PREFIX</varname>, use <varname>MANDIRS</varname> to specify those directories. Note that the files corresponding to manual pages must be be placed in <filename>pkg-plist</filename> along with the rest of the files. The purpose of <varname>MANDIRS</varname> is to enable automatic compression of manual pages, therefore the file names are suffixed with <filename>.gz</filename>.</para> </sect1> <sect1 xml:id="makefile-info"> <title>Info Files</title> <para>If the package needs to install <acronym>GNU</acronym> info files, list them in <varname>INFO</varname> (without the trailing <literal>.info</literal>), one entry per document. These files are assumed to be installed to <filename>PREFIX/INFO_PATH</filename>. Change <varname>INFO_PATH</varname> if the 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 role="port">lang/gcc34</package> installs info files to <filename>PREFIX/INFO_PATH/gcc34</filename>, and <varname>INFO</varname> will be something like this:</para> <programlisting>INFO= gcc34/cpp gcc34/cppinternals gcc34/g77 ...</programlisting> <para>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>Many applications can be built with optional or differing configurations. Examples include choice of natural (human) language, GUI versus command-line, or type of database to support. Users may need a different configuration than the default, so the ports system provides hooks the port author can use to control which variant will be built. Supporting these options properly will make users happy, and effectively provide two or more ports for the price of one.</para> <sect2 xml:id="makefile-options-options"> <title><varname>OPTIONS</varname></title> <sect3 xml:id="makefile-options-background"> <title>Background</title> <para><varname>OPTIONS_<replaceable>*</replaceable></varname> give the user installing the port a dialog showing the available options, and then saves those options to <filename>${PORT_DBDIR}/${OPTIONS_NAME}/options</filename>. The next time the port is built, the options are reused. <varname>PORT_DBDIR</varname> defaults to <filename>/var/db/ports</filename>. <varname>OPTIONS_NAME</varname> is to the port origin with an underscore as the space separator, for example, for <package role="port">dns/bind99</package> it will be <literal>dns_bind99</literal>.</para> <para>When the user runs <command>make config</command> (or runs <command>make build</command> for the first time), the framework checks for <filename>${PORT_DBDIR}/${OPTIONS_NAME}/options</filename>. If that file does not exist, the values of <varname>OPTIONS_<replaceable>*</replaceable></varname> are used, and a dialog box is displayed where the options can be enabled or disabled. Then <filename>options</filename> is saved and the configured variables are 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><command>make showconfig</command> shows the saved configuration. Use <command>make rmconfig</command> to remove the saved configuration.</para> </sect3> <sect3 xml:id="makefile-options-syntax"> <title>Syntax</title> <para><varname>OPTIONS_DEFINE</varname> contains a list of <varname>OPTIONS</varname> to be used. These are independent of each other and are not grouped:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT2</programlisting> <para>Once defined, <varname>OPTIONS</varname> are described (optional, but strongly recommended):</para> <programlisting>OPT1_DESC= Describe OPT1 OPT2_DESC= Describe OPT2 OPT3_DESC= Describe OPT3 OPT4_DESC= Describe OPT4 OPT5_DESC= Describe OPT5 OPT6_DESC= Describe OPT6</programlisting> <para><filename>ports/Mk/bsd.options.desc.mk</filename> has descriptions for many common <varname>OPTIONS</varname>. While often useful, override them if the description is insufficient for the port.</para> <tip> <para>When describing options, view it from the perspective of the user: <quote>What functionality does it change?</quote> and <quote>Why would I want to enable this?</quote> Do not just repeat the name. For example, describing the <literal>NLS</literal> option as <quote>include NLS support</quote> does not help the user, who can already see the option name but may not know what it means. Describing it as <quote>Native Language Support via gettext utilities</quote> is much more helpful.</para> </tip> <important> <para>Option names are always in all uppercase. They cannot use mixed case or lowercase.</para> </important> <para><varname>OPTIONS</varname> can be grouped as radio choices, where only one choice from each group is allowed:</para> <programlisting>OPTIONS_SINGLE= SG1 OPTIONS_SINGLE_SG1= OPT3 OPT4</programlisting> <warning> <para>There <emphasis>must</emphasis> be one of each <literal>OPTIONS_SINGLE</literal> group selected at all times for the options to be valid. One option of each group <emphasis>must</emphasis> be added to <varname>OPTIONS_DEFAULT</varname>.</para> </warning> <para><varname>OPTIONS</varname> can be grouped as radio choices, where none or only one choice from each group is allowed:</para> <programlisting>OPTIONS_RADIO= RG1 OPTIONS_RADIO_RG1= OPT7 OPT8</programlisting> <para><varname>OPTIONS</varname> can also be grouped as <quote>multiple-choice</quote> lists, where <emphasis>at least one</emphasis> option must be enabled:</para> <programlisting>OPTIONS_MULTI= MG1 OPTIONS_MULTI_MG1= OPT5 OPT6</programlisting> <para><varname>OPTIONS</varname> can also be grouped as <quote>multiple-choice</quote> lists, where none or any option can be enabled:</para> <programlisting>OPTIONS_GROUP= GG1 OPTIONS_GROUP_GG1= OPT9 OPT10</programlisting> <para><varname>OPTIONS</varname> are unset by default, unless they are listed in <varname>OPTIONS_DEFAULT</varname>:</para> <programlisting>OPTIONS_DEFAULT= OPT1 OPT3 OPT6</programlisting> <para><varname>OPTIONS</varname> definitions must appear before the inclusion of <filename>bsd.port.options.mk</filename>. <varname>PORT_OPTIONS</varname> values can only be tested after the inclusion of <filename>bsd.port.options.mk</filename>. Inclusion of <filename>bsd.port.pre.mk</filename> can be used instead, too, and is still widely used in ports written before the introduction of <filename>bsd.port.options.mk</filename>. But be aware that some variables will not work as expected after the inclusion of <filename>bsd.port.pre.mk</filename>, typically some <varname>USE_<replaceable>*</replaceable></varname> flags.</para> <example xml:id="ports-options-simple-use"> <title>Simple Use of <varname>OPTIONS</varname></title> <programlisting>OPTIONS_DEFINE= FOO BAR FOO_DESC= Option foo support BAR_DESC= Feature bar support OPTIONS_DEFAULT=FOO # Will add --with-foo / --without-foo FOO_CONFIGURE_WITH= foo BAR_RUN_DEPENDS= bar:${PORTSDIR}/bar/bar .include <bsd.port.mk></programlisting> </example> <example xml:id="ports-options-check-unset"> <title>Check for Unset Port <varname>OPTIONS</varname></title> <programlisting>.if ! ${PORT_OPTIONS:MEXAMPLES} CONFIGURE_ARGS+=--without-examples .endif</programlisting> <para>The form shown above is discouraged. The preferred method is using a configure knob to really enable and disable the feature to match the option:</para> <programlisting># Will add --with-examples / --without-examples EXAMPLES_CONFIGURE_WITH= examples</programlisting> </example> <example xml:id="ports-options-practical-use"> <title>Practical Use of <varname>OPTIONS</varname></title> <programlisting>OPTIONS_DEFINE= EXAMPLES OPTIONS_SINGLE= BACKEND OPTIONS_SINGLE_BACKEND= MYSQL PGSQL BDB OPTIONS_MULTI= AUTH OPTIONS_MULTI_AUTH= LDAP PAM SSL EXAMPLES_DESC= Install extra examples MYSQL_DESC= Use MySQL as backend PGSQL_DESC= Use PostgreSQL as backend BDB_DESC= Use Berkeley DB as backend LDAP_DESC= Build with LDAP authentication support PAM_DESC= Build with PAM support SSL_DESC= Build with OpenSSL support OPTIONS_DEFAULT= PGSQL LDAP SSL # Will add USE_PGSQL=yes PGSQL_USE= pgsql=yes # Will add --enable-postgres / --disable-postgres PGSQL_CONFIGURE_ENABLE= postgres ICU_LIB_DEPENDS= libicuuc.so:${PORTSDIR}/devel/icu # Will add --with-examples / --without-examples EXAMPLES_CONFIGURE_WITH= examples # Check other OPTIONS .include <bsd.port.mk></programlisting> </example> </sect3> <sect3 xml:id="makefile-options-default"> <title>Default Options</title> <para>These options are always on by default.</para> <itemizedlist> <listitem> <para><literal>DOCS</literal> — build and install documentation.</para> </listitem> <listitem> <para><literal>NLS</literal> — Native Language Support.</para> </listitem> <listitem> <para><literal>EXAMPLES</literal> — build and install examples.</para> </listitem> <listitem> <para><literal>IPV6</literal> — IPv6 protocol support.</para> </listitem> </itemizedlist> <note> <para>There is no need to add these to <varname>OPTIONS_DEFAULT</varname>. To have them active, and show up in the options selection dialog, however, they must be added to <varname>OPTIONS_DEFINE</varname>.</para> </note> </sect3> </sect2> <sect2 xml:id="makefile-options-auto-activation"> <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 that are not needed by adding <literal>--without-xxx</literal> or <literal>--disable-xxx</literal> in <varname>CONFIGURE_ARGS</varname>.</para> <example xml:id="makefile-options-auto-activation-bad"> <title>Wrong Handling of an Option</title> <programlisting>.if ${PORT_OPTIONS:MFOO} LIB_DEPENDS+= libfoo.so:${PORTSDIR}/devel/foo CONFIGURE_ARGS+= --enable-foo .endif</programlisting> </example> <para>In the example above, imagine a library libfoo is installed on the system. The 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 the 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 xml:id="makefile-options-auto-activation-good"> <title>Correct Handling of an Option</title> <programlisting>FOO_LIB_DEPENDS= libfoo.so:${PORTSDIR}/devel/foo # Will add --enable-foo / --disable-foo FOO_CONFIGURE_ENABLE= foo</programlisting> </example> <note> <para>Under some circumstances, the shorthand conditional syntax can cause problems with complex constructs. The errors are usually <literal>Malformed conditional</literal>, an alternative syntax can be used.</para> <programlisting>.if !empty(VARIABLE:MVALUE) # as an alternative to .if ${VARIABLE:MVALUE}</programlisting> </note> </sect2> <sect2 xml:id="options-helpers"> <title>Options Helpers</title> <para>There are some macros to help simplify conditional values which differ based on the options set.</para> <sect3 xml:id="options_sub"> <title><varname>OPTIONS_SUB</varname></title> <para>If <varname>OPTIONS_SUB</varname> is set to <literal>yes</literal> then each of the options added to <varname>OPTIONS_DEFINE</varname> will be added to <varname>PLIST_SUB</varname> and <varname>SUB_LIST</varname>, for example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPTIONS_SUB= yes</programlisting> <para> is equivalent to:</para> <programlisting>OPTIONS_DEFINE= OPT1 .include <bsd.port.options.mk> .if ${PORT_OPTIONS:MOPT1} PLIST_SUB+= OPT1="" NO_OPT1="@comment " SUB_LIST+= OPT1="" NO_OPT1="@comment " .else PLIST_SUB+= OPT1="@comment " NO_OPT1="" SUB_LIST+= OPT1="@comment " NO_OPT1="" .endif</programlisting> <note> <para>The value of <varname>OPTIONS_SUB</varname> is ignored. Setting it to any value will add <varname>PLIST_SUB</varname> and <varname>SUB_LIST</varname> entries for <emphasis>all</emphasis> options.</para> </note> </sect3> <sect3 xml:id="options-use"> <title><varname><replaceable>OPT</replaceable>_USE</varname></title> <para>When option <replaceable>OPT</replaceable> is selected, for each <literal><replaceable>key</replaceable>=<replaceable>value</replaceable></literal> pair in <varname><replaceable>OPT</replaceable>_USE</varname>, <replaceable>value</replaceable> is appended to the corresponding <varname>USE_<replaceable>KEY</replaceable></varname>. If <replaceable>value</replaceable> has spaces in it, replace them with commas and they will be changed back to spaces during processing. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT1_USE= mysql=yes xorg=x11,xextproto,xext,xrandr</programlisting> <para>is equivalent to:</para> <programlisting>OPTIONS_DEFINE= OPT1 .include <bsd.port.options.mk> .if ${PORT_OPTIONS:MOPT1} USE_MYSQL= yes USE_XORG= x11 xextproto xext xrandr .endif</programlisting> </sect3> <sect3 xml:id="options-use-off"> <title><varname><replaceable>OPT</replaceable>_USE_OFF</varname></title> <para>When option <replaceable>OPT</replaceable> <emphasis>is not</emphasis> selected, for each <literal><replaceable>key</replaceable>=<replaceable>value</replaceable></literal> pair in <varname><replaceable>OPT</replaceable>_USE_OFF</varname>, <replaceable>value</replaceable> is appended to the corresponding <varname>USE_<replaceable>KEY</replaceable></varname>. If <replaceable>value</replaceable> has spaces in it, replace them with commas and they will be changed back to spaces during processing. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT1_USE_OFF= mysql=yes xorg=x11,xextproto,xext,xrandr</programlisting> <para>is equivalent to:</para> <programlisting>OPTIONS_DEFINE= OPT1 .include <bsd.port.options.mk> .if ! ${PORT_OPTIONS:MOPT1} USE_MYSQL= yes USE_XORG= x11 xextproto xext xrandr .endif</programlisting> </sect3> <sect3 xml:id="options-configure_enable"> <title><varname><replaceable>OPT</replaceable>_CONFIGURE_ENABLE</varname></title> <para>When option <replaceable>OPT</replaceable> is selected, for each <replaceable>entry</replaceable> in <varname><replaceable>OPT</replaceable>_CONFIGURE_ENABLE</varname> then <literal>--enable-<replaceable>entry</replaceable></literal> is appended to <varname>CONFIGURE_ARGS</varname>. When option <replaceable>OPT</replaceable> is not selected, <literal>--disable-<replaceable>entry</replaceable></literal> is appended to <varname>CONFIGURE_ARGS</varname>. An optional argument can be specified with an <literal>=</literal> symbol. This argument is only appended to the <literal>--enable-<replaceable>entry</replaceable></literal> configure option. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT2 OPT1_CONFIGURE_ENABLE= test1 test2 OPT2_CONFIGURE_ENABLE= test2=exhaustive</programlisting> <para>is equivalent to:</para> <programlisting>OPTIONS_DEFINE= OPT1 .include <bsd.port.options.mk> .if ${PORT_OPTIONS:MOPT1} CONFIGURE_ARGS+= --enable-test1 --enable-test2 .else CONFIGURE_ARGS+= --disable-test1 --disable-test2 .endif .if ${PORT_OPTIONS:MOPT2} CONFIGURE_ARGS+= --enable-test2=exhaustive .else CONFIGURE_ARGS+= --disable-test2 .endif</programlisting> </sect3> <sect3 xml:id="options-configure_with"> <title><varname><replaceable>OPT</replaceable>_CONFIGURE_WITH</varname></title> <para>When option <replaceable>OPT</replaceable> is selected, for each <replaceable>entry</replaceable> in <varname><replaceable>OPT</replaceable>_CONFIGURE_ENABLE</varname> then <literal>--with-<replaceable>entry</replaceable></literal> is appended to <varname>CONFIGURE_ARGS</varname>. When option <replaceable>OPT</replaceable> is not selected, <literal>--without-<replaceable>entry</replaceable></literal> is appended to <varname>CONFIGURE_ARGS</varname>. An optional argument can be specified with an <literal>=</literal> symbol. This argument is only appended to the <literal>--with-<replaceable>entry</replaceable></literal> configure option. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT2 OPT1_CONFIGURE_WITH= test1 OPT2_CONFIGURE_WITH= test2=exhaustive</programlisting> <para>is equivalent to:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT2 .include <bsd.port.options.mk> .if ${PORT_OPTIONS:MOPT1} CONFIGURE_ARGS+= --with-test1 .else CONFIGURE_ARGS+= --without-test1 .endif .if ${PORT_OPTIONS:MOPT2} CONFIGURE_ARGS+= --with-test2=exhaustive .else CONFIGURE_ARGS+= --without-test2 .endif</programlisting> </sect3> <sect3 xml:id="options-configure_on"> <title><varname><replaceable>OPT</replaceable>_CONFIGURE_ON</varname></title> <para>When option <replaceable>OPT</replaceable> is selected, the value of <varname><replaceable>OPT</replaceable>_CONFIGURE_ON</varname>, if defined, is appended to <varname>CONFIGURE_ARGS</varname>. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT1_CONFIGURE_ON= --add-test</programlisting> <para>is equivalent to:</para> <programlisting>OPTIONS_DEFINE= OPT1 .include <bsd.port.options.mk> .if ${PORT_OPTIONS:MOPT1} CONFIGURE_ARGS+= --add-test .endif</programlisting> </sect3> <sect3 xml:id="options-configure_off"> <title><varname><replaceable>OPT</replaceable>_CONFIGURE_OFF</varname></title> <para>When option <replaceable>OPT</replaceable> <emphasis>is not</emphasis> selected, the value of <varname><replaceable>OPT</replaceable>_CONFIGURE_ON</varname>, if defined, is appended to <varname>CONFIGURE_ARGS</varname>. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT1_CONFIGURE_OFF= --no-test</programlisting> <para>is equivalent to:</para> <programlisting>OPTIONS_DEFINE= OPT1 .include <bsd.port.options.mk> .if ! ${PORT_OPTIONS:MOPT1} CONFIGURE_ARGS+= --no-test .endif</programlisting> </sect3> <sect3 xml:id="options-cmake_on"> <title><varname><replaceable>OPT</replaceable>_CMAKE_ON</varname></title> <para>When option <replaceable>OPT</replaceable> is selected, the value of <varname><replaceable>OPT</replaceable>_CMAKE_ON</varname>, if defined, is appended to <varname>CMAKE_ARGS</varname>. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT1_CMAKE_ON= -DTEST:BOOL=true</programlisting> <para>is equivalent to:</para> <programlisting>OPTIONS_DEFINE= OPT1 .include <bsd.port.options.mk> .if ${PORT_OPTIONS:MOPT1} CMAKE_ARGS+= -DTEST:BOOL=true .endif</programlisting> </sect3> <sect3 xml:id="options-cmake_off"> <title><varname><replaceable>OPT</replaceable>_CMAKE_OFF</varname></title> <para>When option <replaceable>OPT</replaceable> <emphasis>is not</emphasis> selected, the value of <varname><replaceable>OPT</replaceable>_CMAKE_OFF</varname>, if defined, is appended to <varname>CMAKE_ARGS</varname>. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT1_CMAKE_OFF= -DTEST:BOOL=false</programlisting> <para>is equivalent to:</para> <programlisting>OPTIONS_DEFINE= OPT1 .include <bsd.port.options.mk> .if ! ${PORT_OPTIONS:MOPT1} CMAKE_ARGS+= -DTEST:BOOL=false .endif</programlisting> </sect3> <sect3 xml:id="options-qmake_on"> <title><varname><replaceable>OPT</replaceable>_QMAKE_ON</varname></title> <para>When option <replaceable>OPT</replaceable> is selected, the value of <varname><replaceable>OPT</replaceable>_QMAKE_ON</varname>, if defined, is appended to <varname>QMAKE_ARGS</varname>. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT1_QMAKE_ON= -DTEST:BOOL=true</programlisting> <para>is equivalent to:</para> <programlisting>OPTIONS_DEFINE= OPT1 .include <bsd.port.options.mk> .if ${PORT_OPTIONS:MOPT1} QMAKE_ARGS+= -DTEST:BOOL=true .endif</programlisting> </sect3> <sect3 xml:id="options-qmake_off"> <title><varname><replaceable>OPT</replaceable>_QMAKE_OFF</varname></title> <para>When option <replaceable>OPT</replaceable> <emphasis>is not</emphasis> selected, the value of <varname><replaceable>OPT</replaceable>_QMAKE_OFF</varname>, if defined, is appended to <varname>QMAKE_ARGS</varname>. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT1_QMAKE_OFF= -DTEST:BOOL=false</programlisting> <para>is equivalent to:</para> <programlisting>OPTIONS_DEFINE= OPT1 .include <bsd.port.options.mk> .if ! ${PORT_OPTIONS:MOPT1} QMAKE_ARGS+= -DTEST:BOOL=false .endif</programlisting> </sect3> <sect3 xml:id="options-dependencies"> <title>Dependencies</title> <para>For any of these dependency types:</para> <itemizedlist> <listitem> <para><varname>PKG_DEPENDS</varname></para> </listitem> <listitem> <para><varname>EXTRACT_DEPENDS</varname></para> </listitem> <listitem> <para><varname>PATCH_DEPENDS</varname></para> </listitem> <listitem> <para><varname>FETCH_DEPENDS</varname></para> </listitem> <listitem> <para><varname>BUILD_DEPENDS</varname></para> </listitem> <listitem> <para><varname>LIB_DEPENDS</varname></para> </listitem> <listitem> <para><varname>RUN_DEPENDS</varname></para> </listitem> </itemizedlist> <sect4> <title><varname><replaceable>OPT</replaceable>_<replaceable>ABOVEVARIABLE</replaceable></varname></title> <para>When option <replaceable>OPT</replaceable> is selected, the value of <varname><replaceable>OPT</replaceable>_<replaceable>ABOVEVARIABLE</replaceable></varname>, if defined, is appended to <literal><replaceable>ABOVEVARIABLE</replaceable></literal>. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT1_LIB_DEPENDS= liba.so:${PORTSDIR}/devel/a</programlisting> <para>is equivalent to:</para> <programlisting>OPTIONS_DEFINE= OPT1 .include <bsd.port.options.mk> .if ${PORT_OPTIONS:MOPT1} LIB_DEPENDS+= liba.so:${PORTSDIR}/devel/a .endif</programlisting> </sect4> <sect4> <title><varname><replaceable>OPT</replaceable>_<replaceable>ABOVEVARIABLE</replaceable>_OFF</varname></title> <para>When option <replaceable>OPT</replaceable> <emphasis>is not</emphasis> selected, the value of <varname><replaceable>OPT</replaceable>_<replaceable>ABOVEVARIABLE</replaceable>_OFF</varname>, if defined, is appended to <literal><replaceable>ABOVEVARIABLE</replaceable></literal>. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT1_LIB_DEPENDS_OFF= liba.so:${PORTSDIR}/devel/a</programlisting> <para>is equivalent to:</para> <programlisting>OPTIONS_DEFINE= OPT1 .include <bsd.port.options.mk> . if ! ${PORT_OPTIONS:MOPT1} LIB_DEPENDS+= liba.so:${PORTSDIR}/devel/a .endif</programlisting> </sect4> </sect3> <sect3 xml:id="options-variables"> <title>Generic Variables Replacement</title> <para>For any of these variables:</para> <itemizedlist> <listitem> <para><varname>ALL_TARGET</varname></para> </listitem> <listitem> <para><varname>CATEGORIES</varname></para> </listitem> <listitem> <para><varname>CFLAGS</varname></para> </listitem> <listitem> <para><varname>CPPFLAGS</varname></para> </listitem> <listitem> <para><varname>CXXFLAGS</varname></para> </listitem> <listitem> <para><varname>CONFIGURE_ENV</varname></para> </listitem> <listitem> <para><varname>CONFLICTS</varname></para> </listitem> <listitem> <para><varname>CONFLICTS_BUILD</varname></para> </listitem> <listitem> <para><varname>CONFLICTS_INSTALL</varname></para> </listitem> <listitem> <para><varname>DISTFILES</varname></para> </listitem> <listitem> <para><varname>EXTRA_PATCHES</varname></para> </listitem> <listitem> <para><varname>INFO</varname></para> </listitem> <listitem> <para><varname>INSTALL_TARGET</varname></para> </listitem> <listitem> <para><varname>LDFLAGS</varname></para> </listitem> <listitem> <para><varname>MAKE_ARGS</varname></para> </listitem> <listitem> <para><varname>MAKE_ENV</varname></para> </listitem> <listitem> <para><varname>PATCH_SITES</varname></para> </listitem> <listitem> <para><varname>PATCHFILES</varname></para> </listitem> <listitem> <para><varname>PLIST_FILES</varname></para> </listitem> <listitem> <para><varname>PLIST_DIRS</varname></para> </listitem> <listitem> <para><varname>PLIST_DIRSTRY</varname></para> </listitem> <listitem> <para><varname>PLIST_SUB</varname></para> </listitem> <listitem> <para><varname>USES</varname></para> </listitem> </itemizedlist> <warning> <para>Some of these variables, at least <varname>ALL_TARGET</varname> and <varname>INSTALL_TARGET</varname>, have their default values set <emphasis>after</emphasis> the options are processed.</para> <para>With these lines in the <filename>Makefile</filename>:</para> <programlisting>ALL_TARGET= all DOCS_ALL_TARGET= doc</programlisting> <para>If the <literal>DOCS</literal> option is enabled, <varname>ALL_TARGET</varname> will have a final value of <literal>all doc</literal>; if the option is disabled, it would have a value of <literal>all</literal>.</para> <para>With only the options helper line in the <filename>Makefile</filename>:</para> <programlisting>DOCS_ALL_TARGET= doc</programlisting> <para>If the <literal>DOCS</literal> option is enabled, <varname>ALL_TARGET</varname> will have a final value of <literal>doc</literal>; if the option is disabled, it would have a value of <literal>all</literal>.</para> </warning> <sect4> <title><varname><replaceable>OPT</replaceable>_<replaceable>ABOVEVARIABLE</replaceable></varname></title> <para>When option <replaceable>OPT</replaceable> is selected, the value of <varname><replaceable>OPT</replaceable>_<replaceable>ABOVEVARIABLE</replaceable></varname>, if defined, is appended to <literal><replaceable>ABOVEVARIABLE</replaceable></literal>. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT1_USES= gmake OPT1_CFLAGS= -DTEST</programlisting> <para>is equivalent to:</para> <programlisting>OPTIONS_DEFINE= OPT1 .include <bsd.port.options.mk> .if ${PORT_OPTIONS:MOPT1} USES+= gmake CFLAGS+= -DTEST .endif</programlisting> </sect4> <sect4> <title><varname><replaceable>OPT</replaceable>_<replaceable>ABOVEVARIABLE</replaceable>_OFF</varname></title> <para>When option OPT is not selected, the value of <varname><replaceable>OPT</replaceable>_<replaceable>ABOVEVARIABLE</replaceable>_OFF</varname>, if defined, is appended to <literal><replaceable>ABOVEVARIABLE</replaceable></literal>. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT1_USES_OFF= gmake</programlisting> <para>is equivalent to:</para> <programlisting>OPTIONS_DEFINE= OPT1 .include <bsd.port.options.mk> .if ! ${PORT_OPTIONS:MOPT1} USES+= gmake .endif</programlisting> </sect4> </sect3> </sect2> </sect1> <sect1 xml:id="makefile-wrkdir"> <title>Specifying the Working Directory</title> <para>Each port is extracted into a working directory, which must be writable. The ports system defaults to having <varname>DISTFILES</varname> unpack in to a directory called <literal>${DISTNAME}</literal>. In other words, if the <filename>Makefile</filename> has:</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>A number of variables can overriden if that is not the case.</para> <sect2 xml:id="makefile-wrksrc"> <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>) write:</para> <programlisting>WRKSRC= ${WRKDIR}/foo</programlisting> <para>or possibly</para> <programlisting>WRKSRC= ${WRKDIR}/${PORTNAME}</programlisting> </sect2> <sect2 xml:id="makefile-no_wrksubdir"> <title><varname>NO_WRKSUBDIR</varname></title> <para>If the port does not extract in to a subdirectory at all, then set <varname>NO_WRKSUBDIR</varname> to indicate that.</para> <programlisting>NO_WRKSUBDIR= yes</programlisting> </sect2> </sect1> <sect1 xml:id="conflicts"> <title>Conflict Handling</title> <para>There are three different variables to register a conflict between packages and ports: <varname>CONFLICTS</varname>, <varname>CONFLICTS_INSTALL</varname> and <varname>CONFLICTS_BUILD</varname>.</para> <note> <para>The conflict variables automatically set the variable <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 <varname>CONFLICTS</varname> in those other ports for a few months to cater for users who only update once in a while.</para> <sect2 xml:id="conflicts-conflicts_install"> <title><varname>CONFLICTS_INSTALL</varname></title> <para>If the package cannot coexist with other packages (because of file conflicts, runtime incompatibilities, etc.), list the other package names in <varname>CONFLICTS_INSTALL</varname>. Use shell globs like <literal>*</literal> and <literal>?</literal> here. Enumerate package names in there, not port names or origins. Please make sure that <varname>CONFLICTS_INSTALL</varname> does not match this port's package itself. Otherwise enforcing its installation with <varname>FORCE_PKG_REGISTER</varname> will no longer work. <varname>CONFLICTS_INSTALL</varname> check is done after the build stage and prior to the install stage.</para> </sect2> <sect2 xml:id="conflicts-conflicts_build"> <title><varname>CONFLICTS_BUILD</varname></title> <para>If the port cannot be built when other specific ports are already installed, list the other port names in <varname>CONFLICTS_BUILD</varname>. Use shell globs like <literal>*</literal> and <literal>?</literal> here. Use package names, not port names or origins. <varname>CONFLICTS_BUILD</varname> check is done prior to the build stage. Build conflicts are not recorded in the resulting package.</para> </sect2> <sect2 xml:id="conflicts-conflicts"> <title><varname>CONFLICTS</varname></title> <para>If the port cannot be built if a certain port is already installed and the resulting package cannot coexist with the other package, list the other package name in <varname>CONFLICTS</varname>. use shell globs like <literal>*</literal> and <literal>?</literal> here. Enumerate package names in there, not port names or origins. Please make sure that <varname>CONFLICTS</varname> does not match this port's package itself. Otherwise enforcing its installation with <varname>FORCE_PKG_REGISTER</varname> will no longer work. <varname>CONFLICTS</varname> check is done prior to the build stage and prior to the install stage.</para> </sect2> </sect1> <sect1 xml:id="install"> <title>Installing Files</title> <sect2 xml:id="install-macros"> <title><varname>INSTALL_<replaceable>*</replaceable></varname> Macros</title> <para>Use the macros provided in <filename>bsd.port.mk</filename> to ensure correct modes of files in the port's <buildtarget>*-install</buildtarget> targets. Set ownership directly in <filename>pkg-plist</filename> with the corresponding entries, such as <literal>@owner <replaceable>owner</replaceable></literal> and <literal>@group <replaceable>group</replaceable></literal>. These operators work until being overridden, or until the end of <filename>pkg-plist</filename>, so do not forget to reset them after they are no longer needed. The default ownership is <literal>root:wheel</literal>.</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_LIB</varname> is a command to install shared libraries (but not static libraries).</para> </listitem> <listitem> <para><varname>INSTALL_KLD</varname> is a command to install kernel loadable modules. Some architectures do not like having the modules stripped, so use this command instead of <varname>INSTALL_PROGRAM</varname>.</para> </listitem> <listitem> <para><varname>INSTALL_DATA</varname> is a command to install sharable data, including static libraries.</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 the <command>install</command> command with all the appropriate flags.</para> <note> <para>Do not use <varname>INSTALL_LIB</varname> to install static libraries, because stripping them render them useless. Use <varname>INSTALL_DATA</varname> instead.</para> </note> </sect2> <sect2 xml:id="install-strip"> <title>Stripping Binaries and Shared Libraries</title> <para>Installed binaries should be stripped. Do not strip binaries manually unless forced to. The <varname>INSTALL_PROGRAM</varname> macro will install and strip a binary at the same time (see the next section). The <varname>INSTALL_LIB</varname> macro does the same thing to shared libraries.</para> <para>When a file must be stripped, but neither <varname>INSTALL_PROGRAM</varname> nor <varname>INSTALL_LIB</varname> macros are desirable, <literal>${STRIP_CMD}</literal> will strip the program or shared library. This is typically done within the <buildtarget>post-install</buildtarget> target. For example:</para> <programlisting>post-install: ${STRIP_CMD} ${STAGEDIR}${PREFIX}/bin/xdl</programlisting> <para>When multiple files need to be stripped:</para> <programlisting>post-install: .for l in geometry media body track world ${STRIP_CMD} ${STAGEDIR}${PREFIX}/lib/lib${PORTNAME}-${l}.so.0 .endfor</programlisting> <para>Use &man.file.1; on a file to determine if it has been stripped. Binaries are reported by &man.file.1; as <literal>stripped</literal>, or <literal>not stripped</literal>. Additionally, &man.strip.1; will detect programs that have already been stripped and exit cleanly.</para> </sect2> <sect2 xml:id="install-copytree"> <title>Installing a Whole Tree of Files</title> <para>Sometimes, a large number of files must be installed while preserving their hierarchical organization. For example, copying over a whole directory tree from <varname>WRKSRC</varname> to a target directory under <varname>PREFIX</varname>. Note that <varname>PREFIX</varname>, <varname>EXAMPLESDIR</varname>, <varname>DATADIR</varname>, and other path variables must always be prepended with <varname>STAGEDIR</varname> to respect staging (see <xref linkend="staging"/>).</para> <para>Two macros exist 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. The 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} ${STAGEDIR}${EXAMPLESDIR} (cd ${WRKSRC}/examples && ${COPYTREE_SHARE} . ${STAGEDIR}${EXAMPLESDIR})</programlisting> <para>This example will install the contents of the <filename>examples</filename> directory in the vendor distfile to the proper examples location of the port.</para> <programlisting>post-install: ${MKDIR} ${STAGEDIR}${DATADIR}/summer (cd ${WRKSRC}/temperatures && ${COPYTREE_SHARE} "June July August" ${STAGEDIR}${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 <varname>COPYTREE_<replaceable>*</replaceable></varname> macros. For example, to install all files from the first example except Makefiles, one can use these commands.</para> <programlisting>post-install: ${MKDIR} ${STAGEDIR}${EXAMPLESDIR} (cd ${WRKSRC}/examples && \ ${COPYTREE_SHARE} . ${STAGEDIR}${EXAMPLESDIR} "! -name Makefile")</programlisting> <para>These macros do not add the installed files to <filename>pkg-plist</filename>. They must be added manually. For optional documentation (<varname>PORTDOCS</varname>, see <xref linkend="install-documentation"/>) and examples (<varname>PORTEXAMPLES</varname>), the <literal>%%PORTDOCS%%</literal> or <literal>%%PORTEXAMPLES%%</literal> prefixes must be prepended in <filename>pkg-plist</filename>.</para> </sect2> <sect2 xml:id="install-documentation"> <title>Install Additional Documentation</title> <para>If the software has some documentation other than the standard man and info pages that is useful for the user, install it under <varname>DOCSDIR</varname> This can be done, like the previous item, in the <buildtarget>post-install</buildtarget> target.</para> <para>Create a new directory for the port. The directory name is <varname>DOCSDIR</varname>. This usually equals <varname>PORTNAME</varname>. However, if the user might want different versions of the port to be installed at the same time, the whole <varname>PKGNAME</varname> can be used.</para> <para>Since only the files listed in <filename>pkg-plist</filename> are installed, it is safe to always install documentation to <varname>STAGEDIR</varname> (see <xref linkend="staging"/>). Hence <literal>.if</literal> blocks are only needed when the installed files are large enough to cause significant I/O overhead.</para> <programlisting>post-install: ${MKDIR} ${STAGEDIR}${DOCSDIR} ${INSTALL_MAN} ${WRKSRC}/docs/xvdocs.ps ${STAGEDIR}${DOCSDIR}</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>The <literal>DOCS</literal> option 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 <literal>DATA</literal> and <literal>EXAMPLES</literal> options, 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 are included in <filename>pkg-plist</filename> with the <literal>%%PORTDOCS%%</literal> prefix, for example:</para> <programlisting>%%PORTDOCS%%%%DOCSDIR%%/AUTHORS %%PORTDOCS%%%%DOCSDIR%%/CONTACT</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, must 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 the <literal>DOCS</literal> option has been unset then files and directories listed in <varname>PORTDOCS</varname> would not be installed or 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>The contents of <filename>pkg-message</filename> are displayed upon installation. See <link linkend="porting-message">the section on using <filename>pkg-message</filename></link> for details. <filename>pkg-message</filename> does not need to be added to <filename>pkg-plist</filename>.</para> </note> </sect2> <sect2 xml:id="install-subdirs"> <title>Subdirectories Under <varname>PREFIX</varname></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 must be moved to one of these directories: <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>