#!/bin/bash

set -euo pipefail

MDQ_HOME=${PWD%/*/*/*}

cd curl

if [ ! -f curl-8.19.0.tar.gz ] ; then
    wget https://curl.se/download/curl-8.19.0.tar.gz
fi

if [ ! -d curl-8.19.0 ] ; then
    tar -xf curl-8.19.0.tar.gz
fi

#
# Compiling curl needs a bit of help to find libssl.so
# as OpenSSL 3.x has put it under lib64/ rather than /lib
#
export LDFLAGS=-L$MDQ_HOME/local/lib64

cd curl-8.19.0
./configure --prefix=$MDQ_HOME/local \
	    --with-openssl=$MDQ_HOME/local \
	    --without-libpsl \
            --without-brotli \
            --without-zstd

make -j$(nproc)
make install

cd ../..

