Skip to content

Commit

Permalink
dynamically resolve envs
Browse files Browse the repository at this point in the history
  • Loading branch information
zhongxiang117 committed Jun 14, 2024
1 parent 2e07dd1 commit cc864a1
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 6 deletions.
9 changes: 7 additions & 2 deletions patches/patch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -284,14 +284,19 @@ case "$action" in
test -n "$quiet" || echo "Executing plumed_before_patch function"
plumed_before_patch
fi
if test -f "$PLUMED_INCLUDEDIR/$PLUMED_PROGRAM_NAME/wrapper/Plumed.h"; then
header="$PLUMED_INCLUDEDIR/$PLUMED_PROGRAM_NAME/wrapper/Plumed.h"
else
header=`realpath "$PLUMED_ROOT/../../include/plumed/wrapper/Plumed.h"`
fi
if test -n "$include" ; then
test -n "$quiet" || echo "Including Plumed.h, Plumed.inc, and Plumed.cmake ($mode mode)"
echo "#include \"$PLUMED_INCLUDEDIR/$PLUMED_PROGRAM_NAME/wrapper/Plumed.h\"" > Plumed.h
echo "#include \"$header\"" > Plumed.h
echo "include $PLUMED_ROOT/src/lib/Plumed.inc.$mode" > Plumed.inc
echo "include($PLUMED_ROOT/src/lib/Plumed.cmake.$mode)" > Plumed.cmake
else
test -n "$quiet" || echo "Linking Plumed.h, Plumed.inc, and Plumed.cmake ($mode mode)"
ln -fs "$PLUMED_INCLUDEDIR/$PLUMED_PROGRAM_NAME/wrapper/Plumed.h" Plumed.h
ln -fs "$header" Plumed.h
ln -fs "$PLUMED_ROOT/src/lib/Plumed.inc.$mode" Plumed.inc
ln -fs "$PLUMED_ROOT/src/lib/Plumed.cmake.$mode" Plumed.cmake
fi
Expand Down
28 changes: 24 additions & 4 deletions src/lib/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -446,16 +446,36 @@ ifeq ($(PLUMED_INSTALL),Install)
# If plumed is installed, single paths can be overridden using env vars
@echo "export PLUMED_IS_INSTALLED=yes" >> $@
@echo "export PLUMED_ROOT=\"\$${PLUMED_ROOT-$(libdir)/$(program_name)}\"" >> $@
@echo "export PLUMED_INCLUDEDIR=\"\$${PLUMED_INCLUDEDIR-$(includedir)}\"" >> $@
@echo "export PLUMED_HTMLDIR=\"\$${PLUMED_HTMLDIR=$(htmldir)}\"" >> $@
@echo "PLUMED_INCLUDEDIR=\"\$${PLUMED_INCLUDEDIR-$(includedir)}\"" >> $@
@echo "if test -d \"\$$PLUMED_INCLUDEDIR/plumed\"; then" >> $@
@echo " export PLUMED_INCLUDEDIR=\$$PLUMED_INCLUDEDIR" >> $@
@echo "else" >> $@
@echo " export PLUMED_INCLUDEDIR=\$$PLUMED_ROOT/../../include" >> $@
@echo "fi" >> $@
@echo "PLUMED_HTMLDIR=\"\$${PLUMED_HTMLDIR=$(htmldir)}\"" >> $@
@echo "if test -d \"\$$PLUMED_HTMLDIR\"; then" >> $@
@echo " export PLUMED_HTMLDIR=\$$PLUMED_HTMLDIR" >> $@
@echo "else" >> $@
@echo " export PLUMED_HTMLDIR=\$$PLUMED_ROOT/../../share/doc/plumed" >> $@
@echo "fi" >> $@
@echo "export PLUMED_PROGRAM_NAME=\"\$${PLUMED_PROGRAM_NAME-$(program_name)}\"" >> $@
@echo "export PLUMED_VERSION=$(VERSION)" >> $@
@echo "source \"\$$PLUMED_ROOT\"/scripts/$(subst plumed-,,$(@F)).sh" >> $@
else
@echo "export PLUMED_IS_INSTALLED=no" >> $@
@echo "export PLUMED_ROOT=\"\$${PLUMED_ROOT-$(realpath ../../)}\"" >> $@
@echo "export PLUMED_INCLUDEDIR=\"\$${PLUMED_ROOT}/src/include\"" >> $@
@echo "export PLUMED_HTMLDIR=\"\$${PLUMED_ROOT}\"" >> $@
@echo "PLUMED_INCLUDEDIR=\"\$${PLUMED_INCLUDEDIR-$(includedir)}\"" >> $@
@echo "if test -d \"\$$PLUMED_INCLUDEDIR/plumed\"; then" >> $@
@echo " export PLUMED_INCLUDEDIR=\$$PLUMED_INCLUDEDIR" >> $@
@echo "else" >> $@
@echo " export PLUMED_INCLUDEDIR=\$$PLUMED_ROOT/../../include" >> $@
@echo "fi" >> $@
@echo "PLUMED_HTMLDIR=\"\$${PLUMED_HTMLDIR=$(htmldir)}\"" >> $@
@echo "if test -d \"\$$PLUMED_HTMLDIR\"; then" >> $@
@echo " export PLUMED_HTMLDIR=\$$PLUMED_HTMLDIR" >> $@
@echo "else" >> $@
@echo " export PLUMED_HTMLDIR=\$$PLUMED_ROOT/../../share/doc/plumed" >> $@
@echo "fi" >> $@
@echo "export PLUMED_PROGRAM_NAME=plumed" >> $@
@echo "export PLUMED_VERSION=$(VERSION)" >> $@
@echo "source \"\$$PLUMED_ROOT\"/scripts/$(subst plumed-,,$(@F)).sh" >> $@
Expand Down

0 comments on commit cc864a1

Please sign in to comment.