ports: how to handle 'alternate' dependencies

Dan Nelson dnelson at allantgroup.com
Sat Sep 12 07:06:57 UTC 2009

In the last episode (Sep 11), John W said:
> I'm just learning the guts of how ports work, and wonder:
> How do ports specify that "any one of X, Y, Z " would satisfy a dependency.
> For instance, when I build graphics/jalbum, it says it requires jdk16.
> I would rather use diablo-jdk16, since I find it faster and it is
> easier to install.
> But how would I alter graphics/jalbum to say, essentially, "either
> jdk16 or diablo-jdk16 is required"
> Generally, how to handle the case when a port requires X, but there are
> multiple implementations of X that can perform the job, and any will
> suffice?  I feel like this issue must come up from time to time, what is
> the right way to deal with it?  I didn't see any mention of this in the
> porters handbook...

This question might be better asked on the freebsd-ports mailing list...

In your specific case, since you're looking at a java port, you have to
follow the rules in /usr/ports/Mk/bsd.java.mk , which let you specify things

  JAVA_VENDOR="freebsd bsdjava"

, to force the use of only Java 1.6 (not 1.5 or 1.7), and only the
source-built or diablo-binary variants.

Many port groups that provide multiple versions of an application either
have special code in bsd.port.mk or have their own bsd.xxx.mk, and they
usually let the port maintainer set WANT_XXX or WITH_XXX variables to prefer
a particular version.  See bsd.gecko.mk and bsd.database.mk for some complex

For the completely general case of two independant ports providing the same
feature your port needs, you can roll your own checks.  To prefer the
playmusic port, but use the playwav port if it's already installed:

.if exists(${LOCALBASE}/bin/playwavfile)

You can also get fancy and use OPTIONS to allow the user to pick their
preferred alternative ports, using ".if exists" checks to pre-select any
already-installed ones.

	Dan Nelson
	dnelson at allantgroup.com

More information about the freebsd-questions mailing list