Only receive RTP audio data, if connected to remote.
[lcr.git] / configure.ac
1 ##   -*- autoconf -*-
2
3 dnl    This file is part of linux-call-router
4 dnl    Copyright (C) 2007 Joerg Habenicht (j.habenicht@gmx.de)
5 dnl    Copyright (C) 2008 Peter Schlaile (peter -at- schlaile.de)
6 dnl    Copyright (C) 2010 Andreas Eversberg (jolly@eversberg.eu)
7
8 dnl    This program is free software; you can redistribute it and/or
9 dnl    modify it under the terms of the GNU General Public License as
10 dnl    published by the Free Software Foundation; either
11 dnl    version 2 of the License, or (at your option) any later version.
12
13 dnl    This program is distributed in the hope that it will be useful,
14 dnl    but WITHOUT ANY WARRANTY; without even the implied warranty of
15 dnl    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 dnl    GNU General Public License for more details.
17
18 dnl    You should have received a copy of the GNU General Public License
19 dnl    along with this library; see the file COPYING.  If not, write to
20 dnl    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
21 dnl    Boston, MA 02110-1301, USA.
22
23
24
25 dnl This keeps being the first instruction.
26 dnl Change the 2nd argument if the version increases
27 dnl 1st + 2nd argument is used for distribution package name
28 AC_INIT(lcr, 1.12, andreas@eversberg.eu)
29 AC_PREREQ(2.59)
30 AC_CONFIG_SRCDIR([main.c])
31 AM_CONFIG_HEADER(config.h)
32
33 # fix warnings from autoconf + automake
34 AC_GNU_SOURCE
35 # AC_USE_SYSTEM_EXTENSIONS
36 AM_INIT_AUTOMAKE(lcr,1.12)
37
38
39
40 # Checks for programs.
41 AC_PROG_CPP
42 AC_PROG_CXX
43 AC_PROG_CC
44 AC_PROG_INSTALL
45 AC_PROG_MAKE_SET
46 dnl required, if per binary CFLAGS are used
47 dnl AM_PROG_CC_C_O
48
49
50 # site specific configs
51 dnl enable this to have all special options on one place
52 dnl AC_PRESERVE_HELP_ORDER
53
54 # check for mISDN
55 AC_ARG_WITH([misdn],
56         [AS_HELP_STRING([--with-misdn],
57                         [compile with mISDN driver @<:@default=check@:>@])
58         ],
59         [],
60         [with_misdn="check"])
61
62 AS_IF([test "x$with_misdn" != xno],
63       [AC_CHECK_HEADERS([mISDN/mbuffer.h],
64                         [with_misdn="yes"],
65                         [if test "x$with_misdn" != xcheck ; then
66                       AC_MSG_FAILURE(
67                         [--with-misdn was given, but test for header-file mISDN/mbuffer.h failed])
68                      fi
69                      ])
70       ])
71
72 AM_CONDITIONAL(ENABLE_MISDN, test "x$with_misdn" == "xyes" )
73
74 # check for asterisk
75 AC_ARG_WITH([asterisk],
76         [AS_HELP_STRING([--with-asterisk],
77                         [compile with built-in Asterisk channel driver @<:@default=check@:>@])
78         ],
79         [],
80         [with_asterisk="check"])
81
82 AS_IF([test "x$with_asterisk" != xno],
83       [AC_CHECK_HEADERS([asterisk/compiler.h],
84                         [with_asterisk="yes"],
85                         [if test "x$with_asterisk" != xcheck ; then
86                       AC_MSG_FAILURE(
87                         [--with-asterisk was given, but test for header-file asterisk/compiler.h failed])
88                      fi
89                      ])
90       ])
91
92 if test "x$with_asterisk" = "xyes"; then
93         ast_tone_zone_sound=
94         ast_1_8_or_higher=
95
96         AC_MSG_CHECKING([for struct tone_zone_sound in asterisk/indications.h])
97         tzs_test_result=no
98         AC_COMPILE_IFELSE([
99                 AC_LANG_PROGRAM(
100                         [[#include <asterisk.h>],
101                         [#include <asterisk/linkedlists.h>],
102                         [#include <asterisk/indications.h>]],
103                         [[struct tone_zone_sound * ts = NULL; (void) ts->data;]])],
104                 [tzs_test_result=yes])
105         AC_MSG_RESULT([$tzs_test_result])
106
107         if test "x$tzs_test_result" = "xyes"; then
108                 ast_tone_zone_sound=tone_zone_sound
109         fi
110
111         if test "x$ast_tone_zone_sound" = "x"; then
112                 AC_MSG_CHECKING([for struct ast_tone_zone_sound in asterisk/indications.h])
113                 tzs_test_result=no
114                 AC_COMPILE_IFELSE([
115                         AC_LANG_PROGRAM(
116                                 [[#include <asterisk.h>],
117                                 [#include <asterisk/linkedlists.h>],
118                                 [#include <asterisk/indications.h>]],
119                                 [[struct ast_tone_zone_sound * ts = NULL; (void) ts->name;]])],
120                         [tzs_test_result=yes])
121                 AC_MSG_RESULT([$tzs_test_result])
122
123                 if test "x$tzs_test_result" = "xyes"; then
124                         ast_tone_zone_sound=ast_tone_zone_sound
125                 fi
126         fi
127
128         if test "x$ast_tone_zone_sound" = "x"; then
129                 AC_MSG_FAILURE([No ast_tone_zone_sound, confused...])
130         fi
131
132         AC_MSG_CHECKING([for struct ast_party_caller in asterisk/channel.h])
133         apc_test_result=no
134         AC_COMPILE_IFELSE([
135                 AC_LANG_PROGRAM(
136                         [[#include <asterisk.h>],
137                         [#include <asterisk/channel.h>]],
138                         [[struct ast_party_caller * caller = NULL; (void) caller->id;]])],
139                 [apc_test_result=yes])
140         AC_MSG_RESULT([$apc_test_result])
141
142         if test "x$apc_test_result" = "xyes"; then
143                 ast_1_8_or_higher="-DAST_1_8_OR_HIGHER"
144         fi
145
146         AST_CFLAGS="-Dtone_zone_sound=$ast_tone_zone_sound $ast_1_8_or_higher"
147
148         AC_SUBST([AST_CFLAGS])
149 fi
150
151 AM_CONDITIONAL(ENABLE_ASTERISK_CHANNEL_DRIVER, test "x$with_asterisk" == "xyes" )
152
153 # check for crypto
154 AC_ARG_WITH([ssl],
155         [AS_HELP_STRING([--with-ssl],
156                         [compile with ssl support (libcrypto) @<:@default=check@:>@])
157         ],
158         [],
159         [with_ssl=check])
160 LIBCRYPTO=
161 AS_IF([test "x$with_ssl" != xno],
162       [AC_CHECK_HEADERS([openssl/rsa.h])
163        AC_CHECK_LIB([crypto], [main],
164                     [AC_SUBST([LIBCRYPTO], ["-lcrypto"])
165                      AC_DEFINE([HAVE_LIBCRYPTO], [1],
166                                [Define if you have libcrypto])
167                     ],
168                     [if test "x$with_ssl" != xcheck ; then
169                       AC_MSG_FAILURE(
170                         [--with-ssl was given, but test for libcrypto failed])
171                      fi
172                     ],
173                     -lcrypto
174                    )
175       ]
176      )
177
178 # check for gsm-bs
179 AC_ARG_WITH([gsm-bs],
180         [AS_HELP_STRING([--with-gsm-bs],
181                         [compile with OpenBSC support @<:@default=no@:>@])
182         ],
183         [],
184         [with_gsm_bs="check"])
185
186 AM_CONDITIONAL(ENABLE_GSM_BS, test "x$with_gsm_bs" == "xyes" )
187
188 # check for gsm-ms
189 AC_ARG_WITH([gsm-ms],
190         [AS_HELP_STRING([--with-gsm-ms],
191                         [compile with Osmocom-bb support @<:@default=no@:>@])
192         ],
193         [],
194         [with_gsm_ms="check"])
195
196 AM_CONDITIONAL(ENABLE_GSM_MS, test "x$with_gsm_ms" == "xyes" )
197
198 AM_CONDITIONAL(ENABLE_GSM, test "x$with_gsm_bs" == "xyes" -o "x$with_gsm_ms" == "xyes")
199
200 AS_IF([test "x$with_gsm_bs" == xyes -o "x$with_gsm_ms" == xyes],
201         [AC_MSG_CHECKING(/usr/include/gsm/gsm.h)
202         if test -e /usr/include/gsm/gsm.h; then
203                 AC_MSG_RESULT(yes)
204         else
205         AC_MSG_FAILURE([You have enabled GSM, but /usr/include/gsm/gsm.h not found! Please install the lossy GSM codec. Be sure to install it in /usr/ and not in /usr/local/. You will also find a copy on http://www.linux-call-router.de.])
206         fi
207         ])
208
209 # check for ss5
210 AC_ARG_WITH([ss5],
211         [AS_HELP_STRING([--with-ss5],
212                         [compile with CCITT No. 5 support @<:@default=no@:>@])
213         ],
214         [],
215         [with_ss5="check"])
216
217 AM_CONDITIONAL(ENABLE_SS5, test "x$with_ss5" == "xyes" )
218
219 # check for SIP
220 AC_ARG_WITH([sip],
221         [AS_HELP_STRING([--with-sip],
222                         [compile with SIP support (sofia-sip is required) @<:@default=no@:>@])
223         ],
224         [],
225         [with_sip="check"])
226
227 AM_CONDITIONAL(ENABLE_SIP, test "x$with_sip" == "xyes" )
228
229 AS_IF([test "x$with_sip" == xyes -o "x$with_sip" == xyes], [
230                 PKG_CHECK_MODULES(SOFIA, sofia-sip-ua >= 1.12)
231         ])
232
233 # Checks for libraries.
234 AC_CHECK_LIB([m], [main])
235 AC_CHECK_LIB([ncurses], [main])
236 AC_CHECK_LIB([pthread], [main])
237
238 # Checks for header files.
239 AC_HEADER_DIRENT
240 AC_HEADER_STDC
241 AC_HEADER_SYS_WAIT
242 AC_CHECK_HEADERS([fcntl.h netinet/in.h stdlib.h string.h sys/file.h sys/ioctl.h sys/socket.h sys/time.h unistd.h ctype.h assert.h assert.h])
243
244 # Checks for typedefs, structures, and compiler characteristics.
245 AC_HEADER_STDBOOL
246 AC_C_CONST
247 AC_C_INLINE
248 AC_TYPE_PID_T
249 AC_HEADER_TIME
250 AC_STRUCT_TM
251
252 # Checks for library functions.
253 AC_FUNC_FORK
254 AC_PROG_GCC_TRADITIONAL
255 AC_FUNC_LSTAT
256 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
257 AC_FUNC_MALLOC
258 AC_FUNC_MEMCMP
259 AC_TYPE_SIGNAL
260 AC_FUNC_STRNLEN
261 AC_FUNC_STRTOD
262 AC_FUNC_VPRINTF
263 AC_CHECK_FUNCS([gettimeofday memmove memset mkdir socket strcasecmp strchr strerror strncasecmp strstr strtol strtoul])
264
265
266 AC_CONFIG_FILES([Makefile])
267 AC_OUTPUT
268
269
270 AS_IF([test "x$with_misdn" == xyes],[AC_MSG_NOTICE( Compiled with mISDN support )],[AC_MSG_NOTICE( Not compiled with mISDN support)])
271 AS_IF([test "x$with_gsm_bs" == xyes],[AC_MSG_NOTICE( Compiled with GSM network side support )],[AC_MSG_NOTICE( Not compiled with GSM network side support)])
272 AS_IF([test "x$with_gsm_ms" == xyes],[AC_MSG_NOTICE( Compiled with GSM mobile side support )],[AC_MSG_NOTICE( Not compiled with GSM mobile side support)])
273 AS_IF([test "x$with_asterisk" == xyes],[AC_MSG_NOTICE( Compiled with Asterisk channel driver support )],[AC_MSG_NOTICE( Not compiled with Asterisk channel driver support)])
274 AS_IF([test "x$with_ss5" == xyes],[AC_MSG_NOTICE( Compiled with CCITT No.5 support )],[AC_MSG_NOTICE( Not compiled with CCITT No.5 support)])
275 AS_IF([test "x$with_sip" == xyes],[AC_MSG_NOTICE( Compiled with SIP support )],[AC_MSG_NOTICE( Not compiled with SIP support)])
276