blob: 2467c68d67200e6f6b8aede27f9975b0f4bef52b [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'
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070056 LTLDFLAGS_OSMOCODING='-Wl,--version-script=$(srcdir)/libosmocoding.map'
Harald Welteed605782018-05-26 17:07:39 +020057 LTLDFLAGS_OSMOCTRL='-Wl,--version-script=$(srcdir)/libosmoctrl.map'
Tobias Engel597460f2012-10-24 17:52:52 +020058 ;;
59esac
60AC_SUBST(LTLDFLAGS_OSMOGB)
61AC_SUBST(LTLDFLAGS_OSMOGSM)
Vadim Yanitskiy272bd4f2017-08-31 17:53:04 +070062AC_SUBST(LTLDFLAGS_OSMOCODING)
Harald Welteed605782018-05-26 17:07:39 +020063AC_SUBST(LTLDFLAGS_OSMOCTRL)
Tobias Engel597460f2012-10-24 17:52:52 +020064
Harald Welte3cae0392010-02-20 21:09:24 +010065dnl checks for header files
66AC_HEADER_STDC
Harald Weltee4cd2672019-08-06 19:56:16 +020067AC_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)
Holger Hans Peter Freyther47723482011-11-09 11:26:15 +010068# for src/conv.c
69AC_FUNC_ALLOCA
Pau Espin Pedrolcacaa4a2018-05-04 19:21:58 +020070AC_SEARCH_LIBS([dlopen], [dl dld], [LIBRARY_DLOPEN="$LIBS";LIBS=""])
71AC_SUBST(LIBRARY_DLOPEN)
72AC_SEARCH_LIBS([dlsym], [dl dld], [LIBRARY_DLSYM="$LIBS";LIBS=""])
73AC_SUBST(LIBRARY_DLSYM)
Holger Hans Peter Freytherc2c042d2014-04-17 23:19:10 +020074# for src/backtrace.c
75AC_CHECK_LIB(execinfo, backtrace, BACKTRACE_LIB=-lexecinfo, BACKTRACE_LIB=)
76AC_SUBST(BACKTRACE_LIB)
Harald Welte3cae0392010-02-20 21:09:24 +010077
Pau Espin Pedrold12f6982019-09-17 18:38:58 +020078# check for pthread (PTHREAD_CFLAGS, PTHREAD_LIBS)
79AX_PTHREAD
80
Harald Weltec17546f2022-03-28 15:38:28 +020081AC_MSG_CHECKING(for pthread_getname_np(pthread_t, char*, size_t))
82saved_CFLAGS="$CFLAGS"
83saved_LIBS="$LIBS"
84CFLAGS="$CFLAGS $PTHREAD_CFLAGS"
85LIBS="$LIBS $PTHREAD_LIBS"
86AC_LINK_IFELSE(
87 [AC_LANG_PROGRAM(
88 [#define _GNU_SOURCE
89 #include <pthread.h>],
90 [pthread_getname_np(pthread_self(),"example",0)])],
91 [AC_MSG_RESULT(yes)
92 AC_DEFINE(HAVE_PTHREAD_GETNAME_NP,1,
93 [Have function pthread_setname_np(const char*)])],
94 [AC_MSG_RESULT(no)])
95CFLAGS="$saved_CFLAGS"
96LIBS="$saved_LIBS"
97
98
Alexander Couzensa2f696f2018-04-24 16:15:23 +020099# check for old glibc < 2.17 to get clock_gettime
Pau Espin Pedrol47eb4e12020-05-01 16:51:20 +0200100AC_SEARCH_LIBS([clock_gettime], [rt posix4],
101 [AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if clock_gettime is available])
102 LIBRARY_RT="$LIBS";LIBS="";])
Alexander Couzensa2f696f2018-04-24 16:15:23 +0200103AC_SUBST(LIBRARY_RT)
104
Pau Espin Pedrol639c4082017-07-06 10:45:22 +0200105AC_ARG_ENABLE(doxygen,
106 [AS_HELP_STRING(
107 [--disable-doxygen],
108 [Disable generation of documentation using doxygen],
109 )],
110 [doxygen=$enableval], [doxygen="yes"])
Harald Welte21e73c22011-08-17 19:33:06 +0200111AC_PATH_PROG(DOXYGEN,doxygen,false)
Pau Espin Pedrol639c4082017-07-06 10:45:22 +0200112AM_CONDITIONAL(HAVE_DOXYGEN, test $DOXYGEN != false && test "x$doxygen" = "xyes")
Harald Welte21e73c22011-08-17 19:33:06 +0200113
Max4b2b0cc2017-07-10 14:32:48 +0200114# check for syscal fallback on glibc < 2.25 - can be removed once glibc version requirement is bumped
115AC_CHECK_DECLS([SYS_getrandom], [], [], [[#include <sys/syscall.h>]])
116
Harald Welte3cae0392010-02-20 21:09:24 +0100117# The following test is taken from WebKit's webkit.m4
118saved_CFLAGS="$CFLAGS"
119CFLAGS="$CFLAGS -fvisibility=hidden "
120AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
Alexander Huemer3d79f532011-05-24 15:16:13 +0200121AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
Harald Welte3cae0392010-02-20 21:09:24 +0100122 [ AC_MSG_RESULT([yes])
123 SYMBOL_VISIBILITY="-fvisibility=hidden"],
124 AC_MSG_RESULT([no]))
125CFLAGS="$saved_CFLAGS"
126AC_SUBST(SYMBOL_VISIBILITY)
127
Pau Espin Pedrol47eb4e12020-05-01 16:51:20 +0200128AC_CHECK_FUNCS(localtime_r)
Harald Welte14c4c492018-06-28 08:28:52 +0200129
Harald Welte7c8e2cc2012-08-29 16:47:30 +0200130AC_DEFUN([CHECK_TM_INCLUDES_TM_GMTOFF], [
131 AC_CACHE_CHECK(
132 [whether struct tm has tm_gmtoff member],
133 osmo_cv_tm_includes_tm_gmtoff,
134 [AC_LINK_IFELSE([
135 AC_LANG_PROGRAM([
136 #include <time.h>
137 ], [
138 time_t t = time(NULL);
139 struct tm* lt = localtime(&t);
140 int off = lt->tm_gmtoff;
141 ])
142 ],
143 osmo_cv_tm_includes_tm_gmtoff=yes,
144 osmo_cv_tm_includes_tm_gmtoff=no
145 )]
146 )
147 if test "x$osmo_cv_tm_includes_tm_gmtoff" = xyes; then
148 AC_DEFINE(HAVE_TM_GMTOFF_IN_TM, 1,
149 [Define if struct tm has tm_gmtoff member.])
150 fi
151])
152
153CHECK_TM_INCLUDES_TM_GMTOFF
154
Pau Espin Pedrol88e40582021-02-17 17:46:02 +0100155# Check if gettid is available (despite not being documented in glibc doc,
156# it requires __USE_GNU on some systems)
157# C compiler is used since __USE_GNU seems to be always defined for g++.
158save_CPPFLAGS=$CPPFLAGS
159AC_LANG_PUSH(C)
160CPPFLAGS="$CPPFLAGS -D_GNU_SOURCE"
161AC_CHECK_FUNCS([gettid])
162AC_LANG_POP(C)
163CPPFLAGS=$save_CPPFLAGS
164
Pau Espin Pedrole188b8c2019-08-05 13:46:33 +0200165dnl 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 +0200166ARG_ENABLE_DETECT_TLS_GCC_ARM_BUG
Pau Espin Pedrole188b8c2019-08-05 13:46:33 +0200167
Harald Welte3cae0392010-02-20 21:09:24 +0100168dnl Generate the output
Christian Vogel854debc2013-01-05 20:30:41 +0100169AC_CONFIG_HEADER(config.h)
Harald Welte3cae0392010-02-20 21:09:24 +0100170
Pau Espin Pedrol75b03e52021-10-28 15:11:32 +0200171PKG_CHECK_MODULES(TALLOC, [talloc >= 2.1.0])
Harald Welte90e614f2015-12-05 23:38:18 +0100172
Harald Welte495fe262012-09-10 16:28:17 +0200173AC_ARG_ENABLE([pcsc], [AS_HELP_STRING([--disable-pcsc], [Build without PC/SC support])],
174 [
Neels Hofmeyr96831042016-11-15 17:31:14 +0100175 ENABLE_PCSC=$enableval
Harald Welte495fe262012-09-10 16:28:17 +0200176 ],
177 [
Neels Hofmeyr96831042016-11-15 17:31:14 +0100178 ENABLE_PCSC="yes"
Harald Welte495fe262012-09-10 16:28:17 +0200179 ])
Neels Hofmeyr96831042016-11-15 17:31:14 +0100180AS_IF([test "x$ENABLE_PCSC" = "xyes"], [
Holger Hans Peter Freyther18bcc8a2014-11-14 15:06:09 +0100181 PKG_CHECK_MODULES(PCSC, libpcsclite)
Harald Welte3c44a642020-03-15 22:50:06 +0100182 AC_DEFINE([HAVE_PCSC],[1],[Build with PC/SC support])
Harald Welted086f212015-11-21 11:38:09 +0100183])
Neels Hofmeyr96831042016-11-15 17:31:14 +0100184AM_CONDITIONAL(ENABLE_PCSC, test "x$ENABLE_PCSC" = "xyes")
185AC_SUBST(ENABLE_PCSC)
Harald Welte495fe262012-09-10 16:28:17 +0200186
Harald Welteda432cd2019-12-15 19:13:26 +0100187AC_ARG_ENABLE([libusb], [AS_HELP_STRING([--disable-libusb], [Build without libusb support])],
188 [
189 ENABLE_LIBUSB=$enableval
190 ],
191 [
192 ENABLE_LIBUSB="yes"
193 ])
194AS_IF([test "x$ENABLE_LIBUSB" = "xyes"], [
195 PKG_CHECK_MODULES(LIBUSB, libusb-1.0)
196])
197AM_CONDITIONAL(ENABLE_LIBUSB, test "x$ENABLE_LIBUSB" = "xyes")
198AC_SUBST(ENABLE_LIBUSB)
199
Maxed029df2017-10-26 10:56:04 +0200200AC_ARG_ENABLE([gnutls], [AS_HELP_STRING([--disable-gnutls], [Do not use GnuTLS fallback for missing getrandom()])],
201 [ENABLE_GNUTLS=$enableval], [ENABLE_GNUTLS="yes"])
202AM_CONDITIONAL(ENABLE_GNUTLS, test x"$ENABLE_GNUTLS" = x"yes")
203AS_IF([test "x$ENABLE_GNUTLS" = "xyes"], [
204 PKG_CHECK_MODULES([LIBGNUTLS], [gnutls >= 2.12.0])
205])
206AC_SUBST(ENABLE_GNUTLS)
207if test x"$ENABLE_GNUTLS" = x"yes"
208then
209 AC_SUBST([LIBGNUTLS_CFLAGS])
210 AC_SUBST([LIBGNUTLS_LIBS])
211 AC_DEFINE([USE_GNUTLS], [1], [Use GnuTLS as a fallback for missing getrandom()])
212fi
213
Vadim Yanitskiye7bf4352020-09-09 03:36:48 +0700214AC_ARG_ENABLE([systemd_logging],
215 [AS_HELP_STRING(
216 [--enable-systemd-logging],
217 [Build with systemd-journal logging support]
218 )],
219 [systemd_logging=$enableval], [systemd_logging="no"])
220AS_IF([test "x$systemd_logging" = "xyes"], [
221 PKG_CHECK_MODULES(SYSTEMD, libsystemd)
222 AC_DEFINE([ENABLE_SYSTEMD_LOGGING], [1], [Enable systemd-journal logging target])
223])
224AM_CONDITIONAL(ENABLE_SYSTEMD_LOGGING, test "x$systemd_logging" = "xyes")
225AC_SUBST(ENABLE_SYSTEMD_LOGGING)
226
Harald Welte53a2fde2020-12-01 22:21:14 +0100227AC_ARG_ENABLE([libmnl],
228 [AS_HELP_STRING(
229 [--disable-libmnl],
230 [Build without netlink socket support via libmnl]
231 )],
232 [mnl=$enableval], [mnl="yes"])
233AS_IF([test "x$mnl" = "xyes"], [
234 PKG_CHECK_MODULES(LIBMNL, libmnl)
235 AC_DEFINE([ENABLE_LIBMNL], [1], [Enable netlink socket support via libmnl])
236])
237AM_CONDITIONAL(ENABLE_LIBMNL, test "x$mnl" = "xyes")
238AC_SUBST(ENABLE_LIBMNL)
239
Pau Espin Pedrolea2afb22019-10-24 15:41:32 +0200240AC_ARG_ENABLE([libsctp], [AS_HELP_STRING([--disable-libsctp], [Do not enable socket multiaddr APIs requiring libsctp])],
241 [ENABLE_LIBSCTP=$enableval], [ENABLE_LIBSCTP="yes"])
242AM_CONDITIONAL(ENABLE_LIBSCTP, test x"$ENABLE_LIBSCTP" = x"yes")
243AS_IF([test "x$ENABLE_LIBSCTP" = "xyes"], [
Pau Espin Pedrolc80a0042022-03-29 11:56:43 +0200244 AC_DEFINE(HAVE_LIBSCTP, 1, [Define 1 to enable SCTP support])
245 # Attempt finding .pc, otherwise set manually (<1.0.17 have no .pc file)
246 PKG_CHECK_MODULES(LIBSCTP, libsctp,
247 [AC_SUBST(LIBSCTP_PC, [libsctp])],
248 [
249 AC_MSG_NOTICE([libsctp.pc not found (building against <1.0.17 ?), attempting manual lib lookup])
250 old_LIBS=$LIBS
251 AC_SEARCH_LIBS([sctp_bindx], [sctp], [
252 AC_SUBST(HAVE_LIBSCTP, [1])
253 if test -n "$ac_lib"; then
254 AC_SUBST(LIBSCTP_LIBS, [-l$ac_lib])
255 fi
256 ], [
257 AC_MSG_ERROR([sctp_bindx not found in searched libs])])
258 LIBS=$old_LIBS
259 ])
Pau Espin Pedrolea2afb22019-10-24 15:41:32 +0200260])
261
Pau Espin Pedrol16b076c2020-08-25 13:56:43 +0200262AC_ARG_ENABLE([sctp-tests], [AS_HELP_STRING([--disable-sctp-tests], [Do not run socket tests requiring system SCTP support])],
263 [ENABLE_SCTP_TESTS=$enableval], [ENABLE_SCTP_TESTS="yes"])
264AM_CONDITIONAL(ENABLE_SCTP_TESTS, test x"$ENABLE_SCTP_TESTS" = x"yes")
265
Harald Welteb9ce51c2010-06-30 19:43:11 +0200266AC_ARG_ENABLE(plugin,
Sylvain Munautf23abab2010-07-25 16:16:42 +0200267 [AS_HELP_STRING(
268 [--disable-plugin],
269 [Disable support for dlopen plugins],
270 )],
job36b4a202011-08-21 17:18:23 +0200271 [enable_plugin=$enableval], [enable_plugin="yes"])
272AM_CONDITIONAL(ENABLE_PLUGIN, test x"$enable_plugin" = x"yes")
Harald Welteb9ce51c2010-06-30 19:43:11 +0200273
Harald Welte1067e8c2010-06-25 03:00:58 +0200274AC_ARG_ENABLE(vty,
Sylvain Munautf23abab2010-07-25 16:16:42 +0200275 [AS_HELP_STRING(
276 [--disable-vty],
277 [Disable building VTY telnet interface]
278 )],
job36b4a202011-08-21 17:18:23 +0200279 [enable_vty=$enableval], [enable_vty="yes"])
280AM_CONDITIONAL(ENABLE_VTY, test x"$enable_vty" = x"yes")
Harald Welte54403772010-05-29 11:49:51 +0200281
Sylvain Munautac3e61a2010-07-25 18:08:54 +0200282AC_ARG_ENABLE(panic_infloop,
283 [AS_HELP_STRING(
284 [--enable-panic-infloop],
285 [Trigger infinite loop on panic rather than fprintf/abort]
286 )],
job36b4a202011-08-21 17:18:23 +0200287 [panic_infloop=$enableval], [panic_infloop="no"])
288if test x"$panic_infloop" = x"yes"
Sylvain Munautac3e61a2010-07-25 18:08:54 +0200289then
290 AC_DEFINE([PANIC_INFLOOP],[1],[Use infinite loop on panic rather than fprintf/abort])
291fi
292
Holger Hans Peter Freyther43558312010-08-06 06:48:43 +0800293AC_ARG_ENABLE(bsc_fd_check,
294 [AS_HELP_STRING(
295 [--enable-bsc-fd-check],
Pau Espin Pedrold05def02020-05-09 19:24:21 +0200296 [Instrument osmo_fd_register to check that the fd is registered]
Holger Hans Peter Freyther43558312010-08-06 06:48:43 +0800297 )],
job36b4a202011-08-21 17:18:23 +0200298 [fd_check=$enableval], [fd_check="no"])
299if test x"$fd_check" = x"no"
Holger Hans Peter Freyther43558312010-08-06 06:48:43 +0800300then
Pau Espin Pedrold05def02020-05-09 19:24:21 +0200301 AC_DEFINE([OSMO_FD_CHECK],[1],[Instrument the osmo_fd_register])
Holger Hans Peter Freyther43558312010-08-06 06:48:43 +0800302fi
303
Harald Welteb904e422020-10-18 21:24:13 +0200304AC_ARG_ENABLE([force_io_select],
305 [AS_HELP_STRING(
306 [--enable-force-io-select],
307 [Build with old select I/O instead of poll]
308 )],
309 [force_io_select=$enableval], [force_io_select="no"])
310AS_IF([test "x$force_io_select" = "xyes"], [
311 AC_DEFINE([FORCE_IO_SELECT], [1], [Force the use of select() instaed of poll()])
312])
313
Holger Hans Peter Freytherc87f2662010-10-07 00:00:15 +0800314AC_ARG_ENABLE(msgfile,
315 [AS_HELP_STRING(
316 [--disable-msgfile],
317 [Disable support for the msgfile],
318 )],
job36b4a202011-08-21 17:18:23 +0200319 [enable_msgfile=$enableval], [enable_msgfile="yes"])
320AM_CONDITIONAL(ENABLE_MSGFILE, test x"$enable_msgfile" = x"yes")
Holger Hans Peter Freytherc87f2662010-10-07 00:00:15 +0800321
Sylvain Munautfe28ded2011-09-02 22:18:24 +0200322AC_ARG_ENABLE(serial,
323 [AS_HELP_STRING(
324 [--disable-serial],
325 [Disable support for the serial helpers],
326 )],
327 [enable_serial=$enableval], [enable_serial="yes"])
328AM_CONDITIONAL(ENABLE_SERIAL, test x"$enable_serial" = x"yes")
329
job8e4deb62011-08-21 17:18:24 +0200330AC_ARG_ENABLE(utilities,
331 [AS_HELP_STRING(
332 [--disable-utilities],
333 [Disable building utility programs],
334 )],
335 [enable_utilities=$enableval], [enable_utilities="yes"])
336AM_CONDITIONAL(ENABLE_UTILITIES, test x"$enable_utilities" = x"yes")
337
Harald Weltee3a10b62012-09-08 22:18:43 +0200338AC_ARG_ENABLE(gb,
339 [AS_HELP_STRING(
340 [--disable-gb],
341 [Disable building Gb library],
342 )],
343 [enable_gb=$enableval], [enable_gb="yes"])
344AM_CONDITIONAL(ENABLE_GB, test x"$enable_gb" = x"yes")
345
Harald Welte1c67e752017-01-15 17:52:30 +0100346AC_ARG_ENABLE(ctrl,
347 [AS_HELP_STRING(
348 [--disable-ctrl],
349 [Disable building CTRL library],
350 )],
351 [enable_ctrl=$enableval], [enable_ctrl="yes"])
352AM_CONDITIONAL(ENABLE_CTRL, test x"$enable_ctrl" = x"yes")
353
Harald Welte898ffef2017-05-15 21:37:34 +0200354AC_ARG_ENABLE(pseudotalloc,
355 [AS_HELP_STRING(
356 [--enable-pseudotalloc],
357 [Enable building pseudotalloc library],
358 )],
359 [enable_pseudotalloc=$enableval], [enable_pseudotalloc="no"])
360AM_CONDITIONAL(ENABLE_PSEUDOTALLOC, test x"$enable_pseudotalloc" = x"yes")
361
job8e4deb62011-08-21 17:18:24 +0200362AC_ARG_ENABLE(embedded,
363 [AS_HELP_STRING(
364 [--enable-embedded],
365 [Enable building for embedded use and disable unsupported features]
366 )],
367 [embedded=$enableval], [embedded="no"])
Max89c8c402018-01-18 16:05:27 +0100368
Harald Weltec6a86972019-12-16 23:14:45 +0100369AM_CONDITIONAL(EMBEDDED, false)
Max3da79382018-01-18 16:50:51 +0100370AM_CONDITIONAL(ENABLE_SERCOM_STUB, false)
Max89c8c402018-01-18 16:05:27 +0100371
job8e4deb62011-08-21 17:18:24 +0200372if test x"$embedded" = x"yes"
373then
374 AC_DEFINE([EMBEDDED],[1],[Select building for embedded use])
job8e4deb62011-08-21 17:18:24 +0200375 AM_CONDITIONAL(ENABLE_PLUGIN, false)
376 AM_CONDITIONAL(ENABLE_MSGFILE, false)
Sylvain Munautfe28ded2011-09-02 22:18:24 +0200377 AM_CONDITIONAL(ENABLE_SERIAL, false)
Maxed029df2017-10-26 10:56:04 +0200378 AM_CONDITIONAL(ENABLE_GNUTLS, false)
job8e4deb62011-08-21 17:18:24 +0200379 AM_CONDITIONAL(ENABLE_VTY, false)
Harald Welte1c67e752017-01-15 17:52:30 +0100380 AM_CONDITIONAL(ENABLE_CTRL, false)
job8e4deb62011-08-21 17:18:24 +0200381 AM_CONDITIONAL(ENABLE_UTILITIES, false)
Harald Weltee3a10b62012-09-08 22:18:43 +0200382 AM_CONDITIONAL(ENABLE_GB, false)
Maxed029df2017-10-26 10:56:04 +0200383 AM_CONDITIONAL(ENABLE_GNUTLS, false)
Sylvain Munaut90370562022-04-29 08:15:09 +0200384 AM_CONDITIONAL(ENABLE_LIBMNL, false)
Pau Espin Pedrolea2afb22019-10-24 15:41:32 +0200385 AM_CONDITIONAL(ENABLE_LIBSCTP, false)
Sylvain Munaut90370562022-04-29 08:15:09 +0200386 AM_CONDITIONAL(ENABLE_LIBUSB, false)
Harald Welte1a7d64c2017-01-15 17:53:23 +0100387 AM_CONDITIONAL(ENABLE_PCSC, false)
Harald Welte898ffef2017-05-15 21:37:34 +0200388 AM_CONDITIONAL(ENABLE_PSEUDOTALLOC, true)
Max3da79382018-01-18 16:50:51 +0100389 AM_CONDITIONAL(ENABLE_SERCOM_STUB, true)
Harald Weltec6a86972019-12-16 23:14:45 +0100390 AM_CONDITIONAL(EMBEDDED, true)
Maxed029df2017-10-26 10:56:04 +0200391 AC_DEFINE([USE_GNUTLS], [0])
job8e4deb62011-08-21 17:18:24 +0200392 AC_DEFINE([PANIC_INFLOOP],[1],[Use infinite loop on panic rather than fprintf/abort])
393fi
Harald Welte54403772010-05-29 11:49:51 +0200394
Eric Wild63e1b2b2021-11-26 21:09:01 +0100395AC_ARG_ENABLE(log_macros,
396 [AS_HELP_STRING(
397 [--disable-log-macros],
398 [Disable logging macros that are also used internally to print information]
399 )],
400 [log_macros="yes"], [log_macros="no"])
401if test x"$log_macros" == x"yes"
402then
403 AC_DEFINE([LIBOSMOCORE_NO_LOGGING],[1],[Disable logging macros])
404fi
405
Neels Hofmeyra2381762016-09-30 01:25:45 +0200406AC_ARG_ENABLE(sanitize,
407 [AS_HELP_STRING(
408 [--enable-sanitize],
409 [Compile with address sanitizer enabled],
410 )],
411 [sanitize=$enableval], [sanitize="no"])
412if test x"$sanitize" = x"yes"
413then
Pau Espin Pedrol13492492017-06-23 11:18:04 +0200414 CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined"
415 CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
Neels Hofmeyra2381762016-09-30 01:25:45 +0200416fi
417
Neels Hofmeyr09ecbb72018-03-05 20:40:05 +0100418AC_ARG_ENABLE(werror,
419 [AS_HELP_STRING(
420 [--enable-werror],
421 [Turn all compiler warnings into errors, with exceptions:
422 a) deprecation (allow upstream to mark deprecation without breaking builds);
423 b) "#warning" pragmas (allow to remind ourselves of errors without breaking builds)
424 ]
425 )],
426 [werror=$enableval], [werror="no"])
427if test x"$werror" = x"yes"
428then
429 WERROR_FLAGS="-Werror"
430 WERROR_FLAGS+=" -Wno-error=deprecated -Wno-error=deprecated-declarations"
431 WERROR_FLAGS+=" -Wno-error=cpp" # "#warning"
432 CFLAGS="$CFLAGS $WERROR_FLAGS"
433 CPPFLAGS="$CPPFLAGS $WERROR_FLAGS"
434fi
435
Neels Hofmeyr3a9ff112018-09-10 17:18:28 +0200436AC_ARG_ENABLE([external_tests],
437 AC_HELP_STRING([--enable-external-tests],
438 [Include the VTY/CTRL tests in make check [default=no]]),
439 [enable_ext_tests="$enableval"],[enable_ext_tests="no"])
440if test "x$enable_ext_tests" = "xyes" ; then
441 AM_PATH_PYTHON
442 AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmo_verify_transcript_vty.py,yes)
443 if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then
Harald Welte02396202022-06-17 23:20:10 +0200444 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 +0200445 fi
446fi
447AC_MSG_CHECKING([whether to enable VTY/CTRL tests])
448AC_MSG_RESULT([$enable_ext_tests])
449AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
450
Pau Espin Pedrol13492492017-06-23 11:18:04 +0200451CFLAGS="$CFLAGS -DBUILDING_LIBOSMOCORE -Wall"
452CPPFLAGS="$CPPFLAGS -DBUILDING_LIBOSMOCORE -Wall"
Pau Espin Pedrol69dfe5a2017-06-17 23:18:11 +0200453
Vadim Yanitskiy2c3066e2017-04-30 19:41:56 +0700454AC_ARG_ENABLE(simd,
455 [AS_HELP_STRING(
456 [--disable-simd],
457 [Disable SIMD support]
458 )],
459 [simd=$enableval], [simd="yes"])
460if test x"$simd" = x"yes"
461then
462 # Find and define supported SIMD extensions
463 AX_CHECK_SIMD
464else
465 AM_CONDITIONAL(HAVE_AVX2, false)
Harald Welteb93f60f2017-11-17 11:41:34 +0100466 AM_CONDITIONAL(HAVE_SSSE3, false)
Vadim Yanitskiy2c3066e2017-04-30 19:41:56 +0700467 AM_CONDITIONAL(HAVE_SSE4_1, false)
468fi
469
Eric3afc1d12020-07-23 02:16:46 +0200470AC_ARG_ENABLE(neon,
471 [AS_HELP_STRING(
472 [--enable-neon],
Vadim Yanitskiy325d9b32020-08-07 03:53:40 +0700473 [Enable ARM NEON instructions support [default=no]]
Eric3afc1d12020-07-23 02:16:46 +0200474 )],
475 [neon=$enableval], [neon="no"])
Vadim Yanitskiy2ecb71b2021-01-14 18:55:26 +0100476AS_IF([test "x$neon" = "xyes"], [
477 AC_DEFINE([HAVE_NEON],, [Support ARM NEON instructions])
478])
Vadim Yanitskiy7dbae9e2020-08-07 04:01:12 +0700479AC_MSG_CHECKING([whether to enable ARM NEON instructions support])
480AC_MSG_RESULT([$neon])
Eric3afc1d12020-07-23 02:16:46 +0200481AM_CONDITIONAL(HAVE_NEON, [test "x$neon" != "xno"])
482
Harald Welte433005c2020-09-26 11:51:32 +0200483#
484# SystemTap support
485#
486AC_MSG_CHECKING([whether to include systemtap tracing support])
487AC_ARG_ENABLE([systemtap],
488 [AS_HELP_STRING([--enable-systemtap],
489 [Enable inclusion of systemtap trace support])],
490 [ENABLE_SYSTEMTAP="${enableval}"], [ENABLE_SYSTEMTAP='no'])
491AM_CONDITIONAL([ENABLE_SYSTEMTAP], [test x$ENABLE_SYSTEMTAP = xyes])
492AC_MSG_RESULT(${ENABLE_SYSTEMTAP})
493
494if test "x${ENABLE_SYSTEMTAP}" = xyes; then
495 # Additional configuration for --enable-systemtap is HERE
496 AC_CHECK_PROGS(DTRACE, dtrace)
497 if test -z "$DTRACE"; then
498 AC_MSG_ERROR([dtrace not found])
499 fi
500 AC_CHECK_HEADER([sys/sdt.h], [SDT_H_FOUND='yes'],
501 [SDT_H_FOUND='no';
502 AC_MSG_ERROR([systemtap support needs sys/sdt.h header])])
503 AC_DEFINE([HAVE_SYSTEMTAP], [1], [Define to 1 if using SystemTap probes.])
504 AC_ARG_WITH([tapset-install-dir],
505 [AS_HELP_STRING([--with-tapset-install-dir],
506 [The absolute path where the tapset dir will be installed])],
507 [if test "x${withval}" = x; then
508 ABS_TAPSET_DIR="\$(datadir)/systemtap/tapset"
509 else
510 ABS_TAPSET_DIR="${withval}"
511 fi], [ABS_TAPSET_DIR="\$(datadir)/systemtap/tapset"])
512 AC_SUBST(ABS_TAPSET_DIR)
513fi
514
Eric3afc1d12020-07-23 02:16:46 +0200515
Vasil Velichkov499510b2019-04-03 02:32:37 +0300516OSMO_AC_CODE_COVERAGE
517
Vadim Yanitskiya8a58192017-05-08 00:07:21 +0700518dnl Check if the compiler supports specified GCC's built-in function
519AC_DEFUN([CHECK_BUILTIN_SUPPORT], [
520 AC_CACHE_CHECK(
521 [whether ${CC} has $1 built-in],
522 [osmo_cv_cc_has_builtin], [
523 AC_LINK_IFELSE([
524 AC_LANG_PROGRAM([], [
525 __builtin_cpu_supports("sse");
526 ])
527 ],
528 [AS_VAR_SET([osmo_cv_cc_has_builtin], [yes])],
529 [AS_VAR_SET([osmo_cv_cc_has_builtin], [no])])
530 ]
531 )
532
533 AS_IF([test yes = AS_VAR_GET([osmo_cv_cc_has_builtin])], [
534 AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$1), 1,
535 [Define to 1 if compiler has the '$1' built-in function])
536 ], [
537 AC_MSG_WARN($2)
538 ])
539])
540
541dnl Check if the compiler supports runtime SIMD detection
542CHECK_BUILTIN_SUPPORT([__builtin_cpu_supports],
543 [Runtime SIMD detection will be disabled])
544
Philipp Maierb1ef8f52021-12-06 16:31:02 +0100545dnl There are some members in struct tcp_info that might not exist on all linux versions
Harald Weltec809f4e2021-12-24 11:31:12 +0100546AC_CHECK_MEMBER([struct tcp_info.tcpi_notsent_bytes],
547 AC_DEFINE([HAVE_TCP_INFO_TCPI_NOTSENT_BYTES],
548 [1],
549 [Define to 1 if your <linux/tcp.h> header file have the tcpi_notsent_bytes member in struct tcp_info]),
550 [],
551 [#include <linux/tcp.h>])
552
Philipp Maierb1ef8f52021-12-06 16:31:02 +0100553AC_CHECK_MEMBER([struct tcp_info.tcpi_rwnd_limited],
554 AC_DEFINE([HAVE_TCP_INFO_TCPI_RWND_LIMITED],
555 [1],
556 [Define to 1 if your <linux/tcp.h> header file have the tcpi_rwnd_limited member in struct tcp_info]),
557 [],
558 [#include <linux/tcp.h>])
559
560AC_CHECK_MEMBER([struct tcp_info.tcpi_sndbuf_limited],
561 AC_DEFINE([HAVE_TCP_INFO_TCPI_SNDBUF_LIMITED],
562 [1],
563 [Define to 1 if your <linux/tcp.h> header file have the tcpi_sndbuf_limited member in struct tcp_info]),
564 [],
565 [#include <linux/tcp.h>])
566
567AC_CHECK_MEMBER([struct tcp_info.tcpi_reord_seen],
568 AC_DEFINE([HAVE_TCP_INFO_TCPI_REORD_SEEN],
569 [1],
570 [Define to 1 if your <linux/tcp.h> header file have the tcpi_reord_seen member in struct tcp_info]),
571 [],
572 [#include <linux/tcp.h>])
573
Neels Hofmeyr09ecbb72018-03-05 20:40:05 +0100574AC_MSG_RESULT([CFLAGS="$CFLAGS"])
575AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
576
Harald Welte3cae0392010-02-20 21:09:24 +0100577AC_OUTPUT(
578 libosmocore.pc
Sylvain Munautb99b9302010-10-24 18:23:10 +0200579 libosmocodec.pc
Vadim Yanitskiy3262f822016-09-23 01:48:59 +0700580 libosmocoding.pc
Harald Weltee352c522010-05-19 19:42:32 +0200581 libosmovty.pc
Pablo Neira Ayusofba495e2011-03-23 18:08:08 +0100582 libosmogsm.pc
Harald Welte641f7ce2012-06-17 23:05:26 +0800583 libosmogb.pc
Harald Welte3ff81b12014-08-20 19:58:40 +0200584 libosmoctrl.pc
Harald Welted54c2ee2012-01-17 18:25:50 +0100585 libosmosim.pc
Harald Welteda432cd2019-12-15 19:13:26 +0100586 libosmousb.pc
Harald Welte3cae0392010-02-20 21:09:24 +0100587 include/Makefile
588 src/Makefile
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200589 src/vty/Makefile
Sylvain Munaut1a4ea5b2010-10-08 15:09:16 +0200590 src/codec/Makefile
Vadim Yanitskiy3262f822016-09-23 01:48:59 +0700591 src/coding/Makefile
Harald Welted54c2ee2012-01-17 18:25:50 +0100592 src/sim/Makefile
Harald Welteda432cd2019-12-15 19:13:26 +0100593 src/usb/Makefile
Pablo Neira Ayusofba495e2011-03-23 18:08:08 +0100594 src/gsm/Makefile
Harald Welte641f7ce2012-06-17 23:05:26 +0800595 src/gb/Makefile
Harald Welte3ff81b12014-08-20 19:58:40 +0200596 src/ctrl/Makefile
Harald Welte898ffef2017-05-15 21:37:34 +0200597 src/pseudotalloc/Makefile
Harald Welte433005c2020-09-26 11:51:32 +0200598 tapset/Makefile
Harald Welte3cae0392010-02-20 21:09:24 +0100599 tests/Makefile
Neels Hofmeyr96831042016-11-15 17:31:14 +0100600 tests/atlocal
Harald Welteeeb78dd2011-08-02 13:44:54 +0200601 utils/Makefile
Harald Weltec7859ed2011-08-20 12:54:17 +0200602 Doxyfile.core
Harald Welte49e10562011-08-17 19:21:07 +0200603 Doxyfile.gsm
604 Doxyfile.vty
605 Doxyfile.codec
Vadim Yanitskiy3262f822016-09-23 01:48:59 +0700606 Doxyfile.coding
Neels Hofmeyr249fb712017-06-20 02:52:38 +0200607 Doxyfile.gb
Harald Welteb4186822018-05-26 17:25:11 +0200608 Doxyfile.ctrl
Oliver Smith6370f5d2020-05-14 11:27:08 +0200609 Makefile
610 contrib/libosmocore.spec)