Subject: Re: Alternatives in the same package
To: Mike M. Volokhov <mishka@apk.od.ua>
From: Quentin Garnier <cube@cubidou.net>
List: tech-pkg
Date: 04/20/2005 16:23:36
--/mvwczta11gu4fnM
Content-Type: text/plain; charset=us-ascii
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Wed, Apr 20, 2005 at 04:34:18PM +0300, Mike M. Volokhov wrote:
> > You can test on ${PKG_OPTIONS} and then set PKG_FAIL_REASON.
>=20
> It's suboptimal for a big number of mutex options (in this case a
> number of tests will grew up by exponential regression), but it's
> needed very rare. I've asked just for the future.

make(1) doesn't offer the possibility to do such a check easily,
that's for sure.  So wherever is the logic, i.e. in pkgsrc/mk or
not, it will be the same.

When I thought about this for devel/rt3, I wanted to use the :[#]
modifier, but it is not available in 1.6 make.

Now, here's what I'm tempted to commit, knowing that the options
starting with "frontend-" are mutually exclusive, as are the ones
starting with "backend-".  A bit convoluted, but it works.  It
needs a special way of naming options, though, but you can always
add a translation step.

=2Efor _option_ in backend frontend
=2E if empty(PKG_OPTIONS:M${_option_}-*)
PKG_FAIL_REASON+=3D "There must be one ${_option_} defined."
=2E else
_RT_DUMMY:=3D     # empty
=2E  for _dummy_ in ${PKG_OPTIONS:M${_option_}-*}
_RT_DUMMY:=3D     ${_RT_DUMMY}+
=2E  endfor
=2E  if ${_RT_DUMMY} !=3D +
PKG_FAIL_REASON+=3D "There must be no more than one ${_option_} defined."
=2E  endif
=2E endif
=2Eendfor

--=20
Quentin Garnier - cube@cubidou.net - cube@NetBSD.org
"When I find the controls, I'll go where I like, I'll know where I want
to be, but maybe for now I'll stay right here on a silent sea."
KT Tunstall, Silent Sea, Eye to the Telescope, 2004.

--/mvwczta11gu4fnM
Content-Type: application/pgp-signature
Content-Disposition: inline

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.6 (NetBSD)

iQEVAwUBQmZl6NgoQloHrPnoAQJkowgAvndkZMAca69UF46ASdRhjBrrDzc30NtD
+4w/lv/xBBR1IiIecLKvMZrAlKWEnrUCmdDfC0rC07Nn8KRk5qhPk/lkyKd/GUmt
QGHNKZ6ylfblUDsgHBbl8hXCt+puNFwesnKec7zTH6AydDSGJe3qeNmfzW5TtkSj
mA8K5LrQJ+L8vW3sNY//jP9AWZnvpwG3O/D/LS+ug2UuIrnh2Ut2vVt6VI28sXHi
/MkrvqFw8Gpt2t2FQ2sjDhsk7S4bwi5DQZjD11jx8mtmlkG7+laqS6+LZavLnHed
opH8gpnYke8zHVsIel6JikXj3YDwEqkJH0H6+BXXD9ZpVjpEa3Heog==
=Smmm
-----END PGP SIGNATURE-----

--/mvwczta11gu4fnM--