|
Lines 3843-3848
Link Here
|
| 3843 |
may be able to save a large number of people—including |
3843 |
may be able to save a large number of people—including |
| 3844 |
yourself— a lot of grief in the process.</para> |
3844 |
yourself— a lot of grief in the process.</para> |
| 3845 |
</sect2> |
3845 |
</sect2> |
|
|
3846 |
|
| 3847 |
<sect2> |
| 3848 |
<title>Automatic Detection Causes Problems</title> |
| 3849 |
|
| 3850 |
<para>Dependencies must be declared either explicitly or by |
| 3851 |
using the <link |
| 3852 |
linkend="makefile-options">OPTIONS framework</link>. |
| 3853 |
Using other methods like automatic detection complicates |
| 3854 |
indexing, which causes problems for port and package |
| 3855 |
management.</para> |
| 3856 |
|
| 3857 |
<example> |
| 3858 |
<title>Wrong Declaration of an Optional Dependency</title> |
| 3859 |
|
| 3860 |
<programlisting>.include <bsd.port.pre.mk> |
| 3861 |
|
| 3862 |
.if exists(${LOCALBASE}/bin/foo) |
| 3863 |
LIB_DEPENDS= bar:${PORTSDIR}/foo/bar |
| 3864 |
.endif</programlisting> |
| 3865 |
</example> |
| 3866 |
|
| 3867 |
<para>The problem with the above method is that it declares a |
| 3868 |
dependency based on the existence of a file that may have |
| 3869 |
been installed by another port. If all options were |
| 3870 |
recursively defined for a batch of ports and an index of |
| 3871 |
these ports was built, then the index would become |
| 3872 |
inconsistent during the installation of this batch if one of |
| 3873 |
its ports installed that file. A new index would need to be |
| 3874 |
created, but it too may be inconsistent if there are other |
| 3875 |
ports that use this same method.</para> |
| 3876 |
|
| 3877 |
<example> |
| 3878 |
<title>Correct Declaration of an Optional Dependency</title> |
| 3879 |
|
| 3880 |
<programlisting>OPTIONS= BAR "Enable bar support" on |
| 3881 |
|
| 3882 |
.include <bsd.port.pre.mk> |
| 3883 |
|
| 3884 |
.if defined(WITH_BAR) && !defined(WITHOUT_BAR) |
| 3885 |
LIB_DEPENDS= bar:${PORTSDIR}/foo/bar |
| 3886 |
.endif</programlisting> |
| 3887 |
</example> |
| 3888 |
|
| 3889 |
<para>This second method is correct because it would not cause |
| 3890 |
inconsistencies in the index of a batch of ports, provided |
| 3891 |
the batch's options were defined prior to the index's build. |
| 3892 |
This makes it possible to use simple scripts to automate the |
| 3893 |
building, installation, and updating of these ports and |
| 3894 |
their packages.</para> |
| 3895 |
</sect2> |
| 3846 |
</sect1> |
3896 |
</sect1> |
| 3847 |
|
3897 |
|
| 3848 |
<sect1 id="makefile-masterdir"> |
3898 |
<sect1 id="makefile-masterdir"> |