| 1 |
#!/bin/bash |
| 2 |
# |
| 3 |
# libcurl support, with installer |
| 4 |
# |
| 5 |
# Usage: |
| 6 |
# mkl_require libcurl |
| 7 |
# |
| 8 |
# And then call the following function from the correct place/order in checks: |
| 9 |
# mkl_check libcurl |
| 10 |
# |
| 11 |
|
| 12 |
mkl_toggle_option "Feature" ENABLE_CURL "--enable-curl" "Enable HTTP client (using libcurl)" "try" |
| 13 |
|
| 14 |
function manual_checks { |
| 15 |
case "$ENABLE_CURL" in |
| 16 |
n) return 0 ;; |
| 17 |
y) local action=fail ;; |
| 18 |
try) local action=disable ;; |
| 19 |
*) mkl_err "mklove internal error: invalid value for ENABLE_CURL: $ENABLE_CURL"; exit 1 ;; |
| 20 |
esac |
| 21 |
|
| 22 |
mkl_meta_set "libcurl" "apk" "curl-dev curl-static" |
| 23 |
mkl_meta_set "libcurl" "deb" "libcurl4-openssl-dev" |
| 24 |
mkl_meta_set "libcurl" "static" "libcurl.a" |
| 25 |
if [[ $MKL_DISTRO == "osx" && $WITH_STATIC_LINKING ]]; then |
| 26 |
mkl_env_append LDFLAGS "-framework CoreFoundation -framework SystemConfiguration" |
| 27 |
mkl_mkvar_append "libcurl" MKL_PKGCONFIG_LIBS_PRIVATE "-framework CoreFoundation -framework SystemConfiguration" |
| 28 |
fi |
| 29 |
mkl_lib_check "libcurl" "WITH_CURL" $action CC "-lcurl" \ |
| 30 |
" |
| 31 |
#include <curl/curl.h> |
| 32 |
|
| 33 |
void foo (void) { |
| 34 |
curl_global_init(CURL_GLOBAL_DEFAULT); |
| 35 |
} |
| 36 |
" |
| 37 |
} |
| 38 |
|
| 39 |
|
| 40 |
# Install curl from source tarball |
| 41 |
# |
| 42 |
# Param 1: name (libcurl) |
| 43 |
# Param 2: install-dir-prefix (e.g., DESTDIR) |
| 44 |
# Param 2: version (optional) |
| 45 |
function install_source { |
| 46 |
local name=$1 |
| 47 |
local destdir=$2 |
| 48 |
local ver=8.20.0 |
| 49 |
local checksum="fc5819cad3f9f5482669adcdc49a782c15f36d2a0715b395b06d9173593d2dc0" |
| 50 |
|
| 51 |
echo "### Installing $name $ver from source to $destdir" |
| 52 |
if [[ ! -f Makefile ]]; then |
| 53 |
mkl_download_archive \ |
| 54 |
"https://curl.se/download/curl-${ver}.tar.gz" \ |
| 55 |
256 \ |
| 56 |
$checksum || return 1 |
| 57 |
fi |
| 58 |
|
| 59 |
# curl's configure has a runtime check where a program is built |
| 60 |
# with all libs linked and then executed, since mklove's destdir |
| 61 |
# is outside the standard ld.so search path this runtime check will |
| 62 |
# fail due to missing libraries. |
| 63 |
# We patch curl's configure file to skip this check altogether. |
| 64 |
if ! mkl_patch libcurl 0000 ; then |
| 65 |
return 1 |
| 66 |
fi |
| 67 |
|
| 68 |
# Clear out LIBS to not interfer with lib detection process. |
| 69 |
LIBS="" ./configure \ |
| 70 |
--with-openssl \ |
| 71 |
--enable-static \ |
| 72 |
--disable-shared \ |
| 73 |
--disable-ntlm{,-wb} \ |
| 74 |
--disable-dict \ |
| 75 |
--disable-ftp \ |
| 76 |
--disable-file \ |
| 77 |
--disable-gopher \ |
| 78 |
--disable-imap \ |
| 79 |
--disable-mqtt \ |
| 80 |
--disable-pop3 \ |
| 81 |
--disable-rtsp \ |
| 82 |
--disable-smb \ |
| 83 |
--disable-smtp \ |
| 84 |
--disable-telnet \ |
| 85 |
--disable-tftp \ |
| 86 |
--disable-manual \ |
| 87 |
--disable-ldap{,s} \ |
| 88 |
--disable-libcurl-option \ |
| 89 |
--without-{librtmp,libidn2,winidn,nghttp2,nghttp3,ngtcp2,quiche,brotli,libpsl} && |
| 90 |
time make -j && |
| 91 |
make DESTDIR="${destdir}" prefix=/usr install |
| 92 |
local ret=$? |
| 93 |
|
| 94 |
if [[ $MKL_DISTRO == osx ]]; then |
| 95 |
mkl_mkvar_append "libcurl" LIBS "-framework CoreFoundation -framework SystemConfiguration" |
| 96 |
fi |
| 97 |
|
| 98 |
return $ret |
| 99 |
} |