blob: 7c56e657712a8da0bad9924a1a9c9bb4d99f56b4 [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
Harald Weltede729a12008-12-23 21:01:25 +000039dnl checks for libraries
Jacob Erlbeck51a869c2013-10-15 12:00:26 +020040AC_SEARCH_LIBS([dlopen], [dl dld], [LIBRARY_DL="$LIBS";LIBS=""])
41AC_SUBST(LIBRARY_DL)
42
Erice885bc52020-04-11 00:52:43 +020043AC_SEARCH_LIBS([dlsym], [dl dld], [LIBRARY_DLSYM="$LIBS";LIBS=""])
44AC_SUBST(LIBRARY_DLSYM)
45
Harald Weltede729a12008-12-23 21:01:25 +000046
Pau Espin Pedrol730a1f22023-09-12 14:48:51 +020047PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.9.0)
48PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.9.0)
49PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl >= 1.9.0)
50PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.9.0)
51PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 1.4.0)
52PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 1.5.0)
53PKG_CHECK_MODULES(LIBOSMOTRAU, libosmotrau >= 1.5.0)
Holger Hans Peter Freyther25b70ce2012-12-20 23:49:24 +010054
Pau Espin Pedrol8e8d59f2023-06-13 19:41:44 +020055CFLAGS="$CFLAGS -DBUILDING_LIBOSMOMGCPCLIENT -pthread"
56CPPFLAGS="$CPPFLAGS -DBUILDING_LIBOSMOMGCPCLIENT -pthread"
Eric55fdfc22021-08-13 00:14:18 +020057LDFLAGS="$LDFLAGS -pthread"
58
Neels Hofmeyr7c20c9d2017-11-17 01:43:36 +010059AC_ARG_ENABLE(sanitize,
60 [AS_HELP_STRING(
61 [--enable-sanitize],
62 [Compile with address sanitizer enabled],
63 )],
64 [sanitize=$enableval], [sanitize="no"])
65if test x"$sanitize" = x"yes"
66then
67 CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined"
68 CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
69fi
70
Neels Hofmeyr4f7613e2018-03-05 20:43:27 +010071AC_ARG_ENABLE(werror,
72 [AS_HELP_STRING(
73 [--enable-werror],
74 [Turn all compiler warnings into errors, with exceptions:
75 a) deprecation (allow upstream to mark deprecation without breaking builds);
76 b) "#warning" pragmas (allow to remind ourselves of errors without breaking builds)
77 ]
78 )],
79 [werror=$enableval], [werror="no"])
80if test x"$werror" = x"yes"
81then
82 WERROR_FLAGS="-Werror"
Harald Welte6ea8d7d2022-11-03 11:59:21 +010083 WERROR_FLAGS+=" -Werror=implicit-int -Werror=int-conversion -Werror=old-style-definition"
Neels Hofmeyr4f7613e2018-03-05 20:43:27 +010084 WERROR_FLAGS+=" -Wno-error=deprecated -Wno-error=deprecated-declarations"
85 WERROR_FLAGS+=" -Wno-error=cpp" # "#warning"
86 CFLAGS="$CFLAGS $WERROR_FLAGS"
87 CPPFLAGS="$CPPFLAGS $WERROR_FLAGS"
88fi
89
Holger Hans Peter Freytherecd94a42010-11-15 18:37:57 +010090# Coverage build taken from WebKit's configure.in
91AC_MSG_CHECKING([whether to enable code coverage support])
92AC_ARG_ENABLE(coverage,
93 AC_HELP_STRING([--enable-coverage],
94 [enable code coverage support [default=no]]),
95 [],[enable_coverage="no"])
96AC_MSG_RESULT([$enable_coverage])
97if test "$enable_coverage" = "yes"; then
98 COVERAGE_CFLAGS="-ftest-coverage -fprofile-arcs"
99 COVERAGE_LDFLAGS="-ftest-coverage -fprofile-arcs"
100 AC_SUBST([COVERAGE_CFLAGS])
101 AC_SUBST([COVERAGE_LDFLAGS])
102fi
103
Katerina Barone-Adesie0aee7a2013-04-05 17:36:09 +0200104AC_ARG_ENABLE([vty_tests],
105 AC_HELP_STRING([--enable-vty-tests],
Holger Hans Peter Freytherdd588ae2014-08-22 00:29:04 +0200106 [Include the VTY/CTRL tests in make check (deprecated)
107 [default=no]]),
108 [enable_ext_tests="$enableval"],[enable_ext_tests="no"])
Pablo Neira Ayuso92240102014-09-01 09:34:07 +0200109AC_ARG_ENABLE([external_tests],
Holger Hans Peter Freytherdd588ae2014-08-22 00:29:04 +0200110 AC_HELP_STRING([--enable-external-tests],
111 [Include the VTY/CTRL tests in make check [default=no]]),
112 [enable_ext_tests="$enableval"],[enable_ext_tests="no"])
113if test "x$enable_ext_tests" = "xyes" ; then
Katerina Barone-Adesie0aee7a2013-04-05 17:36:09 +0200114 AM_PATH_PYTHON
Holger Hans Peter Freytherdd588ae2014-08-22 00:29:04 +0200115 AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmotestvty.py,yes)
116 if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then
Harald Weltec9466052022-06-18 12:18:10 +0200117 AC_MSG_ERROR([Please install https://gitea.osmocom.org/cellular-infrastructure/osmo-python-tests to run the VTY/CTRL tests.])
Katerina Barone-Adesie0aee7a2013-04-05 17:36:09 +0200118 fi
119fi
Holger Hans Peter Freytherdd588ae2014-08-22 00:29:04 +0200120AC_MSG_CHECKING([whether to enable VTY/CTRL tests])
121AC_MSG_RESULT([$enable_ext_tests])
122AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
Katerina Barone-Adesie0aee7a2013-04-05 17:36:09 +0200123
Oliver Smith7c0b70a2018-11-14 10:47:01 +0100124# Generate manuals
125AC_ARG_ENABLE(manuals,
126 [AS_HELP_STRING(
127 [--enable-manuals],
128 [Generate manual PDFs [default=no]],
129 )],
130 [osmo_ac_build_manuals=$enableval], [osmo_ac_build_manuals="no"])
131AM_CONDITIONAL([BUILD_MANUALS], [test x"$osmo_ac_build_manuals" = x"yes"])
132AC_ARG_VAR(OSMO_GSM_MANUALS_DIR, [path to common osmo-gsm-manuals files, overriding pkg-config and "../osmo-gsm-manuals"
133 fallback])
134if test x"$osmo_ac_build_manuals" = x"yes"
135then
136 # Find OSMO_GSM_MANUALS_DIR (env, pkg-conf, fallback)
137 if test -n "$OSMO_GSM_MANUALS_DIR"; then
138 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from env)"
139 else
140 OSMO_GSM_MANUALS_DIR="$($PKG_CONFIG osmo-gsm-manuals --variable=osmogsmmanualsdir 2>/dev/null)"
141 if test -n "$OSMO_GSM_MANUALS_DIR"; then
142 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from pkg-conf)"
143 else
144 OSMO_GSM_MANUALS_DIR="../osmo-gsm-manuals"
145 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (fallback)"
146 fi
147 fi
148 if ! test -d "$OSMO_GSM_MANUALS_DIR"; then
149 AC_MSG_ERROR("OSMO_GSM_MANUALS_DIR does not exist! Install osmo-gsm-manuals or set OSMO_GSM_MANUALS_DIR.")
150 fi
151
152 # Find and run check-depends
153 CHECK_DEPENDS="$OSMO_GSM_MANUALS_DIR/check-depends.sh"
154 if ! test -x "$CHECK_DEPENDS"; then
155 CHECK_DEPENDS="osmo-gsm-manuals-check-depends"
156 fi
157 if ! $CHECK_DEPENDS; then
158 AC_MSG_ERROR("missing dependencies for --enable-manuals")
159 fi
160
161 # Put in Makefile with absolute path
162 OSMO_GSM_MANUALS_DIR="$(realpath "$OSMO_GSM_MANUALS_DIR")"
163 AC_SUBST([OSMO_GSM_MANUALS_DIR])
164fi
165
Pau Espin Pedrole6866752018-09-10 12:46:47 +0200166# https://www.freedesktop.org/software/systemd/man/daemon.html
167AC_ARG_WITH([systemdsystemunitdir],
168 [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
169 [with_systemdsystemunitdir=auto])
170AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
171 def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
172
173 AS_IF([test "x$def_systemdsystemunitdir" = "x"],
174 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
175 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
176 with_systemdsystemunitdir=no],
177 [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
178AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
179 [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
180AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
181
Neels Hofmeyr4f7613e2018-03-05 20:43:27 +0100182AC_MSG_RESULT([CFLAGS="$CFLAGS"])
183AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
184
Holger Freyther6d9f77a2009-06-08 10:32:54 +0000185dnl Generate the output
186AM_CONFIG_HEADER(bscconfig.h)
187
Holger Freyther5f755982008-12-27 09:42:59 +0000188AC_OUTPUT(
Neels Hofmeyr97df6912017-09-03 23:52:51 +0200189 libosmo-mgcp-client.pc
Holger Freyther5f755982008-12-27 09:42:59 +0000190 include/Makefile
Neels Hofmeyre9920f22017-07-10 15:07:22 +0200191 include/osmocom/Makefile
Neels Hofmeyr97df6912017-09-03 23:52:51 +0200192 include/osmocom/mgcp_client/Makefile
Philipp Maier87bd9be2017-08-22 16:35:41 +0200193 include/osmocom/mgcp/Makefile
Holger Freyther5f755982008-12-27 09:42:59 +0000194 src/Makefile
Neels Hofmeyr97df6912017-09-03 23:52:51 +0200195 src/libosmo-mgcp-client/Makefile
Philipp Maier87bd9be2017-08-22 16:35:41 +0200196 src/libosmo-mgcp/Makefile
Philipp Maier87bd9be2017-08-22 16:35:41 +0200197 src/osmo-mgw/Makefile
Holger Freyther5f755982008-12-27 09:42:59 +0000198 tests/Makefile
Holger Hans Peter Freyther93ef33e2012-01-09 22:53:04 +0100199 tests/atlocal
Neels Hofmeyr97df6912017-09-03 23:52:51 +0200200 tests/mgcp_client/Makefile
Philipp Maier87bd9be2017-08-22 16:35:41 +0200201 tests/mgcp/Makefile
Harald Welteeb113132011-05-11 22:11:28 +0200202 doc/Makefile
203 doc/examples/Makefile
Oliver Smith7c0b70a2018-11-14 10:47:01 +0100204 doc/manuals/Makefile
Neels Hofmeyrffebe6e2017-07-20 17:57:37 +0200205 contrib/Makefile
Pau Espin Pedrole6866752018-09-10 12:46:47 +0200206 contrib/systemd/Makefile
Oliver Smith6500d722020-05-14 11:48:29 +0200207 contrib/osmo-mgw.spec
Holger Freyther5f755982008-12-27 09:42:59 +0000208 Makefile)