/*
-----BEGIN QCMOD-----
name: Cyrus SASL2
arg: with-sasl-inc=[path],Path to Cyrus SASL2 include files
arg: with-sasl-lib=[path],Path to Cyrus SASL2 library files
-----END QCMOD-----
*/
class qc_cyrussasl : public ConfObj
{
public:
	qc_cyrussasl(Conf *c) : ConfObj(c) {}
	QString name() const { return "Cyrus SASL2"; }
	QString shortname() const { return "cyrussasl"; }
	bool exec()
	{
		QString inc, lib;
		QString s;

		s = conf->getenv("QC_WITH_SASL_INC");
		if(!s.isEmpty()) {
			if(!conf->checkHeader(s, "sasl/sasl.h"))
				return false;
			inc = s;
		}
		else {
			if(!conf->findHeader("sasl/sasl.h", QStringList(), &s))
				return false;
			inc = s;
		}

		s = conf->getenv("QC_WITH_SASL_LIB");
		if(!s.isEmpty()) {
			if(!conf->checkLibrary(s, "sasl2"))
				return false;
			lib = s;
		}
		else {
			if(!conf->findLibrary("sasl2", &s))
				return false;
			lib = s;
		}

		if(!inc.isEmpty())
			conf->addIncludePath(inc);
		if(!lib.isEmpty())
			conf->addLib(QString("-L") + s);
		conf->addLib("-lsasl2");
		return true;
	}
};
