Fix static building for 7.78.0
All checks were successful
moparisthebest/static-curl/pipeline/head This commit looks good

This commit is contained in:
Travis Burtrum 2021-07-21 07:33:35 -04:00
parent c86910a3e2
commit 0ab82474d4
2 changed files with 23 additions and 2 deletions

View File

@ -40,8 +40,14 @@ apk add openssl-libs-static zlib-static || true
# gcc is apparantly incapable of building a static binary, even gcc -static helloworld.c ends up linked to libc, instead of solving, use clang # gcc is apparantly incapable of building a static binary, even gcc -static helloworld.c ends up linked to libc, instead of solving, use clang
export CC=clang export CC=clang
# temp patch so it will build statically https://github.com/curl/curl/pull/7476
patch -p1 < ../static.patch
apk add autoconf automake libtool
autoreconf -fi
# end temp patch
# set up any required curl options here # set up any required curl options here
#LDFLAGS="-static" PKG_CONFIG="pkg-config --static" ./configure --disable-shared --enable-static --disable-libcurl-option --without-brotli --disable-manual --disable-unix-sockets --disable-dict --disable-file --disable-gopher --disable-imap --disable-smtp --disable-rtsp --disable-telnet --disable-tftp --disable-pop3 --without-zlib --disable-threaded-resolver --disable-ipv6 --disable-smb --disable-ntlm-wb --disable-tls-srp --disable-crypto-auth --with-ssl #LDFLAGS="-static" PKG_CONFIG="pkg-config --static" ./configure --disable-shared --enable-static --disable-libcurl-option --without-brotli --disable-manual --disable-unix-sockets --disable-dict --disable-file --disable-gopher --disable-imap --disable-smtp --disable-rtsp --disable-telnet --disable-tftp --disable-pop3 --without-zlib --disable-threaded-resolver --disable-ipv6 --disable-smb --disable-ntlm-wb --disable-tls-srp --disable-crypto-auth --without-ngtcp2 --without-nghttp2 --disable-ftp --disable-mqtt --disable-alt-svc --without-ssl
LDFLAGS="-static" PKG_CONFIG="pkg-config --static" ./configure --disable-shared --enable-static --disable-ldap --enable-ipv6 --enable-unix-sockets --with-ssl --with-libssh2 LDFLAGS="-static" PKG_CONFIG="pkg-config --static" ./configure --disable-shared --enable-static --disable-ldap --enable-ipv6 --enable-unix-sockets --with-ssl --with-libssh2
@ -53,7 +59,8 @@ strip src/curl
# print out some info about this, size, and to ensure it's actually fully static # print out some info about this, size, and to ensure it's actually fully static
ls -lah src/curl ls -lah src/curl
file src/curl file src/curl
ldd src/curl || true # exit with error code 1 if the executable is dynamic, not static
ldd src/curl && exit 1 || true
./src/curl -V ./src/curl -V

14
static.patch Normal file
View File

@ -0,0 +1,14 @@
diff --git a/src/Makefile.am b/src/Makefile.am
index 734373187..37e3a1564 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -66,6 +66,9 @@ else
curl_LDADD = $(top_builddir)/lib/libcurl.la @NSS_LIBS@ @SSL_LIBS@ @ZLIB_LIBS@ @CURL_NETWORK_AND_TIME_LIBS@
endif
+curl_LDFLAGS = $(curl_LDFLAGS)
+curl_CPPFLAGS = $(AM_CPPFLAGS)
+
# if unit tests are enabled, build a static library to link them with
if BUILD_UNITTESTS
noinst_LTLIBRARIES = libcurltool.la