Re: add support for the old naming libs convention on windows (ssleay32.lib and libeay32.lib) - Mailing list pgsql-hackers

From Darek Ślusarczyk
Subject Re: add support for the old naming libs convention on windows (ssleay32.lib and libeay32.lib)
Date
Msg-id CAHrt6663W9qjpxXsnUbYdGL45xGLMdAjOc9c0TEf50NyFpZxKQ@mail.gmail.com
Whole thread Raw
In response to Re: add support for the old naming libs convention on windows (ssleay32.lib and libeay32.lib)  (Nazir Bilal Yavuz <byavuz81@gmail.com>)
Responses Re: add support for the old naming libs convention on windows (ssleay32.lib and libeay32.lib)
List pgsql-hackers

Hi,

Thanks for reviewing the patch - I've added a few changes and it looks as follows:

diff --git a/meson.build b/meson.build
index e5ce437a5c7..37d4e9ca741 100644
--- a/meson.build
+++ b/meson.build
@@ -1343,14 +1343,41 @@ if sslopt in ['auto', 'openssl']

   # via library + headers
   if not ssl.found()
+    is_windows = host_system == 'windows'
+
+    ssl_lib_common_params = {
+      'dirs': test_lib_d,
+      'header_include_directories': postgres_inc,
+      'has_headers': ['openssl/ssl.h', 'openssl/err.h'],
+    }
     ssl_lib = cc.find_library('ssl',
-      dirs: test_lib_d,
-      header_include_directories: postgres_inc,
-      has_headers: ['openssl/ssl.h', 'openssl/err.h'],
-      required: openssl_required)
+      kwargs: ssl_lib_common_params,
+      required: openssl_required and not is_windows
+    )
+    # before openssl version 1.1.0, there was a different naming convention for libraries on win
+    # the counterpart for libssl.[lib|dll] was ssleay32.[lib|dll]
+    # more details in https://github.com/openssl/openssl/issues/10332#issuecomment-549027653
+    # hence if 'ssl' is not found and it's windows, try 'ssleay32'
+    if not ssl_lib.found() and is_windows
+      ssl_lib = cc.find_library('ssleay32',
+        kwargs: ssl_lib_common_params,
+        required: openssl_required
+      )
+    endif
+
     crypto_lib = cc.find_library('crypto',
       dirs: test_lib_d,
-      required: openssl_required)
+      required: openssl_required and not is_windows)
+    # before openssl version 1.1.0, there was a different naming convention for libraries on win
+    # the counterpart for libcrypto.[lib|dll] was libeay32.[lib|dll]
+    # more details in https://github.com/openssl/openssl/issues/10332#issuecomment-549027653
+    # hence if 'crypto' is not found and it's windows, try 'libeay32'
+    if not crypto_lib.found() and is_windows
+      crypto_lib = cc.find_library('libeay32',
+        dirs: test_lib_d,
+        required: openssl_required)
+    endif
+
     if ssl_lib.found() and crypto_lib.found()
       ssl_int = [ssl_lib, crypto_lib]
       ssl = declare_dependency(dependencies: ssl_int, include_directories: postgres_inc)



btw I also submitted a pull request on GitHub, which can be found here: https://github.com/postgres/postgres/pull/197

thnx,
ds
--
marines() {
    return Darek_Slusarczyk; 

pgsql-hackers by date:

Previous
From: Thomas Munro
Date:
Subject: Re: Meson bug in detection of 64 atomics
Next
From: Noah Misch
Date:
Subject: Re: AIO v2.2