blob: eafe4d6e7fc8c73e726965145b58d6e840b4795c [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
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 Pedrol08d02dd2018-07-27 19:25:05 +020042PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 0.12.0)
43PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 0.12.0)
44PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl >= 0.12.0)
45PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 0.12.0)
46PKG_CHECK_MODULES(LIBOSMOABIS, libosmoabis >= 0.5.1)
47PKG_CHECK_MODULES(LIBOSMONETIF, libosmo-netif >= 0.3.0)
48PKG_CHECK_MODULES(LIBOSMOSIGTRAN, libosmo-sigtran >= 0.10.0)
49PKG_CHECK_MODULES(LIBOSMOSCCP, libosmo-sccp >= 0.10.0)
50PKG_CHECK_MODULES(LIBOSMOMGCPCLIENT, libosmo-mgcp-client >= 1.4.0)
Philipp Maier65df74d2018-05-02 15:11:01 +020051
Harald Weltede729a12008-12-23 21:01:25 +000052dnl checks for header files
53AC_HEADER_STDC
Max7bb383a2017-05-02 12:59:15 +020054
55found_pcap=yes
56AC_CHECK_HEADERS(pcap/pcap.h,,found_pcap=no)
57AM_CONDITIONAL(HAVE_PCAP, test "$found_pcap" = yes)
Harald Welteca17ef82011-02-05 15:13:27 +010058
Harald Welte7465e4c2012-11-13 07:06:54 +010059found_cdk=yes
60AC_CHECK_HEADERS(cdk/cdk.h,,found_cdk=no)
61AM_CONDITIONAL(HAVE_LIBCDK, test "$found_cdk" = yes)
62
Holger Hans Peter Freytherbb06eb92015-01-10 09:51:31 +010063found_sqlite3=yes
64PKG_CHECK_MODULES(SQLITE3, sqlite3, ,found_sqlite3=no)
65AM_CONDITIONAL(HAVE_SQLITE3, test "$found_sqlite3" = yes)
66AC_SUBST(found_sqlite3)
67
Harald Weltede729a12008-12-23 21:01:25 +000068
69dnl Checks for typedefs, structures and compiler characteristics
70
Neels Hofmeyr17b773a2017-11-17 01:43:36 +010071AC_ARG_ENABLE(sanitize,
72 [AS_HELP_STRING(
73 [--enable-sanitize],
74 [Compile with address sanitizer enabled],
75 )],
76 [sanitize=$enableval], [sanitize="no"])
77if test x"$sanitize" = x"yes"
78then
79 CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined"
80 CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
81fi
82
Neels Hofmeyr1bb55542018-03-05 20:08:43 +010083AC_ARG_ENABLE(werror,
84 [AS_HELP_STRING(
85 [--enable-werror],
86 [Turn all compiler warnings into errors, with exceptions:
87 a) deprecation (allow upstream to mark deprecation without breaking builds);
88 b) "#warning" pragmas (allow to remind ourselves of errors without breaking builds)
89 ]
90 )],
91 [werror=$enableval], [werror="no"])
92if test x"$werror" = x"yes"
93then
94 WERROR_FLAGS="-Werror"
95 WERROR_FLAGS+=" -Wno-error=deprecated -Wno-error=deprecated-declarations"
96 WERROR_FLAGS+=" -Wno-error=cpp" # "#warning"
97 CFLAGS="$CFLAGS $WERROR_FLAGS"
98 CPPFLAGS="$CPPFLAGS $WERROR_FLAGS"
99fi
100
Holger Freyther6d9f77a2009-06-08 10:32:54 +0000101# The following test is taken from WebKit's webkit.m4
102saved_CFLAGS="$CFLAGS"
103CFLAGS="$CFLAGS -fvisibility=hidden "
104AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
Alexander Huemerdb1bd692011-05-24 15:16:54 +0200105AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
Holger Freyther6d9f77a2009-06-08 10:32:54 +0000106 [ AC_MSG_RESULT([yes])
107 SYMBOL_VISIBILITY="-fvisibility=hidden"],
108 AC_MSG_RESULT([no]))
109CFLAGS="$saved_CFLAGS"
110AC_SUBST(SYMBOL_VISIBILITY)
111
Max34f01262017-01-20 13:03:03 +0100112AX_CHECK_COMPILE_FLAG([-Werror=implicit], [CFLAGS="$CFLAGS -Werror=implicit"])
113AX_CHECK_COMPILE_FLAG([-Werror=maybe-uninitialized], [CFLAGS="$CFLAGS -Werror=maybe-uninitialized"])
114AX_CHECK_COMPILE_FLAG([-Werror=memset-transposed-args], [CFLAGS="$CFLAGS -Werror=memset-transposed-args"])
115AX_CHECK_COMPILE_FLAG([-Werror=null-dereference], [CFLAGS="$CFLAGS -Werror=null-dereference"])
116AX_CHECK_COMPILE_FLAG([-Werror=sizeof-array-argument], [CFLAGS="$CFLAGS -Werror=sizeof-array-argument"])
117AX_CHECK_COMPILE_FLAG([-Werror=sizeof-pointer-memaccess], [CFLAGS="$CFLAGS -Werror=sizeof-pointer-memaccess"])
118
Holger Hans Peter Freytherecd94a42010-11-15 18:37:57 +0100119# Coverage build taken from WebKit's configure.in
120AC_MSG_CHECKING([whether to enable code coverage support])
121AC_ARG_ENABLE(coverage,
122 AC_HELP_STRING([--enable-coverage],
123 [enable code coverage support [default=no]]),
124 [],[enable_coverage="no"])
125AC_MSG_RESULT([$enable_coverage])
126if test "$enable_coverage" = "yes"; then
127 COVERAGE_CFLAGS="-ftest-coverage -fprofile-arcs"
128 COVERAGE_LDFLAGS="-ftest-coverage -fprofile-arcs"
129 AC_SUBST([COVERAGE_CFLAGS])
130 AC_SUBST([COVERAGE_LDFLAGS])
131fi
132
Max0bd729f2017-12-28 14:33:53 +0100133AC_ARG_ENABLE(profile,
134 [AS_HELP_STRING([--enable-profile], [Compile with profiling support enabled], )],
135 [profile=$enableval], [profile="no"])
136if test x"$profile" = x"yes"
137then
138 CFLAGS="$CFLAGS -pg"
139 CPPFLAGS="$CPPFLAGS -pg"
140fi
141
Pablo Neira Ayuso92240102014-09-01 09:34:07 +0200142AC_ARG_ENABLE([external_tests],
Holger Hans Peter Freytherdd588ae2014-08-22 00:29:04 +0200143 AC_HELP_STRING([--enable-external-tests],
144 [Include the VTY/CTRL tests in make check [default=no]]),
145 [enable_ext_tests="$enableval"],[enable_ext_tests="no"])
146if test "x$enable_ext_tests" = "xyes" ; then
Pau Espin Pedrol7e786812017-11-24 12:00:35 +0100147 AC_CHECK_PROG(PYTHON2_AVAIL,python2,yes)
148 if test "x$PYTHON2_AVAIL" != "xyes" ; then
149 AC_MSG_ERROR([Please install python2 to run the VTY/CTRL tests.])
150 fi
Holger Hans Peter Freytherdd588ae2014-08-22 00:29:04 +0200151 AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmotestvty.py,yes)
152 if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then
Neels Hofmeyr178d1372017-07-20 23:01:45 +0200153 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 +0200154 fi
155fi
Holger Hans Peter Freytherdd588ae2014-08-22 00:29:04 +0200156AC_MSG_CHECKING([whether to enable VTY/CTRL tests])
157AC_MSG_RESULT([$enable_ext_tests])
158AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
Katerina Barone-Adesie0aee7a2013-04-05 17:36:09 +0200159
Oliver Smith686deaf2018-11-14 10:47:01 +0100160# Generate manuals
161AC_ARG_ENABLE(manuals,
162 [AS_HELP_STRING(
163 [--enable-manuals],
164 [Generate manual PDFs [default=no]],
165 )],
166 [osmo_ac_build_manuals=$enableval], [osmo_ac_build_manuals="no"])
167AM_CONDITIONAL([BUILD_MANUALS], [test x"$osmo_ac_build_manuals" = x"yes"])
168AC_ARG_VAR(OSMO_GSM_MANUALS_DIR, [path to common osmo-gsm-manuals files, overriding pkg-config and "../osmo-gsm-manuals"
169 fallback])
170if test x"$osmo_ac_build_manuals" = x"yes"
171then
172 # Find OSMO_GSM_MANUALS_DIR (env, pkg-conf, fallback)
173 if test -n "$OSMO_GSM_MANUALS_DIR"; then
174 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from env)"
175 else
176 OSMO_GSM_MANUALS_DIR="$($PKG_CONFIG osmo-gsm-manuals --variable=osmogsmmanualsdir 2>/dev/null)"
177 if test -n "$OSMO_GSM_MANUALS_DIR"; then
178 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from pkg-conf)"
179 else
180 OSMO_GSM_MANUALS_DIR="../osmo-gsm-manuals"
181 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (fallback)"
182 fi
183 fi
184 if ! test -d "$OSMO_GSM_MANUALS_DIR"; then
185 AC_MSG_ERROR("OSMO_GSM_MANUALS_DIR does not exist! Install osmo-gsm-manuals or set OSMO_GSM_MANUALS_DIR.")
186 fi
187
188 # Find and run check-depends
189 CHECK_DEPENDS="$OSMO_GSM_MANUALS_DIR/check-depends.sh"
190 if ! test -x "$CHECK_DEPENDS"; then
191 CHECK_DEPENDS="osmo-gsm-manuals-check-depends"
192 fi
193 if ! $CHECK_DEPENDS; then
194 AC_MSG_ERROR("missing dependencies for --enable-manuals")
195 fi
196
197 # Put in Makefile with absolute path
198 OSMO_GSM_MANUALS_DIR="$(realpath "$OSMO_GSM_MANUALS_DIR")"
199 AC_SUBST([OSMO_GSM_MANUALS_DIR])
200fi
201
Pau Espin Pedrold58ddb22018-09-10 13:00:44 +0200202# https://www.freedesktop.org/software/systemd/man/daemon.html
203AC_ARG_WITH([systemdsystemunitdir],
204 [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
205 [with_systemdsystemunitdir=auto])
206AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
207 def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
208
209 AS_IF([test "x$def_systemdsystemunitdir" = "x"],
210 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
211 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
212 with_systemdsystemunitdir=no],
213 [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
214AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
215 [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
216AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
217
Neels Hofmeyr1bb55542018-03-05 20:08:43 +0100218AC_MSG_RESULT([CFLAGS="$CFLAGS"])
219AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
220
Holger Freyther6d9f77a2009-06-08 10:32:54 +0000221dnl Generate the output
222AM_CONFIG_HEADER(bscconfig.h)
223
Holger Freyther5f755982008-12-27 09:42:59 +0000224AC_OUTPUT(
Holger Freyther5f755982008-12-27 09:42:59 +0000225 include/Makefile
Neels Hofmeyrc0164792017-09-04 15:15:32 +0200226 include/osmocom/Makefile
227 include/osmocom/bsc/Makefile
Holger Freyther5f755982008-12-27 09:42:59 +0000228 src/Makefile
Holger Hans Peter Freyther4247cea2015-04-04 18:42:46 +0200229 src/libfilter/Makefile
Harald Welte31c00f72011-03-03 23:29:05 +0100230 src/osmo-bsc/Makefile
Harald Welte31c00f72011-03-03 23:29:05 +0100231 src/ipaccess/Makefile
232 src/utils/Makefile
Holger Freyther5f755982008-12-27 09:42:59 +0000233 tests/Makefile
Holger Hans Peter Freyther93ef33e2012-01-09 22:53:04 +0100234 tests/atlocal
Holger Freytheraa0fb362008-12-28 21:55:40 +0000235 tests/gsm0408/Makefile
Jacob Erlbeck946d1412013-09-17 13:59:29 +0200236 tests/bsc/Makefile
Philipp Maier844876f2018-07-13 09:17:07 +0200237 tests/codec_pref/Makefile
Holger Hans Peter Freytherbce56752012-11-22 14:59:46 +0100238 tests/abis/Makefile
Jacob Erlbeck0acc0012014-12-03 13:05:16 +0100239 tests/subscr/Makefile
Philippb4cb8382016-09-29 17:01:57 +0200240 tests/nanobts_omlattr/Makefile
Neels Hofmeyr909e9722017-12-07 03:54:01 +0100241 tests/handover/Makefile
Harald Welteeb113132011-05-11 22:11:28 +0200242 doc/Makefile
243 doc/examples/Makefile
Oliver Smith686deaf2018-11-14 10:47:01 +0100244 doc/manuals/Makefile
Pau Espin Pedrold58ddb22018-09-10 13:00:44 +0200245 contrib/Makefile
246 contrib/systemd/Makefile
Holger Freyther5f755982008-12-27 09:42:59 +0000247 Makefile)