Skip to content
Snippets Groups Projects
Commit 21c43f76 authored by Giovanni Bussi's avatar Giovanni Bussi
Browse files

Added "plumed mklib" tool

A compile_options.sh file is generated by make in the src directory
and it is used to properly compile a .cpp into a .so (or .dylib on mac).
Just type "plumed mklib pippo.cpp". Still it should be improved in term
of linking of multiple .cpp files.
parent c29b3bfc
No related branches found
No related tags found
No related merge requests found
......@@ -2,3 +2,4 @@ Plumed.inc*
PlumedConfig.h
*.cdep
*.cppdep
/compile_options.sh
......@@ -27,7 +27,9 @@ ALL_SRC_DEP=$(SRC_KERNEL:.cpp=.cppdep) $(SRC_WRAPPER:.cpp=.cppdep) $(SRC_DYNAMIC
.PHONY: all clean
ifdef GCCDEP
all: libplumedKernel.$(SOEXT) libplumed.$(SOEXT) Plumed.o Plumed.inc Plumed.inc.runtime Plumed.inc.shared Plumed.inc.static
all: libplumedKernel.$(SOEXT) libplumed.$(SOEXT) Plumed.o \
Plumed.inc Plumed.inc.runtime Plumed.inc.shared Plumed.inc.static \
compile_options.sh
else
all:
@echo No configuration available
......@@ -46,6 +48,11 @@ libplumedKernel.$(SOEXT): $(OBJ_KERNEL)
libplumed.$(SOEXT): $(OBJ_KERNEL) $(OBJ_WRAPPER)
$(LDSO) -o $@ $^ $(DYNAMIC_LIBS)
compile_options.sh:
echo "compile='"$(CXX) -c -I$(realpath $(srcdir)) $(CPPFLAGS) $(CXXFLAGS)"'" > $@
echo "link='"$(LDSO) -o"'" >> $@
echo "soext='"$(SOEXT)"'" >> $@
clean:
rm -f *.o
rm -f *.cdep
......@@ -53,6 +60,7 @@ clean:
rm -f PlumedConfig.h
rm -f Plumed.inc*
rm -f *~
rm -f compile_options.sh
ifdef SOEXT
rm -f *.$(SOEXT)
endif
......
#! /bin/bash
source $PLUMED_ROOT/src/compile_options.sh
if [ "$1" = --description ] ; then
echo "compile a .cpp file into a shared library"
exit 0
fi
if [ $# != 1 ] || [[ "$1" != *.cpp ]] ;
then
echo "ERROR"
echo "type 'plumed mklib file.cpp'"
exit 1
fi
file="$1"
obj="${file%%.cpp}".o
lib="${file%%.cpp}".$soext
if [ ! -f "$file" ]
then
echo "ERROR: I cannot find file $file"
exit 1
fi
$compile "$file" -o "$obj" && $link "$lib" "$obj"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment