blob: 10fb4963842cd1a94a1a6eb9cca684dfe0d34478 [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
11dnl kernel style compile messages
12m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
13
Maxff932bb2017-07-04 18:19:38 +020014dnl include release helper
15RELMAKE='-include osmo-release.mk'
16AC_SUBST([RELMAKE])
17
Harald Welte3cae0392010-02-20 21:09:24 +010018dnl checks for programs
19AC_PROG_MAKE_SET
Diego Elio Pettenòd471a212012-06-29 13:01:19 -070020AC_PROG_MKDIR_P
Harald Welte3cae0392010-02-20 21:09:24 +010021AC_PROG_CC
22AC_PROG_INSTALL
Jan Engelhardtc2ddc4f2015-09-16 14:32:31 +020023LT_INIT([pic-only disable-static])
Harald Welte3cae0392010-02-20 21:09:24 +010024
Harald Welte4cd3d8a2010-03-23 00:30:19 +080025AC_CONFIG_MACRO_DIR([m4])
26
Eric099c8342020-04-10 22:10:13 +020027dnl patching ${archive_cmds} to affect generation of file "libtool" to fix linking with clang
28AS_CASE(["$LD"],[*clang*],
29 [AS_CASE(["${host_os}"],
30 [*linux*],[archive_cmds='$CC -shared $pic_flag $libobjs $deplibs $compiler_flags $wl-soname $wl$soname -o $lib'])])
31
Neels Hofmeyrfef2fa22016-08-08 15:38:35 +020032dnl check for pkg-config
33dnl * If pkg-config is missing, we get a "syntax error" for PKG_CHECK_MODULES.
34dnl Instead, we want to say that pkg-config and pkg.m4 are missing.
35dnl * The proper way is PKG_PROG_PKG_CONFIG() but unfortunately that does not
36dnl produce an intelligible error message if pkg-config is missing entirely
37dnl ("syntax error near unexpected token `0.20'").
38dnl * To produce a hint that pkg-config is missing, check for the pkg-config
39dnl binary; but AC_PATH_PROG breaks if the distribution provides only
40dnl prefixed (<arch>-pkg-config) versions, so just print a warning.
41AC_PATH_PROG(PKG_CONFIG_INSTALLED, pkg-config, no)
42if test "x$PKG_CONFIG_INSTALLED" = "xno"; then
43 AC_MSG_WARN([You need to install pkg-config])
44fi
45PKG_PROG_PKG_CONFIG([0.20])
46
Tobias Engel597460f2012-10-24 17:52:52 +020047dnl check os: some linker flags not available on osx
48case $host in
49*-darwin*)
50 ;;
51*)
52 LTLDFLAGS_OSMOGB='-Wl,--version-script=$(srcdir)/libosmogb.map'
53 LTLDFLAGS_OSMOGSM='-Wl,--version-script=$(srcdir)/libosmogsm.map'
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070054 LTLDFLAGS_OSMOCODING='-Wl,--version-script=$(srcdir)/libosmocoding.map'
Harald Welteed605782018-05-26 17:07:39 +020055 LTLDFLAGS_OSMOCTRL='-Wl,--version-script=$(srcdir)/libosmoctrl.map'
Tobias Engel597460f2012-10-24 17:52:52 +020056 ;;
57esac
58AC_SUBST(LTLDFLAGS_OSMOGB)
59AC_SUBST(LTLDFLAGS_OSMOGSM)
Vadim Yanitskiy272bd4f2017-08-31 17:53:04 +070060AC_SUBST(LTLDFLAGS_OSMOCODING)
Harald Welteed605782018-05-26 17:07:39 +020061AC_SUBST(LTLDFLAGS_OSMOCTRL)
Tobias Engel597460f2012-10-24 17:52:52 +020062
Harald Welte3cae0392010-02-20 21:09:24 +010063dnl checks for header files
64AC_HEADER_STDC
Harald Welteb904e422020-10-18 21:24:13 +020065AC_CHECK_HEADERS(execinfo.h poll.h sys/select.h sys/socket.h sys/signalfd.h sys/timerfd.h syslog.h ctype.h netinet/tcp.h netinet/in.h)
Holger Hans Peter Freyther47723482011-11-09 11:26:15 +010066# for src/conv.c
67AC_FUNC_ALLOCA
Pau Espin Pedrolcacaa4a2018-05-04 19:21:58 +020068AC_SEARCH_LIBS([dlopen], [dl dld], [LIBRARY_DLOPEN="$LIBS";LIBS=""])
69AC_SUBST(LIBRARY_DLOPEN)
70AC_SEARCH_LIBS([dlsym], [dl dld], [LIBRARY_DLSYM="$LIBS";LIBS=""])
71AC_SUBST(LIBRARY_DLSYM)
Holger Hans Peter Freytherc2c042d2014-04-17 23:19:10 +020072# for src/backtrace.c
73AC_CHECK_LIB(execinfo, backtrace, BACKTRACE_LIB=-lexecinfo, BACKTRACE_LIB=)
74AC_SUBST(BACKTRACE_LIB)
Harald Welte3cae0392010-02-20 21:09:24 +010075
Pau Espin Pedrold12f6982019-09-17 18:38:58 +020076# check for pthread (PTHREAD_CFLAGS, PTHREAD_LIBS)
77AX_PTHREAD
78
Alexander Couzensa2f696f2018-04-24 16:15:23 +020079# check for old glibc < 2.17 to get clock_gettime
Pau Espin Pedrol47eb4e12020-05-01 16:51:20 +020080AC_SEARCH_LIBS([clock_gettime], [rt posix4],
81 [AC_DEFINE(HAVE_CLOCK_GETTIME, 1, [Define if clock_gettime is available])
82 LIBRARY_RT="$LIBS";LIBS="";])
Alexander Couzensa2f696f2018-04-24 16:15:23 +020083AC_SUBST(LIBRARY_RT)
84
Pau Espin Pedrol639c4082017-07-06 10:45:22 +020085AC_ARG_ENABLE(doxygen,
86 [AS_HELP_STRING(
87 [--disable-doxygen],
88 [Disable generation of documentation using doxygen],
89 )],
90 [doxygen=$enableval], [doxygen="yes"])
Harald Welte21e73c22011-08-17 19:33:06 +020091AC_PATH_PROG(DOXYGEN,doxygen,false)
Pau Espin Pedrol639c4082017-07-06 10:45:22 +020092AM_CONDITIONAL(HAVE_DOXYGEN, test $DOXYGEN != false && test "x$doxygen" = "xyes")
Harald Welte21e73c22011-08-17 19:33:06 +020093
Max4b2b0cc2017-07-10 14:32:48 +020094# check for syscal fallback on glibc < 2.25 - can be removed once glibc version requirement is bumped
95AC_CHECK_DECLS([SYS_getrandom], [], [], [[#include <sys/syscall.h>]])
96
Harald Welte3cae0392010-02-20 21:09:24 +010097# The following test is taken from WebKit's webkit.m4
98saved_CFLAGS="$CFLAGS"
99CFLAGS="$CFLAGS -fvisibility=hidden "
100AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
Alexander Huemer3d79f532011-05-24 15:16:13 +0200101AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
Harald Welte3cae0392010-02-20 21:09:24 +0100102 [ AC_MSG_RESULT([yes])
103 SYMBOL_VISIBILITY="-fvisibility=hidden"],
104 AC_MSG_RESULT([no]))
105CFLAGS="$saved_CFLAGS"
106AC_SUBST(SYMBOL_VISIBILITY)
107
Pau Espin Pedrol47eb4e12020-05-01 16:51:20 +0200108AC_CHECK_FUNCS(localtime_r)
Harald Welte14c4c492018-06-28 08:28:52 +0200109
Harald Welte7c8e2cc2012-08-29 16:47:30 +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
134
Pau Espin Pedrole188b8c2019-08-05 13:46:33 +0200135dnl 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 +0200136ARG_ENABLE_DETECT_TLS_GCC_ARM_BUG
Pau Espin Pedrole188b8c2019-08-05 13:46:33 +0200137
Harald Welte3cae0392010-02-20 21:09:24 +0100138dnl Generate the output
Christian Vogel854debc2013-01-05 20:30:41 +0100139AC_CONFIG_HEADER(config.h)
Harald Welte3cae0392010-02-20 21:09:24 +0100140
Harald Welte90e614f2015-12-05 23:38:18 +0100141PKG_CHECK_MODULES(TALLOC, [talloc >= 2.0.1])
142
Harald Welte495fe262012-09-10 16:28:17 +0200143AC_ARG_ENABLE([pcsc], [AS_HELP_STRING([--disable-pcsc], [Build without PC/SC support])],
144 [
Neels Hofmeyr96831042016-11-15 17:31:14 +0100145 ENABLE_PCSC=$enableval
Harald Welte495fe262012-09-10 16:28:17 +0200146 ],
147 [
Neels Hofmeyr96831042016-11-15 17:31:14 +0100148 ENABLE_PCSC="yes"
Harald Welte495fe262012-09-10 16:28:17 +0200149 ])
Neels Hofmeyr96831042016-11-15 17:31:14 +0100150AS_IF([test "x$ENABLE_PCSC" = "xyes"], [
Holger Hans Peter Freyther18bcc8a2014-11-14 15:06:09 +0100151 PKG_CHECK_MODULES(PCSC, libpcsclite)
Harald Welte3c44a642020-03-15 22:50:06 +0100152 AC_DEFINE([HAVE_PCSC],[1],[Build with PC/SC support])
Harald Welted086f212015-11-21 11:38:09 +0100153])
Neels Hofmeyr96831042016-11-15 17:31:14 +0100154AM_CONDITIONAL(ENABLE_PCSC, test "x$ENABLE_PCSC" = "xyes")
155AC_SUBST(ENABLE_PCSC)
Harald Welte495fe262012-09-10 16:28:17 +0200156
Harald Welteda432cd2019-12-15 19:13:26 +0100157AC_ARG_ENABLE([libusb], [AS_HELP_STRING([--disable-libusb], [Build without libusb support])],
158 [
159 ENABLE_LIBUSB=$enableval
160 ],
161 [
162 ENABLE_LIBUSB="yes"
163 ])
164AS_IF([test "x$ENABLE_LIBUSB" = "xyes"], [
165 PKG_CHECK_MODULES(LIBUSB, libusb-1.0)
166])
167AM_CONDITIONAL(ENABLE_LIBUSB, test "x$ENABLE_LIBUSB" = "xyes")
168AC_SUBST(ENABLE_LIBUSB)
169
Maxed029df2017-10-26 10:56:04 +0200170AC_ARG_ENABLE([gnutls], [AS_HELP_STRING([--disable-gnutls], [Do not use GnuTLS fallback for missing getrandom()])],
171 [ENABLE_GNUTLS=$enableval], [ENABLE_GNUTLS="yes"])
172AM_CONDITIONAL(ENABLE_GNUTLS, test x"$ENABLE_GNUTLS" = x"yes")
173AS_IF([test "x$ENABLE_GNUTLS" = "xyes"], [
174 PKG_CHECK_MODULES([LIBGNUTLS], [gnutls >= 2.12.0])
175])
176AC_SUBST(ENABLE_GNUTLS)
177if test x"$ENABLE_GNUTLS" = x"yes"
178then
179 AC_SUBST([LIBGNUTLS_CFLAGS])
180 AC_SUBST([LIBGNUTLS_LIBS])
181 AC_DEFINE([USE_GNUTLS], [1], [Use GnuTLS as a fallback for missing getrandom()])
182fi
183
Vadim Yanitskiye7bf4352020-09-09 03:36:48 +0700184AC_ARG_ENABLE([systemd_logging],
185 [AS_HELP_STRING(
186 [--enable-systemd-logging],
187 [Build with systemd-journal logging support]
188 )],
189 [systemd_logging=$enableval], [systemd_logging="no"])
190AS_IF([test "x$systemd_logging" = "xyes"], [
191 PKG_CHECK_MODULES(SYSTEMD, libsystemd)
192 AC_DEFINE([ENABLE_SYSTEMD_LOGGING], [1], [Enable systemd-journal logging target])
193])
194AM_CONDITIONAL(ENABLE_SYSTEMD_LOGGING, test "x$systemd_logging" = "xyes")
195AC_SUBST(ENABLE_SYSTEMD_LOGGING)
196
Harald Welte53a2fde2020-12-01 22:21:14 +0100197AC_ARG_ENABLE([libmnl],
198 [AS_HELP_STRING(
199 [--disable-libmnl],
200 [Build without netlink socket support via libmnl]
201 )],
202 [mnl=$enableval], [mnl="yes"])
203AS_IF([test "x$mnl" = "xyes"], [
204 PKG_CHECK_MODULES(LIBMNL, libmnl)
205 AC_DEFINE([ENABLE_LIBMNL], [1], [Enable netlink socket support via libmnl])
206])
207AM_CONDITIONAL(ENABLE_LIBMNL, test "x$mnl" = "xyes")
208AC_SUBST(ENABLE_LIBMNL)
209
Pau Espin Pedrolea2afb22019-10-24 15:41:32 +0200210AC_ARG_ENABLE([libsctp], [AS_HELP_STRING([--disable-libsctp], [Do not enable socket multiaddr APIs requiring libsctp])],
211 [ENABLE_LIBSCTP=$enableval], [ENABLE_LIBSCTP="yes"])
212AM_CONDITIONAL(ENABLE_LIBSCTP, test x"$ENABLE_LIBSCTP" = x"yes")
213AS_IF([test "x$ENABLE_LIBSCTP" = "xyes"], [
214 old_LIBS=$LIBS
215 AC_SEARCH_LIBS([sctp_bindx], [sctp], [
216 AC_DEFINE(HAVE_LIBSCTP, 1, [Define 1 to enable SCTP support])
217 AC_SUBST(HAVE_LIBSCTP, [1])
218 if test -n "$ac_lib"; then
219 AC_SUBST(LIBSCTP_LIBS, [-l$ac_lib])
220 fi
221 ], [
222 AC_MSG_ERROR([sctp_bindx not found in searched libs])])
223 LIBS=$old_LIBS
224])
225
Pau Espin Pedrol16b076c2020-08-25 13:56:43 +0200226AC_ARG_ENABLE([sctp-tests], [AS_HELP_STRING([--disable-sctp-tests], [Do not run socket tests requiring system SCTP support])],
227 [ENABLE_SCTP_TESTS=$enableval], [ENABLE_SCTP_TESTS="yes"])
228AM_CONDITIONAL(ENABLE_SCTP_TESTS, test x"$ENABLE_SCTP_TESTS" = x"yes")
229
Harald Welteb9ce51c2010-06-30 19:43:11 +0200230AC_ARG_ENABLE(plugin,
Sylvain Munautf23abab2010-07-25 16:16:42 +0200231 [AS_HELP_STRING(
232 [--disable-plugin],
233 [Disable support for dlopen plugins],
234 )],
job36b4a202011-08-21 17:18:23 +0200235 [enable_plugin=$enableval], [enable_plugin="yes"])
236AM_CONDITIONAL(ENABLE_PLUGIN, test x"$enable_plugin" = x"yes")
Harald Welteb9ce51c2010-06-30 19:43:11 +0200237
Harald Welte1067e8c2010-06-25 03:00:58 +0200238AC_ARG_ENABLE(vty,
Sylvain Munautf23abab2010-07-25 16:16:42 +0200239 [AS_HELP_STRING(
240 [--disable-vty],
241 [Disable building VTY telnet interface]
242 )],
job36b4a202011-08-21 17:18:23 +0200243 [enable_vty=$enableval], [enable_vty="yes"])
244AM_CONDITIONAL(ENABLE_VTY, test x"$enable_vty" = x"yes")
Harald Welte54403772010-05-29 11:49:51 +0200245
Sylvain Munautac3e61a2010-07-25 18:08:54 +0200246AC_ARG_ENABLE(panic_infloop,
247 [AS_HELP_STRING(
248 [--enable-panic-infloop],
249 [Trigger infinite loop on panic rather than fprintf/abort]
250 )],
job36b4a202011-08-21 17:18:23 +0200251 [panic_infloop=$enableval], [panic_infloop="no"])
252if test x"$panic_infloop" = x"yes"
Sylvain Munautac3e61a2010-07-25 18:08:54 +0200253then
254 AC_DEFINE([PANIC_INFLOOP],[1],[Use infinite loop on panic rather than fprintf/abort])
255fi
256
Holger Hans Peter Freyther43558312010-08-06 06:48:43 +0800257AC_ARG_ENABLE(bsc_fd_check,
258 [AS_HELP_STRING(
259 [--enable-bsc-fd-check],
Pau Espin Pedrold05def02020-05-09 19:24:21 +0200260 [Instrument osmo_fd_register to check that the fd is registered]
Holger Hans Peter Freyther43558312010-08-06 06:48:43 +0800261 )],
job36b4a202011-08-21 17:18:23 +0200262 [fd_check=$enableval], [fd_check="no"])
263if test x"$fd_check" = x"no"
Holger Hans Peter Freyther43558312010-08-06 06:48:43 +0800264then
Pau Espin Pedrold05def02020-05-09 19:24:21 +0200265 AC_DEFINE([OSMO_FD_CHECK],[1],[Instrument the osmo_fd_register])
Holger Hans Peter Freyther43558312010-08-06 06:48:43 +0800266fi
267
Harald Welteb904e422020-10-18 21:24:13 +0200268AC_ARG_ENABLE([force_io_select],
269 [AS_HELP_STRING(
270 [--enable-force-io-select],
271 [Build with old select I/O instead of poll]
272 )],
273 [force_io_select=$enableval], [force_io_select="no"])
274AS_IF([test "x$force_io_select" = "xyes"], [
275 AC_DEFINE([FORCE_IO_SELECT], [1], [Force the use of select() instaed of poll()])
276])
277
Holger Hans Peter Freytherc87f2662010-10-07 00:00:15 +0800278AC_ARG_ENABLE(msgfile,
279 [AS_HELP_STRING(
280 [--disable-msgfile],
281 [Disable support for the msgfile],
282 )],
job36b4a202011-08-21 17:18:23 +0200283 [enable_msgfile=$enableval], [enable_msgfile="yes"])
284AM_CONDITIONAL(ENABLE_MSGFILE, test x"$enable_msgfile" = x"yes")
Holger Hans Peter Freytherc87f2662010-10-07 00:00:15 +0800285
Sylvain Munautfe28ded2011-09-02 22:18:24 +0200286AC_ARG_ENABLE(serial,
287 [AS_HELP_STRING(
288 [--disable-serial],
289 [Disable support for the serial helpers],
290 )],
291 [enable_serial=$enableval], [enable_serial="yes"])
292AM_CONDITIONAL(ENABLE_SERIAL, test x"$enable_serial" = x"yes")
293
job8e4deb62011-08-21 17:18:24 +0200294AC_ARG_ENABLE(utilities,
295 [AS_HELP_STRING(
296 [--disable-utilities],
297 [Disable building utility programs],
298 )],
299 [enable_utilities=$enableval], [enable_utilities="yes"])
300AM_CONDITIONAL(ENABLE_UTILITIES, test x"$enable_utilities" = x"yes")
301
Harald Weltee3a10b62012-09-08 22:18:43 +0200302AC_ARG_ENABLE(gb,
303 [AS_HELP_STRING(
304 [--disable-gb],
305 [Disable building Gb library],
306 )],
307 [enable_gb=$enableval], [enable_gb="yes"])
308AM_CONDITIONAL(ENABLE_GB, test x"$enable_gb" = x"yes")
309
Harald Welte1c67e752017-01-15 17:52:30 +0100310AC_ARG_ENABLE(ctrl,
311 [AS_HELP_STRING(
312 [--disable-ctrl],
313 [Disable building CTRL library],
314 )],
315 [enable_ctrl=$enableval], [enable_ctrl="yes"])
316AM_CONDITIONAL(ENABLE_CTRL, test x"$enable_ctrl" = x"yes")
317
Harald Welte898ffef2017-05-15 21:37:34 +0200318AC_ARG_ENABLE(pseudotalloc,
319 [AS_HELP_STRING(
320 [--enable-pseudotalloc],
321 [Enable building pseudotalloc library],
322 )],
323 [enable_pseudotalloc=$enableval], [enable_pseudotalloc="no"])
324AM_CONDITIONAL(ENABLE_PSEUDOTALLOC, test x"$enable_pseudotalloc" = x"yes")
325
job8e4deb62011-08-21 17:18:24 +0200326AC_ARG_ENABLE(embedded,
327 [AS_HELP_STRING(
328 [--enable-embedded],
329 [Enable building for embedded use and disable unsupported features]
330 )],
331 [embedded=$enableval], [embedded="no"])
Max89c8c402018-01-18 16:05:27 +0100332
Harald Weltec6a86972019-12-16 23:14:45 +0100333AM_CONDITIONAL(EMBEDDED, false)
Max3da79382018-01-18 16:50:51 +0100334AM_CONDITIONAL(ENABLE_SERCOM_STUB, false)
Max89c8c402018-01-18 16:05:27 +0100335
job8e4deb62011-08-21 17:18:24 +0200336if test x"$embedded" = x"yes"
337then
338 AC_DEFINE([EMBEDDED],[1],[Select building for embedded use])
job8e4deb62011-08-21 17:18:24 +0200339 AM_CONDITIONAL(ENABLE_PLUGIN, false)
340 AM_CONDITIONAL(ENABLE_MSGFILE, false)
Sylvain Munautfe28ded2011-09-02 22:18:24 +0200341 AM_CONDITIONAL(ENABLE_SERIAL, false)
Maxed029df2017-10-26 10:56:04 +0200342 AM_CONDITIONAL(ENABLE_GNUTLS, false)
job8e4deb62011-08-21 17:18:24 +0200343 AM_CONDITIONAL(ENABLE_VTY, false)
Harald Welte1c67e752017-01-15 17:52:30 +0100344 AM_CONDITIONAL(ENABLE_CTRL, false)
job8e4deb62011-08-21 17:18:24 +0200345 AM_CONDITIONAL(ENABLE_UTILITIES, false)
Harald Weltee3a10b62012-09-08 22:18:43 +0200346 AM_CONDITIONAL(ENABLE_GB, false)
Maxed029df2017-10-26 10:56:04 +0200347 AM_CONDITIONAL(ENABLE_GNUTLS, false)
Pau Espin Pedrolea2afb22019-10-24 15:41:32 +0200348 AM_CONDITIONAL(ENABLE_LIBSCTP, false)
Harald Welte1a7d64c2017-01-15 17:53:23 +0100349 AM_CONDITIONAL(ENABLE_PCSC, false)
Harald Welte898ffef2017-05-15 21:37:34 +0200350 AM_CONDITIONAL(ENABLE_PSEUDOTALLOC, true)
Max3da79382018-01-18 16:50:51 +0100351 AM_CONDITIONAL(ENABLE_SERCOM_STUB, true)
Harald Weltec6a86972019-12-16 23:14:45 +0100352 AM_CONDITIONAL(EMBEDDED, true)
Maxed029df2017-10-26 10:56:04 +0200353 AC_DEFINE([USE_GNUTLS], [0])
job8e4deb62011-08-21 17:18:24 +0200354 AC_DEFINE([PANIC_INFLOOP],[1],[Use infinite loop on panic rather than fprintf/abort])
355fi
Harald Welte54403772010-05-29 11:49:51 +0200356
Neels Hofmeyra2381762016-09-30 01:25:45 +0200357AC_ARG_ENABLE(sanitize,
358 [AS_HELP_STRING(
359 [--enable-sanitize],
360 [Compile with address sanitizer enabled],
361 )],
362 [sanitize=$enableval], [sanitize="no"])
363if test x"$sanitize" = x"yes"
364then
Pau Espin Pedrol13492492017-06-23 11:18:04 +0200365 CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined"
366 CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
Neels Hofmeyra2381762016-09-30 01:25:45 +0200367fi
368
Neels Hofmeyr09ecbb72018-03-05 20:40:05 +0100369AC_ARG_ENABLE(werror,
370 [AS_HELP_STRING(
371 [--enable-werror],
372 [Turn all compiler warnings into errors, with exceptions:
373 a) deprecation (allow upstream to mark deprecation without breaking builds);
374 b) "#warning" pragmas (allow to remind ourselves of errors without breaking builds)
375 ]
376 )],
377 [werror=$enableval], [werror="no"])
378if test x"$werror" = x"yes"
379then
380 WERROR_FLAGS="-Werror"
381 WERROR_FLAGS+=" -Wno-error=deprecated -Wno-error=deprecated-declarations"
382 WERROR_FLAGS+=" -Wno-error=cpp" # "#warning"
383 CFLAGS="$CFLAGS $WERROR_FLAGS"
384 CPPFLAGS="$CPPFLAGS $WERROR_FLAGS"
385fi
386
Neels Hofmeyr3a9ff112018-09-10 17:18:28 +0200387AC_ARG_ENABLE([external_tests],
388 AC_HELP_STRING([--enable-external-tests],
389 [Include the VTY/CTRL tests in make check [default=no]]),
390 [enable_ext_tests="$enableval"],[enable_ext_tests="no"])
391if test "x$enable_ext_tests" = "xyes" ; then
392 AM_PATH_PYTHON
393 AC_CHECK_PROG(OSMOTESTEXT_CHECK,osmo_verify_transcript_vty.py,yes)
394 if test "x$OSMOTESTEXT_CHECK" != "xyes" ; then
395 AC_MSG_ERROR([Please install git://osmocom.org/python/osmo-python-tests to run the VTY/CTRL tests.])
396 fi
397fi
398AC_MSG_CHECKING([whether to enable VTY/CTRL tests])
399AC_MSG_RESULT([$enable_ext_tests])
400AM_CONDITIONAL(ENABLE_EXT_TESTS, test "x$enable_ext_tests" = "xyes")
401
Pau Espin Pedrol13492492017-06-23 11:18:04 +0200402CFLAGS="$CFLAGS -DBUILDING_LIBOSMOCORE -Wall"
403CPPFLAGS="$CPPFLAGS -DBUILDING_LIBOSMOCORE -Wall"
Pau Espin Pedrol69dfe5a2017-06-17 23:18:11 +0200404
Vadim Yanitskiy2c3066e2017-04-30 19:41:56 +0700405AC_ARG_ENABLE(simd,
406 [AS_HELP_STRING(
407 [--disable-simd],
408 [Disable SIMD support]
409 )],
410 [simd=$enableval], [simd="yes"])
411if test x"$simd" = x"yes"
412then
413 # Find and define supported SIMD extensions
414 AX_CHECK_SIMD
415else
416 AM_CONDITIONAL(HAVE_AVX2, false)
Harald Welteb93f60f2017-11-17 11:41:34 +0100417 AM_CONDITIONAL(HAVE_SSSE3, false)
Vadim Yanitskiy2c3066e2017-04-30 19:41:56 +0700418 AM_CONDITIONAL(HAVE_SSE4_1, false)
419fi
420
Eric3afc1d12020-07-23 02:16:46 +0200421AC_ARG_ENABLE(neon,
422 [AS_HELP_STRING(
423 [--enable-neon],
Vadim Yanitskiy325d9b32020-08-07 03:53:40 +0700424 [Enable ARM NEON instructions support [default=no]]
Eric3afc1d12020-07-23 02:16:46 +0200425 )],
426 [neon=$enableval], [neon="no"])
Vadim Yanitskiy7dbae9e2020-08-07 04:01:12 +0700427AC_MSG_CHECKING([whether to enable ARM NEON instructions support])
428AC_MSG_RESULT([$neon])
Eric3afc1d12020-07-23 02:16:46 +0200429AM_CONDITIONAL(HAVE_NEON, [test "x$neon" != "xno"])
430
431
Vasil Velichkov499510b2019-04-03 02:32:37 +0300432OSMO_AC_CODE_COVERAGE
433
Vadim Yanitskiya8a58192017-05-08 00:07:21 +0700434dnl Check if the compiler supports specified GCC's built-in function
435AC_DEFUN([CHECK_BUILTIN_SUPPORT], [
436 AC_CACHE_CHECK(
437 [whether ${CC} has $1 built-in],
438 [osmo_cv_cc_has_builtin], [
439 AC_LINK_IFELSE([
440 AC_LANG_PROGRAM([], [
441 __builtin_cpu_supports("sse");
442 ])
443 ],
444 [AS_VAR_SET([osmo_cv_cc_has_builtin], [yes])],
445 [AS_VAR_SET([osmo_cv_cc_has_builtin], [no])])
446 ]
447 )
448
449 AS_IF([test yes = AS_VAR_GET([osmo_cv_cc_has_builtin])], [
450 AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$1), 1,
451 [Define to 1 if compiler has the '$1' built-in function])
452 ], [
453 AC_MSG_WARN($2)
454 ])
455])
456
457dnl Check if the compiler supports runtime SIMD detection
458CHECK_BUILTIN_SUPPORT([__builtin_cpu_supports],
459 [Runtime SIMD detection will be disabled])
460
Neels Hofmeyr09ecbb72018-03-05 20:40:05 +0100461AC_MSG_RESULT([CFLAGS="$CFLAGS"])
462AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
463
Harald Welte3cae0392010-02-20 21:09:24 +0100464AC_OUTPUT(
465 libosmocore.pc
Sylvain Munautb99b9302010-10-24 18:23:10 +0200466 libosmocodec.pc
Vadim Yanitskiy3262f822016-09-23 01:48:59 +0700467 libosmocoding.pc
Harald Weltee352c522010-05-19 19:42:32 +0200468 libosmovty.pc
Pablo Neira Ayusofba495e2011-03-23 18:08:08 +0100469 libosmogsm.pc
Harald Welte641f7ce2012-06-17 23:05:26 +0800470 libosmogb.pc
Harald Welte3ff81b12014-08-20 19:58:40 +0200471 libosmoctrl.pc
Harald Welted54c2ee2012-01-17 18:25:50 +0100472 libosmosim.pc
Harald Welteda432cd2019-12-15 19:13:26 +0100473 libosmousb.pc
Harald Welte3cae0392010-02-20 21:09:24 +0100474 include/Makefile
475 src/Makefile
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200476 src/vty/Makefile
Sylvain Munaut1a4ea5b2010-10-08 15:09:16 +0200477 src/codec/Makefile
Vadim Yanitskiy3262f822016-09-23 01:48:59 +0700478 src/coding/Makefile
Harald Welted54c2ee2012-01-17 18:25:50 +0100479 src/sim/Makefile
Harald Welteda432cd2019-12-15 19:13:26 +0100480 src/usb/Makefile
Pablo Neira Ayusofba495e2011-03-23 18:08:08 +0100481 src/gsm/Makefile
Harald Welte641f7ce2012-06-17 23:05:26 +0800482 src/gb/Makefile
Harald Welte3ff81b12014-08-20 19:58:40 +0200483 src/ctrl/Makefile
Harald Welte898ffef2017-05-15 21:37:34 +0200484 src/pseudotalloc/Makefile
Harald Welte3cae0392010-02-20 21:09:24 +0100485 tests/Makefile
Neels Hofmeyr96831042016-11-15 17:31:14 +0100486 tests/atlocal
Harald Welteeeb78dd2011-08-02 13:44:54 +0200487 utils/Makefile
Harald Weltec7859ed2011-08-20 12:54:17 +0200488 Doxyfile.core
Harald Welte49e10562011-08-17 19:21:07 +0200489 Doxyfile.gsm
490 Doxyfile.vty
491 Doxyfile.codec
Vadim Yanitskiy3262f822016-09-23 01:48:59 +0700492 Doxyfile.coding
Neels Hofmeyr249fb712017-06-20 02:52:38 +0200493 Doxyfile.gb
Harald Welteb4186822018-05-26 17:25:11 +0200494 Doxyfile.ctrl
Oliver Smith6370f5d2020-05-14 11:27:08 +0200495 Makefile
496 contrib/libosmocore.spec)