blob: 0e4ff94cd9492f7239b048ce2d19c8a4e2a7435a [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
Pau Espin Pedrol54936e92018-05-03 19:01:44 +020042PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.11.0)
43PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.11.0)
44PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl >= 0.11.0)
45PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.11.0)
46PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 0.5.0)
47PKG_CHECK_MODULES(LIBOSMOGB, libosmogb >= 0.11.0)
48PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 0.2.0)
Harald Welted8f89452018-09-16 07:53:41 +020049PKG_CHECK_MODULES(LIBOSMOGSUPCLIENT, libosmo-gsup-client >= 0.2.1)
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
Pau Espin Pedrol54936e92018-05-03 19:01:44 +020055 PKG_CHECK_MODULES(LIBOSMOSIGTRAN, libosmo-sigtran >= 0.9.0)
56 PKG_CHECK_MODULES(LIBASN1C, libasn1c >= 0.9.30)
57 PKG_CHECK_MODULES(LIBOSMORANAP, libosmo-ranap >= 0.3.0)
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
Pau Espin Pedrol54936e92018-05-03 19:01:44 +020064PKG_CHECK_MODULES(LIBGTP, libgtp >= 1.2.0)
Alexander Couzens79663b32018-01-30 15:59:40 +010065PKG_CHECK_MODULES(LIBCARES, libcares)
Neels Hofmeyr5c8090e2015-11-29 19:14:58 +010066
Harald Welte2b944cf2008-12-23 21:01:25 +000067dnl checks for header files
68AC_HEADER_STDC
Max24ca9182017-05-02 12:59:15 +020069
Harald Welte2b944cf2008-12-23 21:01:25 +000070dnl Checks for typedefs, structures and compiler characteristics
71
Neels Hofmeyr4984c492017-11-17 01:43:36 +010072AC_ARG_ENABLE(sanitize,
73 [AS_HELP_STRING(
74 [--enable-sanitize],
75 [Compile with address sanitizer enabled],
76 )],
77 [sanitize=$enableval], [sanitize="no"])
78if test x"$sanitize" = x"yes"
79then
80 CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined"
81 CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
82fi
83
Neels Hofmeyrf1474f52018-03-05 20:44:29 +010084AC_ARG_ENABLE(werror,
85 [AS_HELP_STRING(
86 [--enable-werror],
87 [Turn all compiler warnings into errors, with exceptions:
88 a) deprecation (allow upstream to mark deprecation without breaking builds);
89 b) "#warning" pragmas (allow to remind ourselves of errors without breaking builds)
90 ]
91 )],
92 [werror=$enableval], [werror="no"])
93if test x"$werror" = x"yes"
94then
95 WERROR_FLAGS="-Werror"
96 WERROR_FLAGS+=" -Wno-error=deprecated -Wno-error=deprecated-declarations"
97 WERROR_FLAGS+=" -Wno-error=cpp" # "#warning"
98 CFLAGS="$CFLAGS $WERROR_FLAGS"
99 CPPFLAGS="$CPPFLAGS $WERROR_FLAGS"
100fi
101
Holger Freyther64026e92009-06-08 10:32:54 +0000102# The following test is taken from WebKit's webkit.m4
103saved_CFLAGS="$CFLAGS"
104CFLAGS="$CFLAGS -fvisibility=hidden "
105AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
Alexander Huemer93ae2d62011-05-24 15:16:54 +0200106AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
Holger Freyther64026e92009-06-08 10:32:54 +0000107 [ AC_MSG_RESULT([yes])
108 SYMBOL_VISIBILITY="-fvisibility=hidden"],
109 AC_MSG_RESULT([no]))
110CFLAGS="$saved_CFLAGS"
111AC_SUBST(SYMBOL_VISIBILITY)
112
Pau Espin Pedrolcec01d32018-01-07 18:24:34 +0100113CPPFLAGS="$CPPFLAGS -Wall"
114CFLAGS="$CFLAGS -Wall"
115
Max0ff613c2017-01-20 13:03:03 +0100116AX_CHECK_COMPILE_FLAG([-Werror=implicit], [CFLAGS="$CFLAGS -Werror=implicit"])
117AX_CHECK_COMPILE_FLAG([-Werror=maybe-uninitialized], [CFLAGS="$CFLAGS -Werror=maybe-uninitialized"])
118AX_CHECK_COMPILE_FLAG([-Werror=memset-transposed-args], [CFLAGS="$CFLAGS -Werror=memset-transposed-args"])
119AX_CHECK_COMPILE_FLAG([-Werror=null-dereference], [CFLAGS="$CFLAGS -Werror=null-dereference"])
120AX_CHECK_COMPILE_FLAG([-Werror=sizeof-array-argument], [CFLAGS="$CFLAGS -Werror=sizeof-array-argument"])
121AX_CHECK_COMPILE_FLAG([-Werror=sizeof-pointer-memaccess], [CFLAGS="$CFLAGS -Werror=sizeof-pointer-memaccess"])
122
Holger Hans Peter Freyther16bdb142010-11-15 18:37:57 +0100123# Coverage build taken from WebKit's configure.in
124AC_MSG_CHECKING([whether to enable code coverage support])
125AC_ARG_ENABLE(coverage,
126 AC_HELP_STRING([--enable-coverage],
127 [enable code coverage support [default=no]]),
128 [],[enable_coverage="no"])
129AC_MSG_RESULT([$enable_coverage])
130if test "$enable_coverage" = "yes"; then
131 COVERAGE_CFLAGS="-ftest-coverage -fprofile-arcs"
132 COVERAGE_LDFLAGS="-ftest-coverage -fprofile-arcs"
133 AC_SUBST([COVERAGE_CFLAGS])
134 AC_SUBST([COVERAGE_LDFLAGS])
135fi
136
Harald Welteeaf4a522012-04-08 16:59:24 +0200137AC_DEFUN([CHECK_TM_INCLUDES_TM_GMTOFF], [
138 AC_CACHE_CHECK(
139 [whether struct tm has tm_gmtoff member],
140 osmo_cv_tm_includes_tm_gmtoff,
141 [AC_LINK_IFELSE([
142 AC_LANG_PROGRAM([
143 #include <time.h>
144 ], [
145 time_t t = time(NULL);
146 struct tm* lt = localtime(&t);
147 int off = lt->tm_gmtoff;
148 ])
149 ],
150 osmo_cv_tm_includes_tm_gmtoff=yes,
151 osmo_cv_tm_includes_tm_gmtoff=no
152 )]
153 )
154 if test "x$osmo_cv_tm_includes_tm_gmtoff" = xyes; then
155 AC_DEFINE(HAVE_TM_GMTOFF_IN_TM, 1,
156 [Define if struct tm has tm_gmtoff member.])
157 fi
158])
159
160CHECK_TM_INCLUDES_TM_GMTOFF
Holger Freyther64026e92009-06-08 10:32:54 +0000161
Pablo Neira Ayuso7194f632014-09-01 09:34:07 +0200162AC_ARG_ENABLE([external_tests],
Holger Hans Peter Freyther8fa08b02014-08-22 00:29:04 +0200163 AC_HELP_STRING([--enable-external-tests],
164 [Include the VTY/CTRL tests in make check [default=no]]),
165 [enable_ext_tests="$enableval"],[enable_ext_tests="no"])
166if test "x$enable_ext_tests" = "xyes" ; then
Pau Espin Pedrol266b61a2017-11-28 20:08:17 +0100167 AC_CHECK_PROG(PYTHON2_AVAIL,python2,yes)
168 if test "x$PYTHON2_AVAIL" != "xyes" ; then
169 AC_MSG_ERROR([Please install python2 to run the VTY/CTRL tests.])
170 fi
Holger Hans Peter Freyther8fa08b02014-08-22 00:29:04 +0200171 AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmotestvty.py,yes)
172 if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then
Neels Hofmeyr684caa42017-07-20 23:01:45 +0200173 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 +0200174 fi
175fi
Holger Hans Peter Freyther8fa08b02014-08-22 00:29:04 +0200176AC_MSG_CHECKING([whether to enable VTY/CTRL tests])
177AC_MSG_RESULT([$enable_ext_tests])
178AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
Katerina Barone-Adesiad5fb002013-04-05 17:36:09 +0200179
Pau Espin Pedrol6a127332018-09-10 12:40:56 +0200180# https://www.freedesktop.org/software/systemd/man/daemon.html
181AC_ARG_WITH([systemdsystemunitdir],
182 [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
183 [with_systemdsystemunitdir=auto])
184AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
185 def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
186
187 AS_IF([test "x$def_systemdsystemunitdir" = "x"],
188 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
189 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
190 with_systemdsystemunitdir=no],
191 [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
192AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
193 [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
194AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
195
Neels Hofmeyrf1474f52018-03-05 20:44:29 +0100196AC_MSG_RESULT([CFLAGS="$CFLAGS"])
197AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
198
Holger Freyther64026e92009-06-08 10:32:54 +0000199dnl Generate the output
200AM_CONFIG_HEADER(bscconfig.h)
201
Holger Freyther1bad6012008-12-27 09:42:59 +0000202AC_OUTPUT(
Neels Hofmeyra759e3a2017-09-04 15:25:43 +0200203 osmo-sgsn.pc
Holger Freyther1bad6012008-12-27 09:42:59 +0000204 include/Makefile
Neels Hofmeyr4b4c5862017-09-04 15:13:25 +0200205 include/osmocom/Makefile
206 include/osmocom/sgsn/Makefile
Holger Freyther1bad6012008-12-27 09:42:59 +0000207 src/Makefile
Harald Welte4f272cc2011-03-03 23:29:05 +0100208 src/gprs/Makefile
Holger Freyther1bad6012008-12-27 09:42:59 +0000209 tests/Makefile
Holger Hans Peter Freyther34abf212012-01-09 22:53:04 +0100210 tests/atlocal
Holger Hans Peter Freyther6721a082011-06-23 17:53:27 -0400211 tests/gprs/Makefile
Jacob Erlbeck76fa57a2013-10-15 12:00:26 +0200212 tests/gbproxy/Makefile
Holger Hans Peter Freyther232f6212014-09-30 09:10:25 +0200213 tests/sgsn/Makefile
Neels Hofmeyr9f796642015-09-24 17:32:30 +0200214 tests/gtphub/Makefile
Philippfcb979a2016-08-10 12:14:57 +0200215 tests/xid/Makefile
Philipp59971b82016-08-10 12:08:03 +0200216 tests/sndcp_xid/Makefile
Philipp49482092016-08-26 16:58:41 +0200217 tests/slhc/Makefile
Philipp8a3fe602016-09-02 13:32:38 +0200218 tests/v42bis/Makefile
Harald Welte2d6f49d2011-05-11 22:11:28 +0200219 doc/Makefile
220 doc/examples/Makefile
Pau Espin Pedrol6a127332018-09-10 12:40:56 +0200221 contrib/Makefile
222 contrib/systemd/Makefile
Holger Freyther1bad6012008-12-27 09:42:59 +0000223 Makefile)