Change Version to 1.14
[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 dnl required, if per binary CFLAGS are used
48 dnl AM_PROG_CC_C_O
49
50
51 # site specific configs
52 dnl enable this to have all special options on one place
53 dnl AC_PRESERVE_HELP_ORDER
54
55 # check for mISDN
56 AC_ARG_WITH([misdn],
57         [AS_HELP_STRING([--with-misdn],
58                         [compile with mISDN driver @<:@default=check@:>@])
59         ],
60         [],
61         [with_misdn="check"])
62
63 AS_IF([test "x$with_misdn" != xno],
64       [AC_CHECK_HEADERS([mISDN/mbuffer.h],
65                         [with_misdn="yes"],
66                         [if test "x$with_misdn" != xcheck ; then
67                       AC_MSG_FAILURE(
68                         [--with-misdn was given, but test for header-file mISDN/mbuffer.h failed])
69                      fi
70                      ])
71       ])
72
73 AM_CONDITIONAL(ENABLE_MISDN, test "x$with_misdn" == "xyes" )
74
75 # check for asterisk
76 AC_ARG_WITH([asterisk],
77         [AS_HELP_STRING([--with-asterisk],
78                         [compile with built-in Asterisk channel driver @<:@default=check@:>@])
79         ],
80         [],
81         [with_asterisk="check"])
82
83 AS_IF([test "x$with_asterisk" != xno],
84       [AC_CHECK_HEADERS([asterisk/compiler.h],
85                         [with_asterisk="yes"],
86                         [if test "x$with_asterisk" != xcheck ; then
87                       AC_MSG_FAILURE(
88                         [--with-asterisk was given, but test for header-file asterisk/compiler.h failed])
89                      fi
90                      ])
91       ])
92
93 if test "x$with_asterisk" = "xyes"; then
94         dnl detect whether asterisk/indications.h defines ast_tone_zone_sound (1.6.2
95         dnl and later), ind_tone_zone_sound (1.6.0) or tone_zone_sound (1.4)
96         ast_tone_zone_sound=
97         apc_test_result=
98         ast_1_8_or_higher=
99
100         AC_CHECK_TYPE([struct ast_tone_zone_sound],
101                 [ast_tone_zone_sound=ast_tone_zone_sound], [], [
102 #include <asterisk.h>
103 #include <asterisk/linkedlists.h>
104 #include <asterisk/indications.h>])
105
106         AS_IF([test "x$ast_tone_zone_sound" = "x"],
107                 [AC_CHECK_TYPE([struct ind_tone_zone_sound],
108                         [ast_tone_zone_sound=ind_tone_zone_sound], [], [
109 #include <asterisk.h>
110 #include <asterisk/linkedlists.h>
111 #include <asterisk/indications.h>])])
112         AS_IF([test "x$ast_tone_zone_sound" = "x"],
113                 [AC_CHECK_TYPE([struct tone_zone_sound],
114                         [ast_tone_zone_sound=tone_zone_sound], [], [
115 #include <asterisk.h>
116 #include <asterisk/indications.h>])])
117
118         if test "x$ast_tone_zone_sound" = "x"; then
119                 AC_MSG_FAILURE([No ast_tone_zone_sound, confused...])
120         fi
121
122
123         AC_CHECK_TYPE([struct ast_party_caller],
124                 [apc_test_result=yes], [], [
125 #include <asterisk.h>
126 #include <asterisk/channel.h>])
127
128         if test "x$apc_test_result" = "xyes"; then
129                 ast_1_8_or_higher="-DAST_1_8_OR_HIGHER"
130         fi
131
132         AST_CFLAGS="-Dast_tone_zone_sound=$ast_tone_zone_sound $ast_1_8_or_higher"
133
134         AC_SUBST([AST_CFLAGS])
135 fi
136
137 AM_CONDITIONAL(ENABLE_ASTERISK_CHANNEL_DRIVER, test "x$with_asterisk" == "xyes" )
138
139 # check for crypto
140 AC_ARG_WITH([ssl],
141         [AS_HELP_STRING([--with-ssl],
142                         [compile with ssl support (libcrypto) @<:@default=check@:>@])
143         ],
144         [],
145         [with_ssl=check])
146 LIBCRYPTO=
147 AS_IF([test "x$with_ssl" != xno],
148       [AC_CHECK_HEADERS([openssl/rsa.h])
149        AC_CHECK_LIB([crypto], [main],
150                     [AC_SUBST([LIBCRYPTO], ["-lcrypto"])
151                      AC_DEFINE([HAVE_LIBCRYPTO], [1],
152                                [Define if you have libcrypto])
153                     ],
154                     [if test "x$with_ssl" != xcheck ; then
155                       AC_MSG_FAILURE(
156                         [--with-ssl was given, but test for libcrypto failed])
157                      fi
158                     ],
159                     -lcrypto
160                    )
161       ]
162      )
163
164 # check for gsm-bs
165 AC_ARG_WITH([gsm-bs],
166         [AS_HELP_STRING([--with-gsm-bs],
167                         [compile with OpenBSC support @<:@default=no@:>@])
168         ],
169         [],
170         [with_gsm_bs="check"])
171
172 AM_CONDITIONAL(ENABLE_GSM_BS, test "x$with_gsm_bs" == "xyes" )
173
174 # check for gsm-ms
175 AC_ARG_WITH([gsm-ms],
176         [AS_HELP_STRING([--with-gsm-ms],
177                         [compile with Osmocom-bb support @<:@default=no@:>@])
178         ],
179         [],
180         [with_gsm_ms="check"])
181
182 AM_CONDITIONAL(ENABLE_GSM_MS, test "x$with_gsm_ms" == "xyes" )
183
184 AM_CONDITIONAL(ENABLE_GSM, test "x$with_gsm_bs" == "xyes" -o "x$with_gsm_ms" == "xyes")
185
186 AS_IF([test "x$with_gsm_bs" == xyes -o "x$with_gsm_ms" == xyes],
187         [AC_MSG_CHECKING(/usr/include/gsm/gsm.h)
188         if test -e /usr/include/gsm/gsm.h; then
189                 AC_MSG_RESULT(yes)
190         else
191         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.])
192         fi
193         ])
194
195 # check for ss5
196 AC_ARG_WITH([ss5],
197         [AS_HELP_STRING([--with-ss5],
198                         [compile with CCITT No. 5 support @<:@default=no@:>@])
199         ],
200         [],
201         [with_ss5="check"])
202
203 AM_CONDITIONAL(ENABLE_SS5, test "x$with_ss5" == "xyes" )
204
205 # check for SIP
206 AC_ARG_WITH([sip],
207         [AS_HELP_STRING([--with-sip],
208                         [compile with SIP support (sofia-sip is required) @<:@default=no@:>@])
209         ],
210         [],
211         [with_sip="check"])
212
213 AM_CONDITIONAL(ENABLE_SIP, test "x$with_sip" == "xyes" )
214
215 AS_IF([test "x$with_sip" == xyes -o "x$with_sip" == xyes], [
216                 PKG_CHECK_MODULES(SOFIA, sofia-sip-ua >= 1.12)
217         ])
218
219 # Checks for libraries.
220 AC_CHECK_LIB([m], [main])
221 AC_CHECK_LIB([ncurses], [main])
222 AC_CHECK_LIB([pthread], [main])
223
224 # Checks for header files.
225 AC_HEADER_DIRENT
226 AC_HEADER_STDC
227 AC_HEADER_SYS_WAIT
228 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])
229
230 # Checks for typedefs, structures, and compiler characteristics.
231 AC_HEADER_STDBOOL
232 AC_C_CONST
233 AC_C_INLINE
234 AC_TYPE_PID_T
235 AC_HEADER_TIME
236 AC_STRUCT_TM
237
238 # Checks for library functions.
239 AC_FUNC_FORK
240 AC_PROG_GCC_TRADITIONAL
241 AC_FUNC_LSTAT
242 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
243 AC_FUNC_MALLOC
244 AC_FUNC_MEMCMP
245 AC_TYPE_SIGNAL
246 AC_FUNC_STRNLEN
247 AC_FUNC_STRTOD
248 AC_FUNC_VPRINTF
249 AC_CHECK_FUNCS([gettimeofday memmove memset mkdir socket strcasecmp strchr strerror strncasecmp strstr strtol strtoul])
250
251
252 AC_CONFIG_FILES([Makefile])
253 AC_OUTPUT
254
255
256 AS_IF([test "x$with_misdn" == xyes],[AC_MSG_NOTICE( Compiled with mISDN support )],[AC_MSG_NOTICE( Not compiled with mISDN support)])
257 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)])
258 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)])
259 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)])
260 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)])
261 AS_IF([test "x$with_sip" == xyes],[AC_MSG_NOTICE( Compiled with SIP support )],[AC_MSG_NOTICE( Not compiled with SIP support)])
262