Unbreak res/Makefile (issue #6891 as reported by casper)
[asterisk/asterisk.git] / res / Makefile
1 #
2 # Asterisk -- A telephony toolkit for Linux.
3
4 # Makefile for resource modules
5 #
6 # Copyright (C) 1999-2006, 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:=$(patsubst %.c,%.so,$(wildcard res_*.c))
15
16 ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/odbcinst.h $(CROSS_COMPILE_TARGET)/usr/local/include/odbcinst.h),)
17   MODS:=$(filter-out res_odbc.so,$(MODS))
18   MODS:=$(filter-out res_config_odbc.so,$(MODS))
19 else
20   ifeq (${OSARCH},FreeBSD)
21     MODS:=$(filter-out $(shell if test ${BSDVERSION} -lt 500000 ; then echo "res_config_odbc.so"; fi),$(MODS))
22   endif
23 endif
24
25 ifeq ($(NOCRYPTO),yes)
26   MODS:=$(filter-out res_crypto.so,$(MODS))
27   MODS:=$(filter-out res_osp.so,$(MODS))
28 endif
29
30 OSPLIB:=$(wildcard $(CROSS_COMPILE_TARGET)/usr/lib/libosptk.a $(CROSS_COMPILE_TARGET)/usr/local/lib/libosptk.a)
31 ifeq (${OSPLIB},)
32   MODS:=$(filter-out res_osp.so,$(MODS))
33 endif
34
35 # NETsnmp has some difficulties on some platforms (conflict with unload_module)
36 # Until we figure out if the collission is version-specific or what to do
37 # we have disabled res_snmp on OS/X and *BSD
38 ifeq ($(OSARCH),Darwin)
39   MODS:=$(filter-out res_snmp.so,$(MODS))
40 else
41   ifeq ($(findstring BSD,$(OSARCH)),BSD)
42     MODS:=$(filter-out res_snmp.so,$(MODS))
43   endif
44 endif
45
46 ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/postgresql $(CROSS_COMPILE_TARGET)/usr/local/pgsql/include $(CROSS_COMPILE_TARGET)/usr/include/pgsql $(CROSS_COMPILE_TARGET)/usr/local/include/pgsql $(CROSS_COMPILE_TARGET)/opt/pgsql/include $(CROSS_COMPILE_TARGET)/usr/include/libpq-fe.h),)
47   MODS:=$(filter-out res_config_pgsql.so,$(MODS))
48 endif
49
50 ifeq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/net-snmp/net-snmp-config.h),)
51   MODS:=$(filter-out res_snmp.so,$(MODS))
52 else
53   SNMP_LDLIBS+=$(shell net-snmp-config --agent-libs)
54 endif
55
56 ifeq (${WITH_SMDI},)
57   MODS:=$(filter-out res_smdi.so,$(MODS))
58 endif
59
60 MLFLAGS=
61
62 # Now, go find postgresql libraries
63 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/postgresql),)
64   CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/include/postgresql
65   MLFLAGS+=-L$(CROSS_COMPILE_TARGET)/usr/lib/postgresql
66 endif
67
68 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/local/pgsql/include),)
69   CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/pgsql/include
70   MLFLAGS+=-L$(CROSS_COMPILE_TARGET)/usr/local/pgsql/lib
71 endif
72
73 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/pgsql),)
74   CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/include/pgsql
75   MLFLAGS+=-L$(CROSS_COMPILE_TARGET)/usr/lib/pgsql
76 endif
77
78 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/pgsql),)
79   CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/local/include/pgsql
80   MLFLAGS+=-L$(CROSS_COMPILE_TARGET)/usr/local/lib/pgsql
81 endif
82
83 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/opt/pgsql/include),)
84   CFLAGS+=-I$(CROSS_COMPILE_TARGET)/opt/pgsql/include
85   MLFLAGS+=-L$(CROSS_COMPILE_TARGET)/opt/pgsql/lib
86 endif
87
88 ifneq ($(wilcard $(CROSS_COMPILE_TARGET)/usr/include/postgresql),)
89   CFLAGS+=-I$(CROSS_COMPILE_TARGET)/usr/include/postgresql
90 endif
91
92 ifneq ($(wilcard $(CROSS_COMPILE_TARGET)/usr/lib/libpq.so),)
93   MLFLAGS+=-L$(CROSS_COMPILE_TARGET)/usr/lib
94 endif
95
96 ifeq (${OSARCH},CYGWIN)
97   CYGSOLINK=-Wl,--out-implib=lib$@.a -Wl,--export-all-symbols
98   CYGSOLIB=-L.. -L. -lasterisk.dll
99   CYG_RES_CONFIG_ODBC_LIB=-lres_odbc.so
100   CYG_RES_FEATURES_LIB=-lres_adsi.so -lres_monitor.so
101   MODS:=$(filter-out res_musiconhold.so,$(MODS))
102 endif
103
104 CRYPTO_LIBS=-lssl -lcrypto
105
106 CFLAGS+=
107
108 ifndef WITHOUT_ZAPTEL
109 ifneq ($(wildcard $(CROSS_COMPILE_TARGET)/usr/include/linux/zaptel.h)$(wildcard $(CROSS_COMPILE_TARGET)/usr/local/include/zaptel.h),)
110   CFLAGS+=-DZAPATA_MOH
111 endif
112 endif # WITHOUT_ZAPTEL
113
114 #
115 # Work around buggy RedHat 9.0
116 #
117 ifeq (${OSARCH},CYGWIN)
118 CFLAGS+=-DOPENSSL_NO_KRB5
119 else
120 CFLAGS+=-DOPENSSL_NO_KRB5 -fPIC
121 endif
122
123 all: depend $(MODS)
124
125 install: all
126         rm -f $(DESTDIR)$(ASTHEADERDIR)/parking.h
127         rm -f $(DESTDIR)$(MODULES_DIR)/app_agi.so 
128         rm -f $(DESTDIR)$(MODULES_DIR)/res_parking.so
129         for x in $(MODS); do $(INSTALL) -m 755 $$x $(DESTDIR)$(MODULES_DIR) ; done
130         @if [ x`which mpg123 2>/dev/null | grep -v '^no'` != x ] ; then \
131           if mpg123 --longhelp 2>&1 | grep -q .59r 2>&1 >/dev/null ; then echo ; else \
132                         echo "*************************************************************";\
133                         echo "*** You have the WRONG version of mpg123... you need .59r ***";\
134                         echo "*** Use 'make mpg123' to get the right verison            ***";\
135                         echo "*************************************************************";\
136           fi ;\
137         else \
138                 echo "*** You don't have mpg123 installed. You may need ***";\
139                 echo "***       it if you want to use MusicOnHold       ***";\
140         fi
141
142 uninstall:
143
144 res_crypto.so: res_crypto.o
145         $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(CRYPTO_LIBS)
146
147 clean-depend:
148         rm -f .depend
149
150 clean: clean-depend
151         rm -f *.so *.o
152
153 res_odbc.so: res_odbc.o
154         $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lodbc
155
156 res_osp.so: res_osp.o $(OSPLIB)
157         $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} $(OSPLIB) $(CRYPTO_LIBS)
158
159 %.so : %.o
160         $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB}
161
162 res_features.so: res_features.o
163         $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} ${CYG_RES_FEATURES_LIB}
164
165 res_config_odbc.so: res_config_odbc.o
166         $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} ${CYG_RES_CONFIG_ODBC_LIB}
167
168 res_snmp.so: res_snmp.o snmp/agent.o
169         $(CC) $(SOLINK) ${SNMP_LDFLAGS} -o $@ ${CYGSOLINK} res_snmp.o snmp/agent.o ${CYGSOLIB} ${SNMP_LDLIBS}
170
171 res_config_pgsql.so: res_config_pgsql.o
172         $(CC) $(SOLINK) -o $@ ${CYGSOLINK} $< ${CYGSOLIB} -lpq -lz $(MLFLAGS)
173
174 ifneq ($(wildcard .depend),)
175   include .depend
176 endif
177
178 depend: .depend
179
180 .depend:
181         ../build_tools/mkdep $(CFLAGS) `ls *.c` 
182
183 env:
184         env