Installation instructions for NCAlgebras

These instructions have been checked for Linux (specifically Ubuntu) as well as Mac OS X up
through Sierra.  We have yet to install it natively on a Windows machine, though with the new Linux Subsystem
on Windows it may be possible.

1)  Regardless of your platform, the first thing to do is install Macaulay2.  This can be done by following
    the instructions located at http://www.macaulay2.com.  The NCAlgebra
    package is also distributed with the most recent version of Macaulay2 (v1.11), but not earlier versions.
    Instructions for installing NCAlgebra on earlier versions are also included below.

2)  Install Common Lisp (also known as CLisp).  On a Linux machine this is usually accomplished via the package manager
    built into your distribution.  For example, on Ubuntu the command "sudo apt-get install clisp" should
    do the trick.

3)  On a Mac, one must first install homebrew.  Instructions for installing homebrew are on their webpage https://brew.sh.
    This installation may also require you to install the XCode Command Line Developer Tools.  Instructions how to accomplish
    this are located at http://osxdaily.com/2014/02/12/install-command-line-tools-mac-os-x/.  Once homebrew is installed,
    execute "brew install clisp" at a command prompt.

4)  Download the Bergman system from http://servus.math.su.se/bergman/.  Extract the tar.gz file to a directory accessible
    by all the users that wish to use the system.  In what follows, I will call the location of this directory <bergmanroot>.

5)  Open a terminal and navigate to the <bergmanroot> directory.  Here the instructions for Linux and Mac diverge a bit:

Linux: Change to the directory <bergmanroot>/scripts/clisp/unix.  Execute the command "./mkbergman -auto"
       This command will build the bergman executable.  Move to step 6.

Mac: Things are a bit more complicated.  The issue is that CLisp seems to have broken how CLisp generates native executables on a Mac in CLisp 2.49,
     or at the very least the more recent versions of the Mac OS do not understand how to run the executables that are generated by CLisp.  To get around
     this, follow these steps:
     
     a) Change to the directory <bergmanroot>/auxil/clisp.  Edit the file "bm-tail-cl.lsp" in a text editor.  You will see the lines

     ;;(SAVEINITMEM "lispinit.mem" :INIT-FUNCTION...
     (SAVEINITMEM "bergman.exe" :INIT-FUNCTION...

     in the file.  In CLisp, ;; indicates a comment.  Switch the lines that are commented; that is, ;; on the front of the
     second line and take the ;; off of the first line.  Save your changes.
 
     b) Change to the <bergmanroot>/scripts/clisp2.29/unix/ directory and execute the command "./mkbergman -auto".
     This command will build the bergman executable.

     c) Finally change the directory to <bergmanroot>/bin/clisp/unix.  In a text editor edit
     the bergman file there.  This is a shell script which loads the necessary files to start the bergman
     executable.  However there is a change that must be made to this file as well.  Here, # denotes a comment.
     By default the third line is active and the second one is commented.  Switch these around as well.  Save your changes.

6) Make sure the bergman executable can be run from any command prompt.  One way to do this is to add a symbolic link 
   of the bergman executable script to /usr/local/bin (or any other directory already on your path).  This command
   may look something like: "ln -s <bergmanroot>/bin/clisp/unix/bergman /usr/local/bin/bergman"
   provided that you followed the steps above to generate the bergman executable.  Note that in the above
   command, the *full* path (from the root directory) to <bergmanroot> must be given.

7) The most recent release of Macaulay2 (v1.11) contains the NCAlgebra package as part of the distribution.
   If you are running an older version of Macaulay2, it is a good idea to upgrade in case some bugs have
   been fixed and improvements made.  If you must use an older version, NCAlgebra is currently available on
   Frank Moore's webpage http://users.wfu.edu/moorewf.

8) Start Macaulay2.  Run the command "installPackage "NCAlgebra"" at the Macaulay2 prompt.

9) Test your installation by running the following commands in Macaulay2:

   needsPackage "NCAlgebra"
   R = fourDimSklyanin(QQ,{a,b,c,d})
   hilbertBergman(R, DegreeLimit => 6)

   If no errors are generated, then you have successfully installed the system.  Enjoy!
