#!/usr/bin/env modbuild

#pbuild::supported_os 'Linux'

case $OS in 
	Linux )
		target='LINUX-X86_64-PMODULE'
		;;
	Darwin )
		target='MACOSX-GFORTRAN-INTEL-MPI'
		;;
esac

pbuild::configure() {
	cp -v "${BUILD_BLOCK_DIR}/${target}" "${MODULE_BUILDDIR}/configure"
	./configure.sh "${target}" || exit 1
}

pbuild::build() {
	make
}

pbuild::install() {
	mkdir -p "${PREFIX}/bin"
	cp "${MODULE_SRCDIR}/bin/cpmd.x" "${PREFIX}/bin"
}

pbuild::add_to_group 'MPI'
pbuild::set_runtime_dependencies "${COMPILER}" "${MPI}"
pbuild::set_build_dependencies "${COMPILER}" "${MPI}"
pbuild::compile_in_sourcetree
pbuild::make_all

