blob: 12788164db1f3f0cf659c8eac0a1edabc38e7b13 [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
Holger Hans Peter Freyther1f59ac42009-10-27 03:34:49 +010012dnl kernel style compile messages
13m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
14
Max58cfd252017-08-28 12:04:18 +020015dnl include release helper
16RELMAKE='-include osmo-release.mk'
17AC_SUBST([RELMAKE])
18
Harald Weltede729a12008-12-23 21:01:25 +000019dnl checks for programs
20AC_PROG_MAKE_SET
21AC_PROG_CC
22AC_PROG_INSTALL
Maxeab5f592017-05-26 12:31:00 +020023LT_INIT
Harald Weltede729a12008-12-23 21:01:25 +000024
Neels Hofmeyra8f91df2016-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
Max34f01262017-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 Weltede729a12008-12-23 21:01:25 +000037dnl checks for libraries
Jacob Erlbeck51a869c2013-10-15 12:00:26 +020038AC_SEARCH_LIBS([dlopen], [dl dld], [LIBRARY_DL="$LIBS";LIBS=""])
39AC_SUBST(LIBRARY_DL)
40
Harald Weltede729a12008-12-23 21:01:25 +000041
Pau Espin Pedrol304b3eb2018-07-27 19:05:23 +020042PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.12.0)
43PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.12.0)
44PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.12.0)
45PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 0.3.0)
Holger Hans Peter Freyther25b70ce2012-12-20 23:49:24 +010046
Neels Hofmeyr7c20c9d2017-11-17 01:43:36 +010047AC_ARG_ENABLE(sanitize,
48 [AS_HELP_STRING(
49 [--enable-sanitize],
50 [Compile with address sanitizer enabled],
51 )],
52 [sanitize=$enableval], [sanitize="no"])
53if test x"$sanitize" = x"yes"
54then
55 CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined"
56 CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
57fi
58
Neels Hofmeyr4f7613e2018-03-05 20:43:27 +010059AC_ARG_ENABLE(werror,
60 [AS_HELP_STRING(
61 [--enable-werror],
62 [Turn all compiler warnings into errors, with exceptions:
63 a) deprecation (allow upstream to mark deprecation without breaking builds);
64 b) "#warning" pragmas (allow to remind ourselves of errors without breaking builds)
65 ]
66 )],
67 [werror=$enableval], [werror="no"])
68if test x"$werror" = x"yes"
69then
70 WERROR_FLAGS="-Werror"
71 WERROR_FLAGS+=" -Wno-error=deprecated -Wno-error=deprecated-declarations"
72 WERROR_FLAGS+=" -Wno-error=cpp" # "#warning"
73 CFLAGS="$CFLAGS $WERROR_FLAGS"
74 CPPFLAGS="$CPPFLAGS $WERROR_FLAGS"
75fi
76
Harald Weltede729a12008-12-23 21:01:25 +000077dnl Checks for typedefs, structures and compiler characteristics
78
Holger Freyther6d9f77a2009-06-08 10:32:54 +000079# The following test is taken from WebKit's webkit.m4
80saved_CFLAGS="$CFLAGS"
81CFLAGS="$CFLAGS -fvisibility=hidden "
82AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
Alexander Huemerdb1bd692011-05-24 15:16:54 +020083AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
Holger Freyther6d9f77a2009-06-08 10:32:54 +000084 [ AC_MSG_RESULT([yes])
85 SYMBOL_VISIBILITY="-fvisibility=hidden"],
86 AC_MSG_RESULT([no]))
87CFLAGS="$saved_CFLAGS"
88AC_SUBST(SYMBOL_VISIBILITY)
89
Max34f01262017-01-20 13:03:03 +010090AX_CHECK_COMPILE_FLAG([-Werror=implicit], [CFLAGS="$CFLAGS -Werror=implicit"])
91AX_CHECK_COMPILE_FLAG([-Werror=maybe-uninitialized], [CFLAGS="$CFLAGS -Werror=maybe-uninitialized"])
92AX_CHECK_COMPILE_FLAG([-Werror=memset-transposed-args], [CFLAGS="$CFLAGS -Werror=memset-transposed-args"])
93AX_CHECK_COMPILE_FLAG([-Werror=null-dereference], [CFLAGS="$CFLAGS -Werror=null-dereference"])
94AX_CHECK_COMPILE_FLAG([-Werror=sizeof-array-argument], [CFLAGS="$CFLAGS -Werror=sizeof-array-argument"])
95AX_CHECK_COMPILE_FLAG([-Werror=sizeof-pointer-memaccess], [CFLAGS="$CFLAGS -Werror=sizeof-pointer-memaccess"])
96
Holger Hans Peter Freytherecd94a42010-11-15 18:37:57 +010097# Coverage build taken from WebKit's configure.in
98AC_MSG_CHECKING([whether to enable code coverage support])
99AC_ARG_ENABLE(coverage,
100 AC_HELP_STRING([--enable-coverage],
101 [enable code coverage support [default=no]]),
102 [],[enable_coverage="no"])
103AC_MSG_RESULT([$enable_coverage])
104if test "$enable_coverage" = "yes"; then
105 COVERAGE_CFLAGS="-ftest-coverage -fprofile-arcs"
106 COVERAGE_LDFLAGS="-ftest-coverage -fprofile-arcs"
107 AC_SUBST([COVERAGE_CFLAGS])
108 AC_SUBST([COVERAGE_LDFLAGS])
109fi
110
Katerina Barone-Adesie0aee7a2013-04-05 17:36:09 +0200111AC_ARG_ENABLE([vty_tests],
112 AC_HELP_STRING([--enable-vty-tests],
Holger Hans Peter Freytherdd588ae2014-08-22 00:29:04 +0200113 [Include the VTY/CTRL tests in make check (deprecated)
114 [default=no]]),
115 [enable_ext_tests="$enableval"],[enable_ext_tests="no"])
Pablo Neira Ayuso92240102014-09-01 09:34:07 +0200116AC_ARG_ENABLE([external_tests],
Holger Hans Peter Freytherdd588ae2014-08-22 00:29:04 +0200117 AC_HELP_STRING([--enable-external-tests],
118 [Include the VTY/CTRL tests in make check [default=no]]),
119 [enable_ext_tests="$enableval"],[enable_ext_tests="no"])
120if test "x$enable_ext_tests" = "xyes" ; then
Katerina Barone-Adesie0aee7a2013-04-05 17:36:09 +0200121 AM_PATH_PYTHON
Holger Hans Peter Freytherdd588ae2014-08-22 00:29:04 +0200122 AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmotestvty.py,yes)
123 if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then
Neels Hofmeyrb6cd7932017-07-20 23:01:45 +0200124 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 +0200125 fi
126fi
Holger Hans Peter Freytherdd588ae2014-08-22 00:29:04 +0200127AC_MSG_CHECKING([whether to enable VTY/CTRL tests])
128AC_MSG_RESULT([$enable_ext_tests])
129AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
Katerina Barone-Adesie0aee7a2013-04-05 17:36:09 +0200130
Oliver Smith7c0b70a2018-11-14 10:47:01 +0100131# Generate manuals
132AC_ARG_ENABLE(manuals,
133 [AS_HELP_STRING(
134 [--enable-manuals],
135 [Generate manual PDFs [default=no]],
136 )],
137 [osmo_ac_build_manuals=$enableval], [osmo_ac_build_manuals="no"])
138AM_CONDITIONAL([BUILD_MANUALS], [test x"$osmo_ac_build_manuals" = x"yes"])
139AC_ARG_VAR(OSMO_GSM_MANUALS_DIR, [path to common osmo-gsm-manuals files, overriding pkg-config and "../osmo-gsm-manuals"
140 fallback])
141if test x"$osmo_ac_build_manuals" = x"yes"
142then
143 # Find OSMO_GSM_MANUALS_DIR (env, pkg-conf, fallback)
144 if test -n "$OSMO_GSM_MANUALS_DIR"; then
145 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from env)"
146 else
147 OSMO_GSM_MANUALS_DIR="$($PKG_CONFIG osmo-gsm-manuals --variable=osmogsmmanualsdir 2>/dev/null)"
148 if test -n "$OSMO_GSM_MANUALS_DIR"; then
149 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from pkg-conf)"
150 else
151 OSMO_GSM_MANUALS_DIR="../osmo-gsm-manuals"
152 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (fallback)"
153 fi
154 fi
155 if ! test -d "$OSMO_GSM_MANUALS_DIR"; then
156 AC_MSG_ERROR("OSMO_GSM_MANUALS_DIR does not exist! Install osmo-gsm-manuals or set OSMO_GSM_MANUALS_DIR.")
157 fi
158
159 # Find and run check-depends
160 CHECK_DEPENDS="$OSMO_GSM_MANUALS_DIR/check-depends.sh"
161 if ! test -x "$CHECK_DEPENDS"; then
162 CHECK_DEPENDS="osmo-gsm-manuals-check-depends"
163 fi
164 if ! $CHECK_DEPENDS; then
165 AC_MSG_ERROR("missing dependencies for --enable-manuals")
166 fi
167
168 # Put in Makefile with absolute path
169 OSMO_GSM_MANUALS_DIR="$(realpath "$OSMO_GSM_MANUALS_DIR")"
170 AC_SUBST([OSMO_GSM_MANUALS_DIR])
171fi
172
Pau Espin Pedrole6866752018-09-10 12:46:47 +0200173# https://www.freedesktop.org/software/systemd/man/daemon.html
174AC_ARG_WITH([systemdsystemunitdir],
175 [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
176 [with_systemdsystemunitdir=auto])
177AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
178 def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
179
180 AS_IF([test "x$def_systemdsystemunitdir" = "x"],
181 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
182 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
183 with_systemdsystemunitdir=no],
184 [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
185AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
186 [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
187AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
188
Neels Hofmeyr4f7613e2018-03-05 20:43:27 +0100189AC_MSG_RESULT([CFLAGS="$CFLAGS"])
190AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
191
Holger Freyther6d9f77a2009-06-08 10:32:54 +0000192dnl Generate the output
193AM_CONFIG_HEADER(bscconfig.h)
194
Holger Freyther5f755982008-12-27 09:42:59 +0000195AC_OUTPUT(
Neels Hofmeyr97df6912017-09-03 23:52:51 +0200196 libosmo-mgcp-client.pc
Holger Freyther5f755982008-12-27 09:42:59 +0000197 include/Makefile
Neels Hofmeyre9920f22017-07-10 15:07:22 +0200198 include/osmocom/Makefile
Neels Hofmeyr97df6912017-09-03 23:52:51 +0200199 include/osmocom/mgcp_client/Makefile
Philipp Maier87bd9be2017-08-22 16:35:41 +0200200 include/osmocom/mgcp/Makefile
Holger Freyther5f755982008-12-27 09:42:59 +0000201 src/Makefile
Neels Hofmeyr97df6912017-09-03 23:52:51 +0200202 src/libosmo-mgcp-client/Makefile
Philipp Maier87bd9be2017-08-22 16:35:41 +0200203 src/libosmo-mgcp/Makefile
Philipp Maier87bd9be2017-08-22 16:35:41 +0200204 src/osmo-mgw/Makefile
Holger Freyther5f755982008-12-27 09:42:59 +0000205 tests/Makefile
Holger Hans Peter Freyther93ef33e2012-01-09 22:53:04 +0100206 tests/atlocal
Neels Hofmeyr97df6912017-09-03 23:52:51 +0200207 tests/mgcp_client/Makefile
Philipp Maier87bd9be2017-08-22 16:35:41 +0200208 tests/mgcp/Makefile
Neels Hofmeyrf2a65b82018-09-30 05:01:20 +0200209 tests/iuup/Makefile
Harald Welteeb113132011-05-11 22:11:28 +0200210 doc/Makefile
211 doc/examples/Makefile
Oliver Smith7c0b70a2018-11-14 10:47:01 +0100212 doc/manuals/Makefile
Neels Hofmeyrffebe6e2017-07-20 17:57:37 +0200213 contrib/Makefile
Pau Espin Pedrole6866752018-09-10 12:46:47 +0200214 contrib/systemd/Makefile
Holger Freyther5f755982008-12-27 09:42:59 +0000215 Makefile)