diff --git a/en_US.ISO8859-1/books/porters-handbook/book.sgml b/en_US.ISO8859-1/books/porters-handbook/book.sgml index ef614172b5..9597a4fc35 100644 --- a/en_US.ISO8859-1/books/porters-handbook/book.sgml +++ b/en_US.ISO8859-1/books/porters-handbook/book.sgml @@ -3843,6 +3843,56 @@ ALWAYS_KEEP_DISTFILES= yes may be able to save a large number of people—including yourself— a lot of grief in the process. + + + Problems Caused by Automatic Dependencies + + Dependencies must be declared either explicitly or by + using the OPTIONS framework. + Using other methods like automatic detection complicates + indexing, which causes problems for port and package + management. + + + Wrong Declaration of an Optional Dependency + + .include <bsd.port.pre.mk> + +.if exists(${LOCALBASE}/bin/foo) +LIB_DEPENDS= bar:${PORTSDIR}/foo/bar +.endif + + + 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. + + + Correct Declaration of an Optional Dependency + + OPTIONS= BAR "Enable bar support" off + +.include <bsd.port.pre.mk> + +.if defined(WITH_BAR) && !defined(WITHOUT_BAR) +LIB_DEPENDS= bar:${PORTSDIR}/foo/bar +.endif + + + 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. +