| 0 | 1 #/bin/bash | 
|  | 2 # | 
|  | 3 # This program is free software; you can redistribute it and/or modify | 
|  | 4 # it under the terms of the GNU General Public License as published by | 
|  | 5 # the Free Software Foundation; either version 3 of the License, or | 
|  | 6 # (at your option) any later version. | 
|  | 7 # | 
|  | 8 # Copyright (C) 2009-2013 Max Planck Society, Sloan-Kettering Institute | 
|  | 9 # | 
|  | 10 | 
|  | 11 set -e | 
|  | 12 echo "To get more information please run: configure -h" | 
|  | 13 if [ $# != "0" ]; | 
|  | 14 then | 
|  | 15 		if [ "$1" == "-h" -o $# != "1" ]; | 
|  | 16         then | 
|  | 17 		  echo Usage: $0 -h   \(this help\) | 
|  | 18 		  echo Usage: $0 -i   \(interactive configuration\) | 
|  | 19 		  echo Usage: $0 [-a] \(automatic configuration\) | 
|  | 20   		  exit -1 | 
|  | 21         fi | 
|  | 22 fi | 
|  | 23 | 
|  | 24 . ./bin/rdiff_config.sh | 
|  | 25 | 
|  | 26 echo ====================================== | 
|  | 27 echo  rDiff configure \(version $RDIFF_VERSION\) | 
|  | 28 echo ====================================== | 
|  | 29 echo | 
|  | 30 | 
|  | 31 if [ "$1" == "-i" ]; | 
|  | 32 then | 
|  | 33   echo rDiff base directory \(currently set to \"$RDIFF_PATH\", suggest to set to \"`pwd`\", used if left empty\) | 
|  | 34   read RDIFF_PATH | 
|  | 35 else | 
|  | 36   echo "Running automatic configuration" | 
|  | 37   RDIFF_PATH="" | 
|  | 38 fi | 
|  | 39 if [ "$RDIFF_PATH" == "" ]; | 
|  | 40 then | 
|  | 41 	RDIFF_PATH=`pwd` | 
|  | 42 fi | 
|  | 43 echo '=>' Setting rDiff base directory to \"$RDIFF_PATH\" | 
|  | 44 echo | 
|  | 45 | 
|  | 46 if [ "$1" == "-i" ]; | 
|  | 47 then | 
|  | 48   echo SAMTools directory \(currently set to \"$RDIFF_SAMTOOLS_BIN_DIR\", system version used if left empty\) | 
|  | 49   read RDIFF_SAMTOOLS_BIN_DIR | 
|  | 50 else | 
|  | 51   echo Checking for samtools | 
|  | 52   RDIFF_SAMTOOLS_BIN_DIR="" | 
|  | 53 fi | 
|  | 54 if [ "$RDIFF_SAMTOOLS_BIN_DIR" == "" ]; | 
|  | 55 then | 
|  | 56 	if [ "$(which samtools)" != "" ] ; | 
|  | 57 	then | 
|  | 58 		RDIFF_SAMTOOLS_BIN_DIR=$(which samtools) | 
|  | 59 	    if [ -f $(dirname $(which samtools))/../include/bam/sam.h ] | 
|  | 60 	    then | 
|  | 61 			RDIFF_SAMTOOLS_INCLUDE_DIR=$(dirname $(which samtools))/../include/bam/ | 
|  | 62 			echo "Include found: $RDIFF_SAMTOOLS_INCLUDE_DIR" | 
|  | 63 	    elif [ -f $(dirname $(which samtools))/sam.h ] | 
|  | 64 	    then | 
|  | 65 	               RDIFF_SAMTOOLS_INCLUDE_DIR=$(dirname $(which samtools))/ | 
|  | 66                        echo "Include found: $RDIFF_SAMTOOLS_INCLUDE_DIR" | 
|  | 67 	    else | 
|  | 68 			echo "ERROR: Include sam.h include not found" | 
|  | 69 			exit -1 ; | 
|  | 70 	    fi | 
|  | 71 	    if [ -f $(dirname $(which samtools))/../lib/libbam.a ] | 
|  | 72 	    then | 
|  | 73 			RDIFF_SAMTOOLS_LIB_DIR=$(dirname $(which samtools))/../lib/ | 
|  | 74 			echo "Library found: $RDIFF_SAMTOOLS_LIB_DIR" | 
|  | 75 	    elif [ -f $(dirname $(which samtools))/libbam.a ] | 
|  | 76 	    then | 
|  | 77 		       RDIFF_SAMTOOLS_LIB_DIR=$(dirname $(which samtools))/ | 
|  | 78                        echo "Library found: $RDIFF_SAMTOOLS_LIB_DIR" | 
|  | 79 	    else | 
|  | 80 			echo "ERROR: Library libbam.a not found" | 
|  | 81 			exit -1 ; | 
|  | 82 	    fi | 
|  | 83 	else | 
|  | 84 	    echo SAMTools libraries not found | 
|  | 85 	    echo please run interactive mode: ./configure -i | 
|  | 86 	    exit -1 ; | 
|  | 87 	fi | 
|  | 88 else | 
|  | 89 	if [ ! -f $RDIFF_SAMTOOLS_BIN_DIR ]; | 
|  | 90 	then | 
|  | 91 		echo "ERROR: Binary $RDIFF_SAMTOOLS_BIN_DIR not found" | 
|  | 92                 echo please run interactive mode: ./configure -i | 
|  | 93 		exit -1 ; | 
|  | 94 	fi | 
|  | 95 | 
|  | 96 	echo SAMTools Include directory \(currently set to \"$RDIFF_SAMTOOLS_INCLUDE_DIR\"\) | 
|  | 97 	read RDIFF_SAMTOOLS_INCLUDE_DIR | 
|  | 98 	if [ ! -f $RDIFF_SAMTOOLS_INCLUDE_DIR/sam.h ] | 
|  | 99 	then | 
|  | 100 		echo "ERROR: Include $RDIFF_SAMTOOLS_INCLUDE_DIR/sam.h include not found" | 
|  | 101                 echo please run interactive mode: ./configure -i | 
|  | 102 		exit -1 ; | 
|  | 103 	fi | 
|  | 104 | 
|  | 105 	echo SAMTools library directory \(currently set to \"$RDIFF_SAMTOOLS_LIB_DIR\"\) | 
|  | 106 	read RDIFF_SAMTOOLS_LIB_DIR | 
|  | 107 	if [ ! -f $RDIFF_SAMTOOLS_LIB_DIR/libbam.a ] | 
|  | 108 	then | 
|  | 109 		echo "ERROR: Library $RDIFF_SAMTOOLS_LIB_DIR/libbam.a include not found" | 
|  | 110                 echo please run interactive mode: ./configure -i | 
|  | 111 		exit -1 ; | 
|  | 112 	fi | 
|  | 113 fi | 
|  | 114 echo '=>' Setting samtools directory to \"$RDIFF_SAMTOOLS_BIN_DIR\" | 
|  | 115 echo | 
|  | 116 | 
|  | 117 if [ "$1" == "-i" ]; | 
|  | 118 then | 
|  | 119   echo Path to the python binary \(currently set to \"$RDIFF_PYTHON_PATH\", system version used, if left empty\) | 
|  | 120   read RDIFF_PYTHON_PATH | 
|  | 121 else | 
|  | 122   echo Checking for python and Scipy | 
|  | 123   RDIFF_PYTHON_PATH="" | 
|  | 124 fi | 
|  | 125 if [ "$RDIFF_PYTHON_PATH" == "" ]; | 
|  | 126 then | 
|  | 127 	python_found= | 
|  | 128     scipy_found= | 
|  | 129 	for i in python python2.7 python2.6 python2.5 python2.4; | 
|  | 130     do | 
|  | 131       RDIFF_PYTHON_PATH=`which $i` | 
|  | 132   	  python_found=$i | 
|  | 133   	  if [ "$RDIFF_PYTHON_PATH" != "" ]; | 
|  | 134  	  then | 
|  | 135 	    scipy=`echo import scipy | $RDIFF_PYTHON_PATH 2>&1 | grep  -e ImportError|wc -l` | 
|  | 136 		if [ $scipy == "0" ]; | 
|  | 137         then | 
|  | 138 		  scipy_found=$RDIFF_PYTHON_PATH | 
|  | 139           break | 
|  | 140 		fi | 
|  | 141 	  fi | 
|  | 142     done | 
|  | 143     if [ "$python_found" == "" ]; | 
|  | 144     then | 
|  | 145       echo "ERROR: Python not found" | 
|  | 146       echo please run interactive mode: ./configure -i | 
|  | 147       exit -1 | 
|  | 148     fi | 
|  | 149     if [ "$scipy_found" == "" ]; | 
|  | 150     then | 
|  | 151       echo "ERROR: Scipy not found (for $python_found)" | 
|  | 152       echo please run interactive mode: ./configure -i | 
|  | 153       exit -1 | 
|  | 154     fi | 
|  | 155 fi | 
|  | 156 echo '=>' Setting Python path to \"$RDIFF_PYTHON_PATH\" | 
|  | 157 echo | 
|  | 158 | 
|  | 159 RDIFF_INTERPRETER="octave" | 
|  | 160 if [ "$RDIFF_INTERPRETER" == 'octave' ]; | 
|  | 161 then | 
|  | 162   if [ "$1" == "-i" ]; | 
|  | 163   then | 
|  | 164 	echo Please enter the full path to octave \(currently set to \"$RDIFF_OCTAVE_BIN_PATH\", system version used, if left empty\) | 
|  | 165 	read RDIFF_OCTAVE_BIN_PATH | 
|  | 166   else | 
|  | 167     RDIFF_OCTAVE_BIN_PATH="" | 
|  | 168 	echo checking for octave | 
|  | 169   fi | 
|  | 170 	if [ "$RDIFF_OCTAVE_BIN_PATH" == "" ]; | 
|  | 171 	then | 
|  | 172 	    RDIFF_OCTAVE_BIN_PATH=`which octave` | 
|  | 173 		if [ "$RDIFF_OCTAVE_BIN_PATH" == "" ]; | 
|  | 174 		then | 
|  | 175 			echo octave not found | 
|  | 176                         echo please run interactive mode: ./configure -i | 
|  | 177 			exit -1 | 
|  | 178 		fi | 
|  | 179 	fi | 
|  | 180 	echo '=>' Setting octave\'s path to \"$RDIFF_OCTAVE_BIN_PATH\" | 
|  | 181   if [ "$1" == "-i" ]; | 
|  | 182   then | 
|  | 183 	echo Please enter the full path to mkoctfile \(currently set to \"$RDIFF_OCTAVE_MKOCT\", system version used, if left empty\) | 
|  | 184 	read RDIFF_OCTAVE_MKOCT | 
|  | 185   else | 
|  | 186     RDIFF_OCTAVE_MKOCT="" | 
|  | 187   fi | 
|  | 188 	if [ "$RDIFF_OCTAVE_MKOCT" == "" ]; | 
|  | 189 	then | 
|  | 190 	    RDIFF_OCTAVE_MKOCT=`which mkoctfile` | 
|  | 191 		if [ "$RDIFF_OCTAVE_MKOCT" == "" ]; | 
|  | 192 		then | 
|  | 193 			RDIFF_OCTAVE_MKOCT=$(dirname $RDIFF_OCTAVE_BIN_PATH)/mkoctfile | 
|  | 194 			if [ ! -f RDIFF_OCTAVE_MKOCT ]; | 
|  | 195 			then | 
|  | 196 				echo mkoctfile not found | 
|  | 197 				echo please run interactive mode: ./configure -i | 
|  | 198 				exit -1 | 
|  | 199 			fi | 
|  | 200 		fi | 
|  | 201 	fi | 
|  | 202 	echo '=>' Setting octave\'s path to \"$RDIFF_OCTAVE_MKOCT\" | 
|  | 203 	echo | 
|  | 204 fi | 
|  | 205 | 
|  | 206 if [ "$RDIFF_INTERPRETER" == 'matlab' ]; | 
|  | 207 then | 
|  | 208 	echo Please enter the full path to matlab \(currently set to \"$MATLAB_BIN_PATH\", system version used, if left empty\) | 
|  | 209 	read MATLAB_BIN_PATH | 
|  | 210 	if [ "$MATLAB_BIN_PATH" == "" ]; | 
|  | 211 	then | 
|  | 212 		MATLAB_BIN_PATH=`which matlab` | 
|  | 213 		if [ "$MATLAB_BIN_PATH" == "" ]; | 
|  | 214 		then | 
|  | 215 			echo matlab not found | 
|  | 216 			echo please run interactive mode: ./configure -i | 
|  | 217 			exit -1 | 
|  | 218 		fi | 
|  | 219 	fi | 
|  | 220 	if [ ! -f $MATLAB_BIN_PATH ]; | 
|  | 221 	then | 
|  | 222 		echo matlab not found | 
|  | 223 		echo please run interactive mode: ./configure -i | 
|  | 224 		exit -1 | 
|  | 225 	fi | 
|  | 226 	echo '=>' Setting matlab\'s path to \"$MATLAB_BIN_PATH\" | 
|  | 227 	echo | 
|  | 228 | 
|  | 229 	echo Please enter the full path to mex binary \(currently set to \"$MATLAB_MEX_PATH\", system version used if left empty\) | 
|  | 230 	read MATLAB_MEX_PATH | 
|  | 231 	if [ "$MATLAB_MEX_PATH" == "" ]; | 
|  | 232 	then | 
|  | 233 		MATLAB_MEX_PATH=`which mex` | 
|  | 234 		if [ "$MATLAB_MEX_PATH" == "" ]; | 
|  | 235 		then | 
|  | 236 			echo mex not found | 
|  | 237 			echo please run interactive mode: ./configure -i | 
|  | 238 			exit -1 | 
|  | 239 		fi | 
|  | 240 	fi | 
|  | 241 	if [ ! -f "$MATLAB_MEX_PATH" ]; | 
|  | 242 	then | 
|  | 243 		echo mex not found | 
|  | 244 		echo please run interactive mode: ./configure -i | 
|  | 245 		exit -1 | 
|  | 246 	fi | 
|  | 247 	echo '=>' Setting mex\' path to \"$MATLAB_MEX_PATH\" | 
|  | 248 	echo | 
|  | 249 | 
|  | 250 	echo Please enter the full path to the matlab include directory \(currently set to \"$MATLAB_INCLUDE_DIR\", system version used, if left empty\) | 
|  | 251 	read MATLAB_INCLUDE_DIR | 
|  | 252 	if [ "$MATLAB_INCLUDE_DIR" == "" ]; | 
|  | 253 	then | 
|  | 254 		MATLAB_INCLUDE_DIR=$(dirname $MATLAB_BIN_PATH)/../extern/include | 
|  | 255 	fi | 
|  | 256 	if [ ! -d "$MATLAB_INCLUDE_DIR" ]; | 
|  | 257 	then | 
|  | 258 		echo matlab include dir not found | 
|  | 259 		echo please run interactive mode: ./configure -i | 
|  | 260 		exit -1 | 
|  | 261 	fi | 
|  | 262 	echo '=>' Setting matlab\'s include directory to \"$MATLAB_INCLUDE_DIR\" | 
|  | 263 	echo | 
|  | 264 | 
|  | 265 	RDIFF_OCTAVE_BIN_PATH= | 
|  | 266 fi | 
|  | 267 | 
|  | 268 cp -p bin/rdiff_config.sh bin/rdiff_config.sh.bak | 
|  | 269 | 
|  | 270 grep -v -e RDIFF_OCTAVE_BIN_PATH -e RDIFF_OCTAVE_MKOCT -e MATLAB_BIN_PATH -e MATLAB_MEX_PATH -e MATLAB_INCLUDE_DIR \ | 
|  | 271     -e RDIFF_PATH -e RDIFF_SRC_PATH -e RDIFF_BIN_PATH \ | 
|  | 272     -e RDIFF_INTERPRETER bin/rdiff_config.sh.bak \ | 
|  | 273     -e RDIFF_SAMTOOLS_BIN_DIR -e RDIFF_SAMTOOLS_LIB_DIR -e RDIFF_SAMTOOLS_INCLUDE_DIR -e RDIFF_PYTHON_PATH -e SCIPY_PATH -e $RDIFF_VERSION > bin/rdiff_config.sh | 
|  | 274 | 
|  | 275 echo Generating config file ... | 
|  | 276 | 
|  | 277 # appending the relevant lines to rdiff_config.sh | 
|  | 278 echo export RDIFF_VERSION=$RDIFF_VERSION >> bin/rdiff_config.sh | 
|  | 279 echo export RDIFF_PATH=$RDIFF_PATH >> bin/rdiff_config.sh | 
|  | 280 echo export RDIFF_SRC_PATH=${RDIFF_PATH}/src >> bin/rdiff_config.sh | 
|  | 281 echo export RDIFF_BIN_PATH=${RDIFF_PATH}/bin >> bin/rdiff_config.sh | 
|  | 282 echo export RDIFF_INTERPRETER=$RDIFF_INTERPRETER >> bin/rdiff_config.sh | 
|  | 283 echo export RDIFF_MATLAB_BIN_PATH=$MATLAB_BIN_PATH >> bin/rdiff_config.sh | 
|  | 284 echo export RDIFF_MATLAB_MEX_PATH=$MATLAB_MEX_PATH >> bin/rdiff_config.sh | 
|  | 285 echo export RDIFF_MATLAB_INCLUDE_DIR=$MATLAB_INCLUDE_DIR >> bin/rdiff_config.sh | 
|  | 286 echo export RDIFF_OCTAVE_BIN_PATH=$RDIFF_OCTAVE_BIN_PATH >> bin/rdiff_config.sh | 
|  | 287 echo export RDIFF_OCTAVE_MKOCT=$RDIFF_OCTAVE_MKOCT >> bin/rdiff_config.sh | 
|  | 288 echo export RDIFF_SAMTOOLS_BIN_DIR=$RDIFF_SAMTOOLS_BIN_DIR >> bin/rdiff_config.sh | 
|  | 289 echo export RDIFF_SAMTOOLS_LIB_DIR=$RDIFF_SAMTOOLS_LIB_DIR >> bin/rdiff_config.sh | 
|  | 290 echo export RDIFF_SAMTOOLS_INCLUDE_DIR=$RDIFF_SAMTOOLS_INCLUDE_DIR >> bin/rdiff_config.sh | 
|  | 291 echo export RDIFF_PYTHON_PATH=$RDIFF_PYTHON_PATH >> bin/rdiff_config.sh | 
|  | 292 | 
|  | 293 echo Done. | 
|  | 294 echo | 
|  | 295 | 
|  | 296 echo Please use \'make\' to compile the mex files before using rDiff. | 
|  | 297 echo To test rDiff use \'make example\' or \'make threeexamples\'. | 
|  | 298 echo |