#!/usr/bin/env modbuild

pbuild::set_download_url "https://github.com/QEF/q-e/archive/$P-$V.tar.gz"
echo "https://github.com/QEF/q-e/archive/$P-$V.tar.gz"

pbuild::add_to_group 'MPI'

pbuild::install_docfiles License README.md CONTRIBUTING.md

pbuild::compile_in_sourcetree


pbuild::configure() {
  mkdir -p ${PREFIX}
  ./configure -enable-openmp --with-prefix="${PREFIX}/bin" --prefix="${PREFIX}/bin"
}

pbuild::compile() {
  make all
}

pbuild::install() {
   # Due to bug in: https://gitlab.com/QEF/q-e/commit/88e6558646dbbcfcafa5f3fa758217f6062ab91c.diff
   #   Deploying custom install procedure
   mkdir -p ${PREFIX}/bin
   cd ${BUILD_DIR}
   for x in `find * ! -path "test-suite/*" -name *.x -type f` ; do 
     cp $x ${PREFIX}/bin/
   done
   echo 'Quantum ESPRESSO binaries installed in ${PREFIX}/bin'
  # make install
}
