Completed GSM mobile station support with OsmocomBB
[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.7, 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.7)
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 asterisk
55 AC_ARG_WITH([asterisk],
56         [AS_HELP_STRING([--with-asterisk],
57                         [compile with built-in Asterisk channel driver @<:@default=check@:>@])
58         ],
59         [],
60         [with_asterisk="check"])
61
62 AS_IF([test "x$with_asterisk" != xno],
63       [AC_CHECK_HEADERS([asterisk/compiler.h],
64                         [with_asterisk="yes"],
65                         [if test "x$with_asterisk" != xcheck ; then
66                       AC_MSG_FAILURE(
67                         [--with-asterisk was given, but test for header-file asterisk/compiler.h failed])
68                      fi
69                      ])
70       ])
71
72 if test "x$with_asterisk" = "xyes"; then
73         ast_tone_zone_sound=
74
75         AC_MSG_CHECKING([for struct tone_zone_sound in asterisk/indications.h])
76         tzs_test_result=no
77         AC_COMPILE_IFELSE([
78                 AC_LANG_PROGRAM(
79                         [[#include <asterisk.h>],
80                         [#include <asterisk/linkedlists.h>],
81                         [#include <asterisk/indications.h>]],
82                         [[struct tone_zone_sound * ts = NULL; (void) ts->data;]])],
83                 [tzs_test_result=yes])
84         AC_MSG_RESULT([$tzs_test_result])
85
86         if test "x$tzs_test_result" = "xyes"; then
87                 ast_tone_zone_sound=tone_zone_sound
88         fi
89
90         if test "x$ast_tone_zone_sound" = "x"; then
91                 AC_MSG_CHECKING([for struct ast_tone_zone_sound in asterisk/indications.h])
92                 tzs_test_result=no
93                 AC_COMPILE_IFELSE([
94                         AC_LANG_PROGRAM(
95                                 [[#include <asterisk.h>],
96                                 [#include <asterisk/linkedlists.h>],
97                                 [#include <asterisk/indications.h>]],
98                                 [[struct ast_tone_zone_sound * ts = NULL; (void) ts->name;]])],
99                         [tzs_test_result=yes])
100                 AC_MSG_RESULT([$tzs_test_result])
101
102                 if test "x$tzs_test_result" = "xyes"; then
103                         ast_tone_zone_sound=ast_tone_zone_sound
104                 fi
105         fi
106
107         if test "x$ast_tone_zone_sound" = "x"; then
108                 AC_MSG_FAILURE([No ast_tone_zone_sound, confused...])
109         fi
110
111         AST_CFLAGS="-Dtone_zone_sound=$ast_tone_zone_sound"
112         AC_SUBST([AST_CFLAGS])
113 fi
114
115 AM_CONDITIONAL(ENABLE_ASTERISK_CHANNEL_DRIVER, test "x$with_asterisk" == "xyes" )
116
117 # check for crypto
118 AC_ARG_WITH([ssl],
119         [AS_HELP_STRING([--with-ssl],
120                         [compile with ssl support (libcrypto) @<:@default=check@:>@])
121         ],
122         [],
123         [with_ssl=check])
124 LIBCRYPTO=
125 AS_IF([test "x$with_ssl" != xno],
126       [AC_CHECK_HEADERS([openssl/rsa.h])
127        AC_CHECK_LIB([crypto], [main],
128                     [AC_SUBST([LIBCRYPTO], ["-lcrypto"])
129                      AC_DEFINE([HAVE_LIBCRYPTO], [1],
130                                [Define if you have libcrypto])
131                     ],
132                     [if test "x$with_ssl" != xcheck ; then
133                       AC_MSG_FAILURE(
134                         [--with-ssl was given, but test for libcrypto failed])
135                      fi
136                     ],
137                     -lcrypto
138                    )
139       ]
140      )
141
142 # check for gsm-bs
143 AC_ARG_WITH([gsm-bs],
144         [AS_HELP_STRING([--with-gsm-bs],
145                         [compile with OpenBSC support @<:@default=check@:>@])
146         ],
147         [],
148         [with_gsm_bs="check"])
149
150 AS_IF([test "x$with_gsm_bs" != xno],
151       [AC_MSG_CHECKING(openbsc/include/openbsc/gsm_data.h)
152        if test -e openbsc/include/openbsc/gsm_data.h; then
153                 with_gsm_bs="yes"
154                 AC_MSG_RESULT(yes)
155        elif test "x$with_gsm_bs" != xcheck ; then
156                 AC_MSG_FAILURE([--with-gsm-bs was given, but openbsc/include/openbsc/gsm_data.h was not found! Please link OpenBSC and libosmocore source directory to LCR source directory: ln -s path_to_openbsc/openbsc/ openbsc ; ln -s patch_to_libosmocore libosmocore])
157        else
158                 AC_MSG_RESULT(no)
159        fi
160       ])
161
162 AM_CONDITIONAL(ENABLE_GSM_BS, test "x$with_gsm_bs" == "xyes" )
163
164 # check for gsm-ms
165 AC_ARG_WITH([gsm-ms],
166         [AS_HELP_STRING([--with-gsm-ms],
167                         [compile with Osmocom-bb support @<:@default=check@:>@])
168         ],
169         [],
170         [with_gsm_ms="check"])
171
172 AS_IF([test "x$with_gsm_ms" != xno],
173       [AC_MSG_CHECKING(layer23/include/osmocom/bb/common/osmocom_data.h)
174        if test -e layer23/include/osmocom/bb/common/osmocom_data.h; then
175                 with_gsm_ms="yes"
176                 AC_MSG_RESULT(yes)
177        elif test "x$with_gsm_ms" != xcheck ; then
178                 AC_MSG_FAILURE([--with-gsm-ms was given, but layer23/include/osmocom/bb/common/osmocom_data.h was not found! Please link Osmocom-BB and libosmocore source directory to LCR source directory: ln -s path_to_osmocom-bb/src/host/layer23/ layer23 ; ln -s path_to_libosmocore libosmocore])
179        else
180                 AC_MSG_RESULT(no)
181        fi
182       ])
183
184 AM_CONDITIONAL(ENABLE_GSM_MS, test "x$with_gsm_ms" == "xyes" )
185
186 AM_CONDITIONAL(ENABLE_GSM, test "x$with_gsm_bs" == "xyes" -o "x$with_gsm_ms" == "xyes")
187
188 # check for ss5
189 AC_ARG_WITH([ss5],
190         [AS_HELP_STRING([--with-ss5],
191                         [compile with CCITT No. 5 support @<:@default=no@:>@])
192         ],
193         [],
194         [with_ss5="check"])
195
196 AM_CONDITIONAL(ENABLE_SS5, test "x$with_ss5" == "xyes" )
197
198 # Checks for libraries.
199 AC_CHECK_LIB([m], [main])
200 AC_CHECK_LIB([ncurses], [main])
201 AC_CHECK_LIB([pthread], [main])
202
203 # Checks for header files.
204 AC_HEADER_DIRENT
205 AC_HEADER_STDC
206 AC_HEADER_SYS_WAIT
207 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 mISDNuser/mbuffer.h assert.h])
208
209 # Checks for typedefs, structures, and compiler characteristics.
210 AC_HEADER_STDBOOL
211 AC_C_CONST
212 AC_C_INLINE
213 AC_TYPE_PID_T
214 AC_HEADER_TIME
215 AC_STRUCT_TM
216
217 # Checks for library functions.
218 AC_FUNC_FORK
219 AC_PROG_GCC_TRADITIONAL
220 AC_FUNC_LSTAT
221 AC_FUNC_LSTAT_FOLLOWS_SLASHED_SYMLINK
222 AC_FUNC_MALLOC
223 AC_FUNC_MEMCMP
224 AC_TYPE_SIGNAL
225 AC_FUNC_STRNLEN
226 AC_FUNC_STRTOD
227 AC_FUNC_VPRINTF
228 AC_CHECK_FUNCS([gettimeofday memmove memset mkdir socket strcasecmp strchr strerror strncasecmp strstr strtol strtoul])
229
230
231 AC_CONFIG_FILES([Makefile])
232 AC_OUTPUT