Last active
August 3, 2022 19:33
-
-
Save tautomer/baa7dab87e3c97496cca2678b4384c77 to your computer and use it in GitHub Desktop.
Compile gnuplot on Mac with x11 and wxt. Qt is dropped.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Homebrew removed the support of adding options while compiling, so there isn't x11 or wx term availble anymore | |
# Here I'm going to remove the gnuplot installation from homebrew and compile it myslef and then relink | |
# remove the one from homebrew or this script | |
if [[ ! -z $(brew list | grep gnuplot) ]]; then | |
if [[ ! -z $(brew list --pinned | grep gnuplot) ]]; then | |
brew unpin gnuplot | |
brew unlink gnuplot | |
fi | |
brew uninstall gnuplot | |
fi | |
# install dependencies, though they are likely installed already | |
brew install wxwidgets gd libcerf lua pango readline -q | |
# obtain the lastest tarball from sourceforge | |
url="https://sourceforge.net/projects/gnuplot/best_release.json" | |
dl_url=$(curl -s $url | python -m json.tool | grep tar | cut -d'"' -f4 | tail -1) | |
filename=$(basename $dl_url | cut -d'?' -f1) | |
dir=$(echo $filename | sed 's/\.tar\.gz//g') | |
version=$(echo $dir | cut -d'-' -f2) | |
prefix=$HOMEBREW_CELLAR/gnuplot/$version | |
# download and untar | |
curl -sLOJ $dl_url | |
tar -zxvf $filename | |
cd $dir | |
./configure --prefix=$prefix --without-qt --with-wx=/usr/local/bin --with-x --with-texdir=$prefix/tex | |
make -j 16 | |
# on my current system, multithread building often fails with a `permission denied` error | |
# singlethread compilation works totally fine, not sure why | |
if [[ $? != 0 ]]; then | |
make | |
fi | |
make install | |
brew link gnuplot | |
# make brew upgrade ignore gnuplot, preventing customized build being overwritten | |
brew pin gnuplot | |
cd .. | |
rm -rf $dir $filename |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Got back to Mac ecosystem again. Lots of stutff has changed since 3 years ago, like
brew --diy
no longer exists.Confirmed to work on my M1 MBP running Monterey.