]> git.ipfire.org Git - thirdparty/curl.git/commitdiff
autotools: detect and link `brotlicommon` library for brotli
authorViktor Szakats <commit@vsz.me>
Mon, 23 Jun 2025 17:09:30 +0000 (19:09 +0200)
committerViktor Szakats <commit@vsz.me>
Wed, 25 Jun 2025 17:45:35 +0000 (19:45 +0200)
`brotlicommon` is necessary when linking brotli statically.
E.g. on Alpine Linux with `PKG_CONFIG='pkg-config --static'`.

It also syncs brotli libs listed in `libcurl.pc` and `curl-config` with
those generated by cmake, which already listed `brotlicommon` there.

Also:
- remove workaround from GHA/configure-vs-cmake CI jobs.

Ref: https://github.com/curl/curl/commit/69cda1b7048ce7651b68040c8c4f14356c93033f
Follow-up to f2adb3b6d73cad0c28ec8a32f5fa969d0f6378a0 #15431
Reported-by: Christopher Boyd
Fixes #17678
Closes #17723

.github/workflows/configure-vs-cmake.yml
configure.ac

index b57e8df184bc81f8263521e9bc56a45c1ae60188..55541e914094e7f2e856c68eacefad7f611a26a0 100644 (file)
@@ -44,10 +44,10 @@ jobs:
         run: |
           autoreconf -fi
           export PKG_CONFIG_DEBUG_SPEW=1
-          mkdir bld-am && cd bld-am && ../configure --enable-static=no --with-openssl --without-libpsl --without-brotli
+          mkdir bld-am && cd bld-am && ../configure --enable-static=no --with-openssl --without-libpsl
 
       - name: 'run cmake'
-        run: cmake -B bld-cm -DCURL_WERROR=ON -DCURL_USE_LIBPSL=OFF -DCURL_BROTLI=OFF
+        run: cmake -B bld-cm -DCURL_WERROR=ON -DCURL_USE_LIBPSL=OFF
 
       - name: 'configure log'
         run: cat bld-am/config.log 2>/dev/null || true
@@ -90,13 +90,12 @@ jobs:
         run: |
           autoreconf -fi
           export PKG_CONFIG_DEBUG_SPEW=1
-          mkdir bld-am && cd bld-am && ../configure --enable-static=no --with-openssl --without-libpsl --disable-ldap --with-zstd
+          mkdir bld-am && cd bld-am && ../configure --enable-static=no --with-openssl --without-libpsl --disable-ldap --with-brotli --with-zstd
 
       - name: 'run cmake'
         run: |
           cmake -B bld-cm -DCURL_WERROR=ON -DCURL_USE_LIBPSL=OFF -DCURL_DISABLE_LDAP=ON \
             -DCMAKE_C_COMPILER_TARGET="$(uname -m | sed 's/arm64/aarch64/')-apple-darwin$(uname -r)" \
-            -DCURL_BROTLI=OFF \
             -DCURL_USE_LIBSSH2=OFF
 
       - name: 'configure log'
index f027cae0ecb1dd0e369f33da91f34892dd55956b..30a4ed26e5efab0d92d852fd2f41e133da6e963e 100644 (file)
@@ -1442,9 +1442,17 @@ if test X"$OPT_BROTLI" != Xno; then
         LD_BROTLI=`$PKGCONFIG --libs-only-L libbrotlidec`
         CPP_BROTLI=`$PKGCONFIG --cflags-only-I libbrotlidec`
         version=`$PKGCONFIG --modversion libbrotlidec`
-        DIR_BROTLI=`echo $LD_BROTLI | $SED -e 's/^-L//'`
       fi
 
+      CURL_CHECK_PKGCONFIG(libbrotlicommon)
+
+      if test "$PKGCONFIG" != "no"; then
+        LIB_BROTLI="$LIB_BROTLI `$PKGCONFIG --libs-only-l libbrotlicommon`"
+        LD_BROTLI="$LD_BROTLI `$PKGCONFIG --libs-only-L libbrotlicommon`"
+        CPP_BROTLI="$CPP_BROTLI `$PKGCONFIG --cflags-only-I libbrotlicommon`"
+      fi
+
+      DIR_BROTLI=`echo $LD_BROTLI | $SED -e 's/^-L//'`
       ;;
     off)
       dnl no --with-brotli option given, just check default places
@@ -1457,7 +1465,7 @@ if test X"$OPT_BROTLI" != Xno; then
 
   dnl if given with a prefix, we set -L and -I based on that
   if test -n "$PREFIX_BROTLI"; then
-    LIB_BROTLI="-lbrotlidec"
+    LIB_BROTLI="-lbrotlidec -lbrotlicommon"
     LD_BROTLI=-L${PREFIX_BROTLI}/lib$libsuff
     CPP_BROTLI=-I${PREFIX_BROTLI}/include
     DIR_BROTLI=${PREFIX_BROTLI}/lib$libsuff