cql_config 1.74 KB
Newer Older
1
#!/bin/bash
2

3 4
cql_lib="cassandra"

5 6 7 8 9 10
if test `uname -s` = "Darwin"; then
	DIR=$(stat -f %N $0 | xargs dirname)
else
	DIR=$(readlink -f $0 | xargs dirname)
fi

11 12
if ! [ -f ${DIR}/cql_config_defines.sh ] || ! [ -x ${DIR}/cql_config_defines.sh ]
then
13
	echo "missing path configuration file for DataStax Cassandra (cql_config_defines.sh)"
14 15 16 17
	exit 0
fi
source ${DIR}/cql_config_defines.sh

18
if [ $# -ne 1 ] && [ $# -ne 2 ]
19 20 21 22 23 24
then
	echo "run: \`$0 --help\` for more help"
	exit 0
fi
if [ $1 == "--help" ]
then
25 26
	echo "cql_config 'option' ['library']"
	echo "options:"
27 28
	echo "--help"
	echo "    print this help message"
29
	echo "--cflags-only-other"
30
	echo "    get cpp compilation flags"
31
	echo "--cflags-only-I"
32
	echo "    get include path"
33
	echo "--libs"
34
	echo "    get lib path"
35
	echo "--modversion"
36
	echo "    get version"
37 38 39
	echo "libraries:"
	echo "    cassandra"
	echo "    cassandra_static"
40
	exit 0
41 42 43 44 45 46 47 48 49 50 51 52 53
else if [ $# -ne 2 ]
	then
		echo "run: \`$0 --help\` for more help"
		exit 0
	else if [ $2 != "cassandra" ] && [ $2 != "cassandra_static" ]
		then
			echo "library $2 not supported"
			echo "run: \`$0 --help\` for more help"
			exit 0
		else
			cql_lib=$2
		fi
	fi
54
fi
55
if [ $1 == "--cflags-only-other" ]
56 57 58
then
	exit 0
fi
59
if [ $1 == "--cflags-only-I" ]
60
then
61
	echo "-I${CPP_DRIVER_PATH}/include/"
62 63
	exit 0
fi
64
if [ $1 == "--libs" ]
65
then
66
	echo "-L${CPP_DRIVER_PATH}/build/ -l${cql_lib} -luv"
67 68
	exit 0
fi
69
if [ $1 == "--modversion" ]
70 71 72 73 74 75 76 77 78
then
	MAJOR=`grep VERSION_MAJOR ${CPP_DRIVER_PATH}/include/cassandra.h | cut -d " " -f 3`
	MINOR=`grep VERSION_MINOR ${CPP_DRIVER_PATH}/include/cassandra.h | cut -d " " -f 3`
	PATCH=`grep VERSION_PATCH ${CPP_DRIVER_PATH}/include/cassandra.h | cut -d " " -f 3`
	echo "${MAJOR}.${MINOR}.${PATCH}"
	exit 0
fi
echo "wrong parameter"
echo "run: \`$0 --help\` for more help"