TLS plugin for the TQt Cryptographic Architecture
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

81 lines
1.7KB

  1. /*
  2. -----BEGIN QCMOD-----
  3. name: OpenSSL
  4. arg: with-openssl-inc=[path],Path to OpenSSL include files
  5. arg: with-openssl-lib=[path],Path to OpenSSL library files
  6. -----END QCMOD-----
  7. */
  8. class qc_openssl : public ConfObj
  9. {
  10. public:
  11. qc_openssl(Conf *c) : ConfObj(c) {}
  12. QString name() const { return "OpenSSL"; }
  13. QString shortname() const { return "openssl"; }
  14. bool exec()
  15. {
  16. QString inc, lib;
  17. QString s;
  18. bool kb = false;
  19. QString kbdir = "/usr/kerberos/include";
  20. // Redhat 9?
  21. if(QFileInfo(kbdir).exists())
  22. kb = true;
  23. s = conf->getenv("QC_WITH_OPENSSL_INC");
  24. if(!s.isEmpty()) {
  25. if(!conf->checkHeader(s, "openssl/ssl.h"))
  26. return false;
  27. inc = s;
  28. }
  29. else {
  30. if(!conf->findHeader("openssl/ssl.h", QStringList(), &s))
  31. return false;
  32. inc = s;
  33. }
  34. s = conf->getenv("QC_WITH_OPENSSL_LIB");
  35. if(!s.isEmpty()) {
  36. if(!conf->checkLibrary(s, "ssl"))
  37. return false;
  38. lib = s;
  39. }
  40. else {
  41. if(!conf->findLibrary("ssl", &s))
  42. return false;
  43. lib = s;
  44. }
  45. // is it at least openssl 0.9.7?
  46. QString str =
  47. "#include<openssl/opensslv.h>\n"
  48. "int main()\n"
  49. "{\n"
  50. " unsigned long x = OPENSSL_VERSION_NUMBER;\n"
  51. " if(x >= 0x00907000) return 0; else return 1;\n"
  52. "}\n";
  53. QString ext;
  54. if(!inc.isEmpty())
  55. ext += QString("-I") + inc + ' ';
  56. if(kb)
  57. ext += QString("-I") + kbdir + ' ';
  58. if(!lib.isEmpty())
  59. ext += QString("-L") + lib + " -lssl -lcrypto ";
  60. int ret;
  61. if(!conf->doCompileAndLink(str, ext, &ret))
  62. return false;
  63. if(ret == 0)
  64. conf->addDefine("OSSL_097");
  65. if(!inc.isEmpty())
  66. conf->addIncludePath(inc);
  67. if(kb)
  68. conf->addIncludePath(kbdir);
  69. if(!lib.isEmpty())
  70. conf->addLib(QString("-L") + s);
  71. conf->addLib("-lssl -lcrypto");
  72. return true;
  73. }
  74. };