blob: 04d126e2a77f12b63e4abe922dba94064b3e3934 [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
14dnl checks for programs
15AC_PROG_MAKE_SET
Diego Elio Pettenòd471a212012-06-29 13:01:19 -070016AC_PROG_MKDIR_P
Harald Welte3cae0392010-02-20 21:09:24 +010017AC_PROG_CC
18AC_PROG_INSTALL
Jan Engelhardtc2ddc4f2015-09-16 14:32:31 +020019LT_INIT([pic-only disable-static])
Harald Welte3cae0392010-02-20 21:09:24 +010020
Harald Welte4cd3d8a2010-03-23 00:30:19 +080021AC_CONFIG_MACRO_DIR([m4])
22
Neels Hofmeyrfef2fa22016-08-08 15:38:35 +020023dnl check for pkg-config
24dnl * If pkg-config is missing, we get a "syntax error" for PKG_CHECK_MODULES.
25dnl Instead, we want to say that pkg-config and pkg.m4 are missing.
26dnl * The proper way is PKG_PROG_PKG_CONFIG() but unfortunately that does not
27dnl produce an intelligible error message if pkg-config is missing entirely
28dnl ("syntax error near unexpected token `0.20'").
29dnl * To produce a hint that pkg-config is missing, check for the pkg-config
30dnl binary; but AC_PATH_PROG breaks if the distribution provides only
31dnl prefixed (<arch>-pkg-config) versions, so just print a warning.
32AC_PATH_PROG(PKG_CONFIG_INSTALLED, pkg-config, no)
33if test "x$PKG_CONFIG_INSTALLED" = "xno"; then
34 AC_MSG_WARN([You need to install pkg-config])
35fi
36PKG_PROG_PKG_CONFIG([0.20])
37
Tobias Engel597460f2012-10-24 17:52:52 +020038dnl check os: some linker flags not available on osx
39case $host in
40*-darwin*)
41 ;;
42*)
43 LTLDFLAGS_OSMOGB='-Wl,--version-script=$(srcdir)/libosmogb.map'
44 LTLDFLAGS_OSMOGSM='-Wl,--version-script=$(srcdir)/libosmogsm.map'
Vadim Yanitskiy3262f822016-09-23 01:48:59 +070045 LTLDFLAGS_OSMOCODING='-Wl,--version-script=$(srcdir)/libosmocoding.map'
Tobias Engel597460f2012-10-24 17:52:52 +020046 ;;
47esac
48AC_SUBST(LTLDFLAGS_OSMOGB)
49AC_SUBST(LTLDFLAGS_OSMOGSM)
50
Harald Welte3cae0392010-02-20 21:09:24 +010051dnl checks for header files
52AC_HEADER_STDC
Harald Weltee15ac062014-12-04 14:15:36 +010053AC_CHECK_HEADERS(execinfo.h sys/select.h sys/socket.h syslog.h ctype.h netinet/tcp.h)
Holger Hans Peter Freyther47723482011-11-09 11:26:15 +010054# for src/conv.c
55AC_FUNC_ALLOCA
56AC_SEARCH_LIBS([dlopen], [dl dld], [LIBRARY_DL="$LIBS";LIBS=""])
57AC_SUBST(LIBRARY_DL)
Holger Hans Peter Freytherc2c042d2014-04-17 23:19:10 +020058# for src/backtrace.c
59AC_CHECK_LIB(execinfo, backtrace, BACKTRACE_LIB=-lexecinfo, BACKTRACE_LIB=)
60AC_SUBST(BACKTRACE_LIB)
Harald Welte3cae0392010-02-20 21:09:24 +010061
Harald Welte21e73c22011-08-17 19:33:06 +020062AC_PATH_PROG(DOXYGEN,doxygen,false)
63AM_CONDITIONAL(HAVE_DOXYGEN, test $DOXYGEN != false)
64
Harald Welte3cae0392010-02-20 21:09:24 +010065# The following test is taken from WebKit's webkit.m4
66saved_CFLAGS="$CFLAGS"
67CFLAGS="$CFLAGS -fvisibility=hidden "
68AC_MSG_CHECKING([if ${CC} supports -fvisibility=hidden])
Alexander Huemer3d79f532011-05-24 15:16:13 +020069AC_COMPILE_IFELSE([AC_LANG_SOURCE([char foo;])],
Harald Welte3cae0392010-02-20 21:09:24 +010070 [ AC_MSG_RESULT([yes])
71 SYMBOL_VISIBILITY="-fvisibility=hidden"],
72 AC_MSG_RESULT([no]))
73CFLAGS="$saved_CFLAGS"
74AC_SUBST(SYMBOL_VISIBILITY)
75
Harald Welte7c8e2cc2012-08-29 16:47:30 +020076AC_DEFUN([CHECK_TM_INCLUDES_TM_GMTOFF], [
77 AC_CACHE_CHECK(
78 [whether struct tm has tm_gmtoff member],
79 osmo_cv_tm_includes_tm_gmtoff,
80 [AC_LINK_IFELSE([
81 AC_LANG_PROGRAM([
82 #include <time.h>
83 ], [
84 time_t t = time(NULL);
85 struct tm* lt = localtime(&t);
86 int off = lt->tm_gmtoff;
87 ])
88 ],
89 osmo_cv_tm_includes_tm_gmtoff=yes,
90 osmo_cv_tm_includes_tm_gmtoff=no
91 )]
92 )
93 if test "x$osmo_cv_tm_includes_tm_gmtoff" = xyes; then
94 AC_DEFINE(HAVE_TM_GMTOFF_IN_TM, 1,
95 [Define if struct tm has tm_gmtoff member.])
96 fi
97])
98
99CHECK_TM_INCLUDES_TM_GMTOFF
100
Harald Welte3cae0392010-02-20 21:09:24 +0100101dnl Generate the output
Christian Vogel854debc2013-01-05 20:30:41 +0100102AC_CONFIG_HEADER(config.h)
Harald Welte3cae0392010-02-20 21:09:24 +0100103
Harald Welte90e614f2015-12-05 23:38:18 +0100104PKG_CHECK_MODULES(TALLOC, [talloc >= 2.0.1])
105
Harald Welte495fe262012-09-10 16:28:17 +0200106AC_ARG_ENABLE([pcsc], [AS_HELP_STRING([--disable-pcsc], [Build without PC/SC support])],
107 [
Neels Hofmeyr96831042016-11-15 17:31:14 +0100108 ENABLE_PCSC=$enableval
Harald Welte495fe262012-09-10 16:28:17 +0200109 ],
110 [
Neels Hofmeyr96831042016-11-15 17:31:14 +0100111 ENABLE_PCSC="yes"
Harald Welte495fe262012-09-10 16:28:17 +0200112 ])
Neels Hofmeyr96831042016-11-15 17:31:14 +0100113AS_IF([test "x$ENABLE_PCSC" = "xyes"], [
Holger Hans Peter Freyther18bcc8a2014-11-14 15:06:09 +0100114 PKG_CHECK_MODULES(PCSC, libpcsclite)
Harald Welted086f212015-11-21 11:38:09 +0100115])
Neels Hofmeyr96831042016-11-15 17:31:14 +0100116AM_CONDITIONAL(ENABLE_PCSC, test "x$ENABLE_PCSC" = "xyes")
117AC_SUBST(ENABLE_PCSC)
Harald Welte495fe262012-09-10 16:28:17 +0200118
Harald Welteb9ce51c2010-06-30 19:43:11 +0200119AC_ARG_ENABLE(plugin,
Sylvain Munautf23abab2010-07-25 16:16:42 +0200120 [AS_HELP_STRING(
121 [--disable-plugin],
122 [Disable support for dlopen plugins],
123 )],
job36b4a202011-08-21 17:18:23 +0200124 [enable_plugin=$enableval], [enable_plugin="yes"])
125AM_CONDITIONAL(ENABLE_PLUGIN, test x"$enable_plugin" = x"yes")
Harald Welteb9ce51c2010-06-30 19:43:11 +0200126
Harald Welte1067e8c2010-06-25 03:00:58 +0200127AC_ARG_ENABLE(vty,
Sylvain Munautf23abab2010-07-25 16:16:42 +0200128 [AS_HELP_STRING(
129 [--disable-vty],
130 [Disable building VTY telnet interface]
131 )],
job36b4a202011-08-21 17:18:23 +0200132 [enable_vty=$enableval], [enable_vty="yes"])
133AM_CONDITIONAL(ENABLE_VTY, test x"$enable_vty" = x"yes")
Harald Welte54403772010-05-29 11:49:51 +0200134
Sylvain Munautac3e61a2010-07-25 18:08:54 +0200135AC_ARG_ENABLE(panic_infloop,
136 [AS_HELP_STRING(
137 [--enable-panic-infloop],
138 [Trigger infinite loop on panic rather than fprintf/abort]
139 )],
job36b4a202011-08-21 17:18:23 +0200140 [panic_infloop=$enableval], [panic_infloop="no"])
141if test x"$panic_infloop" = x"yes"
Sylvain Munautac3e61a2010-07-25 18:08:54 +0200142then
143 AC_DEFINE([PANIC_INFLOOP],[1],[Use infinite loop on panic rather than fprintf/abort])
144fi
145
Holger Hans Peter Freyther43558312010-08-06 06:48:43 +0800146AC_ARG_ENABLE(bsc_fd_check,
147 [AS_HELP_STRING(
148 [--enable-bsc-fd-check],
149 [Instrument bsc_register_fd to check that the fd is registered]
150 )],
job36b4a202011-08-21 17:18:23 +0200151 [fd_check=$enableval], [fd_check="no"])
152if test x"$fd_check" = x"no"
Holger Hans Peter Freyther43558312010-08-06 06:48:43 +0800153then
154 AC_DEFINE([BSC_FD_CHECK],[1],[Instrument the bsc_register_fd])
155fi
156
Holger Hans Peter Freytherc87f2662010-10-07 00:00:15 +0800157AC_ARG_ENABLE(msgfile,
158 [AS_HELP_STRING(
159 [--disable-msgfile],
160 [Disable support for the msgfile],
161 )],
job36b4a202011-08-21 17:18:23 +0200162 [enable_msgfile=$enableval], [enable_msgfile="yes"])
163AM_CONDITIONAL(ENABLE_MSGFILE, test x"$enable_msgfile" = x"yes")
Holger Hans Peter Freytherc87f2662010-10-07 00:00:15 +0800164
Sylvain Munautfe28ded2011-09-02 22:18:24 +0200165AC_ARG_ENABLE(serial,
166 [AS_HELP_STRING(
167 [--disable-serial],
168 [Disable support for the serial helpers],
169 )],
170 [enable_serial=$enableval], [enable_serial="yes"])
171AM_CONDITIONAL(ENABLE_SERIAL, test x"$enable_serial" = x"yes")
172
job8e4deb62011-08-21 17:18:24 +0200173AC_ARG_ENABLE(utilities,
174 [AS_HELP_STRING(
175 [--disable-utilities],
176 [Disable building utility programs],
177 )],
178 [enable_utilities=$enableval], [enable_utilities="yes"])
179AM_CONDITIONAL(ENABLE_UTILITIES, test x"$enable_utilities" = x"yes")
180
Harald Weltee3a10b62012-09-08 22:18:43 +0200181AC_ARG_ENABLE(gb,
182 [AS_HELP_STRING(
183 [--disable-gb],
184 [Disable building Gb library],
185 )],
186 [enable_gb=$enableval], [enable_gb="yes"])
187AM_CONDITIONAL(ENABLE_GB, test x"$enable_gb" = x"yes")
188
Harald Welte1c67e752017-01-15 17:52:30 +0100189AC_ARG_ENABLE(ctrl,
190 [AS_HELP_STRING(
191 [--disable-ctrl],
192 [Disable building CTRL library],
193 )],
194 [enable_ctrl=$enableval], [enable_ctrl="yes"])
195AM_CONDITIONAL(ENABLE_CTRL, test x"$enable_ctrl" = x"yes")
196
Harald Welte898ffef2017-05-15 21:37:34 +0200197AC_ARG_ENABLE(pseudotalloc,
198 [AS_HELP_STRING(
199 [--enable-pseudotalloc],
200 [Enable building pseudotalloc library],
201 )],
202 [enable_pseudotalloc=$enableval], [enable_pseudotalloc="no"])
203AM_CONDITIONAL(ENABLE_PSEUDOTALLOC, test x"$enable_pseudotalloc" = x"yes")
204
job8e4deb62011-08-21 17:18:24 +0200205AC_ARG_ENABLE(embedded,
206 [AS_HELP_STRING(
207 [--enable-embedded],
208 [Enable building for embedded use and disable unsupported features]
209 )],
210 [embedded=$enableval], [embedded="no"])
211if test x"$embedded" = x"yes"
212then
213 AC_DEFINE([EMBEDDED],[1],[Select building for embedded use])
job8e4deb62011-08-21 17:18:24 +0200214 AM_CONDITIONAL(ENABLE_PLUGIN, false)
215 AM_CONDITIONAL(ENABLE_MSGFILE, false)
Sylvain Munautfe28ded2011-09-02 22:18:24 +0200216 AM_CONDITIONAL(ENABLE_SERIAL, false)
job8e4deb62011-08-21 17:18:24 +0200217 AM_CONDITIONAL(ENABLE_VTY, false)
Harald Welte1c67e752017-01-15 17:52:30 +0100218 AM_CONDITIONAL(ENABLE_CTRL, false)
job8e4deb62011-08-21 17:18:24 +0200219 AM_CONDITIONAL(ENABLE_UTILITIES, false)
Harald Weltee3a10b62012-09-08 22:18:43 +0200220 AM_CONDITIONAL(ENABLE_GB, false)
Harald Welte1a7d64c2017-01-15 17:53:23 +0100221 AM_CONDITIONAL(ENABLE_PCSC, false)
Harald Welte898ffef2017-05-15 21:37:34 +0200222 AM_CONDITIONAL(ENABLE_PSEUDOTALLOC, true)
job8e4deb62011-08-21 17:18:24 +0200223 AC_DEFINE([PANIC_INFLOOP],[1],[Use infinite loop on panic rather than fprintf/abort])
224fi
Harald Welte54403772010-05-29 11:49:51 +0200225
Neels Hofmeyra2381762016-09-30 01:25:45 +0200226AC_ARG_ENABLE(sanitize,
227 [AS_HELP_STRING(
228 [--enable-sanitize],
229 [Compile with address sanitizer enabled],
230 )],
231 [sanitize=$enableval], [sanitize="no"])
232if test x"$sanitize" = x"yes"
233then
234 CFLAGS+=" -fsanitize=address -fsanitize=undefined"
235 CPPFLAGS+=" -fsanitize=address -fsanitize=undefined"
236fi
237
Vadim Yanitskiy2c3066e2017-04-30 19:41:56 +0700238AC_ARG_ENABLE(simd,
239 [AS_HELP_STRING(
240 [--disable-simd],
241 [Disable SIMD support]
242 )],
243 [simd=$enableval], [simd="yes"])
244if test x"$simd" = x"yes"
245then
246 # Find and define supported SIMD extensions
247 AX_CHECK_SIMD
248else
249 AM_CONDITIONAL(HAVE_AVX2, false)
250 AM_CONDITIONAL(HAVE_SSE3, false)
251 AM_CONDITIONAL(HAVE_SSE4_1, false)
252fi
253
Vadim Yanitskiya8a58192017-05-08 00:07:21 +0700254dnl Check if the compiler supports specified GCC's built-in function
255AC_DEFUN([CHECK_BUILTIN_SUPPORT], [
256 AC_CACHE_CHECK(
257 [whether ${CC} has $1 built-in],
258 [osmo_cv_cc_has_builtin], [
259 AC_LINK_IFELSE([
260 AC_LANG_PROGRAM([], [
261 __builtin_cpu_supports("sse");
262 ])
263 ],
264 [AS_VAR_SET([osmo_cv_cc_has_builtin], [yes])],
265 [AS_VAR_SET([osmo_cv_cc_has_builtin], [no])])
266 ]
267 )
268
269 AS_IF([test yes = AS_VAR_GET([osmo_cv_cc_has_builtin])], [
270 AC_DEFINE_UNQUOTED(AS_TR_CPP(HAVE_$1), 1,
271 [Define to 1 if compiler has the '$1' built-in function])
272 ], [
273 AC_MSG_WARN($2)
274 ])
275])
276
277dnl Check if the compiler supports runtime SIMD detection
278CHECK_BUILTIN_SUPPORT([__builtin_cpu_supports],
279 [Runtime SIMD detection will be disabled])
280
Harald Welte3cae0392010-02-20 21:09:24 +0100281AC_OUTPUT(
282 libosmocore.pc
Sylvain Munautb99b9302010-10-24 18:23:10 +0200283 libosmocodec.pc
Vadim Yanitskiy3262f822016-09-23 01:48:59 +0700284 libosmocoding.pc
Harald Weltee352c522010-05-19 19:42:32 +0200285 libosmovty.pc
Pablo Neira Ayusofba495e2011-03-23 18:08:08 +0100286 libosmogsm.pc
Harald Welte641f7ce2012-06-17 23:05:26 +0800287 libosmogb.pc
Harald Welte3ff81b12014-08-20 19:58:40 +0200288 libosmoctrl.pc
Harald Welted54c2ee2012-01-17 18:25:50 +0100289 libosmosim.pc
Harald Welte3cae0392010-02-20 21:09:24 +0100290 include/Makefile
291 src/Makefile
Harald Welte3fb0b6f2010-05-19 19:02:52 +0200292 src/vty/Makefile
Sylvain Munaut1a4ea5b2010-10-08 15:09:16 +0200293 src/codec/Makefile
Vadim Yanitskiy3262f822016-09-23 01:48:59 +0700294 src/coding/Makefile
Harald Welted54c2ee2012-01-17 18:25:50 +0100295 src/sim/Makefile
Pablo Neira Ayusofba495e2011-03-23 18:08:08 +0100296 src/gsm/Makefile
Harald Welte641f7ce2012-06-17 23:05:26 +0800297 src/gb/Makefile
Harald Welte3ff81b12014-08-20 19:58:40 +0200298 src/ctrl/Makefile
Harald Welte898ffef2017-05-15 21:37:34 +0200299 src/pseudotalloc/Makefile
Harald Welte3cae0392010-02-20 21:09:24 +0100300 tests/Makefile
Neels Hofmeyr96831042016-11-15 17:31:14 +0100301 tests/atlocal
Harald Welteeeb78dd2011-08-02 13:44:54 +0200302 utils/Makefile
Harald Weltec7859ed2011-08-20 12:54:17 +0200303 Doxyfile.core
Harald Welte49e10562011-08-17 19:21:07 +0200304 Doxyfile.gsm
305 Doxyfile.vty
306 Doxyfile.codec
Vadim Yanitskiy3262f822016-09-23 01:48:59 +0700307 Doxyfile.coding
Harald Welte3cae0392010-02-20 21:09:24 +0100308 Makefile)