42ee168c6df1bcd731554e8c713eae0dc4203cb3
[lcr.git] / Makefile.am
1 ##    Makefile.am -- Process this file with automake to produce Makefile.in
2
3 ##    This file is part of linux-call-router
4 ##    Copyright (C) 2007 Joerg Habenicht (j.habenicht@gmx.de)
5 ##    Copyright (C) 2008 Peter Schlaile (peter -at- schlaile.de)
6 ##    Copyright (C) 2008-2012 Andreas Eversberg (andreas@eversberg.eu)
7
8 ##    This program is free software; you can redistribute it and/or
9 ##    modify it under the terms of the GNU General Public License as
10 ##    published by the Free Software Foundation; either
11 ##    version 2 of the License, or (at your option) any later version.
12
13 ##    This program is distributed in the hope that it will be useful,
14 ##    but WITHOUT ANY WARRANTY; without even the implied warranty of
15 ##    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 ##    GNU General Public License for more details.
17
18 ##    You should have received a copy of the GNU General Public License
19 ##    along with this library; see the file COPYING.  If not, write to
20 ##    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 ##    Boston, MA 02110-1301, USA.
22
23 #INSTALLdir = $(DESTDIR)/usr/local/lcr
24
25 pkglogdir=$(localstatedir)/log/@PACKAGE@
26 pkgsysconfdir=$(sysconfdir)/@PACKAGE@
27
28 CONFIGdir=$(pkgsysconfdir)
29 SHAREdir=$(pkgdatadir)
30 LOGdir=$(pkglogdir)
31 EXTENSIONdir=$(localstatedir)/lib/@PACKAGE@/extensions
32
33 #CONFIGdir=$(INSTALLdir)
34 #SHAREdir=$(INSTALLdir)
35 #LOGdir=$(INSTALLdir)
36 #EXTENSIONdir=$(INSTALLdir)/extensions
37
38 astmoddir = $(libdir)/asterisk/modules
39
40 INSTALLATION_DEFINES = \
41  -DCONFIG_DATA="\"$(CONFIGdir)\"" \
42  -DSHARE_DATA="\"$(SHAREdir)\"" \
43  -DLOG_DIR="\"$(LOGdir)\"" \
44  -DEXTENSION_DATA="\"$(EXTENSIONdir)\""
45
46 SUBDIRS = include
47
48 if ENABLE_MISDN
49
50 MISDN_INCLUDE = -DWITH_MISDN -DWITH_CRYPT
51 MISDN_SOURCE = mISDN.cpp fxs.cpp dss1.cpp crypt.cpp
52 MISDN_LIB = -lmisdn
53
54 endif
55
56 SUBDIRS =
57
58 GSM_INCLUDE =
59 GSM_SOURCE =
60 GSM_LIB =
61
62 if ENABLE_GSM
63
64 #if ENABLE_GSMFR
65
66 GSM_INCLUDE += -DWITH_GSMFR
67
68 GSM_LIB += libgsmfr/lib/libgsm.a
69
70 SUBDIRS += libgsmfr
71
72 #endif
73
74 if ENABLE_GSMHR
75
76 GSM_INCLUDE += -DWITH_GSMHR
77
78 GSM_LIB += libgsmhr/libgsmhr.la
79
80 SUBDIRS += libgsmhr
81
82 endif
83
84 if ENABLE_GSMAMR
85
86 GSM_INCLUDE += -DWITH_GSMAMR
87
88 GSM_LIB += -lopencore-amrnb
89
90 endif
91
92 GSM_SOURCE += gsm_audio.c gsm.cpp
93
94 if ENABLE_GSM_BS
95
96 GSM_INCLUDE += -DWITH_GSM_BS
97
98 GSM_SOURCE += gsm_bs.cpp
99
100 endif
101
102 if ENABLE_GSM_MS
103
104 GSM_INCLUDE += -DWITH_GSM_MS
105
106 GSM_SOURCE += gsm_ms.cpp
107
108 endif
109
110 endif
111
112
113 if ENABLE_SS5
114
115 SS5_INCLUDE = -DWITH_SS5
116
117 SS5_SOURCE = ss5.cpp ss5_encode.c ss5_decode.c
118
119 endif
120
121 SIP_LIB =
122
123 if ENABLE_SIP
124
125 # FIXME: remove that
126 #pkgconfigdir = $(libdir)/pkgconfig
127 #pkgconfig_DATA = sofia-sip-ua.pc
128
129 SIP_INCLUDE = -DWITH_SIP $(SOFIA_CFLAGS)
130
131 SIP_SOURCE = sip.cpp
132
133 SIP_LIB += $(SOFIA_LIBS)
134
135 endif
136
137 bin_PROGRAMS = lcradmin gentones genwave
138
139 sbin_PROGRAMS = lcr genrc genextension
140
141 if ENABLE_ASTERISK_CHANNEL_DRIVER
142 noinst_PROGRAMS = chan_lcr.so
143 chan_lcr_so_SOURCES =
144 chan_lcr_so_LDFLAGS = --shared
145 chan_lcr_so_LDADD = chan_lcr.po options.po callerid.po select.po
146
147 # List chan_lcr specific sources for make dist
148 EXTRA_chan_lcr_so_SOURCES = chan_lcr.c chan_lcr.h
149
150
151 chan_lcr.po: chan_lcr.c chan_lcr.h
152         $(CC) $(AM_CPPFLAGS) $(AST_CFLAGS) $(CPPFLAGS) $(CFLAGS) -D_GNU_SOURCE -fPIC -c $< -o $@
153
154 callerid.po: callerid.c callerid.h
155         $(CC) $(AM_CPPFLAGS) -D_GNU_SOURCE $(CPPFLAGS) $(CFLAGS) -fPIC -c $< -o $@
156
157 options.po: options.c options.h
158         $(CC) $(AM_CPPFLAGS) -D_GNU_SOURCE $(CPPFLAGS) $(CFLAGS) -fPIC -c $< -o $@
159
160 select.po: select.c select.h
161         $(CC) $(AM_CPPFLAGS) -D_GNU_SOURCE $(CPPFLAGS) $(CFLAGS) -fPIC -c $< -o $@
162
163 install-exec-hook: chan_lcr.so
164         $(INSTALL) -d '$(DESTDIR)$(astmoddir)'
165         $(INSTALL) chan_lcr.so '$(DESTDIR)$(astmoddir)'
166
167 uninstall-hook:
168         cd '$(DESTDIR)$(astmoddir)' && rm -f chan_lcr.so
169 endif
170
171 AM_CPPFLAGS = $(all_includes) -I$(top_srcdir)/include $(MISDN_INCLUDE) $(GSM_INCLUDE) $(SS5_INCLUDE) $(SIP_INCLUDE) -Wall $(INSTALLATION_DEFINES)
172
173 lcr_SOURCES = \
174         main.c select.c trace.c options.c tones.c alawulaw.c cause.c interface.c message.c callerid.c socket_server.c \
175         port.cpp vbox.cpp remote.cpp \
176         $(MISDN_SOURCE) $(GSM_SOURCE) $(SS5_SOURCE) $(SIP_SOURCE) \
177         endpoint.cpp endpointapp.cpp \
178         appbridge.cpp apppbx.cpp route.c action.cpp action_efi.cpp action_vbox.cpp extension.c mail.c \
179         join.cpp joinpbx.cpp
180
181 lcr_LDADD = $(LIBCRYPTO) $(MISDN_LIB) -lpthread $(GSM_LIB) $(SIP_LIB)
182
183
184 lcradmin_SOURCES = lcradmin.c cause.c options.c
185 genextension_SOURCES = genext.c options.c extension.c
186
187
188 # List all headers for make dist
189 noinst_HEADERS = \
190         main.h macro.h select.h trace.h options.h tones.h alawulaw.h cause.h interface.h \
191         message.h callerid.h socket_server.h port.h vbox.h endpoint.h endpointapp.h \
192         appbridge.h apppbx.h route.h extension.h join.h joinpbx.h lcrsocket.h
193
194 noinst_HEADERS += myisdn.h mISDN.h dss1.h crypt.h remote.h
195 noinst_HEADERS += ss5.h ss5_encode.h ss5_decode.h
196 noinst_HEADERS += mncc.h gsm.h gsm_audio.h gsm_bs.h gsm_ms.h
197 noinst_HEADERS += ie.cpp sip.h
198
199
200 # Special install function to preserve existing configs.
201 # Optimization with equivalen results are welcome
202 CONFIGFILES = options.conf interface.conf routing.conf directory.list
203 TONEDIRS = tones_american tones_efi tones_german vbox_english vbox_german
204
205 EXTRA_DIST = default debian $(TONEDIRS)
206
207 install-data-hook:
208         @fns='strcpy strncpy strcat strncat sprintf snprintf' ; \
209         files=$$( find $(srcdir) -type f -name "*.c*" \
210           | $(GREP) -v -e chan_lcr.c -e callerid.c ) ; \
211         test -z "$$files" || { for fn in $$fns ; do \
212           $(GREP) -n $$fn $$files ; if test $$? = 0 ; then \
213             ( echo "dont use $$fn, use makro instead." ; exit -1 ) ; \
214           fi ; \
215         done ; }
216         mkdir -p '$(DESTDIR)$(CONFIGdir)'
217         mkdir -p '$(DESTDIR)$(SHAREdir)'
218         mkdir -p '$(DESTDIR)$(LOGdir)'
219         mkdir -p '$(DESTDIR)$(EXTENSIONdir)'
220         @fs='$(CONFIGFILES)' ; for f in $$fs ; do \
221           if test -a "$(DESTDIR)$(CONFIGdir)/$$f" ; then \
222             echo "NOTE: $$f already exists, not changed." ; \
223           else $(INSTALL) -m 644 $(srcdir)/default/$$f "$(DESTDIR)$(CONFIGdir)/" ; fi ; \
224         done
225         @if test -a "$(DESTDIR)$(CONFIGdir)/numbering_int.conf" ; then \
226                 echo "NOTE: numbering_int.conf is obsolete, please use routing." ; fi
227         @if test -a "$(DESTDIR)$(CONFIGdir)/numbering_ext.conf" ; then \
228                 echo "NOTE: numbering_ext.conf is obsolete, please use routing." ; fi
229         @ds='$(TONEDIRS)' ; for d in $$ds ; do \
230           destdir="$(DESTDIR)$(SHAREdir)/$$d" ; \
231           if test -a "$$destdir" ; then \
232             echo "NOTE: $$d already exists, not overwritten." ; \
233           else mkdir -p "$$destdir" ; cp -a $(srcdir)/$$d/* "$$destdir/" ; fi ; \
234         done
235
236
237 # Because distuninstallcheck expects relative filenames, we cannot
238 # replace './' with $(prefix) in _listfiles. Therefore we do it the
239 # other way around to filter out configuration files and tones.
240 distcheck_CONFIGdir = echo $(CONFIGdir) | sed 's|^$(prefix)/|./|'
241 distcheck_SHAREdir  = echo $(SHAREdir)  | sed 's|^$(prefix)/|./|'
242
243 distuninstallcheck_listfiles = find . -type f -print \
244         | $(GREP) -v "$$( $(distcheck_CONFIGdir) )" \
245         | $(GREP) -v "$$( $(distcheck_SHAREdir) )"
246
247
248 clean-generic:
249         rm -f *.po
250
251 # test rule, nothing important
252 #echo:
253 #       -echo $(all_libraries) >&2
254
255 # CAUTION: CRUDE CRUDE HACK !!
256 # This transforms all compiling and linking calls from gcc into g++
257 # This should better be removed and all .c files renamed to .cpp
258 COMPILE=$(CXXCOMPILE)
259 LINK=$(CXXLINK)
260
261