goahead-openssl.me 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107
  1. /*
  2. goahead-openssl.me -- OpenSSL Component for GoAhead
  3. */
  4. Me.load({
  5. targets: {
  6. openssl: {
  7. description: 'OpenSSL Support',
  8. config: function (target) {
  9. if (me.options.gen) {
  10. let result = {
  11. /*
  12. Static configuration to work for standard installations under /usr/lib and /usr/include
  13. and in a custom user directory.
  14. */
  15. includes: [ me.dir.inc ],
  16. libraries: me.platform.os == 'windows' ?
  17. ([ 'gdi32', 'libeay32', 'ssleay32' ]) : ([ 'ssl', 'crypto' ]),
  18. }
  19. if (me.options.gen == 'make') {
  20. result.defines = ['ME_COM_OPENSSL_PATH=/usr/lib']
  21. } else if (me.options.gen == 'nmake') {
  22. result.defines = ['ME_COM_OPENSSL_PATH=']
  23. }
  24. if (me.options.gen == 'make' || me.options.gen == 'nmake' || me.options.gen == 'xcode') {
  25. result.includes.push('$(ME_COM_OPENSSL_PATH)/include')
  26. result.libpaths = ['$(ME_COM_OPENSSL_PATH)']
  27. }
  28. return result
  29. }
  30. let lib, libraries, libpaths, imports, includes, path
  31. let search = getComponentSearch(target, 'openssl')
  32. if (me.platform.os == 'windows') {
  33. search = search.map(function(p:Path) p.join('out32')) +
  34. search.map(function(p:Path) p.join('out32dll'))
  35. lib = probe('libeay32.lib', {fullpath: true, search: search, nopath: true})
  36. path = lib.dirname.parent
  37. libpaths = [ lib.parent ]
  38. libraries = [ 'gdi32', 'libeay32', 'ssleay32' ]
  39. imports = [ lib.parent.join('libeay32.lib'), lib.parent.join('ssleay32.lib') ]
  40. if (lib.dirname == 'out32dll') {
  41. imports += [ lib.parent.join('libeay32.dll'), lib.parent.join('ssleay32.dll') ]
  42. }
  43. includes = [ probe('openssl/ssl.h', {search: [path.join('inc32')]}) ]
  44. } else {
  45. let opt = {fullpath: true, search: search, nopath: true}
  46. let inc, lib
  47. if ((lib = probe('libcrypto.' + me.ext.shobj, blend({nothrow: true}, opt))) != null) {
  48. let isearch = [ lib.dirname.join('include') ]
  49. if (!me.platform.cross) {
  50. isearch.push('/usr/include')
  51. }
  52. inc = probe('openssl/ssl.h', {search: isearch, nothrow: true})
  53. }
  54. if (!lib || !inc) {
  55. lib = probe('libcrypto.' + me.ext.lib, opt)
  56. let isearch = [ lib.dirname.join('include') ]
  57. if (!me.platform.cross) {
  58. isearch.push('/usr/include')
  59. }
  60. inc = probe('openssl/ssl.h', {search: isearch})
  61. }
  62. includes = [ inc ]
  63. libraries = [ 'ssl', 'crypto' ]
  64. libpaths = [ lib.parent ]
  65. imports = lib.parent.files('libssl.*' + lib.extension + '*') +
  66. lib.parent.files('libcrypto.*' + lib.extension + '*')
  67. path = lib.dirname
  68. }
  69. includes.push(me.dir.inc)
  70. return {
  71. location: path,
  72. imports: imports,
  73. includes: includes,
  74. libpaths: libpaths,
  75. libraries, libraries,
  76. }
  77. },
  78. ifdef: [ 'ssl' ],
  79. conflicts: [ 'est', 'matrixssl', 'nanossl' ],
  80. depends: [ 'libgoahead-openssl' ],
  81. },
  82. 'libgoahead-openssl': {
  83. description: 'GoAhead OpenSSL Interface',
  84. type: 'lib',
  85. static: true,
  86. path: '${BIN}/libgoahead-openssl${ARLIB}',
  87. ifdef: [ 'openssl' ],
  88. sources: [ '*.c' ],
  89. postresolve: `
  90. let target = me.target
  91. let openssl = me.targets.openssl
  92. target.includes += openssl.includes
  93. target.libpaths += openssl.libpaths
  94. target.libraries += openssl.libraries
  95. if (me.platform.os == 'macosx') {
  96. target.compiler.push('-Wno-deprecated-declarations')
  97. }
  98. `
  99. }
  100. }
  101. })