blob: f6a0811d3f8d4f07a1e4f196fd0cb0a1d8207a1d (
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
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
|
#! /bin/bash
################################################################################
# Prepare
################################################################################
# Set up shell
if [ "$(echo ${VERBOSE} | tr '[:upper:]' '[:lower:]')" = 'yes' ]; then
set -x # Output commands
fi
set -e # Abort on errors
################################################################################
# Search
################################################################################
if [ -z "${GSL_DIR}" ]; then
echo "BEGIN MESSAGE"
echo "GSL selected, but GSL_DIR not set. Checking some places..."
echo "END MESSAGE"
FILES="include/gsl/gsl_math.h"
DIRS="/usr /usr/local /usr/local/gsl /usr/local/packages/gsl /usr/local/apps/gsl ${HOME} c:/packages/gsl"
for dir in $DIRS; do
GSL_DIR="$dir"
for file in $FILES; do
if [ ! -r "$dir/$file" ]; then
unset GSL_DIR
break
fi
done
if [ -n "$GSL_DIR" ]; then
break
fi
done
if [ -z "$GSL_DIR" ]; then
echo "BEGIN MESSAGE"
echo "GSL not found"
echo "END MESSAGE"
else
echo "BEGIN MESSAGE"
echo "Found GSL in ${GSL_DIR}"
echo "END MESSAGE"
fi
fi
################################################################################
# Build
################################################################################
if [ -z "${GSL_DIR}" \
-o "$(echo "${GSL_DIR}" | tr '[a-z]' '[A-Z]')" = 'BUILD' ]
then
echo "BEGIN MESSAGE"
echo "Using bundled GSL..."
echo "END MESSAGE"
# Check for required tools. Do this here so that we don't require
# them when using the system library.
if [ "x$TAR" = x ] ; then
echo 'BEGIN ERROR'
echo 'Could not find tar command.'
echo 'Please make sure that the (GNU) tar command is present,'
echo 'and that the TAR variable is set to its location.'
echo 'END ERROR'
exit 1
fi
if [ "x$PATCH" = x ] ; then
echo 'BEGIN ERROR'
echo 'Could not find patch command.'
echo 'Please make sure that the patch command is present,'
echo 'and that the PATCH variable is set to its location.'
echo 'END ERROR'
exit 1
fi
# Set locations
THORN=GSL
BUILD_DIR=${SCRATCH_BUILD}/build/${THORN}
if [ -z "${GSL_INSTALL_DIR}" ]; then
INSTALL_DIR=${SCRATCH_BUILD}/external/${THORN}
else
echo "BEGIN MESSAGE"
echo "Installing GSL into ${GSL_INSTALL_DIR} "
echo "END MESSAGE"
INSTALL_DIR=${GSL_INSTALL_DIR}
fi
GSL_DIR=${INSTALL_DIR}
GSL_INC_DIRS="$GSL_DIR/include"
GSL_LIB_DIRS="$GSL_DIR/lib"
GSL_LIBS="gsl gslcblas"
else
THORN=GSL
DONE_FILE=${SCRATCH_BUILD}/done/${THORN}
mkdir ${SCRATCH_BUILD}/done 2> /dev/null || true
date > ${DONE_FILE}
fi
################################################################################
# Configure Cactus
################################################################################
# Pass configuration options to build script
echo "BEGIN MAKE_DEFINITION"
echo "GSL_INSTALL_DIR = ${GSL_INSTALL_DIR}"
echo "END MAKE_DEFINITION"
# Set options
if [ -x ${GSL_DIR}/bin/gsl-config ]; then
inc_dirs="$(${GSL_DIR}/bin/gsl-config --cflags)"
lib_dirs="$(${GSL_DIR}/bin/gsl-config --libs)"
libs="$(${GSL_DIR}/bin/gsl-config --libs)"
# Translate option flags into Cactus options:
# - for INC_DIRS, remove -I prefix from flags
# - for LIB_DIRS, remove all -l flags, and remove -L prefix from flags
# - for LIBS, keep only -l flags, and remove -l prefix from flags
GSL_INC_DIRS="$(echo '' $(for flag in $inc_dirs; do echo '' $flag; done | sed -e 's/^ -I//'))"
GSL_LIB_DIRS="$(echo '' $(for flag in $lib_dirs; do echo '' $flag; done | grep -v '^ -l' | sed -e 's/^ -L//'))"
GSL_LIBS="$(echo '' $(for flag in $libs; do echo '' $flag; done | grep '^ -l' | sed -e 's/^ -l//'))"
fi
GSL_INC_DIRS="$(${CCTK_HOME}/lib/sbin/strip-incdirs.sh ${GSL_INC_DIRS})"
GSL_LIB_DIRS="$(${CCTK_HOME}/lib/sbin/strip-libdirs.sh ${GSL_LIB_DIRS})"
# Pass options to Cactus
echo "BEGIN MAKE_DEFINITION"
echo "GSL_DIR = ${GSL_DIR}"
echo "GSL_INC_DIRS = ${GSL_INC_DIRS}"
echo "GSL_LIB_DIRS = ${GSL_LIB_DIRS}"
echo "GSL_LIBS = ${GSL_LIBS}"
echo "END MAKE_DEFINITION"
echo 'INCLUDE_DIRECTORY $(GSL_INC_DIRS)'
echo 'LIBRARY_DIRECTORY $(GSL_LIB_DIRS)'
echo 'LIBRARY $(GSL_LIBS)'
|