This repository has been archived on 2025-12-24. You can view files and clone it, but you cannot make any changes to it's state, such as pushing and creating new issues, pull requests or comments.
yachat/qcm/openssl.qcm

95 lines
2.1 KiB
Text
Raw Normal View History

2025-12-25 01:37:49 +05:00
/*
-----BEGIN QCMOD-----
name: OpenSSL (bundled QCA only)
arg: with-openssl-inc=[path],Path to OpenSSL include files (bundled QCA only)
arg: with-openssl-lib=[path],Path to OpenSSL library files (bundled QCA only)
-----END QCMOD-----
*/
class qc_openssl : public ConfObj
{
public:
qc_openssl(Conf *c) : ConfObj(c) {}
QString name() const { return "OpenSSL"; }
QString shortname() const { return "openssl"; }
QString checkString() const {
if (!QFile::exists("third-party/qca/qca") || !conf->getenv("QC_DISABLE_bundled_qca").isEmpty())
return "";
else
return ConfObj::checkString();
}
bool exec()
{
if (!QFile::exists("third-party/qca/qca") || !conf->getenv("QC_DISABLE_bundled_qca").isEmpty() || !QFile::exists("third-party/qca/qca-ossl"))
return false;
QString inc, lib;
QString s;
bool kb = false;
QString kbdir = "/usr/kerberos/include";
// Redhat 9?
if(QFileInfo(kbdir).exists())
kb = true;
s = conf->getenv("QC_WITH_OPENSSL_INC");
if(!s.isEmpty()) {
if(!conf->checkHeader(s, "openssl/ssl.h"))
return false;
inc = s;
}
else {
if(!conf->findHeader("openssl/ssl.h", QStringList(), &s))
return false;
inc = s;
}
s = conf->getenv("QC_WITH_OPENSSL_LIB");
if(!s.isEmpty()) {
if(!conf->checkLibrary(s, "ssl"))
return false;
lib = s;
}
else {
if(!conf->findLibrary("ssl", &s))
return false;
lib = s;
}
// is it at least openssl 0.9.7?
QString str =
"#include<openssl/opensslv.h>\n"
"int main()\n"
"{\n"
" unsigned long x = OPENSSL_VERSION_NUMBER;\n"
" if(x >= 0x00907000) return 0; else return 1;\n"
"}\n";
QString ext;
QStringList incs;
if(!inc.isEmpty())
incs += inc;
if(kb)
incs += kbdir;
if(!lib.isEmpty())
ext += QString("-L") + lib + " -lssl -lcrypto ";
int ret;
if(!conf->doCompileAndLink(str, incs, ext, QString(), &ret))
return false;
if(ret == 0)
conf->addDefine("OSSL_097");
if(!inc.isEmpty())
conf->addIncludePath(inc);
if(kb)
conf->addIncludePath(kbdir);
if(!lib.isEmpty())
conf->addLib(QString("-L") + s);
conf->addLib("-lssl -lcrypto");
conf->addDefine("HAVE_OPENSSL");
return true;
}
};