Silly cdr_pgsql.so error
[asterisk/asterisk.git] / cdr / Makefile
index 36b4dba..aac7029 100755 (executable)
 # the GNU General Public License
 #
 
+#ADD cdr_pgsql.so to MODS= to include PostgreSQL support: REQUIRES PostgreSQL libs
 MODS=cdr_csv.so
 
-CFLAGS+=
+
+CFLAGS+=-fPIC
+
+#
+# unixODBC stuff...
+#
+MODS+=$(shell if [ -f "/usr/include/odbcinst.h" ]; then echo "cdr_odbc.so"; fi)
+MODS+=$(shell if [ -f "/usr/local/include/odbcinst.h" ]; then echo "cdr_odbc.so"; fi) 
 
 #
-# MySQL stuff...  Autoconf anyone??
+# PGSQL stuff...  Autoconf anyone??
 #
-MODS+=$(shell if [ -d /usr/local/mysql/include ] || [ --d /usr/include/mysql ] || [ -d /usr/local/include/mysql ] || [ -d /opt/mysql/include ]; then echo "cdr_mysql.so"; fi)
-CFLAGS+=$(shell if [ -d /usr/local/mysql/include ]; then echo "-I/usr/local/mysql/include"; fi)
-CFLAGS+=$(shell if [ -d /usr/include/mysql ]; then echo "-I/usr/include/mysql"; fi)
-CFLAGS+=$(shell if [ -d /usr/local/include/mysql ]; then echo "-I/usr/local/include/mysql"; fi)
-CFLAGS+=$(shell if [ -d /opt/mysql/include/mysql ]; then echo "-I/opt/mysql/include/mysql"; fi)
+MODS+=$(shell if [ -d /usr/local/pgsql/include ] || [ -d /usr/include/pgsql ] || [ -d /usr/local/include/pgsql ] || [ -d /opt/pgsql/include ] || [ -f /usr/include/libpq-fe.h ] ; then echo "cdr_pgsql.so"; fi)
+CFLAGS+=$(shell if [ -d /usr/local/pgsql/include ]; then echo "-I/usr/local/pgsql/include"; fi)
+CFLAGS+=$(shell if [ -d /usr/include/pgsql ]; then echo "-I/usr/include/pgsql"; fi)
+CFLAGS+=$(shell if [ -d /usr/include/postgresql ]; then echo "-I/usr/include/postgresql"; fi)
+CFLAGS+=$(shell if [ -d /usr/local/include/pgsql ]; then echo "-I/usr/local/include/pgsql"; fi)
+CFLAGS+=$(shell if [ -d /opt/pgsql/include ]; then echo "-I/opt/pgsql/include"; fi)
+CFLAGS+=$(shell if [ -f /usr/include/libpq-fe.h ]; then echo "-I/usr/include"; fi)
 MLFLAGS=
-MLFLAGS+=$(shell if [ -d /usr/lib/mysql ]; then echo "-L/usr/lib/mysql"; fi)
-MLFLAGS+=$(shell if [ -d /usr/local/mysql/lib ]; then echo "-L/usr/local/mysql/lib"; fi)
-MLFLAGS+=$(shell if [ -d /usr/local/lib/mysql ]; then echo "-L/usr/local/lib/mysql"; fi)
-MLFLAGS+=$(shell if [ -d /opt/mysql/lib/mysql ]; then echo "-L/opt/mysql/lib/mysql"; fi)
+MLFLAGS+=$(shell if [ -d /usr/lib/pgsql ]; then echo "-L/usr/lib/pgsql"; fi)
+MLFLAGS+=$(shell if [ -d /usr/local/pgsql/lib ]; then echo "-L/usr/local/pgsql/lib"; fi)
+MLFLAGS+=$(shell if [ -d /usr/local/lib/pgsql ]; then echo "-L/usr/local/lib/pgsql"; fi)
+MLFLAGS+=$(shell if [ -d /opt/pgsql/lib ]; then echo "-L/opt/pgsql/lib"; fi)
+MLFLAGS+=$(shell if [ -f /usr/lib/libpq.so ]; then echo "-L/usr/lib"; fi)
 
-all: $(MODS)
+all: depend $(MODS)
 
 install: all
-       for x in $(MODS); do $(INSTALL) -m 755 $$x $(MODULES_DIR) ; done
+       for x in $(MODS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
 
 clean:
-       rm -f *.so *.o
+       rm -f *.so *.o .depend
 
 %.so : %.o
-       $(CC) -shared -Xlinker -x -o $@ $<
+       $(CC) $(SOLINK) -o $@ $<
+
+ifneq ($(wildcard .depend),)
+include .depend
+endif
+
+cdr_odbc.so: cdr_odbc.o
+       $(CC) $(SOLINK) -o $@ $< -lodbc -I/usr/include $(MLFLAGS)
+
+cdr_pgsql.so: cdr_pgsql.o
+       $(CC) $(SOLINK) -o $@ $< -lpq -lz $(MLFLAGS)
+
+depend: .depend
 
-cdr_mysql.so: cdr_mysql.o
-       $(CC) -shared -Xlinker -x -o $@ $< -lmysqlclient -lz $(MLFLAGS)
+.depend:
+       ../mkdep $(CFLAGS) `ls *.c`