diff --git a/Allwmake b/Allwmake index f9b95653..18f08137 100755 --- a/Allwmake +++ b/Allwmake @@ -2,15 +2,6 @@ cd ${0%/*} || exit 1 # Run from this directory ########## CONFIGURATION - You may want to change these ######################## -# Note: system paths such as LD_LIBRARY_PATH, LIBRARY_PATH, or CPLUS_INCLUDE_PATH -# are currently NOT searched. Using these variables here also does not work. -# You need to specify the exact directories, without any list separators. - -# YAML-CPP include path - the PARENT of yaml-cpp/ (try running "locate yaml.h") -ADAPTER_YAML_CPP_INC="/usr/include/" -# YAML-CPP library path (try running "locate libyaml-cpp.") -ADAPTER_YAML_CPP_LIB="/usr/lib/x86_64-linux-gnu/" - # preCICE root path (should be already globally set) ADAPTER_PRECICE_ROOT="${PRECICE_ROOT}" @@ -19,13 +10,8 @@ ADAPTER_PRECICE_ROOT="${PRECICE_ROOT}" # specify its dependncies. # For an up-to-date list of dependencies, # look at https://github.com/precice/precice/wiki/Building -# C++ Boost library path - required from preCICE (try running "locate libboost_log.") -ADAPTER_BOOST_LIB="/usr/local/lib" -# PETSc library path - if required from preCICE (try running "locate libpetsc.") -ADAPTER_PETSC_LIB="${PETSC_DIR}/${PETSC_ARCH}/lib" # Uncomment to use preCICE as a static library: preCICE dependencies -# ADAPTER_PRECICE_DEP="-L${ADAPTER_PETSC_LIB} -lpetsc -lmpi_cxx -L${ADAPTER_BOOST_LIB} -lboost_system -lboost_filesystem -lboost_log -lboost_log_setup -lboost_thread -lboost_program_options -lpthread -lpython2.7" - +ADAPTER_PRECICE_DEP="-lpetsc -lmpi_cxx -lboost_system -lboost_filesystem -lboost_log -lboost_log_setup -lboost_thread -lboost_program_options -lpthread -lpython2.7 -lxml2" # Optional: Preprocessor flags ("-DADAPTER_DEBUG_MODE" enables debug messages) ADAPTER_PREP_FLAGS="-DADAPTER_DEBUG_MODE" @@ -41,25 +27,44 @@ ADAPTER_TARGET_DIR="${FOAM_USER_LIBBIN}" # Information header echo "Building the OpenFOAM adapter for preCICE..." -echo "Make sure that all the required dependencies (mainly yaml-cpp and preCICE) are installed and their paths set in this file are correct. System paths such as LD_LIBRARY_PATH are NOT searched.\n" +echo "Make sure that all the required dependencies (mainly yaml-cpp and preCICE) are installed.\n" + +# What is going on here: +# 1. get the colon-separated paths (e.g. the CPLUS_INCLUDE_PATH), +# 2. translate all the colons to new line characters, i.e. move each entry to a new line, +# 3. remove the empty lines. These would result from ":path" or "path:" or "path::path". +# 4. add the respective "-I" or "-L" in the beginning of the line, +# 5. translate the new line characters to "\", i.e. make everything again one line. + +# Extract the paths from the CPLUS_INCLUDE_PATH list and convert them to a sequence of "-I/path/ \" +if [ "${CPLUS_INCLUDE_PATH}" ]; then + ADAPTER_GLOBAL_CPLUS_INC_PATHS=$(echo $CPLUS_INCLUDE_PATH | tr ':' '\n' | sed '/^$/d' | sed 's/^/-I/' | tr '\n' ' \\') +fi + +# Extract the paths from the LD_LIBRARY_PATH list and convert them to a sequence of "-L/path/ \" +if [ "${LD_LIBRARY_PATH}" ]; then + ADAPTER_GLOBAL_LD_LIBRARY_PATHS=$(echo $LD_LIBRARY_PATH | tr ':' '\n' | sed '/^$/d' | sed 's/^/-L/' | tr '\n' ' \\') +fi + +# Extract the paths from the LIBRARY_PATH list and convert them to a sequence of "-L/path/ \" +if [ "${LIBRARY_PATH}" ]; then + ADAPTER_GLOBAL_LIBRARY_PATHS=$(echo $LIBRARY_PATH | tr ':' '\n' | sed '/^$/d' | sed 's/^/-L/' | tr '\n' ' \\') +fi # Export the environment variables -export ADAPTER_YAML_CPP_INC -export ADAPTER_YAML_CPP_LIB export ADAPTER_PRECICE_ROOT export ADAPTER_PRECICE_DEP export ADAPTER_PREP_FLAGS export ADAPTER_TARGET_DIR +export ADAPTER_GLOBAL_CPLUS_INC_PATHS +export ADAPTER_GLOBAL_LD_LIBRARY_PATHS +export ADAPTER_GLOBAL_LIBRARY_PATHS # Inform the user about the environment echo "Using the following environment variables:" -echo " ADAPTER_YAML_CPP_INC = ${ADAPTER_YAML_CPP_INC}" -echo " ADAPTER_YAML_CPP_LIB = ${ADAPTER_YAML_CPP_LIB}" echo " ADAPTER_PRECICE_ROOT = ${ADAPTER_PRECICE_ROOT}" if [ "${ADAPTER_PRECICE_DEP}" ]; then echo " preCICE dependencies:" - echo " ADAPTER_PETSC_LIB = ${ADAPTER_PETSC_LIB}" - echo " ADAPTER_BOOST_LIB = ${ADAPTER_BOOST_LIB}" echo " ADAPTER_PRECICE_DEP = ${ADAPTER_PRECICE_DEP}" else echo " preCICE dependencies: not specified (ok if shared library)" @@ -67,6 +72,9 @@ fi echo " ADAPTER_PREP_FLAGS = ${ADAPTER_PREP_FLAGS}" echo " ADAPTER_TARGET_DIR = ${ADAPTER_TARGET_DIR}" echo " ADAPTER_WMAKE_OPTIONS = ${ADAPTER_WMAKE_OPTIONS}" +echo " ADAPTER_GLOBAL_CPLUS_INC_PATHS = ${ADAPTER_GLOBAL_CPLUS_INC_PATHS}" +echo " ADAPTER_GLOBAL_LD_LIBRARY_PATHS = ${ADAPTER_GLOBAL_LD_LIBRARY_PATHS}" +echo " ADAPTER_GLOBAL_LIBRARY_PATHS = ${ADAPTER_GLOBAL_LIBRARY_PATHS}" echo "" # Run wmake (build the adapter) and check the exit code diff --git a/Make/options b/Make/options index c0dbe3e1..6b594583 100644 --- a/Make/options +++ b/Make/options @@ -7,8 +7,8 @@ EXE_INC = \ -I$(LIB_SRC)/TurbulenceModels/turbulenceModels/lnInclude \ -I$(LIB_SRC)/TurbulenceModels/compressible/lnInclude \ -I$(LIB_SRC)/TurbulenceModels/incompressible/lnInclude \ + $(ADAPTER_GLOBAL_CPLUS_INC_PATHS) \ -I$(ADAPTER_PRECICE_ROOT)/src/precice \ - -I${ADAPTER_YAML_CPP_INC} \ -I../ \ $(ADAPTER_PREP_FLAGS) @@ -17,8 +17,9 @@ LIB_LIBS = \ -lmeshTools \ -lcompressibleTurbulenceModels \ -lincompressibleTurbulenceModels \ + $(ADAPTER_GLOBAL_LIBRARY_PATHS) \ + $(ADAPTER_GLOBAL_LD_LIBRARY_PATHS) \ -L$(ADAPTER_PRECICE_ROOT)/build/last \ -lprecice \ - ${ADAPTER_PRECICE_DEP} \ - -L${ADAPTER_YAML_CPP_LIB} \ + $(ADAPTER_PRECICE_DEP) \ -lyaml-cpp