Skip to content

Commit

Permalink
curl: build with cmake
Browse files Browse the repository at this point in the history
  • Loading branch information
MehdiChinoune committed May 29, 2024
1 parent b2fcbb7 commit db8fd75
Show file tree
Hide file tree
Showing 4 changed files with 109 additions and 115 deletions.
58 changes: 26 additions & 32 deletions mingw-w64-curl/0001-Make-cURL-relocatable.patch
Original file line number Diff line number Diff line change
@@ -1,51 +1,45 @@
diff --git a/configure.ac b/configure.ac
index 798fa5f1e..2ed766c0d 100755
--- a/configure.ac
+++ b/configure.ac
@@ -3474,6 +3474,7 @@ if test "xyes" = "x$longlong"; then
])
fi
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -24,6 +24,7 @@
set(LIB_NAME libcurl)
set(LIBCURL_OUTPUT_NAME libcurl CACHE STRING "Basename of the curl library")
add_definitions(-DBUILDING_LIBCURL)
+add_definitions(-DCURL_BINDIR="${CMAKE_INSTALL_PREFIX}/bin")

+AC_DEFINE_UNQUOTED(CURL_BINDIR, "${prefix}/bin", [bindir])
configure_file(curl_config.h.cmake
${CMAKE_CURRENT_BINARY_DIR}/curl_config.h)
--- a/lib/curl_config.h.cmake
+++ b/lib/curl_config.h.cmake
@@ -35,6 +35,9 @@
/* Default SSL backend */
#cmakedefine CURL_DEFAULT_SSL_BACKEND "${CURL_DEFAULT_SSL_BACKEND}"

+/* Location of executable */
+#cmakedefine CURL_BINDIR "${CURL_BINDIR}"
+
/* disables alt-svc */
#cmakedefine CURL_DISABLE_ALTSVC 1

