blob: b996e87b0d62f42ddef5b470044276782957b90a [file] [log] [blame]
Harald Weltede729a12008-12-23 21:01:25 +00001dnl Process this file with autoconf to produce a configure script
Neels Hofmeyre9920f22017-07-10 15:07:22 +02002AC_INIT([osmo-mgw],
Harald Welte5a29c7f2010-03-23 00:09:32 +08003 m4_esyscmd([./git-version-gen .tarball-version]),
Holger Hans Peter Freyther47d8f022014-05-15 12:26:16 +02004 [openbsc@lists.osmocom.org])
Harald Weltede729a12008-12-23 21:01:25 +00005
Neels Hofmeyrb8103122016-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 Welte5a29c7f2010-03-23 00:09:32 +08009AM_INIT_AUTOMAKE([dist-bzip2])
Holger Hans Peter Freyther6c882172012-01-06 15:16:12 +010010AC_CONFIG_TESTDIR(tests)
Harald Weltede729a12008-12-23 21:01:25 +000011
Oliver Smith9fec3912021-01-27 17:51:27 +010012CFLAGS="$CFLAGS -std=gnu11"
13
Holger Hans Peter Freyther1f59ac42009-10-27 03:34:49 +010014dnl kernel style compile messages
15m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
16
Max58cfd252017-08-28 12:04:18 +020017dnl include release helper
18RELMAKE='-include osmo-release.mk'
19AC_SUBST([RELMAKE])
20
Harald Weltede729a12008-12-23 21:01:25 +000021dnl checks for programs
22AC_PROG_MAKE_SET
23AC_PROG_CC
24AC_PROG_INSTALL
Maxeab5f592017-05-26 12:31:00 +020025LT_INIT
Harald Weltede729a12008-12-23 21:01:25 +000026
Ericeebbf2b2020-04-11 00:53:38 +020027dnl patching ${archive_cmds} to affect generation of file "libtool" to fix linking with clang
28AS_CASE(["$LD"],[*clang*],
29 [AS_CASE(["${host_os}"],
30 [*linux*],[archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'])])
31
Neels Hofmeyra8f91df2016-10-01 00:50:25 +020032dnl check for pkg-config (explained in detail in libosmocore/configure.ac)
33AC_PATH_PROG(PKG_CONFIG_INSTALLED, pkg-config, no)
34if test "x$PKG_CONFIG_INSTALLED" = "xno"; then
35 AC_MSG_WARN([You need to install pkg-config])
36fi
37PKG_PROG_PKG_CONFIG([0.20])
38
Max34f01262017-01-20 13:03:03 +010039dnl check for AX_CHECK_COMPILE_FLAG
40m4_ifdef([AX_CHECK_COMPILE_FLAG], [], [
41 AC_MSG_ERROR([Please install autoconf-archive; re-run 'autoreconf -fi' for it to take effect.])
42 ])
43
Harald Weltede729a12008-12-23 21:01:25 +000044dnl checks for libraries
Jacob Erlbeck51a869c2013-10-15 12:00:26 +020045AC_SEARCH_LIBS([dlopen], [dl dld], [LIBRARY_DL="$LIBS";LIBS=""])
46AC_SUBST(LIBRARY_DL)
47
Erice885bc52020-04-11 00:52:43 +020048AC_SEARCH_LIBS([dlsym], [dl dld], [LIBRARY_DLSYM="$LIBS";LIBS=""])
49AC_SUBST(LIBRARY_DLSYM)
50
Harald Weltede729a12008-12-23 21:01:25 +000051
Pau Espin Pedrol6ccdaa22021-02-23 18:28:45 +010052PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.5.0)
53PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.5.0)
54PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl >= 1.5.0)
55PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.5.0)
56PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 1.1.0)
57PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 1.1.0)
58PKG_CHECK_MODULES(LIBOSMOTRAU, libosmotrau >= 1.1.0)
Holger Hans Peter Freyther25b70ce2012-12-20 23:49:24 +010059
Eric55fdfc22021-08-13 00:14:18 +020060CFLAGS="$CFLAGS -pthread"
61LDFLAGS="$LDFLAGS -pthread"
62
Neels Hofmeyr7c20c9d2017-11-17 01:43:36 +010063AC_ARG_ENABLE(sanitize,
64 [AS_HELP_STRING(
65 [--enable-sanitize],
66 [Compile with address sanitizer enabled],
67 )],
68 [sanitize=$enableval], [sanitize="no"])
69if test x"$sanitize" = x"yes"
70then
71 CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined"
72 CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
73fi
74
Neels Hofmeyr4f7613e2018-03-05 20:43:27 +010075AC_ARG_ENABLE(werror,
76 [AS_HELP_STRING(
77 [--enable-werror],
78 [Turn all compiler warnings into errors, with exceptions:
79 a) deprecation (allow upstream to mark deprecation without breaking builds);
80 b) "#warning" pragmas (allow to remind ourselves of errors without breaking builds)
81 ]
82 )],
83 [werror=$enableval], [werror="no"])
84if test x"$werror" = x"yes"
85then
86 WERROR_FLAGS="-Werror"
87 WERROR_FLAGS+=" -Wno-error=deprecated -Wno-error=deprecated-declarations"
88 WERROR_FLAGS+=" -Wno-error=cpp" # "#warning"
89 CFLAGS="$CFLAGS $WERROR_FLAGS"
90 CPPFLAGS="$CPPFLAGS $WERROR_FLAGS"
91fi
92
Harald Weltede729a12008-12-23 21:01:25 +000093dnl Checks for typedefs, structures and compiler characteristics
94
Max34f01262017-01-20 13:03:03 +010095AX_CHECK_COMPILE_FLAG([-Werror=implicit], [CFLAGS="$CFLAGS -Werror=implicit"])
Eric374ad782021-09-10 17:24:19 +020096AX_CHECK_COMPILE_FLAG([-Werror=maybe-uninitialized], [CFLAGS="$CFLAGS -Werror=maybe-uninitialized"],,[-Werror])
97AX_CHECK_COMPILE_FLAG([-Werror=sometimes-uninitialized], [CFLAGS="$CFLAGS -Werror=sometimes-uninitialized"],,[-Werror])
Max34f01262017-01-20 13:03:03 +010098AX_CHECK_COMPILE_FLAG([-Werror=memset-transposed-args], [CFLAGS="$CFLAGS -Werror=memset-transposed-args"])
Hoernchen199c5e92019-07-19 00:49:22 +020099AX_CHECK_COMPILE_FLAG([-Wnull-dereference], [CFLAGS="$CFLAGS -Wnull-dereference"])
Max34f01262017-01-20 13:03:03 +0100100AX_CHECK_COMPILE_FLAG([-Werror=sizeof-array-argument], [CFLAGS="$CFLAGS -Werror=sizeof-array-argument"])
101AX_CHECK_COMPILE_FLAG([-Werror=sizeof-pointer-memaccess], [CFLAGS="$CFLAGS -Werror=sizeof-pointer-memaccess"])
102
Holger Hans Peter Freytherecd94a42010-11-15 18:37:57 +0100103# Coverage build taken from WebKit's configure.in
104AC_MSG_CHECKING([whether to enable code coverage support])
105AC_ARG_ENABLE(coverage,
106 AC_HELP_STRING([--enable-coverage],
107 [enable code coverage support [default=no]]),
108 [],[enable_coverage="no"])
109AC_MSG_RESULT([$enable_coverage])
110if test "$enable_coverage" = "yes"; then
111 COVERAGE_CFLAGS="-ftest-coverage -fprofile-arcs"
112 COVERAGE_LDFLAGS="-ftest-coverage -fprofile-arcs"
113 AC_SUBST([COVERAGE_CFLAGS])
114 AC_SUBST([COVERAGE_LDFLAGS])
115fi
116
Katerina Barone-Adesie0aee7a2013-04-05 17:36:09 +0200117AC_ARG_ENABLE([vty_tests],
118 AC_HELP_STRING([--enable-vty-tests],
Holger Hans Peter Freytherdd588ae2014-08-22 00:29:04 +0200119 [Include the VTY/CTRL tests in make check (deprecated)
120 [default=no]]),
121 [enable_ext_tests="$enableval"],[enable_ext_tests="no"])
Pablo Neira Ayuso92240102014-09-01 09:34:07 +0200122AC_ARG_ENABLE([external_tests],
Holger Hans Peter Freytherdd588ae2014-08-22 00:29:04 +0200123 AC_HELP_STRING([--enable-external-tests],
124 [Include the VTY/CTRL tests in make check [default=no]]),
125 [enable_ext_tests="$enableval"],[enable_ext_tests="no"])
126if test "x$enable_ext_tests" = "xyes" ; then
Katerina Barone-Adesie0aee7a2013-04-05 17:36:09 +0200127 AM_PATH_PYTHON
Holger Hans Peter Freytherdd588ae2014-08-22 00:29:04 +0200128 AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmotestvty.py,yes)
129 if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then
Neels Hofmeyrb6cd7932017-07-20 23:01:45 +0200130 AC_MSG_ERROR([Please install git://osmocom.org/python/osmo-python-tests to run the VTY/CTRL tests.])
Katerina Barone-Adesie0aee7a2013-04-05 17:36:09 +0200131 fi
132fi
Holger Hans Peter Freytherdd588ae2014-08-22 00:29:04 +0200133AC_MSG_CHECKING([whether to enable VTY/CTRL tests])
134AC_MSG_RESULT([$enable_ext_tests])
135AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
Katerina Barone-Adesie0aee7a2013-04-05 17:36:09 +0200136
Oliver Smith7c0b70a2018-11-14 10:47:01 +0100137# Generate manuals
138AC_ARG_ENABLE(manuals,
139 [AS_HELP_STRING(
140 [--enable-manuals],
141 [Generate manual PDFs [default=no]],
142 )],
143 [osmo_ac_build_manuals=$enableval], [osmo_ac_build_manuals="no"])
144AM_CONDITIONAL([BUILD_MANUALS], [test x"$osmo_ac_build_manuals" = x"yes"])
145AC_ARG_VAR(OSMO_GSM_MANUALS_DIR, [path to common osmo-gsm-manuals files, overriding pkg-config and "../osmo-gsm-manuals"
146 fallback])
147if test x"$osmo_ac_build_manuals" = x"yes"
148then
149 # Find OSMO_GSM_MANUALS_DIR (env, pkg-conf, fallback)
150 if test -n "$OSMO_GSM_MANUALS_DIR"; then
151 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from env)"
152 else
153 OSMO_GSM_MANUALS_DIR="$($PKG_CONFIG osmo-gsm-manuals --variable=osmogsmmanualsdir 2>/dev/null)"
154 if test -n "$OSMO_GSM_MANUALS_DIR"; then
155 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from pkg-conf)"
156 else
157 OSMO_GSM_MANUALS_DIR="../osmo-gsm-manuals"
158 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (fallback)"
159 fi
160 fi
161 if ! test -d "$OSMO_GSM_MANUALS_DIR"; then
162 AC_MSG_ERROR("OSMO_GSM_MANUALS_DIR does not exist! Install osmo-gsm-manuals or set OSMO_GSM_MANUALS_DIR.")
163 fi
164
165 # Find and run check-depends
166 CHECK_DEPENDS="$OSMO_GSM_MANUALS_DIR/check-depends.sh"
167 if ! test -x "$CHECK_DEPENDS"; then
168 CHECK_DEPENDS="osmo-gsm-manuals-check-depends"
169 fi
170 if ! $CHECK_DEPENDS; then
171 AC_MSG_ERROR("missing dependencies for --enable-manuals")
172 fi
173
174 # Put in Makefile with absolute path
175 OSMO_GSM_MANUALS_DIR="$(realpath "$OSMO_GSM_MANUALS_DIR")"
176 AC_SUBST([OSMO_GSM_MANUALS_DIR])
177fi
178
Pau Espin Pedrole6866752018-09-10 12:46:47 +0200179# https://www.freedesktop.org/software/systemd/man/daemon.html
180AC_ARG_WITH([systemdsystemunitdir],
181 [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
182 [with_systemdsystemunitdir=auto])
183AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
184 def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
185
186 AS_IF([test "x$def_systemdsystemunitdir" = "x"],
187 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
188 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
189 with_systemdsystemunitdir=no],
190 [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
191AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
192 [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
193AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
194
Neels Hofmeyr4f7613e2018-03-05 20:43:27 +0100195AC_MSG_RESULT([CFLAGS="$CFLAGS"])
196AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
197
Holger Freyther6d9f77a2009-06-08 10:32:54 +0000198dnl Generate the output
199AM_CONFIG_HEADER(bscconfig.h)
200
Holger Freyther5f755982008-12-27 09:42:59 +0000201AC_OUTPUT(
Neels Hofmeyr97df6912017-09-03 23:52:51 +0200202 libosmo-mgcp-client.pc
Holger Freyther5f755982008-12-27 09:42:59 +0000203 include/Makefile
Neels Hofmeyre9920f22017-07-10 15:07:22 +0200204 include/osmocom/Makefile
Neels Hofmeyr97df6912017-09-03 23:52:51 +0200205 include/osmocom/mgcp_client/Makefile
Philipp Maier87bd9be2017-08-22 16:35:41 +0200206 include/osmocom/mgcp/Makefile
Holger Freyther5f755982008-12-27 09:42:59 +0000207 src/Makefile
Neels Hofmeyr97df6912017-09-03 23:52:51 +0200208 src/libosmo-mgcp-client/Makefile
Philipp Maier87bd9be2017-08-22 16:35:41 +0200209 src/libosmo-mgcp/Makefile
Philipp Maier87bd9be2017-08-22 16:35:41 +0200210 src/osmo-mgw/Makefile
Holger Freyther5f755982008-12-27 09:42:59 +0000211 tests/Makefile
Holger Hans Peter Freyther93ef33e2012-01-09 22:53:04 +0100212 tests/atlocal
Neels Hofmeyr97df6912017-09-03 23:52:51 +0200213 tests/mgcp_client/Makefile
Philipp Maier87bd9be2017-08-22 16:35:41 +0200214 tests/mgcp/Makefile
Harald Welteeb113132011-05-11 22:11:28 +0200215 doc/Makefile
216 doc/examples/Makefile
Oliver Smith7c0b70a2018-11-14 10:47:01 +0100217 doc/manuals/Makefile
Neels Hofmeyrffebe6e2017-07-20 17:57:37 +0200218 contrib/Makefile
Pau Espin Pedrole6866752018-09-10 12:46:47 +0200219 contrib/systemd/Makefile
Oliver Smith6500d722020-05-14 11:48:29 +0200220 contrib/osmo-mgw.spec
Holger Freyther5f755982008-12-27 09:42:59 +0000221 Makefile)