//#####################################################################
// Copyright 2014, 2021.
// This file is part of PhysBAM whose distribution is governed by the license contained in the accompanying file PHYSBAM_COPYRIGHT.txt.
//#####################################################################
//
// Configuring PhysBAM on Ubuntu or OSX
//
//#####################################################################

1. Get a package manager. If you are running Ubuntu, you have apt-get. If you
are running Mac OSX, install macports or homebrew.

2. Install git and emacs (you probably have already installed git if you are
reading this)

Ubuntu:
sudo apt-get install git
sudo apt-get install emacs23
sudo apt-get install scons
sudo apt-get install cblas

Mac:
sudo port install git
sudo port install emacs
brew install scons
brew install cblas
brew install libjpeg
brew install libpng
brew install fftw
brew install suite-sparse

3. Make sure you have ucr cs account.  Email systems@cs.ucr.edu to get one if
not.

4. Have someone with access (e.g., Craig, Tamar) create an account for you on
iron (and gallium, cobalt) and send you the initial password.

%> sudo useradd -m <username>
%> sudo usermod -a -G users <username>
%> sudo usermod -a -G gitrepo <username>
%> sudo chsh -s /bin/bash <username>
%> sudo passwd <username> <initial password>

5. Log in to bolt

%> ssh <cs username>@bolt.cs.ucr.edu

5. Change your password on iron, bolt, etc.  For each host, do the following:

%> ssh <iron username>@iron.cs.ucr.edu (or <username>@gallium.cs.ucr.edu, etc.)
%> passwd

6. Set up ssh keys for convenient ssh access to bolt and iron, gallium, etc.

%> ssh-keygen (don't overwrite if you already have one)
%> ssh-copy-id <username>@bolt.cs.ucr.edu

7. Edit ~/.ssh/config to contain information for bolt, iron, gallium, etc.  Add
two blocks that look like the below.  Note that access to iron will be via ssh
tunneling, hence the different setup.

host bolt
     user <bolt username>
     hostname bolt.cs.ucr.edu

host iron
     user <iron username>
     hostname localhost
     port 2222

8. Create a script to ssh tunnel to iron.  You can put it anywhere you want,
e.g., ~/bin

%> mkdir ~/bin
%> cd ~/bin
%> cat > tunnel_to_iron.sh
#!/bin/bash
ssh -L 2222:169.235.27.210:22 <bolt username>@bolt.cs.ucr.edu

%> chmod u+x tunnel_to_iron.sh

9. Test the setup by running this in a separate terminal.
%> ~/bin/tunnel_to_iron.sh

Leave that running and switch back to the original terminal.
%> ssh iron

This should log you directly into iron.  Close the connection to iron to go back to your machine.

10. Set up your ssh key on iron
%> ssh-copy-id iron

11. Set up your local copy of the PhysBAM repo 

%> cd ~
%> git clone iron:/git/PhysBAM 

12. cd to the root PhysBAM directory and copy SConstruct.options into this directory

%> cd PhysBAM
%> cp Scripts/scons/SConstruct.options .

If you are on Mac, change "linux" to "osx" in the SConstruct.options file.

13. Also grab .emacs and .bashrc files.  

%> cp Public_Library/Documentation/emacs ~/.emacs
%> cp Public_Library/Documentation/bashrc ~/.bashrc

You may need to edit these a bit.  When you open up emacs, it may give you error messages saying that various commands do not exist; you can comment these lines out in the .emacs file.

In the .bashrc file you will need to change the compile command to reflect the number of cores and memory you have.  A good recommendation is the minimum of (number-of-cores) and (((GB-of-memory) - 2)/1.5)

--------------------------------------------------------------------------------

5. Install g++/gcc and upgrade to a newer version (As of January 2014, version 4.8.x is required. If you are
   running Mac OSX, 4.8.x is available via Macports. If you are running Ubuntu, and are not already at 4.8.x 
   or above, you will need to install it manually. Here are some instructions to do that, but beware they may
   be incomplete.)

	5a. Install g++:

	   sudo apt-get install g++

	5b. Get the most recent 4.8.x and bug somebody who knows how to install it until they help you.


6. Install various packages required for PhysBAM to compile and run.

   scons, boost, petsc, bison, flex -- libraries necessary for various compiling tasks
   libpng, lipjpeg, libavformat, libavcodec, libavutil -- for processing, creating various A/V formats

   Newer versions for these libraries may have been added since this was written. It's worth double-checking.
   In Ubuntu:

   sudo apt-get install scons
   sudo apt-get install libboost-all-dev
   sudo apt-get install libpng12-dev
   sudo apt-get install libjpeg62-dev
   sudo apt-get install libavformat-dev
   sudo apt-get install libavcodec-dev
   sudo apt-get install libavutil-dev
   sudo apt-get install petsc-dev
   sudo apt-get install libglut3-dev (freeglut3-dev)
   sudo apt-get install bison
   sudo apt-get install flex

    sudo apt install g++-10
    sudo apt install libblas-dev liblapack-dev
    sudo apt install libopenblas-dev
    sudo apt install liblapacke-dev
    sudo apt install libfftw3-dev
    sudo apt install libjpeg-dev
    sudo apt install libpng-dev
    sudo apt install libbison-dev
    sudo apt install libgl-dev
    sudo apt install freeglut3-dev
    sudo apt install libqhull-dev
    sudo apt install libsuitesparse-dev
    sudo apt install qtbase5-dev


   For Mac, some of these packages are found by installing XCode Developer Tools, and most of the A/V ones are included in ffmpeg.
   However, flex v 2.5.36 and 2.5.37, which come from Macports and the XCode Tools, do not work, so you will need to install 2.5.35
   from source (as of this writing) and make sure it is the version that gets called. (apt-get installs the working version.) If
   2.5.38 has been released when you read this, you can probably use that.


7. Configure your SConstruct.options file (in your PhysBAM directory), your .bashrc file (in your home directory), and your .emacs
   file (in your home directory). The SConstruct.options file is used when PhysBAM compiles, the .bashrc file contains useful
   Terminal commands, and the .emacs file contains commands and scripts for Emacs (useful for coding in PhysBAM, your life is much
   easier if you get this working properly.)

   It may be easiest to steal/borrow someone else's versions of these until you figure out how to configure things on your own.
   Ask permission first.


8. The command to compile PhysBAM is:

   nice scons --warn=no-duplicate-environment --warn=no-deprecated -Q --implicit-cache -k -u TYPE=release -j 4

   most people have an alias for this ('cs') in their .bashrc file.


9. If you've done all this and you still can't successfully compile/run PhysBAM, ask someone else for help. Find out what you needed
   that wasn't included in this file, and add it to the file :-)

10.-optional- (if you are using a project that uses symbolic) change this line in SConstruct.options file 'USE_LEX_YACC=0'
to this: 'USE_LEX_YACC=1'

11. follow the instructions in Projects/qt_viewer/README.md to set up the viewer
Last edited Jan 14 2014 by Russ Howes


