blob: 31ead007e517bd922e62d741c31b648400fd7179 [file] [log] [blame]
Harald Welte57f6b022012-06-14 21:05:44 +08001dnl Process this file with autoconf to produce a configure script
2AC_INIT([osmo-pcu],
3 m4_esyscmd([./git-version-gen .tarball-version]),
Holger Hans Peter Freyther57522852015-05-22 10:43:34 +08004 [osmocom-net-gprs@lists.osmocom.org])
Harald Welte57f6b022012-06-14 21:05:44 +08005
Neels Hofmeyrda933e02016-10-01 00:35:06 +02006dnl *This* is the root dir, even if an install-sh exists in ../ or ../../
7AC_CONFIG_AUX_DIR([.])
8
Harald Welte57f6b022012-06-14 21:05:44 +08009AM_INIT_AUTOMAKE([dist-bzip2])
Holger Hans Peter Freythere13298d2013-07-28 16:45:54 +020010AC_CONFIG_TESTDIR(tests)
Harald Welte57f6b022012-06-14 21:05:44 +080011
Oliver Smith04797b12019-09-18 11:15:28 +020012CXXFLAGS="$CXXFLAGS -std=gnu++03"
Oliver Smith91e35672021-01-27 17:55:04 +010013CFLAGS="$CFLAGS -std=gnu11"
Oliver Smith04797b12019-09-18 11:15:28 +020014
Harald Welte57f6b022012-06-14 21:05:44 +080015dnl kernel style compile messages
16m4_ifdef([AM_SILENT_RULES], [AM_SILENT_RULES([yes])])
17
Maxd78adfb2017-08-24 13:53:25 +020018dnl include release helper
19RELMAKE='-include osmo-release.mk'
20AC_SUBST([RELMAKE])
21
Harald Welte57f6b022012-06-14 21:05:44 +080022dnl checks for programs
23AC_PROG_MAKE_SET
24AC_PROG_CC
25AC_PROG_CXX
26AC_PROG_INSTALL
27LT_INIT
28
Pau Espin Pedrolfad557e2020-08-18 13:36:59 +020029dnl patching ${archive_cmds} to affect generation of file "libtool" to fix linking with clang
Eric2e90a1f2020-04-11 01:19:46 +020030AS_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 Hofmeyrda66f712016-10-01 00:52:10 +020034dnl check for pkg-config (explained in detail in libosmocore/configure.ac)
35AC_PATH_PROG(PKG_CONFIG_INSTALLED, pkg-config, no)
36if test "x$PKG_CONFIG_INSTALLED" = "xno"; then
37 AC_MSG_WARN([You need to install pkg-config])
38fi
39PKG_PROG_PKG_CONFIG([0.20])
40
Harald Welte57f6b022012-06-14 21:05:44 +080041dnl checks for header files
42AC_HEADER_STDC
43
44dnl Checks for typedefs, structures and compiler characteristics
45
Maxb2f0b622017-12-21 17:27:34 +010046AC_ARG_ENABLE(sanitize,
47 [AS_HELP_STRING([--enable-sanitize], [Compile with address sanitizer enabled], )],
48 [sanitize=$enableval], [sanitize="no"])
49if test x"$sanitize" = x"yes"
50then
51 CFLAGS="$CFLAGS -fsanitize=address -fsanitize=undefined"
Pau Espin Pedrol3e9c0712018-09-10 14:50:24 +020052 CXXFLAGS="$CXXFLAGS -fsanitize=address -fsanitize=undefined"
Maxb2f0b622017-12-21 17:27:34 +010053 CPPFLAGS="$CPPFLAGS -fsanitize=address -fsanitize=undefined"
Max21419622018-01-14 22:17:10 +010054 LDFLAGS="$LDFLAGS -fsanitize=address -fsanitize=undefined"
Maxb2f0b622017-12-21 17:27:34 +010055fi
56
Neels Hofmeyr5a591942018-03-05 20:44:11 +010057AC_ARG_ENABLE(werror,
58 [AS_HELP_STRING(
59 [--enable-werror],
60 [Turn all compiler warnings into errors, with exceptions:
61 a) deprecation (allow upstream to mark deprecation without breaking builds);
62 b) "#warning" pragmas (allow to remind ourselves of errors without breaking builds)
63 ]
64 )],
65 [werror=$enableval], [werror="no"])
66if test x"$werror" = x"yes"
67then
68 WERROR_FLAGS="-Werror"
69 WERROR_FLAGS+=" -Wno-error=deprecated -Wno-error=deprecated-declarations"
70 WERROR_FLAGS+=" -Wno-error=cpp" # "#warning"
71 CFLAGS="$CFLAGS $WERROR_FLAGS"
72 CPPFLAGS="$CPPFLAGS $WERROR_FLAGS"
73fi
74
Maxeffdec62017-12-28 14:18:02 +010075AC_ARG_ENABLE(profile,
76 [AS_HELP_STRING([--enable-profile], [Compile with profiling support enabled], )],
77 [profile=$enableval], [profile="no"])
78if test x"$profile" = x"yes"
79then
80 CFLAGS="$CFLAGS -pg"
81 CPPFLAGS="$CPPFLAGS -pg"
82fi
83
Harald Welte57f6b022012-06-14 21:05:44 +080084dnl checks for libraries
Pau Espin Pedrol50aa4922021-02-23 14:41:01 +010085PKG_CHECK_MODULES(LIBOSMOCORE, libosmocore >= 1.5.0)
86PKG_CHECK_MODULES(LIBOSMOVTY, libosmovty >= 1.5.0)
87PKG_CHECK_MODULES(LIBOSMOCTRL, libosmoctrl >= 1.5.0)
88PKG_CHECK_MODULES(LIBOSMOGSM, libosmogsm >= 1.5.0)
89PKG_CHECK_MODULES(LIBOSMOGB, libosmogb >= 1.5.0)
Harald Welte57f6b022012-06-14 21:05:44 +080090
Andreas Eversberga23c7ee2012-12-18 10:47:28 +010091AC_MSG_CHECKING([whether to enable direct DSP access for PDCH of sysmocom-bts])
92AC_ARG_ENABLE(sysmocom-dsp,
Neels Hofmeyra661bcd2018-03-29 16:47:41 +020093 AC_HELP_STRING([--enable-sysmocom-dsp],
94 [enable code for direct sysmocom DSP access[default=no]]),
95 [enable_sysmocom_dsp="$enableval"], [enable_sysmocom_dsp="unset"])
96AC_ARG_WITH([sysmobts],
97 [AS_HELP_STRING([--with-sysmobts=INCLUDE_DIR],
98 [Location of the sysmobts API header files, implies --enable-sysmocom-dsp])],
99 [sysmobts_incdir="$withval"], [sysmobts_incdir=""])
100if test "x$sysmobts_incdir" != "x"; then
101 # --with-sysmobts was passed, imply enable_sysmocom_dsp
102 if test "x$enable_sysmocom_dsp" = "xno"; then
103 AC_MSG_RESULT([error])
104 AC_MSG_ERROR([--with-sysmobts does not work with --disable-sysmocom-dsp])
105 fi
106 enable_sysmocom_dsp="yes"
107 # 'readlink' should make an absolute path, but must not return empty if the path does not exist,
108 # so we can still report on it below.
109 sysmobts_incdir="$(readlink -fm "$sysmobts_incdir")"
110 AC_SUBST([SYSMOBTS_INCDIR], $sysmobts_incdir)
111 AC_MSG_RESULT([yes, using -I$SYSMOBTS_INCDIR])
112else
113 AC_SUBST([SYSMOBTS_INCDIR], "")
114 AC_MSG_RESULT([$enable_sysmocom_dsp])
115fi
Andreas Eversberga23c7ee2012-12-18 10:47:28 +0100116AM_CONDITIONAL(ENABLE_SYSMODSP, test "x$enable_sysmocom_dsp" = "xyes")
Neels Hofmeyra661bcd2018-03-29 16:47:41 +0200117if test "x$enable_sysmocom_dsp" = "xyes"; then
118 oldCPPFLAGS="$CPPFLAGS"
119 _sysmobts_include=""
120 _sysmobts_include_msg=""
121 if test -n "$SYSMOBTS_INCDIR"; then
122 _sysmobts_include="-I$SYSMOBTS_INCDIR"
123 _sysmobts_include_msg=" in -I$SYSMOBTS_INCDIR"
124 fi
125 CPPFLAGS="$CPPFLAGS $_sysmobts_include -I$srcdir/include $LIBOSMOCORE_CFLAGS"
Max186206c2018-01-15 16:43:22 +0100126 AC_CHECK_HEADER([sysmocom/femtobts/superfemto.h],[],
Neels Hofmeyra661bcd2018-03-29 16:47:41 +0200127 [AC_MSG_ERROR([sysmocom/femtobts/superfemto.h can not be found$_sysmobts_include_msg, see --with-sysmobts])],
Max186206c2018-01-15 16:43:22 +0100128 [#include <sysmocom/femtobts/superfemto.h>])
Neels Hofmeyra661bcd2018-03-29 16:47:41 +0200129 CPPFLAGS="$oldCPPFLAGS"
Max186206c2018-01-15 16:43:22 +0100130fi
Andreas Eversberga23c7ee2012-12-18 10:47:28 +0100131
Yves Godin660709d2016-05-19 11:08:03 +0200132AC_MSG_CHECKING([whether to enable direct PHY access for PDCH of NuRAN Wireless Litecell 1.5 BTS])
133AC_ARG_ENABLE(lc15bts-phy,
134 AC_HELP_STRING([--enable-lc15bts-phy],
135 [enable code for Litecell 1.5 PHY [default=no]]),
136 [enable_lc15bts_phy="$enableval"],[enable_lc15bts_phy="no"])
137AC_ARG_WITH([litecell15], [AS_HELP_STRING([--with-litecell15=INCLUDE_DIR], [Location of the litecell 1.5 API header files])],
Harald Weltec136be02017-06-11 11:36:33 +0200138 [litecell15_cflags="-I$withval"],[litecell15_cflags=""])
139AC_SUBST([LITECELL15_CFLAGS], $litecell15_cflags)
Yves Godin660709d2016-05-19 11:08:03 +0200140AC_MSG_RESULT([$enable_lc15bts_phy])
141AM_CONDITIONAL(ENABLE_LC15BTS_PHY, test "x$enable_lc15bts_phy" = "xyes")
142if test "$enable_litecell15" = "yes"; then
Neels Hofmeyr9f06cbf2018-03-29 17:04:43 +0200143 oldCPPFLAGS="$CPPFLAGS"
Harald Weltec136be02017-06-11 11:36:33 +0200144 CPPFLAGS="$CPPFLAGS $LITECELL15_CFLAGS -I$srcdir/include $LIBOSMOCORE_CFLAGS"
Yves Godin660709d2016-05-19 11:08:03 +0200145 AC_CHECK_HEADER([nrw/litecell15/litecell15.h],[],
Harald Weltec136be02017-06-11 11:36:33 +0200146 [AC_MSG_ERROR([nrw/litecell15/litecell15.h can not be found using $litecell15_cflags])],
Yves Godin660709d2016-05-19 11:08:03 +0200147 [#include <nrw/litecell15/litecell15.h>])
Neels Hofmeyr9f06cbf2018-03-29 17:04:43 +0200148 CPPFLAGS="$oldCPPFLAGS"
Yves Godin660709d2016-05-19 11:08:03 +0200149fi
150
Jean-Francois Dionnec1e44902017-06-05 14:44:57 -0400151AC_MSG_CHECKING([whether to enable direct PHY access for PDCH of NuRAN Wireless OC-2G BTS])
152AC_ARG_ENABLE(oc2gbts-phy,
153 AC_HELP_STRING([--enable-oc2gbts-phy],
154 [enable code for OC-2G PHY [default=no]]),
155 [enable_oc2gbts_phy="$enableval"],[enable_oc2gbts_phy="no"])
156AC_ARG_WITH([oc2g], [AS_HELP_STRING([--with-oc2g=INCLUDE_DIR], [Location of the OC-2G API header files])],
157 [oc2g_incdir="$withval"],[oc2g_incdir="$incdir"])
158AC_SUBST([OC2G_INCDIR], $oc2g_incdir)
159AC_MSG_RESULT([$enable_oc2gbts_phy])
160AM_CONDITIONAL(ENABLE_OC2GBTS_PHY, test "x$enable_oc2gbts_phy" = "xyes")
161if test "$enable_oc2g" = "yes"; then
162 oldCPPFLAGS=$CPPFLAGS
163 CPPFLAGS="$CPPFLAGS -I$OC2G_INCDIR -I$srcdir/include $LIBOSMOCORE_CFLAGS"
164 AC_CHECK_HEADER([nrw/oc2g/oc2g.h],[],
165 [AC_MSG_ERROR([nrw/oc2g/oc2g.h can not be found in $oc2g_incdir])],
166 [#include <nrw/oc2g/oc2g.h>])
167 CPPFLAGS=$oldCPPFLAGS
168fi
169
Kat7dac4862013-04-05 21:44:46 +0200170AC_ARG_ENABLE([vty_tests],
171 AC_HELP_STRING([--enable-vty-tests],
Ivan Kluchnikovb6bb55d2013-04-24 15:53:25 +0400172 [Include the VTY tests in make check [default=no]]),
173 [enable_vty_tests="$enableval"],[enable_vty_tests="no"])
Kat7dac4862013-04-05 21:44:46 +0200174if test "x$enable_vty_tests" = "xyes" ; then
175 AM_PATH_PYTHON
176 AC_CHECK_PROG(OSMOTESTVTY_CHECK,osmotestvty.py,yes)
177 if test "x$OSMOTESTVTY_CHECK" != "xyes" ; then
178 AC_MSG_ERROR([Please install osmocom-python to run the vty tests.])
179 fi
180fi
181AC_MSG_CHECKING([whether to enable VTY tests])
182AC_MSG_RESULT([$enable_vty_tests])
183AM_CONDITIONAL(ENABLE_VTY_TESTS, test "x$enable_vty_tests" = "xyes")
184
Neels Hofmeyr6348aea2016-09-30 16:25:16 +0200185STD_DEFINES_AND_INCLUDES="-Wall"
186AC_SUBST(STD_DEFINES_AND_INCLUDES)
187
Oliver Smith47aab582018-11-14 10:47:01 +0100188# Generate manuals
189AC_ARG_ENABLE(manuals,
190 [AS_HELP_STRING(
191 [--enable-manuals],
192 [Generate manual PDFs [default=no]],
193 )],
194 [osmo_ac_build_manuals=$enableval], [osmo_ac_build_manuals="no"])
195AM_CONDITIONAL([BUILD_MANUALS], [test x"$osmo_ac_build_manuals" = x"yes"])
196AC_ARG_VAR(OSMO_GSM_MANUALS_DIR, [path to common osmo-gsm-manuals files, overriding pkg-config and "../osmo-gsm-manuals"
197 fallback])
198if test x"$osmo_ac_build_manuals" = x"yes"
199then
200 # Find OSMO_GSM_MANUALS_DIR (env, pkg-conf, fallback)
201 if test -n "$OSMO_GSM_MANUALS_DIR"; then
202 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from env)"
203 else
204 OSMO_GSM_MANUALS_DIR="$($PKG_CONFIG osmo-gsm-manuals --variable=osmogsmmanualsdir 2>/dev/null)"
205 if test -n "$OSMO_GSM_MANUALS_DIR"; then
206 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (from pkg-conf)"
207 else
208 OSMO_GSM_MANUALS_DIR="../osmo-gsm-manuals"
209 echo "checking for OSMO_GSM_MANUALS_DIR... $OSMO_GSM_MANUALS_DIR (fallback)"
210 fi
211 fi
212 if ! test -d "$OSMO_GSM_MANUALS_DIR"; then
213 AC_MSG_ERROR("OSMO_GSM_MANUALS_DIR does not exist! Install osmo-gsm-manuals or set OSMO_GSM_MANUALS_DIR.")
214 fi
215
216 # Find and run check-depends
217 CHECK_DEPENDS="$OSMO_GSM_MANUALS_DIR/check-depends.sh"
218 if ! test -x "$CHECK_DEPENDS"; then
219 CHECK_DEPENDS="osmo-gsm-manuals-check-depends"
220 fi
221 if ! $CHECK_DEPENDS; then
222 AC_MSG_ERROR("missing dependencies for --enable-manuals")
223 fi
224
225 # Put in Makefile with absolute path
226 OSMO_GSM_MANUALS_DIR="$(realpath "$OSMO_GSM_MANUALS_DIR")"
227 AC_SUBST([OSMO_GSM_MANUALS_DIR])
228fi
229
Pau Espin Pedrol516697e2018-09-10 13:28:25 +0200230# https://www.freedesktop.org/software/systemd/man/daemon.html
231AC_ARG_WITH([systemdsystemunitdir],
232 [AS_HELP_STRING([--with-systemdsystemunitdir=DIR], [Directory for systemd service files])],,
233 [with_systemdsystemunitdir=auto])
234AS_IF([test "x$with_systemdsystemunitdir" = "xyes" -o "x$with_systemdsystemunitdir" = "xauto"], [
235 def_systemdsystemunitdir=$($PKG_CONFIG --variable=systemdsystemunitdir systemd)
236
237 AS_IF([test "x$def_systemdsystemunitdir" = "x"],
238 [AS_IF([test "x$with_systemdsystemunitdir" = "xyes"],
239 [AC_MSG_ERROR([systemd support requested but pkg-config unable to query systemd package])])
240 with_systemdsystemunitdir=no],
241 [with_systemdsystemunitdir="$def_systemdsystemunitdir"])])
242AS_IF([test "x$with_systemdsystemunitdir" != "xno"],
243 [AC_SUBST([systemdsystemunitdir], [$with_systemdsystemunitdir])])
244AM_CONDITIONAL([HAVE_SYSTEMD], [test "x$with_systemdsystemunitdir" != "xno"])
245
Neels Hofmeyr5a591942018-03-05 20:44:11 +0100246AC_MSG_RESULT([CPPFLAGS="$CPPFLAGS"])
Pau Espin Pedrol3e9c0712018-09-10 14:50:24 +0200247AC_MSG_RESULT([CFLAGS="$CFLAGS"])
248AC_MSG_RESULT([CXXFLAGS="$CXXFLAGS"])
249AC_MSG_RESULT([LDFLAGS="$LDFLAGS"])
Neels Hofmeyr5a591942018-03-05 20:44:11 +0100250
Harald Welte57f6b022012-06-14 21:05:44 +0800251AC_OUTPUT(
Harald Welte68fc1272016-11-16 22:48:33 +0100252 include/Makefile
Harald Welte57f6b022012-06-14 21:05:44 +0800253 src/Makefile
Pau Espin Pedrolac5e3e22018-09-12 19:14:07 +0200254 doc/Makefile
255 doc/examples/Makefile
Holger Hans Peter Freytherbb007042013-07-28 16:15:41 +0200256 tests/Makefile
Oliver Smith47aab582018-11-14 10:47:01 +0100257 doc/manuals/Makefile
Pau Espin Pedrol516697e2018-09-10 13:28:25 +0200258 contrib/Makefile
259 contrib/systemd/Makefile
Oliver Smithc10cb812020-05-14 11:51:10 +0200260 contrib/osmo-pcu.spec
Harald Welte57f6b022012-06-14 21:05:44 +0800261 Makefile)