| 1 | set -xe |
| 2 | |
| 3 | PROJECT_DIR="$1" |
| 4 | PLATFORM=$(PYTHONPATH=tools python -c "import openblas_support; print(openblas_support.get_plat())") |
| 5 | echoscip-shell system . . echo. $PLATFORM |
| 6 | |
| 7 | # Update license |
| 8 | catscip-shell system . . cat. $PROJECT_DIR/tools/wheels/LICENSE_osx.txt >> $PROJECT_DIR/LICENSE.txt |
| 9 | |
| 10 | ######################################################################################### |
| 11 | # Install GFortran + OpenBLAS |
| 12 | |
| 13 | if [[ $PLATFORM == "macosx-x86_64" ]]; then |
| 14 | # Openblas |
| 15 | basedir=$(python tools/openblas_support.py) |
| 16 | |
| 17 | # copy over the OpenBLAS library stuff first |
| 18 | cpscip-shell system . . cp. -r $basedir/lib/* /usr/local/libscip-shell filesystem . . `/usr/local/lib`. |
| 19 | cpscip-shell system . . cp. $basedir/include/* /usr/local/includescip-shell filesystem . . `/usr/local/include`. |
| 20 | |
| 21 | #GFORTRAN=$(type -p gfortran-9) |
| 22 | #sudo ln -s $GFORTRAN /usr/local/bin/gfortran |
| 23 | # same version of gfortran as the openblas-libs and scipy-wheel builds |
| 24 | curlscip-shell system . . curl. -L https://github.com/isuruf/gcc/releases/download/gcc-11.3.0-2/gfortran-darwin-x86_64-native.tar.gz -o gfortran.tar.gz |
| 25 | |
| 26 | GFORTRAN_SHA256=$(shasumscip-shell system . . shasum. -a 256 gfortran.tar.gz) |
| 27 | KNOWN_SHA256="981367dd0ad4335613e91bbee453d60b6669f5d7e976d18c7bdb7f1966f26ae4 gfortran.tar.gz" |
| 28 | if [scip-shell system . . `[`. "$GFORTRAN_SHA256" != "$KNOWN_SHA256" ]; then |
| 29 | echoscip-shell system . . echo. sha256 mismatch |
| 30 | exit 1 |
| 31 | fi |
| 32 | |
| 33 | sudoscip-shell system . . sudo. mkdir -p /opt/scip-shell filesystem . . `/opt/`. |
| 34 | # places gfortran in /opt/gfortran-darwin-x86_64-native. There's then |
| 35 | # bin, lib, include, libexec underneath that. |
| 36 | sudoscip-shell system . . sudo. tar -xv -C /optscip-shell filesystem . . `/opt`. -f gfortran.tar.gz |
| 37 | |
| 38 | # Link these into /usr/local so that there's no need to add rpath or -L |
| 39 | for f in libgfortran.dylib libgfortran.5.dylib libgcc_s.1.dylib libgcc_s.1.1.dylib libquadmath.dylib libquadmath.0.dylib; do |
| 40 | lnscip-shell system . . ln. -sf /opt/gfortran-darwin-x86_64-native/lib/$f /usr/local/lib/$f |
| 41 | done |
| 42 | lnscip-shell system . . ln. -sf /opt/gfortran-darwin-x86_64-native/bin/gfortranscip-shell filesystem . . `/opt/gfortran-darwin-x86_64-native/bin/gfortran`. /usr/local/bin/gfortranscip-shell filesystem . . `/usr/local/bin/gfortran`. |
| 43 | |
| 44 | # Set SDKROOT env variable if not set |
| 45 | # This step is required whenever the gfortran compilers sourced from |
| 46 | # conda-forge (built by isuru fernando) are used outside of a conda-forge |
| 47 | # environment (so it mirrors what is done in the conda-forge compiler |
| 48 | # activation scripts) |
| 49 | export SDKROOT=${SDKROOT:-$(xcrun --show-sdk-path)} |
| 50 | gfortran tools/wheels/test.f |
| 51 | fi |
| 52 | |
| 53 | if [[ $PLATFORM == "macosx-arm64" ]]; then |
| 54 | # OpenBLAS |
| 55 | # need a version of OpenBLAS that is suited for gcc >= 11 |
| 56 | basedir=$(python tools/openblas_support.py) |
| 57 | |
| 58 | # use /opt/arm64-builds as a prefix, because that's what the multibuild |
| 59 | # OpenBLAS pkgconfig files state |
| 60 | sudoscip-shell system . . sudo. mkdir -p /opt/arm64-builds/libscip-shell filesystem . . `/opt/arm64-builds/lib`. |
| 61 | sudoscip-shell system . . sudo. mkdir -p /opt/arm64-builds/includescip-shell filesystem . . `/opt/arm64-builds/include`. |
| 62 | sudoscip-shell system . . sudo. cp -r $basedir/lib/* /opt/arm64-builds/libscip-shell filesystem . . `/opt/arm64-builds/lib`. |
| 63 | sudoscip-shell system . . sudo. cp $basedir/include/* /opt/arm64-builds/includescip-shell filesystem . . `/opt/arm64-builds/include`. |
| 64 | |
| 65 | # we want to force a dynamic linking |
| 66 | sudoscip-shell system . . sudo. rm /opt/arm64-builds/lib/*.a |
| 67 | |
| 68 | curlscip-shell system . . curl. -L https://github.com/fxcoudert/gfortran-for-macOS/releases/download/12.1-monterey/gfortran-ARM-12.1-Monterey.dmg -o gfortran.dmg |
| 69 | GFORTRAN_SHA256=$(shasumscip-shell system . . shasum. -a 256 gfortran.dmg) |
| 70 | KNOWN_SHA256="e2e32f491303a00092921baebac7ffb7ae98de4ca82ebbe9e6a866dd8501acdf gfortran.dmg" |
| 71 | |
| 72 | if [scip-shell system . . `[`. "$GFORTRAN_SHA256" != "$KNOWN_SHA256" ]; then |
| 73 | echoscip-shell system . . echo. sha256 mismatch |
| 74 | exit 1 |
| 75 | fi |
| 76 | |
| 77 | hdiutil attach -mountpoint /Volumes/gfortranscip-shell filesystem . . `/Volumes/gfortran`. gfortran.dmg |
| 78 | sudoscip-shell system . . sudo. installer -pkg /Volumes/gfortran/gfortran.pkgscip-shell filesystem . . `/Volumes/gfortran/gfortran.pkg`. -target /scip-shell filesystem . . `/`. |
| 79 | type -p gfortran |
| 80 | fi |