blob: f1a4ed4808ac14808cbbb925e57bfbae907df77b [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
Pau Espin Pedrol570c4072020-08-18 13:45:09 +020025dnl patching ${archive_cmds} to affect generation of file "libtool" to fix linking with clang
Eric9a69cf32020-04-11 01:04:28 +020026AS_CASE(["$LD"],[*clang*],
27 [AS_CASE(["${host_os}"],
28 [*linux*],[archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'])])
29
Neels Hofmeyredb9ce32016-10-01 00:50:25 +020030dnl check for pkg-config (explained in detail in libosmocore/configure.ac)
31AC_PATH_PROG(PKG_CONFIG_INSTALLED, pkg-config, no)
32if test "x$PKG_CONFIG_INSTALLED" = "xno"; then
33 AC_MSG_WARN([You need to install pkg-config])
34fi
35PKG_PROG_PKG_CONFIG([0.20])
36
Max0ff613c2017-01-20 13:03:03 +010037dnl check for AX_CHECK_COMPILE_FLAG
38m4_ifdef([AX_CHECK_COMPILE_FLAG], [], [
39 AC_MSG_ERROR([Please install autoconf-archive; re-run 'autoreconf -fi' for it to take effect.])
40 ])
41
Alexander Couzens78e56f12021-01-01 17:04:23 +010042dnl use a defined standard across all builds and don't depend on compiler default
43CFLAGS="$CFLAGS -std=gnu11"
44
Harald Welte2b944cf2008-12-23 21:01:25 +000045dnl checks for libraries
Jacob Erlbeck76fa57a2013-10-15 12:00:26 +020046AC_SEARCH_LIBS([dlopen], [dl dld], [LIBRARY_DL="$LIBS";LIBS=""])
47AC_SUBST(LIBRARY_DL)
48
Erica9a289f2020-04-11 01:04:08 +020049AC_SEARCH_LIBS([dlsym], [dl dld], [LIBRARY_DLSYM="$LIBS";LIBS=""])
50AC_SUBST(LIBRARY_DLSYM)
51
Harald Welte2b944cf2008-12-23 21:01:25 +000052
Pau Espin Pedrole77e5bc2020-08-18 13:50:00 +020053PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.4.0)
54PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.4.0)
55PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl >= 1.4.0)
56PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.4.0)
57PKG_CHECK_MODULES(LIBOSMOGB, libosmogb >= 1.4.0)
Harald Weltee250eaa2019-01-23 18:32:41 +010058PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 0.6.0)
Harald Weltee250eaa2019-01-23 18:32:41 +010059PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 0.4.0)
60PKG_CHECK_MODULES(LIBOSMOGSUPCLIENT, libosmo-gsup-client >= 1.0.0)
Jacob Erlbeck9fac8002014-03-13 14:25:51 +010061
Daniel Willmann58b03e32016-05-20 21:42:55 +020062# Enable/disable 3G aka IuPS + IuCS support?
63AC_ARG_ENABLE([iu], [AS_HELP_STRING([--enable-iu], [Build 3G support, aka IuPS and IuCS interfaces])],
64 [osmo_ac_iu="$enableval"],[osmo_ac_iu="no"])
65if test "x$osmo_ac_iu" = "xyes" ; then
Harald Weltee250eaa2019-01-23 18:32:41 +010066 PKG_CHECK_MODULES(LIBOSMOSIGTRAN, libosmo-sigtran >= 1.0.0)
Pau Espin Pedrol54936e92018-05-03 19:01:44 +020067 PKG_CHECK_MODULES(LIBASN1C, libasn1c >= 0.9.30)
Pau Espin Pedrol379e75a2020-01-03 19:17:56 +010068 PKG_CHECK_MODULES(LIBOSMORANAP, libosmo-ranap >= 0.6.0)
Daniel Willmann58b03e32016-05-20 21:42:55 +020069 AC_DEFINE(BUILD_IU, 1, [Define if we want to build IuPS and IuCS interfaces support])
70fi
71AM_CONDITIONAL(BUILD_IU, test "x$osmo_ac_iu" = "xyes")
72AC_SUBST(osmo_ac_iu)
73
Holger Hans Peter Freyther61c586c2012-12-20 23:49:24 +010074
Pau Espin Pedrol379e75a2020-01-03 19:17:56 +010075PKG_CHECK_MODULES(LIBGTP, libgtp >= 1.5.0)
Alexander Couzens79663b32018-01-30 15:59:40 +010076PKG_CHECK_MODULES(LIBCARES, libcares)
Neels Hofmeyr5c8090e2015-11-29 19:14:58 +010077
Harald Welte2b944cf2008-12-23 21:01:25 +000078dnl checks for header files
79AC_HEADER_STDC
Max24ca9182017-05-02 12:59:15 +020080
Harald Welte2b944cf2008-12-23 21:01:25 +000081dnl Checks for typedefs, structures and compiler characteristics
82
Neels Hofmeyr4984c492017-11-17 01:43:36 +010083AC_ARG_ENABLE(sanitize,
84 [AS_HELP_STRING(
85 [--enable-sanitize],
86 [Compile with address sanitizer enabled],
87 )],
88 [sanitize=$enableval], [sanitize="no"])
89if test x"$sanitize" = x"yes"
90then
91 CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined"
92 CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
93fi
94
Neels Hofmeyrf1474f52018-03-05 20:44:29 +010095AC_ARG_ENABLE(werror,
96 [AS_HELP_STRING(
97 [--enable-werror],
98 [Turn all compiler warnings into errors, with exceptions:
99 a) deprecation (allow upstream to mark deprecation without breaking builds);
100 b) "#warning" pragmas (allow to remind ourselves of errors without breaking builds)
101 ]
102 )],
103 [werror=$enableval], [werror="no"])
104if test x"$werror" = x"yes"
105then
106 WERROR_FLAGS="-Werror"
107 WERROR_FLAGS+=" -Wno-error=deprecated -Wno-error=deprecated-declarations"
108 WERROR_FLAGS+=" -Wno-error=cpp" # "#warning"
109 CFLAGS="$CFLAGS $WERROR_FLAGS"
110 CPPFLAGS="$CPPFLAGS $WERROR_FLAGS"
111fi
112
Holger Freyther64026e92009-06-08 10:32:54 +0000113# The following test is taken from WebKit's webkit.m4
114saved_CFLAGS="$CFLAGS"
115CFLAGS="$CFLAGS -fvisibility=hidden "
116AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
Alexander Huemer93ae2d62011-05-24 15:16:54 +0200117AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
Holger Freyther64026e92009-06-08 10:32:54 +0000118 [ AC_MSG_RESULT([yes])
119 SYMBOL_VISIBILITY="-fvisibility=hidden"],
120 AC_MSG_RESULT([no]))
121CFLAGS="$saved_CFLAGS"
122AC_SUBST(SYMBOL_VISIBILITY)
123
Daniel Willmann3696dce2020-12-02 16:08:02 +0100124CPPFLAGS="$CPPFLAGS -Wall -Wno-trigraphs"
125CFLAGS="$CFLAGS -Wall -Wno-trigraphs"
Pau Espin Pedrolcec01d32018-01-07 18:24:34 +0100126
Max0ff613c2017-01-20 13:03:03 +0100127AX_CHECK_COMPILE_FLAG([-Werror=implicit], [CFLAGS="$CFLAGS -Werror=implicit"])
128AX_CHECK_COMPILE_FLAG([-Werror=maybe-uninitialized], [CFLAGS="$CFLAGS -Werror=maybe-uninitialized"])
129AX_CHECK_COMPILE_FLAG([-Werror=memset-transposed-args], [CFLAGS="$CFLAGS -Werror=memset-transposed-args"])
Eric Wildd855b302019-07-19 00:48:50 +0200130AX_CHECK_COMPILE_FLAG([-Wnull-dereference], [CFLAGS="$CFLAGS -Wnull-dereference"])
Max0ff613c2017-01-20 13:03:03 +0100131AX_CHECK_COMPILE_FLAG([-Werror=sizeof-array-argument], [CFLAGS="$CFLAGS -Werror=sizeof-array-argument"])
132AX_CHECK_COMPILE_FLAG([-Werror=sizeof-pointer-memaccess], [CFLAGS="$CFLAGS -Werror=sizeof-pointer-memaccess"])
133
Holger Hans Peter Freyther16bdb142010-11-15 18:37:57 +0100134# Coverage build taken from WebKit's configure.in
135AC_MSG_CHECKING([whether to enable code coverage support])
136AC_ARG_ENABLE(coverage,
137 AC_HELP_STRING([--enable-coverage],
138 [enable code coverage support [default=no]]),
139 [],[enable_coverage="no"])
140AC_MSG_RESULT([$enable_coverage])
141if test "$enable_coverage" = "yes"; then
142 COVERAGE_CFLAGS="-ftest-coverage -fprofile-arcs"
143 COVERAGE_LDFLAGS="-ftest-coverage -fprofile-arcs"
144 AC_SUBST([COVERAGE_CFLAGS])
145 AC_SUBST([COVERAGE_LDFLAGS])
146fi
147
Harald Welteeaf4a522012-04-08 16:59:24 +0200148AC_DEFUN([CHECK_TM_INCLUDES_TM_GMTOFF], [
149 AC_CACHE_CHECK(
150 [whether struct tm has tm_gmtoff member],
151 osmo_cv_tm_includes_tm_gmtoff,
152 [AC_LINK_IFELSE([
153 AC_LANG_PROGRAM([
154 #include <time.h>
155 ], [
156 time_t t = time(NULL);
157 struct tm* lt = localtime(&t);
158 int off = lt->tm_gmtoff;
159 ])
160 ],
161 osmo_cv_tm_includes_tm_gmtoff=yes,
162 osmo_cv_tm_includes_tm_gmtoff=no
163 )]
164 )
165 if test "x$osmo_cv_tm_includes_tm_gmtoff" = xyes; then
166 AC_DEFINE(HAVE_TM_GMTOFF_IN_TM, 1,
167 [Define if struct tm has tm_gmtoff member.])
168 fi
169])
170
171CHECK_TM_INCLUDES_TM_GMTOFF
Holger Freyther64026e92009-06-08 10:32:54 +0000172
Pablo Neira Ayuso7194f632014-09-01 09:34:07 +0200173AC_ARG_ENABLE([external_tests],
Holger Hans Peter Freyther8fa08b02014-08-22 00:29:04 +0200174 AC_HELP_STRING([--enable-external-tests],
175 [Include the VTY/CTRL tests in make check [default=no]]),
176 [enable_ext_tests="$enableval"],[enable_ext_tests="no"])
177if test "x$enable_ext_tests" = "xyes" ; then
Daniel Willmann45cf0d12020-11-06 15:25:59 +0100178 AC_CHECK_PROG(PYTHON3_AVAIL,python3,yes)
179 if test "x$PYTHON3_AVAIL" != "xyes" ; then
180 AC_MSG_ERROR([Please install python3 to run the VTY/CTRL tests.])
Pau Espin Pedrol266b61a2017-11-28 20:08:17 +0100181 fi
Holger Hans Peter Freyther8fa08b02014-08-22 00:29:04 +0200182 AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmotestvty.py,yes)
183 if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then
Neels Hofmeyr684caa42017-07-20 23:01:45 +0200184 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 +0200185 fi
186fi
Holger Hans Peter Freyther8fa08b02014-08-22 00:29:04 +0200187AC_MSG_CHECKING([whether to enable VTY/CTRL tests])
188AC_MSG_RESULT([$enable_ext_tests])
189AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
Katerina Barone-Adesiad5fb002013-04-05 17:36:09 +0200190
Oliver Smith4a1d8052018-11-14 10:47:01 +0100191# Generate manuals
192AC_ARG_ENABLE(manuals,
193 [AS_HELP_STRING(
194 [--enable-manuals],
195 [Generate manual PDFs [default=no]],
196 )],
197 [osmo_ac_build_manuals=$enableval], [osmo_ac_build_manuals="no"])
198AM_CONDITIONAL([BUILD_MANUALS], [test x"$osmo_ac_build_manuals" = x"yes"])
199AC_ARG_VAR(OSMO_GSM_MANUALS_DIR, [path to common osmo-gsm-manuals files, overriding pkg-config and "../osmo-gsm-manuals"
200 fallback])
201if test x"$osmo_ac_build_manuals" = x"yes"
202then
203 # Find OSMO_GSM_MANUALS_DIR (env, pkg-conf, fallback)
204 if test -n "$OSMO_GSM_MANUALS_DIR"; then
205 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from env)"
206 else
207 OSMO_GSM_MANUALS_DIR="$($PKG_CONFIG osmo-gsm-manuals --variable=osmogsmmanualsdir 2>/dev/null)"
208 if test -n "$OSMO_GSM_MANUALS_DIR"; then
209 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from pkg-conf)"
210 else
211 OSMO_GSM_MANUALS_DIR="../osmo-gsm-manuals"
212 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (fallback)"
213 fi
214 fi
215 if ! test -d "$OSMO_GSM_MANUALS_DIR"; then
216 AC_MSG_ERROR("OSMO_GSM_MANUALS_DIR does not exist! Install osmo-gsm-manuals or set OSMO_GSM_MANUALS_DIR.")
217 fi
218
219 # Find and run check-depends
220 CHECK_DEPENDS="$OSMO_GSM_MANUALS_DIR/check-depends.sh"
221 if ! test -x "$CHECK_DEPENDS"; then
222 CHECK_DEPENDS="osmo-gsm-manuals-check-depends"
223 fi
224 if ! $CHECK_DEPENDS; then
225 AC_MSG_ERROR("missing dependencies for --enable-manuals")
226 fi
227
228 # Put in Makefile with absolute path
229 OSMO_GSM_MANUALS_DIR="$(realpath "$OSMO_GSM_MANUALS_DIR")"
230 AC_SUBST([OSMO_GSM_MANUALS_DIR])
231fi
232
Pau Espin Pedrol6a127332018-09-10 12:40:56 +0200233# https://www.freedesktop.org/software/systemd/man/daemon.html
234AC_ARG_WITH([systemdsystemunitdir],
235 [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
236 [with_systemdsystemunitdir=auto])
237AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
238 def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
239
240 AS_IF([test "x$def_systemdsystemunitdir" = "x"],
241 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
242 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
243 with_systemdsystemunitdir=no],
244 [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
245AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
246 [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
247AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
248
Neels Hofmeyrf1474f52018-03-05 20:44:29 +0100249AC_MSG_RESULT([CFLAGS="$CFLAGS"])
250AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
251
Holger Freyther64026e92009-06-08 10:32:54 +0000252dnl Generate the output
253AM_CONFIG_HEADER(bscconfig.h)
254
Holger Freyther1bad6012008-12-27 09:42:59 +0000255AC_OUTPUT(
Holger Freyther1bad6012008-12-27 09:42:59 +0000256 include/Makefile
Neels Hofmeyr4b4c5862017-09-04 15:13:25 +0200257 include/osmocom/Makefile
258 include/osmocom/sgsn/Makefile
Holger Freyther1bad6012008-12-27 09:42:59 +0000259 src/Makefile
Harald Welte4f272cc2011-03-03 23:29:05 +0100260 src/gprs/Makefile
Pau Espin Pedrola3646fb2019-08-30 20:47:02 +0200261 src/sgsn/Makefile
Pau Espin Pedrol1ddefb12019-08-30 19:48:34 +0200262 src/gbproxy/Makefile
Pau Espin Pedrol13fdd512019-08-30 19:50:48 +0200263 src/gtphub/Makefile
Holger Freyther1bad6012008-12-27 09:42:59 +0000264 tests/Makefile
Holger Hans Peter Freyther34abf212012-01-09 22:53:04 +0100265 tests/atlocal
Holger Hans Peter Freyther6721a082011-06-23 17:53:27 -0400266 tests/gprs/Makefile
Holger Hans Peter Freyther232f6212014-09-30 09:10:25 +0200267 tests/sgsn/Makefile
Neels Hofmeyr9f796642015-09-24 17:32:30 +0200268 tests/gtphub/Makefile
Philippfcb979a2016-08-10 12:14:57 +0200269 tests/xid/Makefile
Philipp59971b82016-08-10 12:08:03 +0200270 tests/sndcp_xid/Makefile
Philipp49482092016-08-26 16:58:41 +0200271 tests/slhc/Makefile
Philipp8a3fe602016-09-02 13:32:38 +0200272 tests/v42bis/Makefile
Harald Welte2d6f49d2011-05-11 22:11:28 +0200273 doc/Makefile
274 doc/examples/Makefile
Oliver Smith4a1d8052018-11-14 10:47:01 +0100275 doc/manuals/Makefile
Pau Espin Pedrol6a127332018-09-10 12:40:56 +0200276 contrib/Makefile
277 contrib/systemd/Makefile
Oliver Smitha40ccf62020-05-14 11:53:18 +0200278 contrib/osmo-sgsn.spec
Holger Freyther1bad6012008-12-27 09:42:59 +0000279 Makefile)