1#! /bin/bash 2 3# macports-setup.sh A C Norman June 2019 4 5# $Id: macports-setup.sh 5713 2021-03-11 08:35:17Z arthurcnorman $ 6 7if test "$1" = "--help" 8then 9 printf "macports-setup.sh [--help] [--minimal] [--universal] [[force]\n" 10 printf " help: displays this message\n" 11 printf " minimal: only the bare minimum for local Reduce use\n" 12 printf " universal: try to install x86_64+arm64 on Macintosh" 13 printf " force: overwrite any existing $HOME/.macports/macports.conf\n\n" 14 exit 0 15fi 16 17 18# This script can be used on either a Macintosh (once macports has 19# been installed, and that in turn required Xcode tools including its 20# command-line option). It installs a collection of "ports" sufficient for 21# building, testing and distributing Reduce. 22# 23# When a new release of the main Macintosh operating system is installed 24# or an updated version of Xcode tools gets released it will be proper 25# to refresh all ports. For a new operating system in general a fresh 26# and updated version of macports itself may be required. But in both cases 27# doing "sudo port uninstall all" will discard all current material 28# and then this script can be used to reinstate it. 29 30 31 32# I want binaries of Reduce that I build to be able to support version of 33# the Macintosh back as far as 10.13, and so where there are ports that 34# lead to linkable libraries I will forcibly build from source with 35# macosx_deployment_target set via macports.conf. To achieve that I set up 36# a copy of that file in $HOME/.macports if necessary. 37# 38# For tools that are merely used locally while building Reduce I will let 39# the port system fetch pre-built binaries when it has any, and dong so 40# saves a major amount of time here. 41# On a 2014 Macbook Pro a "minimal" installation takes around 25 minutes 42# and a full one somewhat over an hour. It is OK to run this script without 43# the "--minimal" flag at any stage after you have done a --minimal install, 44# and it will check the alread-installed components but then just go on to 45# fetch and install the rest. 46# 47# The --universal flag is for use on Big Sur and beyond to ttry to install 48# ports so that that support both x86_64 and arm64, and hence Reduce can be 49# built in that way. At the time of writing (February 2021) this still fails 50# on an M1 Macintosh because a few ports will not build in universal mode. 51# On an x86_64 Macintosh it fails much more thoroughly. There are strong 52# indications that the Macports support team are aware of and are addressing 53# these issues and the problem is just a natural one due to to the need for 54# universal builds being fairly new. In many reszpects that extent to which 55# things do work is amazing! 56 57if grep macosx_deployment_target /opt/local/etc/macports/macports.conf 2>/dev/null 58then 59 printf "/opt/local/etc/macports/macports.conf already sets macosx_deployment_target\n" 60 61else 62 63 cp /opt/local/etc/macports/macports.conf /tmp/macports.conf 64 printf "macosx_deployment_target 10.13\n" >> /tmp/macports.conf 65 66 if ! test -f $HOME/.macports/macports.conf 67 then 68 mkdir $HOME/.macports 69 mv /tmp/macports.conf $HOME/.macports 70 printf "I have just created $HOME/.macports/macports.conf\n" 71 printf "to set macosx_deployment_target for you\n" 72 else 73 74 if diff $HOME/.macports/macports.conf /tmp/macports.conf 75 then 76 printf "You already have $HOME/.macports/macports.conf set up\n" 77 else 78 79 printf "Your $HOME/.macports/macports.conf clashes with mine\n" 80 printf "Please review it against /tmp/macports.conf\n" 81 printf "This script will not continue unless you specify '--force'\n" 82 printf "or delete your own macports.conf or bring it into step.\n" 83 case "$*" in 84 *--force*) 85 ;; 86 *) 87 exit 1 88 ;; 89 esac 90 fi 91 fi 92fi 93 94 95# Report that date at start and end of this just for interest. 96date 97 98# Ensure that the latest version of macports will be in use. 99port selfupdate 100 101# The ordering of the installations here is not arbitrary - I have made at 102# least some attempt to set it up so that dependencies do not lead to 103# ports being built from source (or not) against my intention. So for 104# instance if I had listed ncurses lower down I could have found a binary 105# install of it triggered by some package that depended on it, while 106# if I moved xorg-libX11 up then various of its dependencies would end up 107# compiled from source in an unnecessary way. 108 109extraopt="" 110case "$*" in 111*--universal*) 112 extraopt="+universal" 113 ;; 114esac 115 116port -N -s install ncurses gperf libiconv $extraopt 117port -N -s install gettext xz zlib libedit $extraopt 118port -N -s install bzip2 expat $extraopt 119port -N install gsed $extraopt 120port -N install pkgconfig subversion $extraopt 121port -N install autoconf autoconf-archive $extraopt 122port -N install m4 $extraopt 123port -N install perl5 autoconf213 $extraopt 124port -N install automake libtool $extraopt 125port -N install bzip2 libffi python_select $extraopt 126port -N install python2_select python27 $extraopt 127port -N install python39 $extraopt 128# As of February 2021 xorg-libxcb depends on libxml2 which in turn 129# depends on icu, and an attempt to build on an x86_64 Mac stalls with 130# a message 131# ---> Computing dependencies for libxml2 132# Error: Cannot install libxml2 for the archs 'arm64 x86_64' because 133# Error: its dependency icu cannot build for the required archs. 134# this despite the fact that "port install icu +universal" succeeds. I 135# expect this to be a transient issue and will remove this comment when 136# I observe things behave better. 137port -N -s install xorg-libxcb +python39 $extraopt 138# xorg-libX11 is stalled by xorg-libxcb. 139port -N -s install xorg-libX11 $extraopt 140# perl5.28 depends on gdbm which in turn depends on readline, which 141# can not (yet) be built in universal mode if you are on an x86_64 mac. 142port -N install perl5.28 143# Xft2 also depends on libxml2. 144port -N -s install Xft2 $extraopt 145port -N -s install xorg-libXext $extraopt 146port -N install ccache gtime $extraopt 147port -N install gmake bc timeout $extraopt 148port -N -s install xorg-libXrandr $extraopt 149port -N -s install xorg-libXcursor $extraopt 150port -N install brotli $extraopt 151date 152 153case "$*" in 154*--minimal*) 155 printf "You probably have enough installed for a minimal local\n" 156 printf "build of Reduce. But if you want to build documentation and\n" 157 printf "try all [sometimes experimental] options please install the\n" 158 printf "rest of the ports here. They are in general fetched in binary\n" 159 printf "and it should not take TOO long...\n" 160 exit 0 161 ;; 162*) 163 ;; 164esac 165 166# Once again several of the ports that follow are really not essential 167# for Reduce use, but by installing them I find that the full set of tools 168# that I (ACN) have made use of in Reduce development and experiment 169# will be set up. As an example of ports that may not matter as much to 170# others, "gmp" is the GNU multiprecision library and I have some test 171# code that benchmarks CSL arithmetic against it. 172# "fontforge" is obviously relevant when considering details of fonts that 173# may be used in a future Reduce GUI. "astyle" helps to keep C++ source 174# code laid out consistently. All the texlive components are used when 175# building the Reduce manual. 176 177port -N -s install \ 178 fontconfig \ 179 libffi \ 180 gmp $extraopt 181 182port -N install \ 183 astyle \ 184 dvipng \ 185 findutils \ 186 fontforge \ 187 gdb \ 188 git \ 189 gnuplot \ 190 gnutar \ 191 gzip \ 192 md5sha1sum \ 193 netpbm \ 194 psutils \ 195 rsync \ 196 texinfo \ 197 texlive-fonts-extra \ 198 texlive-formats-extra \ 199 texlive-latex-extra \ 200 texlive-plain-generic \ 201 texlive-bin-extra \ 202 texlive-fonts-recommended \ 203 wget 204 205exit 0 206 207# end of script 208