--- /dev/null
+#!/usr/bin/env bash
+# Copyright (C) Viktor Szakats
+#
+# SPDX-License-Identifier: curl
+
+# Sort list of libs, libpaths, cflags found in libcurl.pc and curl-config files,
+# then diff the autotools and cmake generated ones.
+
+sort_lists() {
+ prevline=''
+ section=''
+ while IFS= read -r l; do
+ if [[ "${prevline}" =~ (--cc|--configure) ]]; then # curl-config
+ echo "<IGNORED>"
+ else
+ # libcurl.pc
+ if [[ "${l}" =~ ^(Requires|Libs|Cflags)(\.private)?:\ (.+)$ ]]; then
+ if [ "${BASH_REMATCH[1]}" = 'Requires' ]; then
+ # Spec does not allow duplicates here:
+ # https://manpages.debian.org/unstable/pkg-config/pkg-config.1.en.html#Requires:
+ # "You may only mention the same package one time on the Requires: line"
+ val="$(printf '%s' "${BASH_REMATCH[3]}" | tr ',' '\n' | sort | tr '\n' ' ')"
+ else
+ val="$(printf '%s' "${BASH_REMATCH[3]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')"
+ fi
+ l="${BASH_REMATCH[1]}${BASH_REMATCH[2]}: ${val}"
+ # curl-config
+ elif [[ "${section}" =~ (--libs|--static-libs) && "${l}" =~ ^( *echo\ \")(.+)(\")$ ]]; then
+ val="$(printf '%s' "${BASH_REMATCH[2]}" | tr ' ' '\n' | sort -u | tr '\n' ' ')"
+ l="${BASH_REMATCH[1]}${val}${BASH_REMATCH[3]}"
+ section=''
+ fi
+ echo "${l}"
+ fi
+ # curl-config
+ prevline="${l}"
+ if [[ "${l}" =~ --[a-z-]+\) ]]; then
+ section="${BASH_REMATCH[0]}"
+ fi
+ done < "$1"
+}
+
+am=$(mktemp -t autotools.XXX); sort_lists "$1" > "${am}"
+cm=$(mktemp -t cmake.XXX) ; sort_lists "$2" > "${cm}"
+diff -u "${am}" "${cm}"
+res="$?"
+rm -r -f "${am}" "${cm}"
+
+exit "${res}"
- name: run configure --with-openssl
run: |
autoreconf -fi
- ./configure --with-openssl --without-libpsl
+ export PKG_CONFIG_DEBUG_SPEW=1
+ mkdir bld-am && cd bld-am && ../configure --enable-static=no --with-openssl --without-libpsl --without-brotli --without-zstd
- name: run cmake
run: |
- cmake -B build -DCURL_USE_LIBPSL=OFF
+ cmake -B bld-cm -DCURL_USE_LIBPSL=OFF
+
+ - name: 'configure log'
+ run: cat bld-am/config.log 2>/dev/null || true
+
+ - name: 'cmake log'
+ run: cat bld-cm/CMakeFiles/CMakeConfigureLog.yaml 2>/dev/null || true
- name: compare generated curl_config.h files
- run: ./.github/scripts/cmp-config.pl lib/curl_config.h build/lib/curl_config.h
+ run: ./.github/scripts/cmp-config.pl bld-am/lib/curl_config.h bld-cm/lib/curl_config.h
+
+ - name: compare generated libcurl.pc files
+ run: ./.github/scripts/cmp-pkg-config.sh bld-am/libcurl.pc bld-cm/libcurl.pc
+
+ - name: compare generated curl-config files
+ run: ./.github/scripts/cmp-pkg-config.sh bld-am/curl-config bld-cm/curl-config
check-macos:
runs-on: macos-latest
run: |
while [[ $? == 0 ]]; do for i in 1 2 3; do brew update && brew install libtool autoconf automake && break 2 || { echo Error: wait to try again; sleep 10; } done; false Too many retries; done
+ - name: 'toolchain versions'
+ run: |
+ echo '::group::brew packages installed'; ls -l "$(brew --prefix)/opt"; echo '::endgroup::'
+
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
- name: run configure --with-openssl
run: |
autoreconf -fi
- ./configure --with-openssl --without-libpsl
+ export PKG_CONFIG_DEBUG_SPEW=1
+ mkdir bld-am && cd bld-am && ../configure --enable-static=no --with-openssl --without-libpsl --disable-ldap
- name: run cmake
run: |
- cmake -B build -DCURL_USE_LIBPSL=OFF \
+ cmake -B bld-cm -DCURL_USE_LIBPSL=OFF -DCURL_DISABLE_LDAP=ON \
"-DCMAKE_C_COMPILER_TARGET=$(uname -m | sed 's/arm64/aarch64/')-apple-darwin$(uname -r)" \
-DCURL_USE_LIBSSH2=OFF
+ - name: 'configure log'
+ run: cat bld-am/config.log 2>/dev/null || true
+
+ - name: 'cmake log'
+ run: cat bld-cm/CMakeFiles/CMakeConfigureLog.yaml 2>/dev/null || true
+
- name: compare generated curl_config.h files
- run: ./.github/scripts/cmp-config.pl lib/curl_config.h build/lib/curl_config.h
+ run: ./.github/scripts/cmp-config.pl bld-am/lib/curl_config.h bld-cm/lib/curl_config.h
+
+ - name: compare generated libcurl.pc files
+ run: ./.github/scripts/cmp-pkg-config.sh bld-am/libcurl.pc bld-cm/libcurl.pc
+
+ - name: compare generated curl-config files
+ run: ./.github/scripts/cmp-pkg-config.sh bld-am/curl-config bld-cm/curl-config
check-windows:
runs-on: ubuntu-latest
- name: run configure --with-schannel
run: |
autoreconf -fi
- ./configure --with-schannel --without-libpsl --host=${TRIPLET}
+ export PKG_CONFIG_DEBUG_SPEW=1
+ mkdir bld-am && cd bld-am && ../configure --enable-static=no --with-schannel --without-libpsl --host=${TRIPLET}
- name: run cmake
run: |
- cmake -B build -DCURL_USE_SCHANNEL=ON -DCURL_USE_LIBPSL=OFF \
+ cmake -B bld-cm -DCURL_USE_SCHANNEL=ON -DCURL_USE_LIBPSL=OFF \
-DCMAKE_SYSTEM_NAME=Windows \
-DCMAKE_C_COMPILER_TARGET=${TRIPLET} \
-DCMAKE_C_COMPILER=${TRIPLET}-gcc
+ - name: 'configure log'
+ run: cat bld-am/config.log 2>/dev/null || true
+
+ - name: 'cmake log'
+ run: cat bld-cm/CMakeFiles/CMakeConfigureLog.yaml 2>/dev/null || true
+
- name: compare generated curl_config.h files
- run: ./.github/scripts/cmp-config.pl lib/curl_config.h build/lib/curl_config.h
+ run: ./.github/scripts/cmp-config.pl bld-am/lib/curl_config.h bld-cm/lib/curl_config.h
+
+ - name: compare generated libcurl.pc files
+ run: ./.github/scripts/cmp-pkg-config.sh bld-am/libcurl.pc bld-cm/libcurl.pc
+
+ - name: compare generated curl-config files
+ run: ./.github/scripts/cmp-pkg-config.sh bld-am/curl-config bld-cm/curl-config
endif()
# libssh2
-option(CURL_USE_LIBSSH2 "Use libssh2" ON) # FIXME: default is OFF in autotools
+option(CURL_USE_LIBSSH2 "Use libssh2" ON)
mark_as_advanced(CURL_USE_LIBSSH2)
set(USE_LIBSSH2 OFF)
set(VERSIONNUM "${CURL_VERSION_NUM}")
set(prefix "${CMAKE_INSTALL_PREFIX}")
set(exec_prefix "\${prefix}")
- set(includedir "\${prefix}/include")
+ if(IS_ABSOLUTE ${CMAKE_INSTALL_INCLUDEDIR})
+ set(includedir "${CMAKE_INSTALL_INCLUDEDIR}")
+ else()
+ set(includedir "\${prefix}/${CMAKE_INSTALL_INCLUDEDIR}")
+ endif()
+ if(IS_ABSOLUTE ${CMAKE_INSTALL_LIBDIR})
+ set(libdir "${CMAKE_INSTALL_LIBDIR}")
+ else()
+ set(libdir "\${exec_prefix}/${CMAKE_INSTALL_LIBDIR}")
+ endif()
set(LDFLAGS "${CMAKE_SHARED_LINKER_FLAGS}")
- set(libdir "${CMAKE_INSTALL_PREFIX}/lib")
# "a" (Linux) or "lib" (Windows)
string(REPLACE "." "" libext "${CMAKE_STATIC_LIBRARY_SUFFIX}")
endif()
endforeach()
- foreach(_lib IN LISTS CMAKE_C_IMPLICIT_LINK_LIBRARIES CURL_LIBS)
+ unset(_implicit_libs)
+ if(NOT MINGW AND NOT UNIX)
+ set(_implicit_libs ${CMAKE_C_IMPLICIT_LINK_LIBRARIES})
+ endif()
+
+ foreach(_lib IN LISTS _implicit_libs CURL_LIBS)
if(TARGET "${_lib}")
set(_libname "${_lib}")
get_target_property(_imported "${_libname}" IMPORTED)
if(_ldflags)
list(REMOVE_DUPLICATES _ldflags)
string(REPLACE ";" " " _ldflags "${_ldflags}")
- set(LIBCURL_PC_LIBS_PRIVATE "${_ldflags} ${LIBCURL_PC_LIBS_PRIVATE}")
- string(STRIP "${LIBCURL_PC_LIBS_PRIVATE}" LIBCURL_PC_LIBS_PRIVATE)
+ set(LDFLAGS "${LDFLAGS} ${_ldflags}")
+ string(STRIP "${LDFLAGS}" LDFLAGS)
endif()
set(LIBCURL_PC_CFLAGS_PRIVATE "-DCURL_STATICLIB")
# prefix
# SUPPORT_FEATURES
# SUPPORT_PROTOCOLS
+ # Documentation:
+ # https://people.freedesktop.org/~dbn/pkg-config-guide.html
+ # https://manpages.debian.org/unstable/pkgconf/pkg-config.1.en.html
+ # https://manpages.debian.org/unstable/pkg-config/pkg-config.1.en.html
+ # https://www.msys2.org/docs/pkgconfig/
configure_file(
"${CURL_SOURCE_DIR}/libcurl.pc.in"
"${CURL_BINARY_DIR}/libcurl.pc" @ONLY)
fi
if test "x$ca" != "xno"; then
- CURL_CA_BUNDLE='"'$ca'"'
+ CURL_CA_BUNDLE="$ca"
AC_DEFINE_UNQUOTED(CURL_CA_BUNDLE, "$ca", [Location of default ca bundle])
AC_SUBST(CURL_CA_BUNDLE)
AC_MSG_RESULT([$ca])
# shellcheck disable=SC2006
-prefix="@prefix@"
-# Used in @libdir@
+prefix='@prefix@'
+# Used in 'libdir'
# shellcheck disable=SC2034
-exec_prefix=@exec_prefix@
+exec_prefix="@exec_prefix@"
# shellcheck disable=SC2034
-includedir=@includedir@
-cppflag_curl_staticlib=@LIBCURL_PC_CFLAGS@
+includedir="@includedir@"
+cppflag_curl_staticlib='@LIBCURL_PC_CFLAGS@'
usage()
{
;;
--feature|--features)
- for feature in @SUPPORT_FEATURES@ ""; do
+ for feature in @SUPPORT_FEATURES@ ''; do
test -n "$feature" && echo "$feature"
done
;;
;;
--checkfor)
- checkfor=$2
+ checkfor="$2"
cmajor=`echo "$checkfor" | cut -d. -f1`
cminor=`echo "$checkfor" | cut -d. -f2`
# when extracting the patch part we strip off everything after a
;;
--cflags)
- if test "X$cppflag_curl_staticlib" = "X-DCURL_STATICLIB"; then
- CPPFLAG_CURL_STATICLIB="-DCURL_STATICLIB "
+ if test "X$cppflag_curl_staticlib" = 'X-DCURL_STATICLIB'; then
+ CPPFLAG_CURL_STATICLIB='-DCURL_STATICLIB '
else
- CPPFLAG_CURL_STATICLIB=""
+ CPPFLAG_CURL_STATICLIB=''
fi
- if test "X@includedir@" = "X/usr/include"; then
+ if test "X@includedir@" = 'X/usr/include'; then
echo "${CPPFLAG_CURL_STATICLIB}"
else
echo "${CPPFLAG_CURL_STATICLIB}-I@includedir@"
;;
--libs)
- if test "X@libdir@" != "X/usr/lib" -a "X@libdir@" != "X/usr/lib64"; then
+ if test "X@libdir@" != 'X/usr/lib' -a "X@libdir@" != 'X/usr/lib64'; then
CURLLIBDIR="-L@libdir@ "
else
- CURLLIBDIR=""
+ CURLLIBDIR=''
fi
- if test "X@ENABLE_SHARED@" = "Xno"; then
+ if test 'X@ENABLE_SHARED@' = 'Xno'; then
echo "${CURLLIBDIR}-lcurl @LIBCURL_PC_LIBS_PRIVATE@"
else
echo "${CURLLIBDIR}-lcurl"
;;
--static-libs)
- if test "X@ENABLE_STATIC@" != "Xno" ; then
- echo "@libdir@/libcurl.@libext@" @LDFLAGS@ @LIBCURL_PC_LIBS_PRIVATE@
+ if test 'X@ENABLE_STATIC@' != 'Xno'; then
+ echo "@libdir@/libcurl.@libext@ @LDFLAGS@ @LIBCURL_PC_LIBS_PRIVATE@"
else
echo 'curl was built with static libraries disabled' >&2
exit 1
Name: libcurl
URL: https://curl.se/
-Description: Library to transfer files with ftp, http, etc.
+Description: Library to transfer files with HTTP, FTP, etc.
Version: @CURLVERSION@
Requires: @LIBCURL_PC_REQUIRES@
Requires.private: @LIBCURL_PC_REQUIRES_PRIVATE@
Libs: -L${libdir} -lcurl @LIBCURL_PC_LIBS@
-Libs.private: @LIBCURL_PC_LIBS_PRIVATE@
+Libs.private: @LDFLAGS@ @LIBCURL_PC_LIBS_PRIVATE@
Cflags: -I${includedir} @LIBCURL_PC_CFLAGS@
Cflags.private: @LIBCURL_PC_CFLAGS_PRIVATE@