From e0e397d3f1007295f69e867743e0cf4096dfd45d Mon Sep 17 00:00:00 2001
From: Nicolas Marsic <marsic@temf.tu-darmstadt.de>
Date: Fri, 21 Apr 2017 18:17:32 +0200
Subject: [PATCH] dependency automatic handling script + README typos and fix

---
 README.txt      | 33 ++++++++++++++++++-----------
 dependencies.sh | 56 +++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 77 insertions(+), 12 deletions(-)
 create mode 100755 dependencies.sh

diff --git a/README.txt b/README.txt
index 306cad1..462e6ca 100644
--- a/README.txt
+++ b/README.txt
@@ -38,7 +38,9 @@ with:
   radius            circular contour radius
 
 Additional optional argument are available.
-Please run cim.py -h for more informations.
+Please run:
+  cim.py -h
+for more information.
 
 Dependencies
 ------------
@@ -51,8 +53,14 @@ The getdp module can be obtained by compiling GetDP:
   http://getdp.info
 Among other (and possibly optional) dependencies, GetDP relies on PETSc:
   https://www.mcs.anl.gov/petsc
+The shell script dependencies.sh should handle this automatically if you run:
+  ./dependencies.sh
+This script needs git. Don't forget to update your PYTHONPATH and
+LD_LIBRARY_PATH as instructed.
 
-The PETSc library should be compiled with the following features:
+If you want to handle the PETSc and GetDP libraries yourself, here are the
+options you will need. The PETSc library should be compiled with the following
+features:
   --with-clanguage=cxx
   --with-shared-libraries=1
   --with-x=0
@@ -61,14 +69,15 @@ The PETSc library should be compiled with the following features:
   --with-mpi=0
   --with-mpiuni-fortran-binding=0
   --download-mumps=yes
-the last feature being needed only if you want PETSc to automaticaly download
-and compile the MUMPS direct solver. In other words, PETSc should be compiled
-without MPI, with complex algebra and with a sequencial version of MUMPS.
+In other words, PETSc should be compiled without MPI, with complex algebra and
+with a sequential version of MUMPS. GetDP can then be compiled with the
+following options:
+  ENABLE_BUILD_DYNAMIC: ON
+  ENABLE_BUILD_SHARED:  ON
+  ENABLE_KERNEL:        ON
+  ENABLE_PETSC:         ON
+  ENABLE_WRAP_PYTHON:   ON
+If everything went fine, you should end up with the GetDP Python module:
+  getdp.py
 
-GetDP can then be compiled with the following options:
-  ENABLE_DYNAMIC:     ON
-  ENABLE_SHARED:      ON
-  ENABLE_KERNL:       ON
-  ENABLE_PETSC:       ON
-  ENABLE_WRAP_PYTHON: ON
-If everything went fine, you should endup with the GetDP Python module: getdp.py
+Enjoy!
diff --git a/dependencies.sh b/dependencies.sh
new file mode 100755
index 0000000..11d2546
--- /dev/null
+++ b/dependencies.sh
@@ -0,0 +1,56 @@
+#!/bin/sh
+echo "Creating dependencies folder: dep/"
+mkdir dep
+
+echo "Cloning PETSc"
+git clone -b maint https://bitbucket.org/petsc/petsc dep/petsc
+
+echo "Entering PETSc"
+PETSC_DIR=$(pwd)/dep/petsc
+PETSC_ARCH=linux-gnu-cxx-seq
+PETSC=$PETSC_DIR"/"$PETSC_ARCH
+cd dep/petsc
+
+echo "Configuring PETSc"
+./configure --with-clanguage=cxx --with-shared-libraries=1 --with-x=0 \
+            --with-scalar-type=complex --with-mumps-serial=yes --with-mpi=0 \
+            --with-mpiuni-fortran-binding=0 --download-mumps=yes
+
+echo "Compiling PETSc"
+make all
+
+echo "Checking PETSc"
+make test
+
+echo "Leaving PETSc"
+cd ..
+
+echo "Cloning GetDP"
+git clone http://gitlab.onelab.info/getdp/getdp.git getdp
+
+echo "Entering GetDP"
+cd getdp
+
+echo "Configuring GetDP"
+mkdir build
+cd build
+cmake -DDEFAULT=0 -DENABLE_BUILD_DYNAMIC=1 -DENABLE_BUILD_SHARED=1 \
+      -DENABLE_KERNEL=1 -DENABLE_PETSC=1 -DENABLE_WRAP_PYTHON=1 \
+      -DPython_ADDITIONAL_VERSIONS="2.7" ..
+
+echo "Compiling GetDP"
+GETDP=$(pwd)
+make
+
+echo "Leaving GetDP"
+cd ../../..
+
+echo "   "
+echo "+++"
+echo "PETSc and GetDP should be now compiled with the required features."
+echo "In order to use cim.py, a few additional steps are required."
+echo "We still need to add the libraries and the Python module in your path."
+echo "Please add the following in your .bashrc file (or equivalent):"
+echo "export PYTHONPATH="$GETDP":\$PYTHONPATH"
+echo "export LD_LIBRARY_PATH="$PETSC"/lib:"$GETDP":\$LD_LIBRARY_PATH"
+echo "+++"
-- 
GitLab