fix cdr_pgsql build on Debian testing (issue #5064)
[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-2005, Digium
7 #
8 # Mark Spencer <markster@digium.com>
9 #
10 # This program is free software, distributed under the terms of
11 # the GNU General Public License
12 #
13
14 MODS=cdr_csv.so cdr_manager.so cdr_custom.so
15
16 CFLAGS+=-fPIC
17
18 ifeq ($(findstring BSD,${OSARCH}),BSD)
19   CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include -L$(CROSS_COMPILE_TARGET)/usr/local/lib
20 endif
21
22 #The problem with sparc is the best stuff is in newer versions of gcc (post 3.0) only.
23 #This works for even old (2.96) versions of gcc and provides a small boost either way.
24 #A ultrasparc cpu is really v9 but the stock debian stable 3.0 gcc doesn.t support it.
25 #So we go lowest common available by gcc and go a step down, still a step up from
26 #the default as we now have a better instruction set to work with. - Belgarath
27 ifeq ($(PROC),sparc64)
28  PROC=ultrasparc
29   CFLAGS += -mtune=$(PROC) -O3 -pipe -fomit-frame-pointer -mcpu=v8
30 endif
31
32 #
33 # unixODBC stuff...
34 #
35 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/odbcinst.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/odbcinst.h),)
36   MODS+=cdr_odbc.so
37 endif
38
39 #
40 # FreeTDS stuff...
41 #
42 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/tds.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/tds.h),)
43   MODS+=cdr_tds.so
44 endif
45
46 #
47 # PGSQL stuff...  Autoconf anyone??
48 #
49 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/postgresql)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/pgsql/include)$(wildcard $(CROSS_COMPILE_TARGET)/usr/include/pgsql)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/pgsql)$(wildcard $(CROSS_COMPILE_TARGET)/opt/pgsql/include)$(wildcard $(CROSS_COMPILE_TARGET)/usr/include/libpq-fe.h),)
50   MODS+=cdr_pgsql.so
51 endif
52
53 MLFLAGS=
54
55 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/postgresql),)
56   CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/include/postgresql
57   MLFLAGS+=-L$(CROSS_COMPILE_TARGET)/usr/lib/postgresql
58 endif
59
60 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/local/pgsql/include),)
61   CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/pgsql/include
62   MLFLAGS+=-L$(CROSS_COMPILE_TARGET)/usr/local/pgsql/lib
63 endif
64
65 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/pgsql),)
66   CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/include/pgsql
67   MLFLAGS+=-L$(CROSS_COMPILE_TARGET)/usr/lib/pgsql
68 endif
69
70 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/pgsql),)
71   CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include/pgsql
72   MLFLAGS+=-L$(CROSS_COMPILE_TARGET)/usr/local/lib/pgsql
73 endif
74
75 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/opt/pgsql/include),)
76   CFLAGS+=-I$(CROSS_COMPILE_TARGET)/opt/pgsql/include
77   MLFLAGS+=-L$(CROSS_COMPILE_TARGET) /opt/pgsql/lib
78 endif
79
80 ifneq ($(wilcard $(CROSS_COMPILE_TARGET)/usr/include/postgresql),)
81   CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/include/postgresql
82 endif
83
84 ifneq ($(wilcard $(CROSS_COMPILE_TARGET)/usr/lib/libpq.so),)
85   MLFLAGS+=-L$(CROSS_COMPILE_TARGET)/usr/lib
86 endif
87
88 #
89 # SQLite stuff...
90 #
91 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/sqlite.h),)
92   MODS+=cdr_sqlite.so
93 endif
94
95 all: depend $(MODS)
96
97 install: all
98         for x in $(MODS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
99
100 clean:
101         rm -f *.so *.o .depend
102
103 %.so : %.o
104         $(CC) $(SOLINK) -o $@ $<
105
106 ifneq ($(wildcard .depend),)
107   include .depend
108 endif
109
110 cdr_odbc.so: cdr_odbc.o
111         $(CC) $(SOLINK) -o $@ $< -lodbc $(MLFLAGS)
112
113 cdr_tds.so: cdr_tds.o
114         $(CC) $(SOLINK) -o $@ $< -ltds $(MLFLAGS)
115
116 cdr_pgsql.so: cdr_pgsql.o
117         $(CC) $(SOLINK) -o $@ $< -lpq -lz $(MLFLAGS)
118
119 cdr_sqlite.so: cdr_sqlite.o
120         $(CC) $(SOLINK) -o $@ $< -lsqlite $(MLFLAGS)
121
122 depend: .depend
123
124 .depend:
125         ../build_tools/mkdep $(CFLAGS) `ls *.c`