blob: d25925b41eab594d6d7dd2bf59dda174ac98bcad [file] [log] [blame]
Harald Weltede729a12008-12-23 21:01:25 +00001dnl Process this file with autoconf to produce a configure script
Harald Welte630df7d2017-09-03 22:29:45 +02002AC_INIT([osmo-bsc],
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
Max88d8bcb2017-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
Pau Espin Pedrol911d0762020-07-20 12:21:29 +020025dnl patching ${archive_cmds} to affect generation of file "libtool" to fix linking with clang
Eric93920fa2020-04-11 01:17:17 +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 Hofmeyra8f91df2016-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
Max34f01262017-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
Harald Weltede729a12008-12-23 21:01:25 +000042dnl checks for libraries
Jacob Erlbeck51a869c2013-10-15 12:00:26 +020043AC_SEARCH_LIBS([dlopen], [dl dld], [LIBRARY_DL="$LIBS";LIBS=""])
44AC_SUBST(LIBRARY_DL)
45
Pau Espin Pedroled1dcbb2019-03-12 18:26:19 +010046# Enable/disable ipaccess-utils (src/ipacces/)?
47AC_ARG_ENABLE([ipaccess-utils], [AS_HELP_STRING([--enable-ipaccess-utils], [Build ipaccess utils: abisip-find, ipaccess-config, ...])],
48 [osmo_ac_ipa_utils="$enableval"],[osmo_ac_ipa_utils="yes"])
49AM_CONDITIONAL(BUILD_IPA_UTILS, test "x$osmo_ac_ipa_utils" = "xyes")
50AC_SUBST(osmo_ac_ipa_utils)
Harald Weltede729a12008-12-23 21:01:25 +000051
Pau Espin Pedrola1362ce2020-01-03 18:24:51 +010052PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.3.0)
53PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.3.0)
54PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl >= 1.3.0)
55PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.3.0)
Pau Espin Pedrol3c948572019-08-07 20:42:06 +020056PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 0.6.0)
57PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 0.6.0)
Pau Espin Pedrol08d02dd2018-07-27 19:25:05 +020058PKG_CHECK_MODULES(LIBOSMOSIGTRAN, libosmo-sigtran >= 0.10.0)
59PKG_CHECK_MODULES(LIBOSMOSCCP, libosmo-sccp >= 0.10.0)
Pau Espin Pedrola1362ce2020-01-03 18:24:51 +010060PKG_CHECK_MODULES(LIBOSMOMGCPCLIENT, libosmo-mgcp-client >= 1.6.0)
Philipp Maier65df74d2018-05-02 15:11:01 +020061
Harald Weltede729a12008-12-23 21:01:25 +000062dnl checks for header files
63AC_HEADER_STDC
Max7bb383a2017-05-02 12:59:15 +020064
65found_pcap=yes
66AC_CHECK_HEADERS(pcap/pcap.h,,found_pcap=no)
67AM_CONDITIONAL(HAVE_PCAP, test "$found_pcap" = yes)
Harald Welteca17ef82011-02-05 15:13:27 +010068
Harald Welte7465e4c2012-11-13 07:06:54 +010069found_cdk=yes
70AC_CHECK_HEADERS(cdk/cdk.h,,found_cdk=no)
71AM_CONDITIONAL(HAVE_LIBCDK, test "$found_cdk" = yes)
72
Holger Hans Peter Freytherbb06eb92015-01-10 09:51:31 +010073found_sqlite3=yes
74PKG_CHECK_MODULES(SQLITE3, sqlite3, ,found_sqlite3=no)
75AM_CONDITIONAL(HAVE_SQLITE3, test "$found_sqlite3" = yes)
76AC_SUBST(found_sqlite3)
77
Harald Weltede729a12008-12-23 21:01:25 +000078
79dnl Checks for typedefs, structures and compiler characteristics
80
Neels Hofmeyr17b773a2017-11-17 01:43:36 +010081AC_ARG_ENABLE(sanitize,
82 [AS_HELP_STRING(
83 [--enable-sanitize],
84 [Compile with address sanitizer enabled],
85 )],
86 [sanitize=$enableval], [sanitize="no"])
87if test x"$sanitize" = x"yes"
88then
89 CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined"
90 CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
91fi
92
Neels Hofmeyr1bb55542018-03-05 20:08:43 +010093AC_ARG_ENABLE(werror,
94 [AS_HELP_STRING(
95 [--enable-werror],
96 [Turn all compiler warnings into errors, with exceptions:
97 a) deprecation (allow upstream to mark deprecation without breaking builds);
98 b) "#warning" pragmas (allow to remind ourselves of errors without breaking builds)
99 ]
100 )],
101 [werror=$enableval], [werror="no"])
102if test x"$werror" = x"yes"
103then
104 WERROR_FLAGS="-Werror"
105 WERROR_FLAGS+=" -Wno-error=deprecated -Wno-error=deprecated-declarations"
106 WERROR_FLAGS+=" -Wno-error=cpp" # "#warning"
107 CFLAGS="$CFLAGS $WERROR_FLAGS"
108 CPPFLAGS="$CPPFLAGS $WERROR_FLAGS"
109fi
110
Holger Freyther6d9f77a2009-06-08 10:32:54 +0000111# The following test is taken from WebKit's webkit.m4
112saved_CFLAGS="$CFLAGS"
113CFLAGS="$CFLAGS -fvisibility=hidden "
114AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
Alexander Huemerdb1bd692011-05-24 15:16:54 +0200115AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
Holger Freyther6d9f77a2009-06-08 10:32:54 +0000116 [ AC_MSG_RESULT([yes])
117 SYMBOL_VISIBILITY="-fvisibility=hidden"],
118 AC_MSG_RESULT([no]))
119CFLAGS="$saved_CFLAGS"
120AC_SUBST(SYMBOL_VISIBILITY)
121
Max34f01262017-01-20 13:03:03 +0100122AX_CHECK_COMPILE_FLAG([-Werror=implicit], [CFLAGS="$CFLAGS -Werror=implicit"])
123AX_CHECK_COMPILE_FLAG([-Werror=maybe-uninitialized], [CFLAGS="$CFLAGS -Werror=maybe-uninitialized"])
124AX_CHECK_COMPILE_FLAG([-Werror=memset-transposed-args], [CFLAGS="$CFLAGS -Werror=memset-transposed-args"])
Eric Wild50dc3512019-07-19 00:48:05 +0200125AX_CHECK_COMPILE_FLAG([-Wnull-dereference], [CFLAGS="$CFLAGS -Wnull-dereference"])
Max34f01262017-01-20 13:03:03 +0100126AX_CHECK_COMPILE_FLAG([-Werror=sizeof-array-argument], [CFLAGS="$CFLAGS -Werror=sizeof-array-argument"])
127AX_CHECK_COMPILE_FLAG([-Werror=sizeof-pointer-memaccess], [CFLAGS="$CFLAGS -Werror=sizeof-pointer-memaccess"])
128
Holger Hans Peter Freytherecd94a42010-11-15 18:37:57 +0100129# Coverage build taken from WebKit's configure.in
130AC_MSG_CHECKING([whether to enable code coverage support])
131AC_ARG_ENABLE(coverage,
132 AC_HELP_STRING([--enable-coverage],
133 [enable code coverage support [default=no]]),
134 [],[enable_coverage="no"])
135AC_MSG_RESULT([$enable_coverage])
136if test "$enable_coverage" = "yes"; then
137 COVERAGE_CFLAGS="-ftest-coverage -fprofile-arcs"
138 COVERAGE_LDFLAGS="-ftest-coverage -fprofile-arcs"
139 AC_SUBST([COVERAGE_CFLAGS])
140 AC_SUBST([COVERAGE_LDFLAGS])
141fi
142
Max0bd729f2017-12-28 14:33:53 +0100143AC_ARG_ENABLE(profile,
144 [AS_HELP_STRING([--enable-profile], [Compile with profiling support enabled], )],
145 [profile=$enableval], [profile="no"])
146if test x"$profile" = x"yes"
147then
148 CFLAGS="$CFLAGS -pg"
149 CPPFLAGS="$CPPFLAGS -pg"
150fi
151
Pablo Neira Ayuso92240102014-09-01 09:34:07 +0200152AC_ARG_ENABLE([external_tests],
Holger Hans Peter Freytherdd588ae2014-08-22 00:29:04 +0200153 AC_HELP_STRING([--enable-external-tests],
154 [Include the VTY/CTRL tests in make check [default=no]]),
155 [enable_ext_tests="$enableval"],[enable_ext_tests="no"])
156if test "x$enable_ext_tests" = "xyes" ; then
Pau Espin Pedrol7e786812017-11-24 12:00:35 +0100157 AC_CHECK_PROG(PYTHON2_AVAIL,python2,yes)
158 if test "x$PYTHON2_AVAIL" != "xyes" ; then
159 AC_MSG_ERROR([Please install python2 to run the VTY/CTRL tests.])
160 fi
Holger Hans Peter Freytherdd588ae2014-08-22 00:29:04 +0200161 AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmotestvty.py,yes)
162 if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then
Neels Hofmeyr178d1372017-07-20 23:01:45 +0200163 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 +0200164 fi
165fi
Holger Hans Peter Freytherdd588ae2014-08-22 00:29:04 +0200166AC_MSG_CHECKING([whether to enable VTY/CTRL tests])
167AC_MSG_RESULT([$enable_ext_tests])
168AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
Katerina Barone-Adesie0aee7a2013-04-05 17:36:09 +0200169
Oliver Smith686deaf2018-11-14 10:47:01 +0100170# Generate manuals
171AC_ARG_ENABLE(manuals,
172 [AS_HELP_STRING(
173 [--enable-manuals],
174 [Generate manual PDFs [default=no]],
175 )],
176 [osmo_ac_build_manuals=$enableval], [osmo_ac_build_manuals="no"])
177AM_CONDITIONAL([BUILD_MANUALS], [test x"$osmo_ac_build_manuals" = x"yes"])
178AC_ARG_VAR(OSMO_GSM_MANUALS_DIR, [path to common osmo-gsm-manuals files, overriding pkg-config and "../osmo-gsm-manuals"
179 fallback])
180if test x"$osmo_ac_build_manuals" = x"yes"
181then
182 # Find OSMO_GSM_MANUALS_DIR (env, pkg-conf, fallback)
183 if test -n "$OSMO_GSM_MANUALS_DIR"; then
184 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from env)"
185 else
186 OSMO_GSM_MANUALS_DIR="$($PKG_CONFIG osmo-gsm-manuals --variable=osmogsmmanualsdir 2>/dev/null)"
187 if test -n "$OSMO_GSM_MANUALS_DIR"; then
188 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from pkg-conf)"
189 else
190 OSMO_GSM_MANUALS_DIR="../osmo-gsm-manuals"
191 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (fallback)"
192 fi
193 fi
194 if ! test -d "$OSMO_GSM_MANUALS_DIR"; then
195 AC_MSG_ERROR("OSMO_GSM_MANUALS_DIR does not exist! Install osmo-gsm-manuals or set OSMO_GSM_MANUALS_DIR.")
196 fi
197
198 # Find and run check-depends
199 CHECK_DEPENDS="$OSMO_GSM_MANUALS_DIR/check-depends.sh"
200 if ! test -x "$CHECK_DEPENDS"; then
201 CHECK_DEPENDS="osmo-gsm-manuals-check-depends"
202 fi
203 if ! $CHECK_DEPENDS; then
204 AC_MSG_ERROR("missing dependencies for --enable-manuals")
205 fi
206
207 # Put in Makefile with absolute path
208 OSMO_GSM_MANUALS_DIR="$(realpath "$OSMO_GSM_MANUALS_DIR")"
209 AC_SUBST([OSMO_GSM_MANUALS_DIR])
210fi
211
Pau Espin Pedrold58ddb22018-09-10 13:00:44 +0200212# https://www.freedesktop.org/software/systemd/man/daemon.html
213AC_ARG_WITH([systemdsystemunitdir],
214 [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
215 [with_systemdsystemunitdir=auto])
216AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
217 def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
218
219 AS_IF([test "x$def_systemdsystemunitdir" = "x"],
220 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
221 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
222 with_systemdsystemunitdir=no],
223 [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
224AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
225 [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
226AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
227
Neels Hofmeyr1bb55542018-03-05 20:08:43 +0100228AC_MSG_RESULT([CFLAGS="$CFLAGS"])
229AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
230
Holger Freyther6d9f77a2009-06-08 10:32:54 +0000231dnl Generate the output
232AM_CONFIG_HEADER(bscconfig.h)
233
Holger Freyther5f755982008-12-27 09:42:59 +0000234AC_OUTPUT(
Holger Freyther5f755982008-12-27 09:42:59 +0000235 include/Makefile
Neels Hofmeyrc0164792017-09-04 15:15:32 +0200236 include/osmocom/Makefile
237 include/osmocom/bsc/Makefile
Holger Freyther5f755982008-12-27 09:42:59 +0000238 src/Makefile
Harald Welte31c00f72011-03-03 23:29:05 +0100239 src/osmo-bsc/Makefile
Harald Welte31c00f72011-03-03 23:29:05 +0100240 src/ipaccess/Makefile
241 src/utils/Makefile
Holger Freyther5f755982008-12-27 09:42:59 +0000242 tests/Makefile
Holger Hans Peter Freyther93ef33e2012-01-09 22:53:04 +0100243 tests/atlocal
Holger Freytheraa0fb362008-12-28 21:55:40 +0000244 tests/gsm0408/Makefile
Jacob Erlbeck946d1412013-09-17 13:59:29 +0200245 tests/bsc/Makefile
Philipp Maier844876f2018-07-13 09:17:07 +0200246 tests/codec_pref/Makefile
Holger Hans Peter Freytherbce56752012-11-22 14:59:46 +0100247 tests/abis/Makefile
Jacob Erlbeck0acc0012014-12-03 13:05:16 +0100248 tests/subscr/Makefile
Philippb4cb8382016-09-29 17:01:57 +0200249 tests/nanobts_omlattr/Makefile
Neels Hofmeyr909e9722017-12-07 03:54:01 +0100250 tests/handover/Makefile
Harald Welteeb113132011-05-11 22:11:28 +0200251 doc/Makefile
252 doc/examples/Makefile
Oliver Smith686deaf2018-11-14 10:47:01 +0100253 doc/manuals/Makefile
Pau Espin Pedrold58ddb22018-09-10 13:00:44 +0200254 contrib/Makefile
255 contrib/systemd/Makefile
Oliver Smith700a5a32020-05-14 11:39:37 +0200256 contrib/osmo-bsc.spec
Holger Freyther5f755982008-12-27 09:42:59 +0000257 Makefile)