瀏覽代碼

tools/starpu_env: automatically detect StarPU installation directory

Nathalie Furmento 5 年之前
父節點
當前提交
d9ab12970b
共有 2 個文件被更改,包括 16 次插入21 次删除
  1. 5 6
      doc/doxygen/chapters/101_building.doxy
  2. 11 15
      tools/starpu_env.in

+ 5 - 6
doc/doxygen/chapters/101_building.doxy

@@ -221,14 +221,13 @@ the issue to the \c hwloc project, since this is what StarPU uses to detect the
 
 <br>
 A tool is provided to help setting all the environment variables
-needed by StarPU. If the given directory is a valid StarPU
-installation directory, calling the script <c>bin/starpu_env</c> will
-set in your current environment the variables <c>STARPU_PATH</c>,
-<c>LD_LIBRARY_PATH</c>, <c>PKG_CONFIG_PATH</c>, <c>PATH</c> and
-<c>MANPATH</c>.
+needed by StarPU. Once StarPU is installed in a specific directory,
+calling the script <c>bin/starpu_env</c> will set in your current
+environment the variables <c>STARPU_PATH</c>, <c>LD_LIBRARY_PATH</c>,
+<c>PKG_CONFIG_PATH</c>, <c>PATH</c> and <c>MANPATH</c>.
 
 \verbatim
-$ source ./bin/starpu_env .
+$ source $STARPU_PATH/bin/starpu_env
 \endverbatim
 
 \subsection IntegratingStarPUInABuildSystem Integrating StarPU in a Build System

+ 11 - 15
tools/starpu_env.in

@@ -20,9 +20,8 @@ usage()
 {
     echo "Tool to set StarPU environment variables"
     echo ""
-    echo "Usage: source $PROGNAME directory"
+    echo "Usage: source $PROGNAME"
     echo ""
-    echo "      directory must be a directory in which StarPU has been installed"
     echo ""
     echo "Options:"
     echo "	-h, --help          display this help and exit"
@@ -34,23 +33,20 @@ usage()
 if [ "$1" = "-v" ] || [ "$1" = "--version" ]
 then
     echo "$PROGNAME (@PACKAGE_NAME@) @PACKAGE_VERSION@"
-elif [ "$1" = "-h" ] || [ "$1" = "--help" ] || [ "$1" = "" ]
+elif [ "$1" = "-h" ] || [ "$1" = "--help" ]
 then
     usage
-elif test -d "$1"
-then
-    if test -f $1/bin/starpu_machine_display -a -f $1/lib/pkgconfig/libstarpu.pc
+else
+    starpu_prefix=$(realpath @prefix@)
+    if test -f $starpu_prefix/bin/starpu_machine_display -a -f $starpu_prefix/lib/pkgconfig/libstarpu.pc
     then
-	export STARPU_PATH=$(realpath $1)
-	echo "Setting StarPU environment for $STARPU_PATH"
-	export PKG_CONFIG_PATH=$STARPU_PATH/lib/pkgconfig:$PKG_CONFIG_PATH
-	export LD_LIBRARY_PATH=$STARPU_PATH/lib:$LD_LIBRARY_PATH
-	export PATH=$STARPU_PATH/bin:$PATH
-	export MANPATH=$STARPU_PATH/share/man:$MANPATH
+	echo "Setting StarPU environment for $starpu_prefix"
+	export PKG_CONFIG_PATH=$starpu_prefix/lib/pkgconfig:$PKG_CONFIG_PATH
+	export LD_LIBRARY_PATH=$starpu_prefix/lib:$LD_LIBRARY_PATH
+	export PATH=$starpu_prefix/bin:$PATH
+	export MANPATH=$starpu_prefix/share/man:$MANPATH
     else
-	echo "[Error] $1 is not a valid StarPU installation directory"
+	echo "[Error] $starpu_prefix is not a valid StarPU installation directory"
     fi
-else
-    usage
 fi