@@ -43,6 +43,7 @@ cc = meson.get_compiler('c')
43
43
44
44
not_found_dep = dependency ('' , required : false )
45
45
thread_dep = dependency (' threads' )
46
+ auto_features = get_option (' auto_features' )
46
47
47
48
48
49
@@ -1171,7 +1172,16 @@ cdata.set('USE_SYSTEMD', systemd.found() ? 1 : false)
1171
1172
# Library: SSL
1172
1173
###############################################################
1173
1174
1174
- if get_option (' ssl' ) == ' openssl'
1175
+ ssl = not_found_dep
1176
+ ssl_library = ' none'
1177
+ sslopt = get_option (' ssl' )
1178
+
1179
+ if sslopt == ' auto' and auto_features.disabled()
1180
+ sslopt = ' none'
1181
+ endif
1182
+
1183
+ if sslopt in [' auto' , ' openssl' ]
1184
+ openssl_required = (sslopt == ' openssl' )
1175
1185
1176
1186
# Try to find openssl via pkg-config et al, if that doesn't work
1177
1187
# (e.g. because it's provided as part of the OS, like on FreeBSD), look for
@@ -1193,58 +1203,70 @@ if get_option('ssl') == 'openssl'
1193
1203
1194
1204
ssl = declare_dependency (dependencies : ssl_int,
1195
1205
include_directories : postgres_inc)
1196
- else
1197
- cc.has_header(' openssl/ssl.h' , args : test_c_args, dependencies : ssl, required : true )
1198
- cc.has_header(' openssl/err.h' , args : test_c_args, dependencies : ssl, required : true )
1199
-
1206
+ elif cc.has_header(' openssl/ssl.h' , args : test_c_args, dependencies : ssl, required : openssl_required) and \
1207
+ cc.has_header(' openssl/err.h' , args : test_c_args, dependencies : ssl, required : openssl_required)
1200
1208
ssl_int = [ssl]
1201
1209
endif
1202
1210
1203
- check_funcs = [
1204
- [' CRYPTO_new_ex_data' , {' required' : true }],
1205
- [' SSL_new' , {' required' : true }],
1206
-
1207
- # Function introduced in OpenSSL 1.0.2.
1208
- [' X509_get_signature_nid' ],
1209
-
1210
- # Functions introduced in OpenSSL 1.1.0. We used to check for
1211
- # OPENSSL_VERSION_NUMBER, but that didn't work with 1.1.0, because LibreSSL
1212
- # defines OPENSSL_VERSION_NUMBER to claim version 2.0.0, even though it
1213
- # doesn't have these OpenSSL 1.1.0 functions. So check for individual
1214
- # functions.
1215
- [' OPENSSL_init_ssl' ],
1216
- [' BIO_get_data' ],
1217
- [' BIO_meth_new' ],
1218
- [' ASN1_STRING_get0_data' ],
1219
- [' HMAC_CTX_new' ],
1220
- [' HMAC_CTX_free' ],
1221
-
1222
- # OpenSSL versions before 1.1.0 required setting callback functions, for
1223
- # thread-safety. In 1.1.0, it's no longer required, and CRYPTO_lock()
1224
- # function was removed.
1225
- [' CRYPTO_lock' ],
1226
-
1227
- # Function introduced in OpenSSL 1.1.1
1228
- [' X509_get_signature_info' ],
1229
- ]
1211
+ if ssl.found()
1212
+ check_funcs = [
1213
+ [' CRYPTO_new_ex_data' , {' required' : true }],
1214
+ [' SSL_new' , {' required' : true }],
1215
+
1216
+ # Function introduced in OpenSSL 1.0.2.
1217
+ [' X509_get_signature_nid' ],
1218
+
1219
+ # Functions introduced in OpenSSL 1.1.0. We used to check for
1220
+ # OPENSSL_VERSION_NUMBER, but that didn't work with 1.1.0, because LibreSSL
1221
+ # defines OPENSSL_VERSION_NUMBER to claim version 2.0.0, even though it
1222
+ # doesn't have these OpenSSL 1.1.0 functions. So check for individual
1223
+ # functions.
1224
+ [' OPENSSL_init_ssl' ],
1225
+ [' BIO_get_data' ],
1226
+ [' BIO_meth_new' ],
1227
+ [' ASN1_STRING_get0_data' ],
1228
+ [' HMAC_CTX_new' ],
1229
+ [' HMAC_CTX_free' ],
1230
+
1231
+ # OpenSSL versions before 1.1.0 required setting callback functions, for
1232
+ # thread-safety. In 1.1.0, it's no longer required, and CRYPTO_lock()
1233
+ # function was removed.
1234
+ [' CRYPTO_lock' ],
1235
+
1236
+ # Function introduced in OpenSSL 1.1.1
1237
+ [' X509_get_signature_info' ],
1238
+ ]
1239
+
1240
+ are_openssl_funcs_complete = true
1241
+ foreach c : check_funcs
1242
+ func = c.get(0 )
1243
+ val = cc.has_function(func, args : test_c_args, dependencies : ssl_int)
1244
+ required = c.get(1 , {}).get(' required' , false )
1245
+ if required and not val
1246
+ are_openssl_funcs_complete = false
1247
+ if openssl_required
1248
+ error (' openssl function @0@ is required' .format(func))
1249
+ endif
1250
+ break
1251
+ elif not required
1252
+ cdata.set(' HAVE_' + func.to_upper(), val ? 1 : false )
1253
+ endif
1254
+ endforeach
1230
1255
1231
- foreach c : check_funcs
1232
- func = c.get( 0 )
1233
- val = cc.has_function(func, args : test_c_args, dependencies : ssl_int )
1234
- required = c.get( 1 , {}).get( ' required ' , false )
1235
- if required and not val
1236
- error ( ' openssl function @0@ is required ' .format(func))
1237
- elif not required
1238
- cdata.set( ' HAVE_ ' + func.to_upper(), val ? 1 : false )
1256
+ if are_openssl_funcs_complete
1257
+ cdata.set( ' USE_OPENSSL ' , 1 ,
1258
+ description : ' Define to 1 to build with OpenSSL support. (-Dssl=openssl) ' )
1259
+ cdata.set( ' OPENSSL_API_COMPAT ' , ' 0x10001000L ' ,
1260
+ description : ''' Define to the OpenSSL API version in use. This avoids deprecation warnings from newer OpenSSL versions. ''' )
1261
+ ssl_library = ' openssl '
1262
+ else
1263
+ ssl = not_found_dep
1239
1264
endif
1240
- endforeach
1265
+ endif
1266
+ endif
1241
1267
1242
- cdata.set(' USE_OPENSSL' , 1 ,
1243
- description : ' Define to 1 to build with OpenSSL support. (-Dssl=openssl)' )
1244
- cdata.set(' OPENSSL_API_COMPAT' , ' 0x10001000L' ,
1245
- description : ''' Define to the OpenSSL API version in use. This avoids deprecation warnings from newer OpenSSL versions.''' )
1246
- else
1247
- ssl = not_found_dep
1268
+ if sslopt == ' auto' and auto_features.enabled() and not ssl.found()
1269
+ error (' no SSL library found' )
1248
1270
endif
1249
1271
1250
1272
@@ -3266,13 +3288,13 @@ if meson.version().version_compare('>=0.57')
3266
3288
' llvm' : llvm,
3267
3289
' lz4' : lz4,
3268
3290
' nls' : libintl,
3291
+ ' openssl' : ssl,
3269
3292
' pam' : pam,
3270
3293
' plperl' : perl_dep,
3271
3294
' plpython' : python3_dep,
3272
3295
' pltcl' : tcl_dep,
3273
3296
' readline' : readline,
3274
3297
' selinux' : selinux,
3275
- ' ssl' : ssl,
3276
3298
' systemd' : systemd,
3277
3299
' uuid' : uuid,
3278
3300
' zlib' : zlib,
0 commit comments