aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authoreschnett <eschnett@4054007a-4839-4648-a056-eb81e030d849>2012-06-15 19:14:27 +0000
committereschnett <eschnett@4054007a-4839-4648-a056-eb81e030d849>2012-06-15 19:14:27 +0000
commitd97676c40363b112b0d4ef70d7af2da6876b8177 (patch)
tree3dfca07055a7603042ac03b4b468744a86d16779
parentf7daa9a42bf5a54a774aa081c0f7695097a3044a (diff)
Autodetect OpenCL libraries
git-svn-id: http://svn.cactuscode.org/projects/ExternalLibraries/OpenCL/trunk@16 4054007a-4839-4648-a056-eb81e030d849
-rw-r--r--configure.sh61
1 files changed, 52 insertions, 9 deletions
diff --git a/configure.sh b/configure.sh
index 86f564b..332639a 100644
--- a/configure.sh
+++ b/configure.sh
@@ -5,7 +5,9 @@
################################################################################
# Set up shell
-set -x # Output commands
+if [ "$(echo ${VERBOSE} | tr '[:upper:]' '[:lower:]')" = 'yes' ]; then
+ set -x # Output commands
+fi
set -e # Abort on errors
@@ -15,25 +17,66 @@ set -e # Abort on errors
################################################################################
if [ -z "${OPENCL_DIR}" ]; then
+ echo "BEGIN MESSAGE"
+ echo "OpenCL selected, but OPENCL_DIR not set. Checking some places..."
+ echo "END MESSAGE"
+
+ DIRS="/usr /usr/local /opt/local /usr/local/packages usr/local/apps /opt/local ${HOME} c:/packages/"
+ # look into each directory
+ for dir in $DIRS; do
+ # libraries might have different file extensions
+ for libext in a so dylib; do
+ # libraries can be in /lib or /lib64
+ for libdir in lib64 lib; do
+ FILES="$libdir/libOpenCL.${libext}"
+ # assume this is the one and check all needed files
+ OPENCL_DIR="$dir"
+ for file in $FILES; do
+ # discard this directory if one file was not found
+ if [ ! -r "$dir/$file" ]; then
+ unset OPENCL_DIR
+ break
+ fi
+ done
+ # don't look further if all files have been found
+ if [ -n "$OPENCL_DIR" ]; then
+ break
+ fi
+ done
+ # don't look further if all files have been found
+ if [ -n "$OPENCL_DIR" ]; then
+ break
+ fi
+ done
+ # don't look further if all files have been found
+ if [ -n "$OPENCL_DIR" ]; then
+ break
+ fi
+ done
+
+ # Prefer the system OpenCL on Mac OSX
if [ -r /System/Library/Frameworks/OpenCL.framework ]; then
OPENCL_DIR=/System/Library/Frameworks/OpenCL.framework
OPENCL_INC_DIRS=/System/Library/Frameworks/OpenCL.framework/Headers
OPENCL_LIB_DIRS=/System/Library/Frameworks/OpenCL.framework/Libraries
OPENCL_LIBS="-Wl,-framework -Wl,OpenCL"
- else
- echo "BEGIN ERROR"
- echo "OpenCL selected, but OPENCL_DIR not set."
- echo "END ERROR"
- exit 1
fi
fi
-# Set options
-: ${OPENCL_INC_DIRS:=${OPENCL_DIR}/include}
-: ${OPENCL_LIB_DIRS:=${OPENCL_DIR}/lib}
+
+################################################################################
+# Configure Cactus
+################################################################################
+
+# Set options
+if [ "${OPENCL_DIR}" != '/usr' -a "${OPENCL_DIR}" != '/usr/local' ]; then
+ : ${OPENCL_INC_DIRS:=${OPENCL_DIR}/include}
+ : ${OPENCL_LIB_DIRS:=${OPENCL_DIR}/lib}
+fi
: ${OPENCL_LIBS:=OpenCL}
+# Pass options to Cactus
echo "BEGIN MAKE_DEFINITION"
echo "HAVE_OPENCL = 1"
echo "OPENCL_DIR = ${OPENCL_DIR}"