sandbox/INSTALL_MACOS

    There are essentially two ways of installing linux tools on the mac: using MacPorts or Brew. We give step by step recipes for both.

    For Mac OS X users using MacPorts, darcs and zsh

    Since the latest Mac OS X system upgrades, the default shell is not bash anymore but zsh. This creates important changes in the installation process.

    If you don’t have Xcode and the Command Line Tools, install them following the MacPort instructions.

    Agree to the Xcode licence and follow the other MacPorts installation instructions.

    Install darcs using MacPorts:

    % sudo port install darcs
    Note that you don’t really need darcs, you could just use the tarball.

    The installation is slow (about two minutes). You may encounter warnings such as

    Warning: The macOS 11.2 SDK does not appear to be installed. Ports may not build correctly.

    This is a complex mac problem that may or may not be related to the next issue: currently on my system this macports darcs installation fails, if you encounter this problem then install the darcs binary and man page from this page. Once the darcs binary is downloaded, you need to move it to one of the places in your PATH, for example

    % cd ~/Downloads
    % mv darcs /usr/local/bin/darcs
    % mv darcs.1 /usr/local/man/man1/darcs.1

    Download the basilisk sources using

    darcs get --lazy http://basilisk.fr/basilisk

    You will need to install some software using MacPorts, the exact list of needed software is work I have in progress. At lest you need to do

    sudo port install bison

    and similarly, still with sudo port, you may need to install other software such as “md5sha1sum”. It is sometimes surprising that these installations are needed, since “bison” should be present on a UNIX system (and MacOSX is a UNIX system). For bison the reason is that the version of bison on MacOSX is slightly different from the linux standard. Do not install flex as it leads to serious errors.

    Same comment here. If you use the tarball, you should not need either bison or flex.

    The next step is to edit the config.osx file with your favorite text editor. I you are not familiar with text editors such as

    vim 
    vi
    emacs

    you are in bad shape. Ask a friend who uses them on Mac, Windows or Linux to help you. If you know how to edit a file then do

    cd $BASILISK/src

    and open the config.osx file. You should see in config.osx lines like

    # if you don't have md5sum, replace it with something equivalent
    GENSUM = shasum
    CHECKSUM = shasum -c --status

    type

    which shasum

    if you do not find shasum then install md5sha1sum using “sudo port install” and modify the lines to

    # if you don't have md5sum, replace it with something equivalent
    GENSUM = sha1sum
    CHECKSUM = sha1sum -c --status

    You may also uncomment the PNG line

    # if gnuplot supports pngcairo, otherwise comment this out
    PNG = pngcairo

    since gnuplot installed by MacPorts (see below for important information on gnuplot) has pngcairo. Once you have edited “config.osx” do

    The idea of “config.osx” is that it should provide a default working configuration for Macs. So it would be good to update the one currently in the source code. I am waiting for a patch…
    cp config.osx config
    export BASILISK=$PWD
    export PATH=$PATH:$PWD
    make -k

    You will get many warnings and messages, but you may disregard them. You may see twice the message

    make: *** No rule to make target `bview.s.d', needed by `Makefile.deps'.

    and once the error

    make: Failed to remake makefile `Makefile.deps'.

    do not worry, type “make” again and all should be fine. To summarize:

    cd $BASILISK/src
    cp config.osx config
    export BASILISK=$PWD
    export PATH=$PATH:$PWD
    make -k
    make

    Finally set the paths in your .zshrc file:

    cd $BASILISK/src
    echo "export BASILISK=$PWD" >> ~/.zshrc
    echo "export PATH=\$PATH:$BASILISK" >> ~/.zshrc

    Be careful that it was properly done, double check using “printenv” or looking at your ~/.zshrc with your text editor.

    To test your installation, try to make a test or example file.

    • First try bump2D:
    cd $BASILISK/src/tests
    make bump2D.tst

    Notice that in this installation I did not need to certify gdb as described below, nor did I uncomment the gdb line in config.osx . You may want to check that you have no errors, and to see the graphic output that should be similar to the bump2D1.c test case output. For that (and for many other things on mac) you shall need to install gnuplot. Unfortunately gnuplot’s binary installation does not work on MacOS Big Sur, so you need it install from source:

    Note that the default makefile should work without any gdb. What it does not like is a broken gdb. So a solution would be not to install gdb, rather than trying desperately to certify it.
    sudo port install -s wxWidgets-3.0 gnuplot

    (The “-s” option forces installation from source in MacPorts.) Then edit the $BASILISK/src/tests/bump2D/bump2D.plot file to change the line

    set term @PNG enhanced size 400,400

    to

    set term pngcairo enhanced size 400,400

    and then run

    cd $BASILISK/src/tests/bump2D/
    gnuplot < bump2D.plot > tmp.png
    open tmp.png
    Why not use the Makefile? This is where the @PNG variable comes from.
    • Second try an example with the interactive js view server. First you need to edit the Makefile in src/examples to comment out the -fopenmp directive in CFLAGS (because Macs dot not support OpenMP). Either use a text editor (see above) or do
    cd basilisk/src/examples
    sed -i '' s/-fopenmp/'# -fopenmp'/ Makefile 

    (Please note that the “sed -i ’’” syntax above is specific to the FreeBSD version of sed.) Then run the karman test and open the view server in your browser as described in the jview documentation

    cd $BASILISK/src/examples
    CFLAGS=-DDISPLAY=-1 make karman.tst 
    open $BASILISK/examples/karman/display.html

    For Mac OS X users using brew, bash and gdb

    This is probably obsolete

    If you don’t have Xcode, install it following this link. You’ll also need brew.

    Then, take the Mac OS X config file and copy it :

    cd basilisk/src
    cp config.osx config

    Then type

    export BASILISK=$PWD
    export PATH=$PATH:$PWD
    make -k
    make

    Be careful of the different names of the .bashrc file on macs:

    cd basilisk/src
    echo "export BASILISK=$PWD" >> ~/.bashrc
    echo "export PATH=\$PATH:$BASILISK" >> ~/.bashrc

    To use a Makefile, you need to install manually gdb by using brew:

    brew install gdb

    Then, you need to certify it, which is not an easy thing to do. So, go to this link and go directly to the “Certify GDB” section. Then just follow the instructions.

    To test the Makefile, go to /basilisk/src/test and make a test file (here, bump2D):

    cd ~/basilisk/src/tests
    make bump2D.tst

    You’ll have several warnings, which are not important. If you’ll have “make: *** [bump2D.tst] Error” on the last line, then you must check the file “gdb.err” in the “bump2D” repertory. If the content of this file is starting by “Unable to find Mach task port for process-id”, so something went wrong in the certifying process and you must restart it.