Skip to content

Commit

Permalink
Reverted to old formattation for mklib.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
Iximiel authored Nov 27, 2023
1 parent 3a2685d commit 1ff0a97
Showing 1 changed file with 20 additions and 14 deletions.
34 changes: 20 additions & 14 deletions scripts/mklib.sh
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
#! /usr/bin/env bash

if [ "$1" = --description ]; then
if [ "$1" = --description ] ; then
echo "compile one or more *.cpp files into a shared library"
echo " you can create and export the variable PLUMED_MKLIB_CFLAGS with some extra compile time flags to be used"
echo " you can create and export the variable PLUMED_MKLIB_LDFLAGS with some extra link time flags (and libraries) to be used"
exit 0
fi

if [ "$1" = --options ]; then
if [ "$1" = --options ] ; then
echo "--description --options"
exit 0
fi

if [ $# == 0 ]; then
if [ $# == 0 ]
then
echo "ERROR"
echo "type 'plumed mklib file1.cpp [file2.cpp etc]'"
exit 1
Expand All @@ -33,17 +34,20 @@ remover() {
trap "remover" EXIT
objs=""

for file; do
for file
do

if [[ "$file" != *.cpp ]]; then
if [[ "$file" != *.cpp ]] ;
then
echo "ERROR"
echo "type 'plumed mklib file1.cpp [file2.cpp etc]'"
exit 1
fi

obj="${file%%.cpp}".o

if [ ! -f "$file" ]; then

if [ ! -f "$file" ]
then
echo "ERROR: I cannot find file $file"
exit 1
fi
Expand All @@ -57,22 +61,24 @@ for file; do
toRemove="${toRemove} ${tmpfile} ${tmpfile}.bak"

if grep -q '^#include "\(bias\|colvar\|function\|sasa\|vatom\)\/ActionRegister.h"' "${tmpfile}"; then
echo >&2 'WARNING: using a legacy ActionRegister.h include path, please use <<#include "core/ActionRegister.h">>'
sed -i.bak 's%^#include ".*/ActionRegister.h"%#include "core/ActionRegister.h"%g' "${tmpfile}"
>&2 echo 'WARNING: using a legacy ActionRegister.h include path, please use <<#include "core/ActionRegister.h">>'
sed -i.bak 's%^#include ".*/ActionRegister.h"%#include "core/ActionRegister.h"%g' "${tmpfile}"
fi

if grep -q '^#include "\(cltools\)\/CLToolRegister.h"' "${tmpfile}"; then
echo >&2 'WARNING: using a legacy CLToolRegister.h include path, please use <<#include "core/CLToolRegister.h">>'
sed -i.bak 's%^#include ".*/CLToolRegister.h"%#include "core/CLToolRegister.h"%g' "${tmpfile}"
>&2 echo 'WARNING: using a legacy CLToolRegister.h include path, please use <<#include "core/CLToolRegister.h">>'
sed -i.bak 's%^#include ".*/CLToolRegister.h"%#include "core/CLToolRegister.h"%g' "${tmpfile}"
fi

rm -f "$obj"
eval "$compile" "$PLUMED_MKLIB_CFLAGS" "$tmpfile" -o "$obj" || {

eval "$compile" "$PLUMED_MKLIB_CFLAGS" -o "$obj" "$tmpfile" || {
echo "ERROR: compiling $file"
exit 1
}

objs="$objs $obj"

done

link_command="$link_uninstalled"
Expand Down

0 comments on commit 1ff0a97

Please sign in to comment.