WIP: chan_lcr support for Asterisk 11.5
[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.14, 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.14)
37
38
39
40 # Checks for programs.
41 AC_PROG_GREP
42 AC_PROG_CPP
43 AC_PROG_CXX
44 AC_PROG_CC
45 AC_PROG_INSTALL
46 AC_PROG_MAKE_SET
47 AC_PROG_LIBTOOL
48 dnl required, if per binary CFLAGS are used
49 dnl AM_PROG_CC_C_O
50
51
52 # site specific configs
53 dnl enable this to have all special options on one place
54 dnl AC_PRESERVE_HELP_ORDER
55
56 # check for mISDN
57 AC_ARG_WITH([misdn],
58         [AS_HELP_STRING([--with-misdn],
59                         [compile with mISDN driver @<:@default=check@:>@])
60         ],
61         [],
62         [with_misdn="check"])
63
64 AS_IF([test "x$with_misdn" != xno],
65       [AC_CHECK_HEADERS([mISDN/mbuffer.h],
66                         [with_misdn="yes"],
67                         [if test "x$with_misdn" != xcheck ; then
68                       AC_MSG_FAILURE(
69                         [--with-misdn was given, but test for header-file mISDN/mbuffer.h failed])
70                      fi
71                      ])
72       ])
73
74 AM_CONDITIONAL(ENABLE_MISDN, test "x$with_misdn" == "xyes" )
75
76 # check for asterisk
77 AC_ARG_WITH([asterisk],
78         [AS_HELP_STRING([--with-asterisk],
79                         [compile with built-in Asterisk channel driver @<:@default=check@:>@])
80         ],
81         [],
82         [with_asterisk="check"])
83
84 AS_IF([test "x$with_asterisk" != xno],
85       [AC_CHECK_HEADERS([asterisk/compiler.h],
86                         [with_asterisk="yes"],
87                         [if test "x$with_asterisk" != xcheck ; then
88                       AC_MSG_FAILURE(
89                         [--with-asterisk was given, but test for header-file asterisk/compiler.h failed])
90                      fi
91                      ])
92       ])
93
94 if test "x$with_asterisk" = "xyes"; then
95         dnl detect whether asterisk/indications.h defines ast_tone_zone_sound (1.6.2
96         dnl and later), ind_tone_zone_sound (1.6.0) or tone_zone_sound (1.4)
97         ast_tone_zone_sound=
98         apc_test_result=
99         ast_1_8_or_higher=
100
101         AC_CHECK_TYPE([struct ast_tone_zone_sound],
102                 [ast_tone_zone_sound=ast_tone_zone_sound], [], [
103 #include <asterisk.h>
104 #include <asterisk/linkedlists.h>
105 #include <asterisk/indications.h>])
106
107         AS_IF([test "x$ast_tone_zone_sound" = "x"],
108                 [AC_CHECK_TYPE([struct ind_tone_zone_sound],
109                         [ast_tone_zone_sound=ind_tone_zone_sound], [], [
110 #include <asterisk.h>
111 #include <asterisk/linkedlists.h>
112 #include <asterisk/indications.h>])])
113         AS_IF([test "x$ast_tone_zone_sound" = "x"],
114                 [AC_CHECK_TYPE([struct tone_zone_sound],
115                         [ast_tone_zone_sound=tone_zone_sound], [], [
116 #include <asterisk.h>
117 #include <asterisk/indications.h>])])
118
119         if test "x$ast_tone_zone_sound" = "x"; then
120                 AC_MSG_FAILURE([No ast_tone_zone_sound, confused...])
121         fi
122
123
124         AC_CHECK_TYPE([struct ast_party_caller],
125                 [apc_test_result=yes], [], [
126 #include <asterisk.h>
127 #include <asterisk/channel.h>])
128
129         if test "x$apc_test_result" = "xyes"; then
130                 ast_1_8_or_higher="-DAST_1_8_OR_HIGHER"
131         fi
132
133         AST_CFLAGS="-Dast_tone_zone_sound=$ast_tone_zone_sound $ast_1_8_or_higher"
134
135         AC_SUBST([AST_CFLAGS])
136
137         AC_CHECK_PROG(ASTERISK, asterisk, executable found,)
138         if test x"$ASTERISK" = x; then
139                 AC_MSG_ERROR([asterisk executable not found])
140         fi
141
142         AC_MSG_CHECKING([for asterisk's version])
143                 version=`asterisk -V`
144                 pri=`echo $version | sed 's#.* \([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)#\1#' `
145                 sec=`echo $version | sed 's#.* \([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)#\2#' `
146                 ter=`echo $version | sed 's#.* \([0-9]*\)\.\([0-9]*\)\.\([0-9]*\)#\3#' `
147                 numver="$(printf '%02d' "$pri")$(printf '%02d' "$sec")$(printf '%02d' "$ter")"
148 #               if [ $numver -lt 100000 ]; then
149 #                       AC_MSG_ERROR([Asterisk version found is too old; x.y.z required])
150 #               fi
151         AC_MSG_RESULT([$numver])
152         AC_DEFINE_UNQUOTED([ASTERISK_VERSION_NUM], $numver, [Asterisk version found])
153 fi
154
155 AM_CONDITIONAL(ENABLE_ASTERISK_CHANNEL_DRIVER, test "x$with_asterisk" == "xyes" )
156
157 # check for crypto
158 AC_ARG_WITH([ssl],
159         [AS_HELP_STRING([--with-ssl],
160                         [compile with ssl support (libcrypto) @<:@default=check@:>@])
161         ],
162         [],
163         [with_ssl=check])
164 LIBCRYPTO=
165 AS_IF([test "x$with_ssl" != xno],
166       [AC_CHECK_HEADERS([openssl/rsa.h])
167        AC_CHECK_LIB([crypto], [main],
168                     [AC_SUBST([LIBCRYPTO], ["-lcrypto"])
169                      AC_DEFINE([HAVE_LIBCRYPTO], [1],
170                                [Define if you have libcrypto])
171                     ],
172                     [if test "x$with_ssl" != xcheck ; then
173                       AC_MSG_FAILURE(
174                         [--with-ssl was given, but test for libcrypto failed])
175                      fi
176                     ],
177                     -lcrypto
178                    )
179       ]
180      )
181
182 # check for gsm-bs
183 AC_ARG_WITH([gsm-bs],
184         [AS_HELP_STRING([--with-gsm-bs],
185                         [compile with OpenBSC support @<:@default=no@:>@])
186         ],
187         [],
188         [with_gsm_bs="check"])
189
190 AM_CONDITIONAL(ENABLE_GSM_BS, test "x$with_gsm_bs" == "xyes" )
191
192 # check for gsm-ms
193 AC_ARG_WITH([gsm-ms],
194         [AS_HELP_STRING([--with-gsm-ms],
195                         [compile with Osmocom-bb support @<:@default=no@:>@])
196         ],
197         [],
198         [with_gsm_ms="check"])
199
200 AM_CONDITIONAL(ENABLE_GSM_MS, test "x$with_gsm_ms" == "xyes" )
201
202 AM_CONDITIONAL(ENABLE_GSM, test "x$with_gsm_bs" == "xyes" -o "x$with_gsm_ms" == "xyes")
203
204 # check for opencore-amrnb for AMR and EFR decoding
205 found_opencore_amrnb=yes
206 PKG_CHECK_MODULES(OPENCORE_AMRNB, opencore-amrnb >= 0.1.0, , found_opencore_amrnb=no)
207 AM_CONDITIONAL(ENABLE_GSMAMR, test "$found_opencore_amrnb" = "yes")
208 if test "$found_opencore_amrnb" = yes; then
209         AC_DEFINE(HAVE_OPENCORE_AMRNB, 1, [Define to 1 if OpenCore AMR-NB library is available])
210 fi
211
212 # check for HR codec
213 AC_ARG_ENABLE(gsmhr,
214         [AS_HELP_STRING(
215                 [--enable-gsmhr],
216                 [Enable support for GSM HR codec using reference code]
217         )],
218         [enable_gsmhr=1], [enable_gsmhr=0])
219 AM_CONDITIONAL(ENABLE_GSMHR, test "x$enable_gsmhr" = "x1")
220 if test "x$enable_gsmhr" = "x1"; then
221         AM_PATH_PYTHON([2.4])
222         AC_DEFINE(HAVE_LIBGSMHR, 1, [Define to 1 if libgsmhr is available])
223 fi
224
225 # check for ss5
226 AC_ARG_WITH([ss5],
227         [AS_HELP_STRING([--with-ss5],
228                         [compile with CCITT No. 5 support @<:@default=no@:>@])
229         ],
230         [],
231         [with_ss5="check"])
232
233 AM_CONDITIONAL(ENABLE_SS5, test "x$with_ss5" == "xyes" )
234
235 # check for SIP
236 AC_ARG_WITH([sip],
237         [AS_HELP_STRING([--with-sip],
238                         [compile with SIP support (sofia-sip is required) @<:@default=no@:>@])
239         ],
240         [],
241         [with_sip="check"])
242
243 AM_CONDITIONAL(ENABLE_SIP, test "x$with_sip" == "xyes" )
244
245 AS_IF([test "x$with_sip" == xyes -o "x$with_sip" == xyes], [
246                 PKG_CHECK_MODULES(SOFIA, sofia-sip-ua >= 1.12)
247         ])
248
249 # Checks for libraries.
250 AC_CHECK_LIB([m], [main])
251 AC_CHECK_LIB([ncurses], [main])
252 AC_CHECK_LIB([pthread], [main])
253
254 # Checks for header files.
255 AC_HEADER_DIRENT
256 AC_HEADER_STDC
257 AC_HEADER_SYS_WAIT
258 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])
259
260 # Checks for typedefs, structures, and compiler characteristics.
261 AC_HEADER_STDBOOL
262 AC_C_CONST
263 AC_C_INLINE
264 AC_TYPE_PID_T
265 AC_HEADER_TIME
266 AC_STRUCT_TM
267
268 # Checks for library functions.
269 AC_FUNC_FORK
270 AC_PROG_GCC_TRADITIONAL
271 AC_FUNC_LSTAT
272 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
273 AC_FUNC_MALLOC
274 AC_FUNC_MEMCMP
275 AC_TYPE_SIGNAL
276 AC_FUNC_STRNLEN
277 AC_FUNC_STRTOD
278 AC_FUNC_VPRINTF
279 AC_CHECK_FUNCS([gettimeofday memmove memset mkdir socket strcasecmp strchr strerror strncasecmp strstr strtol strtoul])
280
281
282 AC_CONFIG_FILES([Makefile include/Makefile include/gsmhr/Makefile libgsmhr/Makefile])
283 AC_OUTPUT
284
285
286 AS_IF([test "x$with_misdn" == xyes],[AC_MSG_NOTICE( Compiled with mISDN support )],[AC_MSG_NOTICE( Not compiled with mISDN support)])
287 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)])
288 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)])
289 AS_IF([test "x$enable_gsmhr" == x1],[AC_MSG_NOTICE( Compiled with GSM half rate codec support )],[AC_MSG_NOTICE( Not compiled with GSM half rate codec support)])
290 AS_IF([test "x$found_opencore_amrnb" == xyes],[AC_MSG_NOTICE( Compiled with GSM AMR codec support )],[AC_MSG_NOTICE( Not compiled with GSM AMR codec support)])
291 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)])
292 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)])
293 AS_IF([test "x$with_sip" == xyes],[AC_MSG_NOTICE( Compiled with SIP support )],[AC_MSG_NOTICE( Not compiled with SIP support)])
294