#!/bin/sh

# Settings

PKG_NAME=hdf5
NCORES=`sysctl hw.ncpu | awk '{print $2}'`

# Work out the root directory

pushd ../.. > /dev/null
ROOT_DIR=`pwd`
popd > /dev/null

# Change into build dir

BUILD_DIR=$ROOT_DIR/src/$PKG_NAME

echo "Building in $BUILD_DIR"

cd $BUILD_DIR

# Clean up

make distclean

# Configure

export DYLD_LIBRARY_PATH=$ROOT_DIR/lib:$DYLD_LIBRARY_PATH

FC=gfortran ./configure --build=x86_64-apple-darwin`uname -r` \
    --prefix=$ROOT_DIR --enable-fortran 

# Build

make -j$NCORES

# Install

make install

# Finish
