blob: a4758b553586375e582ab99ddc03932dbb151da2 [file] [log] [blame]
Harald Welte2b944cf2008-12-23 21:01:25 +00001dnl Process this file with autoconf to produce a configure script
Oliver Smith29532c22021-01-29 11:13:00 +01002AC_INIT([osmo-gbproxy],
Harald Weltefa13cad2010-03-23 00:09:32 +08003 m4_esyscmd([./git-version-gen .tarball-version]),
Neels Hofmeyra2ea7292017-09-04 15:17:33 +02004 [osmocom-net-gprs@lists.osmocom.org])
Harald Welte2b944cf2008-12-23 21:01:25 +00005
Neels Hofmeyr7c61f752016-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 Weltefa13cad2010-03-23 00:09:32 +08009AM_INIT_AUTOMAKE([dist-bzip2])
Holger Hans Peter Freytherfee826b2012-01-06 15:16:12 +010010AC_CONFIG_TESTDIR(tests)
Harald Welte2b944cf2008-12-23 21:01:25 +000011
Holger Hans Peter Freytherc746e682009-10-27 03:34:49 +010012dnl kernel style compile messages
13m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
14
Max938cf562017-08-28 12:04:18 +020015dnl include release helper
16RELMAKE='-include osmo-release.mk'
17AC_SUBST([RELMAKE])
18
Harald Welte2b944cf2008-12-23 21:01:25 +000019dnl checks for programs
20AC_PROG_MAKE_SET
21AC_PROG_CC
22AC_PROG_INSTALL
Max72ca1342017-05-26 12:31:00 +020023LT_INIT
Harald Welte2b944cf2008-12-23 21:01:25 +000024
Pau Espin Pedrol570c4072020-08-18 13:45:09 +020025dnl patching ${archive_cmds} to affect generation of file "libtool" to fix linking with clang
Eric9a69cf32020-04-11 01:04:28 +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 Hofmeyredb9ce32016-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
Max0ff613c2017-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
Alexander Couzens78e56f12021-01-01 17:04:23 +010042dnl use a defined standard across all builds and don't depend on compiler default
43CFLAGS="$CFLAGS -std=gnu11"
44
Harald Welte2b944cf2008-12-23 21:01:25 +000045dnl checks for libraries
Jacob Erlbeck76fa57a2013-10-15 12:00:26 +020046AC_SEARCH_LIBS([dlopen], [dl dld], [LIBRARY_DL="$LIBS";LIBS=""])
47AC_SUBST(LIBRARY_DL)
48
Erica9a289f2020-04-11 01:04:08 +020049AC_SEARCH_LIBS([dlsym], [dl dld], [LIBRARY_DLSYM="$LIBS";LIBS=""])
50AC_SUBST(LIBRARY_DLSYM)
51
Harald Welte2b944cf2008-12-23 21:01:25 +000052
Pau Espin Pedrolf89d4f82021-02-24 16:54:13 +010053PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.5.0)
54PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.5.0)
55PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.5.0)
56PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl >= 1.5.0)
57PKG_CHECK_MODULES(LIBOSMOGB, libosmogb >= 1.5.0)
Neels Hofmeyr5c8090e2015-11-29 19:14:58 +010058
Harald Welte2b944cf2008-12-23 21:01:25 +000059dnl checks for header files
60AC_HEADER_STDC
Max24ca9182017-05-02 12:59:15 +020061
Harald Welte2b944cf2008-12-23 21:01:25 +000062dnl Checks for typedefs, structures and compiler characteristics
63
Neels Hofmeyr4984c492017-11-17 01:43:36 +010064AC_ARG_ENABLE(sanitize,
65 [AS_HELP_STRING(
66 [--enable-sanitize],
67 [Compile with address sanitizer enabled],
68 )],
69 [sanitize=$enableval], [sanitize="no"])
70if test x"$sanitize" = x"yes"
71then
72 CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined"
73 CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
74fi
75
Neels Hofmeyrf1474f52018-03-05 20:44:29 +010076AC_ARG_ENABLE(werror,
77 [AS_HELP_STRING(
78 [--enable-werror],
79 [Turn all compiler warnings into errors, with exceptions:
80 a) deprecation (allow upstream to mark deprecation without breaking builds);
81 b) "#warning" pragmas (allow to remind ourselves of errors without breaking builds)
82 ]
83 )],
84 [werror=$enableval], [werror="no"])
85if test x"$werror" = x"yes"
86then
87 WERROR_FLAGS="-Werror"
88 WERROR_FLAGS+=" -Wno-error=deprecated -Wno-error=deprecated-declarations"
89 WERROR_FLAGS+=" -Wno-error=cpp" # "#warning"
90 CFLAGS="$CFLAGS $WERROR_FLAGS"
91 CPPFLAGS="$CPPFLAGS $WERROR_FLAGS"
92fi
93
Holger Freyther64026e92009-06-08 10:32:54 +000094# The following test is taken from WebKit's webkit.m4
95saved_CFLAGS="$CFLAGS"
96CFLAGS="$CFLAGS -fvisibility=hidden "
97AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
Alexander Huemer93ae2d62011-05-24 15:16:54 +020098AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
Holger Freyther64026e92009-06-08 10:32:54 +000099 [ AC_MSG_RESULT([yes])
100 SYMBOL_VISIBILITY="-fvisibility=hidden"],
101 AC_MSG_RESULT([no]))
102CFLAGS="$saved_CFLAGS"
103AC_SUBST(SYMBOL_VISIBILITY)
104
Daniel Willmann3696dce2020-12-02 16:08:02 +0100105CPPFLAGS="$CPPFLAGS -Wall -Wno-trigraphs"
106CFLAGS="$CFLAGS -Wall -Wno-trigraphs"
Pau Espin Pedrolcec01d32018-01-07 18:24:34 +0100107
Max0ff613c2017-01-20 13:03:03 +0100108AX_CHECK_COMPILE_FLAG([-Werror=implicit], [CFLAGS="$CFLAGS -Werror=implicit"])
109AX_CHECK_COMPILE_FLAG([-Werror=maybe-uninitialized], [CFLAGS="$CFLAGS -Werror=maybe-uninitialized"])
110AX_CHECK_COMPILE_FLAG([-Werror=memset-transposed-args], [CFLAGS="$CFLAGS -Werror=memset-transposed-args"])
Eric Wildd855b302019-07-19 00:48:50 +0200111AX_CHECK_COMPILE_FLAG([-Wnull-dereference], [CFLAGS="$CFLAGS -Wnull-dereference"])
Max0ff613c2017-01-20 13:03:03 +0100112AX_CHECK_COMPILE_FLAG([-Werror=sizeof-array-argument], [CFLAGS="$CFLAGS -Werror=sizeof-array-argument"])
113AX_CHECK_COMPILE_FLAG([-Werror=sizeof-pointer-memaccess], [CFLAGS="$CFLAGS -Werror=sizeof-pointer-memaccess"])
114
Holger Hans Peter Freyther16bdb142010-11-15 18:37:57 +0100115# Coverage build taken from WebKit's configure.in
116AC_MSG_CHECKING([whether to enable code coverage support])
117AC_ARG_ENABLE(coverage,
118 AC_HELP_STRING([--enable-coverage],
119 [enable code coverage support [default=no]]),
120 [],[enable_coverage="no"])
121AC_MSG_RESULT([$enable_coverage])
122if test "$enable_coverage" = "yes"; then
123 COVERAGE_CFLAGS="-ftest-coverage -fprofile-arcs"
124 COVERAGE_LDFLAGS="-ftest-coverage -fprofile-arcs"
125 AC_SUBST([COVERAGE_CFLAGS])
126 AC_SUBST([COVERAGE_LDFLAGS])
127fi
128
Harald Welteeaf4a522012-04-08 16:59:24 +0200129AC_DEFUN([CHECK_TM_INCLUDES_TM_GMTOFF], [
130 AC_CACHE_CHECK(
131 [whether struct tm has tm_gmtoff member],
132 osmo_cv_tm_includes_tm_gmtoff,
133 [AC_LINK_IFELSE([
134 AC_LANG_PROGRAM([
135 #include <time.h>
136 ], [
137 time_t t = time(NULL);
138 struct tm* lt = localtime(&t);
139 int off = lt->tm_gmtoff;
140 ])
141 ],
142 osmo_cv_tm_includes_tm_gmtoff=yes,
143 osmo_cv_tm_includes_tm_gmtoff=no
144 )]
145 )
146 if test "x$osmo_cv_tm_includes_tm_gmtoff" = xyes; then
147 AC_DEFINE(HAVE_TM_GMTOFF_IN_TM, 1,
148 [Define if struct tm has tm_gmtoff member.])
149 fi
150])
151
152CHECK_TM_INCLUDES_TM_GMTOFF
Holger Freyther64026e92009-06-08 10:32:54 +0000153
Pablo Neira Ayuso7194f632014-09-01 09:34:07 +0200154AC_ARG_ENABLE([external_tests],
Holger Hans Peter Freyther8fa08b02014-08-22 00:29:04 +0200155 AC_HELP_STRING([--enable-external-tests],
156 [Include the VTY/CTRL tests in make check [default=no]]),
157 [enable_ext_tests="$enableval"],[enable_ext_tests="no"])
158if test "x$enable_ext_tests" = "xyes" ; then
Daniel Willmann45cf0d12020-11-06 15:25:59 +0100159 AC_CHECK_PROG(PYTHON3_AVAIL,python3,yes)
160 if test "x$PYTHON3_AVAIL" != "xyes" ; then
161 AC_MSG_ERROR([Please install python3 to run the VTY/CTRL tests.])
Pau Espin Pedrol266b61a2017-11-28 20:08:17 +0100162 fi
Holger Hans Peter Freyther8fa08b02014-08-22 00:29:04 +0200163 AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmotestvty.py,yes)
164 if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then
Neels Hofmeyr684caa42017-07-20 23:01:45 +0200165 AC_MSG_ERROR([Please install git://osmocom.org/python/osmo-python-tests to run the VTY/CTRL tests.])
Katerina Barone-Adesiad5fb002013-04-05 17:36:09 +0200166 fi
167fi
Holger Hans Peter Freyther8fa08b02014-08-22 00:29:04 +0200168AC_MSG_CHECKING([whether to enable VTY/CTRL tests])
169AC_MSG_RESULT([$enable_ext_tests])
170AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
Katerina Barone-Adesiad5fb002013-04-05 17:36:09 +0200171
Oliver Smith4a1d8052018-11-14 10:47:01 +0100172# Generate manuals
173AC_ARG_ENABLE(manuals,
174 [AS_HELP_STRING(
175 [--enable-manuals],
176 [Generate manual PDFs [default=no]],
177 )],
178 [osmo_ac_build_manuals=$enableval], [osmo_ac_build_manuals="no"])
179AM_CONDITIONAL([BUILD_MANUALS], [test x"$osmo_ac_build_manuals" = x"yes"])
180AC_ARG_VAR(OSMO_GSM_MANUALS_DIR, [path to common osmo-gsm-manuals files, overriding pkg-config and "../osmo-gsm-manuals"
181 fallback])
182if test x"$osmo_ac_build_manuals" = x"yes"
183then
184 # Find OSMO_GSM_MANUALS_DIR (env, pkg-conf, fallback)
185 if test -n "$OSMO_GSM_MANUALS_DIR"; then
186 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from env)"
187 else
188 OSMO_GSM_MANUALS_DIR="$($PKG_CONFIG osmo-gsm-manuals --variable=osmogsmmanualsdir 2>/dev/null)"
189 if test -n "$OSMO_GSM_MANUALS_DIR"; then
190 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from pkg-conf)"
191 else
192 OSMO_GSM_MANUALS_DIR="../osmo-gsm-manuals"
193 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (fallback)"
194 fi
195 fi
196 if ! test -d "$OSMO_GSM_MANUALS_DIR"; then
197 AC_MSG_ERROR("OSMO_GSM_MANUALS_DIR does not exist! Install osmo-gsm-manuals or set OSMO_GSM_MANUALS_DIR.")
198 fi
199
200 # Find and run check-depends
201 CHECK_DEPENDS="$OSMO_GSM_MANUALS_DIR/check-depends.sh"
202 if ! test -x "$CHECK_DEPENDS"; then
203 CHECK_DEPENDS="osmo-gsm-manuals-check-depends"
204 fi
205 if ! $CHECK_DEPENDS; then
206 AC_MSG_ERROR("missing dependencies for --enable-manuals")
207 fi
208
209 # Put in Makefile with absolute path
210 OSMO_GSM_MANUALS_DIR="$(realpath "$OSMO_GSM_MANUALS_DIR")"
211 AC_SUBST([OSMO_GSM_MANUALS_DIR])
212fi
213
Pau Espin Pedrol6a127332018-09-10 12:40:56 +0200214# https://www.freedesktop.org/software/systemd/man/daemon.html
215AC_ARG_WITH([systemdsystemunitdir],
216 [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
217 [with_systemdsystemunitdir=auto])
218AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
219 def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
220
221 AS_IF([test "x$def_systemdsystemunitdir" = "x"],
222 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
223 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
224 with_systemdsystemunitdir=no],
225 [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
226AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
227 [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
228AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
229
Neels Hofmeyrf1474f52018-03-05 20:44:29 +0100230AC_MSG_RESULT([CFLAGS="$CFLAGS"])
231AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
232
Holger Freyther64026e92009-06-08 10:32:54 +0000233dnl Generate the output
234AM_CONFIG_HEADER(bscconfig.h)
235
Holger Freyther1bad6012008-12-27 09:42:59 +0000236AC_OUTPUT(
Holger Freyther1bad6012008-12-27 09:42:59 +0000237 include/Makefile
Neels Hofmeyr4b4c5862017-09-04 15:13:25 +0200238 include/osmocom/Makefile
239 include/osmocom/sgsn/Makefile
Holger Freyther1bad6012008-12-27 09:42:59 +0000240 src/Makefile
241 tests/Makefile
Harald Welte2d6f49d2011-05-11 22:11:28 +0200242 doc/Makefile
243 doc/examples/Makefile
Oliver Smith4a1d8052018-11-14 10:47:01 +0100244 doc/manuals/Makefile
Pau Espin Pedrol6a127332018-09-10 12:40:56 +0200245 contrib/Makefile
246 contrib/systemd/Makefile
Oliver Smith29532c22021-01-29 11:13:00 +0100247 contrib/osmo-gbproxy.spec
Holger Freyther1bad6012008-12-27 09:42:59 +0000248 Makefile)