Configuring 'RUN_DEPENDS'

Dmitry Marakasov amdmi3 at
Tue Mar 3 07:38:22 PST 2009

* Jerry (gesbbb at wrote:
> A port I am creating has a RUN_DEPENDS of either 'curl' or 'wget'. I
> have tried several times to write some sort of test in the make file to
> determine if one or the other were installed, and if neither then to
> install 'curl'. I suppose I could create an OPTIONS to install one or
> the other; however, I have not gotten that to work correctly either.

You'll need something like this:

.include <>

.if exists(${LOCALBASE}/bin/wget) && !exists(${LOCALBASE}/bin/curl)
RUN_DEPENDS+=	wget:${PORTSDIR}/ftp/wget
RUN_DEPENDS+=	curl:${PORTSDIR}/ftp/curl

You should be careful though to match this with your program's logic.
I.e. `what does it do if both wget and curl are installed?' The above
case is for `it uses curl then' answer.

> The port will also require Clamav, either the standard port or the
> devel one. Therefore I have two run dependencies to adjust.

No, you don't. clamav and clamav-devel are conflicting ports that
install the same files, so should you depend on clamav as

RUN_DEPENDS=	clamscan:${PORTSDIR}/security/clamav
LIB_DEPENDS=	clamav:${PORTSDIR}/security/clamav

if clamav-devel is installed instead, dependency will still match it and
it'll be used. Note `clamav', not `clamav.5' in LIB_DEPENDS.

> I tried Googling and the Porters Handbook, but I cannot find what I am
> looking for. Is it possible? I assume it must be. A regular 'if' or
> 'case' statement I would normally use does not work in a make file.

>From my experience, the best source for digging examples of such
nontrivial cases are Makefiles for other ports. grep'ping portstree
is too slow, so it's better to create an index like that:

find -L /usr/ports -name Makefile -maxdepth 3 -mindepth 3 -exec grep -H '' {} \; > MAKEFILES.INDEX

Dmitry Marakasov   .   55B5 0596 FF1E 8D84 5F56  9510 D35A 80DD F9D2 F77D
amdmi3 at  ..:  jabber: amdmi3 at

More information about the freebsd-ports mailing list