9 ls "`which mysql 2>/dev/null`" > /dev/null 2>&1
11 # Check if mysql_config is installed to use it
12 mysql_config --port > /dev/null 2>&1
14 MI=`mysql_config --cflags`
15 ML=`mysql_config --libs`
18 # Check in a few dirs if mysql_config is perhaps there
19 for i in /usr /usr/local $1
21 for j in $i/include/mysql/mysql.h $i/include/mysql.h
23 ls $j > /dev/null 2>&1
25 if [ "X$MI" = "X" ]; then
32 for j in $i/lib/mysql $i/lib64/mysql
34 ls $j > /dev/null 2>&1
36 if [ "X$ML" = "X" ]; then
37 ML="-L $j -lmysqlclient";
46 ls "`which psql 2>/dev/null`" > /dev/null 2>&1
48 # Check if pg_config is installed to use it
49 pg_config --version > /dev/null 2>&1
51 PGID=`pg_config --includedir`
52 PGPI=`pg_config --pkgincludedir`
53 PGLD=`pg_config --libdir`
54 PGLI=`pg_config --pkglibdir`
55 PI="${PGID} -I${PGPI}"
56 PL="-L${PGLD} -L${PGLI}"
59 for i in /usr /usr/local /usr/local/pgsql /usr/pgsql /usr/postgresql $1
61 for j in $i/include/pgsql/libpq-fe.h $i/include/libpq-fe.h $i/include/postgresql/libpq-fe.h
63 ls $j > /dev/null 2>&1
65 if [ "X$PI" = "X" ]; then
72 for j in $i/lib/pgsql $i/lib/postgresql $i/lib64/pgsql $i/lib64/postgresql
74 ls $j > /dev/null 2>&1
76 if [ "X$PL" = "X" ]; then
78 PL="-L$j -L${PG_MAIN}";
86 # Print error if MySQL is not found
87 if [ "X$MI" = "X" -a "X$ML" = "X" ]; then
89 echo "Error: MySQL client libraries not installed." >&2
93 # Print error if PostgreSQL is not found
94 if [ "X$PI" = "X" -a "X$PL" = "X" ]; then
96 echo "Error: PostgreSQL client libraries not installed." >&2
101 if [ "X$MI" = "X" -o "X$ML" = "X" ]; then
104 echo "Info: Compiled with MySQL support." >&2
105 MYSQL_FINAL="$MI $ML -DDBD -DUMYSQL"
108 # Final PostgreSQL CFLAGS
109 if [ "X$PI" = "X" -o "X$PL" = "X" ]; then
112 echo "Info: Compiled with PostgreSQL support." >&2
113 POSTGRES_FINAL="-I$PI $PL -lpq -DDBD -DUPOSTGRES"
117 if [ "X${MYSQL_FINAL}" = "X" -a "X${POSTGRES_FINAL}" = "X" ]; then
118 echo "Error: DB libraries not installed." >&2
122 echo "${MYSQL_FINAL} ${POSTGRES_FINAL}"