goahead-openssl.me 6.0 KB

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