Variants are a powerful feature of the MacPorts port system that allow users to install ports in other than the default manner, optionally enabling or disabling a feature or building a port with or without a dependency.


In a portfile, you may use the line: default_variants variant1 variant2... to indicate that the port should, by default, build with those variants.

Breaking variants out of the main port into conflicting variants where one variant is the default variant has the benifit of installing the port with the default variant embedded in the version. Consider the following ports:

port Foo

version 1
configure.args --enable-this --enable-that
variant disable_this {
    configure.args_delete --enable-this
    configure.args_append --disable-this

port Bar

version 1
configure.args --enable-that
default_variants +enable_this
variant enable_this conflicts disable_this {
    configure.args_append --enable-this
variant disable_this conflicts enable_this {
    configure.args_append --disable-this

When a user installs port Foo, port Foo installs as version @1_0 while port Bar installs as version @1_0+enable_this. Due to the way port Bar was written, the user knows what variants were applied when the port was installed.

Last modified 11 years ago Last modified on Mar 21, 2007, 1:47:22 AM