Saturday, December 11, 2021

Installing wget on MacOS from source

I recently had the time-consuming pleasure of trying to get wget onto my Mac ... without using homebrew.  Don't get me wrong, I think homebrew is a really helpful project, but it also kind of feels like curling a script and piping it into a root shell.  Here's what I did (on MacOS Monterey) to build and install from source.

Step 1: You're going to need either OpenSSL or gnutls libraries (not just the binary) in order to build it.  I chose OpenSSL.  Honestly, I picked it simply because it was the only one I could get to compile.

git clone git://git.openssl.org/openssl.git
cd openssl
./config
make
make -n install   # Dry run, for a sanity check.
sudo make install # Actually do the install.

Step 2:  Now you can compile wget -- we just need an extra flag in the configure step, to tell it we're using OpenSSL.  The last command here updates your wget config to tell it where to find the trusted TLS certificates on a Mac.

curl -o wget.tar.gz https://ftp.gnu.org/gnu/wget/wget-latest.tar.gz
tar -xzf wget.tar.gz
cd wget-*
./configure --with-ssl=openssl
make
make -n install   # Sanity check.
sudo make install # VĂ¡monos.

echo 'ca-certificate=/etc/ssl/cert.pem' >> ~/.wgetrc

There you go!  Three hours of your life back.