Repository: spack/spack

Issue:
Installation issue: curl
### Steps to reproduce the issue

```
spack --env-dir utils/spack/redshift install curl
```

The newest version of `curl` (7.78) does not build on macOS any more. Version 7.76.1 built fine.

The error message is
```
1 error found in build log:
     38    checking for nawk... no
     39    checking for awk... awk
     40    checking whether make sets $(MAKE)... yes
     41    checking whether make supports the include directive... yes (GNU style)
     42    checking dependency style of /Users/eschnett/src/spack/lib/spack/env/clang/clang... gcc3
     43    checking curl version... 7.78.0
  >> 44    configure: error: select TLS backend(s) or disable TLS with --without-ssl.
     45
     46    Select from these:
     47
     48      --with-amissl
     49      --with-bearssl
     50      --with-gnutls
```

### Information on your system

```
$ spack debug report
* **Spack:** 0.16.2-3997-37a1885deb
* **Python:** 3.8.2
* **Platform:** darwin-bigsur-skylake
* **Concretizer:** original
```

### Additional information

[spack-build-out.txt](https://github.com/spack/spack/files/7024382/spack-build-out.txt)
[spack-build-env.txt](https://github.com/spack/spack/files/7024383/spack-build-env.txt)
[spack.lock.txt](https://github.com/spack/spack/files/7024389/spack.lock.txt)


### General information

- [X] I have run `spack debug report` and reported the version of Spack/Python/Platform
- [X] I have run `spack maintainers <name-of-the-package>` and **@mentioned** any maintainers
- [X] I have uploaded the build log and environment files
- [X] I have searched the issues of this repo and believe this is not a duplicate


Discussion:

Resolving patch:
diff --git a/var/spack/repos/builtin/packages/curl/package.py b/var/spack/repos/builtin/packages/curl/package.py
--- a/var/spack/repos/builtin/packages/curl/package.py
+++ b/var/spack/repos/builtin/packages/curl/package.py
@@ -45,10 +45,29 @@ class Curl(AutotoolsPackage):
     version('7.43.0', sha256='baa654a1122530483ccc1c58cc112fec3724a82c11c6a389f1e6a37dc8858df9')
     version('7.42.1', sha256='e2905973391ec2dfd7743a8034ad10eeb58dab8b3a297e7892a41a7999cac887')
 
+    default_tls = 'openssl'
+    if sys.platform == 'darwin':
+        default_tls = 'secure_transport'
+
+    # TODO: add dependencies for other possible TLS backends
+    values_tls = [
+        # 'amissl',
+        # 'bearssl',
+        'gnutls',
+        'mbedtls',
+        # 'mesalink',
+        'nss',
+        'openssl',
+        # 'rustls',
+        # 'schannel',
+        'secure_transport',
+        # 'wolfssl',
+    ]
+
+    variant('tls', default=default_tls, description='TLS backend', values=values_tls, multi=True)
     variant('nghttp2',    default=False, description='build nghttp2 library (requires C++11)')
     variant('libssh2',    default=False, description='enable libssh2 support')
     variant('libssh',     default=False, description='enable libssh support')  # , when='7.58:')
-    variant('darwinssl',  default=sys.platform == 'darwin', description="use Apple's SSL/TLS implementation")
     variant('gssapi',     default=False, description='enable Kerberos support')
     variant('librtmp',    default=False, description='enable Rtmp support')
     variant('ldap',       default=False, description='enable ldap support')
@@ -62,9 +81,14 @@ class Curl(AutotoolsPackage):
     # C.f. https://github.com/spack/spack/issues/7777
     conflicts('platform=darwin', when='+libssh2')
     conflicts('platform=darwin', when='+libssh')
-    conflicts('platform=linux', when='+darwinssl')
+    conflicts('platform=cray', when='tls=secure_transport', msg='Only supported on macOS')
+    conflicts('platform=linux', when='tls=secure_transport', msg='Only supported on macOS')
+    conflicts('tls=mbedtls', when='@:7.45')
 
-    depends_on('openssl', when='~darwinssl')
+    depends_on('gnutls', when='tls=gnutls')
+    depends_on('mbedtls', when='tls=mbedtls')
+    depends_on('nss', when='tls=nss')
+    depends_on('openssl', when='tls=openssl')
     depends_on('libidn2', when='+libidn2')
     depends_on('zlib')
     depends_on('nghttp2', when='+nghttp2')
@@ -91,16 +115,12 @@ def configure_args(self):
         if spec.satisfies('@:7.77'):
             args.append('--without-libmetalink')
 
-        if spec.satisfies('+darwinssl'):
-            args.append('--with-darwinssl')
-        else:
-            args.append('--with-ssl=' + spec['openssl'].prefix)
-
         if spec.satisfies('+gssapi'):
             args.append('--with-gssapi=' + spec['krb5'].prefix)
         else:
             args.append('--without-gssapi')
 
+        args += self.with_or_without('tls')
         args += self.with_or_without('libidn2', 'prefix')
         args += self.with_or_without('librtmp')
         args += self.with_or_without('nghttp2')
@@ -108,3 +128,46 @@ def configure_args(self):
         args += self.with_or_without('libssh')
         args += self.enable_or_disable('ldap')
         return args
+
+    def with_or_without_gnutls(self, activated):
+        if activated:
+            return '--with-gnutls=' + self.spec['gnutls'].prefix
+        else:
+            return '--without-gnutls'
+
+    def with_or_without_mbedtls(self, activated):
+        if self.spec.satisfies('@7.46:'):
+            if activated:
+                return '--with-mbedtls=' + self.spec['mbedtls'].prefix
+            else:
+                return '--without-mbedtls'
+
+    def with_or_without_nss(self, activated):
+        if activated:
+            return '--with-nss=' + self.spec['nss'].prefix
+        else:
+            return '--without-nss'
+
+    def with_or_without_openssl(self, activated):
+        if self.spec.satisfies('@7.77:'):
+            if activated:
+                return '--with-openssl=' + self.spec['openssl'].prefix
+            else:
+                return '--without-openssl'
+        else:
+            if activated:
+                return '--with-ssl=' + self.spec['openssl'].prefix
+            else:
+                return '--without-ssl'
+
+    def with_or_without_secure_transport(self, activated):
+        if self.spec.satisfies('@7.65:'):
+            if activated:
+                return '--with-secure-transport'
+            else:
+                return '--without-secure-transport'
+        else:
+            if activated:
+                return '--with-darwinssl'
+            else:
+                return '--without-darwinssl'


Test patch: