blob: a1dbce5496d0d2646f1ff2266904a67bf635f8cd [file] [log] [blame]
Harald Welte2b944cf2008-12-23 21:01:25 +00001dnl Process this file with autoconf to produce a configure script
Neels Hofmeyra2ea7292017-09-04 15:17:33 +02002AC_INIT([osmo-sgsn],
Harald Weltefa13cad2010-03-23 00:09:32 +08003 m4_esyscmd([./git-version-gen .tarball-version]),
Neels Hofmeyra2ea7292017-09-04 15:17:33 +02004 [osmocom-net-gprs@lists.osmocom.org])
Harald Welte2b944cf2008-12-23 21:01:25 +00005
Neels Hofmeyr7c61f752016-10-01 00:34:31 +02006dnl *This* is the root dir, even if an install-sh exists in ../ or ../../
7AC_CONFIG_AUX_DIR([.])
8
Harald Weltefa13cad2010-03-23 00:09:32 +08009AM_INIT_AUTOMAKE([dist-bzip2])
Holger Hans Peter Freytherfee826b2012-01-06 15:16:12 +010010AC_CONFIG_TESTDIR(tests)
Harald Welte2b944cf2008-12-23 21:01:25 +000011
Holger Hans Peter Freytherc746e682009-10-27 03:34:49 +010012dnl kernel style compile messages
13m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
14
Max938cf562017-08-28 12:04:18 +020015dnl include release helper
16RELMAKE='-include osmo-release.mk'
17AC_SUBST([RELMAKE])
18
Harald Welte2b944cf2008-12-23 21:01:25 +000019dnl checks for programs
20AC_PROG_MAKE_SET
21AC_PROG_CC
22AC_PROG_INSTALL
Max72ca1342017-05-26 12:31:00 +020023LT_INIT
Harald Welte2b944cf2008-12-23 21:01:25 +000024
Neels Hofmeyredb9ce32016-10-01 00:50:25 +020025dnl check for pkg-config (explained in detail in libosmocore/configure.ac)
26AC_PATH_PROG(PKG_CONFIG_INSTALLED, pkg-config, no)
27if test "x$PKG_CONFIG_INSTALLED" = "xno"; then
28 AC_MSG_WARN([You need to install pkg-config])
29fi
30PKG_PROG_PKG_CONFIG([0.20])
31
Max0ff613c2017-01-20 13:03:03 +010032dnl check for AX_CHECK_COMPILE_FLAG
33m4_ifdef([AX_CHECK_COMPILE_FLAG], [], [
34 AC_MSG_ERROR([Please install autoconf-archive; re-run 'autoreconf -fi' for it to take effect.])
35 ])
36
Harald Welte2b944cf2008-12-23 21:01:25 +000037dnl checks for libraries
Jacob Erlbeck76fa57a2013-10-15 12:00:26 +020038AC_SEARCH_LIBS([dlopen], [dl dld], [LIBRARY_DL="$LIBS";LIBS=""])
39AC_SUBST(LIBRARY_DL)
40
Harald Welte2b944cf2008-12-23 21:01:25 +000041
Neels Hofmeyr7aef97a2016-12-08 21:28:29 +010042PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.9.5)
Harald Welte4d109ff2011-05-08 09:41:45 +020043PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.3.0)
Harald Welte4f45c9b2014-08-21 15:56:00 +020044PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl)
Harald Welte9fda1462016-05-06 23:28:52 +020045PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.9.5)
Jacob Erlbeck1a5c2462014-03-31 13:42:11 +020046PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 0.2.0)
Holger Hans Peter Freyther5b574132013-10-15 13:29:06 +020047PKG_CHECK_MODULES(LIBOSMOGB, libosmogb >= 0.6.4)
Pablo Neira Ayuso4a2f6592014-02-05 18:56:17 +010048PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 0.0.1)
Daniel Willmann59265962015-10-08 16:10:23 +020049PKG_CHECK_MODULES(LIBCRYPTO, libcrypto >= 0.9.5)
Jacob Erlbeck9fac8002014-03-13 14:25:51 +010050
Daniel Willmann58b03e32016-05-20 21:42:55 +020051# Enable/disable 3G aka IuPS + IuCS support?
52AC_ARG_ENABLE([iu], [AS_HELP_STRING([--enable-iu], [Build 3G support, aka IuPS and IuCS interfaces])],
53 [osmo_ac_iu="$enableval"],[osmo_ac_iu="no"])
54if test "x$osmo_ac_iu" = "xyes" ; then
Philipp Maierd394c6c2017-10-19 18:11:02 +020055 PKG_CHECK_MODULES(LIBOSMOSIGTRAN, libosmo-sigtran) # TODO version?
Daniel Willmann58b03e32016-05-20 21:42:55 +020056 PKG_CHECK_MODULES(LIBASN1C, libasn1c) # TODO version?
57 PKG_CHECK_MODULES(LIBOSMORANAP, libosmo-ranap) # TODO version?
Daniel Willmann58b03e32016-05-20 21:42:55 +020058 AC_DEFINE(BUILD_IU, 1, [Define if we want to build IuPS and IuCS interfaces support])
59fi
60AM_CONDITIONAL(BUILD_IU, test "x$osmo_ac_iu" = "xyes")
61AC_SUBST(osmo_ac_iu)
62
Holger Hans Peter Freyther61c586c2012-12-20 23:49:24 +010063
Sylvain Munautf4b4e8f2011-10-18 13:27:00 +020064found_libgtp=yes
Maxab654012017-09-27 15:08:17 +020065PKG_CHECK_MODULES(LIBGTP, libgtp >= 1.0.0, , found_libgtp=no)
Sylvain Munautf4b4e8f2011-10-18 13:27:00 +020066AM_CONDITIONAL(HAVE_LIBGTP, test "$found_libgtp" = yes)
Holger Hans Peter Freyther232f6212014-09-30 09:10:25 +020067AC_SUBST(found_libgtp)
Sylvain Munautf4b4e8f2011-10-18 13:27:00 +020068
Holger Hans Peter Freyther180027c2015-05-25 01:21:50 +080069found_libcares=yes
70PKG_CHECK_MODULES([LIBCARES], [libcares], [], [found_libcares=no])
71AM_CONDITIONAL(HAVE_LIBCARES, test "$found_libcares" = yes)
72AC_SUBST(found_libcares)
73
Neels Hofmeyr5c8090e2015-11-29 19:14:58 +010074found_libgtp_and_libcares=no
75if test "$found_libgtp" = "yes" -a "$found_libcares" = "yes"; then
76 found_libgtp_and_libcares=yes
77fi
78AC_SUBST(found_libgtp_and_libcares)
79
Harald Welte2b944cf2008-12-23 21:01:25 +000080dnl checks for header files
81AC_HEADER_STDC
Max24ca9182017-05-02 12:59:15 +020082
83found_pcap=yes
84AC_CHECK_HEADERS(pcap/pcap.h,,found_pcap=no)
85AM_CONDITIONAL(HAVE_PCAP, test "$found_pcap" = yes)
Harald Weltec7841cc2011-02-05 15:13:27 +010086
Harald Welteec83de52012-11-13 07:06:54 +010087found_cdk=yes
88AC_CHECK_HEADERS(cdk/cdk.h,,found_cdk=no)
89AM_CONDITIONAL(HAVE_LIBCDK, test "$found_cdk" = yes)
90
Harald Welte2b944cf2008-12-23 21:01:25 +000091
92dnl Checks for typedefs, structures and compiler characteristics
93
Neels Hofmeyr4984c492017-11-17 01:43:36 +010094AC_ARG_ENABLE(sanitize,
95 [AS_HELP_STRING(
96 [--enable-sanitize],
97 [Compile with address sanitizer enabled],
98 )],
99 [sanitize=$enableval], [sanitize="no"])
100if test x"$sanitize" = x"yes"
101then
102 CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined"
103 CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
104fi
105
Holger Freyther64026e92009-06-08 10:32:54 +0000106# The following test is taken from WebKit's webkit.m4
107saved_CFLAGS="$CFLAGS"
108CFLAGS="$CFLAGS -fvisibility=hidden "
109AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
Alexander Huemer93ae2d62011-05-24 15:16:54 +0200110AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
Holger Freyther64026e92009-06-08 10:32:54 +0000111 [ AC_MSG_RESULT([yes])
112 SYMBOL_VISIBILITY="-fvisibility=hidden"],
113 AC_MSG_RESULT([no]))
114CFLAGS="$saved_CFLAGS"
115AC_SUBST(SYMBOL_VISIBILITY)
116
Max0ff613c2017-01-20 13:03:03 +0100117AX_CHECK_COMPILE_FLAG([-Werror=implicit], [CFLAGS="$CFLAGS -Werror=implicit"])
118AX_CHECK_COMPILE_FLAG([-Werror=maybe-uninitialized], [CFLAGS="$CFLAGS -Werror=maybe-uninitialized"])
119AX_CHECK_COMPILE_FLAG([-Werror=memset-transposed-args], [CFLAGS="$CFLAGS -Werror=memset-transposed-args"])
120AX_CHECK_COMPILE_FLAG([-Werror=null-dereference], [CFLAGS="$CFLAGS -Werror=null-dereference"])
121AX_CHECK_COMPILE_FLAG([-Werror=sizeof-array-argument], [CFLAGS="$CFLAGS -Werror=sizeof-array-argument"])
122AX_CHECK_COMPILE_FLAG([-Werror=sizeof-pointer-memaccess], [CFLAGS="$CFLAGS -Werror=sizeof-pointer-memaccess"])
123
Holger Hans Peter Freyther16bdb142010-11-15 18:37:57 +0100124# Coverage build taken from WebKit's configure.in
125AC_MSG_CHECKING([whether to enable code coverage support])
126AC_ARG_ENABLE(coverage,
127 AC_HELP_STRING([--enable-coverage],
128 [enable code coverage support [default=no]]),
129 [],[enable_coverage="no"])
130AC_MSG_RESULT([$enable_coverage])
131if test "$enable_coverage" = "yes"; then
132 COVERAGE_CFLAGS="-ftest-coverage -fprofile-arcs"
133 COVERAGE_LDFLAGS="-ftest-coverage -fprofile-arcs"
134 AC_SUBST([COVERAGE_CFLAGS])
135 AC_SUBST([COVERAGE_LDFLAGS])
136fi
137
Harald Welteeaf4a522012-04-08 16:59:24 +0200138AC_DEFUN([CHECK_TM_INCLUDES_TM_GMTOFF], [
139 AC_CACHE_CHECK(
140 [whether struct tm has tm_gmtoff member],
141 osmo_cv_tm_includes_tm_gmtoff,
142 [AC_LINK_IFELSE([
143 AC_LANG_PROGRAM([
144 #include <time.h>
145 ], [
146 time_t t = time(NULL);
147 struct tm* lt = localtime(&t);
148 int off = lt->tm_gmtoff;
149 ])
150 ],
151 osmo_cv_tm_includes_tm_gmtoff=yes,
152 osmo_cv_tm_includes_tm_gmtoff=no
153 )]
154 )
155 if test "x$osmo_cv_tm_includes_tm_gmtoff" = xyes; then
156 AC_DEFINE(HAVE_TM_GMTOFF_IN_TM, 1,
157 [Define if struct tm has tm_gmtoff member.])
158 fi
159])
160
161CHECK_TM_INCLUDES_TM_GMTOFF
Holger Freyther64026e92009-06-08 10:32:54 +0000162
Katerina Barone-Adesiad5fb002013-04-05 17:36:09 +0200163AC_ARG_ENABLE([vty_tests],
164 AC_HELP_STRING([--enable-vty-tests],
Holger Hans Peter Freyther8fa08b02014-08-22 00:29:04 +0200165 [Include the VTY/CTRL tests in make check (deprecated)
166 [default=no]]),
167 [enable_ext_tests="$enableval"],[enable_ext_tests="no"])
Pablo Neira Ayuso7194f632014-09-01 09:34:07 +0200168AC_ARG_ENABLE([external_tests],
Holger Hans Peter Freyther8fa08b02014-08-22 00:29:04 +0200169 AC_HELP_STRING([--enable-external-tests],
170 [Include the VTY/CTRL tests in make check [default=no]]),
171 [enable_ext_tests="$enableval"],[enable_ext_tests="no"])
172if test "x$enable_ext_tests" = "xyes" ; then
Pau Espin Pedrol266b61a2017-11-28 20:08:17 +0100173 AC_CHECK_PROG(PYTHON2_AVAIL,python2,yes)
174 if test "x$PYTHON2_AVAIL" != "xyes" ; then
175 AC_MSG_ERROR([Please install python2 to run the VTY/CTRL tests.])
176 fi
Holger Hans Peter Freyther8fa08b02014-08-22 00:29:04 +0200177 AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmotestvty.py,yes)
178 if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then
Neels Hofmeyr684caa42017-07-20 23:01:45 +0200179 AC_MSG_ERROR([Please install git://osmocom.org/python/osmo-python-tests to run the VTY/CTRL tests.])
Katerina Barone-Adesiad5fb002013-04-05 17:36:09 +0200180 fi
181fi
Holger Hans Peter Freyther8fa08b02014-08-22 00:29:04 +0200182AC_MSG_CHECKING([whether to enable VTY/CTRL tests])
183AC_MSG_RESULT([$enable_ext_tests])
184AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
Katerina Barone-Adesiad5fb002013-04-05 17:36:09 +0200185
Holger Freyther64026e92009-06-08 10:32:54 +0000186dnl Generate the output
187AM_CONFIG_HEADER(bscconfig.h)
188
Holger Freyther1bad6012008-12-27 09:42:59 +0000189AC_OUTPUT(
Neels Hofmeyra759e3a2017-09-04 15:25:43 +0200190 osmo-sgsn.pc
Holger Freyther1bad6012008-12-27 09:42:59 +0000191 include/Makefile
Neels Hofmeyr4b4c5862017-09-04 15:13:25 +0200192 include/osmocom/Makefile
193 include/osmocom/sgsn/Makefile
Holger Freyther1bad6012008-12-27 09:42:59 +0000194 src/Makefile
Harald Welte4f272cc2011-03-03 23:29:05 +0100195 src/gprs/Makefile
Holger Freyther1bad6012008-12-27 09:42:59 +0000196 tests/Makefile
Holger Hans Peter Freyther34abf212012-01-09 22:53:04 +0100197 tests/atlocal
Holger Hans Peter Freyther6721a082011-06-23 17:53:27 -0400198 tests/gprs/Makefile
Jacob Erlbeck76fa57a2013-10-15 12:00:26 +0200199 tests/gbproxy/Makefile
Holger Hans Peter Freyther232f6212014-09-30 09:10:25 +0200200 tests/sgsn/Makefile
Neels Hofmeyr2989ff82015-10-12 11:57:35 +0200201 tests/oap/Makefile
Neels Hofmeyr9f796642015-09-24 17:32:30 +0200202 tests/gtphub/Makefile
Philippfcb979a2016-08-10 12:14:57 +0200203 tests/xid/Makefile
Philipp59971b82016-08-10 12:08:03 +0200204 tests/sndcp_xid/Makefile
Philipp49482092016-08-26 16:58:41 +0200205 tests/slhc/Makefile
Philipp8a3fe602016-09-02 13:32:38 +0200206 tests/v42bis/Makefile
Harald Welte2d6f49d2011-05-11 22:11:28 +0200207 doc/Makefile
208 doc/examples/Makefile
Neels Hofmeyr69cf4612017-07-20 17:57:37 +0200209 contrib/Makefile
Holger Freyther1bad6012008-12-27 09:42:59 +0000210 Makefile)