From c8465c126b31f4b08178c96a2c262d47f85e3f7e Mon Sep 17 00:00:00 2001 From: lwthiker Date: Sat, 2 Mar 2024 17:03:50 +0200 Subject: [PATCH] Disable extraneous linking in released binaries Libraries present on the CI runner system might affect the released binaries. Specifically, the MacOS runner in GitHub has librtsp, libidn2 and zstd installed, which makes curl link against them. Explicitly disable these linking, as we want to keep the precompiled binaries in our releases with minimal requirements. A user wishing to use these specific features can build from source on a system with these libraries present. --- .github/workflows/build-and-test-make.yml | 3 ++- INSTALL.md | 9 ++++++++ Makefile.in | 9 ++++++-- README.md | 6 +++++- configure | 26 ++++++++++++++--------- configure.ac | 2 ++ 6 files changed, 41 insertions(+), 14 deletions(-) diff --git a/.github/workflows/build-and-test-make.yml b/.github/workflows/build-and-test-make.yml index a8439406..0db6f6d7 100644 --- a/.github/workflows/build-and-test-make.yml +++ b/.github/workflows/build-and-test-make.yml @@ -105,7 +105,8 @@ jobs: if: matrix.arch == 'x86_64' run: | mkdir ${{ runner.temp }}/install - ./configure --prefix=${{ runner.temp }}/install + ./configure --prefix=${{ runner.temp }}/install \ + CURL_CONFIG_FLAGS="--disable-rtsp --without-libidn2 --without-zstd" # When cross compiling a more complicated configuration is needed, since # curl's configure script can't figure out where some files and libraries diff --git a/INSTALL.md b/INSTALL.md index a877b1f4..edcb8962 100644 --- a/INSTALL.md +++ b/INSTALL.md @@ -134,6 +134,15 @@ cd ../ && rm -Rf build To compile curl-impersonate statically with libcurl-impersonate, pass `--enable-static` to the `configure` script. +### Configuring curl's build + +You might want to configure the underlying curl build to your needs. +To do that, use the `CURL_CONFIG_FLAGS` variable. These flags will be passed down to curl's `configure` script: + +```sh +../configure CURL_CONFIG_FLAGS="--disable-rtsp" +``` + ### A note about the Firefox version The Firefox version compiles a static version of nss, Firefox's TLS library. diff --git a/Makefile.in b/Makefile.in index fb0813c3..af2b7050 100644 --- a/Makefile.in +++ b/Makefile.in @@ -57,6 +57,9 @@ CC = @CC@ CXX = @CXX@ STRIP = @STRIP@ +# Additional flags to be passed down to curl's configure script during build. +CURL_CONFIG_FLAGS = @CURL_CONFIG_FLAGS@ + # Auto-generate Makefile help. # Borrowed from https://marmelab.com/blog/2016/02/29/auto-documented-makefile.html help: ## Show this help message @@ -360,7 +363,8 @@ $(CURL_VERSION)/.firefox: $(firefox_libs) $(CURL_VERSION).tar.xz $(CURL_VERSION) # If the user provided the --host flag to our configure script # (for cross compilation), then pass it on to curl. { \ - config_flags="--prefix=@prefix@"; \ + config_flags="$(CURL_CONFIG_FLAGS)"; \ + config_flags+=" --prefix=@prefix@"; \ config_flags+=" --with-nghttp2=$(nghttp2_install_dir)"; \ config_flags+=" --with-brotli=$(brotli_install_dir)"; \ config_flags+=" --with-nss=$(nss_install_dir) --with-nss-deprecated"; \ @@ -401,7 +405,8 @@ $(CURL_VERSION)/.chrome: $(chrome_libs) $(CURL_VERSION).tar.xz $(CURL_VERSION)/. # If the user provided the --host flag to our configure script # (for cross compilation), then pass it on to curl. { \ - config_flags="--prefix=@prefix@"; \ + config_flags="$(CURL_CONFIG_FLAGS)"; \ + config_flags="$$config_flags --prefix=@prefix@"; \ config_flags="$$config_flags --with-nghttp2=$(nghttp2_install_dir)"; \ config_flags="$$config_flags --with-brotli=$(brotli_install_dir)"; \ config_flags="$$config_flags --with-openssl=$(boringssl_install_dir)"; \ diff --git a/README.md b/README.md index b6ead0ab..91f9299c 100644 --- a/README.md +++ b/README.md @@ -74,12 +74,16 @@ More documentation is available in the [docs/](docs/README.md) directory. There are two versions of `curl-impersonate` for technical reasons. The **chrome** version is used to impersonate Chrome, Edge and Safari. The **firefox** version is used to impersonate Firefox. ### Pre-compiled binaries -Pre-compiled binaries for Linux and macOS (Intel) are available at the [GitHub releases](https://github.com/lwthiker/curl-impersonate/releases) page. Before you use them you need to install nss (Firefox's TLS library) and CA certificates: +Pre-compiled binaries for Linux and macOS (Intel) are available at the [GitHub releases](https://github.com/lwthiker/curl-impersonate/releases) page. +Before you use them you need to install nss (Firefox's TLS library) and CA certificates: * Ubuntu - `sudo apt install libnss3 nss-plugin-pem ca-certificates` * Red Hat/Fedora/CentOS - `yum install nss nss-pem ca-certificates` * Archlinux - `pacman -S nss ca-certificates` * macOS - `brew install nss ca-certificates` +Also ensure you have zlib installed on your system. +zlib is almost always present, but on some minimal systems it might be missing. + The pre-compiled binaries contain libcurl-impersonate and a statically compiled curl-impersonate for ease of use. The pre-compiled Linux binaries are built for Ubuntu systems. On other distributions if you have errors with certificate verification you may have to tell curl where to find the CA certificates. For example: diff --git a/configure b/configure index c24d4c0f..837f7db8 100755 --- a/configure +++ b/configure @@ -1,6 +1,6 @@ #! /bin/sh # Guess values for system-dependent variables and create Makefiles. -# Generated by GNU Autoconf 2.71 for curl-impersonate 0.5.0. +# Generated by GNU Autoconf 2.71 for curl-impersonate 0.6.0. # # Report bugs to . # @@ -610,8 +610,8 @@ MAKEFLAGS= # Identity of this package. PACKAGE_NAME='curl-impersonate' PACKAGE_TARNAME='curl-impersonate' -PACKAGE_VERSION='0.5.0' -PACKAGE_STRING='curl-impersonate 0.5.0' +PACKAGE_VERSION='0.6.0' +PACKAGE_STRING='curl-impersonate 0.6.0' PACKAGE_BUGREPORT='lwt@lwthiker.com' PACKAGE_URL='' @@ -619,6 +619,7 @@ ac_subst_vars='LTLIBOBJS LIBOBJS ninja cmake +CURL_CONFIG_FLAGS with_libnssckbi with_ca_path with_ca_bundle @@ -701,7 +702,8 @@ LIBS CPPFLAGS CXX CXXFLAGS -CCC' +CCC +CURL_CONFIG_FLAGS' # Initialize some variables set by options. @@ -1250,7 +1252,7 @@ if test "$ac_init_help" = "long"; then # Omit some internal or obsolete options to make the list less imposing. # This message is too long to be a string in the A/UX 3.1 sh. cat <<_ACEOF -\`configure' configures curl-impersonate 0.5.0 to adapt to many kinds of systems. +\`configure' configures curl-impersonate 0.6.0 to adapt to many kinds of systems. Usage: $0 [OPTION]... [VAR=VALUE]... @@ -1317,7 +1319,7 @@ fi if test -n "$ac_init_help"; then case $ac_init_help in - short | recursive ) echo "Configuration of curl-impersonate 0.5.0:";; + short | recursive ) echo "Configuration of curl-impersonate 0.6.0:";; esac cat <<\_ACEOF @@ -1354,6 +1356,8 @@ Some influential environment variables: you have headers in a nonstandard directory CXX C++ compiler command CXXFLAGS C++ compiler flags + CURL_CONFIG_FLAGS + "configuration flags to be passed down to curls 'configure'" Use these variables to override the choices made by `configure' or to help it to find libraries and programs with nonstandard names/locations. @@ -1422,7 +1426,7 @@ fi test -n "$ac_init_help" && exit $ac_status if $ac_init_version; then cat <<\_ACEOF -curl-impersonate configure 0.5.0 +curl-impersonate configure 0.6.0 generated by GNU Autoconf 2.71 Copyright (C) 2021 Free Software Foundation, Inc. @@ -1584,7 +1588,7 @@ cat >config.log <<_ACEOF This file contains any messages produced by compilers while running configure, to aid debugging if configure makes a mistake. -It was created by curl-impersonate $as_me 0.5.0, which was +It was created by curl-impersonate $as_me 0.6.0, which was generated by GNU Autoconf 2.71. Invocation command line was $ $0$ac_configure_args_raw @@ -4223,6 +4227,8 @@ else $as_nop fi + + # BoringSSL requires cmake 3.5+, which is sometimes available under # "cmake3" instead of "cmake" for ac_prog in cmake3 cmake @@ -4859,7 +4865,7 @@ cat >>$CONFIG_STATUS <<\_ACEOF || ac_write_fail=1 # report actual input values of CONFIG_FILES etc. instead of their # values after options handling. ac_log=" -This file was extended by curl-impersonate $as_me 0.5.0, which was +This file was extended by curl-impersonate $as_me 0.6.0, which was generated by GNU Autoconf 2.71. Invocation command line was CONFIG_FILES = $CONFIG_FILES @@ -4914,7 +4920,7 @@ ac_cs_config_escaped=`printf "%s\n" "$ac_cs_config" | sed "s/^ //; s/'/'\\\\\\\\ cat >>$CONFIG_STATUS <<_ACEOF || ac_write_fail=1 ac_cs_config='$ac_cs_config_escaped' ac_cs_version="\\ -curl-impersonate config.status 0.5.0 +curl-impersonate config.status 0.6.0 configured by $0, generated by GNU Autoconf 2.71, with options \\"\$ac_cs_config\\" diff --git a/configure.ac b/configure.ac index a3fba9f6..420d60c7 100644 --- a/configure.ac +++ b/configure.ac @@ -67,6 +67,8 @@ AC_ARG_WITH([libnssckbi], [AC_SUBST([with_libnssckbi], ["$withval"])], [AC_SUBST([with_libnssckbi], [""])]) +AC_ARG_VAR([CURL_CONFIG_FLAGS], ["configuration flags to be passed down to curls 'configure'"]) + # BoringSSL requires cmake 3.5+, which is sometimes available under # "cmake3" instead of "cmake" AC_CHECK_PROGS([cmake], [cmake3 cmake])