# check for ssize_t
AC_CHECK_TYPE(ssize_t, ,
diff --git a/lib/Makefile.inc b/lib/Makefile.inc
index 69f9b403d..44e2dc039 100644
--- a/lib/Makefile.inc
+++ b/lib/Makefile.inc
@@ -170,6 +170,7 @@
nonblock.c \
@@ -197,6 +197,7 @@
noproxy.c \
openldap.c \
parsedate.c \
+ pathtools.c \
pingpong.c \
pop3.c \
progress.c \
@@ -289,6 +290,7 @@
non-ascii.h \
@@ -333,6 +334,7 @@
nonblock.h \
noproxy.h \
parsedate.h \
+ pathtools.h \
pingpong.h \
pop3.h \
progress.h \
diff --git a/lib/curl_config.h.in b/lib/curl_config.h.in
index 0f2a80403..9bad51f8d 100644
--- a/lib/curl_config.h.in
+++ b/lib/curl_config.h.in
@@ -12,6 +12,9 @@
/* Default SSL backend */
#undef CURL_DEFAULT_SSL_BACKEND

+/* Location of executable */
+#undef CURL_BINDIR
+
/* to disable cookies support */
#undef CURL_DISABLE_COOKIES

--- curl-8.8.0/lib/url.c.orig 2024-05-22 07:55:00.000000000 +0200
+++ curl-8.8.0/lib/url.c 2024-05-22 08:15:11.653046500 +0200
--- a/lib/url.c
+++ b/lib/url.c
@@ -119,6 +119,9 @@
#include "altsvc.h"
#include "dynbuf.h"
Expand Down
10 changes: 10 additions & 0 deletions mingw-w64-curl/0003-enable-soversion-on-mingw.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
--- a/lib/CMakeLists.txt
+++ b/lib/CMakeLists.txt
@@ -72,6 +72,7 @@
if(CMAKE_SYSTEM_NAME STREQUAL "AIX" OR
CMAKE_SYSTEM_NAME STREQUAL "Linux" OR
CMAKE_SYSTEM_NAME STREQUAL "Darwin" OR
+ CMAKE_SYSTEM_NAME STREQUAL "Windows" OR
CMAKE_SYSTEM_NAME STREQUAL "SunOS" OR
CMAKE_SYSTEM_NAME STREQUAL "GNU/kFreeBSD" OR

17 changes: 2 additions & 15 deletions mingw-w64-curl/0004-more-static-fixes.patch
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
diff -urN curl-7.84.0/libcurl.pc.in.orig curl-7.84.0/libcurl.pc.in
--- curl-7.84.0/libcurl.pc.in.orig 2022-06-22 11:49:29.000000000 +0200
+++ curl-7.84.0/libcurl.pc.in 2022-06-30 18:10:26.835823300 +0200
--- a/libcurl.pc.in
+++ b/libcurl.pc.in
@@ -36,6 +36,8 @@
URL: https://curl.se/
Description: Library to transfer files with ftp, http, etc.
Expand All @@ -10,15 +9,3 @@ diff -urN curl-7.84.0/libcurl.pc.in.orig curl-7.84.0/libcurl.pc.in
Libs.private: @LIBCURL_LIBS@
Cflags: -I${includedir} @CPPFLAG_CURL_STATICLIB@
+Cflags.private: -DCURL_STATICLIB
diff -urN curl-7.84.0/configure.ac.orig curl-7.84.0/configure.ac
--- curl-7.84.0/configure.ac.orig 2022-06-30 18:13:08.954675200 +0200
+++ curl-7.84.0/configure.ac 2022-06-30 18:18:29.024823500 +0200
@@ -1914,7 +1914,7 @@

dnl link required libraries for USE_WIN32_CRYPTO or USE_SCHANNEL
if test "x$USE_WIN32_CRYPTO" = "x1" -o "x$USE_SCHANNEL" = "x1"; then
- LIBS="-ladvapi32 -lcrypt32 $LIBS"
+ LIBS="-ladvapi32 -lcrypt32 -lbcrypt $LIBS"
fi

case "x$OPENSSL_ENABLED$GNUTLS_ENABLED$NSS_ENABLED$MBEDTLS_ENABLED$WOLFSSL_ENABLED$SCHANNEL_ENABLED$SECURETRANSPORT_ENABLED$BEARSSL_ENABLED$AMISSL_ENABLED$RUSTLS_ENABLED"
139 changes: 71 additions & 68 deletions mingw-w64-curl/PKGBUILD
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ pkgname=("${MINGW_PACKAGE_PREFIX}-${_realname}"
"${MINGW_PACKAGE_PREFIX}-${_realname}-gnutls" \
"${MINGW_PACKAGE_PREFIX}-${_realname}-winssl"))
pkgver=8.8.0
pkgrel=3
pkgrel=4
pkgdesc="Command line tool and library for transferring data with URLs (mingw-w64)"
arch=('any')
mingw_arch=('mingw32' 'mingw64' 'ucrt64' 'clang64' 'clang32' 'clangarm64')
Expand All @@ -30,7 +30,8 @@ _openssl_depends=("${MINGW_PACKAGE_PREFIX}-openssl"
_gnutls_depends=("${MINGW_PACKAGE_PREFIX}-rtmpdump"
"${MINGW_PACKAGE_PREFIX}-gnutls")
makedepends=("${MINGW_PACKAGE_PREFIX}-cc"
"${MINGW_PACKAGE_PREFIX}-autotools"
"${MINGW_PACKAGE_PREFIX}-cmake"
"${MINGW_PACKAGE_PREFIX}-ninja"
"${_cert_depends[@]}"
"${_openssl_depends[@]}"
$([[ ${CARCH} == i686 ]] || echo "${_gnutls_depends[@]}"))
Expand All @@ -45,13 +46,15 @@ source=("https://github.com/curl/curl/releases/download/${_realname}-${pkgver//.
"pathtools.c"
"pathtools.h"
"0001-Make-cURL-relocatable.patch"
"0003-enable-soversion-on-mingw.patch"
"0004-more-static-fixes.patch")
sha256sums=('0f58bb95fc330c8a46eeb3df5701b0d90c9d9bfcc42bd1cd08791d12551d4400'
'SKIP'
'ebf471173f5ee9c4416c10a78760cea8afaf1a4a6e653977321e8547ce7bf3c0'
'1585ef1b61cf53a2ca27049c11d49e0834683dfda798f03547761375df482a90'
'3651bd543cc574556ccea185bc6b519284ed55792b65b37ebac99a8d85c4b2a0'
'590eb65e90e756eaad993d52a101f29091ada2c742c5a607684e88fc5c560d54')
'4bd59182c6da8679cec015c9fd28fb512cfdc4d2be5fe5904a4955980b4cce93'
'f411ae7662fc67ff52bdc7d42a92e255e52154bb7d06251694802ba8d709319d'
'e1f32a6b03e337f188262b6201980c874138f0524123afb11285d0802451e5b1')
validpgpkeys=('27EDEAF22F3ABCEB50DB9A125CC908FDB71E12C2') # Daniel Stenberg

apply_patch_with_msg() {
Expand All @@ -73,9 +76,8 @@ prepare() {

apply_patch_with_msg \
0001-Make-cURL-relocatable.patch \
0003-enable-soversion-on-mingw.patch \
0004-more-static-fixes.patch

autoreconf -vfi
}

do_build() {
Expand All @@ -86,83 +88,84 @@ do_build() {
_destdir="${_destdir}${_variant}"
fi

local -a extra_config
if check_option "debug" "y"; then
extra_config+=( --enable-debug )
declare -a _extra_config
if check_option "debug" "n"; then
_extra_config+=("-DCMAKE_BUILD_TYPE=Release")
else
extra_config+=( --disable-debug )
_extra_config+=("-DCMAKE_BUILD_TYPE=Debug")
fi

local -a _variant_config
declare -a _variant_config
if [ "${_variant}" = "-winssl" ]; then
_variant_config+=("--with-schannel")
_variant_config+=('--without-nghttp2')
_variant_config+=("--without-ca-bundle")
_variant_config+=("--without-ca-path")
_variant_config+=("--without-librtmp")
_variant_config+=("-DCURL_DEFAULT_SSL_BACKEND=schannel")
_variant_config+=("-DCURL_USE_SCHANNEL=ON")
_variant_config+=('-DUSE_NGHTTP2=OFF')
_variant_config+=("-DCURL_CA_BUNDLE=none")
_variant_config+=("-DCURL_CA_PATH=none")
_variant_config+=("-DUSE_LIBRTMP=OFF")
elif [ "${_variant}" = "-gnutls" ]; then
_variant_config+=("--with-default-ssl-backend=gnutls")
_variant_config+=("--with-gnutls")
_variant_config+=("--with-schannel")
_variant_config+=('--without-nghttp2')
_variant_config+=("--with-ca-bundle=${MINGW_PREFIX}/etc/ssl/certs/ca-bundle.crt")
_variant_config+=("--with-librtmp")
_variant_config+=("-DCURL_DEFAULT_SSL_BACKEND=gnutls")
_variant_config+=("-DCURL_USE_GNUTLS=ON")
_variant_config+=("-DCURL_USE_SCHANNEL=ON")
_variant_config+=('-DUSE_NGHTTP2=OFF')
_variant_config+=("-DCURL_CA_BUNDLE=${MINGW_PREFIX}/etc/ssl/certs/ca-bundle.crt")
_variant_config+=("-DUSE_LIBRTMP=ON")
elif [ "${_variant}" = "-openssl" ]; then
_variant_config+=("--with-default-ssl-backend=openssl")
_variant_config+=("--with-openssl")
_variant_config+=("--with-ca-bundle=${MINGW_PREFIX}/etc/ssl/certs/ca-bundle.crt")
_variant_config+=("--with-nghttp2=${MINGW_PREFIX}")
_variant_config+=("--without-librtmp")
_variant_config+=("-DCURL_DEFAULT_SSL_BACKEND=openssl")
_variant_config+=("-DCURL_USE_OPENSSL=ON")
_variant_config+=("-DCURL_CA_BUNDLE=${MINGW_PREFIX}/etc/ssl/certs/ca-bundle.crt")
_variant_config+=("-DUSE_NGHTTP2=ON")
_variant_config+=("-DUSE_LIBRTMP=OFF")
if [[ ${CARCH} != i686 ]]; then
_variant_config+=("--with-openssl-quic" "--with-nghttp3=${MINGW_PREFIX}")
_variant_config+=("-DUSE_OPENSSL_QUIC=ON")
fi
fi

msg2 "Building static library for curl${_variant}"
mkdir -p "${_destdir}-static" && cd "${_destdir}-static"

CFLAGS+=" -DNGHTTP2_STATICLIB -DNGHTTP3_STATICLIB" \
CXXFLAGS+=" -DNGHTTP2_STATICLIB -DNGHTTP3_STATICLIB" \
../${_realname}-${pkgver}/configure \
--prefix=${MINGW_PREFIX} \
--disable-pthreads \
--without-random \
--enable-static \
--disable-shared \
--enable-sspi \
--enable-ldap \
--enable-ldaps \
--with-brotli \
--with-ldap-lib=wldap32 \
--with-libssh2 \
--with-zstd \
"${_variant_config[@]}" \
"${extra_config[@]}"
# there's a bug with zsh completion generation script and Windows.
# curl has to be specified with the file extension.
sed -i "s|\/curl > \$\@|\/curl\$\{EXEEXT\} > \$\@|" scripts/Makefile
make
LDFLAGS+=" -static" \
MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
"${MINGW_PREFIX}"/bin/cmake.exe \
-GNinja \
-DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
-DCMAKE_FIND_STATIC_LIBRARIES=ON \
"${_extra_config[@]}" \
"${_variant_config[@]}" \
-DPICKY_COMPILER=OFF \
-DBUILD_CURL_EXE=OFF \
-DBUILD_SHARED_LIBS=OFF \
-DBUILD_STATIC_LIBS=ON \
-DCURL_WINDOWS_SSPI=ON \
-DCURL_BROTLI=ON \
-DCURL_ZSTD=ON \
-DCURL_USE_LIBSSH2=ON \
../"${_realname}-${pkgver}"

"${MINGW_PREFIX}"/bin/cmake.exe --build .

msg2 "Building shared library for curl${_variant}"
mkdir -p "${_destdir}-shared" && cd "${_destdir}-shared"
../${_realname}-${pkgver}/configure \
--prefix=${MINGW_PREFIX} \
--disable-pthreads \
--without-random \
--disable-static \
--enable-shared \
--enable-sspi \
--enable-ldap \
--enable-ldaps \
--with-brotli \
--with-ldap-lib=wldap32 \
--with-libssh2 \
--with-zstd \
"${_variant_config[@]}" \
"${extra_config[@]}"
# there's a bug with zsh completion generation script and Windows.
# curl has to be specified with the file extension.
sed -i "s|\/curl > \$\@|\/curl\$\{EXEEXT\} > \$\@|" scripts/Makefile
make

MSYS2_ARG_CONV_EXCL="-DCMAKE_INSTALL_PREFIX=" \
"${MINGW_PREFIX}"/bin/cmake.exe \
-GNinja \
-DCMAKE_INSTALL_PREFIX="${MINGW_PREFIX}" \
-DCMAKE_DLL_NAME_WITH_SOVERSION=ON \
"${_extra_config[@]}" \
"${_variant_config[@]}" \
-DPICKY_COMPILER=OFF \
-DBUILD_SHARED_LIBS=ON \
-DBUILD_STATIC_LIBS=OFF \
-DCURL_WINDOWS_SSPI=ON \
-DCURL_BROTLI=ON \
-DCURL_ZSTD=ON \
-DCURL_USE_LIBSSH2=ON \
../"${_realname}-${pkgver}"

"${MINGW_PREFIX}"/bin/cmake.exe --build .
}

build() {
Expand All @@ -175,10 +178,10 @@ build() {

do_package() {
cd "${srcdir}/build-${MSYSTEM}$1-static"
make DESTDIR="${pkgdir}" install
DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/cmake --install .

cd "${srcdir}/build-${MSYSTEM}$1-shared"
make DESTDIR="${pkgdir}" install
DESTDIR="${pkgdir}" ${MINGW_PREFIX}/bin/cmake --install .

local PREFIX_DEPS=$(cygpath -am ${MINGW_PREFIX})
sed -s "s|${PREFIX_DEPS}|${MINGW_PREFIX}|g" -i ${pkgdir}${MINGW_PREFIX}/bin/curl-config
Expand Down

0 comments on commit db8fd75

Please sign in to comment.