blob: 4608db191bd5b6c8ff3ade94f609f017791675d6 [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
Alexander Couzens78e56f12021-01-01 17:04:23 +010037dnl use a defined standard across all builds and don't depend on compiler default
38CFLAGS="$CFLAGS -std=gnu11"
39
Harald Welte2b944cf2008-12-23 21:01:25 +000040dnl checks for libraries
Pau Espin Pedrol20f90672023-09-12 17:02:12 +020041PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.9.0)
42PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.9.0)
43PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.9.0)
44PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl >= 1.9.0)
45PKG_CHECK_MODULES(LIBOSMOGB, libosmogb >= 1.9.0)
Neels Hofmeyr5c8090e2015-11-29 19:14:58 +010046
Harald Welte2b944cf2008-12-23 21:01:25 +000047dnl checks for header files
48AC_HEADER_STDC
Max24ca9182017-05-02 12:59:15 +020049
Harald Welte2b944cf2008-12-23 21:01:25 +000050dnl Checks for typedefs, structures and compiler characteristics
51
Neels Hofmeyr4984c492017-11-17 01:43:36 +010052AC_ARG_ENABLE(sanitize,
53 [AS_HELP_STRING(
54 [--enable-sanitize],
55 [Compile with address sanitizer enabled],
56 )],
57 [sanitize=$enableval], [sanitize="no"])
58if test x"$sanitize" = x"yes"
59then
60 CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined"
61 CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
62fi
63
Neels Hofmeyrf1474f52018-03-05 20:44:29 +010064AC_ARG_ENABLE(werror,
65 [AS_HELP_STRING(
66 [--enable-werror],
67 [Turn all compiler warnings into errors, with exceptions:
68 a) deprecation (allow upstream to mark deprecation without breaking builds);
69 b) "#warning" pragmas (allow to remind ourselves of errors without breaking builds)
70 ]
71 )],
72 [werror=$enableval], [werror="no"])
73if test x"$werror" = x"yes"
74then
75 WERROR_FLAGS="-Werror"
76 WERROR_FLAGS+=" -Wno-error=deprecated -Wno-error=deprecated-declarations"
77 WERROR_FLAGS+=" -Wno-error=cpp" # "#warning"
78 CFLAGS="$CFLAGS $WERROR_FLAGS"
79 CPPFLAGS="$CPPFLAGS $WERROR_FLAGS"
80fi
81
Holger Freyther64026e92009-06-08 10:32:54 +000082# The following test is taken from WebKit's webkit.m4
83saved_CFLAGS="$CFLAGS"
84CFLAGS="$CFLAGS -fvisibility=hidden "
85AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
Alexander Huemer93ae2d62011-05-24 15:16:54 +020086AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
Holger Freyther64026e92009-06-08 10:32:54 +000087 [ AC_MSG_RESULT([yes])
88 SYMBOL_VISIBILITY="-fvisibility=hidden"],
89 AC_MSG_RESULT([no]))
90CFLAGS="$saved_CFLAGS"
91AC_SUBST(SYMBOL_VISIBILITY)
92
Daniel Willmann3696dce2020-12-02 16:08:02 +010093CPPFLAGS="$CPPFLAGS -Wall -Wno-trigraphs"
94CFLAGS="$CFLAGS -Wall -Wno-trigraphs"
Pau Espin Pedrolcec01d32018-01-07 18:24:34 +010095
Holger Hans Peter Freyther16bdb142010-11-15 18:37:57 +010096# Coverage build taken from WebKit's configure.in
97AC_MSG_CHECKING([whether to enable code coverage support])
98AC_ARG_ENABLE(coverage,
99 AC_HELP_STRING([--enable-coverage],
100 [enable code coverage support [default=no]]),
101 [],[enable_coverage="no"])
102AC_MSG_RESULT([$enable_coverage])
103if test "$enable_coverage" = "yes"; then
104 COVERAGE_CFLAGS="-ftest-coverage -fprofile-arcs"
105 COVERAGE_LDFLAGS="-ftest-coverage -fprofile-arcs"
106 AC_SUBST([COVERAGE_CFLAGS])
107 AC_SUBST([COVERAGE_LDFLAGS])
108fi
109
Harald Welteeaf4a522012-04-08 16:59:24 +0200110AC_DEFUN([CHECK_TM_INCLUDES_TM_GMTOFF], [
111 AC_CACHE_CHECK(
112 [whether struct tm has tm_gmtoff member],
113 osmo_cv_tm_includes_tm_gmtoff,
114 [AC_LINK_IFELSE([
115 AC_LANG_PROGRAM([
116 #include <time.h>
117 ], [
118 time_t t = time(NULL);
119 struct tm* lt = localtime(&t);
120 int off = lt->tm_gmtoff;
121 ])
122 ],
123 osmo_cv_tm_includes_tm_gmtoff=yes,
124 osmo_cv_tm_includes_tm_gmtoff=no
125 )]
126 )
127 if test "x$osmo_cv_tm_includes_tm_gmtoff" = xyes; then
128 AC_DEFINE(HAVE_TM_GMTOFF_IN_TM, 1,
129 [Define if struct tm has tm_gmtoff member.])
130 fi
131])
132
133CHECK_TM_INCLUDES_TM_GMTOFF
Holger Freyther64026e92009-06-08 10:32:54 +0000134
Pablo Neira Ayuso7194f632014-09-01 09:34:07 +0200135AC_ARG_ENABLE([external_tests],
Holger Hans Peter Freyther8fa08b02014-08-22 00:29:04 +0200136 AC_HELP_STRING([--enable-external-tests],
137 [Include the VTY/CTRL tests in make check [default=no]]),
138 [enable_ext_tests="$enableval"],[enable_ext_tests="no"])
139if test "x$enable_ext_tests" = "xyes" ; then
Daniel Willmann45cf0d12020-11-06 15:25:59 +0100140 AC_CHECK_PROG(PYTHON3_AVAIL,python3,yes)
141 if test "x$PYTHON3_AVAIL" != "xyes" ; then
142 AC_MSG_ERROR([Please install python3 to run the VTY/CTRL tests.])
Pau Espin Pedrol266b61a2017-11-28 20:08:17 +0100143 fi
Holger Hans Peter Freyther8fa08b02014-08-22 00:29:04 +0200144 AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmotestvty.py,yes)
145 if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then
Harald Welte3cc70e62022-06-18 12:03:12 +0200146 AC_MSG_ERROR([Please install https://gitea.osmocom.org/cellular-infrastructure/osmo-python-tests to run the VTY/CTRL tests.])
Katerina Barone-Adesiad5fb002013-04-05 17:36:09 +0200147 fi
148fi
Holger Hans Peter Freyther8fa08b02014-08-22 00:29:04 +0200149AC_MSG_CHECKING([whether to enable VTY/CTRL tests])
150AC_MSG_RESULT([$enable_ext_tests])
151AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
Katerina Barone-Adesiad5fb002013-04-05 17:36:09 +0200152
Oliver Smith4a1d8052018-11-14 10:47:01 +0100153# Generate manuals
154AC_ARG_ENABLE(manuals,
155 [AS_HELP_STRING(
156 [--enable-manuals],
157 [Generate manual PDFs [default=no]],
158 )],
159 [osmo_ac_build_manuals=$enableval], [osmo_ac_build_manuals="no"])
160AM_CONDITIONAL([BUILD_MANUALS], [test x"$osmo_ac_build_manuals" = x"yes"])
161AC_ARG_VAR(OSMO_GSM_MANUALS_DIR, [path to common osmo-gsm-manuals files, overriding pkg-config and "../osmo-gsm-manuals"
162 fallback])
163if test x"$osmo_ac_build_manuals" = x"yes"
164then
165 # Find OSMO_GSM_MANUALS_DIR (env, pkg-conf, fallback)
166 if test -n "$OSMO_GSM_MANUALS_DIR"; then
167 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from env)"
168 else
169 OSMO_GSM_MANUALS_DIR="$($PKG_CONFIG osmo-gsm-manuals --variable=osmogsmmanualsdir 2>/dev/null)"
170 if test -n "$OSMO_GSM_MANUALS_DIR"; then
171 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from pkg-conf)"
172 else
173 OSMO_GSM_MANUALS_DIR="../osmo-gsm-manuals"
174 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (fallback)"
175 fi
176 fi
177 if ! test -d "$OSMO_GSM_MANUALS_DIR"; then
178 AC_MSG_ERROR("OSMO_GSM_MANUALS_DIR does not exist! Install osmo-gsm-manuals or set OSMO_GSM_MANUALS_DIR.")
179 fi
180
181 # Find and run check-depends
182 CHECK_DEPENDS="$OSMO_GSM_MANUALS_DIR/check-depends.sh"
183 if ! test -x "$CHECK_DEPENDS"; then
184 CHECK_DEPENDS="osmo-gsm-manuals-check-depends"
185 fi
186 if ! $CHECK_DEPENDS; then
187 AC_MSG_ERROR("missing dependencies for --enable-manuals")
188 fi
189
190 # Put in Makefile with absolute path
191 OSMO_GSM_MANUALS_DIR="$(realpath "$OSMO_GSM_MANUALS_DIR")"
192 AC_SUBST([OSMO_GSM_MANUALS_DIR])
193fi
194
Pau Espin Pedrol6a127332018-09-10 12:40:56 +0200195# https://www.freedesktop.org/software/systemd/man/daemon.html
196AC_ARG_WITH([systemdsystemunitdir],
197 [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
198 [with_systemdsystemunitdir=auto])
199AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
200 def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
201
202 AS_IF([test "x$def_systemdsystemunitdir" = "x"],
203 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
204 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
205 with_systemdsystemunitdir=no],
206 [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
207AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
208 [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
209AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
210
Neels Hofmeyrf1474f52018-03-05 20:44:29 +0100211AC_MSG_RESULT([CFLAGS="$CFLAGS"])
212AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
213
Holger Freyther64026e92009-06-08 10:32:54 +0000214dnl Generate the output
215AM_CONFIG_HEADER(bscconfig.h)
216
Holger Freyther1bad6012008-12-27 09:42:59 +0000217AC_OUTPUT(
Holger Freyther1bad6012008-12-27 09:42:59 +0000218 include/Makefile
Neels Hofmeyr4b4c5862017-09-04 15:13:25 +0200219 include/osmocom/Makefile
Daniel Willmanna16ecc32021-03-10 09:57:12 +0100220 include/osmocom/gbproxy/Makefile
Holger Freyther1bad6012008-12-27 09:42:59 +0000221 src/Makefile
222 tests/Makefile
Harald Welte2d6f49d2011-05-11 22:11:28 +0200223 doc/Makefile
224 doc/examples/Makefile
Oliver Smith4a1d8052018-11-14 10:47:01 +0100225 doc/manuals/Makefile
Pau Espin Pedrol6a127332018-09-10 12:40:56 +0200226 contrib/Makefile
227 contrib/systemd/Makefile
Oliver Smith29532c22021-01-29 11:13:00 +0100228 contrib/osmo-gbproxy.spec
Holger Freyther1bad6012008-12-27 09:42:59 +0000229 Makefile)