d2ba09cac80bbc207a574debf2070432a2bb6e7c
[asterisk/asterisk.git] / cdr / Makefile
1 #
2 # Asterisk -- A telephony toolkit for Linux.
3
4 # Makefile for CDR backends (dynamically loaded)
5 #
6 # Copyright (C) 1999, Mark Spencer
7 #
8 # Mark Spencer <markster@linux-support.net>
9 #
10 # This program is free software, distributed under the terms of
11 # the GNU General Public License
12 #
13
14 #ADD cdr_pgsql.so to MODS= to include PostgreSQL support: REQUIRES PostgreSQL libs
15 MODS=cdr_csv.so cdr_manager.so
16
17
18 CFLAGS+=-fPIC
19
20 OSARCH=$(shell uname -s)
21 ifeq (${OSARCH},FreeBSD)
22 SOLINK+=-L/usr/local/lib
23 endif
24
25 #
26 # unixODBC stuff...
27 #
28 MODS+=$(shell if [ -f "/usr/include/odbcinst.h" ]; then echo "cdr_odbc.so"; fi)
29 MODS+=$(shell if [ -f "/usr/local/include/odbcinst.h" ]; then echo "cdr_odbc.so"; fi) 
30
31 #
32 # FreeTDS stuff...
33 #
34 MODS+=$(shell if [ -f "/usr/include/tds.h" ]; then echo "cdr_tds.so"; fi)
35 MODS+=$(shell if [ -f "/usr/local/include/tds.h" ]; then echo "cdr_tds.so"; fi)
36
37 #
38 # PGSQL stuff...  Autoconf anyone??
39 #
40 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)
41 CFLAGS+=$(shell if [ -d /usr/local/pgsql/include ]; then echo "-I/usr/local/pgsql/include"; fi)
42 CFLAGS+=$(shell if [ -d /usr/include/pgsql ]; then echo "-I/usr/include/pgsql"; fi)
43 CFLAGS+=$(shell if [ -d /usr/include/postgresql ]; then echo "-I/usr/include/postgresql"; fi)
44 CFLAGS+=$(shell if [ -d /usr/local/include/pgsql ]; then echo "-I/usr/local/include/pgsql"; fi)
45 CFLAGS+=$(shell if [ -d /opt/pgsql/include ]; then echo "-I/opt/pgsql/include"; fi)
46 #CFLAGS+=$(shell if [ -f /usr/include/libpq-fe.h ]; then echo "-I/usr/include"; fi)
47 MLFLAGS=
48 MLFLAGS+=$(shell if [ -d /usr/lib/pgsql ]; then echo "-L/usr/lib/pgsql"; fi)
49 MLFLAGS+=$(shell if [ -d /usr/local/pgsql/lib ]; then echo "-L/usr/local/pgsql/lib"; fi)
50 MLFLAGS+=$(shell if [ -d /usr/local/lib/pgsql ]; then echo "-L/usr/local/lib/pgsql"; fi)
51 MLFLAGS+=$(shell if [ -d /opt/pgsql/lib ]; then echo "-L/opt/pgsql/lib"; fi)
52 MLFLAGS+=$(shell if [ -f /usr/lib/libpq.so ]; then echo "-L/usr/lib"; fi)
53
54 #
55 # SQLIte stuff...
56 #
57 MODS+=$(shell if [ -f "/usr/include/sqlite.h" ]; then echo "cdr_sqlite.so"; fi)
58
59 all: depend $(MODS)
60
61 install: all
62         for x in $(MODS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
63
64 clean:
65         rm -f *.so *.o .depend
66
67 %.so : %.o
68         $(CC) $(SOLINK) -o $@ $<
69
70 ifneq ($(wildcard .depend),)
71 include .depend
72 endif
73
74 cdr_odbc.so: cdr_odbc.o
75         $(CC) $(SOLINK) -o $@ $< -lodbc $(MLFLAGS)
76
77 cdr_tds.so: cdr_tds.o
78         $(CC) $(SOLINK) -o $@ $< -ltds $(MLFLAGS)
79
80 cdr_pgsql.so: cdr_pgsql.o
81         $(CC) $(SOLINK) -o $@ $< -lpq -lz $(MLFLAGS)
82
83 cdr_sqlite.so: cdr_sqlite.o
84         $(CC) $(SOLINK) -o $@ $< -lsqlite $(MLFLAGS)
85
86 depend: .depend
87
88 .depend:
89         ../mkdep $(CFLAGS) `ls *.c`