2013-10-25 17:58:40 +08:00
|
|
|
#!/bin/bash
|
|
|
|
# PATCH SCRIPT FOR QE Makefiles with addson
|
|
|
|
#
|
|
|
|
|
|
|
|
# this script needs to be launched from the root directory of the host code
|
|
|
|
# two arguments are neede where the addson source code is and
|
|
|
|
# where the source code has to be linked in order to be
|
|
|
|
# compiled by QE
|
|
|
|
|
|
|
|
# This script has been adapted from an original patch script
|
|
|
|
# of plumed (www.plumed-code.org)
|
|
|
|
|
|
|
|
destination="$PWD"
|
2014-04-28 20:46:24 +08:00
|
|
|
#echo "root directory of host package: $destination"
|
2013-10-25 17:58:40 +08:00
|
|
|
|
2013-10-25 19:47:39 +08:00
|
|
|
# bisogna prendere il nome del plugin in input
|
2013-10-28 21:53:31 +08:00
|
|
|
ADDSON_NAME="$1"
|
2013-10-25 19:47:39 +08:00
|
|
|
|
2013-10-28 21:53:31 +08:00
|
|
|
LINKED_FILES="$2/*.f90"
|
|
|
|
WHERE_LINKS="$3/"
|
2013-10-25 17:58:40 +08:00
|
|
|
|
2014-05-15 17:15:20 +08:00
|
|
|
echo "The NAME of the addson is: $ADDSON_NAME"
|
|
|
|
echo "LINKED_FILES are: $LINKED_FILES"
|
|
|
|
echo "WHERE_LINKS are: $WHERE_LINKS"
|
2013-10-25 17:58:40 +08:00
|
|
|
|
|
|
|
function to_do_before_patch () {
|
|
|
|
echo > /dev/null
|
2016-06-25 15:26:50 +08:00
|
|
|
cp $destination/make.inc $destination/make.inc.pre$ADDSON_NAME
|
2013-10-28 21:53:31 +08:00
|
|
|
cp $destination/$WHERE_LINKS/Makefile $destination/$WHERE_LINKS/Makefile.pre$ADDSON_NAME
|
2014-02-25 21:26:45 +08:00
|
|
|
if test -e $destination/$WHERE_LINKS/make.depend ; then
|
|
|
|
cp $destination/$WHERE_LINKS/make.depend $destination/$WHERE_LINKS/make.depend.pre$ADDSON_NAME
|
|
|
|
fi
|
2013-10-25 17:58:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function to_do_after_patch () {
|
|
|
|
{
|
2013-10-28 21:53:31 +08:00
|
|
|
echo -n "${ADDSON_NAME}_OBJECTS="
|
2013-10-25 17:58:40 +08:00
|
|
|
for file in $destination/$LINKED_FILES
|
|
|
|
do f=${file##*/}
|
|
|
|
echo " \\"
|
|
|
|
echo -n " ${f%.f90}.o"
|
|
|
|
done
|
|
|
|
echo
|
2013-10-28 21:53:31 +08:00
|
|
|
echo -n "${ADDSON_NAME}_SRC="
|
2013-10-25 17:58:40 +08:00
|
|
|
for file in $destination/$LINKED_FILES
|
|
|
|
do f=${file##*/}
|
|
|
|
echo " \\"
|
|
|
|
echo -n " ${f%.f90}.f90"
|
|
|
|
done
|
|
|
|
echo
|
|
|
|
echo
|
2014-02-25 19:12:25 +08:00
|
|
|
} >> $destination/$WHERE_LINKS/$ADDSON_NAME.inc
|
2013-10-25 17:58:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function to_do_before_revert () {
|
2014-02-25 19:12:25 +08:00
|
|
|
rm $destination/$WHERE_LINKS/$ADDSON_NAME.inc
|
2013-10-25 19:47:39 +08:00
|
|
|
echo > /dev/null
|
2013-10-25 17:58:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
function to_do_after_revert () {
|
|
|
|
echo > /dev/null
|
2016-06-25 15:26:50 +08:00
|
|
|
mv $destination/make.inc.pre$ADDSON_NAME $destination/make.inc
|
2013-10-28 21:53:31 +08:00
|
|
|
mv $destination/$WHERE_LINKS/Makefile.pre$ADDSON_NAME $destination/$WHERE_LINKS/Makefile
|
2014-02-25 21:26:45 +08:00
|
|
|
if test -e $destination/$WHERE_LINKS/make.depend.pre$ADDSON_NAME ; then \
|
|
|
|
mv $destination/$WHERE_LINKS/make.depend.pre$ADDSON_NAME $destination/$WHERE_LINKS/make.depend ; fi
|
2013-10-25 17:58:40 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
#########
|
|
|
|
|
|
|
|
NAME="$0"
|
|
|
|
echo "NAME $NAME "
|
|
|
|
if test -e $destination/install/addsontool.sh ; then
|
|
|
|
source $destination/install/addsontool.sh
|
|
|
|
else
|
|
|
|
echo "missing file addsontool.sh in install directory"
|
|
|
|
EXIT
|
|
|
|
fi
|