Add cross compilation support (#85)

Add support for cross-compiling curl-impersonate.

Cross compiling can now be done using the '--host' flag to the configure
script. This will make sure that all sub-components are cross-compiled.
In addition, compiling for a different system requires explicitly
specifying multiple paths used by curl (e.g. for certificates). These
options were added to the configure script as well.

The build and test CI workflow will now attempt to cross-compile
curl-impersonate to ARM64 (aarch64), and upload this binary to the
GitHub release page.

Add the 'configure' script generated by autoconf and its dependencies to
the repository to save the users from having to run 'autoconf' manually.
This commit is contained in:
lwthiker
2022-07-14 19:50:11 +03:00
committed by GitHub
parent 6572db81db
commit 72f30c958e
8 changed files with 9539 additions and 87 deletions

View File

@@ -2,9 +2,10 @@
This guide shows how to compile and install curl-impersonate and libcurl-impersonate from source.
The build process takes care of downloading dependencies, patching them, compiling them and finally compiling curl itself with the needed patches.
There are currently two build options depending on your use case:
* Native build using Makefile
* Docker container build
There are currently three build options depending on your use case:
* [Native build](#Native-build) using an autotools-based Makefile
* [Cross compiling](#Cross-compiling) using an autotools-based Makefile
* [Docker container build](#Docker-build)
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.
@@ -29,11 +30,6 @@ git clone https://github.com/lwthiker/curl-impersonate.git
cd curl-impersonate
```
Generate the configure script:
```
autoconf
```
Configure and compile:
```
mkdir build && cd build
@@ -102,11 +98,6 @@ pip3 install gyp-next
brew install go
```
Generate the configure script:
```
autoconf
```
Configure and compile:
```
mkdir build && cd build
@@ -135,6 +126,32 @@ Make sure that NSS is installed (see above).
If the issue persists it might be that NSS is installed in a non-standard location on your system.
Please open an issue in that case.
## Cross compiling
There is some basic support for cross compiling curl-impersonate.
It is currently being used to build curl-impersonate for ARM64 (aarch64) systems from x86-64 systems.
Cross compiling is similar to the usual build but a bit trickier:
* You'd have to build zlib for the target architecture so that curl can link with it.
* Some paths have to be specified manually since curl's own build system can't determine their location.
An example build for aarch64 on Ubuntu x86_64:
```
sudo apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu
./configure --host=aarch64-linux-gnu \
--with-zlib=/path/to/compiled/zlib \
--with-ca-path=/etc/ssl/certs \
--with-ca-bundle=/etc/ssl/certs/ca-certificates.crt \
--with-libnssckbi=/usr/lib/aarch64-linux-gnu/nss
make chrome-build
make firefox-build
```
The flags mean as follows:
`--with-zlib` is the location of a compiled zlib library for the target architecture.
`--with-ca-path` and `--with-ca-bundle` will be passed to curl's configure script as is.
`--with-libnssckbi` indicates the location of libnssckbi.so on the target system. This file contains the certificates needed by curl. This must be supplied if NSS is not installed in a standard location (i.e. not in `/usr/lib`).
## Docker build
The Docker build is a bit more reproducible and serves as the reference implementation. It creates a Debian-based Docker image with the binaries.