blob: 29a957020149bf53d54867434b150b8ac7eb05f3 [file] [log] [blame]
Harald Welte4cd3d8a2010-03-23 00:30:19 +08001AC_INIT([libosmocore],
2 m4_esyscmd([./git-version-gen .tarball-version]),
Holger Hans Peter Freyther8db70202012-03-26 16:34:37 +02003 [openbsc@lists.osmocom.org])
Harald Welte3cae0392010-02-20 21:09:24 +01004
Neels Hofmeyrcbdfa652016-09-30 23:45:28 +02005dnl *This* is the root dir, even if an install-sh exists in ../ or ../../
6AC_CONFIG_AUX_DIR([.])
7
Sylvain Munaut69b1b8b2015-08-19 11:15:14 +02008AM_INIT_AUTOMAKE([foreign dist-bzip2 no-dist-gzip 1.6 subdir-objects])
Holger Hans Peter Freytherf9eda742011-11-13 01:02:54 +01009AC_CONFIG_TESTDIR(tests)
Harald Welte3cae0392010-02-20 21:09:24 +010010
Oliver Smithf2afb982021-01-21 11:42:40 +010011CFLAGS="$CFLAGS -std=gnu11"
12
Harald Welte3cae0392010-02-20 21:09:24 +010013dnl kernel style compile messages
14m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
15
Maxff932bb2017-07-04 18:19:38 +020016dnl include release helper
17RELMAKE='-include osmo-release.mk'
18AC_SUBST([RELMAKE])
19
Harald Welte3cae0392010-02-20 21:09:24 +010020dnl checks for programs
21AC_PROG_MAKE_SET
Diego Elio Pettenòd471a212012-06-29 13:01:19 -070022AC_PROG_MKDIR_P
Harald Welte3cae0392010-02-20 21:09:24 +010023AC_PROG_CC
24AC_PROG_INSTALL
Jan Engelhardtc2ddc4f2015-09-16 14:32:31 +020025LT_INIT([pic-only disable-static])
Harald Welte3cae0392010-02-20 21:09:24 +010026
Harald Welte4cd3d8a2010-03-23 00:30:19 +080027AC_CONFIG_MACRO_DIR([m4])
28
Eric099c8342020-04-10 22:10:13 +020029dnl patching ${archive_cmds} to affect generation of file "libtool" to fix linking with clang
30AS_CASE(["$LD"],[*clang*],
31 [AS_CASE(["${host_os}"],
32 [*linux*],[archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'])])
33
Neels Hofmeyrfef2fa22016-08-08 15:38:35 +020034dnl check for pkg-config
35dnl * If pkg-config is missing, we get a "syntax error" for PKG_CHECK_MODULES.
36dnl Instead, we want to say that pkg-config and pkg.m4 are missing.
37dnl * The proper way is PKG_PROG_PKG_CONFIG() but unfortunately that does not
38dnl produce an intelligible error message if pkg-config is missing entirely
39dnl ("syntax error near unexpected token `0.20'").
40dnl * To produce a hint that pkg-config is missing, check for the pkg-config
41dnl binary; but AC_PATH_PROG breaks if the distribution provides only
42dnl prefixed (<arch>-pkg-config) versions, so just print a warning.
43AC_PATH_PROG(PKG_CONFIG_INSTALLED, pkg-config, no)
44if test "x$PKG_CONFIG_INSTALLED" = "xno"; then
45 AC_MSG_WARN([You need to install pkg-config])
46fi
47PKG_PROG_PKG_CONFIG([0.20])
48
Tobias Engel597460f2012-10-24 17:52:52 +020049dnl check os: some linker flags not available on osx
50case $host in
51*-darwin*)
52 ;;
53*)
54 LTLDFLAGS_OSMOGB='-Wl,--version-script=$(srcdir)/libosmogb.map'
55 LTLDFLAGS_OSMOGSM='-Wl,--version-script=$(srcdir)/libosmogsm.map'
Harald Welted55a2092022-11-29 22:33:54 +010056 LTLDFLAGS_OSMOISDN='-Wl,--version-script=$(srcdir)/libosmoisdn.map'
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070057 LTLDFLAGS_OSMOCODING='-Wl,--version-script=$(srcdir)/libosmocoding.map'
Daniel Willmann213fc422023-02-03 07:44:55 +010058 LTLDFLAGS_OSMOCORE='-Wl,--version-script=$(srcdir)/libosmocore.map'
Harald Welteed605782018-05-26 17:07:39 +020059 LTLDFLAGS_OSMOCTRL='-Wl,--version-script=$(srcdir)/libosmoctrl.map'
Tobias Engel597460f2012-10-24 17:52:52 +020060 ;;
61esac
62AC_SUBST(LTLDFLAGS_OSMOGB)
63AC_SUBST(LTLDFLAGS_OSMOGSM)
Harald Welted55a2092022-11-29 22:33:54 +010064AC_SUBST(LTLDFLAGS_OSMOISDN)
Vadim Yanitskiy272bd4f2017-08-31 17:53:04 +070065AC_SUBST(LTLDFLAGS_OSMOCODING)
Daniel Willmann213fc422023-02-03 07:44:55 +010066AC_SUBST(LTLDFLAGS_OSMOCORE)
Harald Welteed605782018-05-26 17:07:39 +020067AC_SUBST(LTLDFLAGS_OSMOCTRL)
Tobias Engel597460f2012-10-24 17:52:52 +020068
Harald Welte3cae0392010-02-20 21:09:24 +010069dnl checks for header files
70AC_HEADER_STDC
Harald Weltee4cd2672019-08-06 19:56:16 +020071AC_CHECK_HEADERS(execinfo.h poll.h sys/select.h sys/socket.h sys/signalfd.h sys/eventfd.h sys/timerfd.h syslog.h ctype.h netinet/tcp.h netinet/in.h)
Andreas Eversbergbb20d4e2023-06-09 15:21:56 +020072AC_CHECK_DECL(HAVE_SYS_SOCKET_H, AC_SUBST(HAVE_SYS_SOCKET_H, 1), AC_SUBST(HAVE_SYS_SOCKET_H, 0))
Holger Hans Peter Freyther47723482011-11-09 11:26:15 +010073# for src/conv.c
74AC_FUNC_ALLOCA
Pau Espin Pedrolcacaa4a2018-05-04 19:21:58 +020075AC_SEARCH_LIBS([dlopen], [dl dld], [LIBRARY_DLOPEN="$LIBS";LIBS=""])
76AC_SUBST(LIBRARY_DLOPEN)
77AC_SEARCH_LIBS([dlsym], [dl dld], [LIBRARY_DLSYM="$LIBS";LIBS=""])
78AC_SUBST(LIBRARY_DLSYM)
Holger Hans Peter Freytherc2c042d2014-04-17 23:19:10 +020079# for src/backtrace.c
80AC_CHECK_LIB(execinfo, backtrace, BACKTRACE_LIB=-lexecinfo, BACKTRACE_LIB=)
81AC_SUBST(BACKTRACE_LIB)
Harald Welte3cae0392010-02-20 21:09:24 +010082
Pau Espin Pedrold12f6982019-09-17 18:38:58 +020083# check for pthread (PTHREAD_CFLAGS, PTHREAD_LIBS)
84AX_PTHREAD
85
Harald Weltec17546f2022-03-28 15:38:28 +020086AC_MSG_CHECKING(for pthread_getname_np(pthread_t, char*, size_t))
87saved_CFLAGS="$CFLAGS"
88saved_LIBS="$LIBS"
89CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
90LIBS="$LIBS $PTHREAD_LIBS"
91AC_LINK_IFELSE(
92 [AC_LANG_PROGRAM(
93 [#define _GNU_SOURCE
94 #include <pthread.h>],
95 [pthread_getname_np(pthread_self(),"example",0)])],
96 [AC_MSG_RESULT(yes)
97 AC_DEFINE(HAVE_PTHREAD_GETNAME_NP,1,
98 [Have function pthread_setname_np(const char*)])],
99 [AC_MSG_RESULT(no)])
100CFLAGS="$saved_CFLAGS"
101LIBS="$saved_LIBS"
102
103
Alexander Couzensa2f696f2018-04-24 16:15:23 +0200104# check for old glibc < 2.17 to get clock_gettime
Pau Espin Pedrol47eb4e12020-05-01 16:51:20 +0200105AC_SEARCH_LIBS([clock_gettime], [rt posix4],
106 [AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if clock_gettime is available])
107 LIBRARY_RT="$LIBS";LIBS="";])
Alexander Couzensa2f696f2018-04-24 16:15:23 +0200108AC_SUBST(LIBRARY_RT)
109
Pau Espin Pedrol639c4082017-07-06 10:45:22 +0200110AC_ARG_ENABLE(doxygen,
111 [AS_HELP_STRING(
112 [--disable-doxygen],
113 [Disable generation of documentation using doxygen],
114 )],
115 [doxygen=$enableval], [doxygen="yes"])
Harald Welte21e73c22011-08-17 19:33:06 +0200116AC_PATH_PROG(DOXYGEN,doxygen,false)
Pau Espin Pedrol639c4082017-07-06 10:45:22 +0200117AM_CONDITIONAL(HAVE_DOXYGEN, test $DOXYGEN != false && test "x$doxygen" = "xyes")
Harald Welte21e73c22011-08-17 19:33:06 +0200118
Max4b2b0cc2017-07-10 14:32:48 +0200119# check for syscal fallback on glibc < 2.25 - can be removed once glibc version requirement is bumped
120AC_CHECK_DECLS([SYS_getrandom], [], [], [[#include <sys/syscall.h>]])
121
Harald Welte3cae0392010-02-20 21:09:24 +0100122# The following test is taken from WebKit's webkit.m4
123saved_CFLAGS="$CFLAGS"
124CFLAGS="$CFLAGS -fvisibility=hidden "
125AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
Alexander Huemer3d79f532011-05-24 15:16:13 +0200126AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
Harald Welte3cae0392010-02-20 21:09:24 +0100127 [ AC_MSG_RESULT([yes])
128 SYMBOL_VISIBILITY="-fvisibility=hidden"],
129 AC_MSG_RESULT([no]))
130CFLAGS="$saved_CFLAGS"
131AC_SUBST(SYMBOL_VISIBILITY)
132
Pau Espin Pedrol47eb4e12020-05-01 16:51:20 +0200133AC_CHECK_FUNCS(localtime_r)
Harald Welte14c4c492018-06-28 08:28:52 +0200134
Harald Welte7c8e2cc2012-08-29 16:47:30 +0200135AC_DEFUN([CHECK_TM_INCLUDES_TM_GMTOFF], [
136 AC_CACHE_CHECK(
137 [whether struct tm has tm_gmtoff member],
138 osmo_cv_tm_includes_tm_gmtoff,
139 [AC_LINK_IFELSE([
140 AC_LANG_PROGRAM([
141 #include <time.h>
142 ], [
143 time_t t = time(NULL);
144 struct tm* lt = localtime(&t);
145 int off = lt->tm_gmtoff;
146 ])
147 ],
148 osmo_cv_tm_includes_tm_gmtoff=yes,
149 osmo_cv_tm_includes_tm_gmtoff=no
150 )]
151 )
152 if test "x$osmo_cv_tm_includes_tm_gmtoff" = xyes; then
153 AC_DEFINE(HAVE_TM_GMTOFF_IN_TM, 1,
154 [Define if struct tm has tm_gmtoff member.])
155 fi
156])
157
158CHECK_TM_INCLUDES_TM_GMTOFF
159
Pau Espin Pedrol88e40582021-02-17 17:46:02 +0100160# Check if gettid is available (despite not being documented in glibc doc,
161# it requires __USE_GNU on some systems)
162# C compiler is used since __USE_GNU seems to be always defined for g++.
163save_CPPFLAGS=$CPPFLAGS
164AC_LANG_PUSH(C)
165CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
166AC_CHECK_FUNCS([gettid])
167AC_LANG_POP(C)
168CPPFLAGS=$save_CPPFLAGS
169
Pau Espin Pedrole188b8c2019-08-05 13:46:33 +0200170dnl Check if We need to apply workaround for TLS bug on ARM platform for GCC < 7.3.0:
Pau Espin Pedrolafce89d2019-08-06 12:46:46 +0200171ARG_ENABLE_DETECT_TLS_GCC_ARM_BUG
Pau Espin Pedrole188b8c2019-08-05 13:46:33 +0200172
Harald Welte3cae0392010-02-20 21:09:24 +0100173dnl Generate the output
Christian Vogel854debc2013-01-05 20:30:41 +0100174AC_CONFIG_HEADER(config.h)
Harald Welte3cae0392010-02-20 21:09:24 +0100175
Pau Espin Pedrol75b03e52021-10-28 15:11:32 +0200176PKG_CHECK_MODULES(TALLOC, [talloc >= 2.1.0])
Harald Welte90e614f2015-12-05 23:38:18 +0100177
Daniel Willmannf91d2aa2023-01-04 18:20:55 +0100178AC_ARG_ENABLE([uring], [AS_HELP_STRING([--disable-uring], [Build without io_uring support])],
179 [
180 ENABLE_URING=$enableval
181 ],
182 [
183 ENABLE_URING="yes"
184 ])
185AS_IF([test "x$ENABLE_URING" = "xyes"], [
186 PKG_CHECK_MODULES(URING, [liburing >= 0.7])
187 AC_DEFINE([HAVE_URING],[1],[Build with io_uring support])
188])
189AM_CONDITIONAL(ENABLE_URING, test "x$ENABLE_URING" = "xyes")
190AC_SUBST(ENABLE_URING)
191
Harald Welte495fe262012-09-10 16:28:17 +0200192AC_ARG_ENABLE([pcsc], [AS_HELP_STRING([--disable-pcsc], [Build without PC/SC support])],
193 [
Neels Hofmeyr96831042016-11-15 17:31:14 +0100194 ENABLE_PCSC=$enableval
Harald Welte495fe262012-09-10 16:28:17 +0200195 ],
196 [
Neels Hofmeyr96831042016-11-15 17:31:14 +0100197 ENABLE_PCSC="yes"
Harald Welte495fe262012-09-10 16:28:17 +0200198 ])
Neels Hofmeyr96831042016-11-15 17:31:14 +0100199AS_IF([test "x$ENABLE_PCSC" = "xyes"], [
Holger Hans Peter Freyther18bcc8a2014-11-14 15:06:09 +0100200 PKG_CHECK_MODULES(PCSC, libpcsclite)
Harald Welte3c44a642020-03-15 22:50:06 +0100201 AC_DEFINE([HAVE_PCSC],[1],[Build with PC/SC support])
Harald Welted086f212015-11-21 11:38:09 +0100202])
Neels Hofmeyr96831042016-11-15 17:31:14 +0100203AM_CONDITIONAL(ENABLE_PCSC, test "x$ENABLE_PCSC" = "xyes")
204AC_SUBST(ENABLE_PCSC)
Harald Welte495fe262012-09-10 16:28:17 +0200205
Harald Welteda432cd2019-12-15 19:13:26 +0100206AC_ARG_ENABLE([libusb], [AS_HELP_STRING([--disable-libusb], [Build without libusb support])],
207 [
208 ENABLE_LIBUSB=$enableval
209 ],
210 [
211 ENABLE_LIBUSB="yes"
212 ])
213AS_IF([test "x$ENABLE_LIBUSB" = "xyes"], [
214 PKG_CHECK_MODULES(LIBUSB, libusb-1.0)
215])
216AM_CONDITIONAL(ENABLE_LIBUSB, test "x$ENABLE_LIBUSB" = "xyes")
217AC_SUBST(ENABLE_LIBUSB)
218
Maxed029df2017-10-26 10:56:04 +0200219AC_ARG_ENABLE([gnutls], [AS_HELP_STRING([--disable-gnutls], [Do not use GnuTLS fallback for missing getrandom()])],
220 [ENABLE_GNUTLS=$enableval], [ENABLE_GNUTLS="yes"])
221AM_CONDITIONAL(ENABLE_GNUTLS, test x"$ENABLE_GNUTLS" = x"yes")
222AS_IF([test "x$ENABLE_GNUTLS" = "xyes"], [
223 PKG_CHECK_MODULES([LIBGNUTLS], [gnutls >= 2.12.0])
224])
225AC_SUBST(ENABLE_GNUTLS)
226if test x"$ENABLE_GNUTLS" = x"yes"
227then
228 AC_SUBST([LIBGNUTLS_CFLAGS])
229 AC_SUBST([LIBGNUTLS_LIBS])
230 AC_DEFINE([USE_GNUTLS], [1], [Use GnuTLS as a fallback for missing getrandom()])
231fi
232
Vadim Yanitskiye7bf4352020-09-09 03:36:48 +0700233AC_ARG_ENABLE([systemd_logging],
234 [AS_HELP_STRING(
235 [--enable-systemd-logging],
236 [Build with systemd-journal logging support]
237 )],
238 [systemd_logging=$enableval], [systemd_logging="no"])
239AS_IF([test "x$systemd_logging" = "xyes"], [
240 PKG_CHECK_MODULES(SYSTEMD, libsystemd)
241 AC_DEFINE([ENABLE_SYSTEMD_LOGGING], [1], [Enable systemd-journal logging target])
242])
243AM_CONDITIONAL(ENABLE_SYSTEMD_LOGGING, test "x$systemd_logging" = "xyes")
244AC_SUBST(ENABLE_SYSTEMD_LOGGING)
245
Harald Welte53a2fde2020-12-01 22:21:14 +0100246AC_ARG_ENABLE([libmnl],
247 [AS_HELP_STRING(
248 [--disable-libmnl],
249 [Build without netlink socket support via libmnl]
250 )],
251 [mnl=$enableval], [mnl="yes"])
252AS_IF([test "x$mnl" = "xyes"], [
Pau Espin Pedrol4eb89af2023-01-25 17:02:05 +0100253 PKG_CHECK_MODULES(LIBMNL, libmnl, [AC_SUBST(LIBMNL_PC, [libmnl])])
Harald Welte53a2fde2020-12-01 22:21:14 +0100254 AC_DEFINE([ENABLE_LIBMNL], [1], [Enable netlink socket support via libmnl])
255])
256AM_CONDITIONAL(ENABLE_LIBMNL, test "x$mnl" = "xyes")
257AC_SUBST(ENABLE_LIBMNL)
258
Pau Espin Pedrolea2afb22019-10-24 15:41:32 +0200259AC_ARG_ENABLE([libsctp], [AS_HELP_STRING([--disable-libsctp], [Do not enable socket multiaddr APIs requiring libsctp])],
260 [ENABLE_LIBSCTP=$enableval], [ENABLE_LIBSCTP="yes"])
261AM_CONDITIONAL(ENABLE_LIBSCTP, test x"$ENABLE_LIBSCTP" = x"yes")
262AS_IF([test "x$ENABLE_LIBSCTP" = "xyes"], [
Pau Espin Pedrolc80a0042022-03-29 11:56:43 +0200263 AC_DEFINE(HAVE_LIBSCTP, 1, [Define 1 to enable SCTP support])
264 # Attempt finding .pc, otherwise set manually (<1.0.17 have no .pc file)
265 PKG_CHECK_MODULES(LIBSCTP, libsctp,
266 [AC_SUBST(LIBSCTP_PC, [libsctp])],
267 [
268 AC_MSG_NOTICE([libsctp.pc not found (building against <1.0.17 ?), attempting manual lib lookup])
269 old_LIBS=$LIBS
270 AC_SEARCH_LIBS([sctp_bindx], [sctp], [
271 AC_SUBST(HAVE_LIBSCTP, [1])
272 if test -n "$ac_lib"; then
273 AC_SUBST(LIBSCTP_LIBS, [-l$ac_lib])
274 fi
275 ], [
276 AC_MSG_ERROR([sctp_bindx not found in searched libs])])
277 LIBS=$old_LIBS
278 ])
Pau Espin Pedrolea2afb22019-10-24 15:41:32 +0200279])
280
Pau Espin Pedrol16b076c2020-08-25 13:56:43 +0200281AC_ARG_ENABLE([sctp-tests], [AS_HELP_STRING([--disable-sctp-tests], [Do not run socket tests requiring system SCTP support])],
282 [ENABLE_SCTP_TESTS=$enableval], [ENABLE_SCTP_TESTS="yes"])
283AM_CONDITIONAL(ENABLE_SCTP_TESTS, test x"$ENABLE_SCTP_TESTS" = x"yes")
284
Harald Welteb9ce51c2010-06-30 19:43:11 +0200285AC_ARG_ENABLE(plugin,
Sylvain Munautf23abab2010-07-25 16:16:42 +0200286 [AS_HELP_STRING(
287 [--disable-plugin],
288 [Disable support for dlopen plugins],
289 )],
job36b4a202011-08-21 17:18:23 +0200290 [enable_plugin=$enableval], [enable_plugin="yes"])
291AM_CONDITIONAL(ENABLE_PLUGIN, test x"$enable_plugin" = x"yes")
Harald Welteb9ce51c2010-06-30 19:43:11 +0200292
Harald Welte1067e8c2010-06-25 03:00:58 +0200293AC_ARG_ENABLE(vty,
Sylvain Munautf23abab2010-07-25 16:16:42 +0200294 [AS_HELP_STRING(
295 [--disable-vty],
296 [Disable building VTY telnet interface]
297 )],
job36b4a202011-08-21 17:18:23 +0200298 [enable_vty=$enableval], [enable_vty="yes"])
299AM_CONDITIONAL(ENABLE_VTY, test x"$enable_vty" = x"yes")
Harald Welte54403772010-05-29 11:49:51 +0200300
Sylvain Munautac3e61a2010-07-25 18:08:54 +0200301AC_ARG_ENABLE(panic_infloop,
302 [AS_HELP_STRING(
303 [--enable-panic-infloop],
304 [Trigger infinite loop on panic rather than fprintf/abort]
305 )],
job36b4a202011-08-21 17:18:23 +0200306 [panic_infloop=$enableval], [panic_infloop="no"])
307if test x"$panic_infloop" = x"yes"
Sylvain Munautac3e61a2010-07-25 18:08:54 +0200308then
309 AC_DEFINE([PANIC_INFLOOP],[1],[Use infinite loop on panic rather than fprintf/abort])
310fi
311
Holger Hans Peter Freyther43558312010-08-06 06:48:43 +0800312AC_ARG_ENABLE(bsc_fd_check,
313 [AS_HELP_STRING(
Pau Espin Pedrol5ef158f2023-03-14 12:38:13 +0100314 [--enable-ofd-check],
Pau Espin Pedrold05def02020-05-09 19:24:21 +0200315 [Instrument osmo_fd_register to check that the fd is registered]
Holger Hans Peter Freyther43558312010-08-06 06:48:43 +0800316 )],
job36b4a202011-08-21 17:18:23 +0200317 [fd_check=$enableval], [fd_check="no"])
Pau Espin Pedrol5ef158f2023-03-14 12:38:13 +0100318if test x"$fd_check" = x"yes"
Holger Hans Peter Freyther43558312010-08-06 06:48:43 +0800319then
Pau Espin Pedrol5ef158f2023-03-14 12:38:13 +0100320 AC_DEFINE([OSMO_FD_CHECK], [1], [Instrument the osmo_fd_register])
Holger Hans Peter Freyther43558312010-08-06 06:48:43 +0800321fi
322
Harald Welteb904e422020-10-18 21:24:13 +0200323AC_ARG_ENABLE([force_io_select],
324 [AS_HELP_STRING(
325 [--enable-force-io-select],
326 [Build with old select I/O instead of poll]
327 )],
328 [force_io_select=$enableval], [force_io_select="no"])
329AS_IF([test "x$force_io_select" = "xyes"], [
Pau Espin Pedrol3b450f02023-03-14 12:42:24 +0100330 AC_DEFINE([FORCE_IO_SELECT], [1], [Force the use of select() instead of poll()])
Harald Welteb904e422020-10-18 21:24:13 +0200331])
332
Holger Hans Peter Freytherc87f2662010-10-07 00:00:15 +0800333AC_ARG_ENABLE(msgfile,
334 [AS_HELP_STRING(
335 [--disable-msgfile],
336 [Disable support for the msgfile],
337 )],
job36b4a202011-08-21 17:18:23 +0200338 [enable_msgfile=$enableval], [enable_msgfile="yes"])
339AM_CONDITIONAL(ENABLE_MSGFILE, test x"$enable_msgfile" = x"yes")
Holger Hans Peter Freytherc87f2662010-10-07 00:00:15 +0800340
Sylvain Munautfe28ded2011-09-02 22:18:24 +0200341AC_ARG_ENABLE(serial,
342 [AS_HELP_STRING(
343 [--disable-serial],
344 [Disable support for the serial helpers],
345 )],
346 [enable_serial=$enableval], [enable_serial="yes"])
347AM_CONDITIONAL(ENABLE_SERIAL, test x"$enable_serial" = x"yes")
348
job8e4deb62011-08-21 17:18:24 +0200349AC_ARG_ENABLE(utilities,
350 [AS_HELP_STRING(
351 [--disable-utilities],
352 [Disable building utility programs],
353 )],
354 [enable_utilities=$enableval], [enable_utilities="yes"])
355AM_CONDITIONAL(ENABLE_UTILITIES, test x"$enable_utilities" = x"yes")
356
Harald Weltee3a10b62012-09-08 22:18:43 +0200357AC_ARG_ENABLE(gb,
358 [AS_HELP_STRING(
359 [--disable-gb],
360 [Disable building Gb library],
361 )],
362 [enable_gb=$enableval], [enable_gb="yes"])
363AM_CONDITIONAL(ENABLE_GB, test x"$enable_gb" = x"yes")
364
Harald Welte1c67e752017-01-15 17:52:30 +0100365AC_ARG_ENABLE(ctrl,
366 [AS_HELP_STRING(
367 [--disable-ctrl],
368 [Disable building CTRL library],
369 )],
370 [enable_ctrl=$enableval], [enable_ctrl="yes"])
371AM_CONDITIONAL(ENABLE_CTRL, test x"$enable_ctrl" = x"yes")
372
Harald Welte898ffef2017-05-15 21:37:34 +0200373AC_ARG_ENABLE(pseudotalloc,
374 [AS_HELP_STRING(
375 [--enable-pseudotalloc],
376 [Enable building pseudotalloc library],
377 )],
378 [enable_pseudotalloc=$enableval], [enable_pseudotalloc="no"])
379AM_CONDITIONAL(ENABLE_PSEUDOTALLOC, test x"$enable_pseudotalloc" = x"yes")
380
job8e4deb62011-08-21 17:18:24 +0200381AC_ARG_ENABLE(embedded,
382 [AS_HELP_STRING(
383 [--enable-embedded],
384 [Enable building for embedded use and disable unsupported features]
385 )],
386 [embedded=$enableval], [embedded="no"])
Max89c8c402018-01-18 16:05:27 +0100387
Harald Weltec6a86972019-12-16 23:14:45 +0100388AM_CONDITIONAL(EMBEDDED, false)
Max3da79382018-01-18 16:50:51 +0100389AM_CONDITIONAL(ENABLE_SERCOM_STUB, false)
Max89c8c402018-01-18 16:05:27 +0100390
job8e4deb62011-08-21 17:18:24 +0200391if test x"$embedded" = x"yes"
392then
393 AC_DEFINE([EMBEDDED],[1],[Select building for embedded use])
job8e4deb62011-08-21 17:18:24 +0200394 AM_CONDITIONAL(ENABLE_PLUGIN, false)
395 AM_CONDITIONAL(ENABLE_MSGFILE, false)
Sylvain Munautfe28ded2011-09-02 22:18:24 +0200396 AM_CONDITIONAL(ENABLE_SERIAL, false)
Maxed029df2017-10-26 10:56:04 +0200397 AM_CONDITIONAL(ENABLE_GNUTLS, false)
job8e4deb62011-08-21 17:18:24 +0200398 AM_CONDITIONAL(ENABLE_VTY, false)
Harald Welte1c67e752017-01-15 17:52:30 +0100399 AM_CONDITIONAL(ENABLE_CTRL, false)
job8e4deb62011-08-21 17:18:24 +0200400 AM_CONDITIONAL(ENABLE_UTILITIES, false)
Harald Weltee3a10b62012-09-08 22:18:43 +0200401 AM_CONDITIONAL(ENABLE_GB, false)
Sylvain Munaut90370562022-04-29 08:15:09 +0200402 AM_CONDITIONAL(ENABLE_LIBMNL, false)
Pau Espin Pedrolea2afb22019-10-24 15:41:32 +0200403 AM_CONDITIONAL(ENABLE_LIBSCTP, false)
Sylvain Munaut90370562022-04-29 08:15:09 +0200404 AM_CONDITIONAL(ENABLE_LIBUSB, false)
Harald Welte1a7d64c2017-01-15 17:53:23 +0100405 AM_CONDITIONAL(ENABLE_PCSC, false)
Daniel Willmann128bec32023-10-24 09:45:21 +0200406 AM_CONDITIONAL(ENABLE_URING, false)
Harald Welte898ffef2017-05-15 21:37:34 +0200407 AM_CONDITIONAL(ENABLE_PSEUDOTALLOC, true)
Max3da79382018-01-18 16:50:51 +0100408 AM_CONDITIONAL(ENABLE_SERCOM_STUB, true)
Harald Weltec6a86972019-12-16 23:14:45 +0100409 AM_CONDITIONAL(EMBEDDED, true)
Maxed029df2017-10-26 10:56:04 +0200410 AC_DEFINE([USE_GNUTLS], [0])
job8e4deb62011-08-21 17:18:24 +0200411 AC_DEFINE([PANIC_INFLOOP],[1],[Use infinite loop on panic rather than fprintf/abort])
412fi
Harald Welte54403772010-05-29 11:49:51 +0200413
Eric Wild63e1b2b2021-11-26 21:09:01 +0100414AC_ARG_ENABLE(log_macros,
415 [AS_HELP_STRING(
416 [--disable-log-macros],
417 [Disable logging macros that are also used internally to print information]
418 )],
419 [log_macros="yes"], [log_macros="no"])
420if test x"$log_macros" == x"yes"
421then
422 AC_DEFINE([LIBOSMOCORE_NO_LOGGING],[1],[Disable logging macros])
423fi
424
Neels Hofmeyra2381762016-09-30 01:25:45 +0200425AC_ARG_ENABLE(sanitize,
426 [AS_HELP_STRING(
427 [--enable-sanitize],
428 [Compile with address sanitizer enabled],
429 )],
430 [sanitize=$enableval], [sanitize="no"])
431if test x"$sanitize" = x"yes"
432then
Pau Espin Pedrol13492492017-06-23 11:18:04 +0200433 CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined"
434 CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
Neels Hofmeyra2381762016-09-30 01:25:45 +0200435fi
436
Neels Hofmeyr09ecbb72018-03-05 20:40:05 +0100437AC_ARG_ENABLE(werror,
438 [AS_HELP_STRING(
439 [--enable-werror],
440 [Turn all compiler warnings into errors, with exceptions:
441 a) deprecation (allow upstream to mark deprecation without breaking builds);
442 b) "#warning" pragmas (allow to remind ourselves of errors without breaking builds)
443 ]
444 )],
445 [werror=$enableval], [werror="no"])
446if test x"$werror" = x"yes"
447then
448 WERROR_FLAGS="-Werror"
Harald Welte88bb5ed2022-11-03 11:53:35 +0100449 WERROR_FLAGS+=" -Werror=implicit-int -Werror=int-conversion -Werror=old-style-definition"
Neels Hofmeyr09ecbb72018-03-05 20:40:05 +0100450 WERROR_FLAGS+=" -Wno-error=deprecated -Wno-error=deprecated-declarations"
451 WERROR_FLAGS+=" -Wno-error=cpp" # "#warning"
452 CFLAGS="$CFLAGS $WERROR_FLAGS"
453 CPPFLAGS="$CPPFLAGS $WERROR_FLAGS"
454fi
455
Neels Hofmeyr3a9ff112018-09-10 17:18:28 +0200456AC_ARG_ENABLE([external_tests],
457 AC_HELP_STRING([--enable-external-tests],
458 [Include the VTY/CTRL tests in make check [default=no]]),
459 [enable_ext_tests="$enableval"],[enable_ext_tests="no"])
460if test "x$enable_ext_tests" = "xyes" ; then
461 AM_PATH_PYTHON
462 AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmo_verify_transcript_vty.py,yes)
463 if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then
Harald Welte02396202022-06-17 23:20:10 +0200464 AC_MSG_ERROR([Please install https://gitea.osmocom.org/cellular-infrastructure/osmo-python-tests to run the VTY/CTRL tests.])
Neels Hofmeyr3a9ff112018-09-10 17:18:28 +0200465 fi
466fi
467AC_MSG_CHECKING([whether to enable VTY/CTRL tests])
468AC_MSG_RESULT([$enable_ext_tests])
469AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
470
Pau Espin Pedrol13492492017-06-23 11:18:04 +0200471CFLAGS="$CFLAGS -DBUILDING_LIBOSMOCORE -Wall"
472CPPFLAGS="$CPPFLAGS -DBUILDING_LIBOSMOCORE -Wall"
Pau Espin Pedrol69dfe5a2017-06-17 23:18:11 +0200473
Vadim Yanitskiy2c3066e2017-04-30 19:41:56 +0700474AC_ARG_ENABLE(simd,
475 [AS_HELP_STRING(
476 [--disable-simd],
477 [Disable SIMD support]
478 )],
479 [simd=$enableval], [simd="yes"])
480if test x"$simd" = x"yes"
481then
482 # Find and define supported SIMD extensions
483 AX_CHECK_SIMD
484else
485 AM_CONDITIONAL(HAVE_AVX2, false)
Harald Welteb93f60f2017-11-17 11:41:34 +0100486 AM_CONDITIONAL(HAVE_SSSE3, false)
Vadim Yanitskiy2c3066e2017-04-30 19:41:56 +0700487 AM_CONDITIONAL(HAVE_SSE4_1, false)
488fi
489
Eric3afc1d12020-07-23 02:16:46 +0200490AC_ARG_ENABLE(neon,
491 [AS_HELP_STRING(
492 [--enable-neon],
Vadim Yanitskiy325d9b32020-08-07 03:53:40 +0700493 [Enable ARM NEON instructions support [default=no]]
Eric3afc1d12020-07-23 02:16:46 +0200494 )],
495 [neon=$enableval], [neon="no"])
Vadim Yanitskiy2ecb71b2021-01-14 18:55:26 +0100496AS_IF([test "x$neon" = "xyes"], [
497 AC_DEFINE([HAVE_NEON],, [Support ARM NEON instructions])
498])
Vadim Yanitskiy7dbae9e2020-08-07 04:01:12 +0700499AC_MSG_CHECKING([whether to enable ARM NEON instructions support])
500AC_MSG_RESULT([$neon])
Eric3afc1d12020-07-23 02:16:46 +0200501AM_CONDITIONAL(HAVE_NEON, [test "x$neon" != "xno"])
502
Harald Welte433005c2020-09-26 11:51:32 +0200503#
504# SystemTap support
505#
506AC_MSG_CHECKING([whether to include systemtap tracing support])
507AC_ARG_ENABLE([systemtap],
508 [AS_HELP_STRING([--enable-systemtap],
509 [Enable inclusion of systemtap trace support])],
510 [ENABLE_SYSTEMTAP="${enableval}"], [ENABLE_SYSTEMTAP='no'])
511AM_CONDITIONAL([ENABLE_SYSTEMTAP], [test x$ENABLE_SYSTEMTAP = xyes])
512AC_MSG_RESULT(${ENABLE_SYSTEMTAP})
513
514if test "x${ENABLE_SYSTEMTAP}" = xyes; then
515 # Additional configuration for --enable-systemtap is HERE
516 AC_CHECK_PROGS(DTRACE, dtrace)
517 if test -z "$DTRACE"; then
518 AC_MSG_ERROR([dtrace not found])
519 fi
520 AC_CHECK_HEADER([sys/sdt.h], [SDT_H_FOUND='yes'],
521 [SDT_H_FOUND='no';
522 AC_MSG_ERROR([systemtap support needs sys/sdt.h header])])
523 AC_DEFINE([HAVE_SYSTEMTAP], [1], [Define to 1 if using SystemTap probes.])
524 AC_ARG_WITH([tapset-install-dir],
525 [AS_HELP_STRING([--with-tapset-install-dir],
526 [The absolute path where the tapset dir will be installed])],
527 [if test "x${withval}" = x; then
528 ABS_TAPSET_DIR="\$(datadir)/systemtap/tapset"
529 else
530 ABS_TAPSET_DIR="${withval}"
531 fi], [ABS_TAPSET_DIR="\$(datadir)/systemtap/tapset"])
532 AC_SUBST(ABS_TAPSET_DIR)
533fi
534
Eric3afc1d12020-07-23 02:16:46 +0200535
Vasil Velichkov499510b2019-04-03 02:32:37 +0300536OSMO_AC_CODE_COVERAGE
537
Vadim Yanitskiya8a58192017-05-08 00:07:21 +0700538dnl Check if the compiler supports specified GCC's built-in function
539AC_DEFUN([CHECK_BUILTIN_SUPPORT], [
540 AC_CACHE_CHECK(
541 [whether ${CC} has $1 built-in],
542 [osmo_cv_cc_has_builtin], [
543 AC_LINK_IFELSE([
544 AC_LANG_PROGRAM([], [
545 __builtin_cpu_supports("sse");
546 ])
547 ],
548 [AS_VAR_SET([osmo_cv_cc_has_builtin], [yes])],
549 [AS_VAR_SET([osmo_cv_cc_has_builtin], [no])])
550 ]
551 )
552
553 AS_IF([test yes = AS_VAR_GET([osmo_cv_cc_has_builtin])], [
554 AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$1), 1,
555 [Define to 1 if compiler has the '$1' built-in function])
556 ], [
557 AC_MSG_WARN($2)
558 ])
559])
560
561dnl Check if the compiler supports runtime SIMD detection
562CHECK_BUILTIN_SUPPORT([__builtin_cpu_supports],
563 [Runtime SIMD detection will be disabled])
564
Philipp Maierb1ef8f52021-12-06 16:31:02 +0100565dnl There are some members in struct tcp_info that might not exist on all linux versions
Harald Weltec809f4e2021-12-24 11:31:12 +0100566AC_CHECK_MEMBER([struct tcp_info.tcpi_notsent_bytes],
567 AC_DEFINE([HAVE_TCP_INFO_TCPI_NOTSENT_BYTES],
568 [1],
569 [Define to 1 if your <linux/tcp.h> header file have the tcpi_notsent_bytes member in struct tcp_info]),
570 [],
571 [#include <linux/tcp.h>])
572
Philipp Maierb1ef8f52021-12-06 16:31:02 +0100573AC_CHECK_MEMBER([struct tcp_info.tcpi_rwnd_limited],
574 AC_DEFINE([HAVE_TCP_INFO_TCPI_RWND_LIMITED],
575 [1],
576 [Define to 1 if your <linux/tcp.h> header file have the tcpi_rwnd_limited member in struct tcp_info]),
577 [],
578 [#include <linux/tcp.h>])
579
580AC_CHECK_MEMBER([struct tcp_info.tcpi_sndbuf_limited],
581 AC_DEFINE([HAVE_TCP_INFO_TCPI_SNDBUF_LIMITED],
582 [1],
583 [Define to 1 if your <linux/tcp.h> header file have the tcpi_sndbuf_limited member in struct tcp_info]),
584 [],
585 [#include <linux/tcp.h>])
586
587AC_CHECK_MEMBER([struct tcp_info.tcpi_reord_seen],
588 AC_DEFINE([HAVE_TCP_INFO_TCPI_REORD_SEEN],
589 [1],
590 [Define to 1 if your <linux/tcp.h> header file have the tcpi_reord_seen member in struct tcp_info]),
591 [],
592 [#include <linux/tcp.h>])
593
Neels Hofmeyr09ecbb72018-03-05 20:40:05 +0100594AC_MSG_RESULT([CFLAGS="$CFLAGS"])
595AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
596
Harald Welte3cae0392010-02-20 21:09:24 +0100597AC_OUTPUT(
598 libosmocore.pc
Sylvain Munautb99b9302010-10-24 18:23:10 +0200599 libosmocodec.pc
Vadim Yanitskiy3262f822016-09-23 01:48:59 +0700600 libosmocoding.pc
Harald Weltee352c522010-05-19 19:42:32 +0200601 libosmovty.pc
Pablo Neira Ayusofba495e2011-03-23 18:08:08 +0100602 libosmogsm.pc
Harald Welted55a2092022-11-29 22:33:54 +0100603 libosmoisdn.pc
Harald Welte641f7ce2012-06-17 23:05:26 +0800604 libosmogb.pc
Harald Welte3ff81b12014-08-20 19:58:40 +0200605 libosmoctrl.pc
Harald Welted54c2ee2012-01-17 18:25:50 +0100606 libosmosim.pc
Harald Welteda432cd2019-12-15 19:13:26 +0100607 libosmousb.pc
Harald Welte3cae0392010-02-20 21:09:24 +0100608 include/Makefile
Pau Espin Pedrol4fc61182023-01-18 18:01:54 +0100609 include/osmocom/Makefile
610 include/osmocom/codec/Makefile
611 include/osmocom/coding/Makefile
612 include/osmocom/core/Makefile
613 include/osmocom/crypt/Makefile
614 include/osmocom/ctrl/Makefile
615 include/osmocom/gprs/Makefile
616 include/osmocom/gprs/protocol/Makefile
617 include/osmocom/gsm/Makefile
618 include/osmocom/gsm/protocol/Makefile
Harald Welted55a2092022-11-29 22:33:54 +0100619 include/osmocom/isdn/Makefile
Pau Espin Pedrol4fc61182023-01-18 18:01:54 +0100620 include/osmocom/sim/Makefile
621 include/osmocom/usb/Makefile
622 include/osmocom/vty/Makefile
Harald Welte3cae0392010-02-20 21:09:24 +0100623 src/Makefile
Pau Espin Pedrold4c3dc82023-01-18 17:04:04 +0100624 src/core/Makefile
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200625 src/vty/Makefile
Sylvain Munaut1a4ea5b2010-10-08 15:09:16 +0200626 src/codec/Makefile
Vadim Yanitskiy3262f822016-09-23 01:48:59 +0700627 src/coding/Makefile
Harald Welted54c2ee2012-01-17 18:25:50 +0100628 src/sim/Makefile
Harald Welteda432cd2019-12-15 19:13:26 +0100629 src/usb/Makefile
Pablo Neira Ayusofba495e2011-03-23 18:08:08 +0100630 src/gsm/Makefile
Harald Welted55a2092022-11-29 22:33:54 +0100631 src/isdn/Makefile
Harald Welte641f7ce2012-06-17 23:05:26 +0800632 src/gb/Makefile
Harald Welte3ff81b12014-08-20 19:58:40 +0200633 src/ctrl/Makefile
Harald Welte898ffef2017-05-15 21:37:34 +0200634 src/pseudotalloc/Makefile
Harald Welte433005c2020-09-26 11:51:32 +0200635 tapset/Makefile
Harald Welte3cae0392010-02-20 21:09:24 +0100636 tests/Makefile
Neels Hofmeyr96831042016-11-15 17:31:14 +0100637 tests/atlocal
Harald Welteeeb78dd2011-08-02 13:44:54 +0200638 utils/Makefile
Max7a79dd32022-12-02 23:13:43 +0300639 utils/osmo-stat-dummy/Makefile
Harald Weltec7859ed2011-08-20 12:54:17 +0200640 Doxyfile.core
Harald Welte49e10562011-08-17 19:21:07 +0200641 Doxyfile.gsm
Harald Welted55a2092022-11-29 22:33:54 +0100642 Doxyfile.isdn
Harald Welte49e10562011-08-17 19:21:07 +0200643 Doxyfile.vty
644 Doxyfile.codec
Vadim Yanitskiy3262f822016-09-23 01:48:59 +0700645 Doxyfile.coding
Neels Hofmeyr249fb712017-06-20 02:52:38 +0200646 Doxyfile.gb
Harald Welteb4186822018-05-26 17:25:11 +0200647 Doxyfile.ctrl
Vadim Yanitskiy94e0af02023-02-25 16:56:16 +0700648 Doxyfile.sim
649 Doxyfile.usb
Oliver Smith6370f5d2020-05-14 11:27:08 +0200650 Makefile
651 contrib/libosmocore.spec)