aboutsummaryrefslogtreecommitdiff
path: root/configure.sh
blob: 332639a221e114ff12b041be97549c164ca936b7 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#! /bin/bash

################################################################################
# Prepare
################################################################################

# Set up shell
if [ "$(echo ${VERBOSE} | tr '[:upper:]' '[:lower:]')" = 'yes' ]; then
    set -x                      # Output commands
fi
set -e                          # Abort on errors



################################################################################
# Configure Cactus
################################################################################

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"
    fi
fi



################################################################################
# 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}"
echo "OPENCL_INC_DIRS = ${OPENCL_INC_DIRS}"
echo "OPENCL_LIB_DIRS = ${OPENCL_LIB_DIRS}"
echo "OPENCL_LIBS     = ${OPENCL_LIBS}"
echo "END MAKE_DEFINITION"

echo 'INCLUDE_DIRECTORY $(OPENCL_INC_DIRS)'
echo 'LIBRARY_DIRECTORY $(OPENCL_LIB_DIRS)'
echo 'LIBRARY           $(OPENCL_LIBS)'