1 /*
2  * Copyright (C) 2019 The Android Open Source Project
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  *      http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  */
16 
17 package com.android.ndkports
18 
19 import java.io.File
20 
21 object : AutoconfPort() {
22     override val name = "curl"
23     override val version = "7.66.0"
24     override val url = "https://curl.haxx.se/download/curl-$version.tar.gz"
25     override val licensePath = "COPYING"
26 
27     override val license = License(
28         "The curl License", "https://curl.haxx.se/docs/copyright.html"
29     )
30 
31     override val dependencies = listOf("openssl")
32 
33     override val modules = listOf(
34         Module(
35             "curl",
36             dependencies = listOf("//openssl:crypto", "//openssl:ssl")
37         )
38     )
39 
configureArgsnull40     override fun configureArgs(
41         workingDirectory: File,
42         toolchain: Toolchain
43     ): List<String> {
44         val sslPrefix = installDirectoryForPort(
45             "openssl",
46             workingDirectory,
47             toolchain
48         ).absolutePath
49         return listOf(
50             "--disable-ntlm-wb",
51             "--enable-ipv6",
52             "--with-zlib",
53             "--with-ca-path=/system/etc/security/cacerts",
54             "--with-ssl=$sslPrefix"
55         )
56     }
57 
configureEnvnull58     override fun configureEnv(
59         workingDirectory: File,
60         toolchain: Toolchain
61     ): Map<String, String> = mapOf(
62         // aarch64 still defaults to bfd which transitively checks libraries.
63         // When curl is linking one of its own libraries which depends on
64         // openssl, it doesn't pass -rpath-link to be able to find the SSL
65         // libraries and fails to build because of it.
66         //
67         // TODO: Switch to lld once we're using r21.
68         "LDFLAGS" to "-fuse-ld=gold"
69     )
70 }