Index: head/en_US.ISO8859-1/books/porters-handbook/makefiles/chapter.xml =================================================================== --- head/en_US.ISO8859-1/books/porters-handbook/makefiles/chapter.xml (revision 51829) +++ head/en_US.ISO8859-1/books/porters-handbook/makefiles/chapter.xml (revision 51830) @@ -1,8118 +1,8118 @@ <?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></title> <para>Set <varname>PORTNAME</varname> to the base name of the software. It is used as the base for the &os; package, and for <link linkend="makefile-distname"><varname>DISTNAME</varname></link>.</para> <important> <para>The package name must be unique across the entire ports tree. Make sure that the <varname>PORTNAME</varname> is not already in use by an existing port, and that no other port already has the same <varname>PKGBASE</varname>. If the name has already been used, add either <link linkend="porting-pkgnameprefix-suffix"><varname>PKGNAMEPREFIX</varname> or <varname>PKGNAMESUFFIX</varname></link>.</para> </important> </sect2> <sect2 xml:id="makefile-versions"> <title>Versions, <varname>DISTVERSION</varname> <emphasis>or</emphasis> <varname>PORTVERSION</varname></title> <para>Set <varname>DISTVERSION</varname> to the version number of the software.</para> <para><varname>PORTVERSION</varname> is the version used for the &os; package. It will be automatically derived from <varname>DISTVERSION</varname> to be compatible with &os;'s package versioning scheme. If the version contains <emphasis>letters</emphasis>, it might be needed to set <varname>PORTVERSION</varname> and not <varname>DISTVERSION</varname>.</para> <important> <para>Only one of <varname>PORTVERSION</varname> and <varname>DISTVERSION</varname> can be set at a time.</para> </important> <para>From time to time, some software will use a version scheme that is not compatible with how <varname>DISTVERSION</varname> translates in <varname>PORTVERSION</varname>.</para> <tip> <para>When updating a port, it is possible to use &man.pkg-version.8;'s <option>-t</option> argument to check if the new version is greater or lesser than before. See <xref linkend="makefile-versions-ex-pkg-version"/>.</para> </tip> <example xml:id="makefile-versions-ex-pkg-version"> <title>Using &man.pkg-version.8; to Compare Versions.</title> <para><command>pkg version -t</command> takes two versions as arguments, it will respond with <literal><</literal>, <literal>=</literal> or <literal>></literal> if the first version is less, equal, or more than the second version, respectively.</para> <screen>&prompt.user; <userinput>pkg version -t 1.2 1.3</userinput> < <co xml:id="makefile-versions-tip-co1"/> &prompt.user; <userinput>pkg version -t 1.2 1.2</userinput> = <co xml:id="makefile-versions-tip-co2"/> &prompt.user; <userinput>pkg version -t 1.2 1.2.0</userinput> = <co xml:id="makefile-versions-tip-co3"/> &prompt.user; <userinput>pkg version -t 1.2 1.2.p1</userinput> > <co xml:id="makefile-versions-tip-co4"/> &prompt.user; <userinput>pkg version -t 1.2.a1 1.2.b1</userinput> < <co xml:id="makefile-versions-tip-co5"/> &prompt.user; <userinput>pkg version -t 1.2 1.2p1</userinput> < <co xml:id="makefile-versions-tip-co6"/></screen> <calloutlist> <callout arearefs="makefile-versions-tip-co1"> <para><literal>1.2</literal> is before <literal>1.3</literal>.</para> </callout> <callout arearefs="makefile-versions-tip-co3"> <para><literal>1.2</literal> and <literal>1.2</literal> are equal as they have the same version.</para> </callout> <callout arearefs="makefile-versions-tip-co3"> <para><literal>1.2</literal> and <literal>1.2.0</literal> are equal as nothing equals zero.</para> </callout> <callout arearefs="makefile-versions-tip-co4"> <para><literal>1.2</literal> is after <literal>1.2.p1</literal> as <literal>.p1</literal>, think <quote>pre-release 1</quote>.</para> </callout> <callout arearefs="makefile-versions-tip-co4"> <para><literal>1.2.a1</literal> is before <literal>1.2.b1</literal>, think <quote>alpha</quote> and <quote>beta</quote>, and <literal>a</literal> is before <literal>b</literal>.</para> </callout> <callout arearefs="makefile-versions-tip-co6"> <para><literal>1.2</literal> is before <literal>1.2p1</literal> as <literal>2p1</literal>, think <quote>2, patch level 1</quote> which is a version after any <literal>2.X</literal> but before <literal>3</literal>.</para> </callout> </calloutlist> <note> <para>In here, the <literal>a</literal>, <literal>b</literal>, and <literal>p</literal> are used as if meaning <quote>alpha</quote>, <quote>beta</quote> or <quote>pre-release</quote> and <quote>patch level</quote>, but they are only letters and are sorted alphabetically, so any letter can be used, and they will be sorted appropriately.</para> </note> </example> <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> <example xml:id="makefile-versions-ex1"> <title>Using <varname>DISTVERSION</varname></title> <para>When the version only contains numbers separated by dots, dashes or underscores, use <varname>DISTVERSION</varname>.</para> <programlisting>PORTNAME= nekoto DISTVERSION= 1.2-4</programlisting> <para>It will generate a <varname>PORTVERSION</varname> of <literal>1.2.4</literal>.</para> </example> <example xml:id="makefile-versions-ex2"> <title>Using <varname>DISTVERSION</varname> When the Version Starts with a Letter or a Prefix</title> <para>When the version starts or ends with a letter, or a prefix or a suffix that is not part of the version, use <varname>DISTVERSIONPREFIX</varname>, <varname>DISTVERSION</varname>, and <varname>DISTVERSIONSUFFIX</varname>.</para> <para>If the version is <literal>v1.2-4</literal>:</para> <programlisting>PORTNAME= nekoto DISTVERSIONPREFIX= v DISTVERSION= 1_2_4</programlisting> <para>Some of the time, projects using <application>GitHub</application> will use their name in their versions. For example, the version could be <literal>nekoto-1.2-4</literal>:</para> <programlisting>PORTNAME= nekoto DISTVERSIONPREFIX= nekoto- DISTVERSION= 1.2_4</programlisting> <para>Those projects also sometimes use some string at the end of the version, for example, <literal>1.2-4_RELEASE</literal>:</para> <programlisting>PORTNAME= nekoto DISTVERSION= 1.2-4 DISTVERSIONSUFFIX= _RELEASE</programlisting> <para>Or they do both, for example, <literal>nekoto-1.2-4_RELEASE</literal>:</para> <programlisting>PORTNAME= nekoto DISTVERSIONPREFIX= nekoto- DISTVERSION= 1.2-4 DISTVERSIONSUFFIX= _RELEASE</programlisting> <para><varname>DISTVERSIONPREFIX</varname> and <varname>DISTVERSIONSUFFIX</varname> will not be used while constructing <varname>PORTVERSION</varname>, but only used in <varname>DISTNAME</varname>.</para> <para>All will generate a <varname>PORTVERSION</varname> of <literal>1.2.4</literal>.</para> </example> <example xml:id="makefile-versions-ex3"> <title>Using <varname>DISTVERSION</varname> When the Version Contains Letters Meaning <quote>alpha</quote>, <quote>beta</quote>, or <quote>pre-release</quote></title> <para>When the version contains numbers separated by dots, dashes or underscores, and letters are used to mean <quote>alpha</quote>, <quote>beta</quote> or <quote>pre-release</quote>, which is, before the version without the letters, use <varname>DISTVERSION</varname>.</para> <programlisting>PORTNAME= nekoto DISTVERSION= 1.2-pre4</programlisting> <programlisting>PORTNAME= nekoto DISTVERSION= 1.2p4</programlisting> <para>Both will generate a <varname>PORTVERSION</varname> of <literal>1.2.p4</literal> which is before than 1.2. &man.pkg-version.8; can be used to check that fact:</para> <screen>&prompt.user; <userinput>pkg version -t 1.2.p4 1.2</userinput> <</screen> </example> <example xml:id="makefile-versions-ex4"> <title>Not Using <varname>DISTVERSION</varname> When the Version Contains Letters Meaning "Patch Level"</title> <para>When the version contains letters that are not meant as <quote>alpha</quote>, <quote>beta</quote>, or <quote>pre</quote>, but more in a <quote>patch level</quote>, and meaning after the version without the letters, use <varname>PORTVERSION</varname>.</para> <programlisting>PORTNAME= nekoto PORTVERSION= 1.2p4</programlisting> <para>In this case, using <varname>DISTVERSION</varname> is not possible because it would generate a version of <literal>1.2.p4</literal> which would be before <literal>1.2</literal> and not after. &man.pkg-version.8; will verify this:</para> <screen>&prompt.user; <userinput>pkg version -t 1.2 1.2.p4</userinput> > <co xml:id="makefile-versions-ex4-co1"/> &prompt.user; <userinput>pkg version -t 1.2 1.2p4</userinput> < <co xml:id="makefile-versions-ex4-co2"/></screen> <calloutlist> <callout arearefs="makefile-versions-ex4-co1"> <para><literal>1.2</literal> is after <literal>1.2.p4</literal>, which is <emphasis>wrong</emphasis> in this case.</para> </callout> <callout arearefs="makefile-versions-ex4-co2"> <para><literal>1.2</literal> is before <literal>1.2p4</literal>, which is what was needed.</para> </callout> </calloutlist> </example> <para>For some more advanced examples of setting <varname>PORTVERSION</varname>, when the software's versioning is really not compatible with &os;'s, or <varname>DISTNAME</varname> when the distribution file does not contain the version itself, see <xref linkend="makefile-distname"/>.</para> </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>DISTVERSION</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>DISTVERSION</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>DISTVERSION</varname>, or that use <varname>PORTVERSION</varname> carefully, 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>DISTVERSION</varname>. The correct way is a <varname>DISTVERSION</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 DISTVERSION= 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 DISTVERSION= 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 DISTVERSION= 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 DISTVERSION= 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>DISTVERSION</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>d<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 a letter, here <literal>d</literal> (for date), 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, for each line, only one of <varname>DISTVERSION</varname> or <varname>PORTVERSION</varname> is set in, depending on which would be used in the port's <filename>Makefile</filename>:</para> <table frame="none" pgwide="1"> <title>Package Naming Examples</title> <tgroup cols="7"> <thead> <row> <entry>Distribution Name</entry> <entry><varname>PKGNAMEPREFIX</varname></entry> <entry><varname>PORTNAME</varname></entry> <entry><varname>PKGNAMESUFFIX</varname></entry> <entry><varname>DISTVERSION</varname></entry> <entry><varname>PORTVERSION</varname></entry> <entry>Reason or comment</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></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></entry> <entry>This is version 1 of <application>mule</application>, and version 2 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></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.3alpha</entry> <entry></entry> <entry>Version will be <literal>1.3.a</literal></entry> </row> <row> <entry>es-0.9-beta1</entry> <entry>(empty)</entry> <entry>es</entry> <entry>(empty)</entry> <entry>0.9-beta1</entry> <entry></entry> <entry>Version will be <literal>0.9.b1</literal></entry> </row> <row> <entry>mailman-2.0rc3</entry> <entry>(empty)</entry> <entry>mailman</entry> <entry>(empty)</entry> <entry>2.0rc3</entry> <entry></entry> <entry>Version will be <varname>2.0.r3</varname></entry> </row> <row> <entry>v3.3beta021.src</entry> <entry>(empty)</entry> <entry>tiff</entry> <entry>(empty)</entry> <entry></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></entry> <entry>p11</entry> <entry>No version in the filename, use what upstream says it is</entry> </row> <row> <entry>piewm</entry> <entry>(empty)</entry> <entry>piewm</entry> <entry>(empty)</entry> <entry>1.0</entry> <entry></entry> <entry>No version in the filename, use what upstream says it is</entry> </row> <row> <entry>xvgr-2.10pl1</entry> <entry>(empty)</entry> <entry>xvgr</entry> <entry>(empty)</entry> <entry></entry> <entry>2.10.pl1</entry> <entry>In that case, <literal>pl1</literal> means patch level, so using DISTVERSION is not possible.</entry> </row> <row> <entry>gawk-2.15.6</entry> <entry>ja-</entry> <entry>gawk</entry> <entry>(empty)</entry> <entry>2.15.6</entry> <entry></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></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></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>d<replaceable>yyyy</replaceable>.<replaceable>mm</replaceable>.<replaceable>dd</replaceable></literal>, or <literal>d<replaceable>yyyy</replaceable><replaceable>mm</replaceable><replaceable>dd</replaceable></literal>) as the version.</para> <tip> <para>Use any letter. Here, <literal>d</literal> here stands for date, if the source is a <application>Git</application> repository, <literal>g</literal> followed by the commit date is commonly used, using <literal>s</literal> for snapshot is also common.</para> </tip> </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> <literal>*</literal></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> <literal>*</literal></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> <literal>*</literal></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> <literal>*</literal></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> <literal>*</literal></entry> <entry>Ports from the <link xlink:href="http://www.gnome.org">GNOME</link> Project.</entry> <entry/> </row> <row> <entry><filename>gnustep</filename> <literal>*</literal></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> <literal>*</literal></entry> <entry>Software for amateur radio.</entry> <entry/> </row> <row> <entry><filename>haskell</filename> <literal>*</literal></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> <literal>*</literal></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> <literal>*</literal></entry> <entry>Ports from the <link xlink:href="http://www.kde.org">KDE</link> Project.</entry> <entry/> </row> <row> <entry><filename>kld</filename> <literal>*</literal></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> <literal>*</literal></entry> <entry>Linux applications and support utilities.</entry> <entry/> </row> <row> <entry><filename>lisp</filename> <literal>*</literal></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> <literal>*</literal></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> <literal>*</literal></entry> <entry>Applications dealing with parallelism in computing.</entry> <entry/> </row> <row> <entry><filename>pear</filename> <literal>*</literal></entry> <entry>Ports related to the Pear PHP framework.</entry> <entry/> </row> <row> <entry><filename>perl5</filename> <literal>*</literal></entry> <entry>Ports that require <application>Perl</application> version 5 to run.</entry> <entry/> </row> <row> <entry><filename>plan9</filename> <literal>*</literal></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> <literal>*</literal></entry> <entry>Software related to the <link xlink:href="http://www.python.org/">Python</link> language.</entry> <entry/> </row> <row> <entry><filename>ruby</filename> <literal>*</literal></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> <literal>*</literal></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> <literal>*</literal></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> <literal>*</literal></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> <literal>*</literal></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> <literal>*</literal></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> <literal>*</literal></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> <literal>*</literal></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> <literal>*</literal></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.</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-distname"> <title><varname>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 if not set, <varname>DISTVERSION</varname> defaults to <literal>${PORTVERSION}</literal> so override <varname>DISTNAME</varname> 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>DISTVERSIONPREFIX</varname>, <varname>DISTVERSION</varname>, and <varname>DISTVERSIONSUFFIX</varname>. <varname>PORTVERSION</varname> will be derived from <varname>DISTVERSION</varname> automatically.</para> <important> <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>.</para> </important> <para>If the upstream version scheme can be derived into a ports-compatible version scheme, set some variable to the upstream version, <emphasis>do not</emphasis> use <varname>DISTVERSION</varname> as the variable name. Set <varname>PORTVERSION</varname> to the computed version based on the variable you created, and set <varname>DISTNAME</varname> accordingly.</para> <para>If the upstream version scheme cannot easily be coerced into a ports-compatible value, set <varname>PORTVERSION</varname> to a sensible value, and set <varname>DISTNAME</varname> with <varname>PORTNAME</varname> with the verbatim upstream version.</para> <example xml:id="makefile-distname-ex1"> <title>Deriving <varname>PORTVERSION</varname> Manually</title> <para><application>BIND9</application> uses a version scheme that is not compatible with the ports versions (it has <literal>-</literal> in its versions) and cannot be derived using <varname>DISTVERSION</varname> because after the 9.9.9 release, it will release a <quote>patchlevels</quote> in the form of <literal>9.9.9-P1</literal>. DISTVERSION would translate that into <literal>9.9.9.p1</literal>, which, in the ports versioning scheme means 9.9.9 pre-release 1, which is before 9.9.9 and not after. So <varname>PORTVERSION</varname> is manually derived from an <varname>ISCVERSION</varname> variable to output <literal>9.9.9p1</literal>.</para> <para>The order into which the ports framework, and pkg, will sort versions is checked using the <literal>-t</literal> argument of &man.pkg-version.8;:</para> <screen>&prompt.user; <userinput>pkg version -t 9.9.9 9.9.9.p1</userinput> > <co xml:id="distversion-ex1-gt"/> &prompt.user; <userinput>pkg version -t 9.9.9 9.9.9p1</userinput> < <co xml:id="distversion-ex1-lt"/></screen> <calloutlist> <callout arearefs="distversion-ex1-gt"> <para>The <literal>></literal> sign means that the first argument passed to <literal>-t</literal> is greater than the second argument. <literal>9.9.9</literal> is after <literal>9.9.9.p1</literal>.</para> </callout> <callout arearefs="distversion-ex1-lt"> <para>The <literal><</literal> sign means that the first argument passed to <literal>-t</literal> is less than the second argument. <literal>9.9.9</literal> is before <literal>9.9.9p1</literal>.</para> </callout> </calloutlist> <para>In the port <filename>Makefile</filename>, for example <package role="port">dns/bind99</package>, it is achieved by:</para> <programlisting>PORTNAME= bind PORTVERSION= ${ISCVERSION:S/-P/P/:S/b/.b/:S/a/.a/:S/rc/.rc/} <co xml:id="distversion-ex1-portversion"/> CATEGORIES= dns net ipv6 MASTER_SITES= ISC/bind9/${ISCVERSION} <co xml:id="distversion-ex1-master_sites"/> PKGNAMESUFFIX= 99 DISTNAME= ${PORTNAME}-${ISCVERSION} <co xml:id="distversion-ex1-distname"/> MAINTAINER= mat@FreeBSD.org COMMENT= BIND DNS suite with updated DNSSEC and DNS64 LICENSE= ISCL # ISC releases things like 9.8.0-P1 or 9.8.1rc1, which our versioning does not like ISCVERSION= 9.9.9-P6 <co xml:id="distversion-ex1-iscversion"/></programlisting> <calloutlist> <callout arearefs="distversion-ex1-iscversion"> <para>Define upstream version in <varname>ISCVERSION</varname>, with a comment saying <emphasis>why</emphasis> it is needed.</para> </callout> <callout arearefs="distversion-ex1-portversion"> <para>Use <varname>ISCVERSION</varname> to get a ports-compatible <varname>PORTVERSION</varname>.</para> </callout> <callout arearefs="distversion-ex1-master_sites"> <para>Use <varname>ISCVERSION</varname> directly to get the correct <acronym>URL</acronym> for fetching the distribution file.</para> </callout> <callout arearefs="distversion-ex1-distname"> <para>Use <varname>ISCVERSION</varname> directly to name the distribution file.</para> </callout> </calloutlist> </example> <example xml:id="makefile-distname-ex2"> <title>Derive <varname>DISTNAME</varname> from <varname>PORTVERSION</varname></title> <para>From time to time, the distribution file name has little or no relation to the version of the software.</para> <para>In <package role="port">comms/kermit</package>, only the last element of the version is present in the distribution file:</para> <programlisting>PORTNAME= kermit PORTVERSION= 9.0.304 CATEGORIES= comms ftp net MASTER_SITES= ftp://ftp.kermitproject.org/kermit/test/tar/ DISTNAME= cku${PORTVERSION:E}-dev20 <co xml:id="distversion-ex2-distname"/></programlisting> <calloutlist> <callout arearefs="distversion-ex2-distname"> <para>The <literal>:E</literal> &man.make.1; modifier returns the suffix of the variable, in this case, <literal>304</literal>. The distribution file is correctly generated as <literal>cku304-dev20.tar.gz</literal>.</para> </callout> </calloutlist> </example> <example xml:id="makefile-distname-ex3"> <title>Exotic Case 1</title> <para>Sometimes, there is no relation between the software name, its version, and the distribution file it is distributed in.</para> <para>From <package role="port">audio/libworkman</package>:</para> <programlisting>PORTNAME= libworkman PORTVERSION= 1.4 CATEGORIES= audio MASTER_SITES= LOCAL/jim DISTNAME= ${PORTNAME}-1999-06-20</programlisting> </example> <example xml:id="makefile-distname-ex4"> <title>Exotic Case 2</title> <para>In <package role="port">comms/librs232</package>, the distribution file is not versioned, so using <link linkend="makefile-dist_subdir"><varname>DIST_SUBDIR</varname></link> is needed:</para> <programlisting>PORTNAME= librs232 PORTVERSION= 20160710 CATEGORIES= comms MASTER_SITES= http://www.teuniz.net/RS-232/ DISTNAME= RS-232 DIST_SUBDIR= ${PORTNAME}-${PORTVERSION}</programlisting> </example> <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.</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> <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>SOURCEFORGE</literal>), GNU (<literal>GNU</literal>), or Perl CPAN (<literal>PERL_CPAN</literal>). <varname>MASTER_SITES</varname> can use them directly:</para> <programlisting>MASTER_SITES= GNU/make</programlisting> <para>The older expanded format still works, but all ports have been 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 <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> <note> <para>Some <varname>MASTER_SITE_<replaceable>*</replaceable></varname> names are quite long, and for ease of use, shortcuts have been defined:</para> <table frame="none" xml:id="makefile-master_sites-shortcut"> <title>Shortcuts for <varname>MASTER_SITE_<replaceable>*</replaceable></varname> Macros</title> <tgroup cols="2"> <thead> <row> <entry>Macro</entry> <entry>Shortcut</entry> </row> </thead> <tbody> <row> <entry><varname>PERL_CPAN</varname></entry> <entry><varname>CPAN</varname></entry> </row> <row> <entry><varname>GITHUB</varname></entry> <entry><varname>GH</varname></entry> </row> <row> <entry><varname>GITHUB_CLOUD</varname></entry> <entry><varname>GHC</varname></entry> </row> <row> <entry><varname>LIBREOFFICE_DEV</varname></entry> <entry><varname>LODEV</varname></entry> </row> <row> <entry><varname>NETLIB</varname></entry> <entry><varname>NL</varname></entry> </row> <row> <entry><varname>RUBYGEMS</varname></entry> <entry><varname>RG</varname></entry> </row> <row> <entry><varname>SOURCEFORGE</varname></entry> <entry><varname>SF</varname></entry> </row> </tbody> </tgroup> </table> </note> </sect3> <sect3 xml:id="makefile-master_sites-magic"> <title>Magic MASTER_SITES Macros</title> <para>Several <quote>magic</quote> macros exist for popular sites with a predictable directory structure. For these, just use the abbreviation and the system will choose a 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>infers a subdirectory named <literal>/project/stardict/stardict/1.2.3</literal>. If the inferred directory is incorrect, it can be overridden:</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>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_COMMONS_BINARIES</varname></entry> <entry><literal>${PORTNAME:S,commons-,,}</literal></entry> </row> <row> <entry><varname>APACHE_COMMONS_SOURCE</varname></entry> <entry><literal>${PORTNAME:S,commons-,,}</literal></entry> </row> <row> <entry><varname>APACHE_JAKARTA</varname></entry> <entry><literal>${PORTNAME:S,-,/,}/source</literal></entry> </row> <row> <entry><varname>BERLIOS</varname></entry> <entry><literal>${PORTNAME:tl}.berlios</literal></entry> </row> <row> <entry><varname>CHEESESHOP</varname></entry> <entry><literal>source/${DISTNAME:C/(.).*/\1/}/${DISTNAME:C/(.*)-[0-9].*/\1/}</literal></entry> </row> <row> <entry><varname>CPAN</varname></entry> <entry><literal>${PORTNAME:C/-.*//}</literal></entry> </row> <row> <entry><varname>DEBIAN</varname></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>FESTIVAL</varname></entry> <entry><literal>${PORTREVISION}</literal></entry> </row> <row> <entry><varname>GCC</varname></entry> <entry><literal>releases/${DISTNAME}</literal></entry> </row> <row> <entry><varname>GENTOO</varname></entry> <entry><literal>distfiles</literal></entry> </row> <row> <entry><varname>GIMP</varname></entry> <entry><literal>${PORTNAME}/${PORTVERSION:R}/</literal></entry> </row> <row> <entry><varname>GH</varname></entry> <entry><literal>${GH_ACCOUNT}/${GH_PROJECT}/tar.gz/${GH_TAGNAME}?dummy=/</literal></entry> </row> <row> <entry><varname>GHC</varname></entry> <entry><literal>${GH_ACCOUNT}/${GH_PROJECT}/</literal></entry> </row> <row> <entry><varname>GNOME</varname></entry> <entry><literal>sources/${PORTNAME}/${PORTVERSION:C/^([0-9]+\.[0-9]+).*/\1/}</literal></entry> </row> <row> <entry><varname>GNU</varname></entry> <entry><literal>${PORTNAME}</literal></entry> </row> <row> <entry><varname>GNUPG</varname></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>${PORTNAME}</literal></entry> </row> <row> <entry><varname>LODEV</varname></entry> <entry><literal>${PORTNAME}</literal></entry> </row> <row> <entry><varname>MATE</varname></entry> <entry><literal>${PORTVERSION:C/^([0-9]+\.[0-9]+).*/\1/}</literal></entry> </row> <row> <entry><varname>MOZDEV</varname></entry> <entry><literal>${PORTNAME:tl}</literal></entry> </row> <row> <entry><varname>NL</varname></entry> <entry><literal>${PORTNAME}</literal></entry> </row> <row> <entry><varname>QT</varname></entry> <entry><literal>archive/qt/${PORTVERSION:R}</literal></entry> </row> <row> <entry><varname>SAMBA</varname></entry> <entry><literal>${PORTNAME}</literal></entry> </row> <row> <entry><varname>SAVANNAH</varname></entry> <entry><literal>${PORTNAME:tl}</literal></entry> </row> <row> <entry><varname>SF</varname></entry> <entry><literal>${PORTNAME:tl}/${PORTNAME:tl}/${PORTVERSION}</literal></entry> </row> </tbody> </tgroup> </table> </sect3> </sect2> <sect2 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> <row> <entry><varname>GH_SUBDIR</varname></entry> <entry>When the software needs an additional distribution file to be extracted within <varname>${WRKSRC}</varname>, this variable can be used. See the examples in <xref linkend="makefile-master_sites-github-multiple"/> for more information.</entry> <entry>(none)</entry> </row> <row> <entry><varname>GH_TUPLE</varname></entry> <entry><varname>GH_TUPLE</varname> allows putting <varname>GH_ACCOUNT</varname>, <varname>GH_PROJECT</varname>, <varname>GH_TAGNAME</varname>, and <varname>GH_SUBDIR</varname> into a single variable. The format is <replaceable>account</replaceable><literal>:</literal><replaceable>project</replaceable><literal>:</literal><replaceable>tagname</replaceable><literal>:</literal><replaceable>group</replaceable><literal>/</literal><replaceable>subdir</replaceable>. The <literal>/</literal><replaceable>subdir</replaceable> part is optional. It is helpful when there is more than one GitHub project from which to fetch.</entry> </row> </tbody> </tgroup> </table> <important> <para>Do not use <varname>GH_TUPLE</varname> for the default distribution file, as it has no default.</para> </important> <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 DISTVERSION= 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> ends up looking like this (slightly stripped for the example):</para> <programlisting>PORTNAME= pkg-devel DISTVERSION= 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> <tip> <para><literal>20140411</literal> is the date of the commit referenced in <varname>GH_TAGNAME</varname>, not the date the <filename>Makefile</filename> is edited, or the date the commit is made.</para> </tip> </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>DISTVERSION</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 DISTVERSIONPREFIX= v DISTVERSION= 1.0.2 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> <example xml:id="makefile-master_sites-github-ex4"> <title>Using <varname>USE_GITHUB</varname> When Upstream Does Not Use Versions</title> <para>If there never was a version upstream, do not invent one like <literal>0.1</literal> or <literal>1.0</literal>. Create the port with a <varname>DISTVERSION</varname> of <literal>g<replaceable>YYYY</replaceable><replaceable>MM</replaceable><replaceable>DD</replaceable></literal>, where <literal>g</literal> is for <application>Git</application>, and <literal><replaceable>YYYY</replaceable><replaceable>MM</replaceable><replaceable>DD</replaceable></literal> represents the date the commit referenced in <varname>GH_TAGNAME</varname>.</para> <programlisting>PORTNAME= bar DISTVERSION= g20140411 USE_GITHUB= yes GH_TAGNAME= c472d66b</programlisting> <para>This creates a versioning scheme that increases over time, and that is still before version <literal>0</literal> (see <xref linkend="makefile-versions-ex-pkg-version"/> for details on &man.pkg-version.8;):</para> <screen>&prompt.user; <userinput>pkg version -t g20140411 0</userinput> <</screen> <para>Which means using <varname>PORTEPOCH</varname> will not be needed in case upstream decides to cut versions in the future.</para> </example> <example xml:id="makefile-master_sites-github-ex5"> <title>Using <varname>USE_GITHUB</varname> to Access a Commit Between Two Versions</title> <para>If the current version of the software uses a <application>Git</application> tag, and the port needs to be updated to a newer, intermediate version, without a tag, use &man.git-describe.1; to find out the version to use:</para> <screen>&prompt.user; <userinput>git describe --tags <replaceable>f0038b1</replaceable></userinput> v0.7.3-14-gf0038b1</screen> <para><literal>v0.7.3-14-gf0038b1</literal> can be split into three parts:</para> <variablelist> <varlistentry> <term><literal>v0.7.3</literal></term> <listitem> <para>This is the last <application>Git</application> tag that appears in the commit history before the requested commit.</para> </listitem> </varlistentry> <varlistentry> <term><literal>-14</literal></term> <listitem> <para>This means that the requested commit, <literal>f0038b1</literal>, is the 14th commit after the <literal>v0.7.3</literal> tag.</para> </listitem> </varlistentry> <varlistentry> <term><literal>-gf0038b1</literal></term> <listitem> <para>The <literal>-g</literal> means <quote><application>Git</application></quote>, and the <literal>f0038b1</literal> is the commit hash that this reference points to.</para> </listitem> </varlistentry> </variablelist> <programlisting>PORTNAME= bar DISTVERSIONPREFIX= v DISTVERSION= 0.7.3-14 DISTVERSIONSUFFIX= -gf0038b1 USE_GITHUB= yes</programlisting> <para>This creates a versioning scheme that increases over time (well, over commits), and does not conflict with the creation of a <literal>0.7.4</literal> version. (See <xref linkend="makefile-versions-ex-pkg-version"/> for details on &man.pkg-version.8;):</para> <screen>&prompt.user; <userinput>pkg version -t 0.7.3 0.7.3.14</userinput> < &prompt.user; <userinput>pkg version -t 0.7.3.14 0.7.4</userinput> <</screen> <note> <para>If the requested commit is the same as a tag, a shorter description is shown by default. The longer version is equivalent:</para> <screen>&prompt.user; <userinput>git describe --tags <replaceable>c66c71d</replaceable></userinput> v0.7.3 &prompt.user; <userinput>git describe --tags --long <replaceable>c66c71d</replaceable></userinput> v0.7.3-0-gc66c71d</screen> </note> </example> <sect3 xml:id="makefile-master_sites-github-multiple"> <title>Fetching Multiple Files from GitHub</title> <para>The <varname>USE_GITHUB</varname> framework also supports fetching multiple distribution files from different places in GitHub. It works in a way very similar to <xref linkend="porting-master-sites-n"/>.</para> <para>When fetching multiple files from GitHub, sometimes the default distribution file is not fetched from GitHub. To disable fetching the default distribution, set:</para> <programlisting>USE_GITHUB= nodefault</programlisting> <para>Multiple values are added to <varname>GH_ACCOUNT</varname>, <varname>GH_PROJECT</varname>, and <varname>GH_TAGNAME</varname>. Each different value is assigned a group. The main value can either have no group, or the <literal>:DEFAULT</literal> group. A value can be omitted if it is the same as the default as listed in <xref linkend="makefile-master_sites-github-description"/>.</para> <para><varname>GH_TUPLE</varname> can also be used when there are a lot of distribution files. It helps keep the account, project, tagname, and group information at the same place.</para> <para>For each group, a <varname>${WRKSRC_<replaceable>group</replaceable>}</varname> helper variable is created, containing the directory into which the file has been extracted. The <varname>${WRKSRC_<replaceable>group</replaceable>}</varname> variables can be used to move directories around during <buildtarget>post-extract</buildtarget>, or add to <varname>CONFIGURE_ARGS</varname>, or whatever is needed so that the software builds correctly.</para> <caution> <para>The <literal>:<replaceable>group</replaceable></literal> part <emphasis>must</emphasis> be used for <emphasis>only one</emphasis> distribution file. It is used as a unique key and using it more than once will overwrite the previous values.</para> </caution> <note> <para>As this is only syntastic sugar above <varname>DISTFILES</varname> and <varname>MASTER_SITES</varname>, the group names must adhere to the restrictions on group names outlined in <xref linkend="porting-master-sites-n"/></para> </note> <example xml:id="makefile-master_sites-github-multi"> <title>Use of <varname>USE_GITHUB</varname> with Multiple Distribution Files</title> <para>From time to time, there is a need to fetch more than one distribution file. For example, when the upstream git repository uses submodules. This can be done easily using groups in the <varname>GH_<replaceable>*</replaceable></varname> variables:</para> <programlisting>PORTNAME= foo DISTVERSION= 1.0.2 USE_GITHUB= yes GH_ACCOUNT= bar:icons,contrib GH_PROJECT= foo-icons:icons foo-contrib:contrib GH_TAGNAME= 1.0:icons fa579bc:contrib GH_SUBDIR= ext/icons:icons CONFIGURE_ARGS= --with-contrib=${WRKSRC_contrib}</programlisting> <para>This will fetch three distribution files from github. The default one comes from <filename>foo/foo</filename> and is version <literal>1.0.2</literal>. The second one, with the <literal>icons</literal> group, comes from <filename>bar/foo-icons</filename> and is in version <literal>1.0</literal>. The third one comes from <filename>bar/foo-contrib</filename> and uses the <application>Git</application> commit <literal>fa579bc</literal>. The distribution files are named <filename>foo-foo-1.0.2_GH0.tar.gz</filename>, <filename>bar-foo-icons-1.0_GH0.tar.gz</filename>, and <filename>bar-foo-contrib-fa579bc_GH0.tar.gz</filename>.</para> <para>All the distribution files are extracted in <varname>${WRKDIR}</varname> in their respective subdirectories. The default file is still extracted in <varname>${WRKSRC}</varname>, in this case, <filename>${WRKDIR}/foo-1.0.2</filename>. Each additional distribution file is extracted in <varname>${WRKSRC_<replaceable>group</replaceable>}</varname>. Here, for the <literal>icons</literal> group, it is called <varname>${WRKSRC_icons}</varname> and it contains <filename>${WRKDIR}/foo-icons-1.0</filename>. The file with the <literal>contrib</literal> group is called <varname>${WRKSRC_contrib}</varname> and contains <literal>${WRKDIR}/foo-contrib-fa579bc</literal>.</para> <para>The software's build system expects to find the icons in a <filename>ext/icons</filename> subdirectory in its sources, so <varname>GH_SUBDIR</varname> is used. <varname>GH_SUBDIR</varname> makes sure that <filename>ext</filename> exists, but that <filename>ext/icons</filename> does not already exist. Then it does this:</para> <programlisting>post-extract: @${MV} ${WRKSRC_icons} ${WRKSRC}/ext/icons</programlisting> </example> <example xml:id="makefile-master_sites-github-multi2"> <title>Use of <varname>USE_GITHUB</varname> with Multiple Distribution Files Using <varname>GH_TUPLE</varname></title> <para>This is functionally equivalent to <xref linkend="makefile-master_sites-github-multi"/>, but using <varname>GH_TUPLE</varname>:</para> <programlisting>PORTNAME= foo DISTVERSION= 1.0.2 USE_GITHUB= yes GH_TUPLE= bar:foo-icons:1.0:icons/ext/icons \ bar:foo-contrib:fa579bc:contrib CONFIGURE_ARGS= --with-contrib=${WRKSRC_contrib}</programlisting> <para>Grouping was used in the previous example with <literal>bar:icons,contrib</literal>. Some redundant information is present with <varname>GH_TUPLE</varname> because grouping is not possible.</para> </example> <example xml:id="makefile-master_sites-github-submodules"> <title>How to Use <varname>USE_GITHUB</varname> with <application>Git</application> Submodules?</title> <para>Ports with GitHub as an upstream repository sometimes use submodules. See &man.git-submodule.1; for more information.</para> <para>The problem with submodules is that each is a separate repository. As such, they each must be fetched separately.</para> <para>Using <package role="port">finance/moneymanagerex</package> as an example, its GitHub repository is <link xlink:href="https://github.com/moneymanagerex/moneymanagerex"/>. It has a <link xlink:href="https://github.com/moneymanagerex/moneymanagerex/blob/master/.gitmodules"><filename>.gitmodules</filename></link> file at the root. This file describes all the submodules used in this repository, and lists additional repositories needed. This file will tell what additional repositories are needed:</para> <programlisting>[submodule "lib/wxsqlite3"] path = lib/wxsqlite3 url = https://github.com/utelle/wxsqlite3.git [submodule "3rd/mongoose"] path = 3rd/mongoose url = https://github.com/cesanta/mongoose.git [submodule "3rd/LuaGlue"] path = 3rd/LuaGlue url = https://github.com/moneymanagerex/LuaGlue.git [submodule "3rd/cgitemplate"] path = 3rd/cgitemplate url = https://github.com/moneymanagerex/html-template.git [...]</programlisting> <para>The only information missing from that file is the commit hash or tag to use as a version. This information is found after cloning the repository:</para> <screen>&prompt.user; <userinput>git clone --recurse-submodules https://github.com/moneymanagerex/moneymanagerex.git</userinput> Cloning into 'moneymanagerex'... remote: Counting objects: 32387, done. [...] Submodule '3rd/LuaGlue' (https://github.com/moneymanagerex/LuaGlue.git) registered for path '3rd/LuaGlue' Submodule '3rd/cgitemplate' (https://github.com/moneymanagerex/html-template.git) registered for path '3rd/cgitemplate' Submodule '3rd/mongoose' (https://github.com/cesanta/mongoose.git) registered for path '3rd/mongoose' Submodule 'lib/wxsqlite3' (https://github.com/utelle/wxsqlite3.git) registered for path 'lib/wxsqlite3' [...] Cloning into '/home/mat/work/freebsd/ports/finance/moneymanagerex/moneymanagerex/3rd/LuaGlue'... Cloning into '/home/mat/work/freebsd/ports/finance/moneymanagerex/moneymanagerex/3rd/cgitemplate'... Cloning into '/home/mat/work/freebsd/ports/finance/moneymanagerex/moneymanagerex/3rd/mongoose'... Cloning into '/home/mat/work/freebsd/ports/finance/moneymanagerex/moneymanagerex/lib/wxsqlite3'... [...] Submodule path '3rd/LuaGlue': checked out 'c51d11a247ee4d1e9817dfa2a8da8d9e2f97ae3b' Submodule path '3rd/cgitemplate': checked out 'cd434eeeb35904ebcd3d718ba29c281a649b192c' Submodule path '3rd/mongoose': checked out '2140e5992ab9a3a9a34ce9a281abf57f00f95cda' Submodule path 'lib/wxsqlite3': checked out 'fb66eb230d8aed21dec273b38c7c054dcb7d6b51' [...] &prompt.user; <userinput>cd moneymanagerex</userinput> &prompt.user; <userinput>git submodule status</userinput> c51d11a247ee4d1e9817dfa2a8da8d9e2f97ae3b 3rd/LuaGlue (heads/master) cd434eeeb35904ebcd3d718ba29c281a649b192c 3rd/cgitemplate (cd434ee) 2140e5992ab9a3a9a34ce9a281abf57f00f95cda 3rd/mongoose (6.2-138-g2140e59) fb66eb230d8aed21dec273b38c7c054dcb7d6b51 lib/wxsqlite3 (v3.4.0) [...]</screen> <para>It can also be found on GitHub. Each subdirectory that is a submodule is shown as <replaceable>directory</replaceable><literal> @ </literal><replaceable>hash</replaceable>, for example, <literal>mongoose @ 2140e59</literal>.</para> <note> <para>While getting the information from GitHub seems more straightforward, the information found using <command>git submodule status</command> will provide more meaningful information. For example, here, <literal>lib/wxsqlite3</literal>'s commit hash <literal>fb66eb2</literal> correspond to <literal>v3.4.0</literal>. Both can be used interchangeably, but when a tag is available, use it.</para> </note> <para>Now that all the required information has been gathered, the <filename>Makefile</filename> can be written (only GitHub-related lines are shown):</para> <programlisting>PORTNAME= moneymanagerex DISTVERSIONPREFIX= v DISTVERSION= 1.3.0 USE_GITHUB= yes GH_TUPLE= utelle:wxsqlite3:v3.4.0:wxsqlite3/lib/wxsqlite3 \ moneymanagerex:LuaGlue:c51d11a:lua_glue/3rd/LuaGlue \ moneymanagerex:html-template:cd434ee:html_template/3rd/cgitemplate \ cesanta:mongoose:2140e59:mongoose/3rd/mongoose \ [...]</programlisting> </example> </sect3> </sect2> <sect2 xml:id="makefile-master_sites-gitlab"> <title><varname>USE_GITLAB</varname></title> <para>Similar to GitHub, if the distribution file comes from <link xlink:href="https://gitlab.com">gitlab.com</link> or is hosting the <application>GitLab</application> software, these variables are available for use and might need to be set.</para> <table xml:id="makefile-master_sites-gitlab-description"> <title><varname>USE_GITLAB</varname> Description</title> <tgroup cols="3"> <thead> <row> <entry>Variable</entry> <entry>Description</entry> <entry>Default</entry> </row> </thead> <tbody> <row> <entry><varname>GL_SITE</varname></entry> <entry>Site name hosting the <application>GitLab</application> project</entry> <entry>https://gitlab.com</entry> </row> <row> <entry><varname>GL_ACCOUNT</varname></entry> <entry>Account name of the <application>GitLab</application> user hosting the project</entry> <entry><literal>${PORTNAME}</literal></entry> </row> <row> <entry><varname>GL_PROJECT</varname></entry> <entry>Name of the project on <application>GitLab</application></entry> <entry><literal>${PORTNAME}</literal></entry> </row> <row> <entry><varname>GL_COMMIT</varname></entry> <entry>The commit hash to download. Must be the full 160 bit, 40 character hex sha1 hash. This is a required variable for <application>GitLab</application>.</entry> <entry><literal>(none)</literal></entry> </row> <row> <entry><varname>GL_SUBDIR</varname></entry> <entry>When the software needs an additional distribution file to be extracted within <varname>${WRKSRC}</varname>, this variable can be used. See the examples in <xref linkend="makefile-master_sites-gitlab-multiple"/> for more information.</entry> <entry>(none)</entry> </row> <row> <entry><varname>GL_TUPLE</varname></entry> <entry><varname>GL_TUPLE</varname> allows putting <varname>GL_SITE</varname>, <varname>GL_ACCOUNT</varname>, <varname>GL_PROJECT</varname>, <varname>GL_COMMIT</varname>, and <varname>GL_SUBDIR</varname> into a single variable. The format is <replaceable>site</replaceable><literal>:</literal><replaceable>account</replaceable><literal>:</literal><replaceable>project</replaceable><literal>:</literal><replaceable>commit</replaceable><literal>:</literal><replaceable>group</replaceable><literal>/</literal><replaceable>subdir</replaceable>. The <replaceable>site</replaceable><literal>:</literal> and <literal>/</literal><replaceable>subdir</replaceable> part is optional. It is helpful when there are more than one <application>GitLab</application> project from which to fetch.</entry> </row> </tbody> </tgroup> </table> <example xml:id="makefile-master_sites-gitlab-ex1"> <title>Simple Use of <varname>USE_GITLAB</varname></title> <para>While trying to make a port for version <literal>1.14</literal> of <application>libsignon-glib</application> from the accounts-sso user on gitlab.com, at <link xlink:href="https://gitlab.com/accounts-sso/libsignon-glib"/>, The <filename>Makefile</filename> would end up looking like this for fetching the distribution files:</para> <programlisting>PORTNAME= libsignon-glib DISTVERSION= 1.14 USE_GITLAB= yes GL_ACCOUNT= accounts-sso GL_COMMIT= e90302e342bfd27bc8c9132ab9d0ea3d8723fd03</programlisting> <para>It will automatically have <varname>MASTER_SITES</varname> set to <link xlink:href="https://gitlab.com">gitlab.com</link> and <varname>WRKSRC</varname> to <literal>${WRKDIR}/libsignon-glib-e90302e342bfd27bc8c9132ab9d0ea3d8723fd03-e90302e342bfd27bc8c9132ab9d0ea3d8723fd03</literal>.</para> </example> <example xml:id="makefile-master_sites-gitlab-ex2"> <title>More Complete Use of <varname>USE_GITLAB</varname></title> <para>A more complete use of the above if port had no versioning and <application>foobar</application> from the foo user on project bar on a self hosted <application>GitLab</application> site <literal>https://gitlab.example.com</literal>, the <filename>Makefile</filename> ends up looking like this for fetching distribution files:</para> <programlisting>PORTNAME= foobar DISTVERSION= g20170906 USE_GITLAB= yes GL_SITE= https://gitlab.example.com GL_ACCOUNT= foo GL_PROJECT= bar GL_COMMIT= 9c1669ce60c3f4f5eb43df874d7314483fb3f8a6</programlisting> <para>It will have <varname>MASTER_SITES</varname> set to "<literal>https://gitlab.example.com</literal>" and <varname>WRKSRC</varname> to <literal>${WRKDIR}/bar-9c1669ce60c3f4f5eb43df874d7314483fb3f8a6-9c1669ce60c3f4f5eb43df874d7314483fb3f8a6</literal>.</para> <tip> <para><literal>20170906</literal> is the date of the commit referenced in <varname>GL_COMMIT</varname>, not the date the <filename>Makefile</filename> is edited, or the date the commit to the &os; ports tree is made.</para> </tip> <note> <para><varname>GL_SITE</varname>'s protocol, port and webroot can all be modified in the same variable.</para> </note> </example> <sect3 xml:id="makefile-master_sites-gitlab-multiple"> <title>Fetching Multiple Files from <application>GitLab</application></title> <para>The <varname>USE_GITLAB</varname> framework also supports fetching multiple distribution files from different places from <application>GitLab</application> and <application>GitLab</application> hosted sites. It works in a way very similar to <xref linkend="porting-master-sites-n"/> and xref linkend="makefile-master_sites-gitlab-multiple".</para> <para>When fetching multiple files using <application>GitLab</application>, sometimes the default distribution file is not fetched from a <application>GitLab</application> site. To disable fetching the default distribution, set:</para> <programlisting>USE_GITLAB= nodefault</programlisting> <para>Multiple values are added to <varname>GL_SITE</varname>, <varname>GL_ACCOUNT</varname>, <varname>GL_PROJECT</varname> and <varname>GL_COMMIT</varname>. Each different value is assigned a group. <xref linkend="makefile-master_sites-gitlab-description"/>.</para> <para><varname>GL_TUPLE</varname> can also be used when there are a lot of distribution files. It helps keep the site, account, project, commit, and group information at the same place.</para> <para>For each group, a <varname>${WRKSRC_<replaceable>group</replaceable>}</varname> helper variable is created, containing the directory into which the file has been extracted. The <varname>${WRKSRC_<replaceable>group</replaceable>}</varname> variables can be used to move directories around during <buildtarget>post-extract</buildtarget>, or add to <varname>CONFIGURE_ARGS</varname>, or whatever is needed so that the software builds correctly.</para> <caution> <para>The <literal>:<replaceable>group</replaceable></literal> part <emphasis>must</emphasis> be used for <emphasis>only one</emphasis> distribution file. It is used as a unique key and using it more than once will overwrite the previous values.</para> </caution> <note> <para>As this is only syntastic sugar above <varname>DISTFILES</varname> and <varname>MASTER_SITES</varname>, the group names must adhere to the restrictions on group names outlined in <xref linkend="porting-master-sites-n"/></para> </note> <example xml:id="makefile-master_sites-gitlab-multi"> <title>Use of <varname>USE_GITLAB</varname> with Multiple Distribution Files</title> <para>From time to time, there is a need to fetch more than one distribution file. For example, when the upstream git repository uses submodules. This can be done easily using groups in the <varname>GL_<replaceable>*</replaceable></varname> variables:</para> <programlisting>PORTNAME= foo DISTVERSION= 1.0.2 USE_GITLAB= yes GL_SITE= https://gitlab.example.com:9434/gitlab:icons GL_ACCOUNT= bar:icons,contrib GL_PROJECT= foo-icons:icons foo-contrib:contrib GL_COMMIT= c189207a55da45305c884fe2b50e086fcad4724b ae7368cab1ca7ca754b38d49da064df87968ffe4:icons 9e4dd76ad9b38f33fdb417a4c01935958d5acd2a:contrib GL_SUBDIR= ext/icons:icons CONFIGURE_ARGS= --with-contrib=${WRKSRC_contrib}</programlisting> <para>This will fetch two distribution files from gitlab.com and one from <literal>gitlab.example.com</literal> hosting <application>GitLab</application>. The default one comes from <filename>https://gitlab.com/foo/foo</filename> and commit is <literal>c189207a55da45305c884fe2b50e086fcad4724b</literal>. The second one, with the <literal>icons</literal> group, comes from <filename>https://gitlab.example.com:9434/gitlab/bar/foo-icons</filename> and commit is <literal>ae7368cab1ca7ca754b38d49da064df87968ffe4</literal>. The third one comes from <filename>https://gitlab.com/bar/foo-contrib</filename> and is commit <literal>9e4dd76ad9b38f33fdb417a4c01935958d5acd2a</literal>. The distribution files are named <filename>foo-foo-c189207a55da45305c884fe2b50e086fcad4724b_GL0.tar.gz</filename>, <filename>bar-foo-icons-ae7368cab1ca7ca754b38d49da064df87968ffe4_GL0.tar.gz</filename>, and <filename>bar-foo-contrib-9e4dd76ad9b38f33fdb417a4c01935958d5acd2a_GL0.tar.gz</filename>.</para> <para>All the distribution files are extracted in <varname>${WRKDIR}</varname> in their respective subdirectories. The default file is still extracted in <varname>${WRKSRC}</varname>, in this case, <filename>${WRKDIR}/foo-c189207a55da45305c884fe2b50e086fcad4724b-c189207a55da45305c884fe2b50e086fcad4724b</filename>. Each additional distribution file is extracted in <varname>${WRKSRC_<replaceable>group</replaceable>}</varname>. Here, for the <literal>icons</literal> group, it is called <varname>${WRKSRC_icons}</varname> and it contains <filename>${WRKDIR}/foo-icons-ae7368cab1ca7ca754b38d49da064df87968ffe4-ae7368cab1ca7ca754b38d49da064df87968ffe4</filename>. The file with the <literal>contrib</literal> group is called <varname>${WRKSRC_contrib}</varname> and contains <literal>${WRKDIR}/foo-contrib-9e4dd76ad9b38f33fdb417a4c01935958d5acd2a-9e4dd76ad9b38f33fdb417a4c01935958d5acd2a</literal>.</para> <para>The software's build system expects to find the icons in a <filename>ext/icons</filename> subdirectory in its sources, so <varname>GL_SUBDIR</varname> is used. <varname>GL_SUBDIR</varname> makes sure that <filename>ext</filename> exists, but that <filename>ext/icons</filename> does not already exist. Then it does this:</para> <programlisting>post-extract: @${MV} ${WRKSRC_icons} ${WRKSRC}/ext/icons</programlisting> </example> <example xml:id="makefile-master_sites-gitlab-multi2"> <title>Use of <varname>USE_GITLAB</varname> with Multiple Distribution Files Using <varname>GL_TUPLE</varname></title> <para>This is functionally equivalent to <xref linkend="makefile-master_sites-gitlab-multi"/>, but using <varname>GL_TUPLE</varname>:</para> <programlisting>PORTNAME= foo DISTVERSION= 1.0.2 USE_GITLAB= yes GL_COMMIT= c189207a55da45305c884fe2b50e086fcad4724b GL_TUPLE= https://gitlab.example.com:9434/gitlab:bar:foo-icons:ae7368cab1ca7ca754b38d49da064df87968ffe4:icons/ext/icons \ bar:foo-contrib:9e4dd76ad9b38f33fdb417a4c01935958d5acd2a:contrib CONFIGURE_ARGS= --with-contrib=${WRKSRC_contrib}</programlisting> <para>Grouping was used in the previous example with <literal>bar:icons,contrib</literal>. Some redundant information is present with <varname>GL_TUPLE</varname> because grouping is not possible.</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"/> 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 compressed 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 compressed 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 or Patches Files from Multiple Locations</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 any word containing <literal>[0-9a-zA-Z_]</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> <important> <para>The group names cannot have dashes in them (<literal>-</literal>), in fact, they cannot have any characters out of the <literal>[a-zA-Z0-9_]</literal> range. This is because, while &man.make.1; is ok with variable names containing dashes, &man.sh.1; is not.</para> </important> <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>group name</quote>. Each site listed in <varname>MASTER_SITES</varname> is then followed by a colon, and the group 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 group. 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 macros from <filename>bsd.sites.mk</filename>, for example, SourceForge (<literal>SF</literal>)?</para> <para>This has been simplified as much as possible. 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 SourceForge (<literal>SF</literal>)</title> <programlisting>MASTER_SITES= http://site1/ SF/something/1.0:sourceforge,TEST DISTFILES= something.tar.gz:sourceforge</programlisting> <para><filename>something.tar.gz</filename> will be fetched from all sites within SourceForge.</para> </example> </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 <link xlink:href="http://distcache.FreeBSD.org">http://distcache.FreeBSD.org</link> (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> </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-contributing.html#maintain-port">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 timeout, and the update can 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 + leave, and all of their ports can be assigned back to the pool. + 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>The comment is a one-line description of a port shown by <command>pkg info</command>. Please follow these rules when composing it:</para> <orderedlist> <listitem> <para>The COMMENT string should be 70 characters or less.</para> </listitem> <listitem> <para>Do <emphasis>not</emphasis> include the package name or version number of 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>Capitalize names such as Apache, JavaScript, or Perl.</para> </listitem> <listitem> <para>Use a serial comma for lists of words: "green, red<emphasis>,</emphasis> and blue."</para> </listitem> <listitem> <para>Check for spelling errors.</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="licenses"> <title>Licenses</title> <para>Each port must document the license under which it is available. If it is not an OSI approved license it must also document any restrictions on redistribution.</para> <sect2 xml:id="licenses-license"> <title><varname>LICENSE</varname></title> <para>A short name for the license or licenses if more than one license apply.</para> <para>If it is one of the licenses listed in <xref linkend="licenses-license-list"/>, only <varname>LICENSE_FILE</varname> and <varname>LICENSE_DISTFILES</varname> variables can be set.</para> <para>If this is a license that has not been defined in the ports framework (see <xref linkend="licenses-license-list"/>), the <varname>LICENSE_PERMS</varname> and <varname>LICENSE_NAME</varname> must be set, along with either <varname>LICENSE_FILE</varname> or <varname>LICENSE_TEXT</varname>. <varname>LICENSE_DISTFILES</varname> and <varname>LICENSE_GROUPS</varname> can also be set, but are not required.</para> <para>The predefined licenses are shown in <xref linkend="licenses-license-list"/>. The current list is always available in <filename>Mk/bsd.licenses.db.mk</filename>.</para> <example xml:id="licenses-license-ex1"> <title>Simplest Usage, Predefined Licenses</title> <para>When the <filename>README</filename> of some software says <quote>This software is under the terms of the GNU Lesser General Public License as published by the Free Software Foundation; either version 2.1 of the License, or (at your option) any later version.</quote> but does not provide the license file, use this:</para> <programlisting>LICENSE= LGPL21+</programlisting> <para>When the software provides the license file, use this:</para> <programlisting>LICENSE= LGPL21+ LICENSE_FILE= ${WRKSRC}/COPYING</programlisting> </example> <para>For the predefined licenses, the default permissions are <literal>dist-mirror dist-sell pkg-mirror pkg-sell auto-accept</literal>.</para> <table frame="none" xml:id="licenses-license-list"> <title>Predefined License List</title> <tgroup cols="4"> <thead> <row> <entry>Short Name</entry> <entry>Name</entry> <entry>Group</entry> <entry>Permissions</entry> </row> </thead> <!-- from any port, run for i in $(make -V _LICENSE_LIST:O) do echo "<row xml:id=\"licenses-license-${i/+/_}\">" echo "<entry><literal>$i</literal></entry>" echo "<entry>$(make -V _LICENSE_NAME_$i)</entry>" echo "<entry>$(make -V '${_LICENSE_GROUPS_'$i':@p@<literal>${p}</literal>@}')</entry>" if [ "$(make -V _LICENSE_PERMS_DEFAULT)" = "$(make -V _LICENSE_PERMS_$i)" ] then echo "<entry>(default)</entry>" else echo "<entry>$(make -V '${_LICENSE_PERMS_'$i':@p@<literal>${p}</literal>@}')</entry>" fi echo "</row>" echo done --> <tbody> <row xml:id="licenses-license-AGPLv3"> <entry><literal>AGPLv3</literal></entry> <entry>GNU Affero General Public License version 3</entry> <entry><literal>FSF</literal> <literal>GPL</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-AGPLv3_"> <entry><literal>AGPLv3+</literal></entry> <entry>GNU Affero General Public License version 3 (or later)</entry> <entry><literal>FSF</literal> <literal>GPL</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-APACHE10"> <entry><literal>APACHE10</literal></entry> <entry>Apache License 1.0</entry> <entry><literal>FSF</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-APACHE11"> <entry><literal>APACHE11</literal></entry> <entry>Apache License 1.1</entry> <entry><literal>FSF</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-APACHE20"> <entry><literal>APACHE20</literal></entry> <entry>Apache License 2.0</entry> <entry><literal>FSF</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-ART10"> <entry><literal>ART10</literal></entry> <entry>Artistic License version 1.0</entry> <entry><literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-ART20"> <entry><literal>ART20</literal></entry> <entry>Artistic License version 2.0</entry> <entry><literal>FSF</literal> <literal>GPL</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-ARTPERL10"> <entry><literal>ARTPERL10</literal></entry> <entry>Artistic License (perl) version 1.0</entry> <entry><literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-BSD"> <entry><literal>BSD</literal></entry> <entry>BSD license Generic Version (deprecated)</entry> <entry><literal>FSF</literal> <literal>OSI</literal> <literal>COPYFREE</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-BSD2CLAUSE"> <entry><literal>BSD2CLAUSE</literal></entry> <entry>BSD 2-clause "Simplified" License</entry> <entry><literal>FSF</literal> <literal>OSI</literal> <literal>COPYFREE</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-BSD3CLAUSE"> <entry><literal>BSD3CLAUSE</literal></entry> <entry>BSD 3-clause "New" or "Revised" License</entry> <entry><literal>FSF</literal> <literal>OSI</literal> <literal>COPYFREE</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-BSD4CLAUSE"> <entry><literal>BSD4CLAUSE</literal></entry> <entry>BSD 4-clause "Original" or "Old" License</entry> <entry><literal>FSF</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-BSL"> <entry><literal>BSL</literal></entry> <entry>Boost Software License</entry> <entry><literal>FSF</literal> <literal>OSI</literal> <literal>COPYFREE</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-CC-BY-1.0"> <entry><literal>CC-BY-1.0</literal></entry> <entry>Creative Commons Attribution 1.0</entry> <entry></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-CC-BY-2.0"> <entry><literal>CC-BY-2.0</literal></entry> <entry>Creative Commons Attribution 2.0</entry> <entry></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-CC-BY-2.5"> <entry><literal>CC-BY-2.5</literal></entry> <entry>Creative Commons Attribution 2.5</entry> <entry></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-CC-BY-3.0"> <entry><literal>CC-BY-3.0</literal></entry> <entry>Creative Commons Attribution 3.0</entry> <entry></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-CC-BY-4.0"> <entry><literal>CC-BY-4.0</literal></entry> <entry>Creative Commons Attribution 4.0</entry> <entry></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-CC-BY-NC-1.0"> <entry><literal>CC-BY-NC-1.0</literal></entry> <entry>Creative Commons Attribution Non Commercial 1.0</entry> <entry></entry> <entry><literal>dist-mirror</literal> <literal>pkg-mirror</literal> <literal>auto-accept</literal></entry> </row> <row xml:id="licenses-license-CC-BY-NC-2.0"> <entry><literal>CC-BY-NC-2.0</literal></entry> <entry>Creative Commons Attribution Non Commercial 2.0</entry> <entry></entry> <entry><literal>dist-mirror</literal> <literal>pkg-mirror</literal> <literal>auto-accept</literal></entry> </row> <row xml:id="licenses-license-CC-BY-NC-2.5"> <entry><literal>CC-BY-NC-2.5</literal></entry> <entry>Creative Commons Attribution Non Commercial 2.5</entry> <entry></entry> <entry><literal>dist-mirror</literal> <literal>pkg-mirror</literal> <literal>auto-accept</literal></entry> </row> <row xml:id="licenses-license-CC-BY-NC-3.0"> <entry><literal>CC-BY-NC-3.0</literal></entry> <entry>Creative Commons Attribution Non Commercial 3.0</entry> <entry></entry> <entry><literal>dist-mirror</literal> <literal>pkg-mirror</literal> <literal>auto-accept</literal></entry> </row> <row xml:id="licenses-license-CC-BY-NC-4.0"> <entry><literal>CC-BY-NC-4.0</literal></entry> <entry>Creative Commons Attribution Non Commercial 4.0</entry> <entry></entry> <entry><literal>dist-mirror</literal> <literal>pkg-mirror</literal> <literal>auto-accept</literal></entry> </row> <row xml:id="licenses-license-CC-BY-NC-ND-1.0"> <entry><literal>CC-BY-NC-ND-1.0</literal></entry> <entry>Creative Commons Attribution Non Commercial No Derivatives 1.0</entry> <entry></entry> <entry><literal>dist-mirror</literal> <literal>pkg-mirror</literal> <literal>auto-accept</literal></entry> </row> <row xml:id="licenses-license-CC-BY-NC-ND-2.0"> <entry><literal>CC-BY-NC-ND-2.0</literal></entry> <entry>Creative Commons Attribution Non Commercial No Derivatives 2.0</entry> <entry></entry> <entry><literal>dist-mirror</literal> <literal>pkg-mirror</literal> <literal>auto-accept</literal></entry> </row> <row xml:id="licenses-license-CC-BY-NC-ND-2.5"> <entry><literal>CC-BY-NC-ND-2.5</literal></entry> <entry>Creative Commons Attribution Non Commercial No Derivatives 2.5</entry> <entry></entry> <entry><literal>dist-mirror</literal> <literal>pkg-mirror</literal> <literal>auto-accept</literal></entry> </row> <row xml:id="licenses-license-CC-BY-NC-ND-3.0"> <entry><literal>CC-BY-NC-ND-3.0</literal></entry> <entry>Creative Commons Attribution Non Commercial No Derivatives 3.0</entry> <entry></entry> <entry><literal>dist-mirror</literal> <literal>pkg-mirror</literal> <literal>auto-accept</literal></entry> </row> <row xml:id="licenses-license-CC-BY-NC-ND-4.0"> <entry><literal>CC-BY-NC-ND-4.0</literal></entry> <entry>Creative Commons Attribution Non Commercial No Derivatives 4.0</entry> <entry></entry> <entry><literal>dist-mirror</literal> <literal>pkg-mirror</literal> <literal>auto-accept</literal></entry> </row> <row xml:id="licenses-license-CC-BY-NC-SA-1.0"> <entry><literal>CC-BY-NC-SA-1.0</literal></entry> <entry>Creative Commons Attribution Non Commercial Share Alike 1.0</entry> <entry></entry> <entry><literal>dist-mirror</literal> <literal>pkg-mirror</literal> <literal>auto-accept</literal></entry> </row> <row xml:id="licenses-license-CC-BY-NC-SA-2.0"> <entry><literal>CC-BY-NC-SA-2.0</literal></entry> <entry>Creative Commons Attribution Non Commercial Share Alike 2.0</entry> <entry></entry> <entry><literal>dist-mirror</literal> <literal>pkg-mirror</literal> <literal>auto-accept</literal></entry> </row> <row xml:id="licenses-license-CC-BY-NC-SA-2.5"> <entry><literal>CC-BY-NC-SA-2.5</literal></entry> <entry>Creative Commons Attribution Non Commercial Share Alike 2.5</entry> <entry></entry> <entry><literal>dist-mirror</literal> <literal>pkg-mirror</literal> <literal>auto-accept</literal></entry> </row> <row xml:id="licenses-license-CC-BY-NC-SA-3.0"> <entry><literal>CC-BY-NC-SA-3.0</literal></entry> <entry>Creative Commons Attribution Non Commercial Share Alike 3.0</entry> <entry></entry> <entry><literal>dist-mirror</literal> <literal>pkg-mirror</literal> <literal>auto-accept</literal></entry> </row> <row xml:id="licenses-license-CC-BY-NC-SA-4.0"> <entry><literal>CC-BY-NC-SA-4.0</literal></entry> <entry>Creative Commons Attribution Non Commercial Share Alike 4.0</entry> <entry></entry> <entry><literal>dist-mirror</literal> <literal>pkg-mirror</literal> <literal>auto-accept</literal></entry> </row> <row xml:id="licenses-license-CC-BY-ND-1.0"> <entry><literal>CC-BY-ND-1.0</literal></entry> <entry>Creative Commons Attribution No Derivatives 1.0</entry> <entry></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-CC-BY-ND-2.0"> <entry><literal>CC-BY-ND-2.0</literal></entry> <entry>Creative Commons Attribution No Derivatives 2.0</entry> <entry></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-CC-BY-ND-2.5"> <entry><literal>CC-BY-ND-2.5</literal></entry> <entry>Creative Commons Attribution No Derivatives 2.5</entry> <entry></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-CC-BY-ND-3.0"> <entry><literal>CC-BY-ND-3.0</literal></entry> <entry>Creative Commons Attribution No Derivatives 3.0</entry> <entry></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-CC-BY-ND-4.0"> <entry><literal>CC-BY-ND-4.0</literal></entry> <entry>Creative Commons Attribution No Derivatives 4.0</entry> <entry></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-CC-BY-SA-1.0"> <entry><literal>CC-BY-SA-1.0</literal></entry> <entry>Creative Commons Attribution Share Alike 1.0</entry> <entry></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-CC-BY-SA-2.0"> <entry><literal>CC-BY-SA-2.0</literal></entry> <entry>Creative Commons Attribution Share Alike 2.0</entry> <entry></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-CC-BY-SA-2.5"> <entry><literal>CC-BY-SA-2.5</literal></entry> <entry>Creative Commons Attribution Share Alike 2.5</entry> <entry></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-CC-BY-SA-3.0"> <entry><literal>CC-BY-SA-3.0</literal></entry> <entry>Creative Commons Attribution Share Alike 3.0</entry> <entry></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-CC-BY-SA-4.0"> <entry><literal>CC-BY-SA-4.0</literal></entry> <entry>Creative Commons Attribution Share Alike 4.0</entry> <entry></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-CC0-1.0"> <entry><literal>CC0-1.0</literal></entry> <entry>Creative Commons Zero v1.0 Universal</entry> <entry><literal>FSF</literal> <literal>GPL</literal> <literal>COPYFREE</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-CDDL"> <entry><literal>CDDL</literal></entry> <entry>Common Development and Distribution License</entry> <entry><literal>FSF</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-CPAL-1.0"> <entry><literal>CPAL-1.0</literal></entry> <entry>Common Public Attribution License</entry> <entry><literal>FSF</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-ClArtistic"> <entry><literal>ClArtistic</literal></entry> <entry>Clarified Artistic License</entry> <entry><literal>FSF</literal> <literal>GPL</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-EPL"> <entry><literal>EPL</literal></entry> <entry>Eclipse Public License</entry> <entry><literal>FSF</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-GFDL"> <entry><literal>GFDL</literal></entry> <entry>GNU Free Documentation License</entry> <entry><literal>FSF</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-GMGPL"> <entry><literal>GMGPL</literal></entry> <entry>GNAT Modified General Public License</entry> <entry><literal>FSF</literal> <literal>GPL</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-GPLv1"> <entry><literal>GPLv1</literal></entry> <entry>GNU General Public License version 1</entry> <entry><literal>FSF</literal> <literal>GPL</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-GPLv1_"> <entry><literal>GPLv1+</literal></entry> <entry>GNU General Public License version 1 (or later)</entry> <entry><literal>FSF</literal> <literal>GPL</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-GPLv2"> <entry><literal>GPLv2</literal></entry> <entry>GNU General Public License version 2</entry> <entry><literal>FSF</literal> <literal>GPL</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-GPLv2_"> <entry><literal>GPLv2+</literal></entry> <entry>GNU General Public License version 2 (or later)</entry> <entry><literal>FSF</literal> <literal>GPL</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-GPLv3"> <entry><literal>GPLv3</literal></entry> <entry>GNU General Public License version 3</entry> <entry><literal>FSF</literal> <literal>GPL</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-GPLv3_"> <entry><literal>GPLv3+</literal></entry> <entry>GNU General Public License version 3 (or later)</entry> <entry><literal>FSF</literal> <literal>GPL</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-GPLv3RLE"> <entry><literal>GPLv3RLE</literal></entry> <entry>GNU GPL version 3 Runtime Library Exception</entry> <entry><literal>FSF</literal> <literal>GPL</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-GPLv3RLE_"> <entry><literal>GPLv3RLE+</literal></entry> <entry>GNU GPL version 3 Runtime Library Exception (or later)</entry> <entry><literal>FSF</literal> <literal>GPL</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-ISCL"> <entry><literal>ISCL</literal></entry> <entry>Internet Systems Consortium License</entry> <entry><literal>FSF</literal> <literal>GPL</literal> <literal>OSI</literal> <literal>COPYFREE</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-LGPL20"> <entry><literal>LGPL20</literal></entry> <entry>GNU Library General Public License version 2.0</entry> <entry><literal>FSF</literal> <literal>GPL</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-LGPL20_"> <entry><literal>LGPL20+</literal></entry> <entry>GNU Library General Public License version 2.0 (or later)</entry> <entry><literal>FSF</literal> <literal>GPL</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-LGPL21"> <entry><literal>LGPL21</literal></entry> <entry>GNU Lesser General Public License version 2.1</entry> <entry><literal>FSF</literal> <literal>GPL</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-LGPL21_"> <entry><literal>LGPL21+</literal></entry> <entry>GNU Lesser General Public License version 2.1 (or later)</entry> <entry><literal>FSF</literal> <literal>GPL</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-LGPL3"> <entry><literal>LGPL3</literal></entry> <entry>GNU Lesser General Public License version 3</entry> <entry><literal>FSF</literal> <literal>GPL</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-LGPL3_"> <entry><literal>LGPL3+</literal></entry> <entry>GNU Lesser General Public License version 3 (or later)</entry> <entry><literal>FSF</literal> <literal>GPL</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-LPPL10"> <entry><literal>LPPL10</literal></entry> <entry>LaTeX Project Public License version 1.0</entry> <entry><literal>FSF</literal> <literal>OSI</literal></entry> <entry><literal>dist-mirror</literal> <literal>dist-sell</literal></entry> </row> <row xml:id="licenses-license-LPPL11"> <entry><literal>LPPL11</literal></entry> <entry>LaTeX Project Public License version 1.1</entry> <entry><literal>FSF</literal> <literal>OSI</literal></entry> <entry><literal>dist-mirror</literal> <literal>dist-sell</literal></entry> </row> <row xml:id="licenses-license-LPPL12"> <entry><literal>LPPL12</literal></entry> <entry>LaTeX Project Public License version 1.2</entry> <entry><literal>FSF</literal> <literal>OSI</literal></entry> <entry><literal>dist-mirror</literal> <literal>dist-sell</literal></entry> </row> <row xml:id="licenses-license-LPPL13"> <entry><literal>LPPL13</literal></entry> <entry>LaTeX Project Public License version 1.3</entry> <entry><literal>FSF</literal> <literal>OSI</literal></entry> <entry><literal>dist-mirror</literal> <literal>dist-sell</literal></entry> </row> <row xml:id="licenses-license-LPPL13a"> <entry><literal>LPPL13a</literal></entry> <entry>LaTeX Project Public License version 1.3a</entry> <entry><literal>FSF</literal> <literal>OSI</literal></entry> <entry><literal>dist-mirror</literal> <literal>dist-sell</literal></entry> </row> <row xml:id="licenses-license-LPPL13b"> <entry><literal>LPPL13b</literal></entry> <entry>LaTeX Project Public License version 1.3b</entry> <entry><literal>FSF</literal> <literal>OSI</literal></entry> <entry><literal>dist-mirror</literal> <literal>dist-sell</literal></entry> </row> <row xml:id="licenses-license-LPPL13c"> <entry><literal>LPPL13c</literal></entry> <entry>LaTeX Project Public License version 1.3c</entry> <entry><literal>FSF</literal> <literal>OSI</literal></entry> <entry><literal>dist-mirror</literal> <literal>dist-sell</literal></entry> </row> <row xml:id="licenses-license-MIT"> <entry><literal>MIT</literal></entry> <entry>MIT license / X11 license</entry> <entry><literal>COPYFREE</literal> <literal>FSF</literal> <literal>GPL</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-MPL10"> <entry><literal>MPL10</literal></entry> <entry>Mozilla Public License version 1.0</entry> <entry><literal>FSF</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-MPL11"> <entry><literal>MPL11</literal></entry> <entry>Mozilla Public License version 1.1</entry> <entry><literal>FSF</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-MPL20"> <entry><literal>MPL20</literal></entry> <entry>Mozilla Public License version 2.0</entry> <entry><literal>FSF</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-NCSA"> <entry><literal>NCSA</literal></entry> <entry>University of Illinois/NCSA Open Source License</entry> <entry><literal>COPYFREE</literal> <literal>FSF</literal> <literal>GPL</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-NONE"> <entry><literal>NONE</literal></entry> <entry>No license specified</entry> <entry></entry> <entry><literal>none</literal></entry> </row> <row xml:id="licenses-license-OFL10"> <entry><literal>OFL10</literal></entry> <entry>SIL Open Font License version 1.0 (http://scripts.sil.org/OFL)</entry> <entry><literal>FONTS</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-OFL11"> <entry><literal>OFL11</literal></entry> <entry>SIL Open Font License version 1.1 (http://scripts.sil.org/OFL)</entry> <entry><literal>FONTS</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-OWL"> <entry><literal>OWL</literal></entry> <entry>Open Works License (owl.apotheon.org)</entry> <entry><literal>COPYFREE</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-OpenSSL"> <entry><literal>OpenSSL</literal></entry> <entry>OpenSSL License</entry> <entry><literal>FSF</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-PD"> <entry><literal>PD</literal></entry> <entry>Public Domain</entry> <entry><literal>GPL</literal> <literal>COPYFREE</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-PHP202"> <entry><literal>PHP202</literal></entry> <entry>PHP License version 2.02</entry> <entry><literal>FSF</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-PHP30"> <entry><literal>PHP30</literal></entry> <entry>PHP License version 3.0</entry> <entry><literal>FSF</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-PHP301"> <entry><literal>PHP301</literal></entry> <entry>PHP License version 3.01</entry> <entry><literal>FSF</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-PSFL"> <entry><literal>PSFL</literal></entry> <entry>Python Software Foundation License</entry> <entry><literal>FSF</literal> <literal>GPL</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-PostgreSQL"> <entry><literal>PostgreSQL</literal></entry> <entry>PostgreSQL Licence</entry> <entry><literal>FSF</literal> <literal>GPL</literal> <literal>OSI</literal> <literal>COPYFREE</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-RUBY"> <entry><literal>RUBY</literal></entry> <entry>Ruby License</entry> <entry><literal>FSF</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-UNLICENSE"> <entry><literal>UNLICENSE</literal></entry> <entry>The Unlicense</entry> <entry><literal>COPYFREE</literal> <literal>FSF</literal> <literal>GPL</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-WTFPL"> <entry><literal>WTFPL</literal></entry> <entry>Do What the Fuck You Want To Public License version 2</entry> <entry><literal>GPL</literal> <literal>FSF</literal> <literal>COPYFREE</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-WTFPL1"> <entry><literal>WTFPL1</literal></entry> <entry>Do What the Fuck You Want To Public License version 1</entry> <entry><literal>GPL</literal> <literal>FSF</literal> <literal>COPYFREE</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-ZLIB"> <entry><literal>ZLIB</literal></entry> <entry>zlib License</entry> <entry><literal>GPL</literal> <literal>FSF</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> <row xml:id="licenses-license-ZPL21"> <entry><literal>ZPL21</literal></entry> <entry>Zope Public License version 2.1</entry> <entry><literal>GPL</literal> <literal>OSI</literal></entry> <entry>(default)</entry> </row> </tbody> </tgroup> </table> </sect2> <sect2 xml:id="licenses-license_perms"> <title><varname>LICENSE_PERMS</varname> and <varname>LICENSE_PERMS_<replaceable>NAME</replaceable></varname></title> <para>Permissions. use <literal>none</literal> if empty.</para> <variablelist xml:id="licenses-license_perms-list"> <title>License Permissions List</title> <varlistentry xml:id="licenses-license_perms-dist-mirror"> <term><literal>dist-mirror</literal></term> <listitem> <para>Redistribution of the distribution files is permitted. The distribution files will be added to the &os; <varname>MASTER_SITE_BACKUP</varname> <acronym>CDN</acronym>.</para> </listitem> </varlistentry> <varlistentry xml:id="licenses-license_perms-no-dist-mirror"> <term><literal>no-dist-mirror</literal></term> <listitem> <para>Redistribution of the distribution files is prohibited. This is equivalent to setting <link linkend="porting-restrictions-restricted"><varname>RESTRICTED</varname></link>. The distribution files will <emphasis>not</emphasis> be added to the &os; <varname>MASTER_SITE_BACKUP</varname> <acronym>CDN</acronym>.</para> </listitem> </varlistentry> <varlistentry xml:id="licenses-license_perms-dist-sell"> <term><literal>dist-sell</literal></term> <listitem> <para>Selling of distribution files is permitted. The distribution files will be present on the installer images.</para> </listitem> </varlistentry> <varlistentry xml:id="licenses-license_perms-no-dist-sell"> <term><literal>no-dist-sell</literal></term> <listitem> <para>Selling of distribution files is prohibited. This is equivalent to setting <link linkend="porting-restrictions-no_cdrom"><varname>NO_CDROM</varname></link>.</para> </listitem> </varlistentry> <varlistentry xml:id="licenses-license_perms-pkg-mirror"> <term><literal>pkg-mirror</literal></term> <listitem> <para>Free redistribution of package is permitted. The package will be distributed on the &os; package <acronym>CDN</acronym> <link xlink:href="https://pkg.freebsd.org/">https://pkg.freebsd.org/</link>.</para> </listitem> </varlistentry> <varlistentry xml:id="licenses-license_perms-no-pkg-mirror"> <term><literal>no-pkg-mirror</literal></term> <listitem> <para>Free redistribution of package is prohibited. Equivalent to setting <link linkend="porting-restrictions-no_package"><varname>NO_PACKAGE</varname></link>. The package will <emphasis>not</emphasis> be distributed from the &os; package <acronym>CDN</acronym> <link xlink:href="https://pkg.freebsd.org/">https://pkg.freebsd.org/</link>.</para> </listitem> </varlistentry> <varlistentry xml:id="licenses-license_perms-pkg-sell"> <term><literal>pkg-sell</literal></term> <listitem> <para>Selling of package is permitted. The package will be present on the installer images.</para> </listitem> </varlistentry> <varlistentry xml:id="licenses-license_perms-no-pkg-sell"> <term><literal>no-pkg-sell</literal></term> <listitem> <para>Selling of package is prohibited. This is equivalent to setting <link linkend="porting-restrictions-no_cdrom"><varname>NO_CDROM</varname></link>. The package will <emphasis>not</emphasis> be present on the installer images.</para> </listitem> </varlistentry> <varlistentry xml:id="licenses-license_perms-auto-accept"> <term><literal>auto-accept</literal></term> <listitem> <para>License is accepted by default. Prompts to accept a license are not displayed unless the user has defined <varname>LICENSES_ASK</varname>. Use this unless the license states the user must accept the terms of the license.</para> </listitem> </varlistentry> <varlistentry xml:id="licenses-license_perms-no-auto-accept"> <term><literal>no-auto-accept</literal></term> <listitem> <para>License is not accepted by default. The user will always be asked to confirm the acceptance of this license. This must be used if the license states that the user must accept its terms.</para> </listitem> </varlistentry> </variablelist> <para>When both <literal><replaceable>permission</replaceable></literal> and <literal>no-<replaceable>permission</replaceable></literal> is present the <literal>no-<replaceable>permission</replaceable></literal> will cancel <literal><replaceable>permission</replaceable></literal>.</para> <para>When <literal><replaceable>permission</replaceable></literal> is not present, it is considered to be a <literal>no-<replaceable>permission</replaceable></literal>.</para> <example xml:id="licenses-license_perms-ex1"> <title>Nonstandard License</title> <para>Read the terms of the license and translate those using the available permissions.</para> <programlisting>LICENSE= UNKNOWN LICENSE_NAME= unknown LICENSE_TEXT= This program is NOT in public domain.\ It can be freely distributed for non-commercial purposes only. LICENSE_PERMS= dist-mirror no-dist-sell pkg-mirror no-pkg-sell auto-accept</programlisting> </example> <example xml:id="licenses-license_perms-ex2"> <title>Standard and Nonstandard Licenses</title> <para>Read the terms of the license and express those using the available permissions. In case of doubt, please ask for guidance on the &a.ports;.</para> <programlisting>LICENSE= WARSOW GPLv2 LICENSE_COMB= multi LICENSE_NAME_WARSOW= Warsow Content License LICENSE_FILE_WARSOW= ${WRKSRC}/docs/license.txt LICENSE_PERMS_WARSOW= dist-mirror pkg-mirror auto-accept</programlisting> <para>When the permissions of the GPLv2 and the UNKNOWN licenses are mixed, the port ends up with <literal>dist-mirror dist-sell pkg-mirror pkg-sell auto-accept dist-mirror no-dist-sell pkg-mirror no-pkg-sell auto-accept</literal>. The <literal>no-<replaceable>permissions</replaceable></literal> cancel the <replaceable>permissions</replaceable>. The resulting list of permissions are <replaceable>dist-mirror pkg-mirror auto-accept</replaceable>. The distribution files and the packages will not be available on the installer images.</para> </example> </sect2> <sect2 xml:id="licenses-license_groups"> <title><varname>LICENSE_GROUPS</varname> and <varname>LICENSE_GROUPS_<replaceable>NAME</replaceable></varname></title> <para>Groups the license belongs.</para> <variablelist xml:id="licenses-license_groups-list"> <title>Predefined License Groups List</title> <varlistentry xml:id="licenses-license_groups-FSF"> <term><literal>FSF</literal></term> <listitem> <para>Free Software Foundation Approved, see the <link xlink:href="http://www.fsf.org/licensing">FSF Licensing & Compliance Team</link>.</para> </listitem> </varlistentry> <varlistentry xml:id="licenses-license_groups-GPL"> <term><literal>GPL</literal></term> <listitem> <para>GPL Compatible</para> </listitem> </varlistentry> <varlistentry xml:id="licenses-license_groups-OSI"> <term><literal>OSI</literal></term> <listitem> <para>OSI Approved, see the Open Source Initiative <link xlink:href="http://opensource.org/licenses">Open Source Licenses</link> page.</para> </listitem> </varlistentry> <varlistentry xml:id="licenses-license_groups-COPYFREE"> <term><literal>COPYFREE</literal></term> <listitem> <para>Comply with Copyfree Standard Definition, see the <link xlink:href="http://copyfree.org/standard/licenses">Copyfree Licenses</link> page.</para> </listitem> </varlistentry> <varlistentry xml:id="licenses-license_groups-FONTS"> <term><literal>FONTS</literal></term> <listitem> <para>Font licenses</para> </listitem> </varlistentry> </variablelist> </sect2> <sect2 xml:id="licenses-license_name"> <title><varname>LICENSE_NAME</varname> and <varname>LICENSE_NAME_<replaceable>NAME</replaceable></varname></title> <para>Full name of the license.</para> <example xml:id="licenses-license_name-ex1"> <title><varname>LICENSE_NAME</varname></title> <programlisting>LICENSE= UNRAR LICENSE_NAME= UnRAR License LICENSE_FILE= ${WRKSRC}/license.txt LICENSE_PERMS= dist-mirror dist-sell pkg-mirror pkg-sell auto-accept</programlisting> </example> </sect2> <sect2 xml:id="licenses-license_file"> <title><varname>LICENSE_FILE</varname> and <varname>LICENSE_FILE_<replaceable>NAME</replaceable></varname></title> <para>Full path to the file containing the license text, usually <filename>${WRKSRC}/some/file</filename>. If the file is not in the distfile, and its content is too long to be put in <link linkend="licenses-license_text"><varname>LICENSE_TEXT</varname></link>, put it in a new file in <filename>${FILESDIR}</filename>.</para> <example xml:id="licenses-license_file-ex1"> <title><varname>LICENSE_FILE</varname></title> <programlisting>LICENSE= GPLv3+ LICENSE_FILE= ${WRKSRC}/COPYING</programlisting> </example> </sect2> <sect2 xml:id="licenses-license_text"> <title><varname>LICENSE_TEXT</varname> and <varname>LICENSE_TEXT_<replaceable>NAME</replaceable></varname></title> <para>Text to use as a license. Useful when the license is not in the distribution files and its text is short.</para> <example xml:id="licenses-license_text-ex1"> <title><varname>LICENSE_TEXT</varname></title> <programlisting>LICENSE= UNKNOWN LICENSE_NAME= unknown LICENSE_TEXT= This program is NOT in public domain.\ It can be freely distributed for non-commercial purposes only,\ and THERE IS NO WARRANTY FOR THIS PROGRAM. LICENSE_PERMS= dist-mirror no-dist-sell pkg-mirror no-pkg-sell auto-accept</programlisting> </example> </sect2> <sect2 xml:id="licenses-license_distfiles"> <title><varname>LICENSE_DISTFILES</varname> and <varname>LICENSE_DISTFILES_<replaceable>NAME</replaceable></varname></title> <para>The distribution files to which the licenses apply. Defaults to all the distribution files.</para> <example xml:id="licenses-license_distfiles-ex1"> <title><varname>LICENSE_DISTFILES</varname></title> <para>Used when the distribution files do not all have the same license. For example, one has a code license, and another has some artwork that cannot be redistributed:</para> <programlisting>MASTER_SITES= SF/some-game DISTFILES= ${DISTNAME}${EXTRACT_SUFX} artwork.zip LICENSE= BSD3CLAUSE ARTWORK LICENSE_COMB= dual LICENSE_NAME_ARTWORK= The game artwork license LICENSE_TEXT_ARTWORK= The README says that the files cannot be redistributed LICENSE_PERMS_ARTWORK= pkg-mirror pkg-sell auto-accept LICENSE_DISTFILES_BSD3CLAUSE= ${DISTNAME}${EXTRACT_SUFX} LICENSE_DISTFILES_ARTWORK= artwork.zip</programlisting> </example> </sect2> <sect2 xml:id="licenses-license_comb"> <title><varname>LICENSE_COMB</varname></title> <para>Set to <literal>multi</literal> if all licenses apply. Set to <literal>dual</literal> if any license applies. Defaults to <literal>single</literal>.</para> <example xml:id="licenses-license_comb-ex1"> <title>Dual Licenses</title> <para>When a port says <quote>This software may be distributed under the GNU General Public License or the Artistic License</quote>, it means that either license can be used. Use this:</para> <programlisting>LICENSE= ART10 GPLv1 LICENSE_COMB= dual</programlisting> <para>If license files are provided, use this:</para> <programlisting>LICENSE= ART10 GPLv1 LICENSE_COMB= dual LICENSE_FILE_ART10= ${WRKSRC}/Artistic LICENSE_FILE_GPLv1= ${WRKSRC}/Copying</programlisting> </example> <example xml:id="licenses-license_comb-ex2"> <title>Multiple Licenses</title> <para>When part of a port has one license, and another part has a different license, use <literal>multi</literal>:</para> <programlisting>LICENSE= GPLv2 LGPL21+ LICENSE_COMB= multi</programlisting> </example> </sect2> </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: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:news/inn \ xmlcatmgr: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>, create another variable with the current content of <varname>BUILD_DEPENDS</varname> and assign it to both <varname>BUILD_DEPENDS</varname> and <varname>RUN_DEPENDS</varname>:</para> <programlisting>MY_DEPENDS= some:devel/some \ other:lang/other BUILD_DEPENDS= ${MY_DEPENDS} RUN_DEPENDS= ${MY_DEPENDS}</programlisting> <important> <para><emphasis>Do not</emphasis> use <literal>:=</literal> to assign <varname>BUILD_DEPENDS</varname> to <varname>RUN_DEPENDS</varname> or vice-versa. All variables are expanded immediately, which is exactly the wrong thing to do and almost always a failure.</para> </important> </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: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: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: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"/>.</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}: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"/>.</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: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}: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: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: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> </sect1> <sect1 xml:id="makefile-masterdir"> <title>Slave Ports and <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>print/pkfonts300/Makefile</filename>;</para> <programlisting>PORTNAME= pkfonts${RESOLUTION} PORTVERSION= 1.0 DISTFILES= pk${RESOLUTION}.tar.gz PLIST= ${PKGDIR}/pkg-plist.${RESOLUTION} .if !defined(RESOLUTION) RESOLUTION= 300 .else .if ${RESOLUTION} != 118 && ${RESOLUTION} != 240 && \ ${RESOLUTION} != 300 && ${RESOLUTION} != 360 && \ ${RESOLUTION} != 400 && ${RESOLUTION} != 600 .BEGIN: @${ECHO_MSG} "Error: invalid value for RESOLUTION: \"${RESOLUTION}\"" @${ECHO_MSG} "Possible values are: 118, 240, 300, 360, 400 and 600." @${FALSE} .endif .endif</programlisting> <para><package role="port">print/pkfonts300</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>print/pkfonts360/Makefile</filename>:</para> <programlisting>RESOLUTION= 360 MASTERDIR= ${.CURDIR}/../pkfonts300 .include "${MASTERDIR}/Makefile"</programlisting> <para>(<filename>print/pkfonts118/Makefile</filename>, <filename>print/pkfonts600/Makefile</filename>, and all the other 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>pkfonts300</filename>. The <literal>RESOLUTION=360</literal> line will override the <literal>RESOLUTION=300</literal> line in <filename>pkfonts300/Makefile</filename> and the port will be built with resolution set to 360.</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 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: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: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: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: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)</programlisting> <para>as an alternative to</para> <programlisting>.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. For easier access, a comprehensive list is provided:</para> <variablelist xml:id="options-helpers-list"> <varlistentry> <term><varname>PLIST_SUB</varname>, <varname>SUB_LIST</varname></term> <listitem> <para>For automatic <literal>%%<replaceable>OPT</replaceable>%%</literal> and <literal>%%NO_<replaceable>OPT</replaceable>%%</literal> generation, see <xref linkend="options_sub"/>.</para> <para>For more complex usage, see <xref linkend="options-variables"/>.</para> </listitem> </varlistentry> <varlistentry> <term><varname>CONFIGURE_ARGS</varname></term> <listitem> <para>For <literal>--enable-<replaceable>x</replaceable></literal> and <literal>--disable-<replaceable>x</replaceable></literal>, see <xref linkend="options-configure_enable"/>.</para> <para>For <literal>--with-<replaceable>x</replaceable></literal> and <literal>--without-<replaceable>x</replaceable></literal>, see <xref linkend="options-configure_with"/>.</para> <para>For all other cases, see <xref linkend="options-configure_on"/>.</para> </listitem> </varlistentry> <varlistentry> <term><varname>CMAKE_ARGS</varname></term> <listitem> <para>For arguments that are booleans (<literal>on</literal>, <literal>off</literal>, <literal>true</literal>, <literal>false</literal>, <literal>0</literal>, <literal>1</literal>) see <xref linkend="options-cmake_bool"/>.</para> <para>For all other cases, see <xref linkend="options-cmake_on"/>.</para> </listitem> </varlistentry> <varlistentry> <term><varname>MESON_ARGS</varname></term> <listitem> <para>For arguments that take <literal>true</literal> or <literal>false</literal>, see <xref linkend="options-meson_true"/>.</para> <para>For arguments that take <literal>yes</literal> or <literal>no</literal>, use <xref linkend="options-meson_yes"/>.</para> <para>For all other cases, use <xref linkend="options-meson_on"/>.</para> </listitem> </varlistentry> <varlistentry> <term><varname>QMAKE_ARGS</varname></term> <listitem> <para>See <xref linkend="options-qmake_on"/>.</para> </listitem> </varlistentry> <varlistentry> <term><varname>USE_<replaceable>*</replaceable></varname></term> <listitem> <para>See <xref linkend="options-use"/>.</para> </listitem> </varlistentry> <varlistentry> <term><varname><replaceable>*</replaceable>_DEPENDS</varname></term> <listitem> <para>See <xref linkend="options-dependencies"/>.</para> </listitem> </varlistentry> <varlistentry> <term><replaceable>*</replaceable> (Any variable)</term> <listitem> <para>The most used variables have direct helpers, see <xref linkend="options-variables"/>.</para> <para>For any variable without a specific helper, see <xref linkend="options-vars"/>.</para> </listitem> </varlistentry> <varlistentry> <term>Options dependencies</term> <listitem> <para>When an option need another option to work, see <xref linkend="options-implies"/>.</para> </listitem> </varlistentry> <varlistentry> <term>Options conflicts</term> <listitem> <para>When an option cannot work if another is also enabled, see <xref linkend="options-prevents"/>.</para> </listitem> </varlistentry> <varlistentry> <term>Build targets</term> <listitem> <para>When an option need some extra processing, see <xref linkend="options-targets"/>.</para> </listitem> </varlistentry> </variablelist> <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> and <varname><replaceable>OPT</replaceable>_USE_OFF</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. <varname><replaceable>OPT</replaceable>_USE_OFF</varname> works the same way, but when <literal>OPT</literal> is <emphasis>not</emphasis> selected. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT1_USE= mysql=yes xorg=x11,xextproto,xext,xrandr OPT1_USE_OFF= openssl=yes</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 .else USE_OPENSSL= yes .endif</programlisting> </sect3> <sect3 xml:id="options-configure-helpers"> <title><varname>CONFIGURE_ARGS</varname> Helpers</title> <sect4 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 <emphasis>not</emphasis> 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> </sect4> <sect4 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_WITH</varname> then <literal>--with-<replaceable>entry</replaceable></literal> is appended to <varname>CONFIGURE_ARGS</varname>. When option <replaceable>OPT</replaceable> is <emphasis>not</emphasis> 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> </sect4> <sect4 xml:id="options-configure_on"> <title><varname><replaceable>OPT</replaceable>_CONFIGURE_ON</varname> and <varname><replaceable>OPT</replaceable>_CONFIGURE_OFF</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>. <varname><replaceable>OPT</replaceable>_CONFIGURE_OFF</varname> works the same way, but when <literal>OPT</literal> is <emphasis>not</emphasis> selected. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT1_CONFIGURE_ON= --add-test 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+= --add-test .else CONFIGURE_ARGS+= --no-test .endif</programlisting> <tip> <para>Most of the time, the helpers in <xref linkend="options-configure_enable"/> and <xref linkend="options-configure_with"/> provide a shorter and more comprehensive functionality.</para> </tip> </sect4> </sect3> <sect3 xml:id="options-cmake-helpers"> <title><varname>CMAKE_ARGS</varname> Helpers</title> <sect4 xml:id="options-cmake_on"> <title><varname><replaceable>OPT</replaceable>_CMAKE_ON</varname> and <varname><replaceable>OPT</replaceable>_CMAKE_OFF</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>. <varname><replaceable>OPT</replaceable>_CMAKE_OFF</varname> works the same way, but when <literal>OPT</literal> is <emphasis>not</emphasis> selected. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT1_CMAKE_ON= -DTEST:BOOL=true -DDEBUG:BOOL=true OPT1_CMAKE_OFF= -DOPTIMIZE: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 -DDEBUG:BOOL=true .else CMAKE_ARGS+= -DOPTIMIZE:BOOL=true .endif</programlisting> <tip> <para>See <xref linkend="options-cmake_bool"/> for a shorter helper when the value is boolean.</para> </tip> </sect4> <sect4 xml:id="options-cmake_bool"> <title><varname><replaceable>OPT</replaceable>_CMAKE_BOOL</varname> and <varname><replaceable>OPT</replaceable>_CMAKE_BOOL_OFF</varname></title> <para>When option <replaceable>OPT</replaceable> is selected, for each <replaceable>entry</replaceable> in <varname><replaceable>OPT</replaceable>_CMAKE_BOOL</varname> then <literal>-D<replaceable>entry</replaceable>:BOOL=true</literal> is appended to <varname>CMAKE_ARGS</varname>. When option <replaceable>OPT</replaceable> is <emphasis>not</emphasis> selected, <literal>-D<replaceable>entry</replaceable>:BOOL=false</literal> is appended to <varname>CONFIGURE_ARGS</varname>. <varname><replaceable>OPT</replaceable>_CMAKE_BOOL_OFF</varname> is the oposite, <literal>-D<replaceable>entry</replaceable>:BOOL=false</literal> is appended to <varname>CMAKE_ARGS</varname> when the option is selected, and <literal>-D<replaceable>entry</replaceable>:BOOL=true</literal> when the option is <emphasis>not</emphasis> selected. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT1_CMAKE_BOOL= TEST DEBUG OPT1_CMAKE_BOOL_OFF= OPTIMIZE</programlisting> <para>is equivalent to:</para> <programlisting>OPTIONS_DEFINE= OPT1 .include <bsd.port.options.mk> .if ${PORT_OPTIONS:MOPT1} CMAKE_ARGS+= -DTEST:BOOL=true -DDEBUG:BOOL=true \ -DOPTIMIZE:BOOL=false .else CMAKE_ARGS+= -DTEST:BOOL=false -DDEBUG:BOOL=false \ -DOPTIMIZE:BOOL=true .endif</programlisting> </sect4> </sect3> <sect3 xml:id="options-meson-helpers"> <title><varname>MESON_ARGS</varname> Helpers</title> <sect4 xml:id="options-meson_on"> <title><varname><replaceable>OPT</replaceable>_MESON_ON</varname> and <varname><replaceable>OPT</replaceable>_MESON_OFF</varname></title> <para>When option <replaceable>OPT</replaceable> is selected, the value of <varname><replaceable>OPT</replaceable>_MESON_ON</varname>, if defined, is appended to <varname>MESON_ARGS</varname>. <varname><replaceable>OPT</replaceable>_MESON_OFF</varname> works the same way, but when <literal>OPT</literal> is <emphasis>not</emphasis> selected. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT1_MESON_ON= -Dopt=1 OPT1_MESON_OFF= -Dopt=2</programlisting> <para>is equivalent to:</para> <programlisting>OPTIONS_DEFINE= OPT1 .include <bsd.port.options.mk> .if ${PORT_OPTIONS:MOPT1} MESON_ARGS+= -Dopt=1 .else MESON_ARGS+= -Dopt=2 .endif</programlisting> </sect4> <sect4 xml:id="options-meson_true"> <title><varname><replaceable>OPT</replaceable>_MESON_TRUE</varname> and <varname><replaceable>OPT</replaceable>_MESON_FALSE</varname></title> <para>When option <replaceable>OPT</replaceable> is selected, for each <replaceable>entry</replaceable> in <varname><replaceable>OPT</replaceable>_MESON_TRUE</varname> then <literal>-D<replaceable>entry</replaceable>=true</literal> is appended to <varname>CMAKE_ARGS</varname>. When option <replaceable>OPT</replaceable> is <emphasis>not</emphasis> selected, <literal>-D<replaceable>entry</replaceable>=false</literal> is appended to <varname>CONFIGURE_ARGS</varname>. <varname><replaceable>OPT</replaceable>_MESON_FALSE</varname> is the oposite, <literal>-D<replaceable>entry</replaceable>=false</literal> is appended to <varname>CMAKE_ARGS</varname> when the option is selected, and <literal>-D<replaceable>entry</replaceable>=true</literal> when the option is <emphasis>not</emphasis> selected. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT1_MESON_TRUE= test debug OPT1_MESON_FALSE= optimize</programlisting> <para>is equivalent to:</para> <programlisting>OPTIONS_DEFINE= OPT1 .include <bsd.port.options.mk> .if ${PORT_OPTIONS:MOPT1} MESON_ARGS+= -Dtest=true -Ddebug=true \ -Doptimize=false .else MESON_ARGS+= -Dtest=false -Ddebug=false \ -Doptimize=true .endif</programlisting> </sect4> <sect4 xml:id="options-meson_yes"> <title><varname><replaceable>OPT</replaceable>_MESON_YES</varname> and <varname><replaceable>OPT</replaceable>_MESON_NO</varname></title> <para>When option <replaceable>OPT</replaceable> is selected, for each <replaceable>entry</replaceable> in <varname><replaceable>OPT</replaceable>_MESON_YES</varname> then <literal>-D<replaceable>entry</replaceable>=yes</literal> is appended to <varname>CMAKE_ARGS</varname>. When option <replaceable>OPT</replaceable> is <emphasis>not</emphasis> selected, <literal>-D<replaceable>entry</replaceable>=no</literal> is appended to <varname>CONFIGURE_ARGS</varname>. <varname><replaceable>OPT</replaceable>_MESON_NO</varname> is the oposite, <literal>-D<replaceable>entry</replaceable>=no</literal> is appended to <varname>CMAKE_ARGS</varname> when the option is selected, and <literal>-D<replaceable>entry</replaceable>=yes</literal> when the option is <emphasis>not</emphasis> selected. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT1_MESON_YES= test debug OPT1_MESON_NO= optimize</programlisting> <para>is equivalent to:</para> <programlisting>OPTIONS_DEFINE= OPT1 .include <bsd.port.options.mk> .if ${PORT_OPTIONS:MOPT1} CMAKE_ARGS+= -Dtest=yes -Ddebug=yes \ -Doptimize=no .else CMAKE_ARGS+= -Dtest=no -Ddebug=no \ -Doptimize=yes .endif</programlisting> </sect4> </sect3> <sect3 xml:id="options-qmake_on"> <title><varname><replaceable>OPT</replaceable>_QMAKE_ON</varname> and <varname><replaceable>OPT</replaceable>_QMAKE_OFF</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>. <varname><replaceable>OPT</replaceable>_QMAKE_OFF</varname> works the same way, but when <literal>OPT</literal> is <emphasis>not</emphasis> selected. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT1_QMAKE_ON= -DTEST:BOOL=true OPT1_QMAKE_OFF= -DPRODUCTION: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 .else QMAKE_ARGS+= -DPRODUCTION:BOOL=true .endif</programlisting> </sect3> <sect3 xml:id="options-implies"> <title><varname><replaceable>OPT</replaceable>_IMPLIES</varname></title> <para>Provides a way to add dependencies between options.</para> <para>When <replaceable>OPT</replaceable> is selected, all the options listed in this variable will be selected too. Using the <link linkend="options-configure_enable"><varname><replaceable>OPT</replaceable>_CONFIGURE_ENABLE</varname></link> described earlier to illustrate:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT2 OPT1_IMPLIES= OPT2 OPT1_CONFIGURE_ENABLE= opt1 OPT2_CONFIGURE_ENABLE= opt2</programlisting> <para>Is equivalent to:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT2 .include <bsd.port.options.mk> .if ${PORT_OPTIONS:MOPT1} CONFIGURE_ARGS+= --enable-opt1 .else CONFIGURE_ARGS+= --disable-opt1 .endif .if ${PORT_OPTIONS:MOPT2} || ${PORT_OPTIONS:MOPT1} CONFIGURE_ARGS+= --enable-opt2 .else CONFIGURE_ARGS+= --disable-opt2 .endif</programlisting> <example xml:id="options-implies-ex1"> <title>Simple Use of <varname><replaceable>OPT</replaceable>_IMPLIES</varname></title> <para>This port has a <literal>X11</literal> option, and a <literal>GNOME</literal> option that needs the <literal>X11</literal> option to be selected to build.</para> <programlisting>OPTIONS_DEFINE= X11 GNOME OPTIONS_DEFAULT= X11 X11_USE= xorg=xi,xextproto GNOME_USE= gnome=gtk30 GNOME_IMPLIES= X11</programlisting> </example> </sect3> <sect3 xml:id="options-prevents"> <title><varname><replaceable>OPT</replaceable>_PREVENTS</varname> and <varname><replaceable>OPT</replaceable>_PREVENTS_MSG</varname></title> <para>Provides a way to add conflicts between options.</para> <para>When <replaceable>OPT</replaceable> is selected, all the options listed in this variable must be un-selected. If <varname><replaceable>OPT</replaceable>_PREVENTS_MSG</varname> is also selected, its content will be shown, explaining why they conflict. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT2 OPT1_PREVENTS= OPT2 OPT1_PREVENTS_MSG= OPT1 and OPT2 enable conflicting options</programlisting> <para>Is roughly equivalent to:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT2 .include <bsd.port.options.mk> .if ${PORT_OPTIONS:MOPT2} && ${PORT_OPTIONS:MOPT1} BROKEN= Option OPT1 conflicts with OPT2 (select only one) .endif</programlisting> <para>The only difference is that the first one will write an error after running <command>make config</command>, suggesting changing the selected options.</para> <example xml:id="options-prevents-ex1"> <title>Simple Use of <varname><replaceable>OPT</replaceable>_PREVENTS</varname></title> <para>This port has <literal>X509</literal> and <literal>SCTP</literal> options. Both options add patches, but the patches conflict with each other, so they cannot be selected at the same time.</para> <programlisting>OPTIONS_DEFINE= X509 SCTP SCTP_PATCHFILES= ${PORTNAME}-6.8p1-sctp-2573.patch.gz:-p1 SCTP_CONFIGURE_WITH= sctp X509_PATCH_SITES= http://www.roumenpetrov.info/openssh/x509/:x509 X509_PATCHFILES= ${PORTNAME}-7.0p1+x509-8.5.diff.gz:-p1:x509 X509_PREVENTS= SCTP X509_PREVENTS_MSG= X509 and SCTP patches conflict</programlisting> </example> </sect3> <sect3 xml:id="options-vars"> <title><varname><replaceable>OPT</replaceable>_VARS</varname> and <varname><replaceable>OPT</replaceable>_VARS_OFF</varname></title> <para>Provides a generic way to set and append to variables.</para> <warning><para>Before using <varname><replaceable>OPT</replaceable>_VARS</varname> and <varname><replaceable>OPT</replaceable>_VARS_OFF</varname>, see if there is already a more specific helper available in <xref linkend="options-variables"/>.</para></warning> <para>When option <replaceable>OPT</replaceable> is selected, and <varname><replaceable>OPT</replaceable>_VARS</varname> defined, <literal><replaceable>key</replaceable>=<replaceable>value</replaceable></literal> and <literal><replaceable>key</replaceable>+=<replaceable>value</replaceable></literal> pairs are evaluated from <varname><replaceable>OPT</replaceable>_VARS</varname>. An <literal>=</literal> cause the existing value of <literal>KEY</literal> to be overwritten, an <literal>+=</literal> appends to the value. <varname><replaceable>OPT</replaceable>_VARS_OFF</varname> works the same way, but when <literal>OPT</literal> is <emphasis>not</emphasis> selected.</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT2 OPT3 OPT1_VARS= also_build+=bin1 OPT2_VARS= also_build+=bin2 OPT3_VARS= bin3_build=yes OPT3_VARS_OFF= bin3_build=no MAKE_ARGS= ALSO_BUILD="${ALSO_BUILD}" BIN3_BUILD="${BIN3_BUILD}"</programlisting> <para>is equivalent to:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT2 MAKE_ARGS= ALSO_BUILD="${ALSO_BUILD}" BIN3_BUILD="${BIN3_BUILD}" .include <bsd.port.options.mk> .if ${PORT_OPTIONS:MOPT1} ALSO_BUILD+= bin1 .endif .if ${PORT_OPTIONS:MOPT2} ALSO_BUILD+= bin2 .endif .if ${PORT_OPTIONS:MOPT2} BIN3_BUILD= yes .else BIN3_BUILD= no .endif</programlisting> <important> <para>Values containing whitespace must be enclosed in quotes:</para> <programlisting>OPT_VARS= foo="bar baz"</programlisting> <para>This is due to the way &man.make.1; variable expansion deals with whitespace. When <literal>OPT_VARS= foo=bar baz</literal> is expanded, the variable ends up containing two strings, <literal>foo=bar</literal> and <literal>baz</literal>. But the submitter probably intended there to be only one string, <literal>foo=bar baz</literal>. Quoting the value prevents whitespace from being used as a delimiter.</para> <para>Also, <emphasis>do not</emphasis> add extra spaces after the <literal><replaceable>var</replaceable>=</literal> sign and before the value, it would also be split into two strings. <emphasis>This will not work</emphasis>:</para> <programlisting>OPT_VARS= foo= bar</programlisting> </important> </sect3> <sect3 xml:id="options-dependencies"> <title>Dependencies, <varname><replaceable>OPT</replaceable>_<replaceable>DEPTYPE</replaceable></varname> and <varname><replaceable>OPT</replaceable>_<replaceable>DEPTYPE</replaceable>_OFF</varname></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> <para>When option <replaceable>OPT</replaceable> is selected, the value of <varname><replaceable>OPT</replaceable>_<replaceable>DEPTYPE</replaceable></varname>, if defined, is appended to <literal><replaceable>DEPTYPE</replaceable></literal>. <varname><replaceable>OPT</replaceable>_<replaceable>DEPTYPE</replaceable>_OFF</varname> works the same, but when <literal>OPT</literal> is <emphasis>not</emphasis> selected. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT1_LIB_DEPENDS= liba.so:devel/a OPT1_LIB_DEPENDS_OFF= libb.so:devel/b</programlisting> <para>is equivalent to:</para> <programlisting>OPTIONS_DEFINE= OPT1 .include <bsd.port.options.mk> .if ${PORT_OPTIONS:MOPT1} LIB_DEPENDS+= liba.so:devel/a .else LIB_DEPENDS+= libb.so:devel/b .endif</programlisting> </sect3> <sect3 xml:id="options-variables"> <title>Generic Variables Replacement, <varname><replaceable>OPT</replaceable>_<replaceable>VARIABLE</replaceable></varname> and <varname><replaceable>OPT</replaceable>_<replaceable>VARIABLE</replaceable>_OFF</varname></title> <para>For any of these variables:</para> <!-- $ for i in $(make -V _OPTIONS_FLAGS:O); do printf '<listitem>\n<para><varname>%s</varname></para>\n</listitem>\n\n' $i; done --> <itemizedlist> <listitem> <para><varname>ALL_TARGET</varname></para> </listitem> <listitem> <para><varname>BINARY_ALIAS</varname></para> </listitem> <listitem> <para><varname>BROKEN</varname></para> </listitem> <listitem> <para><varname>CATEGORIES</varname></para> </listitem> <listitem> <para><varname>CFLAGS</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>CPPFLAGS</varname></para> </listitem> <listitem> <para><varname>CXXFLAGS</varname></para> </listitem> <listitem> <para><varname>DESKTOP_ENTRIES</varname></para> </listitem> <listitem> <para><varname>DISTFILES</varname></para> </listitem> <listitem> <para><varname>EXTRACT_ONLY</varname></para> </listitem> <listitem> <para><varname>EXTRA_PATCHES</varname></para> </listitem> <listitem> <para><varname>GH_ACCOUNT</varname></para> </listitem> <listitem> <para><varname>GH_PROJECT</varname></para> </listitem> <listitem> <para><varname>GH_SUBDIR</varname></para> </listitem> <listitem> <para><varname>GH_TAGNAME</varname></para> </listitem> <listitem> <para><varname>GH_TUPLE</varname></para> </listitem> <listitem> <para><varname>GL_ACCOUNT</varname></para> </listitem> <listitem> <para><varname>GL_COMMIT</varname></para> </listitem> <listitem> <para><varname>GL_PROJECT</varname></para> </listitem> <listitem> <para><varname>GL_SITE</varname></para> </listitem> <listitem> <para><varname>GL_SUBDIR</varname></para> </listitem> <listitem> <para><varname>GL_TUPLE</varname></para> </listitem> <listitem> <para><varname>IGNORE</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>LIBS</varname></para> </listitem> <listitem> <para><varname>MAKE_ARGS</varname></para> </listitem> <listitem> <para><varname>MAKE_ENV</varname></para> </listitem> <listitem> <para><varname>MASTER_SITES</varname></para> </listitem> <listitem> <para><varname>PATCHFILES</varname></para> </listitem> <listitem> <para><varname>PATCH_SITES</varname></para> </listitem> <listitem> <para><varname>PLIST_DIRS</varname></para> </listitem> <listitem> <para><varname>PLIST_FILES</varname></para> </listitem> <listitem> <para><varname>PLIST_SUB</varname></para> </listitem> <listitem> <para><varname>PORTDOCS</varname></para> </listitem> <listitem> <para><varname>PORTEXAMPLES</varname></para> </listitem> <listitem> <para><varname>SUB_FILES</varname></para> </listitem> <listitem> <para><varname>SUB_LIST</varname></para> </listitem> <listitem> <para><varname>TEST_TARGET</varname></para> </listitem> <listitem> <para><varname>USES</varname></para> </listitem> </itemizedlist> <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>. <varname><replaceable>OPT</replaceable>_<replaceable>ABOVEVARIABLE</replaceable>_OFF</varname> works the same way, but when <literal>OPT</literal> is <emphasis>not</emphasis> selected. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 OPT1_USES= gmake OPT1_CFLAGS_OFF= -DTEST</programlisting> <para>is equivalent to:</para> <programlisting>OPTIONS_DEFINE= OPT1 .include <bsd.port.options.mk> .if ${PORT_OPTIONS:MOPT1} USES+= gmake .else CFLAGS+= -DTEST .endif</programlisting> <note> <para>Some variables are not in this list, in particular <varname>PKGNAMEPREFIX</varname> and <varname>PKGNAMESUFFIX</varname>. This is intentional. A port <emphasis>must not</emphasis> change its name when its option set changes.</para> </note> <warning> <para>Some of these variables, at least <varname>ALL_TARGET</varname>, <varname>DISTFILES</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> </sect3> <sect3 xml:id="options-targets"> <title>Additional Build Targets, <buildtarget><replaceable>target</replaceable>-<replaceable>OPT</replaceable>-on</buildtarget> and <buildtarget><replaceable>target</replaceable>-<replaceable>OPT</replaceable>-off</buildtarget></title> <para>These <filename>Makefile</filename> targets can accept optional extra build targets:</para> <itemizedlist> <listitem> <para><buildtarget>pre-fetch</buildtarget></para> </listitem> <listitem> <para><buildtarget>do-fetch</buildtarget></para> </listitem> <listitem> <para><buildtarget>post-fetch</buildtarget></para> </listitem> <listitem> <para><buildtarget>pre-extract</buildtarget></para> </listitem> <listitem> <para><buildtarget>do-extract</buildtarget></para> </listitem> <listitem> <para><buildtarget>post-extract</buildtarget></para> </listitem> <listitem> <para><buildtarget>pre-patch</buildtarget></para> </listitem> <listitem> <para><buildtarget>do-patch</buildtarget></para> </listitem> <listitem> <para><buildtarget>post-patch</buildtarget></para> </listitem> <listitem> <para><buildtarget>pre-configure</buildtarget></para> </listitem> <listitem> <para><buildtarget>do-configure</buildtarget></para> </listitem> <listitem> <para><buildtarget>post-configure</buildtarget></para> </listitem> <listitem> <para><buildtarget>pre-build</buildtarget></para> </listitem> <listitem> <para><buildtarget>do-build</buildtarget></para> </listitem> <listitem> <para><buildtarget>post-build</buildtarget></para> </listitem> <listitem> <para><buildtarget>pre-install</buildtarget></para> </listitem> <listitem> <para><buildtarget>do-install</buildtarget></para> </listitem> <listitem> <para><buildtarget>post-install</buildtarget></para> </listitem> <listitem> <para><buildtarget>post-stage</buildtarget></para> </listitem> <listitem> <para><buildtarget>pre-package</buildtarget></para> </listitem> <listitem> <para><buildtarget>do-package</buildtarget></para> </listitem> <listitem> <para><buildtarget>post-package</buildtarget></para> </listitem> </itemizedlist> <para>When option <replaceable>OPT</replaceable> is selected, the target <buildtarget><replaceable>TARGET</replaceable>-<replaceable>OPT</replaceable>-on</buildtarget>, if defined, is executed after <buildtarget><replaceable>TARGET</replaceable></buildtarget>. <buildtarget><replaceable>TARGET</replaceable>-<replaceable>OPT</replaceable>-off</buildtarget> works the same way, but when <literal>OPT</literal> is <emphasis>not</emphasis> selected. For example:</para> <programlisting>OPTIONS_DEFINE= OPT1 post-patch: @${REINPLACE_CMD} -e 's/echo/true/' ${WRKSRC}/Makefile post-patch-OPT1-on: @${REINPLACE_CMD} -e '/opt1/d' ${WRKSRC}/Makefile post-patch-OPT1-off: @${REINPLACE_CMD} -e '/opt1/s|/usr/bin/|${LOCALBASE}/bin/|' ${WRKSRC}/Makefile</programlisting> <para>is equivalent to:</para> <programlisting>OPTIONS_DEFINE= OPT1 .include <bsd.port.options.mk> post-patch: @${REINPLACE_CMD} -e 's/echo/true/' ${WRKSRC}/Makefile .if ${PORT_OPTIONS:MOPT1} @${REINPLACE_CMD} -e '/opt1/d' ${WRKSRC}/Makefile .else @${REINPLACE_CMD} -e '/opt1/s|/usr/bin/|${LOCALBASE}/bin/|' ${WRKSRC}/Makefile .endif</programlisting> </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 DISTVERSION= 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 be overridden 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-wrksrc_subdir"> <title><varname>WRKSRC_SUBDIR</varname></title> <para>If the source files needed for the port are in a subdirectory of the extracted distribution file, set <varname>WRKSRC_SUBDIR</varname> to that directory.</para> <programlisting>WRKSRC_SUBDIR= src</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> <note> <para>Because <varname>WRKDIR</varname> is the only directory that is supposed to be writable during the build, and is used to store many files recording the status of the build, the port's extraction will be forced into a subdirectory.</para> </note> </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> <variablelist xml:id="conflicts-variables"> <varlistentry xml:id="conclicts-conflicts_install"> <term><varname>CONFLICTS_INSTALL</varname></term> <listitem> <para>If the package cannot coexist with other packages (because of file conflicts, runtime incompatibilities, etc.). <varname>CONFLICTS_INSTALL</varname> check is done after the build stage and prior to the install stage.</para> </listitem> </varlistentry> <varlistentry xml:id="conclicts-conflicts_build"> <term><varname>CONFLICTS_BUILD</varname></term> <listitem> <para>If the port cannot be built when other specific ports are already installed. Build conflicts are not recorded in the resulting package.</para> </listitem> </varlistentry> <varlistentry xml:id="conclicts-conflicts"> <term><varname>CONFLICTS</varname></term> <listitem> <para>If the port cannot be built if a certain port is already installed and the resulting package cannot coexist with the other package. <varname>CONFLICTS</varname> check is done prior to the build stage and prior to the install stage.</para> </listitem> </varlistentry> </variablelist> <para>The most common content of one of these variable is the package base of another port. The package base is the package name without the appended version, it can be obtained by running <command>make -V PKGBASE</command>.</para> <example xml:id="conflicts-ex1"> <title>Basic usage of <varname>CONFLICTS<replaceable>*</replaceable></varname></title> <para><package role="port">dns/bind99</package> cannot be installed if <package role="port">dns/bind910</package> is present because they install same files. First gather the package base to use:</para> <screen>&prompt.user; <userinput>make -C dns/bind99 -V PKGBASE</userinput> bind99 &prompt.user; <userinput>make -C dns/bind910 -V PKGBASE</userinput> bind910</screen> <para>Then add to the <filename>Makefile</filename> of <package role="port">dns/bind99</package>:</para> <programlisting>CONFLICTS_INSTALL= bind910</programlisting> <para>And add to the <filename>Makefile</filename> of <package role="port">dns/bind910</package>:</para> <programlisting>CONFLICTS_INSTALL= bind99</programlisting> </example> <para>Sometime, only some version of another port is incompatible, in this case, use the full package name, with the version, and use shell globs, like <literal>*</literal> and <literal>?</literal> to make sure all possible versions are matched.</para> <example xml:id="conflicts-ex2"> <title>Using <varname>CONFLICTS<replaceable>*</replaceable></varname> With Globs.</title> <para>From versions from 2.0 and up-to 2.4.1_2, <package role="port">deskutils/gnotime</package> used to install a bundled version of <package role="port">databases/qof</package>.</para> <para>To reflect this past, the <filename>Makefile</filename> of <package role="port">databases/qof</package> contains:</para> <programlisting>CONFLICTS_INSTALL= gnotime-2.[0-3]* \ gnotime-2.4.0* gnotime-2.4.1 \ gnotime-2.4.1_[12]</programlisting> <para>The first entry match versions <literal>2.0</literal> through <literal>2.3</literal>, the second all the revisions of <literal>2.4.0</literal>, the third the exact <literal>2.4.1</literal> version, and the last the first and second revisions of the <literal>2.4.1</literal> version.</para> <para><package role="port">deskutils/gnotime</package> does not have any conflicts line because its current version does not conflict with anything else.</para> </example> </sect1> <sect1 xml:id="install"> <title>Installing Files</title> <important> <para>The <buildtarget>install</buildtarget> phase is very important to the end user because it adds files to their system. All the additional commands run in the port <filename>Makefile</filename>'s <buildtarget>*-install</buildtarget> targets should be echoed to the screen. <emphasis>Do not</emphasis> silence these commands with <literal>@</literal> or <literal>.SILENT</literal>.</para> </important> <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>@(<replaceable>owner</replaceable>,<replaceable>group</replaceable>,)</literal>, <literal>@owner <replaceable>owner</replaceable></literal>, and <literal>@group <replaceable>group</replaceable></literal>. These operators work until overridden, or until the end of <filename>pkg-plist</filename>, so remember to reset them after they are no longer needed. The default ownership is <literal>root:wheel</literal>. See <xref linkend="plist-keywords-base"/> for more information.</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 variables are set to the &man.install.1; command with the appropriate flags for each situation.</para> <important> <para>Do not use <varname>INSTALL_LIB</varname> to install static libraries, because stripping them renders them useless. Use <varname>INSTALL_DATA</varname> instead.</para> </important> </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 absolutely required. The <varname>INSTALL_PROGRAM</varname> macro installs and strips a binary at the same time. 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> strips 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> <important> <para>When <varname>WITH_DEBUG</varname> is defined, elf files <emphasis>must not</emphasis> be stripped.</para> <para>The variables (<varname>STRIP_CMD</varname>, <varname>INSTALL_PROGRAM</varname>, <varname>INSTALL_LIB</varname>, ...) and <link linkend="uses"><varname>USES</varname></link> provided by the framework handle this automatically.</para> <para>Some software, add <literal>-s</literal> to their <varname>LDFLAGS</varname>, in this case, either remove <literal>-s</literal> if <varname>WITH_DEBUG</varname> is set, or remove it unconditionally and use <varname>STRIP_CMD</varname> in <buildtarget>post-install</buildtarget>.</para> </important> </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>On the other hand, if there is a DOCS option in the port, install the documentation in a <buildtarget>post-install-DOCS-on</buildtarget> target. These targets are described in <xref linkend="options-targets"/>.</para> <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>EXAMPLESDIR</varname> are controlled by the <literal>EXAMPLES</literal> option.</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>:</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> <sect1 xml:id="binary-alias"> <title>Use <varname>BINARY_ALIAS</varname> to Rename Commands Instead of Patching the Build</title> <para>When <varname>BINARY_ALIAS</varname> is defined it will create symlinks of the given commands in a directory which will be prepended to <varname>PATH</varname>.</para> <para>Use it to substitute hardcoded commands the build phase relies on without having to patch any build files.</para> <example xml:id="binary-alias-ex1"> <title>Using <varname>BINARY_ALIAS</varname> to Make <command>gsed</command> Available as <command>sed</command></title> <para>Some ports expect <command>sed</command> to behave like <application>GNU sed</application> and use features that &man.sed.1; does not provide. <application>GNU sed</application> is available from <package role="port">textproc/gsed</package> on &os;.</para> <para>Use <varname>BINARY_ALIAS</varname> to substitute <command>sed</command> with <command>gsed</command> for the duration of the build:</para> <programlisting>BUILD_DEPENDS= gsed:textproc/gsed ... BINARY_ALIAS= sed=gsed</programlisting> </example> <example xml:id="binary-alias-ex2"> <title>Using <varname>BINARY_ALIAS</varname> to Provide Aliases for Hardcoded <command>python3</command> Commands</title> <para>A port that has a hardcoded reference to <command>python3</command> in its build scripts will need to have it available in <varname>PATH</varname> at build time. Use <varname>BINARY_ALIAS</varname> to create an alias that points to the right Python 3 binary:</para> <programlisting>USES= python:3.4+,build ... BINARY_ALIAS= python3=${PYTHON_CMD}</programlisting> <para>See <xref linkend="using-python" /> for more information about <literal>USES=python</literal>.</para> </example> </sect1> </chapter>