curl 的 http2 特性需要在編譯時(shí)加入第三方庫(kù) nghttp2 才能開(kāi)啟亏狰,而 nghttp2 又依賴 openssl/boringssl役纹。
編譯 OpenSSL
cd ./openssl
./Configure darwin64-x86_64-cc --prefix=/tmp/openssl no-shared
clean_make
make install
編譯 nghttp2
cd ./nghttp2
autoreconf -i
automake
autoconf
./configure --prefix=/tmp/nghttp2 --disable-shared --enable-static
clean_make
make install
編譯 CURL
cd ./curl
./configure --prefix=/tmp/curl --disable-shared --enable-static --with-ssl=/tmp/openssl --with-nghttp2=/tmp/nghttp2
clean_make
make install
查看一下編譯后的 curl -V,輸出內(nèi)容如下
curl 7.66.0-DEV (x86_64-apple-darwin18.7.0) libcurl/7.66.0-DEV OpenSSL/3.0.0 zlib/1.2.11 nghttp2/1.40.0-DEV
Release-Date: [unreleased]
Protocols: dict file ftp ftps gopher http https imap imaps ldap ldaps pop3 pop3s rtsp smb smbs smtp smtps telnet tftp
Features: AsynchDNS HTTP2 HTTPS-proxy IPv6 Largefile libz NTLM NTLM_WB SSL TLS-SRP UnixSockets
clean_make 是一個(gè)工具方法暇唾,用于加快 make 的速度促脉,代碼如下
CPUNUM=`sysctl -n hw.logicalcpu_max`
clean_make() {
make clean
make -j ${CPUNUM}
}