#!/bin/bash

declare -r -i nThreads = 1

# unpack archives
tar -zxvf adept-1.1.tar.gz
tar -zxvf CppAD.tar.gz
tar -zxvf trilinos-12.4.2-Source.tar.gz
unzip FADBAD++-2.1.zip

# build CppAD
cd CppAD
mkdir build
mkdir local
cd build
cmake .. -Dcppad_prefix=../local
make -j $nThreads install
cd ../..

# build adept
cd adept-1.1
mkdir local
./configure --prefix=$PWD/local
make -j $nThreads install
cd ..

# build trilinos
cd trilinos-12.4.2-Source
mkdir build
mkdir local
cd build
cmake .. \
  -DCMAKE_BUILD_TYPE=RELEASE \
  -DCMAKE_INSTALL_PREFIX=../local \
  -DTrilinos_ENABLE_Sacado=ON \
  -DTrilinos_ENABLE_TESTS=OFF
make -j $nThreads install
cd ../..
