4174bedb3c9cab606e7309602d6e1acc261ffd29
[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 if ENABLE_MISDN
47
48 MISDN_INCLUDE = -DWITH_MISDN -DWITH_CRYPT
49 MISDN_SOURCE = mISDN.cpp dss1.cpp loop.c crypt.cpp remote.cpp joinremote.cpp
50 MISDN_LIB = -lmisdn
51
52 endif
53
54 GSM_INCLUDE =
55 GSM_SOURCE =
56 GSM_LIB =
57
58 if ENABLE_GSM
59
60 GSM_INCLUDE +=
61
62 GSM_SOURCE += gsm_audio.c gsm.cpp
63   
64 GSM_LIB += /usr/lib/libgsm.a
65
66 #gsm_audio.po: gsm_audio.c gsm_audio.h
67 #       $(CC) -D_GNU_SOURCE -fPIC -c gsm_audio.c -o gsm_audio.po
68
69 endif
70
71 if ENABLE_GSM_BS
72
73 GSM_INCLUDE += -DWITH_GSM_BS
74
75 GSM_SOURCE += gsm_bs.cpp
76
77 endif
78
79 if ENABLE_GSM_MS
80
81 GSM_INCLUDE += -DWITH_GSM_MS
82
83 GSM_SOURCE += gsm_ms.cpp
84
85 endif
86
87 if ENABLE_SS5
88
89 SS5_INCLUDE = -DWITH_SS5
90
91 SS5_SOURCE = ss5.cpp ss5_encode.c ss5_decode.c
92
93 endif
94
95 SIP_LIB =
96
97 if ENABLE_SIP
98
99 # FIXME: remove that
100 #pkgconfigdir = $(libdir)/pkgconfig
101 #pkgconfig_DATA = sofia-sip-ua.pc
102
103 SIP_INCLUDE = -DWITH_SIP $(SOFIA_CFLAGS)
104
105 SIP_SOURCE = sip.cpp
106
107 SIP_LIB += $(SOFIA_LIBS)
108
109 endif
110
111 bin_PROGRAMS = lcradmin gentones genwave
112
113 sbin_PROGRAMS = lcr genrc genextension
114
115 if ENABLE_ASTERISK_CHANNEL_DRIVER
116 noinst_PROGRAMS = chan_lcr.so
117 chan_lcr_so_SOURCES =
118 chan_lcr_so_LDFLAGS = -shared
119 chan_lcr_so_LDADD = chan_lcr.po bchannel.po options.po callerid.po select.po
120
121 chan_lcr.po: chan_lcr.c chan_lcr.h
122         $(CC) $(INCLUDES) $(AST_CFLAGS) $(CPPFLAGS) $(CFLAGS) -D_GNU_SOURCE -fPIC -c chan_lcr.c -o chan_lcr.po
123
124 bchannel.po: bchannel.c bchannel.h
125         $(CC) $(INCLUDES) -D_GNU_SOURCE $(CPPFLAGS) $(CFLAGS) -fPIC -c bchannel.c -o bchannel.po
126
127 callerid.po: callerid.c callerid.h
128         $(CC) $(INCLUDES) -D_GNU_SOURCE $(CPPFLAGS) $(CFLAGS) -fPIC -c callerid.c -o callerid.po
129
130 options.po: options.c options.h
131         $(CC) $(INCLUDES) -D_GNU_SOURCE $(CPPFLAGS) $(CFLAGS) -fPIC -c options.c -o options.po
132
133 select.po: select.c select.h
134         $(CC) $(INCLUDES) -D_GNU_SOURCE $(CPPFLAGS) $(CFLAGS) -fPIC -c select.c -o select.po
135
136 install-exec-hook:
137         $(INSTALL) -d '$(DESTDIR)$(astmoddir)'
138         $(INSTALL) chan_lcr.so '$(DESTDIR)$(astmoddir)'
139 endif
140
141 INCLUDES = $(all_includes) $(MISDN_INCLUDE) $(GSM_INCLUDE) $(SS5_INCLUDE) $(SIP_INCLUDE) -Wall $(INSTALLATION_DEFINES)
142
143 lcr_SOURCES = \
144         main.c select.c trace.c options.c tones.c alawulaw.c cause.c interface.c message.c callerid.c socket_server.c \
145         port.cpp vbox.cpp \
146         $(MISDN_SOURCE) $(GSM_SOURCE) $(SS5_SOURCE) $(SIP_SOURCE) \
147         endpoint.cpp endpointapp.cpp \
148         appbridge.cpp apppbx.cpp route.c action.cpp action_efi.cpp action_vbox.cpp extension.c mail.c \
149         join.cpp joinpbx.cpp
150
151 lcr_LDADD = $(LIBCRYPTO) $(MISDN_LIB) -lpthread $(GSM_LIB) $(SIP_LIB)
152
153
154 lcradmin_SOURCES = lcradmin.c cause.c options.c
155 genextension_SOURCES = genext.c options.c extension.c
156
157 # Special install function to preserve existing configs.
158 # Optimization with equivalen results are welcome
159 CONFIGFILES = options.conf interface.conf routing.conf directory.list
160 TONEDIRS = tones_american tones_efi tones_german vbox_english vbox_german
161
162 install-data-hook:
163         @fns='strcpy strncpy strcat strncat sprintf snprintf' ; \
164         files=$$( find . -type f -name "*.c*" \
165           | $(GREP) -v -e chan_lcr.c -e bchannel.c -e callerid.c ) ; \
166         test -z "$$files" || { for fn in $$fns ; do \
167           $(GREP) -n $$fn $$files ; if test $$? = 0 ; then \
168             ( echo "dont use $$fn, use makro instead." ; exit -1 ) ; \
169           fi ; \
170         done ; }
171         mkdir -p '$(DESTDIR)$(CONFIGdir)'
172         mkdir -p '$(DESTDIR)$(SHAREdir)'
173         mkdir -p '$(DESTDIR)$(LOGdir)'
174         mkdir -p '$(DESTDIR)$(EXTENSIONdir)'
175         @fs='$(CONFIGFILES)' ; for f in $$fs ; do \
176           if test -a "$(DESTDIR)$(CONFIGdir)/$$f" ; then \
177             echo "NOTE: $$f already exists, not changed." ; \
178           else $(INSTALL) -m 644 default/$$f "$(DESTDIR)$(CONFIGdir)/" ; fi ; \
179         done
180         @if test -a "$(DESTDIR)$(CONFIGdir)/numbering_int.conf" ; then \
181                 echo "NOTE: numbering_int.conf is obsolete, please use routing." ; fi
182         @if test -a "$(DESTDIR)$(CONFIGdir)/numbering_ext.conf" ; then \
183                 echo "NOTE: numbering_ext.conf is obsolete, please use routing." ; fi
184         @ds='$(TONEDIRS)' ; for d in $$ds ; do \
185           destdir="$(DESTDIR)$(SHAREdir)/$$d" ; \
186           if test -a "$$destdir" ; then \
187             echo "NOTE: $$d already exists, not overwritten." ; \
188           else mkdir -p "$$destdir" ; cp -a $$d/* "$$destdir/" ; fi ; \
189         done
190
191 clean-generic:
192         rm -f *.po
193
194 # test rule, nothing important
195 #echo:
196 #       -echo $(all_libraries) >&2
197
198 # CAUTION: CRUDE CRUDE HACK !!
199 # This transforms all compiling and linking calls from gcc into g++
200 # This should better be removed and all .c files renamed to .cpp
201 COMPILE=$(CXXCOMPILE)
202 LINK=$(CXXLINK)
203
204