b56560bbb42df62476924894c45e5749122f68ab
[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 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=$(DESTDIR)$(pkgsysconfdir)
29 #SHAREdir=$(DESTDIR)$(pkgdatadir)
30 #LOGdir=$(DESTDIR)$(pkglogdir)
31 #EXTENSIONdir=$(DESTDIR)$(localstatedir)/lib/lcr
32
33 CONFIGdir=$(INSTALLdir)
34 SHAREdir=$(INSTALLdir)
35 LOGdir=$(INSTALLdir)
36 EXTENSIONdir=$(INSTALLdir)/extensions
37
38 astmoddir = $(DESTDIR)/usr/lib/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_GSM
47
48 GSM_INCLUDE = -DWITH_GSM -I./openbsc/include -I./libosmocore/include
49
50 GSM_SOURCE = gsm_audio.c gsm.cpp gsm_conf.c openbsc/src/bsc_init.c openbsc/src/vty_interface.c openbsc/src/vty_interface_layer3.c
51
52 GSM_LIB = /usr/lib/libgsm.a ./openbsc/src/libbsc.a ./openbsc/src/libmsc.a ./openbsc/src/libvty.a -L./libosmocore/src/ -losmocore -ldbi -lcrypt
53
54 #gsm_audio.po: gsm_audio.c gsm_audio.h
55 #       $(CC) -D_GNU_SOURCE -fPIC -c gsm_audio.c -o gsm_audio.po
56
57 endif
58
59 if ENABLE_SS5
60
61 SS5_INCLUDE = -DWITH_SS5
62
63 SS5_SOURCE = ss5.cpp ss5_encode.c ss5_decode.c
64
65 endif
66
67 bin_PROGRAMS = lcradmin gentones genwave
68
69 sbin_PROGRAMS = lcr genrc genextension
70
71 if ENABLE_ASTERISK_CHANNEL_DRIVER
72 noinst_PROGRAMS = chan_lcr.so
73 chan_lcr_so_SOURCES =
74 chan_lcr_so_LDFLAGS = -shared
75 chan_lcr_so_LDADD = chan_lcr.po bchannel.po options.po callerid.po select.po
76
77 chan_lcr.po: chan_lcr.c chan_lcr.h
78         $(CC) $(INCLUDES) -D_GNU_SOURCE -fPIC -c chan_lcr.c -o chan_lcr.po
79
80 bchannel.po: bchannel.c bchannel.h
81         $(CC) $(INCLUDES) -D_GNU_SOURCE -fPIC -c bchannel.c -o bchannel.po
82
83 callerid.po: callerid.c callerid.h
84         $(CC) $(INCLUDES) -D_GNU_SOURCE -fPIC -c callerid.c -o callerid.po
85
86 options.po: options.c options.h
87         $(CC) $(INCLUDES) -D_GNU_SOURCE -fPIC -c options.c -o options.po
88
89 select.po: select.c select.h
90         $(CC) $(INCLUDES) -D_GNU_SOURCE -fPIC -c select.c -o select.po
91
92 install-exec-hook:
93         mkdir -p $(astmoddir)
94         $(INSTALL) -d $(astmoddir)
95         $(INSTALL) chan_lcr.so $(astmoddir)
96 endif
97
98 INCLUDES = $(all_includes) $(GSM_INCLUDE) $(SS5_INCLUDE) -Wall $(INSTALLATION_DEFINES)
99
100 lcr_SOURCES = $(GSM_SOURCE) $(SS5_SOURCE) select.c action.cpp       mISDN.cpp        tones.c \
101         action_efi.cpp   crypt.cpp        mail.c           trace.c \
102         action_vbox.cpp  dss1.cpp         main.c           \
103         vbox.cpp alawulaw.c       endpoint.cpp     interface.c     message.c \
104         apppbx.cpp       endpointapp.cpp  join.cpp        options.c       \
105         extension.c      joinpbx.cpp     port.cpp \
106         callerid.c       joinremote.cpp  route.c \
107         cause.c          socket_server.c
108
109 lcr_LDADD = $(LIBCRYPTO) -lmisdn -lpthread $(GSM_LIB)
110
111
112 lcradmin_SOURCES = lcradmin.c cause.c options.c
113 genextension_SOURCES = genext.c options.c extension.c
114
115 # Special install function to preserve existing configs.
116 # Optimization with equivalen results are welcome
117
118 install-data-hook:
119         @sh -c 'grep -n strcpy *.c* --exclude chan_lcr.c --exclude bchannel.c --exclude callerid.c ; if test $$''? = 0 ; then echo "dont use strcpy, use makro instead." ; exit -1 ; fi'
120         @sh -c 'grep -n strncpy *.c* --exclude chan_lcr.c --exclude bchannel.c --exclude callerid.c ; if test $$''? = 0 ; then echo "dont use strncpy, use makro instead." ; exit -1 ; fi'
121         @sh -c 'grep -n strcat *.c* --exclude chan_lcr.c --exclude bchannel.c --exclude callerid.c ; if test $$''? = 0 ; then echo "dont use strcat, use makro instead." ; exit -1 ; fi'
122         @sh -c 'grep -n strncat *.c* --exclude chan_lcr.c --exclude bchannel.c --exclude callerid.c ; if test $$''? = 0 ; then echo "dont use strncat, use makro instead." ; exit -1 ; fi'
123         @sh -c 'grep -n sprintf *.c* --exclude chan_lcr.c --exclude bchannel.c --exclude callerid.c ; if test $$''? = 0 ; then echo "dont use sprintf, use makro instead." ; exit -1 ; fi'
124         @sh -c 'grep -n snprintf *.c* --exclude chan_lcr.c --exclude bchannel.c --exclude callerid.c ; if test $$''? = 0 ; then echo "dont use snprintf, use makro instead." ; exit -1 ; fi'
125         mkdir -p $(CONFIGdir)
126         mkdir -p $(SHAREdir)
127         mkdir -p $(LOGdir)
128         mkdir -p $(EXTENSIONdir)
129         @if test -a $(CONFIGdir)/options.conf ; then \
130                 echo "NOTE: options.conf already exists, not changed." ; else \
131                 cp -v default/options.conf $(CONFIGdir) ; fi
132         @if test -a $(CONFIGdir)/interface.conf ; then \
133                 echo "NOTE: interface.conf already exists, not changed." ; else \
134                 cp -v default/interface.conf $(CONFIGdir) ; fi
135         @if test -a $(CONFIGdir)/routing.conf ; then \
136                 echo "NOTE: routing.conf already exists, not changed." ; else \
137                 cp -v default/routing.conf $(CONFIGdir) ; fi
138 if ENABLE_GSM
139         @if test -a $(CONFIGdir)/gsm.conf ; then \
140                 echo "NOTE: gsm.conf already exists, not changed." ; else \
141                 cp -v default/gsm.conf $(CONFIGdir) ; fi
142         @if test -a $(CONFIGdir)/openbsc.cfg ; then \
143                 echo "NOTE: openbsc.cfg already exists, not changed." ; else \
144                 cp -v default/openbsc.cfg $(CONFIGdir) ; fi
145 endif
146         @if test -a $(CONFIGdir)/numbering_int.conf ; then \
147                 echo "NOTE: numbering_int.conf is obsolete, please use routing." ; fi
148         @if test -a $(CONFIGdir)/numbering_ext.conf ; then \
149                 echo "NOTE: numbering_ext.conf is obsolete, please use routing." ; fi
150         @if test -a $(CONFIGdir)/directory.list ; then \
151                 echo "NOTE: directory.list already exists, not changed." ; else \
152                 cp -v default/directory.list $(CONFIGdir) ; fi
153         @if test -a $(SHAREdir)/tones_american ; then \
154                 echo "NOTE: american tones already exists, not overwritten." ; else \
155                 cp -a tones_american $(SHAREdir) ; fi
156         @if test -a $(SHAREdir)/tones_german ; then \
157                 echo "NOTE: german tones already exists, not overwritten." ; else \
158                 cp -a tones_german $(SHAREdir) ; fi
159         @if test -a $(SHAREdir)/vbox_german ; then \
160                 echo "NOTE: german vbox tones already exists, not overwritten." ; else \
161                 cp -a vbox_german $(SHAREdir) ; fi
162         @if test -a $(SHAREdir)/vbox_english ; then \
163                 echo "NOTE: english vbox tones already exists, not overwritten." ; else \
164                 cp -a vbox_english $(SHAREdir) ; fi
165         @if test -a $(SHAREdir)/tones_efi ; then \
166                 echo "NOTE: special efi tones already exists, not overwritten." ; else \
167                 cp -a tones_efi $(SHAREdir) ; fi
168
169 clean-generic:
170         rm -f *.po
171
172 # test rule, nothing important
173 #echo:
174 #       -echo $(all_libraries) >&2
175
176 # CAUTION: CRUDE CRUDE HACK !!
177 # This transforms all compiling and linking calls from gcc into g++
178 # This should better be removed and all .c files renamed to .cpp
179 COMPILE=$(CXXCOMPILE)
180 LINK=$(CXXLINK)
181
182