11 ls "`which mysql 2>/dev/null`" > /dev/null 2>&1
14 # Checking if mysql_config is installed to use it.
15 mysql_config --port > /dev/null 2>&1
17 MI=`mysql_config --cflags`
18 ML=`mysql_config --libs`
22 # Checking on a few dirs if mysql_config is not there.
23 for i in /usr /usr/local $1
25 for j in $i/include/mysql/mysql.h $i/include/mysql.h
27 ls $j > /dev/null 2>&1
29 if [ "X$MI" = "X" ]; then
36 for j in $i/lib/mysql $i/lib64/mysql
38 ls $j > /dev/null 2>&1
40 if [ "X$ML" = "X" ]; then
41 ML="-L $j -lmysqlclient";
50 # Looking for postgresql
51 ls "`which psql 2>/dev/null`" > /dev/null 2>&1
54 # Checking if pg_config is installed to use it.
55 pg_config --version > /dev/null 2>&1
57 PGID=`pg_config --includedir`
58 PGPI=`pg_config --pkgincludedir`
59 PGLD=`pg_config --libdir`
60 PGLI=`pg_config --pkglibdir`
61 PI="${PGID} -I${PGPI}"
62 PL="-L${PGLD} -L${PGLI}"
65 for i in /usr /usr/local /usr/local/pgsql /usr/pgsql /usr/postgresql $1
67 for j in $i/include/pgsql/libpq-fe.h $i/include/libpq-fe.h $i/include/postgresql/libpq-fe.h
69 ls $j > /dev/null 2>&1
71 if [ "X$PI" = "X" ]; then
78 for j in $i/lib/pgsql $i/lib/postgresql $i/lib64/pgsql $i/lib64/postgresql
80 ls $j > /dev/null 2>&1
82 if [ "X$PL" = "X" ]; then
84 PL="-L$j -L${PG_MAIN}";
95 # Printing error if mysql is not found
96 if [ "X$MI" = "X" -a "X$ML" = "X" ]; then
98 echo "Error: MySQL client libraries not installed." >&2
102 # Printing error if postgresql is not found
103 if [ "X$PI" = "X" -a "X$PL" = "X" ]; then
105 echo "Error: PostgreSQL client libraries not installed." >&2
110 # Final cflags -- can not be empty.
111 if [ "X$MI" = "X" -o "X$ML" = "X" ]; then
114 echo "Info: Compiled with MySQL support." >&2
115 MYSQL_FINAL="$MI $ML -DDBD -DUMYSQL"
119 if [ "X$PI" = "X" -o "X$PL" = "X" ]; then
122 echo "Info: Compiled with PostgreSQL support." >&2
123 POSTGRES_FINAL="-I$PI $PL -lpq -DDBD -DUPOSTGRES"
127 if [ "X${MYSQL_FINAL}" = "X" -a "X${POSTGRES_FINAL}" = "X" ]; then
128 echo "Error: DB libraries not installed." >&2
132 echo "${MYSQL_FINAL} ${POSTGRES_FINAL}"