/*
-----BEGIN QCMOD-----
name: QCA 2.0
arg: in-tree-build,Build with uninstalled QCA, only useful for SVN users.
-----END QCMOD-----
*/

//----------------------------------------------------------------------------
// qc_qca
//----------------------------------------------------------------------------
class qc_qca : public ConfObj
{
public:
	qc_qca(Conf *c) : ConfObj(c) {}
	QString name() const { return "QCA 2.0"; }
	QString shortname() const { return "qca"; }
	bool exec()
	{
		// test for "crypto" feature and check qca version number
		QString arg;
		arg = conf->getenv("QC_IN_TREE_BUILD");

		QString proextra;
		if (!arg.isEmpty()) {
			proextra =
			"CONFIG += qt \n"
			"QT -= gui\n"
			"INCLUDEPATH += ../../../../include/QtCrypto \n"
			"LIBS += -L../../../../lib -lqca \n";
		} else {
			proextra =
			"CONFIG += qt crypto\n"
			"QT -= gui\n";
		}
		QString str =
		"#include <QtCrypto>\n"
		"\n"
		"int main()\n"
		"{\n"
		"	unsigned long x = QCA_VERSION;\n"
		"	if(x >= 0x020000) return 0; else return 1;\n"
		"}\n";

		int ret;
		if(!conf->doCompileAndLink(str, QStringList(), QString(), proextra, &ret))
			return false;
		if(ret != 0)
			return false;
		if (!arg.isEmpty()) {
			conf->addIncludePath("../../include/QtCrypto");
			conf->addLib("-L../../lib -lqca");
		}
		return true;
	}
};
